2 * DirectShow capture interface
3 * Copyright (c) 2010 Ramiro Polla
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "dshow_capture.h"
24 DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,
25 { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
26 DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
27 DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
29 long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
30 AM_MEDIA_TYPE **types, unsigned long *fetched)
33 dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
36 if (!this->pos && n == 1) {
37 if (!IsEqualGUID(&this->type.majortype, &GUID_NULL)) {
38 AM_MEDIA_TYPE *type = av_malloc(sizeof(AM_MEDIA_TYPE));
41 ff_copy_dshow_media_type(type, &this->type);
53 long ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
55 dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
56 if (n) /* Any skip will always fall outside of the only valid type. */
60 long ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
62 dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
66 long ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
68 DShowEnumMediaTypes *new;
69 dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
72 new = ff_dshow_enummediatypes_Create(&this->type);
80 static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
82 IEnumMediaTypesVtbl *vtbl = this->vtbl;
83 SETVTBL(vtbl, enummediatypes, QueryInterface);
84 SETVTBL(vtbl, enummediatypes, AddRef);
85 SETVTBL(vtbl, enummediatypes, Release);
86 SETVTBL(vtbl, enummediatypes, Next);
87 SETVTBL(vtbl, enummediatypes, Skip);
88 SETVTBL(vtbl, enummediatypes, Reset);
89 SETVTBL(vtbl, enummediatypes, Clone);
92 this->type.majortype = GUID_NULL;
94 ff_copy_dshow_media_type(&this->type, type);
99 DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
100 DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)