AppendData:MPEG4Writer&Extractor,MediaAppender
Bug: 154734325
Append media data to an MPEG4File. Changes were made in
MPEG4Extractor to pass sample offsets of existing data in file to
the writer. MediaAppender class takes cares of parsing and preparing
exisiting MPEG4 file to be added with new data. Data that is present
in the file is not copied again, hence that pass happens fast.
New data is appended at the end of the file.
Test: atest android.mediav2.cts.MuxerTest
Test: atest android.media.cts.MediaMuxerTest
Test: atest android.media.cts.MediaRecorderTest
Test: atest android.media.cts.MediaExtractorTest
Merged-In: I3f2bfa6b92d85c3a87ac740b2d401dcb10d7976e
Change-Id: I55c90b3e71f2d94a497b2196a02e17e61c34ce3a
diff --git a/media/ndk/NdkMediaExtractor.cpp b/media/ndk/NdkMediaExtractor.cpp
index 0c65e9e..07fc5de 100644
--- a/media/ndk/NdkMediaExtractor.cpp
+++ b/media/ndk/NdkMediaExtractor.cpp
@@ -419,6 +419,7 @@
EXPORT
media_status_t AMediaExtractor_getSampleFormat(AMediaExtractor *ex, AMediaFormat *fmt) {
+ ALOGV("AMediaExtractor_getSampleFormat");
if (fmt == NULL) {
return AMEDIA_ERROR_INVALID_PARAMETER;
}
@@ -428,6 +429,9 @@
if (err != OK) {
return translate_error(err);
}
+#ifdef LOG_NDEBUG
+ sampleMeta->dumpToLog();
+#endif
sp<AMessage> meta;
AMediaFormat_getFormat(fmt, &meta);
@@ -483,6 +487,19 @@
meta->setBuffer(AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO, audioPresentationsData);
}
+ int64_t val64;
+ if (sampleMeta->findInt64(kKeySampleFileOffset, &val64)) {
+ meta->setInt64("sample-file-offset", val64);
+ ALOGV("SampleFileOffset Found");
+ }
+ if (sampleMeta->findInt64(kKeyLastSampleIndexInChunk, &val64)) {
+ meta->setInt64("last-sample-index-in-chunk" /*AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK*/,
+ val64);
+ ALOGV("kKeyLastSampleIndexInChunk Found");
+ }
+
+ ALOGV("AMediaFormat_toString:%s", AMediaFormat_toString(fmt));
+
return AMEDIA_OK;
}