Ocean
AVFLibrary.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_AVF_LIBRARY_H
9 #define META_OCEAN_MEDIA_AVF_LIBRARY_H
10 
14 
15 #include "ocean/media/Library.h"
16 #include "ocean/media/Manager.h"
17 
18 namespace Ocean
19 {
20 
21 namespace Media
22 {
23 
24 namespace AVFoundation
25 {
26 
27 /**
28  * This class implements the AVFoundation library.
29  * @ingroup mediaavf
30  */
31 class AVFLibrary : public Library
32 {
33  friend class Media::Manager;
34  friend class AVFAudio;
35  friend class AVFMovie;
36  friend class AVFLiveVideo;
37 
38  public:
39 
40  /**
41  * Creates a new medium by a given url.
42  * @see Library::newMedium().
43  */
44  MediumRef newMedium(const std::string& url, bool useExclusive = false) override;
45 
46  /**
47  * Creates a new medium by a given url and an expected type.
48  * @see Library::newMedium().
49  */
50  MediumRef newMedium(const std::string& url, const Medium::Type type, bool useExclusive = false) override;
51 
52  /**
53  * Creates a new recorder specified by the recorder type.
54  * @see Library::newRecorder().
55  */
56  RecorderRef newRecorder(const Recorder::Type type) override;
57 
58  /**
59  * Returns a list of selectable mediums.
60  * @see Library::selectableMedia().
61  */
62  Definitions selectableMedia() const override;
63 
64  /**
65  * Returns a list of specific selectable mediums.
66  * @see Library::selectableMedia().
67  */
68  Definitions selectableMedia(const Medium::Type type) const override;
69 
70  /**
71  * Returns the supported medium types.
72  * @see Library::supportedTypes().
73  */
74  Medium::Type supportedTypes() const override;
75 
76  /**
77  * Registers this library at the global media manager.
78  * With each register call, the reference counter for a specific library will be incremented.
79  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
80  * @return True, if the library has not been registered before
81  * @see Manager, unregisterLibrary()
82  */
83  static bool registerLibrary();
84 
85  /**
86  * Unregisters this library at the global media manager.
87  * With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero.
88  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
89  * @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
90  * @see registerLibrary().
91  */
92  static bool unregisterLibrary();
93 
94  protected:
95 
96  /**
97  * Creates a new AVFLibrary object.
98  */
100 
101  /**
102  * Destructs an AVFLibrary object.
103  */
104  ~AVFLibrary() override;
105 
106  /**
107  * Creates this library and returns it an object reference.
108  * @return The new library object
109  */
110  static LibraryRef create();
111 
112  /**
113  * Creates a new audio medium.
114  * @param url Url of the audio medium to create
115  * @param useExclusive Determines whether the caller would like to use this medium exclusively
116  * @return Reference of the new medium
117  */
118  static MediumRef newAudio(const std::string& url, bool useExclusive);
119 
120  /**
121  * Creates a new movie medium.
122  * @param url Url of the movie medium to create
123  * @param useExclusive Determines whether the caller would like to use this medium exclusively
124  * @return Reference of the new medium
125  */
126  static MediumRef newMovie(const std::string& url, bool useExclusive);
127 
128  /**
129  * Creates a new live audio medium.
130  * @param url Url of the live audio medium to create
131  * @param useExclusive Determines whether the caller would like to use this medium exclusively
132  * @return Reference of the new medium
133  */
134  static MediumRef newLiveAudio(const std::string& url, bool useExclusive);
135 
136  /**
137  * Creates a new live video medium.
138  * @param url Url of the video medium to create
139  * @param useExclusive Determines whether the caller would like to use this medium exclusively
140  * @return Reference of the new medium
141  */
142  static MediumRef newLiveVideo(const std::string& url, bool useExclusive);
143 
144  /**
145  * Creates a new microphone medium.
146  * @param url The URL of the audio medium to create
147  * @param useExclusive Determines whether the caller would like to use this medium exclusively
148  * @return Reference of the new medium
149  */
150  MediumRef newMicrophone(const std::string& url, bool useExclusive);
151 };
152 
153 }
154 
155 }
156 
157 }
158 
159 #endif // META_OCEAN_MEDIA_AVF_LIBRARY_H
This class implements an AVFoundation audio object.
Definition: AVFAudio.h:40
This class implements the AVFoundation library.
Definition: AVFLibrary.h:32
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.
RecorderRef newRecorder(const Recorder::Type type) override
Creates a new recorder specified by the recorder type.
static MediumRef newLiveVideo(const std::string &url, bool useExclusive)
Creates a new live video medium.
static MediumRef newAudio(const std::string &url, bool useExclusive)
Creates a new audio medium.
MediumRef newMedium(const std::string &url, bool useExclusive=false) override
Creates a new medium by a given url.
static LibraryRef create()
Creates this library and returns it an object reference.
AVFLibrary()
Creates a new AVFLibrary object.
~AVFLibrary() override
Destructs an AVFLibrary object.
static MediumRef newMovie(const std::string &url, bool useExclusive)
Creates a new movie medium.
static MediumRef newLiveAudio(const std::string &url, bool useExclusive)
Creates a new live audio medium.
static bool registerLibrary()
Registers this library at the global media manager.
MediumRef newMicrophone(const std::string &url, bool useExclusive)
Creates a new microphone medium.
Medium::Type supportedTypes() const override
Returns the supported medium types.
static bool unregisterLibrary()
Unregisters this library at the global media manager.
Definitions selectableMedia(const Medium::Type type) const override
Returns a list of specific selectable mediums.
This class implements a AVFoundation live video object.
Definition: AVFLiveVideo.h:32
This class implements an AVFoundation movie object.
Definition: AVFMovie.h:36
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
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