diff options
author | Robert Shih <robertshih@google.com> | 2014-11-15 02:46:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2014-11-15 02:46:36 +0000 |
commit | be14b79f14cf70e7aaee5383e6a88e9984ffacdc (patch) | |
tree | c4897a079ee9a7d6ac1b6686172809ec2f93c8b3 | |
parent | 7aa310d90179d3811f7581c914e970c2461db7cf (diff) | |
parent | 3db2e5a6bd218ba185a1387d91a974d561d304d5 (diff) | |
download | frameworks_av-be14b79f14cf70e7aaee5383e6a88e9984ffacdc.zip frameworks_av-be14b79f14cf70e7aaee5383e6a88e9984ffacdc.tar.gz frameworks_av-be14b79f14cf70e7aaee5383e6a88e9984ffacdc.tar.bz2 |
am f97dfbc9: Merge "PlaylistFetcher: handle sporadic fetch erros" into lmp-mr1-dev
automerge: 3db2e5a
* commit '3db2e5a6bd218ba185a1387d91a974d561d304d5':
PlaylistFetcher: handle sporadic fetch erros
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index e4ea034..e247550 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -700,8 +700,7 @@ status_t PlaylistFetcher::refreshPlaylist() { mRefreshState = (RefreshState)(mRefreshState + 1); } } else { - ALOGE("failed to load playlist at url '%s'", mURI.c_str()); - notifyError(ERROR_IO); + ALOGE("failed to load playlist at url '%s'", uriDebugString(mURI).c_str()); return ERROR_IO; } } else { @@ -724,26 +723,25 @@ bool PlaylistFetcher::bufferStartsWithTsSyncByte(const sp<ABuffer>& buffer) { } void PlaylistFetcher::onDownloadNext() { - if (refreshPlaylist() != OK) { - return; - } - - int32_t firstSeqNumberInPlaylist; - if (mPlaylist->meta() == NULL || !mPlaylist->meta()->findInt32( - "media-sequence", &firstSeqNumberInPlaylist)) { - firstSeqNumberInPlaylist = 0; - } - + status_t err = refreshPlaylist(); + int32_t firstSeqNumberInPlaylist = 0; + int32_t lastSeqNumberInPlaylist = 0; bool discontinuity = false; - const int32_t lastSeqNumberInPlaylist = - firstSeqNumberInPlaylist + (int32_t)mPlaylist->size() - 1; + if (mPlaylist != NULL) { + if (mPlaylist->meta() != NULL) { + mPlaylist->meta()->findInt32("media-sequence", &firstSeqNumberInPlaylist); + } + + lastSeqNumberInPlaylist = + firstSeqNumberInPlaylist + (int32_t)mPlaylist->size() - 1; - if (mDiscontinuitySeq < 0) { - mDiscontinuitySeq = mPlaylist->getDiscontinuitySeq(); + if (mDiscontinuitySeq < 0) { + mDiscontinuitySeq = mPlaylist->getDiscontinuitySeq(); + } } - if (mSeqNumber < 0) { + if (mPlaylist != NULL && mSeqNumber < 0) { CHECK_GE(mStartTimeUs, 0ll); if (mSegmentStartTimeUs < 0) { @@ -785,19 +783,26 @@ void PlaylistFetcher::onDownloadNext() { } } + // if mPlaylist is NULL then err must be non-OK; but the other way around might not be true if (mSeqNumber < firstSeqNumberInPlaylist - || mSeqNumber > lastSeqNumberInPlaylist) { - if (!mPlaylist->isComplete() && mNumRetries < kMaxNumRetries) { + || mSeqNumber > lastSeqNumberInPlaylist + || err != OK) { + if ((err != OK || !mPlaylist->isComplete()) && mNumRetries < kMaxNumRetries) { ++mNumRetries; - if (mSeqNumber > lastSeqNumberInPlaylist) { + if (mSeqNumber > lastSeqNumberInPlaylist || err != OK) { + // make sure we reach this retry logic on refresh failures + // by adding an err != OK clause to all enclosing if's. + // refresh in increasing fraction (1/2, 1/3, ...) of the // playlist's target duration or 3 seconds, whichever is less - int32_t targetDurationSecs; - CHECK(mPlaylist->meta()->findInt32( - "target-duration", &targetDurationSecs)); - int64_t delayUs = mPlaylist->size() * targetDurationSecs * - 1000000ll / (1 + mNumRetries); + int64_t delayUs = kMaxMonitorDelayUs; + if (mPlaylist != NULL && mPlaylist->meta() != NULL) { + int32_t targetDurationSecs; + CHECK(mPlaylist->meta()->findInt32("target-duration", &targetDurationSecs)); + delayUs = mPlaylist->size() * targetDurationSecs * + 1000000ll / (1 + mNumRetries); + } if (delayUs > kMaxMonitorDelayUs) { delayUs = kMaxMonitorDelayUs; } @@ -809,7 +814,12 @@ void PlaylistFetcher::onDownloadNext() { return; } - // we've missed the boat, let's start from the lowest sequence + if (err != OK) { + notifyError(err); + return; + } + + // we've missed the boat, let's start 3 segments prior to the latest sequence // number available and signal a discontinuity. ALOGI("We've missed the boat, restarting playback." @@ -996,7 +1006,7 @@ void PlaylistFetcher::onDownloadNext() { return; } - status_t err = OK; + err = OK; if (tsBuffer != NULL) { AString method; CHECK(buffer->meta()->findString("cipher-method", &method)); |