diff options
author | Leena Winterrowd <lenhardw@codeaurora.org> | 2015-01-29 08:41:27 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-29 08:41:27 +0000 |
commit | 1eda9bfba04043c380666ba1ee86fd285b8ffbca (patch) | |
tree | ebf4401bd53fd91460b29eda1919179b75191767 /media | |
parent | 00dfe8432618c1d512557b2ed5910c44fc293948 (diff) | |
parent | ce25d85ad22e6df4b861d17e9e67cb6d0e62c363 (diff) | |
download | frameworks_av-1eda9bfba04043c380666ba1ee86fd285b8ffbca.zip frameworks_av-1eda9bfba04043c380666ba1ee86fd285b8ffbca.tar.gz frameworks_av-1eda9bfba04043c380666ba1ee86fd285b8ffbca.tar.bz2 |
am ce25d85a: am a93fd2be: stagefright: httplive: Decouple block size from bandwidth estimate
* commit 'ce25d85ad22e6df4b861d17e9e67cb6d0e62c363':
stagefright: httplive: Decouple block size from bandwidth estimate
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/HTTPBase.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.h | 2 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 3 | ||||
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.h | 2 | ||||
-rw-r--r-- | media/libstagefright/include/HTTPBase.h | 5 |
6 files changed, 26 insertions, 5 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); diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index c906aa8..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() { 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 3f05208..1526af1 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -49,7 +49,8 @@ namespace android { // static const int64_t PlaylistFetcher::kMinBufferedDurationUs = 10000000ll; const int64_t PlaylistFetcher::kMaxMonitorDelayUs = 3000000ll; -const int32_t PlaylistFetcher::kDownloadBlockSize = 2048; +// 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( diff --git a/media/libstagefright/httplive/PlaylistFetcher.h b/media/libstagefright/httplive/PlaylistFetcher.h index b27881b..4e15f85 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.h +++ b/media/libstagefright/httplive/PlaylistFetcher.h @@ -35,6 +35,7 @@ class String8; struct PlaylistFetcher : public AHandler { static const int64_t kMinBufferedDurationUs; + static const int32_t kDownloadBlockSize; enum { kWhatStarted, @@ -95,7 +96,6 @@ private: }; static const int64_t kMaxMonitorDelayUs; - static const int32_t kDownloadBlockSize; static const int32_t kNumSkipFrames; static bool bufferStartsWithTsSyncByte(const sp<ABuffer>& buffer); 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 |