Ocean
NativeMediaLibrary.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_NATIVE_MEDIA_LIBRARY_H
9 #define META_OCEAN_MEDIA_ANDROID_NATIVE_MEDIA_LIBRARY_H
10 
12 
15 #include "ocean/base/Singleton.h"
16 
17 #if defined(__ANDROID_API__) && __ANDROID_API__ >= 21
18 
19 #ifndef OCEAN_MEDIA_ANDROID_NATIVEMEDIALIBRARY_AVAILABLE
20  #define OCEAN_MEDIA_ANDROID_NATIVEMEDIALIBRARY_AVAILABLE
21 #endif
22 
23 #if __ANDROID_API__ >= 24
24  #include <media/NdkImageReader.h>
25 #endif // __ANDROID_API__ >= 24
26 
27 #include <media/NdkMediaCodec.h>
28 #include <media/NdkMediaExtractor.h>
29 #include <media/NdkMediaFormat.h>
30 #include <media/NdkMediaMuxer.h>
31 
32 namespace Ocean
33 {
34 
35 namespace Media
36 {
37 
38 namespace Android
39 {
40 
41 /**
42  * This class is an interface for Android's shared native library mediandk.
43  * @ingroup mediaandroid
44  */
45 class OCEAN_MEDIA_A_EXPORT NativeMediaLibrary : public Singleton<NativeMediaLibrary>
46 {
47  friend class Singleton<NativeMediaLibrary>;
48 
49  public:
50 
51  /**
52  * Definition of a subscription object.
53  */
55 
56  /**
57  * Definition of a scoped object for AMediaFormat objects.
58  */
59  class ScopedAMediaFormat : public ScopedObjectT<AMediaFormat*, AMediaFormat*, std::function<media_status_t(AMediaFormat*)>>
60  {
61  public:
62 
63  /**
64  * Default constructor creating an invalid object.
65  */
66  ScopedAMediaFormat() = default;
67 
68  /**
69  * Creates a new scoped object and takes over the ownership of the given media format.
70  * @param mediaFormat The media format to take over, can be nullptr to create an invalid object.
71  */
72  explicit inline ScopedAMediaFormat(AMediaFormat* mediaFormat);
73  };
74 
75  /**
76  * Definition of a scoped object for AMediaCodec objects.
77  */
78  class ScopedAMediaCodec : public ScopedObjectT<AMediaCodec*, AMediaCodec*, std::function<media_status_t(AMediaCodec*)>>
79  {
80  public:
81 
82  /**
83  * Default constructor creating an invalid object.
84  */
85  ScopedAMediaCodec() = default;
86 
87  /**
88  * Creates a new scoped object and takes over the ownership of the given media codec.
89  * @param mediaCodec The media codec to take over, can be nullptr to create an invalid object.
90  */
91  explicit inline ScopedAMediaCodec(AMediaCodec* mediaCodec);
92  };
93 
94  /**
95  * Definition of individual MediaFormat keys.
96  */
97  static constexpr const char* AMEDIAFORMAT_KEY_MIME = "mime";
98  static constexpr const char* AMEDIAFORMAT_KEY_COLOR_FORMAT = "color-format";
99  static constexpr const char* AMEDIAFORMAT_KEY_COLOR_RANGE = "color-range";
100  static constexpr const char* AMEDIAFORMAT_KEY_WIDTH = "width";
101  static constexpr const char* AMEDIAFORMAT_KEY_HEIGHT = "height";
102  static constexpr const char* AMEDIAFORMAT_KEY_STRIDE = "stride";
103  static constexpr const char* AMEDIAFORMAT_KEY_SLICE_HEIGHT = "slice-height";
104  static constexpr const char* AMEDIAFORMAT_KEY_DURATION = "durationUs";
105  static constexpr const char* AMEDIAFORMAT_KEY_BITS_PER_SAMPLE = "bits-per-sample";
106  static constexpr const char* AMEDIAFORMAT_KEY_BIT_RATE = "bitrate";
107  static constexpr const char* AMEDIAFORMAT_KEY_SAMPLE_RATE = "sample-rate";
108  static constexpr const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT = "channel-count";
109  static constexpr const char* AMEDIAFORMAT_KEY_PCM_ENCODING = "pcm-encoding";
110  static constexpr const char* AMEDIAFORMAT_KEY_DISPLAY_HEIGHT = "display-height";
111  static constexpr const char* AMEDIAFORMAT_KEY_DISPLAY_CROP = "crop";
112  static constexpr const char* AMEDIAFORMAT_KEY_CAPTURE_RATE = "capture-rate";
113  static constexpr const char* AMEDIAFORMAT_KEY_FRAME_RATE = "frame-rate";
114  static constexpr const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL = "i-frame-interval";
115 
116  protected:
117 
118 #if __ANDROID_API__ >= 24
119 
120  /**
121  * Definition of the individual function pointers of AImage.
122  */
123  using Function_AImage_delete = void (AImage* image);
124  using Function_AImage_getWidth = media_status_t (const AImage* image, int32_t* width);
125  using Function_AImage_getHeight = media_status_t (const AImage* image, int32_t* height);
126  using Function_AImage_getFormat = media_status_t (const AImage* image, int32_t* format);
127  using Function_AImage_getCropRect = media_status_t (const AImage* image, AImageCropRect* rect);
128  using Function_AImage_getTimestamp = media_status_t (const AImage* image, int64_t* timestampNs);
129  using Function_AImage_getNumberOfPlanes = media_status_t (const AImage* image, int32_t* numPlanes);
130  using Function_AImage_getPlanePixelStride = media_status_t (const AImage* image, int planeIdx, int32_t* pixelStride);
131  using Function_AImage_getPlaneRowStride = media_status_t (const AImage* image, int planeIdx, int32_t* rowStride);
132  using Function_AImage_getPlaneData = media_status_t (const AImage* image, int planeIdx, uint8_t** data, int* dataLength);
133 
134  /**
135  * Definition of the individual function pointers of AImageReader.
136  */
137  using Function_AImageReader_new = media_status_t (int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader** reader);
138  using Function_AImageReader_delete = void (AImageReader* reader);
139  using Function_AImageReader_getWindow = media_status_t (AImageReader* reader, ANativeWindow** window);
140  using Function_AImageReader_getWidth = media_status_t (const AImageReader* reader, int32_t* width);
141  using Function_AImageReader_getHeight = media_status_t (const AImageReader* reader, int32_t* height);
142  using Function_AImageReader_getFormat = media_status_t (const AImageReader* reader, int32_t* format);
143  using Function_AImageReader_getMaxImages = media_status_t (const AImageReader* reader, int32_t* maxImages);
144  using Function_AImageReader_acquireNextImage = media_status_t (AImageReader* reader, AImage** image);
145  using Function_AImageReader_acquireLatestImage = media_status_t (AImageReader* reader, AImage** image);
146  using Function_AImageReader_setImageListener = media_status_t (AImageReader* reader, AImageReader_ImageListener* listener);
147 
148 #endif // __ANDROID_API__ >= 24
149 
150  /**
151  * Definition of the individual function pointers of AMediaCodec.
152  */
153  using Function_AMediaCodec_createDecoderByType = AMediaCodec* (const char* mime_type);
154  using Function_AMediaCodec_createEncoderByType = AMediaCodec* (const char* mime_type);
155  using Function_AMediaCodec_configure = media_status_t (AMediaCodec* codec, const AMediaFormat* format, ANativeWindow* surface, AMediaCrypto* crypto, uint32_t flags);
156  using Function_AMediaCodec_delete = media_status_t (AMediaCodec* codec);
157  using Function_AMediaCodec_dequeueInputBuffer = ssize_t (AMediaCodec* codec, int64_t timeoutUs);
158  using Function_AMediaCodec_dequeueOutputBuffer = ssize_t (AMediaCodec* codec, AMediaCodecBufferInfo* info, int64_t timeoutUs);
159  using Function_AMediaCodec_flush = media_status_t (AMediaCodec* codec);
160  using Function_AMediaCodec_getBufferFormat = AMediaFormat* (AMediaCodec* codec, size_t index);
161  using Function_AMediaCodec_getInputBuffer = uint8_t* (AMediaCodec* codec, size_t idx, size_t* out_size);
162  using Function_AMediaCodec_getInputFormat = AMediaFormat* (AMediaCodec* codec);
163  using Function_AMediaCodec_getOutputBuffer = uint8_t* (AMediaCodec* codec, size_t idx, size_t* out_size);
164  using Function_AMediaCodec_getOutputFormat = AMediaFormat* (AMediaCodec* codec);
165  using Function_AMediaCodec_queueInputBuffer = media_status_t (AMediaCodec* codec, size_t idx, unsigned int offset, size_t size, uint64_t time, uint32_t flags);
166  using Function_AMediaCodec_releaseOutputBuffer = media_status_t (AMediaCodec* codec, size_t idx, bool render);
167  using Function_AMediaCodec_start = media_status_t (AMediaCodec* codec);
168  using Function_AMediaCodec_stop = media_status_t (AMediaCodec* codec);
169 
170  /**
171  * Definition of the individual function pointers of AMediaFormat.
172  */
173  using Function_AMediaFormat_delete = media_status_t (AMediaFormat* format);
174  using Function_AMediaFormat_new = AMediaFormat*();
175  using Function_AMediaFormat_getInt32 = bool (AMediaFormat* format, const char* name, int32_t* out);
176  using Function_AMediaFormat_getInt64 = bool (AMediaFormat* format, const char* name, int64_t* out);
177  using Function_AMediaFormat_getString = bool (AMediaFormat* format, const char* name, const char** out);
178  using Function_AMediaFormat_getRect = bool (AMediaFormat* format, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom);
179  using Function_AMediaFormat_setBuffer = void (AMediaFormat* format, const char* name, const void* data, size_t size);
180  using Function_AMediaFormat_setFloat = void (AMediaFormat* format, const char* name, float value);
181  using Function_AMediaFormat_setInt32 = void (AMediaFormat* format, const char* name, int32_t value);
182  using Function_AMediaFormat_setInt64 = void (AMediaFormat* format, const char* name, int64_t value);
183  using Function_AMediaFormat_setString = void (AMediaFormat* format, const char* name, const char* value);
184  using Function_AMediaFormat_toString = const char* (AMediaFormat* format);
185 
186  /**
187  * Definition of the individual function pointers of AMediaMuxer.
188  */
189  using Function_AMediaMuxer_addTrack = ssize_t (AMediaMuxer* muxer, const AMediaFormat* format);
190  using Function_AMediaMuxer_delete = media_status_t (AMediaMuxer* muxer);
191  using Function_AMediaMuxer_new = AMediaMuxer* (int fd, OutputFormat format);
192  using Function_AMediaMuxer_setLocation = media_status_t (AMediaMuxer* muxer, float latitude, float longitude);
193  using Function_AMediaMuxer_setOrientationHint = media_status_t (AMediaMuxer* muxer, int degrees);
194  using Function_AMediaMuxer_start = media_status_t (AMediaMuxer* muxer);
195  using Function_AMediaMuxer_stop = media_status_t (AMediaMuxer* muxer);
196  using Function_AMediaMuxer_writeSampleData = media_status_t (AMediaMuxer* muxer, size_t trackIdx, const uint8_t* data, const AMediaCodecBufferInfo* info);
197 
198  /**
199  * Definition of the individual function pointers of AMediaExtractor.
200  */
201  using Function_AMediaExtractor_advance = bool(AMediaExtractor* mediaExtractor);
202  using Function_AMediaExtractor_delete = media_status_t (AMediaExtractor* mediaExtractor);
203  using Function_AMediaExtractor_getSampleTime = int64_t (AMediaExtractor* mediaExtractor);
204  using Function_AMediaExtractor_getTrackCount = size_t (AMediaExtractor* mediaExtractor);
205  using Function_AMediaExtractor_getTrackFormat = AMediaFormat* (AMediaExtractor* mediaExtractor, size_t idx);
206  using Function_AMediaExtractor_new = AMediaExtractor* ();
207  using Function_AMediaExtractor_readSampleData = ssize_t (AMediaExtractor* mediaExtractor, uint8_t* buffer, size_t capacity);
208  using Function_AMediaExtractor_seekTo = media_status_t (AMediaExtractor* mediaExtractor, int64_t seekPosUs, SeekMode mode);
209  using Function_AMediaExtractor_selectTrack = media_status_t (AMediaExtractor* mediaExtractor, size_t idx);
210  using Function_AMediaExtractor_setDataSource = media_status_t (AMediaExtractor* mediaExtractor, const char* location);
211  using Function_AMediaExtractor_setDataSourceFd = media_status_t (AMediaExtractor* mediaExtractor, int fd, off64_t offset, off64_t length);
212 
213  public:
214 
215  /**
216  * Initializes the media library.
217  * The library will be initialized as long as the resulting subscription object exists.
218  * @return The subscription object, invalid in case the library could not be initialized
219  */
221 
222  /**
223  * Returns whether the library is initialized.
224  * @return True, if so
225  */
226  inline bool isInitialized() const;
227 
228 #if __ANDROID_API__ >= 24
229 
230  /**
231  * The individual functions of AImage.
232  */
233  inline void AImage_delete(AImage* image) const;
234  inline media_status_t AImage_getWidth(const AImage* image, int32_t* width) const;
235  inline media_status_t AImage_getHeight(const AImage* image, int32_t* height) const;
236  inline media_status_t AImage_getFormat(const AImage* image, int32_t* format) const;
237  inline media_status_t AImage_getCropRect(const AImage* image, AImageCropRect* rect) const;
238  inline media_status_t AImage_getTimestamp(const AImage* image, int64_t* timestampNs) const;
239  inline media_status_t AImage_getNumberOfPlanes(const AImage* image, int32_t* numPlanes) const;
240  inline media_status_t AImage_getPlanePixelStride(const AImage* image, int planeIdx, int32_t* pixelStride) const;
241  inline media_status_t AImage_getPlaneRowStride(const AImage* image, int planeIdx, int32_t* rowStride) const;
242  inline media_status_t AImage_getPlaneData(const AImage* image, int planeIdx, uint8_t** data, int* dataLength) const;
243 
244  /**
245  * The individual functions of AImageReader.
246  */
247  inline media_status_t AImageReader_new(int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader** reader) const;
248  inline void AImageReader_delete(AImageReader* reader) const;
249  inline media_status_t AImageReader_getWindow(AImageReader* reader, ANativeWindow** window) const;
250  inline media_status_t AImageReader_getWidth(const AImageReader* reader, int32_t* width) const;
251  inline media_status_t AImageReader_getHeight(const AImageReader* reader, int32_t* height) const;
252  inline media_status_t AImageReader_getFormat(const AImageReader* reader, int32_t* format) const;
253  inline media_status_t AImageReader_getMaxImages(const AImageReader* reader, int32_t* maxImages) const;
254  inline media_status_t AImageReader_acquireNextImage(AImageReader* reader, AImage** image) const;
255  inline media_status_t AImageReader_acquireLatestImage(AImageReader* reader, AImage** image) const;
256  inline media_status_t AImageReader_setImageListener(AImageReader* reader, AImageReader_ImageListener* listener) const;
257 
258 #endif // __ANDROID_API__ >= 24
259 
260  /**
261  * The individual functions of AMediaCodec.
262  */
263  inline AMediaCodec* AMediaCodec_createDecoderByType(const char* mime_type) const;
264  inline AMediaCodec* AMediaCodec_createEncoderByType(const char* mime_type) const;
265  inline media_status_t AMediaCodec_configure(AMediaCodec* codec, const AMediaFormat* format, ANativeWindow* surface, AMediaCrypto* crypto, uint32_t flags) const;
266  inline media_status_t AMediaCodec_delete(AMediaCodec* codec) const;
267  inline ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec* codec, int64_t timeoutUs) const;
268  inline ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec* codec, AMediaCodecBufferInfo* info, int64_t timeoutUs) const;
269  inline media_status_t AMediaCodec_flush(AMediaCodec* codec) const;
270  inline AMediaFormat* AMediaCodec_getBufferFormat(AMediaCodec* codec, size_t index) const;
271  inline uint8_t* AMediaCodec_getInputBuffer(AMediaCodec* codec, size_t idx, size_t* out_size) const;
272  inline AMediaFormat* AMediaCodec_getInputFormat(AMediaCodec* codec) const;
273  inline uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec* codec, size_t idx, size_t* out_size) const;
274  inline AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec* codec) const;
275  inline media_status_t AMediaCodec_queueInputBuffer(AMediaCodec* codec, size_t idx, unsigned int offset, size_t size, uint64_t time, uint32_t flags) const;
276  inline media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec* codec, size_t idx, bool render) const;
277  inline media_status_t AMediaCodec_start(AMediaCodec* codec) const;
278  inline media_status_t AMediaCodec_stop(AMediaCodec* codec) const;
279 
280  /**
281  * The individual functions of AMediaFormat.
282  */
283  inline media_status_t AMediaFormat_delete(AMediaFormat* format) const;
284  inline AMediaFormat* AMediaFormat_new() const;
285  inline bool AMediaFormat_getInt32(AMediaFormat* mediaFormat, const char* name, int32_t* out) const;
286  inline bool AMediaFormat_getInt64(AMediaFormat* mediaFormat, const char* name, int64_t* out) const;
287  inline bool AMediaFormat_getString(AMediaFormat* mediaFormat, const char* name, const char** out) const;
288  inline bool AMediaFormat_getRect(AMediaFormat *, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) const;
289  inline void AMediaFormat_setBuffer(AMediaFormat* format, const char* name, const void* data, size_t size) const;
290  inline void AMediaFormat_setFloat(AMediaFormat* format, const char* name, float value) const;
291  inline void AMediaFormat_setInt32(AMediaFormat* format, const char* name, int32_t value) const;
292  inline void AMediaFormat_setInt64(AMediaFormat* format, const char* name, int64_t value) const;
293  inline void AMediaFormat_setString(AMediaFormat* format, const char* name, const char* value) const;
294  inline const char* AMediaFormat_toString(AMediaFormat* format) const;
295 
296  /**
297  * The individual functions of AMediaMuxer.
298  */
299  inline ssize_t AMediaMuxer_addTrack(AMediaMuxer* muxer, const AMediaFormat* format) const;
300  inline media_status_t AMediaMuxer_delete(AMediaMuxer* muxer) const;
301  inline AMediaMuxer* AMediaMuxer_new(int fd, OutputFormat format) const;
302  inline media_status_t AMediaMuxer_setLocation(AMediaMuxer* muxer, float latitude, float longitude) const;
303  inline media_status_t AMediaMuxer_setOrientationHint(AMediaMuxer* muxer, int degrees) const;
304  inline media_status_t AMediaMuxer_start(AMediaMuxer* muxer) const;
305  inline media_status_t AMediaMuxer_stop(AMediaMuxer* muxer) const;
306  inline media_status_t AMediaMuxer_writeSampleData(AMediaMuxer* muxer, size_t trackIdx, const uint8_t* data, const AMediaCodecBufferInfo* info) const;
307 
308  /**
309  * The individual functions of AMediaExtractor.
310  */
311  inline bool AMediaExtractor_advance(AMediaExtractor* mediaExtractor) const;
312  inline media_status_t AMediaExtractor_delete(AMediaExtractor* mediaExtractor) const;
313  inline int64_t AMediaExtractor_getSampleTime(AMediaExtractor* mediaExtractor) const;
314  inline size_t AMediaExtractor_getTrackCount(AMediaExtractor* mediaExtractor) const;
315  inline AMediaFormat* AMediaExtractor_getTrackFormat(AMediaExtractor* mediaExtractor, size_t idx) const;
316  inline AMediaExtractor* AMediaExtractor_new() const;
317  inline ssize_t AMediaExtractor_readSampleData(AMediaExtractor* mediaExtractor, uint8_t* buffer, size_t capacity) const;
318  inline media_status_t AMediaExtractor_seekTo(AMediaExtractor* mediaExtractor, int64_t seekPosUs, SeekMode mode) const;
319  inline media_status_t AMediaExtractor_selectTrack(AMediaExtractor* mediaExtractor, size_t idx) const;
320  inline media_status_t AMediaExtractor_setDataSource(AMediaExtractor* mediaExtractor, const char* location) const;
321  inline media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor* mediaExtractor, int fd, off64_t offset, off64_t length) const;
322 
323  protected:
324 
325  /**
326  * Protected default constructor.
327  */
329 
330  /**
331  * Destructs the library
332  */
333  inline ~NativeMediaLibrary();
334 
335  /**
336  * Uninitializes the library.
337  * @param unused An unused id
338  */
339  void uninitialize(const unsigned int unused);
340 
341  /**
342  * Releases the library.
343  */
344  void release();
345 
346  protected:
347 
348  /// The handle of the library.
349  void* libraryHandle_ = nullptr;
350 
351 #if __ANDROID_API__ >= 24
352 
353  /// All AImage function pointers.
354  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_delete* AImage_delete_ = nullptr;
355  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getWidth* AImage_getWidth_ = nullptr;
356  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getHeight* AImage_getHeight_ = nullptr;
357  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getFormat* AImage_getFormat_ = nullptr;
358  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getCropRect* AImage_getCropRect_ = nullptr;
359  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getTimestamp* AImage_getTimestamp_ = nullptr;
360  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getNumberOfPlanes* AImage_getNumberOfPlanes_ = nullptr;
361  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getPlanePixelStride* AImage_getPlanePixelStride_ = nullptr;
362  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getPlaneRowStride* AImage_getPlaneRowStride_ = nullptr;
363  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_getPlaneData* AImage_getPlaneData_ = nullptr;
364 
365  /// All AImageReader function pointers.
366  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_new* AImageReader_new_ = nullptr;
367  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_delete* AImageReader_delete_ = nullptr;
368  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_getWindow* AImageReader_getWindow_ = nullptr;
369  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_getWidth* AImageReader_getWidth_ = nullptr;
370  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_getHeight* AImageReader_getHeight_ = nullptr;
371  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_getFormat* AImageReader_getFormat_ = nullptr;
372  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_getMaxImages* AImageReader_getMaxImages_ = nullptr;
373  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_acquireNextImage* AImageReader_acquireNextImage_ = nullptr;
374  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_acquireLatestImage* AImageReader_acquireLatestImage_ = nullptr;
375  __attribute__((annotate("dynamic_fn_ptr"))) Function_AImageReader_setImageListener* AImageReader_setImageListener_ = nullptr;
376 
377 #endif // __ANDROID_API__ >= 24
378 
379  /// All AMediaCodec function pointers.
380  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_createDecoderByType* AMediaCodec_createDecoderByType_ = nullptr;
381  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_createEncoderByType* AMediaCodec_createEncoderByType_ = nullptr;
382  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_configure* AMediaCodec_configure_ = nullptr;
383  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_delete* AMediaCodec_delete_ = nullptr;
384  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_dequeueInputBuffer* AMediaCodec_dequeueInputBuffer_ = nullptr;
385  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_dequeueOutputBuffer* AMediaCodec_dequeueOutputBuffer_ = nullptr;
386  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_flush* AMediaCodec_flush_ = nullptr;
387  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_getBufferFormat* AMediaCodec_getBufferFormat_ = nullptr;
388  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_getInputBuffer* AMediaCodec_getInputBuffer_ = nullptr;
389  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_getInputFormat* AMediaCodec_getInputFormat_ = nullptr;
390  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_getOutputBuffer* AMediaCodec_getOutputBuffer_ = nullptr;
391  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_getOutputFormat* AMediaCodec_getOutputFormat_ = nullptr;
392  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_queueInputBuffer* AMediaCodec_queueInputBuffer_ = nullptr;
393  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_releaseOutputBuffer* AMediaCodec_releaseOutputBuffer_ = nullptr;
394  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_start* AMediaCodec_start_ = nullptr;
395  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_stop* AMediaCodec_stop_ = nullptr;
396 
397  // All AMediaFormat function pointers.
398  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_delete* AMediaFormat_delete_ = nullptr;
399  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_new* AMediaFormat_new_ = nullptr;
400  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_getInt32* AMediaFormat_getInt32_ = nullptr;
401  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_getInt64* AMediaFormat_getInt64_ = nullptr;
402  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_getString* AMediaFormat_getString_ = nullptr;
403  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_getRect* AMediaFormat_getRect_ = nullptr;
404  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_setBuffer* AMediaFormat_setBuffer_ = nullptr;
405  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_setFloat* AMediaFormat_setFloat_ = nullptr;
406  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_setInt32* AMediaFormat_setInt32_ = nullptr;
407  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_setInt64* AMediaFormat_setInt64_ = nullptr;
408  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_setString* AMediaFormat_setString_ = nullptr;
409  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaFormat_toString* AMediaFormat_toString_ = nullptr;
410 
411  /// All AMediaMixer function pointers.
412  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_addTrack* AMediaMuxer_addTrack_ = nullptr;
413  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_delete* AMediaMuxer_delete_ = nullptr;
414  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_new* AMediaMuxer_new_ = nullptr;
415  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_setLocation* AMediaMuxer_setLocation_ = nullptr;
416  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_setOrientationHint* AMediaMuxer_setOrientationHint_ = nullptr;
417  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_start* AMediaMuxer_start_ = nullptr;
418  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_stop* AMediaMuxer_stop_ = nullptr;
419  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaMuxer_writeSampleData* AMediaMuxer_writeSampleData_ = nullptr;
420 
421  /// All AMediaExtractor function pointers.
422  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_advance* AMediaExtractor_advance_ = nullptr;
423  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_delete* AMediaExtractor_delete_ = nullptr;
424  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_getSampleTime* AMediaExtractor_getSampleTime_ = nullptr;
425  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_getTrackCount* AMediaExtractor_getTrackCount_ = nullptr;
426  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_getTrackFormat* AMediaExtractor_getTrackFormat_ = nullptr;
427  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_new* AMediaExtractor_new_ = nullptr;
428  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_readSampleData* AMediaExtractor_readSampleData_ = nullptr;
429  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_seekTo* AMediaExtractor_seekTo_ = nullptr;
430  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_selectTrack* AMediaExtractor_selectTrack_ = nullptr;
431  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_setDataSource* AMediaExtractor_setDataSource_ = nullptr;
432  __attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaExtractor_setDataSourceFd* AMediaExtractor_setDataSourceFd_ = nullptr;
433 
434  /// The counter for counting the usage of this library.
435  unsigned int initializationCounter_ = 0u;
436 
437  /// The library's lock.
438  mutable Lock lock_;
439 };
440 
441 inline NativeMediaLibrary::ScopedAMediaFormat::ScopedAMediaFormat(AMediaFormat* mediaFormat) :
442  ScopedObjectT(mediaFormat, std::bind(&NativeMediaLibrary::AMediaFormat_delete, &NativeMediaLibrary::get(), mediaFormat), mediaFormat != nullptr)
443 {
444  // nothing to do here
445 }
446 
448  ScopedObjectT(mediaCodec, std::bind(&NativeMediaLibrary::AMediaCodec_delete, &NativeMediaLibrary::get(), mediaCodec), mediaCodec != nullptr)
449 {
450  // nothing to do here
451 }
452 
454 {
455  ocean_assert(initializationCounter_ == 0u);
456 }
457 
459 {
460  const ScopedLock scopedLock(lock_);
461 
462  return initializationCounter_ != 0u;
463 }
464 
465 #if __ANDROID_API__ >= 24
466 
467 inline void NativeMediaLibrary::AImage_delete(AImage* image) const
468 {
469  ocean_assert(isInitialized());
470  ocean_assert(AImage_delete_ != nullptr);
471 
472  AImage_delete_(image);
473 }
474 
475 inline media_status_t NativeMediaLibrary::AImage_getWidth(const AImage* image, int32_t* width) const
476 {
477  ocean_assert(isInitialized());
478  ocean_assert(AImage_getWidth_ != nullptr);
479 
480  return AImage_getWidth_(image, width);
481 }
482 
483 inline media_status_t NativeMediaLibrary::AImage_getHeight(const AImage* image, int32_t* height) const
484 {
485  ocean_assert(isInitialized());
486  ocean_assert(AImage_getHeight_ != nullptr);
487 
488  return AImage_getHeight_(image, height);
489 }
490 
491 inline media_status_t NativeMediaLibrary::AImage_getFormat(const AImage* image, int32_t* format) const
492 {
493  ocean_assert(isInitialized());
494  ocean_assert(AImage_getFormat_ != nullptr);
495 
496  return AImage_getFormat_(image, format);
497 }
498 
499 inline media_status_t NativeMediaLibrary::AImage_getCropRect(const AImage* image, AImageCropRect* rect) const
500 {
501  ocean_assert(isInitialized());
502  ocean_assert(AImage_getCropRect_ != nullptr);
503 
504  return AImage_getCropRect_(image, rect);
505 }
506 
507 inline media_status_t NativeMediaLibrary::AImage_getTimestamp(const AImage* image, int64_t* timestampNs) const
508 {
509  ocean_assert(isInitialized());
510  ocean_assert(AImage_getTimestamp_ != nullptr);
511 
512  return AImage_getTimestamp_(image, timestampNs);
513 }
514 
515 inline media_status_t NativeMediaLibrary::AImage_getNumberOfPlanes(const AImage* image, int32_t* numPlanes) const
516 {
517  ocean_assert(isInitialized());
518  ocean_assert(AImage_getNumberOfPlanes_ != nullptr);
519 
520  return AImage_getNumberOfPlanes_(image, numPlanes);
521 }
522 
523 inline media_status_t NativeMediaLibrary::AImage_getPlanePixelStride(const AImage* image, int planeIdx, int32_t* pixelStride) const
524 {
525  ocean_assert(isInitialized());
526  ocean_assert(AImage_getPlanePixelStride_ != nullptr);
527 
528  return AImage_getPlanePixelStride_(image, planeIdx, pixelStride);
529 }
530 
531 inline media_status_t NativeMediaLibrary::AImage_getPlaneRowStride(const AImage* image, int planeIdx, int32_t* rowStride) const
532 {
533  ocean_assert(isInitialized());
534  ocean_assert(AImage_getPlaneRowStride_ != nullptr);
535 
536  return AImage_getPlaneRowStride_(image, planeIdx, rowStride);
537 }
538 
539 inline media_status_t NativeMediaLibrary::AImage_getPlaneData(const AImage* image, int planeIdx, uint8_t** data, int* dataLength) const
540 {
541  ocean_assert(isInitialized());
542  ocean_assert(AImage_getPlaneData_ != nullptr);
543 
544  return AImage_getPlaneData_(image, planeIdx, data, dataLength);
545 }
546 
547 inline media_status_t NativeMediaLibrary::AImageReader_new(int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader** reader) const
548 {
549  ocean_assert(isInitialized());
550  ocean_assert(AImageReader_new_ != nullptr);
551 
552  return AImageReader_new_(width, height, format, maxImages, reader);
553 }
554 
555 inline void NativeMediaLibrary::AImageReader_delete(AImageReader* reader) const
556 {
557  ocean_assert(isInitialized());
558  ocean_assert(AImageReader_delete_ != nullptr);
559 
560  AImageReader_delete_(reader);
561 }
562 
563 inline media_status_t NativeMediaLibrary::AImageReader_getWindow(AImageReader* reader, ANativeWindow** window) const
564 {
565  ocean_assert(isInitialized());
566  ocean_assert(AImageReader_getWindow_ != nullptr);
567 
568  return AImageReader_getWindow_(reader, window);
569 }
570 
571 inline media_status_t NativeMediaLibrary::AImageReader_getWidth(const AImageReader* reader, int32_t* width) const
572 {
573  ocean_assert(isInitialized());
574  ocean_assert(AImageReader_getWidth_ != nullptr);
575 
576  return AImageReader_getWidth_(reader, width);
577 }
578 
579 inline media_status_t NativeMediaLibrary::AImageReader_getHeight(const AImageReader* reader, int32_t* height) const
580 {
581  ocean_assert(isInitialized());
582  ocean_assert(AImageReader_getHeight_ != nullptr);
583 
584  return AImageReader_getHeight_(reader, height);
585 }
586 
587 inline media_status_t NativeMediaLibrary::AImageReader_getFormat(const AImageReader* reader, int32_t* format) const
588 {
589  ocean_assert(isInitialized());
590  ocean_assert(AImageReader_getFormat_ != nullptr);
591 
592  return AImageReader_getFormat_(reader, format);
593 }
594 
595 inline media_status_t NativeMediaLibrary::AImageReader_getMaxImages(const AImageReader* reader, int32_t* maxImages) const
596 {
597  ocean_assert(isInitialized());
598  ocean_assert(AImageReader_getMaxImages_ != nullptr);
599 
600  return AImageReader_getMaxImages_(reader, maxImages);
601 }
602 
603 inline media_status_t NativeMediaLibrary::AImageReader_acquireNextImage(AImageReader* reader, AImage** image) const
604 {
605  ocean_assert(isInitialized());
606  ocean_assert(AImageReader_acquireNextImage_ != nullptr);
607 
608  return AImageReader_acquireNextImage_(reader, image);
609 }
610 
611 inline media_status_t NativeMediaLibrary::AImageReader_acquireLatestImage(AImageReader* reader, AImage** image) const
612 {
613  ocean_assert(isInitialized());
614  ocean_assert(AImageReader_acquireLatestImage_ != nullptr);
615 
616  return AImageReader_acquireLatestImage_(reader, image);
617 }
618 
619 inline media_status_t NativeMediaLibrary::AImageReader_setImageListener(AImageReader* reader, AImageReader_ImageListener* listener) const
620 {
621  ocean_assert(isInitialized());
622  ocean_assert(AImageReader_setImageListener_ != nullptr);
623 
624  return AImageReader_setImageListener_(reader, listener);
625 }
626 
627 #endif // __ANDROID_API__ >= 24
628 
629 inline AMediaCodec* NativeMediaLibrary::AMediaCodec_createDecoderByType(const char* mime_type) const
630 {
631  ocean_assert(isInitialized());
632  ocean_assert(AMediaCodec_createDecoderByType_ != nullptr);
633 
634  return AMediaCodec_createDecoderByType_(mime_type);
635 }
636 
637 inline AMediaCodec* NativeMediaLibrary::AMediaCodec_createEncoderByType(const char* mime_type) const
638 {
639  ocean_assert(isInitialized());
640  ocean_assert(AMediaCodec_createEncoderByType_ != nullptr);
641 
642  return AMediaCodec_createEncoderByType_(mime_type);
643 }
644 
645 inline media_status_t NativeMediaLibrary::AMediaCodec_configure(AMediaCodec* codec, const AMediaFormat* format, ANativeWindow* surface, AMediaCrypto* crypto, uint32_t flags) const
646 {
647  ocean_assert(isInitialized());
648  ocean_assert(AMediaCodec_configure_ != nullptr);
649 
650  return AMediaCodec_configure_(codec, format, surface, crypto, flags);
651 }
652 
653 inline media_status_t NativeMediaLibrary::AMediaCodec_delete(AMediaCodec* codec) const
654 {
655  ocean_assert(isInitialized());
656  ocean_assert(AMediaCodec_delete_ != nullptr);
657 
658  return AMediaCodec_delete_(codec);
659 }
660 
661 inline ssize_t NativeMediaLibrary::AMediaCodec_dequeueInputBuffer(AMediaCodec* codec, int64_t timeoutUs) const
662 {
663  ocean_assert(isInitialized());
664  ocean_assert(AMediaCodec_dequeueInputBuffer_ != nullptr);
665 
666  return AMediaCodec_dequeueInputBuffer_(codec, timeoutUs);
667 }
668 
669 inline ssize_t NativeMediaLibrary::AMediaCodec_dequeueOutputBuffer(AMediaCodec* codec, AMediaCodecBufferInfo* info, int64_t timeoutUs) const
670 {
671  ocean_assert(isInitialized());
672  ocean_assert(AMediaCodec_dequeueOutputBuffer_ != nullptr);
673 
674  return AMediaCodec_dequeueOutputBuffer_(codec, info, timeoutUs);
675 }
676 
677 inline media_status_t NativeMediaLibrary::AMediaCodec_flush(AMediaCodec* codec) const
678 {
679  ocean_assert(isInitialized());
680  ocean_assert(AMediaCodec_flush_ != nullptr);
681 
682  return AMediaCodec_flush_(codec);
683 }
684 
685 inline AMediaFormat* NativeMediaLibrary::AMediaCodec_getBufferFormat(AMediaCodec* codec, size_t index) const
686 {
687  ocean_assert(isInitialized());
688  ocean_assert(AMediaCodec_getBufferFormat_ != nullptr);
689 
690  return AMediaCodec_getBufferFormat_(codec, index);
691 }
692 
693 inline uint8_t* NativeMediaLibrary::AMediaCodec_getInputBuffer(AMediaCodec* codec, size_t idx, size_t* out_size) const
694 {
695  ocean_assert(isInitialized());
696  ocean_assert(AMediaCodec_getInputBuffer_ != nullptr);
697 
698  return AMediaCodec_getInputBuffer_(codec, idx, out_size);
699 }
700 
701 inline AMediaFormat* NativeMediaLibrary::AMediaCodec_getInputFormat(AMediaCodec* codec) const
702 {
703  ocean_assert(isInitialized());
704  ocean_assert(AMediaCodec_getInputFormat_ != nullptr);
705 
706  return AMediaCodec_getInputFormat_(codec);
707 }
708 
709 inline uint8_t* NativeMediaLibrary::AMediaCodec_getOutputBuffer(AMediaCodec* codec, size_t idx, size_t* out_size) const
710 {
711  ocean_assert(isInitialized());
712  ocean_assert(AMediaCodec_getOutputBuffer_ != nullptr);
713 
714  return AMediaCodec_getOutputBuffer_(codec, idx, out_size);
715 }
716 
717 inline AMediaFormat* NativeMediaLibrary::AMediaCodec_getOutputFormat(AMediaCodec* codec) const
718 {
719  ocean_assert(isInitialized());
720  ocean_assert(AMediaCodec_getOutputFormat_ != nullptr);
721 
722  return AMediaCodec_getOutputFormat_(codec);
723 }
724 
725 inline media_status_t NativeMediaLibrary::AMediaCodec_queueInputBuffer(AMediaCodec* codec, size_t idx, unsigned int offset, size_t size, uint64_t time, uint32_t flags) const
726 {
727  ocean_assert(isInitialized());
728  ocean_assert(AMediaCodec_queueInputBuffer_ != nullptr);
729 
730  return AMediaCodec_queueInputBuffer_(codec, idx, offset, size, time, flags);
731 }
732 
733 inline media_status_t NativeMediaLibrary::AMediaCodec_releaseOutputBuffer(AMediaCodec* codec, size_t idx, bool render) const
734 {
735  ocean_assert(isInitialized());
736  ocean_assert(AMediaCodec_releaseOutputBuffer_ != nullptr);
737 
738  return AMediaCodec_releaseOutputBuffer_(codec, idx, render);
739 }
740 
741 inline media_status_t NativeMediaLibrary::AMediaCodec_start(AMediaCodec* codec) const
742 {
743  ocean_assert(isInitialized());
744  ocean_assert(AMediaCodec_start_ != nullptr);
745 
746  return AMediaCodec_start_(codec);
747 }
748 
749 inline media_status_t NativeMediaLibrary::AMediaCodec_stop(AMediaCodec* codec) const
750 {
751  ocean_assert(isInitialized());
752  ocean_assert(AMediaCodec_stop_ != nullptr);
753 
754  return AMediaCodec_stop_(codec);
755 }
756 
757 inline media_status_t NativeMediaLibrary::AMediaFormat_delete(AMediaFormat* format) const
758 {
759  ocean_assert(isInitialized());
760  ocean_assert(AMediaFormat_delete_ != nullptr);
761 
762  return AMediaFormat_delete_(format);
763 }
764 
765 inline AMediaFormat* NativeMediaLibrary::AMediaFormat_new() const
766 {
767  ocean_assert(isInitialized());
768  ocean_assert(AMediaFormat_new_ != nullptr);
769 
770  return AMediaFormat_new_();
771 }
772 
773 bool NativeMediaLibrary::AMediaFormat_getInt32(AMediaFormat* mediaFormat, const char* name, int32_t* out) const
774 {
775  ocean_assert(isInitialized());
776  ocean_assert(AMediaFormat_getInt32_ != nullptr);
777 
778  return AMediaFormat_getInt32_(mediaFormat, name, out);
779 }
780 
781 bool NativeMediaLibrary::AMediaFormat_getInt64(AMediaFormat* mediaFormat, const char* name, int64_t* out) const
782 {
783  ocean_assert(isInitialized());
784  ocean_assert(AMediaFormat_getInt64_ != nullptr);
785 
786  return AMediaFormat_getInt64_(mediaFormat, name, out);
787 }
788 
789 bool NativeMediaLibrary::AMediaFormat_getString(AMediaFormat* mediaFormat, const char* name, const char** out) const
790 {
791  ocean_assert(isInitialized());
792  ocean_assert(AMediaFormat_getString_ != nullptr);
793 
794  return AMediaFormat_getString_(mediaFormat, name, out);
795 }
796 
797 bool NativeMediaLibrary::AMediaFormat_getRect(AMediaFormat* mediaFormat, const char* name, int32_t* left, int32_t* top, int32_t* right, int32_t* bottom) const
798 {
799  ocean_assert(isInitialized());
800  ocean_assert(AMediaFormat_getRect_ != nullptr);
801 
802  return AMediaFormat_getRect_(mediaFormat, name, left, top, right, bottom);
803 }
804 
805 inline void NativeMediaLibrary::AMediaFormat_setBuffer(AMediaFormat* format, const char* name, const void* data, size_t size) const
806 {
807  ocean_assert(isInitialized());
808  ocean_assert(AMediaFormat_setBuffer_ != nullptr);
809 
810  return AMediaFormat_setBuffer_(format, name, data, size);
811 }
812 
813 inline void NativeMediaLibrary::AMediaFormat_setFloat(AMediaFormat* format, const char* name, float value) const
814 {
815  ocean_assert(isInitialized());
816  ocean_assert(AMediaFormat_setFloat_ != nullptr);
817 
818  return AMediaFormat_setFloat_(format, name, value);
819 }
820 
821 inline void NativeMediaLibrary::AMediaFormat_setInt32(AMediaFormat* format, const char* name, int32_t value) const
822 {
823  ocean_assert(isInitialized());
824  ocean_assert(AMediaFormat_setInt32_ != nullptr);
825 
826  return AMediaFormat_setInt32_(format, name, value);
827 }
828 
829 inline void NativeMediaLibrary::AMediaFormat_setInt64(AMediaFormat* format, const char* name, int64_t value) const
830 {
831  ocean_assert(isInitialized());
832  ocean_assert(AMediaFormat_setInt64_ != nullptr);
833 
834  return AMediaFormat_setInt64_(format, name, value);
835 }
836 
837 inline void NativeMediaLibrary::AMediaFormat_setString(AMediaFormat* format, const char* name, const char* value) const
838 {
839  ocean_assert(isInitialized());
840  ocean_assert(AMediaFormat_setString_ != nullptr);
841 
842  return AMediaFormat_setString_(format, name, value);
843 }
844 
845 inline const char* NativeMediaLibrary::AMediaFormat_toString(AMediaFormat* format) const
846 {
847  ocean_assert(isInitialized());
848  ocean_assert(AMediaFormat_toString_ != nullptr);
849 
850  return AMediaFormat_toString_(format);
851 }
852 
853 inline ssize_t NativeMediaLibrary::AMediaMuxer_addTrack(AMediaMuxer* muxer, const AMediaFormat* format) const
854 {
855  ocean_assert(isInitialized());
856  ocean_assert(AMediaMuxer_addTrack_ != nullptr);
857 
858  return AMediaMuxer_addTrack_(muxer, format);
859 }
860 
861 inline media_status_t NativeMediaLibrary::AMediaMuxer_delete(AMediaMuxer* muxer) const
862 {
863  ocean_assert(isInitialized());
864  ocean_assert(AMediaMuxer_delete_ != nullptr);
865 
866  return AMediaMuxer_delete_(muxer);
867 }
868 
869 inline AMediaMuxer* NativeMediaLibrary::AMediaMuxer_new(int fd, OutputFormat format) const
870 {
871  ocean_assert(isInitialized());
872  ocean_assert(AMediaMuxer_new_ != nullptr);
873 
874  return AMediaMuxer_new_(fd, format);
875 }
876 
877 inline media_status_t NativeMediaLibrary::AMediaMuxer_setLocation(AMediaMuxer* muxer, float latitude, float longitude) const
878 {
879  ocean_assert(isInitialized());
880  ocean_assert(AMediaMuxer_setLocation_ != nullptr);
881 
882  return AMediaMuxer_setLocation_(muxer, latitude, longitude);
883 }
884 
885 inline media_status_t NativeMediaLibrary::AMediaMuxer_setOrientationHint(AMediaMuxer* muxer, int degrees) const
886 {
887  ocean_assert(isInitialized());
888  ocean_assert(AMediaMuxer_setOrientationHint_ != nullptr);
889 
890  return AMediaMuxer_setOrientationHint_(muxer, degrees);
891 }
892 
893 inline media_status_t NativeMediaLibrary::AMediaMuxer_start(AMediaMuxer* muxer) const
894 {
895  ocean_assert(isInitialized());
896  ocean_assert(AMediaMuxer_start_ != nullptr);
897 
898  return AMediaMuxer_start_(muxer);
899 }
900 
901 inline media_status_t NativeMediaLibrary::AMediaMuxer_stop(AMediaMuxer* muxer) const
902 {
903  ocean_assert(isInitialized());
904  ocean_assert(AMediaMuxer_stop_ != nullptr);
905 
906  return AMediaMuxer_stop_(muxer);
907 }
908 
909 inline media_status_t NativeMediaLibrary::AMediaMuxer_writeSampleData(AMediaMuxer* muxer, size_t trackIdx, const uint8_t* data, const AMediaCodecBufferInfo* info) const
910 {
911  ocean_assert(isInitialized());
912  ocean_assert(AMediaMuxer_writeSampleData_ != nullptr);
913 
914  return AMediaMuxer_writeSampleData_(muxer, trackIdx, data, info);
915 }
916 
917 inline bool NativeMediaLibrary::AMediaExtractor_advance(AMediaExtractor* mediaExtractor) const
918 {
919  ocean_assert(isInitialized());
920  ocean_assert(AMediaExtractor_advance_ != nullptr);
921 
922  return AMediaExtractor_advance_(mediaExtractor);
923 }
924 
925 inline media_status_t NativeMediaLibrary::AMediaExtractor_delete(AMediaExtractor* mediaExtractor) const
926 {
927  ocean_assert(isInitialized());
928  ocean_assert(AMediaExtractor_delete_ != nullptr);
929 
930  return AMediaExtractor_delete_(mediaExtractor);
931 }
932 
933 size_t NativeMediaLibrary::AMediaExtractor_getTrackCount(AMediaExtractor* mediaExtractor) const
934 {
935  ocean_assert(isInitialized());
936  ocean_assert(AMediaExtractor_getTrackCount_ != nullptr);
937 
938  return AMediaExtractor_getTrackCount_(mediaExtractor);
939 }
940 
941 AMediaFormat* NativeMediaLibrary::AMediaExtractor_getTrackFormat(AMediaExtractor* mediaExtractor, size_t idx) const
942 {
943  ocean_assert(isInitialized());
944  ocean_assert(AMediaExtractor_getTrackFormat_ != nullptr);
945 
946  return AMediaExtractor_getTrackFormat_(mediaExtractor, idx);
947 }
948 
949 inline AMediaExtractor* NativeMediaLibrary::AMediaExtractor_new() const
950 {
951  ocean_assert(isInitialized());
952  ocean_assert(AMediaExtractor_new_ != nullptr);
953 
954  return AMediaExtractor_new_();
955 }
956 
957 ssize_t NativeMediaLibrary::AMediaExtractor_readSampleData(AMediaExtractor* mediaExtractor, uint8_t* buffer, size_t capacity) const
958 {
959  ocean_assert(isInitialized());
960  ocean_assert(AMediaExtractor_readSampleData_ != nullptr);
961 
962  return AMediaExtractor_readSampleData_(mediaExtractor, buffer, capacity);
963 }
964 
965 int64_t NativeMediaLibrary::AMediaExtractor_getSampleTime(AMediaExtractor* mediaExtractor) const
966 {
967  ocean_assert(isInitialized());
968  ocean_assert(AMediaExtractor_getSampleTime_ != nullptr);
969 
970  return AMediaExtractor_getSampleTime_(mediaExtractor);
971 }
972 
973 inline media_status_t NativeMediaLibrary::AMediaExtractor_seekTo(AMediaExtractor* mediaExtractor, int64_t seekPosUs, SeekMode mode) const
974 {
975  ocean_assert(isInitialized());
976  ocean_assert(AMediaExtractor_seekTo_ != nullptr);
977 
978  return AMediaExtractor_seekTo_(mediaExtractor, seekPosUs, mode);
979 }
980 
981 inline media_status_t NativeMediaLibrary::AMediaExtractor_selectTrack(AMediaExtractor* mediaExtractor, size_t idx) const
982 {
983  ocean_assert(isInitialized());
984  ocean_assert(AMediaExtractor_selectTrack_ != nullptr);
985 
986  return AMediaExtractor_selectTrack_(mediaExtractor, idx);
987 }
988 
989 inline media_status_t NativeMediaLibrary::AMediaExtractor_setDataSource(AMediaExtractor* mediaExtractor, const char* location) const
990 {
991  ocean_assert(isInitialized());
992  ocean_assert(AMediaExtractor_setDataSource_ != nullptr);
993 
994  return AMediaExtractor_setDataSource_(mediaExtractor, location);
995 }
996 
997 inline media_status_t NativeMediaLibrary::AMediaExtractor_setDataSourceFd(AMediaExtractor* mediaExtractor, int fd, off64_t offset, off64_t length) const
998 {
999  ocean_assert(isInitialized());
1000  ocean_assert(AMediaExtractor_setDataSourceFd_ != nullptr);
1001 
1002  return AMediaExtractor_setDataSourceFd_(mediaExtractor, fd, offset, length);
1003 }
1004 
1005 }
1006 
1007 }
1008 
1009 }
1010 
1011 #endif // defined(__ANDROID_API__) && __ANDROID_API__ >= 21
1012 
1013 #endif // META_OCEAN_MEDIA_ANDROID_NATIVE_MEDIA_LIBRARY_H
This class implements a recursive lock object.
Definition: Lock.h:31
Definition of a scoped object for AMediaCodec objects.
Definition: NativeMediaLibrary.h:79
ScopedAMediaCodec()=default
Default constructor creating an invalid object.
Definition of a scoped object for AMediaFormat objects.
Definition: NativeMediaLibrary.h:60
ScopedAMediaFormat()=default
Default constructor creating an invalid object.
This class is an interface for Android's shared native library mediandk.
Definition: NativeMediaLibrary.h:46
media_status_t(AMediaMuxer *muxer) Function_AMediaMuxer_start
Definition: NativeMediaLibrary.h:194
media_status_t AImage_getCropRect(const AImage *image, AImageCropRect *rect) const
Definition: NativeMediaLibrary.h:499
media_status_t AImageReader_acquireNextImage(AImageReader *reader, AImage **image) const
Definition: NativeMediaLibrary.h:603
media_status_t(AMediaMuxer *muxer, size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info) Function_AMediaMuxer_writeSampleData
Definition: NativeMediaLibrary.h:196
media_status_t(const AImage *image, int planeIdx, int32_t *pixelStride) Function_AImage_getPlanePixelStride
Definition: NativeMediaLibrary.h:130
void AMediaFormat_setFloat(AMediaFormat *format, const char *name, float value) const
Definition: NativeMediaLibrary.h:813
void AImage_delete(AImage *image) const
The individual functions of AImage.
Definition: NativeMediaLibrary.h:467
void AMediaFormat_setString(AMediaFormat *format, const char *name, const char *value) const
Definition: NativeMediaLibrary.h:837
media_status_t(const AImageReader *reader, int32_t *height) Function_AImageReader_getHeight
Definition: NativeMediaLibrary.h:141
media_status_t(AImageReader *reader, AImage **image) Function_AImageReader_acquireNextImage
Definition: NativeMediaLibrary.h:144
media_status_t(const AImage *image, int32_t *numPlanes) Function_AImage_getNumberOfPlanes
Definition: NativeMediaLibrary.h:129
void(AMediaFormat *format, const char *name, float value) Function_AMediaFormat_setFloat
Definition: NativeMediaLibrary.h:180
void(AMediaFormat *format, const char *name, int64_t value) Function_AMediaFormat_setInt64
Definition: NativeMediaLibrary.h:182
media_status_t AMediaMuxer_setOrientationHint(AMediaMuxer *muxer, int degrees) const
Definition: NativeMediaLibrary.h:885
AMediaFormat * AMediaCodec_getBufferFormat(AMediaCodec *codec, size_t index) const
Definition: NativeMediaLibrary.h:685
AMediaCodec *(const char *mime_type) Function_AMediaCodec_createDecoderByType
Definition of the individual function pointers of AMediaCodec.
Definition: NativeMediaLibrary.h:153
media_status_t AImage_getPlaneData(const AImage *image, int planeIdx, uint8_t **data, int *dataLength) const
Definition: NativeMediaLibrary.h:539
AMediaCodec * AMediaCodec_createDecoderByType(const char *mime_type) const
The individual functions of AMediaCodec.
Definition: NativeMediaLibrary.h:629
media_status_t(const AImage *image, int planeIdx, uint8_t **data, int *dataLength) Function_AImage_getPlaneData
Definition: NativeMediaLibrary.h:132
ssize_t AMediaExtractor_readSampleData(AMediaExtractor *mediaExtractor, uint8_t *buffer, size_t capacity) const
Definition: NativeMediaLibrary.h:957
AMediaFormat * AMediaCodec_getOutputFormat(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:717
media_status_t(AMediaCodec *codec) Function_AMediaCodec_stop
Definition: NativeMediaLibrary.h:168
media_status_t AImage_getPlanePixelStride(const AImage *image, int planeIdx, int32_t *pixelStride) const
Definition: NativeMediaLibrary.h:523
~NativeMediaLibrary()
Destructs the library.
Definition: NativeMediaLibrary.h:453
media_status_t AImageReader_getHeight(const AImageReader *reader, int32_t *height) const
Definition: NativeMediaLibrary.h:579
bool AMediaFormat_getInt32(AMediaFormat *mediaFormat, const char *name, int32_t *out) const
Definition: NativeMediaLibrary.h:773
media_status_t(const AImageReader *reader, int32_t *maxImages) Function_AImageReader_getMaxImages
Definition: NativeMediaLibrary.h:143
const char * AMediaFormat_toString(AMediaFormat *format) const
Definition: NativeMediaLibrary.h:845
media_status_t AMediaMuxer_stop(AMediaMuxer *muxer) const
Definition: NativeMediaLibrary.h:901
ScopedSubscription initialize()
Initializes the media library.
media_status_t AImageReader_getWidth(const AImageReader *reader, int32_t *width) const
Definition: NativeMediaLibrary.h:571
media_status_t AImageReader_getWindow(AImageReader *reader, ANativeWindow **window) const
Definition: NativeMediaLibrary.h:563
AMediaFormat * AMediaExtractor_getTrackFormat(AMediaExtractor *mediaExtractor, size_t idx) const
Definition: NativeMediaLibrary.h:941
media_status_t AMediaExtractor_selectTrack(AMediaExtractor *mediaExtractor, size_t idx) const
Definition: NativeMediaLibrary.h:981
media_status_t AImageReader_getMaxImages(const AImageReader *reader, int32_t *maxImages) const
Definition: NativeMediaLibrary.h:595
media_status_t(AMediaCodec *codec, const AMediaFormat *format, ANativeWindow *surface, AMediaCrypto *crypto, uint32_t flags) Function_AMediaCodec_configure
Definition: NativeMediaLibrary.h:155
__attribute__((annotate("dynamic_fn_ptr"))) Function_AImage_delete *AImage_delete_
All AImage function pointers.
media_status_t(AMediaCodec *codec, size_t idx, bool render) Function_AMediaCodec_releaseOutputBuffer
Definition: NativeMediaLibrary.h:166
void AMediaFormat_setInt64(AMediaFormat *format, const char *name, int64_t value) const
Definition: NativeMediaLibrary.h:829
media_status_t AMediaCodec_start(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:741
bool AMediaFormat_getString(AMediaFormat *mediaFormat, const char *name, const char **out) const
Definition: NativeMediaLibrary.h:789
media_status_t AMediaExtractor_delete(AMediaExtractor *mediaExtractor) const
Definition: NativeMediaLibrary.h:925
void(AMediaFormat *format, const char *name, int32_t value) Function_AMediaFormat_setInt32
Definition: NativeMediaLibrary.h:181
media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec *codec, size_t idx, bool render) const
Definition: NativeMediaLibrary.h:733
media_status_t AMediaExtractor_setDataSource(AMediaExtractor *mediaExtractor, const char *location) const
Definition: NativeMediaLibrary.h:989
media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer, size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info) const
Definition: NativeMediaLibrary.h:909
media_status_t(const AImageReader *reader, int32_t *format) Function_AImageReader_getFormat
Definition: NativeMediaLibrary.h:142
media_status_t AImageReader_getFormat(const AImageReader *reader, int32_t *format) const
Definition: NativeMediaLibrary.h:587
bool(AMediaFormat *format, const char *name, const char **out) Function_AMediaFormat_getString
Definition: NativeMediaLibrary.h:177
media_status_t(AMediaFormat *format) Function_AMediaFormat_delete
Definition of the individual function pointers of AMediaFormat.
Definition: NativeMediaLibrary.h:173
const char *(AMediaFormat *format) Function_AMediaFormat_toString
Definition: NativeMediaLibrary.h:184
uint8_t * AMediaCodec_getInputBuffer(AMediaCodec *codec, size_t idx, size_t *out_size) const
Definition: NativeMediaLibrary.h:693
ssize_t AMediaMuxer_addTrack(AMediaMuxer *muxer, const AMediaFormat *format) const
The individual functions of AMediaMuxer.
Definition: NativeMediaLibrary.h:853
AMediaExtractor *() Function_AMediaExtractor_new
Definition: NativeMediaLibrary.h:206
media_status_t AImageReader_acquireLatestImage(AImageReader *reader, AImage **image) const
Definition: NativeMediaLibrary.h:611
media_status_t(AMediaCodec *codec) Function_AMediaCodec_flush
Definition: NativeMediaLibrary.h:159
size_t AMediaExtractor_getTrackCount(AMediaExtractor *mediaExtractor) const
Definition: NativeMediaLibrary.h:933
media_status_t AMediaMuxer_start(AMediaMuxer *muxer) const
Definition: NativeMediaLibrary.h:893
media_status_t AMediaFormat_delete(AMediaFormat *format) const
The individual functions of AMediaFormat.
Definition: NativeMediaLibrary.h:757
media_status_t(AMediaCodec *codec, size_t idx, unsigned int offset, size_t size, uint64_t time, uint32_t flags) Function_AMediaCodec_queueInputBuffer
Definition: NativeMediaLibrary.h:165
media_status_t AImage_getFormat(const AImage *image, int32_t *format) const
Definition: NativeMediaLibrary.h:491
AMediaCodec * AMediaCodec_createEncoderByType(const char *mime_type) const
Definition: NativeMediaLibrary.h:637
uint8_t *(AMediaCodec *codec, size_t idx, size_t *out_size) Function_AMediaCodec_getInputBuffer
Definition: NativeMediaLibrary.h:161
media_status_t AMediaCodec_queueInputBuffer(AMediaCodec *codec, size_t idx, unsigned int offset, size_t size, uint64_t time, uint32_t flags) const
Definition: NativeMediaLibrary.h:725
media_status_t(AMediaExtractor *mediaExtractor, size_t idx) Function_AMediaExtractor_selectTrack
Definition: NativeMediaLibrary.h:209
AMediaFormat *(AMediaCodec *codec, size_t index) Function_AMediaCodec_getBufferFormat
Definition: NativeMediaLibrary.h:160
media_status_t AMediaCodec_flush(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:677
media_status_t AImage_getTimestamp(const AImage *image, int64_t *timestampNs) const
Definition: NativeMediaLibrary.h:507
void(AImage *image) Function_AImage_delete
Definition of the individual function pointers of AImage.
Definition: NativeMediaLibrary.h:123
ssize_t(AMediaExtractor *mediaExtractor, uint8_t *buffer, size_t capacity) Function_AMediaExtractor_readSampleData
Definition: NativeMediaLibrary.h:207
media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor *mediaExtractor, int fd, off64_t offset, off64_t length) const
Definition: NativeMediaLibrary.h:997
media_status_t AMediaMuxer_delete(AMediaMuxer *muxer) const
Definition: NativeMediaLibrary.h:861
media_status_t(AMediaExtractor *mediaExtractor) Function_AMediaExtractor_delete
Definition: NativeMediaLibrary.h:202
media_status_t(const AImage *image, int32_t *width) Function_AImage_getWidth
Definition: NativeMediaLibrary.h:124
Lock lock_
The library's lock.
Definition: NativeMediaLibrary.h:438
media_status_t AImage_getHeight(const AImage *image, int32_t *height) const
Definition: NativeMediaLibrary.h:483
bool(AMediaExtractor *mediaExtractor) Function_AMediaExtractor_advance
Definition of the individual function pointers of AMediaExtractor.
Definition: NativeMediaLibrary.h:201
unsigned int initializationCounter_
The counter for counting the usage of this library.
Definition: NativeMediaLibrary.h:435
int64_t AMediaExtractor_getSampleTime(AMediaExtractor *mediaExtractor) const
Definition: NativeMediaLibrary.h:965
AMediaFormat *(AMediaExtractor *mediaExtractor, size_t idx) Function_AMediaExtractor_getTrackFormat
Definition: NativeMediaLibrary.h:205
media_status_t(AMediaCodec *codec) Function_AMediaCodec_start
Definition: NativeMediaLibrary.h:167
media_status_t(const AImage *image, int32_t *height) Function_AImage_getHeight
Definition: NativeMediaLibrary.h:125
media_status_t(AMediaExtractor *mediaExtractor, int64_t seekPosUs, SeekMode mode) Function_AMediaExtractor_seekTo
Definition: NativeMediaLibrary.h:208
media_status_t(int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader **reader) Function_AImageReader_new
Definition of the individual function pointers of AImageReader.
Definition: NativeMediaLibrary.h:137
void(AImageReader *reader) Function_AImageReader_delete
Definition: NativeMediaLibrary.h:138
size_t(AMediaExtractor *mediaExtractor) Function_AMediaExtractor_getTrackCount
Definition: NativeMediaLibrary.h:204
NativeMediaLibrary()
Protected default constructor.
bool(AMediaFormat *format, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) Function_AMediaFormat_getRect
Definition: NativeMediaLibrary.h:178
void(AMediaFormat *format, const char *name, const char *value) Function_AMediaFormat_setString
Definition: NativeMediaLibrary.h:183
bool AMediaExtractor_advance(AMediaExtractor *mediaExtractor) const
The individual functions of AMediaExtractor.
Definition: NativeMediaLibrary.h:917
media_status_t AMediaCodec_delete(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:653
AMediaMuxer *(int fd, OutputFormat format) Function_AMediaMuxer_new
Definition: NativeMediaLibrary.h:191
bool AMediaFormat_getInt64(AMediaFormat *mediaFormat, const char *name, int64_t *out) const
Definition: NativeMediaLibrary.h:781
uint8_t * AMediaCodec_getOutputBuffer(AMediaCodec *codec, size_t idx, size_t *out_size) const
Definition: NativeMediaLibrary.h:709
void AMediaFormat_setInt32(AMediaFormat *format, const char *name, int32_t value) const
Definition: NativeMediaLibrary.h:821
media_status_t AImage_getNumberOfPlanes(const AImage *image, int32_t *numPlanes) const
Definition: NativeMediaLibrary.h:515
media_status_t AMediaExtractor_seekTo(AMediaExtractor *mediaExtractor, int64_t seekPosUs, SeekMode mode) const
Definition: NativeMediaLibrary.h:973
media_status_t(AMediaCodec *codec) Function_AMediaCodec_delete
Definition: NativeMediaLibrary.h:156
void AMediaFormat_setBuffer(AMediaFormat *format, const char *name, const void *data, size_t size) const
Definition: NativeMediaLibrary.h:805
media_status_t(const AImage *image, AImageCropRect *rect) Function_AImage_getCropRect
Definition: NativeMediaLibrary.h:127
media_status_t AImage_getPlaneRowStride(const AImage *image, int planeIdx, int32_t *rowStride) const
Definition: NativeMediaLibrary.h:531
media_status_t AImage_getWidth(const AImage *image, int32_t *width) const
Definition: NativeMediaLibrary.h:475
void(AMediaFormat *format, const char *name, const void *data, size_t size) Function_AMediaFormat_setBuffer
Definition: NativeMediaLibrary.h:179
media_status_t(const AImage *image, int planeIdx, int32_t *rowStride) Function_AImage_getPlaneRowStride
Definition: NativeMediaLibrary.h:131
media_status_t(AMediaExtractor *mediaExtractor, int fd, off64_t offset, off64_t length) Function_AMediaExtractor_setDataSourceFd
Definition: NativeMediaLibrary.h:211
media_status_t(AMediaExtractor *mediaExtractor, const char *location) Function_AMediaExtractor_setDataSource
Definition: NativeMediaLibrary.h:210
AMediaFormat *(AMediaCodec *codec) Function_AMediaCodec_getOutputFormat
Definition: NativeMediaLibrary.h:164
media_status_t(AMediaMuxer *muxer, float latitude, float longitude) Function_AMediaMuxer_setLocation
Definition: NativeMediaLibrary.h:192
int64_t(AMediaExtractor *mediaExtractor) Function_AMediaExtractor_getSampleTime
Definition: NativeMediaLibrary.h:203
void release()
Releases the library.
uint8_t *(AMediaCodec *codec, size_t idx, size_t *out_size) Function_AMediaCodec_getOutputBuffer
Definition: NativeMediaLibrary.h:163
AMediaFormat * AMediaCodec_getInputFormat(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:701
ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec *codec, AMediaCodecBufferInfo *info, int64_t timeoutUs) const
Definition: NativeMediaLibrary.h:669
void uninitialize(const unsigned int unused)
Uninitializes the library.
AMediaCodec *(const char *mime_type) Function_AMediaCodec_createEncoderByType
Definition: NativeMediaLibrary.h:154
media_status_t AMediaCodec_stop(AMediaCodec *codec) const
Definition: NativeMediaLibrary.h:749
bool AMediaFormat_getRect(AMediaFormat *, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) const
Definition: NativeMediaLibrary.h:797
media_status_t(AImageReader *reader, AImageReader_ImageListener *listener) Function_AImageReader_setImageListener
Definition: NativeMediaLibrary.h:146
AMediaFormat * AMediaFormat_new() const
Definition: NativeMediaLibrary.h:765
AMediaMuxer * AMediaMuxer_new(int fd, OutputFormat format) const
Definition: NativeMediaLibrary.h:869
media_status_t(AImageReader *reader, AImage **image) Function_AImageReader_acquireLatestImage
Definition: NativeMediaLibrary.h:145
media_status_t(const AImage *image, int64_t *timestampNs) Function_AImage_getTimestamp
Definition: NativeMediaLibrary.h:128
media_status_t(const AImageReader *reader, int32_t *width) Function_AImageReader_getWidth
Definition: NativeMediaLibrary.h:140
bool(AMediaFormat *format, const char *name, int64_t *out) Function_AMediaFormat_getInt64
Definition: NativeMediaLibrary.h:176
AMediaExtractor * AMediaExtractor_new() const
Definition: NativeMediaLibrary.h:949
media_status_t AMediaMuxer_setLocation(AMediaMuxer *muxer, float latitude, float longitude) const
Definition: NativeMediaLibrary.h:877
media_status_t(AImageReader *reader, ANativeWindow **window) Function_AImageReader_getWindow
Definition: NativeMediaLibrary.h:139
media_status_t AImageReader_new(int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader **reader) const
The individual functions of AImageReader.
Definition: NativeMediaLibrary.h:547
ssize_t(AMediaCodec *codec, AMediaCodecBufferInfo *info, int64_t timeoutUs) Function_AMediaCodec_dequeueOutputBuffer
Definition: NativeMediaLibrary.h:158
media_status_t AImageReader_setImageListener(AImageReader *reader, AImageReader_ImageListener *listener) const
Definition: NativeMediaLibrary.h:619
bool(AMediaFormat *format, const char *name, int32_t *out) Function_AMediaFormat_getInt32
Definition: NativeMediaLibrary.h:175
bool isInitialized() const
Returns whether the library is initialized.
Definition: NativeMediaLibrary.h:458
media_status_t(AMediaMuxer *muxer) Function_AMediaMuxer_stop
Definition: NativeMediaLibrary.h:195
AMediaFormat *() Function_AMediaFormat_new
Definition: NativeMediaLibrary.h:174
media_status_t(AMediaMuxer *muxer) Function_AMediaMuxer_delete
Definition: NativeMediaLibrary.h:190
void AImageReader_delete(AImageReader *reader) const
Definition: NativeMediaLibrary.h:555
ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec *codec, int64_t timeoutUs) const
Definition: NativeMediaLibrary.h:661
__attribute__((annotate("dynamic_fn_ptr"))) Function_AMediaCodec_createDecoderByType *AMediaCodec_createDecoderByType_
All AMediaCodec function pointers.
media_status_t(AMediaMuxer *muxer, int degrees) Function_AMediaMuxer_setOrientationHint
Definition: NativeMediaLibrary.h:193
media_status_t AMediaCodec_configure(AMediaCodec *codec, const AMediaFormat *format, ANativeWindow *surface, AMediaCrypto *crypto, uint32_t flags) const
Definition: NativeMediaLibrary.h:645
AMediaFormat *(AMediaCodec *codec) Function_AMediaCodec_getInputFormat
Definition: NativeMediaLibrary.h:162
media_status_t(const AImage *image, int32_t *format) Function_AImage_getFormat
Definition: NativeMediaLibrary.h:126
ssize_t(AMediaMuxer *muxer, const AMediaFormat *format) Function_AMediaMuxer_addTrack
Definition of the individual function pointers of AMediaMuxer.
Definition: NativeMediaLibrary.h:189
ssize_t(AMediaCodec *codec, int64_t timeoutUs) Function_AMediaCodec_dequeueInputBuffer
Definition: NativeMediaLibrary.h:157
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class wraps an unmanaged object (or reference) which needs to be released after usage.
Definition: ScopedObject.h:28
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