From 847551cff3fc824e898a2652e4c6a8dd1b049cb5 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 5 Jan 2011 16:24:27 -0800 Subject: Some more fixes regarding HTTP live in NuPlayer. Change-Id: I9e29615fa8ee6c7bd4189373a75c20caef3fd2b1 --- .../nuplayer/HTTPLiveSource.cpp | 2 +- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 14 ++++---------- media/libstagefright/httplive/LiveSession.cpp | 20 +++++++++++++++++--- media/libstagefright/mpeg2ts/ATSParser.cpp | 1 - media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 19 +++++++++++++------ media/libstagefright/mpeg2ts/AnotherPacketSource.h | 2 -- 6 files changed, 35 insertions(+), 23 deletions(-) (limited to 'media') diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp index b81e0e9..6bf6dd3 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp @@ -79,7 +79,7 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() { sp source = static_cast(mLiveSession->getDataSource().get()); - for (int32_t i = 0; i < 10; ++i) { + for (int32_t i = 0; i < 50; ++i) { char buffer[188]; ssize_t n = source->readAtNonBlocking(mOffset, buffer, sizeof(buffer)); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index a607b31..e1b371e 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -394,7 +394,7 @@ void NuPlayer::onMessageReceived(const sp &msg) { int64_t seekTimeUs; CHECK(msg->findInt64("seekTimeUs", &seekTimeUs)); - LOGI("kWhatSeek seekTimeUs=%lld us (%.2f secs)", + LOGV("kWhatSeek seekTimeUs=%lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6); mSource->seekTo(seekTimeUs); @@ -428,17 +428,11 @@ void NuPlayer::finishFlushIfPossible() { mRenderer->signalTimeDiscontinuity(); - bool scanSourcesAgain = false; - - if (mFlushingAudio == SHUT_DOWN) { - scanSourcesAgain = true; - } else if (mAudioDecoder != NULL) { + if (mAudioDecoder != NULL) { mAudioDecoder->signalResume(); } - if (mFlushingVideo == SHUT_DOWN) { - scanSourcesAgain = true; - } else if (mVideoDecoder != NULL) { + if (mVideoDecoder != NULL) { mVideoDecoder->signalResume(); } @@ -453,7 +447,7 @@ void NuPlayer::finishFlushIfPossible() { } else if (mResetPostponed) { (new AMessage(kWhatReset, id()))->post(); mResetPostponed = false; - } else if (scanSourcesAgain) { + } else if (mAudioDecoder == NULL || mVideoDecoder == NULL) { postScanSources(); } } diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 51ab7a1..6fd0171 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -385,6 +385,7 @@ void LiveSession::onDownloadNext() { } bool explicitDiscontinuity = false; + bool bandwidthChanged = false; if (mSeekTimeUs >= 0) { int32_t targetDuration; @@ -404,7 +405,14 @@ void LiveSession::onDownloadNext() { mDataSource->reset(); + // reseting the data source will have had the + // side effect of discarding any previously queued + // bandwidth change discontinuity. + // Therefore we'll need to treat these explicit + // discontinuities as involving a bandwidth change + // even if they aren't directly. explicitDiscontinuity = true; + bandwidthChanged = true; } } } @@ -484,9 +492,15 @@ void LiveSession::onDownloadNext() { return; } - bool bandwidthChanged = - mPrevBandwidthIndex >= 0 - && (size_t)mPrevBandwidthIndex != bandwidthIndex; + if ((size_t)mPrevBandwidthIndex != bandwidthIndex) { + bandwidthChanged = true; + } + + if (mPrevBandwidthIndex < 0) { + // Don't signal a bandwidth change at the very beginning of + // playback. + bandwidthChanged = false; + } if (explicitDiscontinuity || bandwidthChanged) { // Signal discontinuity. diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index 84a3860..d8ab080 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -351,7 +351,6 @@ void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { mQueue.clear(!isASeek); if (mSource != NULL) { - mSource->clear(); mSource->queueDiscontinuity(type); } break; diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index c6edf0a..0ad883b 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -142,16 +142,23 @@ void AnotherPacketSource::queueDiscontinuity( Mutex::Autolock autoLock(mLock); +#if 0 + if (type == ATSParser::DISCONTINUITY_SEEK + || type == ATSParser::DISCONTINUITY_FORMATCHANGE) { + // XXX Fix this: This will also clear any pending discontinuities, + // If there's a pending DISCONTINUITY_FORMATCHANGE and the new + // discontinuity is "just" a DISCONTINUITY_SEEK, this will effectively + // downgrade the type of discontinuity received by the client. + + mBuffers.clear(); + mEOSResult = OK; + } +#endif + mBuffers.push_back(buffer); mCondition.signal(); } -void AnotherPacketSource::clear() { - Mutex::Autolock autoLock(mLock); - mBuffers.clear(); - mEOSResult = OK; -} - void AnotherPacketSource::signalEOS(status_t result) { CHECK(result != OK); diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index c20fca3..6fe93f8 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -49,8 +49,6 @@ struct AnotherPacketSource : public MediaSource { void queueDiscontinuity(ATSParser::DiscontinuityType type); void signalEOS(status_t result); - void clear(); - status_t dequeueAccessUnit(sp *buffer); protected: -- cgit v1.1