Ocean
Loading...
Searching...
No Matches
DSObject.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MEDIA_DS_OBJECT_H
9#define META_OCEAN_MEDIA_DS_OBJECT_H
10
12
14
15DISABLE_WARNINGS_BEGIN
16 #include <Dshow.h>
17DISABLE_WARNINGS_END
18
19namespace Ocean
20{
21
22namespace Media
23{
24
25namespace DirectShow
26{
27
28/**
29 * This functions allows to release a DirectShow object if it does exist.
30 * @param object DirectShow object to be released
31 * @ingroup mediads
32 */
33template <class T> void release(T *object);
34
35/**
36 * Template specialization for ScopedObjectCompileTimeVoid using the release() function to release DirectShow objects.
37 * @tparam T The data type of the wrapped object
38 * @ingroup mediads
39 */
40template <typename T>
42
43/**
44 * Definition of a scoped object holding an IAMStreamConfig object.
45 * The wrapped IAMStreamConfig object will be released automatically once the scoped object does not exist anymore.
46 * @ingroup mediads
47 */
49
50/**
51 * Definition of a scoped object holding an IAMVfwCompressDialogs object.
52 * The wrapped IAMVfwCompressDialogs object will be released automatically once the scoped object does not exist anymore.
53 * @ingroup mediads
54 */
56
57/**
58 * Definition of a scoped object holding an IBaseFilter object.
59 * The wrapped IBaseFilter object will be released automatically once the scoped object does not exist anymore.
60 * @ingroup mediads
61 */
63
64/**
65 * Definition of a scoped object holding an IBasicAudio object.
66 * The wrapped IBasicAudio object will be released automatically once the scoped object does not exist anymore.
67 * @ingroup mediads
68 */
70
71/**
72 * Definition of a scoped object holding an ICreateDevEnum object.
73 * The wrapped ICreateDevEnum object will be released automatically once the scoped object does not exist anymore.
74 * @ingroup mediads
75 */
77
78/**
79 * Definition of a scoped object holding an IEnumFilters object.
80 * The wrapped IEnumFilters object will be released automatically once the scoped object does not exist anymore.
81 * @ingroup mediads
82 */
84
85/**
86 * Definition of a scoped object holding an IEnumMoniker object.
87 * The wrapped IEnumMoniker object will be released automatically once the scoped object does not exist anymore.
88 * @ingroup mediads
89 */
91
92/**
93 * Definition of a scoped object holding an IEnumPins object.
94 * The wrapped IEnumPins object will be released automatically once the scoped object does not exist anymore.
95 * @ingroup mediads
96 */
98
99/**
100 * Definition of a scoped object holding an IFileSinkFilter object.
101 * The wrapped IFileSinkFilter object will be released automatically once the scoped object does not exist anymore.
102 * @ingroup mediads
103 */
105
106/**
107 * Definition of a scoped object holding an IGraphBuilder object.
108 * The wrapped IGraphBuilder object will be released automatically once the scoped object does not exist anymore.
109 * @ingroup mediads
110 */
112
113/**
114 * Definition of a scoped object holding an IMediaControl object.
115 * The wrapped IMediaControl object will be released automatically once the scoped object does not exist anymore.
116 * @ingroup mediads
117 */
119
120/**
121 * Definition of a scoped object holding an IMediaEvent object.
122 * The wrapped IMediaEvent object will be released automatically once the scoped object does not exist anymore.
123 * @ingroup mediads
124 */
126
127/**
128 * Definition of a scoped object holding an IMediaFilter object.
129 * The wrapped IMediaFilter object will be released automatically once the scoped object does not exist anymore.
130 * @ingroup mediads
131 */
133
134/**
135 * Definition of a scoped object holding an IMediaSeeking object.
136 * The wrapped IMediaSeeking object will be released automatically once the scoped object does not exist anymore.
137 * @ingroup mediads
138 */
140
141/**
142 * Definition of a scoped object holding an IMoniker object.
143 * The wrapped IMoniker object will be released automatically once the scoped object does not exist anymore.
144 * @ingroup mediads
145 */
147
148/**
149 * Definition of a scoped object holding an IPin object.
150 * The wrapped IPin object will be released automatically once the scoped object does not exist anymore.
151 * @ingroup mediads
152 */
154
155/**
156 * Definition of a scoped object holding an IPropertyBag object.
157 * The wrapped IPropertyBag object will be released automatically once the scoped object does not exist anymore.
158 * @ingroup mediads
159 */
161
162/**
163 * Definition of a scoped object holding an IRunningObjectTable object.
164 * The wrapped IRunningObjectTable object will be released automatically once the scoped object does not exist anymore.
165 * @ingroup mediads
166 */
168
169
170/**
171 * This class provides basic DirectShow functionalities.
172 * @ingroup mediads
173 */
174class OCEAN_MEDIA_DS_EXPORT DSObject
175{
176 public:
177
178 /**
179 * Definition of input and output pin.
180 */
182 {
183 /// Input pin.
185 /// Output pin.
187 /// Don't care.
188 PTYPE_DONT_CARE
189 };
190
191 /**
192 * Definition of pin connection types.
193 */
195 {
196 /// Connected.
198 /// Not connected.
200 /// Don't care.
201 CTYPE_DONT_CARE
202 };
203
204 /**
205 * Definition of a pair of pins.
206 */
207 typedef std::pair<ScopedIPin, ScopedIPin> PinPair;
208
209 /**
210 * Definition of a vector holding pin pairs.
211 */
212 typedef std::vector<PinPair> PinPairs;
213
214 /**
215 * Definition of a vector holding pins.
216 */
217 typedef std::vector<ScopedIPin> Pins;
218
219 public:
220
221 /**
222 * Returns the first pin.
223 * @param filter The filter to return the pin from
224 * @param pinType Input or output pin
225 * @param connectionType Connection type of the pin
226 * @return First free pin, if any
227 */
228 static ScopedIPin firstPin(IBaseFilter* filter, PinType pinType, ConnectionType connectionType);
229
230 /**
231 * Returns all pins with a specified property.
232 * The pins have to be released by the caller.
233 * @param filter The filter to return the pin from
234 * @param pinType Input or output pin
235 * @param connectionType Connection type of the pin
236 * @return Pins, if any
237 */
238 static Pins pins(IBaseFilter* filter, PinType pinType, ConnectionType connectionType);
239
240 /**
241 * Returns all connects in a branch.
242 * The pins have to be released by the caller.
243 * @param filter Start point of the branch
244 * @return Connections
245 */
247
248 /**
249 * Returns the owner filter of a pin.
250 * The filter has to be released by the caller.
251 * @param pin The pin the get the owner from
252 * @return Filter, if any
253 */
254 static ScopedIBaseFilter pinOwner(IPin* pin);
255
256 /**
257 * Returns the connected pin of a given pin.
258 * The pin has to be released by the caller.
259 * @param pin The pin to get the connected pin from
260 * @return Connected pin, if any
261 */
262 static ScopedIPin connectedPin(IPin* pin);
263};
264
265template <class T>
266void release(T *object)
267{
268 if (object != nullptr)
269 {
270 object->Release();
271 }
272}
273
274}
275
276}
277
278}
279
280#endif // META_OCEAN_MEDIA_DS_OBJECT_H
This class provides basic DirectShow functionalities.
Definition DSObject.h:175
std::vector< ScopedIPin > Pins
Definition of a vector holding pins.
Definition DSObject.h:217
PinType
Definition of input and output pin.
Definition DSObject.h:182
@ PTYPE_INPUT
Input pin.
Definition DSObject.h:184
@ PTYPE_OUTPUT
Output pin.
Definition DSObject.h:186
static ScopedIPin connectedPin(IPin *pin)
Returns the connected pin of a given pin.
std::pair< ScopedIPin, ScopedIPin > PinPair
Definition of a pair of pins.
Definition DSObject.h:207
std::vector< PinPair > PinPairs
Definition of a vector holding pin pairs.
Definition DSObject.h:212
static ScopedIPin firstPin(IBaseFilter *filter, PinType pinType, ConnectionType connectionType)
Returns the first pin.
static Pins pins(IBaseFilter *filter, PinType pinType, ConnectionType connectionType)
Returns all pins with a specified property.
static ScopedIBaseFilter pinOwner(IPin *pin)
Returns the owner filter of a pin.
static PinPairs connections(IBaseFilter *filter)
Returns all connects in a branch.
ConnectionType
Definition of pin connection types.
Definition DSObject.h:195
@ CTYPE_CONNECTED
Connected.
Definition DSObject.h:197
@ CTYPE_NOT_CONNECTED
Not connected.
Definition DSObject.h:199
This class wraps an unmanaged object (or reference) which needs to be released after usage.
Definition ScopedObject.h:166
ScopeDirectShowObject< IGraphBuilder > ScopedIGraphBuilder
Definition of a scoped object holding an IGraphBuilder object.
Definition DSObject.h:111
ScopeDirectShowObject< ICreateDevEnum > ScopedICreateDevEnum
Definition of a scoped object holding an ICreateDevEnum object.
Definition DSObject.h:76
ScopeDirectShowObject< IMoniker > ScopedIMoniker
Definition of a scoped object holding an IMoniker object.
Definition DSObject.h:146
ScopeDirectShowObject< IPin > ScopedIPin
Definition of a scoped object holding an IPin object.
Definition DSObject.h:153
ScopeDirectShowObject< IAMStreamConfig > ScopedIAMStreamConfig
Definition of a scoped object holding an IAMStreamConfig object.
Definition DSObject.h:48
void release(T *object)
This functions allows to release a DirectShow object if it does exist.
Definition DSObject.h:266
ScopeDirectShowObject< IMediaSeeking > ScopedIMediaSeeking
Definition of a scoped object holding an IMediaSeeking object.
Definition DSObject.h:139
ScopeDirectShowObject< IAMVfwCompressDialogs > ScopedIAMVfwCompressDialogs
Definition of a scoped object holding an IAMVfwCompressDialogs object.
Definition DSObject.h:55
ScopeDirectShowObject< IEnumMoniker > ScopedIEnumMoniker
Definition of a scoped object holding an IEnumMoniker object.
Definition DSObject.h:90
ScopeDirectShowObject< IMediaFilter > ScopedIMediaFilter
Definition of a scoped object holding an IMediaFilter object.
Definition DSObject.h:132
ScopeDirectShowObject< IEnumFilters > ScopedIEnumFilters
Definition of a scoped object holding an IEnumFilters object.
Definition DSObject.h:83
ScopeDirectShowObject< IBasicAudio > ScopedIBasicAudio
Definition of a scoped object holding an IBasicAudio object.
Definition DSObject.h:69
ScopeDirectShowObject< IMediaEvent > ScopedIMediaEvent
Definition of a scoped object holding an IMediaEvent object.
Definition DSObject.h:125
ScopeDirectShowObject< IMediaControl > ScopedIMediaControl
Definition of a scoped object holding an IMediaControl object.
Definition DSObject.h:118
ScopeDirectShowObject< IEnumPins > ScopedIEnumPins
Definition of a scoped object holding an IEnumPins object.
Definition DSObject.h:97
ScopeDirectShowObject< IBaseFilter > ScopedIBaseFilter
Definition of a scoped object holding an IBaseFilter object.
Definition DSObject.h:62
ScopeDirectShowObject< IFileSinkFilter > ScopedIFileSinkFilter
Definition of a scoped object holding an IFileSinkFilter object.
Definition DSObject.h:104
ScopeDirectShowObject< IPropertyBag > ScopedIPropertyBag
Definition of a scoped object holding an IPropertyBag object.
Definition DSObject.h:160
ScopeDirectShowObject< IRunningObjectTable > ScopedIRunningObjectTable
Definition of a scoped object holding an IRunningObjectTable object.
Definition DSObject.h:167
The namespace covering the entire Ocean framework.
Definition Accessor.h:15