diff options
author | Robert Shih <robertshih@google.com> | 2014-10-30 17:22:11 -0700 |
---|---|---|
committer | Robert Shih <robertshih@google.com> | 2014-11-12 18:42:10 -0800 |
commit | bf20727f0aaf609bc3b495b07b45822b137d21ba (patch) | |
tree | 54dcd911084ba618a70907efc04da2970240a8da /media | |
parent | 701b96474dc8afd16046e440975e00be57cc4874 (diff) | |
download | frameworks_av-bf20727f0aaf609bc3b495b07b45822b137d21ba.zip frameworks_av-bf20727f0aaf609bc3b495b07b45822b137d21ba.tar.gz frameworks_av-bf20727f0aaf609bc3b495b07b45822b137d21ba.tar.bz2 |
PlaylistFetcher: check ts program streams before disabling a/v
Bug: 14648838
Change-Id: Ibf2b2cbb235f3d80bc33013e2afc053f13b9035f
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 6 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 31 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.h | 1 |
3 files changed, 32 insertions, 6 deletions
diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index 30fa868..0d9ed96 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -963,8 +963,8 @@ void PlaylistFetcher::onDownloadNext() { } while (bytesRead != 0); if (bufferStartsWithTsSyncByte(buffer)) { - // If we still don't see a stream after fetching a full ts segment mark it as - // nonexistent. + // If we don't see a stream in the program table after fetching a full ts segment + // mark it as nonexistent. const size_t kNumTypes = ATSParser::NUM_SOURCE_TYPES; ATSParser::SourceType srcTypes[kNumTypes] = { ATSParser::VIDEO, ATSParser::AUDIO }; @@ -979,7 +979,7 @@ void PlaylistFetcher::onDownloadNext() { static_cast<AnotherPacketSource *>( mTSParser->getSource(srcType).get()); - if (source == NULL) { + if (!mTSParser->hasSource(srcType)) { ALOGW("MPEG2 Transport stream does not contain %s data.", srcType == ATSParser::VIDEO ? "video" : "audio"); diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index eab7616..c1dc0f9 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -63,6 +63,7 @@ struct ATSParser::Program : public RefBase { void signalEOS(status_t finalResult); sp<MediaSource> getSource(SourceType type); + bool hasSource(SourceType type) const; int64_t convertPTSToTimestamp(uint64_t PTS); @@ -119,6 +120,9 @@ struct ATSParser::Stream : public RefBase { sp<MediaSource> getSource(SourceType type); + bool isAudio() const; + bool isVideo() const; + protected: virtual ~Stream(); @@ -146,9 +150,6 @@ private: void extractAACFrames(const sp<ABuffer> &buffer); - bool isAudio() const; - bool isVideo() const; - DISALLOW_EVIL_CONSTRUCTORS(Stream); }; @@ -440,6 +441,19 @@ sp<MediaSource> ATSParser::Program::getSource(SourceType type) { return NULL; } +bool ATSParser::Program::hasSource(SourceType type) const { + for (size_t i = 0; i < mStreams.size(); ++i) { + const sp<Stream> &stream = mStreams.valueAt(i); + if (type == AUDIO && stream->isAudio()) { + return true; + } else if (type == VIDEO && stream->isVideo()) { + return true; + } + } + + return false; +} + int64_t ATSParser::Program::convertPTSToTimestamp(uint64_t PTS) { if (!(mParser->mFlags & TS_TIMESTAMPS_ARE_ABSOLUTE)) { if (!mFirstPTSValid) { @@ -1278,6 +1292,17 @@ sp<MediaSource> ATSParser::getSource(SourceType type) { return NULL; } +bool ATSParser::hasSource(SourceType type) const { + for (size_t i = 0; i < mPrograms.size(); ++i) { + const sp<Program> &program = mPrograms.itemAt(i); + if (program->hasSource(type)) { + return true; + } + } + + return false; +} + bool ATSParser::PTSTimeDeltaEstablished() { if (mPrograms.isEmpty()) { return false; diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index 8986a22..438bf45 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -76,6 +76,7 @@ struct ATSParser : public RefBase { NUM_SOURCE_TYPES = 2 }; sp<MediaSource> getSource(SourceType type); + bool hasSource(SourceType type) const; bool PTSTimeDeltaEstablished(); |