diff options
| author | 2011-04-29 14:42:58 -0700 | |
|---|---|---|
| committer | 2011-04-29 14:42:58 -0700 | |
| commit | f181e416ee3f104e79be2c2a76e9c1c25a214e17 (patch) | |
| tree | dce78ae541a7debf437be6b9c0942178bb1a6992 | |
| parent | 5f2ff42b282e093b61b9e7b07c79a74ea8ce3272 (diff) | |
| parent | ec78f551b575b0274cbe796f8e08a9df1a706680 (diff) | |
am ec78f551: Add avg bandwidth estimate every 2 seconds - do not merge.
* commit 'ec78f551b575b0274cbe796f8e08a9df1a706680':
Add avg bandwidth estimate every 2 seconds - do not merge.
| -rw-r--r-- | media/libstagefright/NuHTTPDataSource.cpp | 11 | ||||
| -rw-r--r-- | media/libstagefright/include/NuHTTPDataSource.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp index bee0d5e03092..62fb73256987 100644 --- a/media/libstagefright/NuHTTPDataSource.cpp +++ b/media/libstagefright/NuHTTPDataSource.cpp @@ -100,6 +100,7 @@ NuHTTPDataSource::NuHTTPDataSource(uint32_t flags) mNumBandwidthHistoryItems(0), mTotalTransferTimeUs(0), mTotalTransferBytes(0), + mPrevBandwidthMeasureTimeUs(0), mDecryptHandle(NULL), mDrmManagerClient(NULL) { } @@ -534,6 +535,16 @@ void NuHTTPDataSource::addBandwidthMeasurement_l( mTotalTransferBytes -= entry->mNumBytes; mBandwidthHistory.erase(mBandwidthHistory.begin()); --mNumBandwidthHistoryItems; + int64_t timeNowUs = ALooper::GetNowUs(); + if (timeNowUs - mPrevBandwidthMeasureTimeUs > 2000000LL) { + if (mPrevBandwidthMeasureTimeUs != 0) { + double estimatedBandwidth = + ((double)mTotalTransferBytes * 8E3 / mTotalTransferTimeUs); + LOGI("estimated avg bandwidth is %8.2f kbps in the past %lld us", + estimatedBandwidth, timeNowUs - mPrevBandwidthMeasureTimeUs); + } + mPrevBandwidthMeasureTimeUs = timeNowUs; + } } } diff --git a/media/libstagefright/include/NuHTTPDataSource.h b/media/libstagefright/include/NuHTTPDataSource.h index 25695688c6cf..0d682340515a 100644 --- a/media/libstagefright/include/NuHTTPDataSource.h +++ b/media/libstagefright/include/NuHTTPDataSource.h @@ -97,6 +97,7 @@ private: size_t mNumBandwidthHistoryItems; int64_t mTotalTransferTimeUs; size_t mTotalTransferBytes; + int64_t mPrevBandwidthMeasureTimeUs; DecryptHandle *mDecryptHandle; DrmManagerClient *mDrmManagerClient; |