Go to the documentation of this file.
26 #define imemoffset offsetof(DShowPin, imemvtbl)
29 { {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,
imemoffset} })
40 const AM_MEDIA_TYPE *
type)
43 dshowdebug(
"ff_dshow_pin_ReceiveConnection(%p)\n",
this);
47 if (this->connectedto)
48 return VFW_E_ALREADY_CONNECTED;
52 if (!IsEqualGUID(&
type->majortype, &MEDIATYPE_Video))
53 return VFW_E_TYPE_NOT_ACCEPTED;
55 if (!IsEqualGUID(&
type->majortype, &MEDIATYPE_Audio))
56 return VFW_E_TYPE_NOT_ACCEPTED;
60 this->connectedto = pin;
68 dshowdebug(
"ff_dshow_pin_Disconnect(%p)\n",
this);
70 if (this->
filter->state != State_Stopped)
71 return VFW_E_NOT_STOPPED;
72 if (!this->connectedto)
74 IPin_Release(this->connectedto);
75 this->connectedto =
NULL;
81 dshowdebug(
"ff_dshow_pin_ConnectedTo(%p)\n",
this);
85 if (!this->connectedto)
86 return VFW_E_NOT_CONNECTED;
87 IPin_AddRef(this->connectedto);
88 *pin = this->connectedto;
94 dshowdebug(
"ff_dshow_pin_ConnectionMediaType(%p)\n",
this);
98 if (!this->connectedto)
99 return VFW_E_NOT_CONNECTED;
105 dshowdebug(
"ff_dshow_pin_QueryPinInfo(%p)\n",
this);
113 info->pFilter = (IBaseFilter *) this->
filter;
114 info->dir = PINDIR_INPUT;
115 wcscpy(
info->achName,
L"Capture");
121 dshowdebug(
"ff_dshow_pin_QueryDirection(%p)\n",
this);
129 dshowdebug(
"ff_dshow_pin_QueryId(%p)\n",
this);
134 *
id = wcsdup(
L"libAV Pin");
140 dshowdebug(
"ff_dshow_pin_QueryAccept(%p)\n",
this);
147 dshowdebug(
"ff_dshow_pin_EnumMediaTypes(%p)\n",
this);
153 return E_OUTOFMEMORY;
155 *enumtypes = (IEnumMediaTypes *)
new;
161 dshowdebug(
"ff_dshow_pin_QueryInternalConnections(%p)\n",
this);
166 dshowdebug(
"ff_dshow_pin_EndOfStream(%p)\n",
this);
172 dshowdebug(
"ff_dshow_pin_BeginFlush(%p)\n",
this);
178 dshowdebug(
"ff_dshow_pin_EndFlush(%p)\n",
this);
185 dshowdebug(
"ff_dshow_pin_NewSegment(%p)\n",
this);
192 IPinVtbl *vtbl = this->vtbl;
193 IMemInputPinVtbl *imemvtbl;
198 imemvtbl =
av_malloc(
sizeof(IMemInputPinVtbl));
202 SETVTBL(imemvtbl, meminputpin, QueryInterface);
203 SETVTBL(imemvtbl, meminputpin, AddRef);
204 SETVTBL(imemvtbl, meminputpin, Release);
205 SETVTBL(imemvtbl, meminputpin, GetAllocator);
206 SETVTBL(imemvtbl, meminputpin, NotifyAllocator);
207 SETVTBL(imemvtbl, meminputpin, GetAllocatorRequirements);
208 SETVTBL(imemvtbl, meminputpin, Receive);
209 SETVTBL(imemvtbl, meminputpin, ReceiveMultiple);
210 SETVTBL(imemvtbl, meminputpin, ReceiveCanBlock);
212 this->imemvtbl = imemvtbl;
214 SETVTBL(vtbl, pin, QueryInterface);
218 SETVTBL(vtbl, pin, ReceiveConnection);
219 SETVTBL(vtbl, pin, Disconnect);
220 SETVTBL(vtbl, pin, ConnectedTo);
221 SETVTBL(vtbl, pin, ConnectionMediaType);
222 SETVTBL(vtbl, pin, QueryPinInfo);
223 SETVTBL(vtbl, pin, QueryDirection);
225 SETVTBL(vtbl, pin, QueryAccept);
226 SETVTBL(vtbl, pin, EnumMediaTypes);
227 SETVTBL(vtbl, pin, QueryInternalConnections);
228 SETVTBL(vtbl, pin, EndOfStream);
229 SETVTBL(vtbl, pin, BeginFlush);
231 SETVTBL(vtbl, pin, NewSegment);
243 if (this->
type.pbFormat) {
244 CoTaskMemFree(this->
type.pbFormat);
258 dshowdebug(
"ff_dshow_meminputpin_QueryInterface(%p)\n",
this);
264 dshowdebug(
"ff_dshow_meminputpin_AddRef(%p)\n",
this);
270 dshowdebug(
"ff_dshow_meminputpin_Release(%p)\n",
this);
275 dshowdebug(
"ff_dshow_meminputpin_GetAllocator(%p)\n",
this);
276 return VFW_E_NO_ALLOCATOR;
281 dshowdebug(
"ff_dshow_meminputpin_NotifyAllocator(%p)\n",
this);
285 ALLOCATOR_PROPERTIES *props)
287 dshowdebug(
"ff_dshow_meminputpin_GetAllocatorRequirements(%p)\n",
this);
302 int use_sample_time = 1;
303 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio";
310 dshowdebug(
"ff_dshow_meminputpin_Receive(%p)\n",
this);
319 hr = IMediaSample_GetTime(
sample, &sampletime, &
dummy);
320 IReferenceClock_GetTime(clock, &graphtime);
321 if (devtype ==
VideoDevice && !
ctx->use_video_device_timestamps) {
323 chosentime = graphtime;
326 if (hr == VFW_E_SAMPLE_TIME_NOT_SET || sampletime == 0) {
327 chosentime = graphtime;
330 "frame with missing sample timestamp encountered, falling back to graph timestamp\n");
332 else if (sampletime > 400000000000000000LL) {
337 "dropping initial (or ending) sample with odd PTS too high %"PRId64
"\n", sampletime);
340 chosentime = sampletime;
347 buf_size = IMediaSample_GetActualDataLength(
sample);
348 IMediaSample_GetPointer(
sample, &buf);
352 "timestamp %"PRId64
" orig timestamp %"PRId64
" graph timestamp %"PRId64
" diff %"PRId64
" %s\n",
353 devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime,
ctx->device_name[devtype]);
359 IMediaSample **
samples,
long n,
long *nproc)
362 dshowdebug(
"ff_dshow_meminputpin_ReceiveMultiple(%p)\n",
this);
364 for (
i = 0;
i < n;
i++)
372 dshowdebug(
"ff_dshow_meminputpin_ReceiveCanBlock(%p)\n",
this);
380 dshowdebug(
"ff_dshow_meminputpin_Destroy(%p)\n",
this);
long WINAPI ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
#define DECLARE_CREATE(prefix, class, setup,...)
long WINAPI ff_dshow_meminputpin_QueryInterface(DShowMemInputPin *this, const GUID *riid, void **ppvObject)
unsigned long WINAPI ff_dshow_meminputpin_AddRef(DShowMemInputPin *this)
long WINAPI ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *this, ALLOCATOR_PROPERTIES *props)
long WINAPI ff_dshow_pin_QueryInterface(DShowPin *, const GUID *, void **)
unsigned long WINAPI ff_dshow_pin_Release(DShowPin *)
long WINAPI ff_dshow_pin_BeginFlush(DShowPin *this)
long WINAPI ff_dshow_pin_QueryInternalConnections(DShowPin *this, IPin **pin, unsigned long *npin)
#define AV_LOG_VERBOSE
Detailed information.
void(* filter)(uint8_t *src, int stride, int qscale)
long WINAPI ff_dshow_pin_EndOfStream(DShowPin *this)
long WINAPI ff_dshow_pin_ConnectionMediaType(DShowPin *this, AM_MEDIA_TYPE *type)
void ff_dshow_pin_Destroy(DShowPin *)
long WINAPI ff_dshow_pin_EnumMediaTypes(DShowPin *this, IEnumMediaTypes **enumtypes)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
void ff_print_AM_MEDIA_TYPE(const AM_MEDIA_TYPE *type)
#define DECLARE_ADDREF(prefix, class)
long WINAPI ff_dshow_meminputpin_ReceiveCanBlock(DShowMemInputPin *this)
long WINAPI ff_dshow_pin_ConnectedTo(DShowPin *this, IPin **pin)
static void ff_dshow_pin_Free(DShowPin *this)
long WINAPI ff_dshow_pin_EndFlush(DShowPin *this)
long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum dshowDeviceType type
#define SETVTBL(vtbl, prefix, fn)
long WINAPI ff_dshow_pin_QueryPinInfo(DShowPin *this, PIN_INFO *info)
long WINAPI ff_dshow_meminputpin_GetAllocator(DShowMemInputPin *this, IMemAllocator **alloc)
DShowEnumMediaTypes * ff_dshow_enummediatypes_Create(const AM_MEDIA_TYPE *type)
long WINAPI ff_dshow_pin_NewSegment(DShowPin *this, REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
long WINAPI ff_dshow_pin_ReceiveConnection(DShowPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
struct DShowMemInputPin DShowMemInputPin
long WINAPI ff_dshow_pin_QueryDirection(DShowPin *this, PIN_DIRECTION *dir)
#define DECLARE_DESTROY(prefix, class, func)
unsigned long WINAPI ff_dshow_meminputpin_Release(DShowMemInputPin *this)
long WINAPI ff_dshow_pin_Disconnect(DShowPin *this)
#define i(width, name, range_min, range_max)
static int ff_dshow_pin_Setup(DShowPin *this, DShowFilter *filter)
void ff_dshow_meminputpin_Destroy(DShowMemInputPin *this)
unsigned long WINAPI ff_dshow_filter_AddRef(DShowFilter *)
#define DECLARE_RELEASE(prefix, class)
long WINAPI ff_dshow_pin_QueryAccept(DShowPin *this, const AM_MEDIA_TYPE *type)
Filter the word “frame” indicates either a video frame or a group of audio samples
unsigned long WINAPI ff_dshow_pin_AddRef(DShowPin *)
DECLARE_QUERYINTERFACE(pin, DShowPin, { {&IID_IUnknown, 0}, {&IID_IPin, 0}, {&IID_IMemInputPin, imemoffset} })
long WINAPI ff_dshow_pin_Connect(DShowPin *, IPin *, const AM_MEDIA_TYPE *)
long WINAPI ff_dshow_meminputpin_ReceiveMultiple(DShowMemInputPin *this, IMediaSample **samples, long n, long *nproc)
long WINAPI ff_dshow_pin_QueryId(DShowPin *this, wchar_t **id)
long WINAPI ff_dshow_meminputpin_NotifyAllocator(DShowMemInputPin *this, IMemAllocator *alloc, BOOL rdwr)
void(* callback)(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType type)