Ocean
MFLibrary.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_MF_LIBRARY_H
9 #define META_OCEAN_MEDIA_MF_LIBRARY_H
10 
12 
13 #include "ocean/media/Library.h"
14 #include "ocean/media/Manager.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 namespace MediaFoundation
23 {
24 
25 /**
26  * This class implements the MediaFoundation library.
27  * @ingroup mediamf
28  */
29 class OCEAN_MEDIA_MF_EXPORT MFLibrary : public Library
30 {
31  friend class Media::Manager;
32  friend class MFAudio;
33  friend class MFMovie;
34 
35  public:
36 
37  /**
38  * Creates a new medium by a given URL.
39  * @see Library::newMedium().
40  */
41  MediumRef newMedium(const std::string& url, bool useExclusive = false) override;
42 
43  /**
44  * Creates a new medium by a given URL and an expected type.
45  * @see Library::newMedium().
46  */
47  MediumRef newMedium(const std::string& url, const Medium::Type type, bool useExclusive = false) override;
48 
49  /**
50  * Creates a new recorder specified by the recorder type.
51  * @see Library::newRecorder().
52  */
53  RecorderRef newRecorder(const Recorder::Type type) override;
54 
55  /**
56  * Returns a list of selectable mediums.
57  * @see Library::selectableMedia().
58  */
59  Definitions selectableMedia() const override;
60 
61  /**
62  * Returns a list of specific selectable mediums.
63  * @see Library::selectableMedia().
64  */
65  Definitions selectableMedia(const Medium::Type type) const override;
66 
67  /**
68  * Returns the supported medium types.
69  * @see Library::supportedTypes().
70  */
71  Medium::Type supportedTypes() const override;
72 
73  /**
74  * Registers this library at the global media manager.
75  * With each register call, the reference counter for a specific library will be incremented.
76  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
77  * @return True, if the library has not been registered before
78  * @see Manager, unregisterLibrary()
79  */
80  static bool registerLibrary();
81 
82  /**
83  * Unregisters this library at the global media manager.
84  * With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero.
85  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
86  * @return True, if the library was actually removed from the system (as the reference counter reached zero); False, if the library is still used by someone else
87  * @see registerLibrary().
88  */
89  static bool unregisterLibrary();
90 
91  protected:
92 
93  /**
94  * Creates a new MFLibrary object.
95  */
97 
98  /**
99  * Creates a new MFLibrary object.
100  */
101  ~MFLibrary() override;
102 
103  /**
104  * Creates this library and returns it an object reference.
105  * @return The new library object
106  */
107  static LibraryRef create();
108 
109  /**
110  * Creates a new audio medium.
111  * @param url The URL of the audio medium to create
112  * @param useExclusive Determines whether the caller would like to use this medium exclusively
113  * @return Reference of the new medium
114  */
115  static MediumRef newAudio(const std::string& url, const bool useExclusive);
116 
117  /**
118  * Creates a new movie medium.
119  * @param url The URL of the movie medium to create
120  * @param useExclusive Determines whether the caller would like to use this medium exclusively
121  * @return Reference of the new medium
122  */
123  static MediumRef newMovie(const std::string& url, const bool useExclusive);
124 
125  /**
126  * Creates a new live medium.
127  * @param url The URL of the live medium to create
128  * @param useExclusive Determines whether the caller would like to use this medium exclusively
129  * @return Reference of the new medium
130  */
131  static MediumRef newLiveVideo(const std::string& url, const bool useExclusive);
132 
133  private:
134 
135  /// True, if the COM library has to be released when this library is released.
136  bool releaseCOM_ = false;
137 };
138 
139 }
140 
141 }
142 
143 }
144 
145 #endif // META_OCEAN_MEDIA_MF_LIBRARY_H
This class is the base class for all media libraries.
Definition: media/Library.h:42
std::vector< Definition > Definitions
Definition of a vector holding medium definition objects.
Definition: media/Library.h:111
This class is the manager for all media objects.
Definition: media/Manager.h:34
This class implements a Media Foundation audio object.
Definition: MFAudio.h:34
This class implements the MediaFoundation library.
Definition: MFLibrary.h:30
static MediumRef newLiveVideo(const std::string &url, const bool useExclusive)
Creates a new live medium.
Definitions selectableMedia() const override
Returns a list of selectable mediums.
MediumRef newMedium(const std::string &url, const Medium::Type type, bool useExclusive=false) override
Creates a new medium by a given URL and an expected type.
MediumRef newMedium(const std::string &url, bool useExclusive=false) override
Creates a new medium by a given URL.
Definitions selectableMedia(const Medium::Type type) const override
Returns a list of specific selectable mediums.
static bool registerLibrary()
Registers this library at the global media manager.
static MediumRef newMovie(const std::string &url, const bool useExclusive)
Creates a new movie medium.
static MediumRef newAudio(const std::string &url, const bool useExclusive)
Creates a new audio medium.
Medium::Type supportedTypes() const override
Returns the supported medium types.
static LibraryRef create()
Creates this library and returns it an object reference.
MFLibrary()
Creates a new MFLibrary object.
static bool unregisterLibrary()
Unregisters this library at the global media manager.
~MFLibrary() override
Creates a new MFLibrary object.
RecorderRef newRecorder(const Recorder::Type type) override
Creates a new recorder specified by the recorder type.
This class implements a MediaFoundation movie object.
Definition: MFMovie.h:36
Type
Definition of different medium types.
Definition: Medium.h:57
Type
Definition of different recorder types.
Definition: Recorder.h:46
This template class implements a object reference with an internal reference counter.
Definition: base/ObjectRef.h:58
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15