FFmpeg
Loading...
Searching...
No Matches
dshow_enummediatypes.c
Go to the documentation of this file.
1/*
2 * DirectShow capture interface
3 * Copyright (c) 2010 Ramiro Polla
4 *
5 * This file is part of FFmpeg.
6 *
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.
11 *
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.
16 *
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
20 */
21
22#include "libavutil/mem.h"
23#include "dshow_capture.h"
24
26 { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
29
30long WINAPI ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
31 AM_MEDIA_TYPE **types, unsigned long *fetched)
32{
33 int count = 0;
34 dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
35 if (!types)
36 return E_POINTER;
37 if (!this->pos && n == 1) {
38 if (!IsEqualGUID(&this->type.majortype, &GUID_NULL)) {
39 AM_MEDIA_TYPE *type = av_malloc(sizeof(AM_MEDIA_TYPE));
40 if (!type)
41 return E_OUTOFMEMORY;
42 ff_copy_dshow_media_type(type, &this->type);
43 *types = type;
44 count = 1;
45 }
46 this->pos = 1;
47 }
48 if (fetched)
49 *fetched = count;
50 if (!count)
51 return S_FALSE;
52 return S_OK;
53}
54long WINAPI ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
55{
56 dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
57 if (n) /* Any skip will always fall outside of the only valid type. */
58 return S_FALSE;
59 return S_OK;
60}
62{
63 dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
64 this->pos = 0;
65 return S_OK;
66}
68{
70 dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
71 if (!enums)
72 return E_POINTER;
73 new = ff_dshow_enummediatypes_Create(&this->type);
74 if (!new)
75 return E_OUTOFMEMORY;
76 new->pos = this->pos;
77 *enums = new;
78 return S_OK;
79}
80
81static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
82{
83 IEnumMediaTypesVtbl *vtbl = this->vtbl;
84 SETVTBL(vtbl, enummediatypes, QueryInterface);
85 SETVTBL(vtbl, enummediatypes, AddRef);
86 SETVTBL(vtbl, enummediatypes, Release);
87 SETVTBL(vtbl, enummediatypes, Next);
88 SETVTBL(vtbl, enummediatypes, Skip);
89 SETVTBL(vtbl, enummediatypes, Reset);
90 SETVTBL(vtbl, enummediatypes, Clone);
91
92 if (!type) {
93 this->type.majortype = GUID_NULL;
94 } else {
95 ff_copy_dshow_media_type(&this->type, type);
96 }
97
98 return 1;
99}
100DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
#define DECLARE_QUERYINTERFACE(prefix, class,...)
#define DECLARE_CREATE(prefix, class, setup,...)
#define dshowdebug(...)
long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
#define DECLARE_RELEASE(prefix, class)
long WINAPI ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *)
DShowEnumMediaTypes * ff_dshow_enummediatypes_Create(const AM_MEDIA_TYPE *type)
#define DECLARE_ADDREF(prefix, class)
static void nothing(void *foo)
#define SETVTBL(vtbl, prefix, fn)
#define DECLARE_DESTROY(prefix, class, func)
long WINAPI ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
long WINAPI ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
long WINAPI ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
cl_device_type type
Memory handling functions.
#define av_malloc(s)
Definition ops_static.c:52
unsigned int pos
Definition spdifenc.c:431