FFmpeg
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 "dshow_capture.h"
23 
25  { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
26 DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
27 DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
28 
29 long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
30  AM_MEDIA_TYPE **types, unsigned long *fetched)
31 {
32  int count = 0;
33  dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
34  if (!types)
35  return E_POINTER;
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));
39  if (!type)
40  return E_OUTOFMEMORY;
41  ff_copy_dshow_media_type(type, &this->type);
42  *types = type;
43  count = 1;
44  }
45  this->pos = 1;
46  }
47  if (fetched)
48  *fetched = count;
49  if (!count)
50  return S_FALSE;
51  return S_OK;
52 }
54 {
55  dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
56  if (n) /* Any skip will always fall outside of the only valid type. */
57  return S_FALSE;
58  return S_OK;
59 }
61 {
62  dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
63  this->pos = 0;
64  return S_OK;
65 }
67 {
69  dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
70  if (!enums)
71  return E_POINTER;
73  if (!new)
74  return E_OUTOFMEMORY;
75  new->pos = this->pos;
76  *enums = new;
77  return S_OK;
78 }
79 
80 static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
81 {
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);
90 
91  if (!type) {
92  this->type.majortype = GUID_NULL;
93  } else {
94  ff_copy_dshow_media_type(&this->type, type);
95  }
96 
97  return 1;
98 }
99 DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
#define DECLARE_ADDREF(prefix, class)
Definition: dshow_capture.h:94
DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,{{&IID_IUnknown, 0},{&IID_IEnumMediaTypes, 0}})
static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
#define dshowdebug(...)
Definition: dshow_capture.h:50
long ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
GLint GLenum type
Definition: opengl_enc.c:104
#define av_malloc(s)
long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
Definition: dshow_common.c:24
unsigned int pos
Definition: spdifenc.c:412
GLsizei count
Definition: opengl_enc.c:108
#define DECLARE_RELEASE(prefix, class)
#define DECLARE_DESTROY(prefix, class, func)
long ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
static void nothing(void *foo)
Definition: dshow_capture.h:52
#define SETVTBL(vtbl, prefix, fn)
long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *)
#define DECLARE_CREATE(prefix, class, setup,...)
DShowEnumMediaTypes * ff_dshow_enummediatypes_Create(const AM_MEDIA_TYPE *type)
long ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)