blob: 0da0740fc94b200267478056a6d1880c6c4d587b [file] [log] [blame]
Marco Nelissen0c3be872014-05-01 10:14:44 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Marco Nelissenc7a11b22014-05-30 10:13:25 -070017//#define LOG_NDEBUG 0
Marco Nelissen0c3be872014-05-01 10:14:44 -070018#define LOG_TAG "NdkMediaExtractor"
19
20
Colin Cross7e8d4ba2017-05-04 16:17:42 -070021#include <media/NdkMediaError.h>
22#include <media/NdkMediaExtractor.h>
Marco Nelissen5dcf85a2018-10-11 09:49:02 -070023#include <media/NdkMediaErrorPriv.h>
Marco Nelissen98603d82018-07-17 11:06:55 -070024#include <media/NdkMediaFormatPriv.h>
Robert Shih0df451b2017-12-08 14:16:50 -080025#include "NdkMediaDataSourcePriv.h"
Marco Nelissen0c3be872014-05-01 10:14:44 -070026
27
Aurimas Liutikas214c8332016-02-19 14:48:23 -080028#include <inttypes.h>
Marco Nelissen0c3be872014-05-01 10:14:44 -070029#include <utils/Log.h>
30#include <utils/StrongPointer.h>
Marco Nelissen050eb322014-05-09 15:10:23 -070031#include <media/hardware/CryptoAPI.h>
Marco Nelissen0c3be872014-05-01 10:14:44 -070032#include <media/stagefright/foundation/ABuffer.h>
33#include <media/stagefright/foundation/AMessage.h>
34#include <media/stagefright/MetaData.h>
35#include <media/stagefright/NuMediaExtractor.h>
36#include <media/IMediaHTTPService.h>
Marco Nelissen0c3be872014-05-01 10:14:44 -070037#include <android_util_Binder.h>
38
39#include <jni.h>
40
41using namespace android;
42
Marco Nelissen0c3be872014-05-01 10:14:44 -070043struct AMediaExtractor {
44 sp<NuMediaExtractor> mImpl;
Marco Nelissen050eb322014-05-09 15:10:23 -070045 sp<ABuffer> mPsshBuf;
Marco Nelissen0c3be872014-05-01 10:14:44 -070046};
47
Robert Shih0b4530d2019-01-18 12:12:03 -080048sp<ABuffer> U32ArrayToSizeBuf(size_t numSubSamples, uint32_t *data) {
49 if (numSubSamples > SIZE_MAX / sizeof(size_t)) {
50 return NULL;
51 }
52 sp<ABuffer> sizebuf = new ABuffer(numSubSamples * sizeof(size_t));
53 size_t *sizes = (size_t *)sizebuf->data();
54 for (size_t i = 0; sizes != NULL && i < numSubSamples; i++) {
55 sizes[i] = data[i];
56 }
57 return sizebuf;
58}
59
Marco Nelissen0c3be872014-05-01 10:14:44 -070060extern "C" {
61
Marco Nelissen3425fd52014-05-14 11:12:46 -070062EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -070063AMediaExtractor* AMediaExtractor_new() {
64 ALOGV("ctor");
65 AMediaExtractor *mData = new AMediaExtractor();
66 mData->mImpl = new NuMediaExtractor();
67 return mData;
68}
69
Marco Nelissen3425fd52014-05-14 11:12:46 -070070EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -070071media_status_t AMediaExtractor_delete(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -070072 ALOGV("dtor");
73 delete mData;
Marco Nelissene419d7c2014-05-15 14:17:25 -070074 return AMEDIA_OK;
Marco Nelissen0c3be872014-05-01 10:14:44 -070075}
76
Marco Nelissen3425fd52014-05-14 11:12:46 -070077EXPORT
Glenn Kastenb187de12014-12-30 08:18:15 -080078media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor *mData, int fd, off64_t offset,
79 off64_t length) {
Aurimas Liutikas214c8332016-02-19 14:48:23 -080080 ALOGV("setDataSource(%d, %" PRId64 ", %" PRId64 ")", fd, offset, length);
Marco Nelissene419d7c2014-05-15 14:17:25 -070081 return translate_error(mData->mImpl->setDataSource(fd, offset, length));
Marco Nelissen0c3be872014-05-01 10:14:44 -070082}
83
Robert Shih6a59e4a2018-08-30 13:31:28 -070084media_status_t AMediaExtractor_setDataSourceWithHeaders(AMediaExtractor *mData,
85 const char *uri,
86 int numheaders,
87 const char * const *keys,
88 const char * const *values) {
89
90 ALOGV("setDataSource(%s)", uri);
Marco Nelissen0c3be872014-05-01 10:14:44 -070091
Marco Nelissena5232042019-09-24 09:27:40 -070092 sp<MediaHTTPService> httpService = createMediaHttpService(uri);
Robert Shih730af222018-09-14 14:02:57 -070093 if (httpService == NULL) {
94 ALOGE("can't create http service");
Marco Nelissene419d7c2014-05-15 14:17:25 -070095 return AMEDIA_ERROR_UNSUPPORTED;
Marco Nelissen0c3be872014-05-01 10:14:44 -070096 }
97
Robert Shih6a59e4a2018-08-30 13:31:28 -070098 KeyedVector<String8, String8> headers;
99 for (int i = 0; i < numheaders; ++i) {
100 String8 key8(keys[i]);
101 String8 value8(values[i]);
102 headers.add(key8, value8);
103 }
104
105 status_t err;
106 err = mData->mImpl->setDataSource(httpService, uri, numheaders > 0 ? &headers : NULL);
Marco Nelissene419d7c2014-05-15 14:17:25 -0700107 return translate_error(err);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700108}
109
Marco Nelissen3425fd52014-05-14 11:12:46 -0700110EXPORT
Robert Shih82248d12018-10-03 15:57:47 -0700111media_status_t AMediaExtractor_setDataSource(AMediaExtractor *mData, const char *location) {
112 return AMediaExtractor_setDataSourceWithHeaders(mData, location, 0, NULL, NULL);
113}
114
115EXPORT
Robert Shih0df451b2017-12-08 14:16:50 -0800116media_status_t AMediaExtractor_setDataSourceCustom(AMediaExtractor* mData, AMediaDataSource *src) {
117 return translate_error(mData->mImpl->setDataSource(new NdkDataSource(src)));
118}
119
120EXPORT
Robert Shih30e3c7d2018-01-21 17:06:12 -0800121AMediaFormat* AMediaExtractor_getFileFormat(AMediaExtractor *mData) {
122 sp<AMessage> format;
123 mData->mImpl->getFileFormat(&format);
124 return AMediaFormat_fromMsg(&format);
125}
126
127EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700128size_t AMediaExtractor_getTrackCount(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700129 return mData->mImpl->countTracks();
130}
131
Marco Nelissen3425fd52014-05-14 11:12:46 -0700132EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700133AMediaFormat* AMediaExtractor_getTrackFormat(AMediaExtractor *mData, size_t idx) {
134 sp<AMessage> format;
135 mData->mImpl->getTrackFormat(idx, &format);
136 return AMediaFormat_fromMsg(&format);
137}
138
Marco Nelissen3425fd52014-05-14 11:12:46 -0700139EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700140media_status_t AMediaExtractor_selectTrack(AMediaExtractor *mData, size_t idx) {
Mark Salyzyn98f28cd2014-06-18 16:32:50 -0700141 ALOGV("selectTrack(%zu)", idx);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700142 return translate_error(mData->mImpl->selectTrack(idx));
143}
144
Marco Nelissen3425fd52014-05-14 11:12:46 -0700145EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700146media_status_t AMediaExtractor_unselectTrack(AMediaExtractor *mData, size_t idx) {
Mark Salyzyn98f28cd2014-06-18 16:32:50 -0700147 ALOGV("unselectTrack(%zu)", idx);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700148 return translate_error(mData->mImpl->unselectTrack(idx));
149}
150
Marco Nelissen3425fd52014-05-14 11:12:46 -0700151EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700152bool AMediaExtractor_advance(AMediaExtractor *mData) {
153 //ALOGV("advance");
Robert Shih70452262016-09-16 16:43:49 -0700154 status_t err = mData->mImpl->advance();
155 if (err == ERROR_END_OF_STREAM) {
156 return false;
157 } else if (err != OK) {
158 ALOGE("sf error code: %d", err);
159 return false;
160 }
161 return true;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700162}
163
Marco Nelissen3425fd52014-05-14 11:12:46 -0700164EXPORT
Marco Nelissen79e2b622014-05-16 08:07:28 -0700165media_status_t AMediaExtractor_seekTo(AMediaExtractor *ex, int64_t seekPosUs, SeekMode mode) {
166 android::MediaSource::ReadOptions::SeekMode sfmode;
167 if (mode == AMEDIAEXTRACTOR_SEEK_PREVIOUS_SYNC) {
168 sfmode = android::MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
169 } else if (mode == AMEDIAEXTRACTOR_SEEK_CLOSEST_SYNC) {
170 sfmode = android::MediaSource::ReadOptions::SEEK_CLOSEST_SYNC;
171 } else {
172 sfmode = android::MediaSource::ReadOptions::SEEK_NEXT_SYNC;
173 }
174
175 return translate_error(ex->mImpl->seekTo(seekPosUs, sfmode));
176}
177
178EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700179ssize_t AMediaExtractor_readSampleData(AMediaExtractor *mData, uint8_t *buffer, size_t capacity) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700180 //ALOGV("readSampleData");
181 sp<ABuffer> tmp = new ABuffer(buffer, capacity);
182 if (mData->mImpl->readSampleData(tmp) == OK) {
183 return tmp->size();
184 }
185 return -1;
186}
187
Marco Nelissen3425fd52014-05-14 11:12:46 -0700188EXPORT
Robert Shih30e3c7d2018-01-21 17:06:12 -0800189ssize_t AMediaExtractor_getSampleSize(AMediaExtractor *mData) {
190 size_t sampleSize;
191 status_t err = mData->mImpl->getSampleSize(&sampleSize);
192 if (err != OK) {
193 return -1;
194 }
195 return sampleSize;
196}
197
198EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700199uint32_t AMediaExtractor_getSampleFlags(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700200 int sampleFlags = 0;
201 sp<MetaData> meta;
202 status_t err = mData->mImpl->getSampleMeta(&meta);
203 if (err != OK) {
204 return -1;
205 }
206 int32_t val;
207 if (meta->findInt32(kKeyIsSyncFrame, &val) && val != 0) {
Marco Nelissene419d7c2014-05-15 14:17:25 -0700208 sampleFlags |= AMEDIAEXTRACTOR_SAMPLE_FLAG_SYNC;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700209 }
210
211 uint32_t type;
212 const void *data;
213 size_t size;
214 if (meta->findData(kKeyEncryptedSizes, &type, &data, &size)) {
Marco Nelissene419d7c2014-05-15 14:17:25 -0700215 sampleFlags |= AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700216 }
217 return sampleFlags;
218}
219
Marco Nelissen3425fd52014-05-14 11:12:46 -0700220EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700221int AMediaExtractor_getSampleTrackIndex(AMediaExtractor *mData) {
222 size_t idx;
223 if (mData->mImpl->getSampleTrackIndex(&idx) != OK) {
224 return -1;
225 }
226 return idx;
227}
228
Marco Nelissen3425fd52014-05-14 11:12:46 -0700229EXPORT
Marco Nelisseneb4860c2014-05-29 08:04:34 -0700230int64_t AMediaExtractor_getSampleTime(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700231 int64_t time;
232 if (mData->mImpl->getSampleTime(&time) != OK) {
233 return -1;
234 }
235 return time;
236}
237
Marco Nelissen3425fd52014-05-14 11:12:46 -0700238EXPORT
Marco Nelissen050eb322014-05-09 15:10:23 -0700239PsshInfo* AMediaExtractor_getPsshInfo(AMediaExtractor *ex) {
240
241 if (ex->mPsshBuf != NULL) {
242 return (PsshInfo*) ex->mPsshBuf->data();
243 }
244
245 sp<AMessage> format;
246 ex->mImpl->getFileFormat(&format);
247 sp<ABuffer> buffer;
248 if(!format->findBuffer("pssh", &buffer)) {
249 return NULL;
250 }
251
252 // the format of the buffer is 1 or more of:
253 // {
254 // 16 byte uuid
255 // 4 byte data length N
256 // N bytes of data
257 // }
258
259 // Determine the number of entries in the source data.
260 // Since we got the data from stagefright, we trust it is valid and properly formatted.
261 const uint8_t* data = buffer->data();
262 size_t len = buffer->size();
263 size_t numentries = 0;
264 while (len > 0) {
265 numentries++;
266
Marco Nelissen346bb512015-04-09 14:32:45 -0700267 if (len < 16) {
268 ALOGE("invalid PSSH data");
269 return NULL;
270 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700271 // skip uuid
272 data += 16;
273 len -= 16;
274
275 // get data length
Marco Nelissen346bb512015-04-09 14:32:45 -0700276 if (len < 4) {
277 ALOGE("invalid PSSH data");
278 return NULL;
279 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700280 uint32_t datalen = *((uint32_t*)data);
281 data += 4;
282 len -= 4;
283
Marco Nelissen346bb512015-04-09 14:32:45 -0700284 if (len < datalen) {
285 ALOGE("invalid PSSH data");
286 return NULL;
287 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700288 // skip the data
289 data += datalen;
290 len -= datalen;
291 }
292
Marco Nelissen58344bc2014-10-23 11:36:38 -0700293 // there are <numentries> in the source buffer, we need
294 // (source buffer size) - (sizeof(uint32_t) * numentries) + sizeof(size_t)
295 // + ((sizeof(void*) + sizeof(size_t)) * numentries) bytes for the PsshInfo structure
296 // Or in other words, the data lengths in the source structure are replaced by size_t
297 // (which may be the same size or larger, for 64 bit), and in addition there is an
298 // extra pointer for each entry, and an extra size_t for the entire PsshInfo.
299 size_t newsize = buffer->size() - (sizeof(uint32_t) * numentries) + sizeof(size_t)
300 + ((sizeof(void*) + sizeof(size_t)) * numentries);
Marco Nelissen346bb512015-04-09 14:32:45 -0700301 if (newsize <= buffer->size()) {
302 ALOGE("invalid PSSH data");
303 return NULL;
304 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700305 ex->mPsshBuf = new ABuffer(newsize);
306 ex->mPsshBuf->setRange(0, newsize);
307
308 // copy data
309 const uint8_t* src = buffer->data();
310 uint8_t* dst = ex->mPsshBuf->data();
Marco Nelissen58344bc2014-10-23 11:36:38 -0700311 uint8_t* dstdata = dst + sizeof(size_t) + numentries * sizeof(PsshEntry);
312 *((size_t*)dst) = numentries;
313 dst += sizeof(size_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700314 for (size_t i = 0; i < numentries; i++) {
315 // copy uuid
316 memcpy(dst, src, 16);
317 src += 16;
318 dst += 16;
319
320 // get/copy data length
321 uint32_t datalen = *((uint32_t*)src);
Marco Nelissen58344bc2014-10-23 11:36:38 -0700322 *((size_t*)dst) = datalen;
323 src += sizeof(uint32_t);
324 dst += sizeof(size_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700325
326 // the next entry in the destination is a pointer to the actual data, which we store
327 // after the array of PsshEntry
Marco Nelissen58344bc2014-10-23 11:36:38 -0700328 *((void**)dst) = dstdata;
329 dst += sizeof(void*);
Marco Nelissen050eb322014-05-09 15:10:23 -0700330
331 // copy the actual data
332 memcpy(dstdata, src, datalen);
333 dstdata += datalen;
334 src += datalen;
335 }
336
337 return (PsshInfo*) ex->mPsshBuf->data();
338}
339
Marco Nelissen3425fd52014-05-14 11:12:46 -0700340EXPORT
Marco Nelissen050eb322014-05-09 15:10:23 -0700341AMediaCodecCryptoInfo *AMediaExtractor_getSampleCryptoInfo(AMediaExtractor *ex) {
342 sp<MetaData> meta;
343 if(ex->mImpl->getSampleMeta(&meta) != 0) {
344 return NULL;
345 }
346
347 uint32_t type;
348 const void *crypteddata;
349 size_t cryptedsize;
350 if (!meta->findData(kKeyEncryptedSizes, &type, &crypteddata, &cryptedsize)) {
351 return NULL;
352 }
Robert Shih0b4530d2019-01-18 12:12:03 -0800353 size_t numSubSamples = cryptedsize / sizeof(uint32_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700354
355 const void *cleardata;
356 size_t clearsize;
357 if (meta->findData(kKeyPlainSizes, &type, &cleardata, &clearsize)) {
358 if (clearsize != cryptedsize) {
359 // The two must be of the same length.
360 return NULL;
361 }
362 }
363
364 const void *key;
365 size_t keysize;
Edwin Wongb2fb3c92016-08-29 14:57:47 -0700366 if (meta->findData(kKeyCryptoKey, &type, &key, &keysize)) {
Marco Nelissen050eb322014-05-09 15:10:23 -0700367 if (keysize != 16) {
Edwin Wongb2fb3c92016-08-29 14:57:47 -0700368 // Keys must be 16 bytes in length.
Marco Nelissen050eb322014-05-09 15:10:23 -0700369 return NULL;
370 }
371 }
372
373 const void *iv;
374 size_t ivsize;
375 if (meta->findData(kKeyCryptoIV, &type, &iv, &ivsize)) {
376 if (ivsize != 16) {
377 // IVs must be 16 bytes in length.
378 return NULL;
379 }
380 }
381
382 int32_t mode;
383 if (!meta->findInt32(kKeyCryptoMode, &mode)) {
384 mode = CryptoPlugin::kMode_AES_CTR;
385 }
386
Robert Shih0b4530d2019-01-18 12:12:03 -0800387 if (sizeof(uint32_t) != sizeof(size_t)) {
388 sp<ABuffer> clearbuf = U32ArrayToSizeBuf(numSubSamples, (uint32_t *)cleardata);
389 sp<ABuffer> cryptedbuf = U32ArrayToSizeBuf(numSubSamples, (uint32_t *)crypteddata);
390 cleardata = clearbuf == NULL ? NULL : clearbuf->data();
391 crypteddata = crypteddata == NULL ? NULL : cryptedbuf->data();
392 if(crypteddata == NULL || cleardata == NULL) {
393 return NULL;
394 }
395 }
396
Marco Nelissen050eb322014-05-09 15:10:23 -0700397 return AMediaCodecCryptoInfo_new(
398 numSubSamples,
399 (uint8_t*) key,
400 (uint8_t*) iv,
Marco Nelissen79e2b622014-05-16 08:07:28 -0700401 (cryptoinfo_mode_t) mode,
Marco Nelissen050eb322014-05-09 15:10:23 -0700402 (size_t*) cleardata,
403 (size_t*) crypteddata);
404}
405
Robert Shih30e3c7d2018-01-21 17:06:12 -0800406EXPORT
407int64_t AMediaExtractor_getCachedDuration(AMediaExtractor *ex) {
408 bool eos;
409 int64_t durationUs;
410 if (ex->mImpl->getCachedDuration(&durationUs, &eos)) {
411 return durationUs;
412 }
413 return -1;
414}
Marco Nelissen0c3be872014-05-01 10:14:44 -0700415
Robert Shihd83d4f42018-02-24 19:02:46 -0800416EXPORT
417media_status_t AMediaExtractor_getSampleFormat(AMediaExtractor *ex, AMediaFormat *fmt) {
418 if (fmt == NULL) {
419 return AMEDIA_ERROR_INVALID_PARAMETER;
420 }
421
422 sp<MetaData> sampleMeta;
423 status_t err = ex->mImpl->getSampleMeta(&sampleMeta);
424 if (err != OK) {
425 return translate_error(err);
426 }
427
428 sp<AMessage> meta;
429 AMediaFormat_getFormat(fmt, &meta);
430 meta->clear();
431
432 int32_t layerId;
433 if (sampleMeta->findInt32(kKeyTemporalLayerId, &layerId)) {
434 meta->setInt32(AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID, layerId);
435 }
436
437 size_t trackIndex;
438 err = ex->mImpl->getSampleTrackIndex(&trackIndex);
439 if (err == OK) {
440 meta->setInt32(AMEDIAFORMAT_KEY_TRACK_INDEX, trackIndex);
441 sp<AMessage> trackFormat;
442 AString mime;
443 err = ex->mImpl->getTrackFormat(trackIndex, &trackFormat);
444 if (err == OK
445 && trackFormat != NULL
446 && trackFormat->findString(AMEDIAFORMAT_KEY_MIME, &mime)) {
447 meta->setString(AMEDIAFORMAT_KEY_MIME, mime);
448 }
449 }
450
451 int64_t durationUs;
452 if (sampleMeta->findInt64(kKeyDuration, &durationUs)) {
453 meta->setInt64(AMEDIAFORMAT_KEY_DURATION, durationUs);
454 }
455
456 uint32_t dataType; // unused
457 const void *seiData;
458 size_t seiLength;
459 if (sampleMeta->findData(kKeySEI, &dataType, &seiData, &seiLength)) {
460 sp<ABuffer> sei = ABuffer::CreateAsCopy(seiData, seiLength);;
461 meta->setBuffer(AMEDIAFORMAT_KEY_SEI, sei);
462 }
463
464 const void *mpegUserDataPointer;
465 size_t mpegUserDataLength;
466 if (sampleMeta->findData(
467 kKeyMpegUserData, &dataType, &mpegUserDataPointer, &mpegUserDataLength)) {
468 sp<ABuffer> mpegUserData = ABuffer::CreateAsCopy(mpegUserDataPointer, mpegUserDataLength);
469 meta->setBuffer(AMEDIAFORMAT_KEY_MPEG_USER_DATA, mpegUserData);
470 }
471
Sampath Shettyc6148a62018-12-18 15:50:43 +1100472 const void *audioPresentationsPointer;
473 size_t audioPresentationsLength;
474 if (sampleMeta->findData(
475 kKeyAudioPresentationInfo, &dataType,
476 &audioPresentationsPointer, &audioPresentationsLength)) {
477 sp<ABuffer> audioPresentationsData = ABuffer::CreateAsCopy(
478 audioPresentationsPointer, audioPresentationsLength);
479 meta->setBuffer(AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO, audioPresentationsData);
480 }
481
Robert Shihd83d4f42018-02-24 19:02:46 -0800482 return AMEDIA_OK;
483}
484
Marco Nelissen0c3be872014-05-01 10:14:44 -0700485} // extern "C"
486