Ocean
Loading...
Searching...
No Matches
ALibrary.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_ANDROID_A_LIBRARY_H
9#define META_OCEAN_MEDIA_ANDROID_A_LIBRARY_H
10
15
16#include "ocean/media/Library.h"
17#include "ocean/media/Manager.h"
18
19#include <jni.h>
20
21#include <SLES/OpenSLES.h>
22
23namespace Ocean
24{
25
26namespace Media
27{
28
29namespace Android
30{
31
32/**
33 * This class implements the android library.
34 * @ingroup mediaandroid
35 */
36class OCEAN_MEDIA_A_EXPORT ALibrary : public Library
37{
38 friend class Media::Manager;
39 friend class AAudio;
40 friend class ALiveAudio;
41 friend class ALiveVideo;
42 friend class AMovie;
43
44 public:
45
46 /**
47 * Creates a new medium by a given url.
48 * @see Library::newMedium().
49 */
50 MediumRef newMedium(const std::string& url, bool useExclusive = false) override;
51
52 /**
53 * Creates a new medium by a given url and an expected type.
54 * @see Library::newMedium().
55 */
56 MediumRef newMedium(const std::string& url, const Medium::Type type, bool useExclusive = false) override;
57
58 /**
59 * Creates a new recorder specified by the recorder type.
60 * @see Library::newRecorder().
61 */
63
64 /**
65 * Returns a list of selectable mediums.
66 * @see Library::selectableMedia().
67 */
68 Definitions selectableMedia() const override;
69
70 /**
71 * Returns a list of specific selectable mediums.
72 * @see Library::selectableMedia().
73 */
74 Definitions selectableMedia(const Medium::Type type) const override;
75
76 /**
77 * Returns the supported medium types.
78 * @see Library::supportedTypes().
79 */
80 Medium::Type supportedTypes() const override;
81
82 /**
83 * Registers this library at the global media manager.
84 * With each register call, the reference counter for a specific library will be incremented.
85 * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
86 * @return True, if the library has not been registered before
87 * @see Manager, unregisterLibrary()
88 */
89 static bool registerLibrary();
90
91 /**
92 * Unregisters this library at the global media manager.
93 * With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero.
94 * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
95 * @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
96 * @see registerLibrary().
97 */
98 static bool unregisterLibrary();
99
100 protected:
101
102 /**
103 * Creates a new ALibrary object.
104 */
106
107 /**
108 * Destructs an ALibrary object.
109 */
110 ~ALibrary() override;
111
112 /**
113 * Creates a new audio medium.
114 * @param url The 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 MediumRef newAudio(const std::string& url, bool useExclusive);
119
120 /**
121 * Creates a new live audio medium.
122 * @param url The URL of the audio 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 MediumRef newLiveAudio(const std::string& url, bool useExclusive);
127
128 /**
129 * Creates a new microphone medium.
130 * @param url The URL of the 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 MediumRef newMicrophone(const std::string& url, bool useExclusive);
135
136 /**
137 * Initializes the SL audio engine.
138 * @return True, if succeeded
139 */
141
142 /**
143 * Releases the SL audio engine.
144 */
146
147 /**
148 * Creates a new live video medium.
149 * @param url The URL of the live video medium to create
150 * @param useExclusive Determines whether the caller would like to use this medium exclusively
151 * @return Reference of the new medium
152 */
153 MediumRef newLiveVideo(const std::string& url, bool useExclusive) const;
154
155 /**
156 * Creates a new movie medium.
157 * @param url The URL of the movie medium to create
158 * @param useExclusive Determines whether the caller would like to use this medium exclusively
159 * @return Reference of the new medium
160 */
161 static MediumRef newMovie(const std::string& url, bool useExclusive);
162
163 /**
164 * Creates this library and returns it an object reference.
165 * @return The new library object
166 */
168
169 protected:
170
171 /// The SL engine for all audio objects.
172 SLObjectItf slEngine_ = nullptr;
173
174 /// The SL engine interface for all audio objects.
175 SLEngineItf slEngineInterface_ = nullptr;
176
177#ifdef OCEAN_MEDIA_ANDROID_NATIVECAMERALIBRARY_AVAILABLE
178 /// The subscription for the native camera library
180
181 /// The selectable live video devices.
183#endif
184
185#ifdef OCEAN_MEDIA_ANDROID_NATIVEMEDIALIBRARY_AVAILABLE
186 /// The subscription for the native media library
188#endif
189};
190
191}
192
193}
194
195}
196
197#endif // META_OCEAN_MEDIA_ANDROID_A_LIBRARY_H
This class implements an Audio class for Android.
Definition AAudio.h:36
This class implements the android library.
Definition ALibrary.h:37
Medium::Type supportedTypes() const override
Returns the supported medium types.
static LibraryRef create()
Creates this library and returns it an object reference.
static MediumRef newMovie(const std::string &url, bool useExclusive)
Creates a new movie medium.
NativeCameraLibrary::ScopedSubscription nativeCameraLibrarySubscription_
The subscription for the native camera library.
Definition ALibrary.h:179
MediumRef newLiveAudio(const std::string &url, bool useExclusive)
Creates a new live audio medium.
MediumRef newAudio(const std::string &url, bool useExclusive)
Creates a new audio medium.
RecorderRef newRecorder(const Recorder::Type type) override
Creates a new recorder specified by the recorder type.
Definitions selectableMedia() const override
Returns a list of selectable mediums.
ALiveVideo::Devices selectableLiveVideoDevices_
The selectable live video devices.
Definition ALibrary.h:182
NativeMediaLibrary::ScopedSubscription nativeMediaLibrarySubscription_
The subscription for the native media library.
Definition ALibrary.h:187
ALibrary()
Creates a new ALibrary object.
bool initializerAudioEngine()
Initializes the SL audio engine.
MediumRef newMicrophone(const std::string &url, bool useExclusive)
Creates a new microphone medium.
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.
MediumRef newLiveVideo(const std::string &url, bool useExclusive) const
Creates a new live video medium.
static bool unregisterLibrary()
Unregisters this library at the global media manager.
~ALibrary() override
Destructs an ALibrary object.
static bool registerLibrary()
Registers this library at the global media manager.
Definitions selectableMedia(const Medium::Type type) const override
Returns a list of specific selectable mediums.
void releaseAudioEngine()
Releases the SL audio engine.
This class implements a LiveAudio class for Android.
Definition ALiveAudio.h:39
This class implements an live video class for Android.
Definition ALiveVideo.h:42
std::vector< Device > Devices
Definition ALiveVideo.h:130
This class implements a movie recorder class for Android.
Definition AMovie.h:45
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
The namespace covering the entire Ocean framework.
Definition Accessor.h:15