diff options
author | Narayan Kamath <narayan@google.com> | 2014-12-29 17:01:55 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-12-29 17:01:55 +0000 |
commit | 8564e13b37d372da78bce08f34a3610795ae173c (patch) | |
tree | ad7f94b921e4ef14964c7f153b050302c8f030bc /media/libstagefright/httplive | |
parent | b915a420a6a205d30c0181d3fc13078fc6d37a3c (diff) | |
parent | 2efb95665d00d422b2a84f575e8acddd598311ad (diff) | |
download | frameworks_av-8564e13b37d372da78bce08f34a3610795ae173c.zip frameworks_av-8564e13b37d372da78bce08f34a3610795ae173c.tar.gz frameworks_av-8564e13b37d372da78bce08f34a3610795ae173c.tar.bz2 |
resolved conflicts for merge of 2efb9566 to lmp-mr1-dev-plus-aosp
Change-Id: I4313941f3561176ce9f6ab055678fb626e570107
Diffstat (limited to 'media/libstagefright/httplive')
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 32 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.h | 2 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 21 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.h | 5 |
4 files changed, 51 insertions, 9 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 04005bd..190188a 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -49,6 +49,9 @@ namespace android { +// Number of recently-read bytes to use for bandwidth estimation +const size_t LiveSession::kBandwidthHistoryBytes = 200 * 1024; + LiveSession::LiveSession( const sp<AMessage> ¬ify, uint32_t flags, const sp<IMediaHTTPService> &httpService) @@ -84,6 +87,13 @@ LiveSession::LiveSession( mPacketSources2.add(indexToType(i), new AnotherPacketSource(NULL /* meta */)); mBuffering[i] = false; } + + size_t numHistoryItems = kBandwidthHistoryBytes / + PlaylistFetcher::kDownloadBlockSize + 1; + if (numHistoryItems < 5) { + numHistoryItems = 5; + } + mHTTPDataSource->setBandwidthHistorySize(numHistoryItems); } LiveSession::~LiveSession() { @@ -145,10 +155,24 @@ status_t LiveSession::dequeueAccessUnit( } } + int32_t targetDuration = 0; + sp<AMessage> meta = packetSource->getLatestEnqueuedMeta(); + if (meta != NULL) { + meta->findInt32("targetDuration", &targetDuration); + } + + int64_t targetDurationUs = targetDuration * 1000000ll; + if (targetDurationUs == 0 || + targetDurationUs > PlaylistFetcher::kMinBufferedDurationUs) { + // Fetchers limit buffering to + // min(3 * targetDuration, kMinBufferedDurationUs) + targetDurationUs = PlaylistFetcher::kMinBufferedDurationUs; + } + if (mBuffering[idx]) { if (mSwitchInProgress || packetSource->isFinished(0) - || packetSource->getEstimatedDurationUs() > 10000000ll) { + || packetSource->getEstimatedDurationUs() > targetDurationUs) { mBuffering[idx] = false; } } @@ -858,7 +882,11 @@ ssize_t LiveSession::fetchFile( // Only resize when we don't know the size. size_t bufferRemaining = buffer->capacity() - buffer->size(); if (bufferRemaining == 0 && getSizeErr != OK) { - bufferRemaining = 32768; + size_t bufferIncrement = buffer->size() / 2; + if (bufferIncrement < 32768) { + bufferIncrement = 32768; + } + bufferRemaining = bufferIncrement; ALOGV("increasing download buffer to %zu bytes", buffer->size() + bufferRemaining); diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h index 896a8fc..dfb5e59 100644 --- a/media/libstagefright/httplive/LiveSession.h +++ b/media/libstagefright/httplive/LiveSession.h @@ -114,6 +114,8 @@ private: kWhatSwitchDown = 'sDwn', }; + static const size_t kBandwidthHistoryBytes; + struct BandwidthItem { size_t mPlaylistIndex; unsigned long mBandwidth; diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index c0c7ed9..1526af1 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -49,8 +49,9 @@ namespace android { // static const int64_t PlaylistFetcher::kMinBufferedDurationUs = 10000000ll; const int64_t PlaylistFetcher::kMaxMonitorDelayUs = 3000000ll; -const int32_t PlaylistFetcher::kDownloadBlockSize = 2048; -const int32_t PlaylistFetcher::kNumSkipFrames = 10; +// LCM of 188 (size of a TS packet) & 1k works well +const int32_t PlaylistFetcher::kDownloadBlockSize = 47 * 1024; +const int32_t PlaylistFetcher::kNumSkipFrames = 5; PlaylistFetcher::PlaylistFetcher( const sp<AMessage> ¬ify, @@ -560,7 +561,7 @@ status_t PlaylistFetcher::onResumeUntil(const sp<AMessage> &msg) { // Don't resume if we would stop within a resume threshold. int32_t discontinuitySeq; int64_t latestTimeUs = 0, stopTimeUs = 0; - sp<AMessage> latestMeta = packetSource->getLatestDequeuedMeta(); + sp<AMessage> latestMeta = packetSource->getLatestEnqueuedMeta(); if (latestMeta != NULL && latestMeta->findInt32("discontinuitySeq", &discontinuitySeq) && discontinuitySeq == mDiscontinuitySeq @@ -609,7 +610,12 @@ void PlaylistFetcher::onMonitorQueue() { int32_t targetDurationSecs; int64_t targetDurationUs = kMinBufferedDurationUs; if (mPlaylist != NULL) { - CHECK(mPlaylist->meta()->findInt32("target-duration", &targetDurationSecs)); + if (mPlaylist->meta() == NULL || !mPlaylist->meta()->findInt32( + "target-duration", &targetDurationSecs)) { + ALOGE("Playlist is missing required EXT-X-TARGETDURATION tag"); + notifyError(ERROR_MALFORMED); + return; + } targetDurationUs = targetDurationSecs * 1000000ll; } @@ -1158,6 +1164,11 @@ const sp<ABuffer> &PlaylistFetcher::setAccessUnitProperties( accessUnit->meta()->setInt32("discard", discard); } + int32_t targetDurationSecs; + if (mPlaylist->meta()->findInt32("target-duration", &targetDurationSecs)) { + accessUnit->meta()->setInt32("targetDuration", targetDurationSecs); + } + accessUnit->meta()->setInt32("discontinuitySeq", mDiscontinuitySeq); accessUnit->meta()->setInt64("segmentStartTimeUs", getSegmentStartTimeUs(mSeqNumber)); return accessUnit; @@ -1667,7 +1678,7 @@ void PlaylistFetcher::updateDuration() { int64_t PlaylistFetcher::resumeThreshold(const sp<AMessage> &msg) { int64_t durationUs; - if (msg->findInt64("durationUs", &durationUs)) { + if (msg->findInt64("durationUs", &durationUs) && durationUs > 0) { return kNumSkipFrames * durationUs; } diff --git a/media/libstagefright/httplive/PlaylistFetcher.h b/media/libstagefright/httplive/PlaylistFetcher.h index 76cc852..4e15f85 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.h +++ b/media/libstagefright/httplive/PlaylistFetcher.h @@ -34,6 +34,9 @@ struct M3UParser; class String8; struct PlaylistFetcher : public AHandler { + static const int64_t kMinBufferedDurationUs; + static const int32_t kDownloadBlockSize; + enum { kWhatStarted, kWhatPaused, @@ -92,9 +95,7 @@ private: kWhatDownloadNext = 'dlnx', }; - static const int64_t kMinBufferedDurationUs; static const int64_t kMaxMonitorDelayUs; - static const int32_t kDownloadBlockSize; static const int32_t kNumSkipFrames; static bool bufferStartsWithTsSyncByte(const sp<ABuffer>& buffer); |