am ec78f551: Add avg bandwidth estimate every 2 seconds - do not merge.
* commit 'ec78f551b575b0274cbe796f8e08a9df1a706680': Add avg bandwidth estimate every 2 seconds - do not merge.
This commit is contained in:
@@ -100,6 +100,7 @@ NuHTTPDataSource::NuHTTPDataSource(uint32_t flags)
|
|||||||
mNumBandwidthHistoryItems(0),
|
mNumBandwidthHistoryItems(0),
|
||||||
mTotalTransferTimeUs(0),
|
mTotalTransferTimeUs(0),
|
||||||
mTotalTransferBytes(0),
|
mTotalTransferBytes(0),
|
||||||
|
mPrevBandwidthMeasureTimeUs(0),
|
||||||
mDecryptHandle(NULL),
|
mDecryptHandle(NULL),
|
||||||
mDrmManagerClient(NULL) {
|
mDrmManagerClient(NULL) {
|
||||||
}
|
}
|
||||||
@@ -534,6 +535,16 @@ void NuHTTPDataSource::addBandwidthMeasurement_l(
|
|||||||
mTotalTransferBytes -= entry->mNumBytes;
|
mTotalTransferBytes -= entry->mNumBytes;
|
||||||
mBandwidthHistory.erase(mBandwidthHistory.begin());
|
mBandwidthHistory.erase(mBandwidthHistory.begin());
|
||||||
--mNumBandwidthHistoryItems;
|
--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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ private:
|
|||||||
size_t mNumBandwidthHistoryItems;
|
size_t mNumBandwidthHistoryItems;
|
||||||
int64_t mTotalTransferTimeUs;
|
int64_t mTotalTransferTimeUs;
|
||||||
size_t mTotalTransferBytes;
|
size_t mTotalTransferBytes;
|
||||||
|
int64_t mPrevBandwidthMeasureTimeUs;
|
||||||
|
|
||||||
DecryptHandle *mDecryptHandle;
|
DecryptHandle *mDecryptHandle;
|
||||||
DrmManagerClient *mDrmManagerClient;
|
DrmManagerClient *mDrmManagerClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user