summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive/LiveSession.cpp
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-12-29 17:01:55 +0000
committerNarayan Kamath <narayan@google.com>2014-12-29 17:01:55 +0000
commit8564e13b37d372da78bce08f34a3610795ae173c (patch)
treead7f94b921e4ef14964c7f153b050302c8f030bc /media/libstagefright/httplive/LiveSession.cpp
parentb915a420a6a205d30c0181d3fc13078fc6d37a3c (diff)
parent2efb95665d00d422b2a84f575e8acddd598311ad (diff)
downloadframeworks_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.cpp32
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> &notify, 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);