summaryrefslogtreecommitdiffstats
path: root/cmds/stagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-06-22 14:57:25 -0700
committerAndreas Huber <andih@google.com>2011-06-22 14:57:25 -0700
commit65f993e0d8ea366bc5178423675ef3299eae3102 (patch)
tree25ce9d37eecea10aef5054dd5a6c7954e834240d /cmds/stagefright
parent8969d9924c662ab4cdacc342bbdc33756db730be (diff)
downloadframeworks_base-65f993e0d8ea366bc5178423675ef3299eae3102.zip
frameworks_base-65f993e0d8ea366bc5178423675ef3299eae3102.tar.gz
frameworks_base-65f993e0d8ea366bc5178423675ef3299eae3102.tar.bz2
Reconstruct sync frame indication for content served by the MPEG2TSExtractor
Strip data up to the first IDR frame if necessary. Change-Id: I4a096785eb1a17b7484983788e223d188454771d
Diffstat (limited to 'cmds/stagefright')
-rw-r--r--cmds/stagefright/stagefright.cpp47
1 files changed, 38 insertions, 9 deletions
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index ca77185..d7b1e71 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -388,13 +388,15 @@ private:
sp<MediaSource> mSource;
StreamType mStreamType;
+ bool mSawFirstIDRFrame;
DISALLOW_EVIL_CONSTRUCTORS(DetectSyncSource);
};
DetectSyncSource::DetectSyncSource(const sp<MediaSource> &source)
: mSource(source),
- mStreamType(OTHER) {
+ mStreamType(OTHER),
+ mSawFirstIDRFrame(false) {
const char *mime;
CHECK(mSource->getFormat()->findCString(kKeyMIMEType, &mime));
@@ -410,6 +412,8 @@ DetectSyncSource::DetectSyncSource(const sp<MediaSource> &source)
}
status_t DetectSyncSource::start(MetaData *params) {
+ mSawFirstIDRFrame = false;
+
return mSource->start(params);
}
@@ -439,16 +443,30 @@ static bool isIDRFrame(MediaBuffer *buffer) {
status_t DetectSyncSource::read(
MediaBuffer **buffer, const ReadOptions *options) {
- status_t err = mSource->read(buffer, options);
+ for (;;) {
+ status_t err = mSource->read(buffer, options);
- if (err != OK) {
- return err;
- }
+ if (err != OK) {
+ return err;
+ }
- if (mStreamType == AVC && isIDRFrame(*buffer)) {
- (*buffer)->meta_data()->setInt32(kKeyIsSyncFrame, true);
- } else {
- (*buffer)->meta_data()->setInt32(kKeyIsSyncFrame, true);
+ if (mStreamType == AVC) {
+ bool isIDR = isIDRFrame(*buffer);
+ (*buffer)->meta_data()->setInt32(kKeyIsSyncFrame, isIDR);
+ if (isIDR) {
+ mSawFirstIDRFrame = true;
+ }
+ } else {
+ (*buffer)->meta_data()->setInt32(kKeyIsSyncFrame, true);
+ }
+
+ if (mStreamType != AVC || mSawFirstIDRFrame) {
+ break;
+ }
+
+ // Ignore everything up to the first IDR frame.
+ (*buffer)->release();
+ *buffer = NULL;
}
return OK;
@@ -945,6 +963,17 @@ int main(int argc, char **argv) {
fprintf(stderr, "could not create extractor.\n");
return -1;
}
+
+ sp<MetaData> meta = extractor->getMetaData();
+
+ if (meta != NULL) {
+ const char *mime;
+ CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+ if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {
+ syncInfoPresent = false;
+ }
+ }
}
size_t numTracks = extractor->countTracks();