From a93fd2be99d21629bed504b9b7df035fc2f54562 Mon Sep 17 00:00:00 2001 From: Leena Winterrowd Date: Thu, 4 Dec 2014 14:03:03 -0800 Subject: 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 --- media/libstagefright/include/HTTPBase.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/include') diff --git a/media/libstagefright/include/HTTPBase.h b/media/libstagefright/include/HTTPBase.h index 1c3cd5e..0c66e27 100644 --- a/media/libstagefright/include/HTTPBase.h +++ b/media/libstagefright/include/HTTPBase.h @@ -48,6 +48,8 @@ struct HTTPBase : public DataSource { virtual status_t setBandwidthStatCollectFreq(int32_t freqMs); + virtual void setBandwidthHistorySize(size_t numHistoryItems); + static void RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag); static void UnRegisterSocketUserTag(int sockfd); @@ -55,7 +57,7 @@ struct HTTPBase : public DataSource { static void UnRegisterSocketUserMark(int sockfd); protected: - void addBandwidthMeasurement(size_t numBytes, int64_t delayUs); + virtual void addBandwidthMeasurement(size_t numBytes, int64_t delayUs); private: struct BandwidthEntry { @@ -69,6 +71,7 @@ private: size_t mNumBandwidthHistoryItems; int64_t mTotalTransferTimeUs; size_t mTotalTransferBytes; + size_t mMaxBandwidthHistoryItems; enum { kMinBandwidthCollectFreqMs = 1000, // 1 second -- cgit v1.1