blob: 28e4f128805f86c251388d4b1a89e22a6c430dca [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>
37#include <android_runtime/AndroidRuntime.h>
38#include <android_util_Binder.h>
39
40#include <jni.h>
41
42using namespace android;
43
Marco Nelissen0c3be872014-05-01 10:14:44 -070044struct AMediaExtractor {
45 sp<NuMediaExtractor> mImpl;
Marco Nelissen050eb322014-05-09 15:10:23 -070046 sp<ABuffer> mPsshBuf;
Marco Nelissen0c3be872014-05-01 10:14:44 -070047};
48
Robert Shih0b4530d2019-01-18 12:12:03 -080049sp<ABuffer> U32ArrayToSizeBuf(size_t numSubSamples, uint32_t *data) {
50 if (numSubSamples > SIZE_MAX / sizeof(size_t)) {
51 return NULL;
52 }
53 sp<ABuffer> sizebuf = new ABuffer(numSubSamples * sizeof(size_t));
54 size_t *sizes = (size_t *)sizebuf->data();
55 for (size_t i = 0; sizes != NULL && i < numSubSamples; i++) {
56 sizes[i] = data[i];
57 }
58 return sizebuf;
59}
60
Marco Nelissen0c3be872014-05-01 10:14:44 -070061extern "C" {
62
Marco Nelissen3425fd52014-05-14 11:12:46 -070063EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -070064AMediaExtractor* AMediaExtractor_new() {
65 ALOGV("ctor");
66 AMediaExtractor *mData = new AMediaExtractor();
67 mData->mImpl = new NuMediaExtractor();
68 return mData;
69}
70
Marco Nelissen3425fd52014-05-14 11:12:46 -070071EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -070072media_status_t AMediaExtractor_delete(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -070073 ALOGV("dtor");
74 delete mData;
Marco Nelissene419d7c2014-05-15 14:17:25 -070075 return AMEDIA_OK;
Marco Nelissen0c3be872014-05-01 10:14:44 -070076}
77
Marco Nelissen3425fd52014-05-14 11:12:46 -070078EXPORT
Glenn Kastenb187de12014-12-30 08:18:15 -080079media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor *mData, int fd, off64_t offset,
80 off64_t length) {
Aurimas Liutikas214c8332016-02-19 14:48:23 -080081 ALOGV("setDataSource(%d, %" PRId64 ", %" PRId64 ")", fd, offset, length);
Marco Nelissene419d7c2014-05-15 14:17:25 -070082 return translate_error(mData->mImpl->setDataSource(fd, offset, length));
Marco Nelissen0c3be872014-05-01 10:14:44 -070083}
84
Robert Shih6a59e4a2018-08-30 13:31:28 -070085media_status_t AMediaExtractor_setDataSourceWithHeaders(AMediaExtractor *mData,
86 const char *uri,
87 int numheaders,
88 const char * const *keys,
89 const char * const *values) {
90
91 ALOGV("setDataSource(%s)", uri);
Marco Nelissen0c3be872014-05-01 10:14:44 -070092
Robert Shih730af222018-09-14 14:02:57 -070093 sp<MediaHTTPService> httpService = createMediaHttpService(uri, /* version = */ 1);
94 if (httpService == NULL) {
95 ALOGE("can't create http service");
Marco Nelissene419d7c2014-05-15 14:17:25 -070096 return AMEDIA_ERROR_UNSUPPORTED;
Marco Nelissen0c3be872014-05-01 10:14:44 -070097 }
98
Robert Shih6a59e4a2018-08-30 13:31:28 -070099 KeyedVector<String8, String8> headers;
100 for (int i = 0; i < numheaders; ++i) {
101 String8 key8(keys[i]);
102 String8 value8(values[i]);
103 headers.add(key8, value8);
104 }
105
106 status_t err;
107 err = mData->mImpl->setDataSource(httpService, uri, numheaders > 0 ? &headers : NULL);
Marco Nelissene419d7c2014-05-15 14:17:25 -0700108 return translate_error(err);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700109}
110
Marco Nelissen3425fd52014-05-14 11:12:46 -0700111EXPORT
Robert Shih82248d12018-10-03 15:57:47 -0700112media_status_t AMediaExtractor_setDataSource(AMediaExtractor *mData, const char *location) {
113 return AMediaExtractor_setDataSourceWithHeaders(mData, location, 0, NULL, NULL);
114}
115
116EXPORT
Robert Shih0df451b2017-12-08 14:16:50 -0800117media_status_t AMediaExtractor_setDataSourceCustom(AMediaExtractor* mData, AMediaDataSource *src) {
118 return translate_error(mData->mImpl->setDataSource(new NdkDataSource(src)));
119}
120
121EXPORT
Robert Shih30e3c7d2018-01-21 17:06:12 -0800122AMediaFormat* AMediaExtractor_getFileFormat(AMediaExtractor *mData) {
123 sp<AMessage> format;
124 mData->mImpl->getFileFormat(&format);
125 return AMediaFormat_fromMsg(&format);
126}
127
128EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700129size_t AMediaExtractor_getTrackCount(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700130 return mData->mImpl->countTracks();
131}
132
Marco Nelissen3425fd52014-05-14 11:12:46 -0700133EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700134AMediaFormat* AMediaExtractor_getTrackFormat(AMediaExtractor *mData, size_t idx) {
135 sp<AMessage> format;
136 mData->mImpl->getTrackFormat(idx, &format);
137 return AMediaFormat_fromMsg(&format);
138}
139
Marco Nelissen3425fd52014-05-14 11:12:46 -0700140EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700141media_status_t AMediaExtractor_selectTrack(AMediaExtractor *mData, size_t idx) {
Mark Salyzyn98f28cd2014-06-18 16:32:50 -0700142 ALOGV("selectTrack(%zu)", idx);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700143 return translate_error(mData->mImpl->selectTrack(idx));
144}
145
Marco Nelissen3425fd52014-05-14 11:12:46 -0700146EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700147media_status_t AMediaExtractor_unselectTrack(AMediaExtractor *mData, size_t idx) {
Mark Salyzyn98f28cd2014-06-18 16:32:50 -0700148 ALOGV("unselectTrack(%zu)", idx);
Marco Nelissen0c3be872014-05-01 10:14:44 -0700149 return translate_error(mData->mImpl->unselectTrack(idx));
150}
151
Marco Nelissen3425fd52014-05-14 11:12:46 -0700152EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700153bool AMediaExtractor_advance(AMediaExtractor *mData) {
154 //ALOGV("advance");
Robert Shih70452262016-09-16 16:43:49 -0700155 status_t err = mData->mImpl->advance();
156 if (err == ERROR_END_OF_STREAM) {
157 return false;
158 } else if (err != OK) {
159 ALOGE("sf error code: %d", err);
160 return false;
161 }
162 return true;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700163}
164
Marco Nelissen3425fd52014-05-14 11:12:46 -0700165EXPORT
Marco Nelissen79e2b622014-05-16 08:07:28 -0700166media_status_t AMediaExtractor_seekTo(AMediaExtractor *ex, int64_t seekPosUs, SeekMode mode) {
167 android::MediaSource::ReadOptions::SeekMode sfmode;
168 if (mode == AMEDIAEXTRACTOR_SEEK_PREVIOUS_SYNC) {
169 sfmode = android::MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
170 } else if (mode == AMEDIAEXTRACTOR_SEEK_CLOSEST_SYNC) {
171 sfmode = android::MediaSource::ReadOptions::SEEK_CLOSEST_SYNC;
172 } else {
173 sfmode = android::MediaSource::ReadOptions::SEEK_NEXT_SYNC;
174 }
175
176 return translate_error(ex->mImpl->seekTo(seekPosUs, sfmode));
177}
178
179EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700180ssize_t AMediaExtractor_readSampleData(AMediaExtractor *mData, uint8_t *buffer, size_t capacity) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700181 //ALOGV("readSampleData");
182 sp<ABuffer> tmp = new ABuffer(buffer, capacity);
183 if (mData->mImpl->readSampleData(tmp) == OK) {
184 return tmp->size();
185 }
186 return -1;
187}
188
Marco Nelissen3425fd52014-05-14 11:12:46 -0700189EXPORT
Robert Shih30e3c7d2018-01-21 17:06:12 -0800190ssize_t AMediaExtractor_getSampleSize(AMediaExtractor *mData) {
191 size_t sampleSize;
192 status_t err = mData->mImpl->getSampleSize(&sampleSize);
193 if (err != OK) {
194 return -1;
195 }
196 return sampleSize;
197}
198
199EXPORT
Marco Nelissene419d7c2014-05-15 14:17:25 -0700200uint32_t AMediaExtractor_getSampleFlags(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700201 int sampleFlags = 0;
202 sp<MetaData> meta;
203 status_t err = mData->mImpl->getSampleMeta(&meta);
204 if (err != OK) {
205 return -1;
206 }
207 int32_t val;
208 if (meta->findInt32(kKeyIsSyncFrame, &val) && val != 0) {
Marco Nelissene419d7c2014-05-15 14:17:25 -0700209 sampleFlags |= AMEDIAEXTRACTOR_SAMPLE_FLAG_SYNC;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700210 }
211
212 uint32_t type;
213 const void *data;
214 size_t size;
215 if (meta->findData(kKeyEncryptedSizes, &type, &data, &size)) {
Marco Nelissene419d7c2014-05-15 14:17:25 -0700216 sampleFlags |= AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED;
Marco Nelissen0c3be872014-05-01 10:14:44 -0700217 }
218 return sampleFlags;
219}
220
Marco Nelissen3425fd52014-05-14 11:12:46 -0700221EXPORT
Marco Nelissen0c3be872014-05-01 10:14:44 -0700222int AMediaExtractor_getSampleTrackIndex(AMediaExtractor *mData) {
223 size_t idx;
224 if (mData->mImpl->getSampleTrackIndex(&idx) != OK) {
225 return -1;
226 }
227 return idx;
228}
229
Marco Nelissen3425fd52014-05-14 11:12:46 -0700230EXPORT
Marco Nelisseneb4860c2014-05-29 08:04:34 -0700231int64_t AMediaExtractor_getSampleTime(AMediaExtractor *mData) {
Marco Nelissen0c3be872014-05-01 10:14:44 -0700232 int64_t time;
233 if (mData->mImpl->getSampleTime(&time) != OK) {
234 return -1;
235 }
236 return time;
237}
238
Marco Nelissen3425fd52014-05-14 11:12:46 -0700239EXPORT
Marco Nelissen050eb322014-05-09 15:10:23 -0700240PsshInfo* AMediaExtractor_getPsshInfo(AMediaExtractor *ex) {
241
242 if (ex->mPsshBuf != NULL) {
243 return (PsshInfo*) ex->mPsshBuf->data();
244 }
245
246 sp<AMessage> format;
247 ex->mImpl->getFileFormat(&format);
248 sp<ABuffer> buffer;
249 if(!format->findBuffer("pssh", &buffer)) {
250 return NULL;
251 }
252
253 // the format of the buffer is 1 or more of:
254 // {
255 // 16 byte uuid
256 // 4 byte data length N
257 // N bytes of data
258 // }
259
260 // Determine the number of entries in the source data.
261 // Since we got the data from stagefright, we trust it is valid and properly formatted.
262 const uint8_t* data = buffer->data();
263 size_t len = buffer->size();
264 size_t numentries = 0;
265 while (len > 0) {
266 numentries++;
267
Marco Nelissen346bb512015-04-09 14:32:45 -0700268 if (len < 16) {
269 ALOGE("invalid PSSH data");
270 return NULL;
271 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700272 // skip uuid
273 data += 16;
274 len -= 16;
275
276 // get data length
Marco Nelissen346bb512015-04-09 14:32:45 -0700277 if (len < 4) {
278 ALOGE("invalid PSSH data");
279 return NULL;
280 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700281 uint32_t datalen = *((uint32_t*)data);
282 data += 4;
283 len -= 4;
284
Marco Nelissen346bb512015-04-09 14:32:45 -0700285 if (len < datalen) {
286 ALOGE("invalid PSSH data");
287 return NULL;
288 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700289 // skip the data
290 data += datalen;
291 len -= datalen;
292 }
293
Marco Nelissen58344bc2014-10-23 11:36:38 -0700294 // there are <numentries> in the source buffer, we need
295 // (source buffer size) - (sizeof(uint32_t) * numentries) + sizeof(size_t)
296 // + ((sizeof(void*) + sizeof(size_t)) * numentries) bytes for the PsshInfo structure
297 // Or in other words, the data lengths in the source structure are replaced by size_t
298 // (which may be the same size or larger, for 64 bit), and in addition there is an
299 // extra pointer for each entry, and an extra size_t for the entire PsshInfo.
300 size_t newsize = buffer->size() - (sizeof(uint32_t) * numentries) + sizeof(size_t)
301 + ((sizeof(void*) + sizeof(size_t)) * numentries);
Marco Nelissen346bb512015-04-09 14:32:45 -0700302 if (newsize <= buffer->size()) {
303 ALOGE("invalid PSSH data");
304 return NULL;
305 }
Marco Nelissen050eb322014-05-09 15:10:23 -0700306 ex->mPsshBuf = new ABuffer(newsize);
307 ex->mPsshBuf->setRange(0, newsize);
308
309 // copy data
310 const uint8_t* src = buffer->data();
311 uint8_t* dst = ex->mPsshBuf->data();
Marco Nelissen58344bc2014-10-23 11:36:38 -0700312 uint8_t* dstdata = dst + sizeof(size_t) + numentries * sizeof(PsshEntry);
313 *((size_t*)dst) = numentries;
314 dst += sizeof(size_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700315 for (size_t i = 0; i < numentries; i++) {
316 // copy uuid
317 memcpy(dst, src, 16);
318 src += 16;
319 dst += 16;
320
321 // get/copy data length
322 uint32_t datalen = *((uint32_t*)src);
Marco Nelissen58344bc2014-10-23 11:36:38 -0700323 *((size_t*)dst) = datalen;
324 src += sizeof(uint32_t);
325 dst += sizeof(size_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700326
327 // the next entry in the destination is a pointer to the actual data, which we store
328 // after the array of PsshEntry
Marco Nelissen58344bc2014-10-23 11:36:38 -0700329 *((void**)dst) = dstdata;
330 dst += sizeof(void*);
Marco Nelissen050eb322014-05-09 15:10:23 -0700331
332 // copy the actual data
333 memcpy(dstdata, src, datalen);
334 dstdata += datalen;
335 src += datalen;
336 }
337
338 return (PsshInfo*) ex->mPsshBuf->data();
339}
340
Marco Nelissen3425fd52014-05-14 11:12:46 -0700341EXPORT
Marco Nelissen050eb322014-05-09 15:10:23 -0700342AMediaCodecCryptoInfo *AMediaExtractor_getSampleCryptoInfo(AMediaExtractor *ex) {
343 sp<MetaData> meta;
344 if(ex->mImpl->getSampleMeta(&meta) != 0) {
345 return NULL;
346 }
347
348 uint32_t type;
349 const void *crypteddata;
350 size_t cryptedsize;
351 if (!meta->findData(kKeyEncryptedSizes, &type, &crypteddata, &cryptedsize)) {
352 return NULL;
353 }
Robert Shih0b4530d2019-01-18 12:12:03 -0800354 size_t numSubSamples = cryptedsize / sizeof(uint32_t);
Marco Nelissen050eb322014-05-09 15:10:23 -0700355
356 const void *cleardata;
357 size_t clearsize;
358 if (meta->findData(kKeyPlainSizes, &type, &cleardata, &clearsize)) {
359 if (clearsize != cryptedsize) {
360 // The two must be of the same length.
361 return NULL;
362 }
363 }
364
365 const void *key;
366 size_t keysize;
Edwin Wongb2fb3c92016-08-29 14:57:47 -0700367 if (meta->findData(kKeyCryptoKey, &type, &key, &keysize)) {
Marco Nelissen050eb322014-05-09 15:10:23 -0700368 if (keysize != 16) {
Edwin Wongb2fb3c92016-08-29 14:57:47 -0700369 // Keys must be 16 bytes in length.
Marco Nelissen050eb322014-05-09 15:10:23 -0700370 return NULL;
371 }
372 }
373
374 const void *iv;
375 size_t ivsize;
376 if (meta->findData(kKeyCryptoIV, &type, &iv, &ivsize)) {
377 if (ivsize != 16) {
378 // IVs must be 16 bytes in length.
379 return NULL;
380 }
381 }
382
383 int32_t mode;
384 if (!meta->findInt32(kKeyCryptoMode, &mode)) {
385 mode = CryptoPlugin::kMode_AES_CTR;
386 }
387
Robert Shih0b4530d2019-01-18 12:12:03 -0800388 if (sizeof(uint32_t) != sizeof(size_t)) {
389 sp<ABuffer> clearbuf = U32ArrayToSizeBuf(numSubSamples, (uint32_t *)cleardata);
390 sp<ABuffer> cryptedbuf = U32ArrayToSizeBuf(numSubSamples, (uint32_t *)crypteddata);
391 cleardata = clearbuf == NULL ? NULL : clearbuf->data();
392 crypteddata = crypteddata == NULL ? NULL : cryptedbuf->data();
393 if(crypteddata == NULL || cleardata == NULL) {
394 return NULL;
395 }
396 }
397
Marco Nelissen050eb322014-05-09 15:10:23 -0700398 return AMediaCodecCryptoInfo_new(
399 numSubSamples,
400 (uint8_t*) key,
401 (uint8_t*) iv,
Marco Nelissen79e2b622014-05-16 08:07:28 -0700402 (cryptoinfo_mode_t) mode,
Marco Nelissen050eb322014-05-09 15:10:23 -0700403 (size_t*) cleardata,
404 (size_t*) crypteddata);
405}
406
Robert Shih30e3c7d2018-01-21 17:06:12 -0800407EXPORT
408int64_t AMediaExtractor_getCachedDuration(AMediaExtractor *ex) {
409 bool eos;
410 int64_t durationUs;
411 if (ex->mImpl->getCachedDuration(&durationUs, &eos)) {
412 return durationUs;
413 }
414 return -1;
415}
Marco Nelissen0c3be872014-05-01 10:14:44 -0700416
Robert Shihd83d4f42018-02-24 19:02:46 -0800417EXPORT
418media_status_t AMediaExtractor_getSampleFormat(AMediaExtractor *ex, AMediaFormat *fmt) {
419 if (fmt == NULL) {
420 return AMEDIA_ERROR_INVALID_PARAMETER;
421 }
422
423 sp<MetaData> sampleMeta;
424 status_t err = ex->mImpl->getSampleMeta(&sampleMeta);
425 if (err != OK) {
426 return translate_error(err);
427 }
428
429 sp<AMessage> meta;
430 AMediaFormat_getFormat(fmt, &meta);
431 meta->clear();
432
433 int32_t layerId;
434 if (sampleMeta->findInt32(kKeyTemporalLayerId, &layerId)) {
435 meta->setInt32(AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID, layerId);
436 }
437
438 size_t trackIndex;
439 err = ex->mImpl->getSampleTrackIndex(&trackIndex);
440 if (err == OK) {
441 meta->setInt32(AMEDIAFORMAT_KEY_TRACK_INDEX, trackIndex);
442 sp<AMessage> trackFormat;
443 AString mime;
444 err = ex->mImpl->getTrackFormat(trackIndex, &trackFormat);
445 if (err == OK
446 && trackFormat != NULL
447 && trackFormat->findString(AMEDIAFORMAT_KEY_MIME, &mime)) {
448 meta->setString(AMEDIAFORMAT_KEY_MIME, mime);
449 }
450 }
451
452 int64_t durationUs;
453 if (sampleMeta->findInt64(kKeyDuration, &durationUs)) {
454 meta->setInt64(AMEDIAFORMAT_KEY_DURATION, durationUs);
455 }
456
457 uint32_t dataType; // unused
458 const void *seiData;
459 size_t seiLength;
460 if (sampleMeta->findData(kKeySEI, &dataType, &seiData, &seiLength)) {
461 sp<ABuffer> sei = ABuffer::CreateAsCopy(seiData, seiLength);;
462 meta->setBuffer(AMEDIAFORMAT_KEY_SEI, sei);
463 }
464
465 const void *mpegUserDataPointer;
466 size_t mpegUserDataLength;
467 if (sampleMeta->findData(
468 kKeyMpegUserData, &dataType, &mpegUserDataPointer, &mpegUserDataLength)) {
469 sp<ABuffer> mpegUserData = ABuffer::CreateAsCopy(mpegUserDataPointer, mpegUserDataLength);
470 meta->setBuffer(AMEDIAFORMAT_KEY_MPEG_USER_DATA, mpegUserData);
471 }
472
Sampath Shettyc6148a62018-12-18 15:50:43 +1100473 const void *audioPresentationsPointer;
474 size_t audioPresentationsLength;
475 if (sampleMeta->findData(
476 kKeyAudioPresentationInfo, &dataType,
477 &audioPresentationsPointer, &audioPresentationsLength)) {
478 sp<ABuffer> audioPresentationsData = ABuffer::CreateAsCopy(
479 audioPresentationsPointer, audioPresentationsLength);
480 meta->setBuffer(AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO, audioPresentationsData);
481 }
482
Robert Shihd83d4f42018-02-24 19:02:46 -0800483 return AMEDIA_OK;
484}
485
Marco Nelissen0c3be872014-05-01 10:14:44 -0700486} // extern "C"
487