123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #include "libavutil/mem.h"
- #include "dshow_capture.h"
- DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,
- { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
- DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
- DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
- long WINAPI ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
- AM_MEDIA_TYPE **types, unsigned long *fetched)
- {
- int count = 0;
- dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
- if (!types)
- return E_POINTER;
- if (!this->pos && n == 1) {
- if (!IsEqualGUID(&this->type.majortype, &GUID_NULL)) {
- AM_MEDIA_TYPE *type = av_malloc(sizeof(AM_MEDIA_TYPE));
- if (!type)
- return E_OUTOFMEMORY;
- ff_copy_dshow_media_type(type, &this->type);
- *types = type;
- count = 1;
- }
- this->pos = 1;
- }
- if (fetched)
- *fetched = count;
- if (!count)
- return S_FALSE;
- return S_OK;
- }
- long WINAPI ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
- {
- dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
- if (n)
- return S_FALSE;
- return S_OK;
- }
- long WINAPI ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
- {
- dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
- this->pos = 0;
- return S_OK;
- }
- long WINAPI ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
- {
- DShowEnumMediaTypes *new;
- dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
- if (!enums)
- return E_POINTER;
- new = ff_dshow_enummediatypes_Create(&this->type);
- if (!new)
- return E_OUTOFMEMORY;
- new->pos = this->pos;
- *enums = new;
- return S_OK;
- }
- static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
- {
- IEnumMediaTypesVtbl *vtbl = this->vtbl;
- SETVTBL(vtbl, enummediatypes, QueryInterface);
- SETVTBL(vtbl, enummediatypes, AddRef);
- SETVTBL(vtbl, enummediatypes, Release);
- SETVTBL(vtbl, enummediatypes, Next);
- SETVTBL(vtbl, enummediatypes, Skip);
- SETVTBL(vtbl, enummediatypes, Reset);
- SETVTBL(vtbl, enummediatypes, Clone);
- if (!type) {
- this->type.majortype = GUID_NULL;
- } else {
- ff_copy_dshow_media_type(&this->type, type);
- }
- return 1;
- }
- DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
- DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)
|