summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/HTTPBase.cpp
diff options
context:
space:
mode:
authorLeena Winterrowd <lenhardw@codeaurora.org>2014-12-04 14:03:03 -0800
committerLajos Molnar <lajos@google.com>2015-01-28 21:52:09 -0800
commita93fd2be99d21629bed504b9b7df035fc2f54562 (patch)
treebacc1924137d3e0e749a1ba47756f3c80eaa1718 /media/libstagefright/HTTPBase.cpp
parent9aff25fb41f516ac26f9d1983a25402909f1e77a (diff)
downloadframeworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.zip
frameworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.tar.gz
frameworks_av-a93fd2be99d21629bed504b9b7df035fc2f54562.tar.bz2
stagefright: httplive: Decouple block size from bandwidth estimate
A very small block size in PlaylistFetcher can lead to framework overhead and difficulty streaming high bitrate content, but since HTTPBase keeps a constant history of the past 100 HTTP reads, the block size directly affects bandwidth estimation and in turn, switching latency. Add setBandwidthHistorySize() to HTTPBase to allow setting the history size for bandwidth estimation. Call this within LiveSession based on the current block size to ensure that the number of bytes used for estimating bandwidth does not change if the block size is changed in PlaylistFetcher. Since a single TCP/IP packet can contain up to 64k of data, increase the block size in PlaylistFetcher from 2k to lcm(188, 1024) or 47k to avoid inaccuracies in read timings due to up to a comparable 47 reads from the same locally-cached packet instead of from the network. Also make HTTPBase::addBandwidthMeasurement() virtual to allow bandwidth estimation extensions that do not rely on a history list. Bug: 18821145 Change-Id: I5f957be01f5346e74cfb7eeb150ca4b397ad5798
Diffstat (limited to 'media/libstagefright/HTTPBase.cpp')
-rw-r--r--media/libstagefright/HTTPBase.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp
index 32291c8..0c2ff15 100644
--- a/media/libstagefright/HTTPBase.cpp
+++ b/media/libstagefright/HTTPBase.cpp
@@ -36,7 +36,8 @@ HTTPBase::HTTPBase()
mTotalTransferBytes(0),
mPrevBandwidthMeasureTimeUs(0),
mPrevEstimatedBandWidthKbps(0),
- mBandWidthCollectFreqMs(5000) {
+ mBandWidthCollectFreqMs(5000),
+ mMaxBandwidthHistoryItems(100) {
}
void HTTPBase::addBandwidthMeasurement(
@@ -50,7 +51,7 @@ void HTTPBase::addBandwidthMeasurement(
mTotalTransferBytes += numBytes;
mBandwidthHistory.push_back(entry);
- if (++mNumBandwidthHistoryItems > 100) {
+ if (++mNumBandwidthHistoryItems > mMaxBandwidthHistoryItems) {
BandwidthEntry *entry = &*mBandwidthHistory.begin();
mTotalTransferTimeUs -= entry->mDelayUs;
mTotalTransferBytes -= entry->mNumBytes;
@@ -104,6 +105,10 @@ status_t HTTPBase::setBandwidthStatCollectFreq(int32_t freqMs) {
return OK;
}
+void HTTPBase::setBandwidthHistorySize(size_t numHistoryItems) {
+ mMaxBandwidthHistoryItems = numHistoryItems;
+}
+
// static
void HTTPBase::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
int res = qtaguid_tagSocket(sockfd, kTag, uid);