diff options
author | Andreas Huber <andih@google.com> | 2010-12-02 13:27:47 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-12-02 13:27:47 -0800 |
commit | b5c6afc208bd70eba386dbb2c0fb29b34e44e4d4 (patch) | |
tree | 3e39cb8af266852629ac56da930324e1fa05a4ce /media/libstagefright/mpeg2ts | |
parent | 97c40a9deeb18393792fe5096143d6760422dbe6 (diff) | |
download | frameworks_base-b5c6afc208bd70eba386dbb2c0fb29b34e44e4d4.zip frameworks_base-b5c6afc208bd70eba386dbb2c0fb29b34e44e4d4.tar.gz frameworks_base-b5c6afc208bd70eba386dbb2c0fb29b34e44e4d4.tar.bz2 |
Squashed commit of the following:
commit de99ae4a523ff5ec40b47071f22fdde1a4b2a0bf
Author: Andreas Huber <andih@google.com>
Date: Thu Dec 2 13:18:40 2010 -0800
Scan for sync words to find H.264 frame/AAC frame boundaries if PES packets do not start with them.
Change-Id: If2861982ecb3006fac806105dbfcd1d43c2a4205
commit be23791ff0d037aa7073589cdc8bfc362e1c281d
Author: Andreas Huber <andih@google.com>
Date: Thu Dec 2 13:12:39 2010 -0800
Properly expand relative key URLs and strip surrounding quotes in the M3UParser.
Change-Id: I013a6d83a64f095d090e5c7730298bdac7d03ab4
commit 0f1d8f65effe0cc42a265dd91d8b91dce6534325
Author: Andreas Huber <andih@google.com>
Date: Thu Dec 2 13:11:27 2010 -0800
Ugly hack that assumes that any http url containing "m3u8" refers to an httplive stream.
Change-Id: I05d7bbc5dab0f9822558122b5b9dc2a109ed8518
commit 255f0d5cdb1072ecd66b47ee614bf574f1388e5a
Author: Andreas Huber <andih@google.com>
Date: Thu Dec 2 13:10:56 2010 -0800
Add one more mimetype "application/x-mpegurl" to identify httplive playlists.
Change-Id: I63fd3b8c2539c9ee23c077df533157af78b10863
Change-Id: I135687383009dbe32d690c9ba8dea60159adc616
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 12 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.cpp | 47 |
2 files changed, 57 insertions, 2 deletions
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index f06a1bb..a559b21 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -238,10 +238,15 @@ void ATSParser::Program::parseProgramMap(ABitReader *br) { } sp<MediaSource> ATSParser::Program::getSource(SourceType type) { + size_t index = (type == MPEG2ADTS_AUDIO) ? 0 : 0; + for (size_t i = 0; i < mStreams.size(); ++i) { sp<MediaSource> source = mStreams.editValueAt(i)->getSource(type); if (source != NULL) { - return source; + if (index == 0) { + return source; + } + --index; } } @@ -508,7 +513,10 @@ void ATSParser::Stream::onPayloadData( int64_t timeUs = mProgram->convertPTSToTimestamp(PTS); status_t err = mQueue.appendData(data, size, timeUs); - CHECK_EQ(err, (status_t)OK); + + if (err != OK) { + return; + } sp<ABuffer> accessUnit; while ((accessUnit = mQueue.dequeueAccessUnit()) != NULL) { diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index f11b3c3..37bcb23 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -55,9 +55,34 @@ status_t ElementaryStreamQueue::appendData( switch (mMode) { case H264: { +#if 0 if (size < 4 || memcmp("\x00\x00\x00\x01", data, 4)) { return ERROR_MALFORMED; } +#else + uint8_t *ptr = (uint8_t *)data; + + ssize_t startOffset = -1; + for (size_t i = 0; i + 3 < size; ++i) { + if (!memcmp("\x00\x00\x00\x01", &ptr[i], 4)) { + startOffset = i; + break; + } + } + + if (startOffset < 0) { + return ERROR_MALFORMED; + } + + if (startOffset > 0) { + LOGI("found something resembling an H.264 syncword at " + "offset %ld", + startOffset); + } + + data = &ptr[startOffset]; + size -= startOffset; +#endif break; } @@ -65,9 +90,31 @@ status_t ElementaryStreamQueue::appendData( { uint8_t *ptr = (uint8_t *)data; +#if 0 if (size < 2 || ptr[0] != 0xff || (ptr[1] >> 4) != 0x0f) { return ERROR_MALFORMED; } +#else + ssize_t startOffset = -1; + for (size_t i = 0; i + 1 < size; ++i) { + if (ptr[i] == 0xff && (ptr[i + 1] >> 4) == 0x0f) { + startOffset = i; + break; + } + } + + if (startOffset < 0) { + return ERROR_MALFORMED; + } + + if (startOffset > 0) { + LOGI("found something resembling an AAC syncword at offset %ld", + startOffset); + } + + data = &ptr[startOffset]; + size -= startOffset; +#endif break; } |