summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-07-01 08:19:52 -0700
committerAndreas Huber <andih@google.com>2010-07-01 09:08:38 -0700
commit19c9a1e2bb6ead5e1e895aea8be573fe0f8cc7bb (patch)
treeae116a41e703a6e2536ecedfdd2f74196e597cf5 /media
parent3eaa4e92dbebb5b27cb89f329f31fac6fb6fe1f0 (diff)
downloadframeworks_av-19c9a1e2bb6ead5e1e895aea8be573fe0f8cc7bb.zip
frameworks_av-19c9a1e2bb6ead5e1e895aea8be573fe0f8cc7bb.tar.gz
frameworks_av-19c9a1e2bb6ead5e1e895aea8be573fe0f8cc7bb.tar.bz2
Support for writing the extracted data to an .mp4 file in the stagefright commandline tool.
Change-Id: I972324a8fc9757e6e8116b0270ec0882106f8733
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/MPEG4Writer.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index a52c888..6a4a131 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -34,6 +34,8 @@
#include <media/mediarecorder.h>
#include <cutils/properties.h>
+#include "include/ESDS.h"
+
namespace android {
class MPEG4Writer::Track {
@@ -126,6 +128,8 @@ private:
int32_t *min, int32_t *avg, int32_t *max);
void findMinMaxChunkDurations(int64_t *min, int64_t *max);
+ void getCodecSpecificDataFromInputFormatIfPossible();
+
Track(const Track &);
Track &operator=(const Track &);
};
@@ -678,6 +682,38 @@ MPEG4Writer::Track::Track(
mCodecSpecificDataSize(0),
mGotAllCodecSpecificData(false),
mReachedEOS(false) {
+ getCodecSpecificDataFromInputFormatIfPossible();
+}
+
+void MPEG4Writer::Track::getCodecSpecificDataFromInputFormatIfPossible() {
+ const char *mime;
+ CHECK(mMeta->findCString(kKeyMIMEType, &mime));
+
+ if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) {
+ uint32_t type;
+ const void *data;
+ size_t size;
+ if (mMeta->findData(kKeyAVCC, &type, &data, &size)) {
+ mCodecSpecificData = malloc(size);
+ mCodecSpecificDataSize = size;
+ memcpy(mCodecSpecificData, data, size);
+ mGotAllCodecSpecificData = true;
+ }
+ } else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_MPEG4)
+ || !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
+ uint32_t type;
+ const void *data;
+ size_t size;
+ if (mMeta->findData(kKeyESDS, &type, &data, &size)) {
+ ESDS esds(data, size);
+ if (esds.getCodecSpecificInfo(&data, &size) == OK) {
+ mCodecSpecificData = malloc(size);
+ mCodecSpecificDataSize = size;
+ memcpy(mCodecSpecificData, data, size);
+ mGotAllCodecSpecificData = true;
+ }
+ }
+ }
}
MPEG4Writer::Track::~Track() {
@@ -721,7 +757,10 @@ status_t MPEG4Writer::Track::start(MetaData *params) {
}
int64_t startTimeUs;
- CHECK(params && params->findInt64(kKeyTime, &startTimeUs));
+ if (params == NULL || !params->findInt64(kKeyTime, &startTimeUs)) {
+ startTimeUs = 0;
+ }
+
initTrackingProgressStatus(params);
sp<MetaData> meta = new MetaData;