From 323e31754c3ba31e537e712e818f90381b8eb6d1 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 4 Aug 2011 12:02:47 -0700 Subject: Restart HLS streaming from the bottom of the playlist if we miss the boat on the next segment. This can happen if for whatever reason we playback video slower than it is served. Also removed some unnecessary verbosity from ChromiumHTTPDataSource. Change-Id: I6e870879310c9efe4d50d7dc0883c08405442d79 related-to-bug: 5120425 --- media/libstagefright/chromium_http/support.cpp | 10 ++++---- media/libstagefright/httplive/LiveSession.cpp | 35 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp index eb10ab76b582..26c3eda8b058 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -183,19 +183,19 @@ void SfDelegate::setOwner(ChromiumHTTPDataSource *owner) { void SfDelegate::OnReceivedRedirect( net::URLRequest *request, const GURL &new_url, bool *defer_redirect) { - MY_LOGI("OnReceivedRedirect"); + MY_LOGV("OnReceivedRedirect"); } void SfDelegate::OnAuthRequired( net::URLRequest *request, net::AuthChallengeInfo *auth_info) { - MY_LOGI("OnAuthRequired"); + MY_LOGV("OnAuthRequired"); inherited::OnAuthRequired(request, auth_info); } void SfDelegate::OnCertificateRequested( net::URLRequest *request, net::SSLCertRequestInfo *cert_request_info) { - MY_LOGI("OnCertificateRequested"); + MY_LOGV("OnCertificateRequested"); inherited::OnCertificateRequested(request, cert_request_info); } @@ -208,7 +208,7 @@ void SfDelegate::OnSSLCertificateError( } void SfDelegate::OnGetCookies(net::URLRequest *request, bool blocked_by_policy) { - MY_LOGI("OnGetCookies"); + MY_LOGV("OnGetCookies"); } void SfDelegate::OnSetCookie( @@ -216,7 +216,7 @@ void SfDelegate::OnSetCookie( const std::string &cookie_line, const net::CookieOptions &options, bool blocked_by_policy) { - MY_LOGI("OnSetCookie"); + MY_LOGV("OnSetCookie"); } void SfDelegate::OnResponseStarted(net::URLRequest *request) { diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 2578d2dbd2a5..f67cdace819c 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -617,23 +617,32 @@ rinse_repeat: goto rinse_repeat; } - if (!mPlaylist->isComplete() - && mSeqNumber > lastSeqNumberInPlaylist - && mNumRetries < kMaxNumRetries) { + if (!mPlaylist->isComplete() && mNumRetries < kMaxNumRetries) { ++mNumRetries; - mLastPlaylistFetchTimeUs = -1; - postMonitorQueue(3000000ll); - return; - } + if (mSeqNumber > lastSeqNumberInPlaylist) { + mLastPlaylistFetchTimeUs = -1; + postMonitorQueue(3000000ll); + return; + } - LOGE("Cannot find sequence number %d in playlist " - "(contains %d - %d)", - mSeqNumber, firstSeqNumberInPlaylist, - firstSeqNumberInPlaylist + mPlaylist->size() - 1); + // we've missed the boat, let's start from the lowest sequence + // number available and signal a discontinuity. - mDataSource->queueEOS(ERROR_END_OF_STREAM); - return; + LOGI("We've missed the boat, restarting playback."); + mSeqNumber = lastSeqNumberInPlaylist; + explicitDiscontinuity = true; + + // fall through + } else { + LOGE("Cannot find sequence number %d in playlist " + "(contains %d - %d)", + mSeqNumber, firstSeqNumberInPlaylist, + firstSeqNumberInPlaylist + mPlaylist->size() - 1); + + mDataSource->queueEOS(ERROR_END_OF_STREAM); + return; + } } mNumRetries = 0; -- cgit v1.2.3-59-g8ed1b