ReactOS 0.4.17-dev-934-g091855f
samplegrabber.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "qedit_private.h"
#include "wine/debug.h"
Include dependency graph for samplegrabber.c:

Go to the source code of this file.

Classes

struct  sample_grabber
 

Macros

#define COBJMACROS
 

Enumerations

enum  { OneShot_None , OneShot_Wait , OneShot_Past }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (quartz)
 
static struct sample_grabber * impl_from_strmbase_filter (struct strmbase_filter *iface)
 
static struct sample_grabber * impl_from_ISampleGrabber (ISampleGrabber *iface)
 
static struct sample_grabber * impl_from_IMemInputPin (IMemInputPin *iface)
 
static void SampleGrabber_cleanup (struct sample_grabber *This)
 
static struct strmbase_pin * sample_grabber_get_pin (struct strmbase_filter *iface, unsigned int index)
 
static void sample_grabber_destroy (struct strmbase_filter *iface)
 
static HRESULT sample_grabber_query_interface (struct strmbase_filter *iface, REFIID iid, void **out)
 
static void SampleGrabber_callback (struct sample_grabber *This, IMediaSample *sample)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_QueryInterface (ISampleGrabber *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI SampleGrabber_ISampleGrabber_AddRef (ISampleGrabber *iface)
 
static ULONG WINAPI SampleGrabber_ISampleGrabber_Release (ISampleGrabber *iface)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetOneShot (ISampleGrabber *iface, BOOL oneShot)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetMediaType (ISampleGrabber *iface, const AM_MEDIA_TYPE *mt)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetConnectedMediaType (ISampleGrabber *iface, AM_MEDIA_TYPE *mt)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetBufferSamples (ISampleGrabber *iface, BOOL bufferEm)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentBuffer (ISampleGrabber *iface, LONG *bufSize, LONG *buffer)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentSample (ISampleGrabber *iface, IMediaSample **sample)
 
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetCallback (ISampleGrabber *iface, ISampleGrabberCB *cb, LONG whichMethod)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_QueryInterface (IMemInputPin *iface, REFIID iid, void **out)
 
static ULONG WINAPI SampleGrabber_IMemInputPin_AddRef (IMemInputPin *iface)
 
static ULONG WINAPI SampleGrabber_IMemInputPin_Release (IMemInputPin *iface)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocator (IMemInputPin *iface, IMemAllocator **allocator)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_NotifyAllocator (IMemInputPin *iface, IMemAllocator *allocator, BOOL readOnly)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocatorRequirements (IMemInputPin *iface, ALLOCATOR_PROPERTIES *props)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_Receive (IMemInputPin *iface, IMediaSample *sample)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveMultiple (IMemInputPin *iface, IMediaSample **samples, LONG nSamples, LONG *nProcessed)
 
static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveCanBlock (IMemInputPin *iface)
 
static struct sample_grabber * impl_from_sink_pin (struct strmbase_pin *iface)
 
static HRESULT sample_grabber_sink_query_interface (struct strmbase_pin *iface, REFIID iid, void **out)
 
static BOOL check_filter_mt (struct sample_grabber *filter, const AM_MEDIA_TYPE *mt)
 
static HRESULT sample_grabber_sink_query_accept (struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
 
static HRESULT sample_grabber_sink_get_media_type (struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
 
static struct sample_grabber * impl_from_source_pin (struct strmbase_pin *iface)
 
static HRESULT sample_grabber_source_query_interface (struct strmbase_pin *iface, REFIID iid, void **out)
 
static HRESULT sample_grabber_source_query_accept (struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
 
static HRESULT sample_grabber_source_get_media_type (struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
 
static BOOL compare_media_types (const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b)
 
static HRESULT WINAPI sample_grabber_source_DecideAllocator (struct strmbase_source *iface, IMemInputPin *peer, IMemAllocator **allocator)
 
HRESULT sample_grabber_create (IUnknown *outer, IUnknown **out)
 

Variables

static const struct strmbase_filter_ops filter_ops
 
static const ISampleGrabberVtbl ISampleGrabber_VTable
 
static const IMemInputPinVtbl IMemInputPin_VTable
 
static const struct strmbase_sink_ops sink_ops
 
static const struct strmbase_source_ops source_ops
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file samplegrabber.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OneShot_None 
OneShot_Wait 
OneShot_Past 

Definition at line 55 of file samplegrabber.c.

55 {
59};
@ OneShot_Wait
Definition: samplegrabber.c:57
@ OneShot_None
Definition: samplegrabber.c:56
@ OneShot_Past
Definition: samplegrabber.c:58

Function Documentation

◆ check_filter_mt()

static BOOL check_filter_mt ( struct sample_grabber *  filter,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 481 of file samplegrabber.c.

482{
483 if (IsEqualGUID(&filter->filter_mt.majortype, &GUID_NULL))
484 return TRUE;
485 if (!IsEqualGUID(&filter->filter_mt.majortype, &mt->majortype))
486 return FALSE;
487
488 if (IsEqualGUID(&filter->filter_mt.subtype, &GUID_NULL))
489 return TRUE;
490 if (!IsEqualGUID(&filter->filter_mt.subtype, &mt->subtype))
491 return FALSE;
492
493 if (IsEqualGUID(&filter->filter_mt.formattype, &GUID_NULL))
494 return TRUE;
495 if (!IsEqualGUID(&filter->filter_mt.formattype, &mt->formattype))
496 return FALSE;
497
498 return TRUE;
499}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GUID_NULL
Definition: ks.h:106
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: filter.c:165

Referenced by sample_grabber_sink_query_accept(), and sample_grabber_source_query_accept().

◆ compare_media_types()

static BOOL compare_media_types ( const AM_MEDIA_TYPE *  a,
const AM_MEDIA_TYPE *  b 
)
inlinestatic

Definition at line 599 of file samplegrabber.c.

600{
601 return !memcmp(a, b, offsetof(AM_MEDIA_TYPE, pbFormat))
602 && !memcmp(a->pbFormat, b->pbFormat, a->cbFormat);
603}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define offsetof(TYPE, MEMBER)

Referenced by sample_grabber_source_DecideAllocator(), and test_connect_pin().

◆ impl_from_IMemInputPin()

◆ impl_from_ISampleGrabber()

◆ impl_from_sink_pin()

static struct sample_grabber * impl_from_sink_pin ( struct strmbase_pin *  iface)
static

Definition at line 463 of file samplegrabber.c.

464{
465 return CONTAINING_RECORD(iface, struct sample_grabber, sink.pin);
466}
GLsizei GLenum GLboolean sink
Definition: glext.h:5672

Referenced by sample_grabber_sink_get_media_type(), sample_grabber_sink_query_accept(), and sample_grabber_sink_query_interface().

◆ impl_from_source_pin()

◆ impl_from_strmbase_filter()

◆ sample_grabber_create()

HRESULT sample_grabber_create ( IUnknown *  outer,
IUnknown **  out 
)

Definition at line 640 of file samplegrabber.c.

641{
642 struct sample_grabber *object;
643
644 if (!(object = calloc(1, sizeof(*object))))
645 return E_OUTOFMEMORY;
646
647 strmbase_filter_init(&object->filter, outer, &CLSID_SampleGrabber, &filter_ops);
648 object->ISampleGrabber_iface.lpVtbl = &ISampleGrabber_VTable;
649 object->IMemInputPin_iface.lpVtbl = &IMemInputPin_VTable;
650
651 strmbase_sink_init(&object->sink, &object->filter, L"In", &sink_ops, NULL);
652 wcscpy(object->sink.pin.name, L"Input");
653
654 strmbase_source_init(&object->source, &object->filter, L"Out", &source_ops);
655 wcscpy(object->source.pin.name, L"Output");
656
657 strmbase_passthrough_init(&object->passthrough, (IUnknown *)&object->source.pin.IPin_iface);
658 ISeekingPassThru_Init(&object->passthrough.ISeekingPassThru_iface, FALSE,
659 &object->sink.pin.IPin_iface);
660
661 object->grabberMethod = -1;
662 object->oneShot = OneShot_None;
663 object->bufferLen = -1;
664
665 TRACE("Created sample grabber %p.\n", object);
666 *out = &object->filter.IUnknown_inner;
667 return S_OK;
668}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
static const IMemInputPinVtbl IMemInputPin_VTable
static const ISampleGrabberVtbl ISampleGrabber_VTable
static const struct strmbase_source_ops source_ops
static const struct strmbase_sink_ops sink_ops
static const struct strmbase_filter_ops filter_ops
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52
static IUnknown * outer
Definition: compobj.c:82
#define calloc
Definition: rosglue.h:14
wcscpy
#define TRACE(s)
Definition: solgame.cpp:4
void strmbase_source_init(struct strmbase_source *pin, struct strmbase_filter *filter, const WCHAR *name, const struct strmbase_source_ops *func_table)
Definition: pin.c:765
void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter, const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator)
Definition: pin.c:1168
void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer)
Definition: pospass.c:725
void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer, const CLSID *clsid, const struct strmbase_filter_ops *func_table)
Definition: filter.c:517
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ sample_grabber_destroy()

static void sample_grabber_destroy ( struct strmbase_filter *  iface)
static

Definition at line 100 of file samplegrabber.c.

101{
103
109 free(filter);
110}
#define free
Definition: debug_ros.c:5
static void SampleGrabber_cleanup(struct sample_grabber *This)
Definition: samplegrabber.c:78
static struct sample_grabber * impl_from_strmbase_filter(struct strmbase_filter *iface)
Definition: samplegrabber.c:61
void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough)
Definition: pospass.c:738
void strmbase_sink_cleanup(struct strmbase_sink *pin)
Definition: pin.c:1185
void strmbase_filter_cleanup(struct strmbase_filter *filter)
Definition: filter.c:540
void strmbase_source_cleanup(struct strmbase_source *pin)
Definition: pin.c:778
IBaseFilter * filter
Definition: filtergraph.c:75

◆ sample_grabber_get_pin()

static struct strmbase_pin * sample_grabber_get_pin ( struct strmbase_filter *  iface,
unsigned int  index 
)
static

Definition at line 89 of file samplegrabber.c.

90{
92
93 if (index == 0)
94 return &filter->sink.pin;
95 else if (index == 1)
96 return &filter->source.pin;
97 return NULL;
98}
GLuint index
Definition: glext.h:6031

◆ sample_grabber_query_interface()

static HRESULT sample_grabber_query_interface ( struct strmbase_filter *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 112 of file samplegrabber.c.

113{
115
116 if (IsEqualGUID(iid, &IID_ISampleGrabber))
117 *out = &filter->ISampleGrabber_iface;
118 else
119 return E_NOINTERFACE;
120
121 IUnknown_AddRef((IUnknown *)*out);
122 return S_OK;
123}
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ sample_grabber_sink_get_media_type()

static HRESULT sample_grabber_sink_get_media_type ( struct strmbase_pin *  iface,
unsigned int  index,
AM_MEDIA_TYPE *  mt 
)
static

Definition at line 508 of file samplegrabber.c.

510{
512 IEnumMediaTypes *enummt;
513 AM_MEDIA_TYPE *pmt;
514 HRESULT hr;
515
516 if (!filter->source.pin.peer)
517 return VFW_E_NOT_CONNECTED;
518
519 if (FAILED(hr = IPin_EnumMediaTypes(filter->source.pin.peer, &enummt)))
520 return hr;
521
522 if ((!index || IEnumMediaTypes_Skip(enummt, index) == S_OK)
523 && IEnumMediaTypes_Next(enummt, 1, &pmt, NULL) == S_OK)
524 {
525 CopyMediaType(mt, pmt);
526 DeleteMediaType(pmt);
527 IEnumMediaTypes_Release(enummt);
528 return S_OK;
529 }
530
531 IEnumMediaTypes_Release(enummt);
532 return VFW_S_NO_MORE_ITEMS;
533}
HRESULT hr
Definition: delayimp.cpp:582
static struct sample_grabber * impl_from_sink_pin(struct strmbase_pin *iface)
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: mediatype.c:150
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:193
#define VFW_S_NO_MORE_ITEMS
Definition: vfwmsgs.h:19
#define VFW_E_NOT_CONNECTED
Definition: vfwmsgs.h:48

◆ sample_grabber_sink_query_accept()

static HRESULT sample_grabber_sink_query_accept ( struct strmbase_pin *  iface,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 501 of file samplegrabber.c.

502{
504
505 return check_filter_mt(filter, mt) ? S_OK : S_FALSE;
506}
static BOOL check_filter_mt(struct sample_grabber *filter, const AM_MEDIA_TYPE *mt)
#define S_FALSE
Definition: winerror.h:3451

◆ sample_grabber_sink_query_interface()

static HRESULT sample_grabber_sink_query_interface ( struct strmbase_pin *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 468 of file samplegrabber.c.

469{
471
472 if (IsEqualGUID(iid, &IID_IMemInputPin))
473 *out = &filter->IMemInputPin_iface;
474 else
475 return E_NOINTERFACE;
476
477 IUnknown_AddRef((IUnknown *)*out);
478 return S_OK;
479}

◆ sample_grabber_source_DecideAllocator()

static HRESULT WINAPI sample_grabber_source_DecideAllocator ( struct strmbase_source *  iface,
IMemInputPin *  peer,
IMemAllocator **  allocator 
)
static

Definition at line 605 of file samplegrabber.c.

607{
609 const AM_MEDIA_TYPE *mt = &iface->pin.mt;
610
611 if (!compare_media_types(mt, &filter->sink.pin.mt))
612 {
614 HRESULT hr;
615
616 if (FAILED(hr = IFilterGraph_QueryInterface(filter->filter.graph,
617 &IID_IFilterGraph2, (void **)&graph)))
618 {
619 ERR("Failed to get IFilterGraph2 interface, hr %#lx.\n", hr);
620 return hr;
621 }
622
623 hr = IFilterGraph2_ReconnectEx(graph, &filter->sink.pin.IPin_iface, mt);
624 IFilterGraph2_Release(graph);
625 return hr;
626 }
627
628 return S_OK;
629}
#define ERR(fmt,...)
Definition: precomp.h:57
static BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b)
static struct sample_grabber * impl_from_source_pin(struct strmbase_pin *iface)
Definition: graph.c:32
struct strmbase_pin pin
Definition: strmbase.h:79

◆ sample_grabber_source_get_media_type()

static HRESULT sample_grabber_source_get_media_type ( struct strmbase_pin *  iface,
unsigned int  index,
AM_MEDIA_TYPE *  mt 
)
static

Definition at line 572 of file samplegrabber.c.

574{
576 IEnumMediaTypes *enummt;
577 AM_MEDIA_TYPE *pmt;
578 HRESULT hr;
579
580 if (!filter->sink.pin.peer)
581 return VFW_E_NOT_CONNECTED;
582
583 if (FAILED(hr = IPin_EnumMediaTypes(filter->sink.pin.peer, &enummt)))
584 return hr;
585
586 if ((!index || IEnumMediaTypes_Skip(enummt, index) == S_OK)
587 && IEnumMediaTypes_Next(enummt, 1, &pmt, NULL) == S_OK)
588 {
589 CopyMediaType(mt, pmt);
590 DeleteMediaType(pmt);
591 IEnumMediaTypes_Release(enummt);
592 return S_OK;
593 }
594
595 IEnumMediaTypes_Release(enummt);
596 return VFW_S_NO_MORE_ITEMS;
597}

◆ sample_grabber_source_query_accept()

static HRESULT sample_grabber_source_query_accept ( struct strmbase_pin *  iface,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 562 of file samplegrabber.c.

563{
565
566 if (filter->sink.pin.peer && IPin_QueryAccept(filter->sink.pin.peer, mt) != S_OK)
567 return S_FALSE;
568
569 return check_filter_mt(filter, mt) ? S_OK : S_FALSE;
570}

◆ sample_grabber_source_query_interface()

static HRESULT sample_grabber_source_query_interface ( struct strmbase_pin *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 547 of file samplegrabber.c.

548{
550
551 if (IsEqualGUID(iid, &IID_IMediaPosition))
552 *out = &filter->passthrough.IMediaPosition_iface;
553 else if (IsEqualGUID(iid, &IID_IMediaSeeking))
554 *out = &filter->passthrough.IMediaSeeking_iface;
555 else
556 return E_NOINTERFACE;
557
558 IUnknown_AddRef((IUnknown *)*out);
559 return S_OK;
560}
IMediaSeeking IMediaSeeking_iface
Definition: filter.c:167

◆ SampleGrabber_callback()

static void SampleGrabber_callback ( struct sample_grabber *  This,
IMediaSample *  sample 
)
static

Definition at line 133 of file samplegrabber.c.

134{
135 double time = 0.0;
136 REFERENCE_TIME tStart, tEnd;
137 if (This->bufferLen >= 0) {
138 BYTE *data = 0;
139 LONG size = IMediaSample_GetActualDataLength(sample);
140 if (size >= 0 && SUCCEEDED(IMediaSample_GetPointer(sample, &data))) {
141 if (!data)
142 size = 0;
143 EnterCriticalSection(&This->filter.filter_cs);
144 if (This->bufferLen != size) {
145 CoTaskMemFree(This->bufferData);
146 This->bufferData = size ? CoTaskMemAlloc(size) : NULL;
147 This->bufferLen = size;
148 }
149 if (size)
150 CopyMemory(This->bufferData, data, size);
151 LeaveCriticalSection(&This->filter.filter_cs);
152 }
153 }
154 if (!This->grabberIface)
155 return;
156 if (SUCCEEDED(IMediaSample_GetTime(sample, &tStart, &tEnd)))
157 time = 1e-7 * tStart;
158 switch (This->grabberMethod) {
159 case 0:
160 {
161 ULONG ref = IMediaSample_AddRef(sample);
162 ISampleGrabberCB_SampleCB(This->grabberIface, time, sample);
163 ref = IMediaSample_Release(sample) + 1 - ref;
164 if (ref)
165 {
166 ERR("(%p) Callback referenced sample %p by %lu\n", This, sample, ref);
167 }
168 }
169 break;
170 case 1:
171 {
172 BYTE *data = 0;
173 LONG size = IMediaSample_GetActualDataLength(sample);
174 if (size && SUCCEEDED(IMediaSample_GetPointer(sample, &data)) && data)
175 ISampleGrabberCB_BufferCB(This->grabberIface, time, data, size);
176 }
177 break;
178 case -1:
179 break;
180 default:
181 FIXME("Unknown method %ld.\n", This->grabberMethod);
182 /* do not bother us again */
183 This->grabberMethod = -1;
184 }
185}
#define FIXME(fmt,...)
Definition: precomp.h:53
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define e
Definition: ke_i.h:82
#define CopyMemory
Definition: minwinbase.h:29
__u16 time
Definition: mkdosfs.c:8
long LONG
Definition: pedump.c:60
Definition: send.c:48
Definition: wave.c:25
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SampleGrabber_IMemInputPin_Receive(), and SampleGrabber_IMemInputPin_ReceiveMultiple().

◆ SampleGrabber_cleanup()

static void SampleGrabber_cleanup ( struct sample_grabber *  This)
static

Definition at line 78 of file samplegrabber.c.

79{
80 TRACE("(%p)\n", This);
81 if (This->allocator)
82 IMemAllocator_Release(This->allocator);
83 if (This->grabberIface)
84 ISampleGrabberCB_Release(This->grabberIface);
85 FreeMediaType(&This->filter_mt);
86 CoTaskMemFree(This->bufferData);
87}
void WINAPI FreeMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:165

Referenced by sample_grabber_destroy().

◆ SampleGrabber_IMemInputPin_AddRef()

static ULONG WINAPI SampleGrabber_IMemInputPin_AddRef ( IMemInputPin *  iface)
static

Definition at line 333 of file samplegrabber.c.

334{
336 return IPin_AddRef(&filter->sink.pin.IPin_iface);
337}
static struct sample_grabber * impl_from_IMemInputPin(IMemInputPin *iface)
Definition: samplegrabber.c:71

◆ SampleGrabber_IMemInputPin_GetAllocator()

static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocator ( IMemInputPin *  iface,
IMemAllocator **  allocator 
)
static

Definition at line 347 of file samplegrabber.c.

348{
350 TRACE("(%p)->(%p) allocator = %p\n", This, allocator, This->allocator);
351 if (!allocator)
352 return E_POINTER;
353 *allocator = This->allocator;
354 if (!*allocator)
355 return VFW_E_NO_ALLOCATOR;
356 IMemAllocator_AddRef(*allocator);
357 return S_OK;
358}
#define VFW_E_NO_ALLOCATOR
Definition: vfwmsgs.h:49
#define E_POINTER
Definition: winerror.h:3480

◆ SampleGrabber_IMemInputPin_GetAllocatorRequirements()

static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocatorRequirements ( IMemInputPin *  iface,
ALLOCATOR_PROPERTIES *  props 
)
static

Definition at line 378 of file samplegrabber.c.

379{
381 FIXME("(%p)->(%p): semi-stub\n", This, props);
382 if (!props)
383 return E_POINTER;
384 return This->source.pMemInputPin ? IMemInputPin_GetAllocatorRequirements(This->source.pMemInputPin, props) : E_NOTIMPL;
385}
#define E_NOTIMPL
Definition: ddrawi.h:99
static const WCHAR props[]
Definition: wbemdisp.c:288

◆ SampleGrabber_IMemInputPin_NotifyAllocator()

static HRESULT WINAPI SampleGrabber_IMemInputPin_NotifyAllocator ( IMemInputPin *  iface,
IMemAllocator *  allocator,
BOOL  readOnly 
)
static

Definition at line 362 of file samplegrabber.c.

363{
365 TRACE("(%p)->(%p, %u) allocator = %p\n", This, allocator, readOnly, This->allocator);
366 if (This->allocator == allocator)
367 return S_OK;
368 if (This->allocator)
369 IMemAllocator_Release(This->allocator);
370 This->allocator = allocator;
371 if (allocator)
372 IMemAllocator_AddRef(allocator);
373 return S_OK;
374}
IMemAllocator * allocator
Definition: samplegrabber.c:46

◆ SampleGrabber_IMemInputPin_QueryInterface()

static HRESULT WINAPI SampleGrabber_IMemInputPin_QueryInterface ( IMemInputPin *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 327 of file samplegrabber.c.

328{
330 return IPin_QueryInterface(&filter->sink.pin.IPin_iface, iid, out);
331}

◆ SampleGrabber_IMemInputPin_Receive()

static HRESULT WINAPI SampleGrabber_IMemInputPin_Receive ( IMemInputPin *  iface,
IMediaSample *  sample 
)
static

Definition at line 389 of file samplegrabber.c.

390{
392 HRESULT hr;
393 TRACE("(%p)->(%p) output = %p, grabber = %p\n", This, sample, This->source.pMemInputPin, This->grabberIface);
394 if (!sample)
395 return E_POINTER;
396 if (This->oneShot == OneShot_Past)
397 return S_FALSE;
399 hr = This->source.pMemInputPin ? IMemInputPin_Receive(This->source.pMemInputPin, sample) : S_OK;
400 if (This->oneShot == OneShot_Wait) {
401 This->oneShot = OneShot_Past;
402 hr = S_FALSE;
403 if (This->source.pin.peer)
404 IPin_EndOfStream(This->source.pin.peer);
405 }
406 return hr;
407}
static void SampleGrabber_callback(struct sample_grabber *This, IMediaSample *sample)

◆ SampleGrabber_IMemInputPin_ReceiveCanBlock()

static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveCanBlock ( IMemInputPin *  iface)
static

Definition at line 429 of file samplegrabber.c.

430{
432 TRACE("(%p)\n", This);
433 return This->source.pMemInputPin ? IMemInputPin_ReceiveCanBlock(This->source.pMemInputPin) : S_OK;
434}

◆ SampleGrabber_IMemInputPin_ReceiveMultiple()

static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveMultiple ( IMemInputPin *  iface,
IMediaSample **  samples,
LONG  nSamples,
LONG *  nProcessed 
)
static

Definition at line 411 of file samplegrabber.c.

412{
414 LONG idx;
415
416 TRACE("filter %p, samples %p, count %lu, ret_count %p.\n", This, samples, nSamples, nProcessed);
417
418 if (!samples || !nProcessed)
419 return E_POINTER;
420 if ((This->filter.state != State_Running) || (This->oneShot == OneShot_Past))
421 return S_FALSE;
422 for (idx = 0; idx < nSamples; idx++)
424 return This->source.pMemInputPin ? IMemInputPin_ReceiveMultiple(This->source.pMemInputPin, samples, nSamples, nProcessed) : S_OK;
425}
unsigned int idx
Definition: utils.c:40
GLsizei samples
Definition: glext.h:7006

◆ SampleGrabber_IMemInputPin_Release()

static ULONG WINAPI SampleGrabber_IMemInputPin_Release ( IMemInputPin *  iface)
static

Definition at line 339 of file samplegrabber.c.

340{
342 return IPin_Release(&filter->sink.pin.IPin_iface);
343}

◆ SampleGrabber_ISampleGrabber_AddRef()

static ULONG WINAPI SampleGrabber_ISampleGrabber_AddRef ( ISampleGrabber *  iface)
static

Definition at line 197 of file samplegrabber.c.

198{
200 return IUnknown_AddRef(filter->filter.outer_unk);
201}
static struct sample_grabber * impl_from_ISampleGrabber(ISampleGrabber *iface)
Definition: samplegrabber.c:66

◆ SampleGrabber_ISampleGrabber_GetConnectedMediaType()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetConnectedMediaType ( ISampleGrabber *  iface,
AM_MEDIA_TYPE *  mt 
)
static

Definition at line 239 of file samplegrabber.c.

240{
242
243 TRACE("filter %p, mt %p.\n", filter, mt);
244
245 if (!mt)
246 return E_POINTER;
247
248 if (!filter->sink.pin.peer)
249 return VFW_E_NOT_CONNECTED;
250
251 CopyMediaType(mt, &filter->sink.pin.mt);
252 return S_OK;
253}

◆ SampleGrabber_ISampleGrabber_GetCurrentBuffer()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentBuffer ( ISampleGrabber *  iface,
LONG *  bufSize,
LONG *  buffer 
)
static

Definition at line 274 of file samplegrabber.c.

275{
277 HRESULT ret = S_OK;
278 TRACE("(%p)->(%p, %p)\n", This, bufSize, buffer);
279 if (!bufSize)
280 return E_POINTER;
281 EnterCriticalSection(&This->filter.filter_cs);
282 if (!This->sink.pin.peer)
284 else if (This->bufferLen < 0)
286 else if (This->bufferLen == 0)
288 else {
289 if (buffer) {
290 if (*bufSize >= This->bufferLen)
291 CopyMemory(buffer, This->bufferData, This->bufferLen);
292 else
294 }
295 *bufSize = This->bufferLen;
296 }
297 LeaveCriticalSection(&This->filter.filter_cs);
298 return ret;
299}
#define E_INVALIDARG
Definition: ddrawi.h:101
return ret
Definition: mutex.c:147
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei bufSize
Definition: glext.h:6040
#define VFW_E_WRONG_STATE
Definition: vfwmsgs.h:78

◆ SampleGrabber_ISampleGrabber_GetCurrentSample()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentSample ( ISampleGrabber *  iface,
IMediaSample **  sample 
)
static

Definition at line 303 of file samplegrabber.c.

304{
305 /* MS doesn't implement it either, no one should call it */
306 WARN("(%p): not implemented\n", sample);
307 return E_NOTIMPL;
308}
#define WARN(fmt,...)
Definition: precomp.h:61

◆ SampleGrabber_ISampleGrabber_QueryInterface()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_QueryInterface ( ISampleGrabber *  iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 189 of file samplegrabber.c.

190{
192 return IUnknown_QueryInterface(filter->filter.outer_unk, riid, ppv);
193}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ SampleGrabber_ISampleGrabber_Release()

static ULONG WINAPI SampleGrabber_ISampleGrabber_Release ( ISampleGrabber *  iface)
static

Definition at line 205 of file samplegrabber.c.

206{
208 return IUnknown_Release(filter->filter.outer_unk);
209}

◆ SampleGrabber_ISampleGrabber_SetBufferSamples()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetBufferSamples ( ISampleGrabber *  iface,
BOOL  bufferEm 
)
static

Definition at line 257 of file samplegrabber.c.

258{
260 TRACE("(%p)->(%u)\n", This, bufferEm);
261 EnterCriticalSection(&This->filter.filter_cs);
262 if (bufferEm) {
263 if (This->bufferLen < 0)
264 This->bufferLen = 0;
265 }
266 else
267 This->bufferLen = -1;
268 LeaveCriticalSection(&This->filter.filter_cs);
269 return S_OK;
270}

◆ SampleGrabber_ISampleGrabber_SetCallback()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetCallback ( ISampleGrabber *  iface,
ISampleGrabberCB *  cb,
LONG  whichMethod 
)
static

Definition at line 312 of file samplegrabber.c.

313{
315
316 TRACE("filter %p, callback %p, method %ld.\n", This, cb, whichMethod);
317
318 if (This->grabberIface)
319 ISampleGrabberCB_Release(This->grabberIface);
320 This->grabberIface = cb;
321 This->grabberMethod = whichMethod;
322 if (cb)
323 ISampleGrabberCB_AddRef(cb);
324 return S_OK;
325}
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118

◆ SampleGrabber_ISampleGrabber_SetMediaType()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetMediaType ( ISampleGrabber *  iface,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 222 of file samplegrabber.c.

223{
225
226 TRACE("filter %p, mt %p.\n", filter, mt);
228
229 if (!mt)
230 return E_POINTER;
231
232 FreeMediaType(&filter->filter_mt);
233 CopyMediaType(&filter->filter_mt, mt);
234 return S_OK;
235}
void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt)
Definition: mediatype.c:58

◆ SampleGrabber_ISampleGrabber_SetOneShot()

static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetOneShot ( ISampleGrabber *  iface,
BOOL  oneShot 
)
static

Definition at line 213 of file samplegrabber.c.

214{
216 TRACE("(%p)->(%u)\n", This, oneShot);
217 This->oneShot = oneShot ? OneShot_Wait : OneShot_None;
218 return S_OK;
219}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( quartz  )

Variable Documentation

◆ filter_ops

const struct strmbase_filter_ops filter_ops
static
Initial value:
=
{
.filter_get_pin = sample_grabber_get_pin,
.filter_destroy = sample_grabber_destroy,
.filter_query_interface = sample_grabber_query_interface,
}
static struct strmbase_pin * sample_grabber_get_pin(struct strmbase_filter *iface, unsigned int index)
Definition: samplegrabber.c:89
static HRESULT sample_grabber_query_interface(struct strmbase_filter *iface, REFIID iid, void **out)
static void sample_grabber_destroy(struct strmbase_filter *iface)

Definition at line 125 of file samplegrabber.c.

Referenced by sample_grabber_create().

◆ IMemInputPin_VTable

const IMemInputPinVtbl IMemInputPin_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveMultiple(IMemInputPin *iface, IMediaSample **samples, LONG nSamples, LONG *nProcessed)
static ULONG WINAPI SampleGrabber_IMemInputPin_Release(IMemInputPin *iface)
static ULONG WINAPI SampleGrabber_IMemInputPin_AddRef(IMemInputPin *iface)
static HRESULT WINAPI SampleGrabber_IMemInputPin_QueryInterface(IMemInputPin *iface, REFIID iid, void **out)
static HRESULT WINAPI SampleGrabber_IMemInputPin_NotifyAllocator(IMemInputPin *iface, IMemAllocator *allocator, BOOL readOnly)
static HRESULT WINAPI SampleGrabber_IMemInputPin_Receive(IMemInputPin *iface, IMediaSample *sample)
static HRESULT WINAPI SampleGrabber_IMemInputPin_ReceiveCanBlock(IMemInputPin *iface)
static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocatorRequirements(IMemInputPin *iface, ALLOCATOR_PROPERTIES *props)
static HRESULT WINAPI SampleGrabber_IMemInputPin_GetAllocator(IMemInputPin *iface, IMemAllocator **allocator)

Definition at line 450 of file samplegrabber.c.

Referenced by sample_grabber_create().

◆ ISampleGrabber_VTable

const ISampleGrabberVtbl ISampleGrabber_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentSample(ISampleGrabber *iface, IMediaSample **sample)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_QueryInterface(ISampleGrabber *iface, REFIID riid, void **ppv)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetCurrentBuffer(ISampleGrabber *iface, LONG *bufSize, LONG *buffer)
static ULONG WINAPI SampleGrabber_ISampleGrabber_AddRef(ISampleGrabber *iface)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetOneShot(ISampleGrabber *iface, BOOL oneShot)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_GetConnectedMediaType(ISampleGrabber *iface, AM_MEDIA_TYPE *mt)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetBufferSamples(ISampleGrabber *iface, BOOL bufferEm)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetCallback(ISampleGrabber *iface, ISampleGrabberCB *cb, LONG whichMethod)
static ULONG WINAPI SampleGrabber_ISampleGrabber_Release(ISampleGrabber *iface)
static HRESULT WINAPI SampleGrabber_ISampleGrabber_SetMediaType(ISampleGrabber *iface, const AM_MEDIA_TYPE *mt)

Definition at line 436 of file samplegrabber.c.

Referenced by sample_grabber_create().

◆ sink_ops

const struct strmbase_sink_ops sink_ops
static
Initial value:
=
{
.base.pin_query_interface = sample_grabber_sink_query_interface,
.base.pin_query_accept = sample_grabber_sink_query_accept,
.base.pin_get_media_type = sample_grabber_sink_get_media_type,
}
static HRESULT sample_grabber_sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
static HRESULT sample_grabber_sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
static HRESULT sample_grabber_sink_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)

Definition at line 535 of file samplegrabber.c.

Referenced by sample_grabber_create().

◆ source_ops

const struct strmbase_source_ops source_ops
static
Initial value:
=
{
.base.pin_query_interface = sample_grabber_source_query_interface,
.base.pin_query_accept = sample_grabber_source_query_accept,
.base.pin_get_media_type = sample_grabber_source_get_media_type,
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
}
static HRESULT sample_grabber_source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
static HRESULT WINAPI sample_grabber_source_DecideAllocator(struct strmbase_source *iface, IMemInputPin *peer, IMemAllocator **allocator)
static HRESULT sample_grabber_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
static HRESULT sample_grabber_source_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt)
Definition: pin.c:710

Definition at line 631 of file samplegrabber.c.

Referenced by sample_grabber_create().