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} })
28 
29 long WINAPI
31  AM_MEDIA_TYPE **types, unsigned long *fetched)
32 {
33  int count = 0;
34  dshowdebug("libAVEnumMediaTypes_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 }
54 long WINAPI
56 {
57  dshowdebug("libAVEnumMediaTypes_Skip(%p)\n", this);
58  if (n) /* Any skip will always fall outside of the only valid type. */
59  return S_FALSE;
60  return S_OK;
61 }
62 long WINAPI
64 {
65  dshowdebug("libAVEnumMediaTypes_Reset(%p)\n", this);
66  this->pos = 0;
67  return S_OK;
68 }
69 long WINAPI
71 {
73  dshowdebug("libAVEnumMediaTypes_Clone(%p)\n", this);
74  if (!enums)
75  return E_POINTER;
76  new = libAVEnumMediaTypes_Create(&this->type);
77  if (!new)
78  return E_OUTOFMEMORY;
79  new->pos = this->pos;
80  *enums = new;
81  return S_OK;
82 }
83 
84 static int
86 {
87  IEnumMediaTypesVtbl *vtbl = this->vtbl;
88  SETVTBL(vtbl, libAVEnumMediaTypes, QueryInterface);
89  SETVTBL(vtbl, libAVEnumMediaTypes, AddRef);
90  SETVTBL(vtbl, libAVEnumMediaTypes, Release);
91  SETVTBL(vtbl, libAVEnumMediaTypes, Next);
92  SETVTBL(vtbl, libAVEnumMediaTypes, Skip);
93  SETVTBL(vtbl, libAVEnumMediaTypes, Reset);
94  SETVTBL(vtbl, libAVEnumMediaTypes, Clone);
95 
96  if (!type) {
97  this->type.majortype = GUID_NULL;
98  } else {
99  ff_copy_dshow_media_type(&this->type, type);
100  }
101 
102  return 1;
103 }
nothing
static void nothing(void *foo)
Definition: dshow_capture.h:52
n
int n
Definition: avisynth_c.h:760
E_POINTER
#define E_POINTER
Definition: windows2linux.h:43
dshow_capture.h
DECLARE_RELEASE
#define DECLARE_RELEASE(class)
Definition: dshow_capture.h:101
count
void INT64 INT64 count
Definition: avisynth_c.h:767
libAVEnumMediaTypes_Create
libAVEnumMediaTypes * libAVEnumMediaTypes_Create(const AM_MEDIA_TYPE *type)
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
S_OK
#define S_OK
Definition: windows2linux.h:40
libAVEnumMediaTypes_Next
long WINAPI libAVEnumMediaTypes_Next(libAVEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *)
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
libAVEnumMediaTypes_Reset
long WINAPI libAVEnumMediaTypes_Reset(libAVEnumMediaTypes *this)
Definition: dshow_enummediatypes.c:63
DECLARE_ADDREF
#define DECLARE_ADDREF(class)
Definition: dshow_capture.h:94
DECLARE_CREATE
#define DECLARE_CREATE(class, setup,...)
Definition: dshow_capture.h:123
dshowdebug
#define dshowdebug(...)
Definition: dshow_capture.h:50
ff_copy_dshow_media_type
long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
Definition: dshow_common.c:24
SETVTBL
#define SETVTBL(vtbl, class, fn)
Definition: dshow_capture.h:145
libAVEnumMediaTypes_Skip
long WINAPI libAVEnumMediaTypes_Skip(libAVEnumMediaTypes *this, unsigned long n)
Definition: dshow_enummediatypes.c:55
DECLARE_QUERYINTERFACE
DECLARE_QUERYINTERFACE(libAVEnumMediaTypes, { {&IID_IUnknown, 0}, {&IID_IEnumMediaTypes, 0} })
Definition: dshow_enummediatypes.c:24
libAVEnumMediaTypes_Clone
long WINAPI libAVEnumMediaTypes_Clone(libAVEnumMediaTypes *this, libAVEnumMediaTypes **enums)
Definition: dshow_enummediatypes.c:70
libAVEnumMediaTypes_Setup
static int libAVEnumMediaTypes_Setup(libAVEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
Definition: dshow_enummediatypes.c:85
E_OUTOFMEMORY
#define E_OUTOFMEMORY
Definition: windows2linux.h:45
DECLARE_DESTROY
#define DECLARE_DESTROY(class, func)
Definition: dshow_capture.h:112
S_FALSE
#define S_FALSE
Definition: windows2linux.h:41
libAVEnumMediaTypes
Definition: dshow_capture.h:228