diff options
author | James Dong <jdong@google.com> | 2011-05-25 19:37:03 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2011-05-31 15:23:25 -0700 |
commit | 5b1b8a93a07326f1cbc627f09e02988375189e0a (patch) | |
tree | 1da7ba8c401fb96b4de5fab790fba8e51eea78f6 /media/libstagefright/include | |
parent | 65580f9adf6c4d98449ad0716488f9fe3869aa5a (diff) | |
download | frameworks_av-5b1b8a93a07326f1cbc627f09e02988375189e0a.zip frameworks_av-5b1b8a93a07326f1cbc627f09e02988375189e0a.tar.gz frameworks_av-5b1b8a93a07326f1cbc627f09e02988375189e0a.tar.bz2 |
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
Diffstat (limited to 'media/libstagefright/include')
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 2 | ||||
-rw-r--r-- | media/libstagefright/include/ChromiumHTTPDataSource.h | 14 | ||||
-rw-r--r-- | media/libstagefright/include/HTTPBase.h | 34 | ||||
-rw-r--r-- | media/libstagefright/include/NuCachedSource2.h | 2 | ||||
-rw-r--r-- | media/libstagefright/include/NuHTTPDataSource.h | 15 |
5 files changed, 37 insertions, 30 deletions
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index a9e8e95..aebcdd1 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -93,6 +93,7 @@ struct AwesomePlayer { status_t setParameter(int key, const Parcel &request); status_t getParameter(int key, Parcel *reply); + status_t setCacheStatCollectFreq(const Parcel &request); status_t seekTo(int64_t timeUs); @@ -291,6 +292,7 @@ private: void setNativeWindow_l(const sp<ANativeWindow> &native); bool isStreamingHTTP() const; + void sendCacheStats(); AwesomePlayer(const AwesomePlayer &); AwesomePlayer &operator=(const AwesomePlayer &); diff --git a/media/libstagefright/include/ChromiumHTTPDataSource.h b/media/libstagefright/include/ChromiumHTTPDataSource.h index 0e2927d..d833e2e 100644 --- a/media/libstagefright/include/ChromiumHTTPDataSource.h +++ b/media/libstagefright/include/ChromiumHTTPDataSource.h @@ -43,8 +43,6 @@ struct ChromiumHTTPDataSource : public HTTPBase { virtual status_t getSize(off64_t *size); virtual uint32_t flags(); - virtual bool estimateBandwidth(int32_t *bandwidth_bps); - virtual sp<DecryptHandle> DrmInitialization(); virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client); @@ -67,11 +65,6 @@ private: DISCONNECTING }; - struct BandwidthEntry { - int64_t mDelayUs; - size_t mNumBytes; - }; - const uint32_t mFlags; mutable Mutex mLock; @@ -94,11 +87,6 @@ private: String8 mContentType; - List<BandwidthEntry> mBandwidthHistory; - size_t mNumBandwidthHistoryItems; - int64_t mTotalTransferTimeUs; - size_t mTotalTransferBytes; - sp<DecryptHandle> mDecryptHandle; DrmManagerClient *mDrmManagerClient; @@ -121,8 +109,6 @@ private: void onReadCompleted(ssize_t size); void onDisconnectComplete(); - void addBandwidthMeasurement_l(size_t numBytes, int64_t delayUs); - void clearDRMState_l(); DISALLOW_EVIL_CONSTRUCTORS(ChromiumHTTPDataSource); diff --git a/media/libstagefright/include/HTTPBase.h b/media/libstagefright/include/HTTPBase.h index 6cec390..3a7fbb6 100644 --- a/media/libstagefright/include/HTTPBase.h +++ b/media/libstagefright/include/HTTPBase.h @@ -20,6 +20,8 @@ #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/DataSource.h> +#include <media/stagefright/MediaErrors.h> +#include <utils/threads.h> namespace android { @@ -40,11 +42,41 @@ struct HTTPBase : public DataSource { // Returns true if bandwidth could successfully be estimated, // false otherwise. - virtual bool estimateBandwidth(int32_t *bandwidth_bps) = 0; + virtual bool estimateBandwidth(int32_t *bandwidth_bps); + + virtual status_t getEstimatedBandwidthKbps(int32_t *kbps); + + virtual status_t setBandwidthStatCollectFreq(int32_t freqMs); static sp<HTTPBase> Create(uint32_t flags = 0); +protected: + void addBandwidthMeasurement(size_t numBytes, int64_t delayUs); + private: + + struct BandwidthEntry { + int64_t mDelayUs; + size_t mNumBytes; + }; + + Mutex mLock; + + List<BandwidthEntry> mBandwidthHistory; + size_t mNumBandwidthHistoryItems; + int64_t mTotalTransferTimeUs; + size_t mTotalTransferBytes; + + enum { + kMinBandwidthCollectFreqMs = 1000, // 1 second + kMaxBandwidthCollectFreqMs = 60000, // one minute + }; + + int64_t mPrevBandwidthMeasureTimeUs; + int32_t mPrevEstimatedBandWidthKbps; + int32_t mBandWidthCollectFreqMs; + + DISALLOW_EVIL_CONSTRUCTORS(HTTPBase); }; diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h index ed3e265..31fc0e5 100644 --- a/media/libstagefright/include/NuCachedSource2.h +++ b/media/libstagefright/include/NuCachedSource2.h @@ -47,8 +47,10 @@ struct NuCachedSource2 : public DataSource { size_t cachedSize(); size_t approxDataRemaining(status_t *finalStatus); + status_t setCacheStatCollectFreq(int32_t freqMs); void resumeFetchingIfNecessary(); + status_t getEstimatedBandwidthKbps(int32_t *kbps); protected: virtual ~NuCachedSource2(); diff --git a/media/libstagefright/include/NuHTTPDataSource.h b/media/libstagefright/include/NuHTTPDataSource.h index 2ab1f19..c265b3a 100644 --- a/media/libstagefright/include/NuHTTPDataSource.h +++ b/media/libstagefright/include/NuHTTPDataSource.h @@ -43,10 +43,6 @@ struct NuHTTPDataSource : public HTTPBase { virtual status_t getSize(off64_t *size); virtual uint32_t flags(); - // Returns true if bandwidth could successfully be estimated, - // false otherwise. - virtual bool estimateBandwidth(int32_t *bandwidth_bps); - virtual sp<DecryptHandle> DrmInitialization(); virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client); virtual String8 getUri(); @@ -63,11 +59,6 @@ private: CONNECTED }; - struct BandwidthEntry { - int64_t mDelayUs; - size_t mNumBytes; - }; - Mutex mLock; uint32_t mFlags; @@ -93,11 +84,6 @@ private: // chunk header (or -1 if no more chunks). ssize_t mChunkDataBytesLeft; - List<BandwidthEntry> mBandwidthHistory; - size_t mNumBandwidthHistoryItems; - int64_t mTotalTransferTimeUs; - size_t mTotalTransferBytes; - sp<DecryptHandle> mDecryptHandle; DrmManagerClient *mDrmManagerClient; @@ -114,7 +100,6 @@ private: ssize_t internalRead(void *data, size_t size); void applyTimeoutResponse(); - void addBandwidthMeasurement_l(size_t numBytes, int64_t delayUs); static void MakeFullHeaders( const KeyedVector<String8, String8> *overrides, |