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/LiveSession.cpp | |
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/LiveSession.cpp')
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 32 |
1 files changed, 30 insertions, 2 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); |