Ocean
Loading...
Searching...
No Matches
DSDeviceEnumerator.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_DEVICE_ENUMERATOR_H
9#define META_OCEAN_MEDIA_DS_DEVICE_ENUMERATOR_H
10
13
15
16DISABLE_WARNINGS_BEGIN
17 #include <Dshow.h>
18DISABLE_WARNINGS_END
19
20namespace Ocean
21{
22
23namespace Media
24{
25
26namespace DirectShow
27{
28
29/**
30 * This class implements a DirectShow device enumerator.
31 * @ingroup mediads
32 */
34{
35 public:
36
37 /**
38 * Definition of a vector holding object names.
39 */
40 typedef std::vector<std::string> Names;
41
42 protected:
43
44 /**
45 * Struct holding parameter of enumerator objects.
46 */
47 struct Object
48 {
49 /// DirectShow moniker.
51
52 /// DirectShow friendly name.
53 std::string friendlyName_;
54
55 /// DirectShow device name.
56 std::string deviceName_;
57
58 /// DirectShow device description.
59 std::string deviceDescription_;
60 };
61
62 /**
63 * Definition of a vector holding objects.
64 */
65 typedef std::vector<Object> Objects;
66
67 public:
68
69 /**
70 * Creates a new device enumerator.
71 */
72 DSDeviceEnumerator() = default;
73
74 /**
75 * Creates a new device enumerator.
76 * @param identifier Class identifier
77 */
78 explicit DSDeviceEnumerator(const GUID& identifier);
79
80 /**
81 * Destructs a DSDeviceEnumerator.
82 */
84
85 /**
86 * Refreshes the enumerated objects.
87 * @return True, if succeeded
88 */
89 bool refresh();
90
91 /**
92 * Returns whether a given object exist.
93 * @param name Friendly name of the object
94 * @return True, if so
95 */
96 bool exist(const std::string& name) const;
97
98 /**
99 * Returns the moniker of a specified object.
100 * @param name Friendly name of the object
101 * @return Moniker, if any
102 */
103 ScopedIMoniker moniker(const std::string& name) const;
104
105 /**
106 * Returns a list of all enumerator objects.
107 * @return Names of enumerated objects
108 */
109 Names names() const;
110
111 /**
112 * Releases all enumerator objects.
113 */
114 void release();
115
116 /**
117 * Returns the class identifier of this enumerator.
118 * @return Class identifier
119 */
120 const GUID& identifier() const;
121
122 protected:
123
124 /**
125 * Disabled copy constructor.
126 */
128
129 /**
130 * Disabled copy operator.
131 * @return Reference to this object
132 */
134
135 protected:
136
137 /// Class identifier.
138 GUID classIdentifier_ = GUID_NULL;
139
140 /// Enumerated objects.
142};
143
144/**
145 * This class holds several different DirectShow device enumerators.
146 * @ingroup mediads
147 */
148class OCEAN_MEDIA_DS_EXPORT DSEnumerators : public Singleton<DSEnumerators>
149{
150 friend class Singleton<DSEnumerators>;
151
152 protected:
153
154 /**
155 * Vector holding different device enumerators.
156 */
157 typedef std::vector<std::shared_ptr<DSDeviceEnumerator>> Enumerators;
158
159 public:
160
161 /**
162 * Returns a device enumerator for a special class.
163 * @param identifier Class identifier
164 * @return Device enumerator
165 */
166 DSDeviceEnumerator& enumerator(const GUID& identifier);
167
168 /**
169 * Releases all internal enumerators.
170 */
171 void release();
172
173 protected:
174
175 /**
176 * Destructs all enumerators.
177 */
179
180 protected:
181
182 /// Vector holding several enumerators.
184
185 /// Enumerator lock.
187};
188
189}
190
191}
192
193}
194
195#endif // META_OCEAN_MEDIA_DS_DEVICE_ENUMERATOR_H
This class implements a recursive lock object.
Definition Lock.h:31
This class implements a DirectShow device enumerator.
Definition DSDeviceEnumerator.h:34
std::vector< Object > Objects
Definition of a vector holding objects.
Definition DSDeviceEnumerator.h:65
DSDeviceEnumerator()=default
Creates a new device enumerator.
Names names() const
Returns a list of all enumerator objects.
DSDeviceEnumerator(const GUID &identifier)
Creates a new device enumerator.
DSDeviceEnumerator & operator=(const DSDeviceEnumerator &)=delete
Disabled copy operator.
~DSDeviceEnumerator()
Destructs a DSDeviceEnumerator.
Objects objects_
Enumerated objects.
Definition DSDeviceEnumerator.h:141
void release()
Releases all enumerator objects.
bool exist(const std::string &name) const
Returns whether a given object exist.
ScopedIMoniker moniker(const std::string &name) const
Returns the moniker of a specified object.
DSDeviceEnumerator(const DSDeviceEnumerator &)=delete
Disabled copy constructor.
const GUID & identifier() const
Returns the class identifier of this enumerator.
std::vector< std::string > Names
Definition of a vector holding object names.
Definition DSDeviceEnumerator.h:40
bool refresh()
Refreshes the enumerated objects.
GUID classIdentifier_
Class identifier.
Definition DSDeviceEnumerator.h:138
This class holds several different DirectShow device enumerators.
Definition DSDeviceEnumerator.h:149
void release()
Releases all internal enumerators.
std::vector< std::shared_ptr< DSDeviceEnumerator > > Enumerators
Vector holding different device enumerators.
Definition DSDeviceEnumerator.h:157
DSDeviceEnumerator & enumerator(const GUID &identifier)
Returns a device enumerator for a special class.
Lock lock_
Enumerator lock.
Definition DSDeviceEnumerator.h:186
~DSEnumerators()
Destructs all enumerators.
Enumerators enumerators_
Vector holding several enumerators.
Definition DSDeviceEnumerator.h:183
This class wraps an unmanaged object (or reference) which needs to be released after usage.
Definition ScopedObject.h:166
This template class is the base class for all singleton objects.
Definition Singleton.h:71
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Struct holding parameter of enumerator objects.
Definition DSDeviceEnumerator.h:48
std::string deviceDescription_
DirectShow device description.
Definition DSDeviceEnumerator.h:59
ScopedIMoniker moniker_
DirectShow moniker.
Definition DSDeviceEnumerator.h:50
std::string friendlyName_
DirectShow friendly name.
Definition DSDeviceEnumerator.h:53
std::string deviceName_
DirectShow device name.
Definition DSDeviceEnumerator.h:56