diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaFile.java | 1 | ||||
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 3 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSource.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/httplive/M3UParser.cpp | 22 | ||||
-rw-r--r-- | media/libstagefright/include/M3UParser.h | 2 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 12 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.cpp | 47 |
7 files changed, 81 insertions, 14 deletions
diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java index 0e689e4..beac04c 100644 --- a/media/java/android/media/MediaFile.java +++ b/media/java/android/media/MediaFile.java @@ -194,6 +194,7 @@ public class MediaFile { addFileType("WBMP", FILE_TYPE_WBMP, "image/vnd.wap.wbmp"); addFileType("M3U", FILE_TYPE_M3U, "audio/x-mpegurl", MtpConstants.FORMAT_M3U_PLAYLIST); + addFileType("M3U", FILE_TYPE_M3U, "application/x-mpegurl", MtpConstants.FORMAT_M3U_PLAYLIST); addFileType("PLS", FILE_TYPE_PLS, "audio/x-scpls", MtpConstants.FORMAT_PLS_PLAYLIST); addFileType("WPL", FILE_TYPE_WPL, "application/vnd.ms-wpl", MtpConstants.FORMAT_WPL_PLAYLIST); addFileType("M3U8", FILE_TYPE_HTTPLIVE, "application/vnd.apple.mpegurl"); diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index a804866..8ebbe6c 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -426,7 +426,8 @@ status_t AwesomePlayer::setDataSource_l( // Hack to support http live. size_t len = strlen(uri); - if (!strcasecmp(&uri[len - 5], ".m3u8")) { + if (!strcasecmp(&uri[len - 5], ".m3u8") + || strstr(&uri[7], "m3u8") != NULL) { mUri = "httplive://"; mUri.append(&uri[7]); } diff --git a/media/libstagefright/httplive/LiveSource.cpp b/media/libstagefright/httplive/LiveSource.cpp index 4b4c3d2..4451bd5 100644 --- a/media/libstagefright/httplive/LiveSource.cpp +++ b/media/libstagefright/httplive/LiveSource.cpp @@ -359,14 +359,6 @@ bool LiveSource::setupCipher() { return false; } - if (keyURI.size() >= 2 - && keyURI.c_str()[0] == '"' - && keyURI.c_str()[keyURI.size() - 1] == '"') { - // Remove surrounding quotes. - AString tmp(keyURI, 1, keyURI.size() - 2); - keyURI = tmp; - } - ssize_t index = mAESKeyForURI.indexOfKey(keyURI); sp<ABuffer> key; diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp index b166cc3..d4a29c0 100644 --- a/media/libstagefright/httplive/M3UParser.cpp +++ b/media/libstagefright/httplive/M3UParser.cpp @@ -162,7 +162,7 @@ status_t M3UParser::parse(const void *_data, size_t size) { if (mIsVariantPlaylist) { return ERROR_MALFORMED; } - err = parseCipherInfo(line, &itemMeta); + err = parseCipherInfo(line, &itemMeta, mBaseURI); } else if (line.startsWith("#EXT-X-ENDLIST")) { mIsComplete = true; } else if (line.startsWith("#EXTINF")) { @@ -298,7 +298,7 @@ status_t M3UParser::parseStreamInf( // static status_t M3UParser::parseCipherInfo( - const AString &line, sp<AMessage> *meta) { + const AString &line, sp<AMessage> *meta, const AString &baseURI) { ssize_t colonPos = line.find(":"); if (colonPos < 0) { @@ -338,6 +338,24 @@ status_t M3UParser::parseCipherInfo( *meta = new AMessage; } + if (key == "uri") { + if (val.size() >= 2 + && val.c_str()[0] == '"' + && val.c_str()[val.size() - 1] == '"') { + // Remove surrounding quotes. + AString tmp(val, 1, val.size() - 2); + val = tmp; + } + + AString absURI; + if (MakeURL(baseURI.c_str(), val.c_str(), &absURI)) { + val = absURI; + } else { + LOGE("failed to make absolute url for '%s'.", + val.c_str()); + } + } + key.insert(AString("cipher-"), 0); (*meta)->setString(key.c_str(), val.c_str(), val.size()); diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h index 531d184..63895b4 100644 --- a/media/libstagefright/include/M3UParser.h +++ b/media/libstagefright/include/M3UParser.h @@ -67,7 +67,7 @@ private: const AString &line, sp<AMessage> *meta); static status_t parseCipherInfo( - const AString &line, sp<AMessage> *meta); + const AString &line, sp<AMessage> *meta, const AString &baseURI); static status_t ParseInt32(const char *s, int32_t *x); 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; } |