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