From 5b1b8a93a07326f1cbc627f09e02988375189e0a Mon Sep 17 00:00:00 2001 From: James Dong Date: Wed, 25 May 2011 19:37:03 -0700 Subject: Send estimated bandwidth value as informational event when cache fetcher pauses o Application can make informed decision about the available network bandwidth when cache fetcher pauses. o Application can also adjust how frequently the bandwidth is estimated within a range from one second to one minute. Change-Id: I90068001343e79da1886de03c565537787e1580b --- .../chromium_http/ChromiumHTTPDataSource.cpp | 35 +--------------------- 1 file changed, 1 insertion(+), 34 deletions(-) (limited to 'media/libstagefright/chromium_http') diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp index 1096717..ad1f342 100644 --- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp +++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp @@ -34,9 +34,6 @@ ChromiumHTTPDataSource::ChromiumHTTPDataSource(uint32_t flags) mCurrentOffset(0), mIOResult(OK), mContentSize(-1), - mNumBandwidthHistoryItems(0), - mTotalTransferTimeUs(0), - mTotalTransferBytes(0), mDecryptHandle(NULL), mDrmManagerClient(NULL) { mDelegate->setOwner(this); @@ -188,7 +185,7 @@ ssize_t ChromiumHTTPDataSource::readAt(off64_t offset, void *data, size_t size) // The read operation was successful, mIOResult contains // the number of bytes read. - addBandwidthMeasurement_l(mIOResult, delayUs); + addBandwidthMeasurement(mIOResult, delayUs); mCurrentOffset += mIOResult; return mIOResult; @@ -246,36 +243,6 @@ void ChromiumHTTPDataSource::onDisconnectComplete() { clearDRMState_l(); } -void ChromiumHTTPDataSource::addBandwidthMeasurement_l( - size_t numBytes, int64_t delayUs) { - BandwidthEntry entry; - entry.mDelayUs = delayUs; - entry.mNumBytes = numBytes; - mTotalTransferTimeUs += delayUs; - mTotalTransferBytes += numBytes; - - mBandwidthHistory.push_back(entry); - if (++mNumBandwidthHistoryItems > 100) { - BandwidthEntry *entry = &*mBandwidthHistory.begin(); - mTotalTransferTimeUs -= entry->mDelayUs; - mTotalTransferBytes -= entry->mNumBytes; - mBandwidthHistory.erase(mBandwidthHistory.begin()); - --mNumBandwidthHistoryItems; - } -} - -bool ChromiumHTTPDataSource::estimateBandwidth(int32_t *bandwidth_bps) { - Mutex::Autolock autoLock(mLock); - - if (mNumBandwidthHistoryItems < 2) { - return false; - } - - *bandwidth_bps = ((double)mTotalTransferBytes * 8E6 / mTotalTransferTimeUs); - - return true; -} - sp ChromiumHTTPDataSource::DrmInitialization() { Mutex::Autolock autoLock(mLock); -- cgit v1.1