summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-06-02 10:22:50 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-02 10:22:50 -0700
commit92a746c3b18d035189f596ce32847bf26247aaca (patch)
tree056ed4c354869613bd1f644323b6c90fb65a9ea2
parentc6854100cea4fcd0f20cb2ac8235c02d1849b3a1 (diff)
parentb33d2ac90cfce0fe6db8c3e979e7ae2bbfc28163 (diff)
downloadframeworks_av-92a746c3b18d035189f596ce32847bf26247aaca.zip
frameworks_av-92a746c3b18d035189f596ce32847bf26247aaca.tar.gz
frameworks_av-92a746c3b18d035189f596ce32847bf26247aaca.tar.bz2
Merge "Do not call getEstimatedBandwidth if the streaming is not HTTP-based"
-rw-r--r--include/media/stagefright/DataSource.h1
-rw-r--r--media/libstagefright/AwesomePlayer.cpp2
-rw-r--r--media/libstagefright/NuCachedSource2.cpp18
-rw-r--r--media/libstagefright/NuHTTPDataSource.cpp2
-rw-r--r--media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp2
-rw-r--r--media/libstagefright/include/NuCachedSource2.h6
6 files changed, 22 insertions, 9 deletions
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index 6b6fcdf..48d1464 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -38,6 +38,7 @@ public:
kWantsPrefetching = 1,
kStreamedFromLocalHost = 2,
kIsCachingDataSource = 4,
+ kIsHTTPBasedSource = 8,
};
static sp<DataSource> CreateFromURI(
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 07a47e5..3a58d3f 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -715,7 +715,7 @@ void AwesomePlayer::onBufferingUpdate() {
void AwesomePlayer::sendCacheStats() {
sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL) {
+ if (listener != NULL && mCachedSource != NULL) {
int32_t kbps = 0;
status_t err = mCachedSource->getEstimatedBandwidthKbps(&kbps);
if (err == OK) {
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index b2ed427..77a6602 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -203,13 +203,19 @@ NuCachedSource2::~NuCachedSource2() {
}
status_t NuCachedSource2::getEstimatedBandwidthKbps(int32_t *kbps) {
- HTTPBase* source = static_cast<HTTPBase *>(mSource.get());
- return source->getEstimatedBandwidthKbps(kbps);
+ if (mSource->flags() & kIsHTTPBasedSource) {
+ HTTPBase* source = static_cast<HTTPBase *>(mSource.get());
+ return source->getEstimatedBandwidthKbps(kbps);
+ }
+ return ERROR_UNSUPPORTED;
}
status_t NuCachedSource2::setCacheStatCollectFreq(int32_t freqMs) {
- HTTPBase *source = static_cast<HTTPBase *>(mSource.get());
- return source->setBandwidthStatCollectFreq(freqMs);
+ if (mSource->flags() & kIsHTTPBasedSource) {
+ HTTPBase *source = static_cast<HTTPBase *>(mSource.get());
+ return source->setBandwidthStatCollectFreq(freqMs);
+ }
+ return ERROR_UNSUPPORTED;
}
status_t NuCachedSource2::initCheck() const {
@@ -221,7 +227,9 @@ status_t NuCachedSource2::getSize(off64_t *size) {
}
uint32_t NuCachedSource2::flags() {
- return (mSource->flags() & ~kWantsPrefetching) | kIsCachingDataSource;
+ // Remove HTTP related flags since NuCachedSource2 is not HTTP-based.
+ uint32_t flags = mSource->flags() & ~(kWantsPrefetching | kIsHTTPBasedSource);
+ return (flags | kIsCachingDataSource);
}
void NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) {
diff --git a/media/libstagefright/NuHTTPDataSource.cpp b/media/libstagefright/NuHTTPDataSource.cpp
index c3b5e8f..dac2ee4 100644
--- a/media/libstagefright/NuHTTPDataSource.cpp
+++ b/media/libstagefright/NuHTTPDataSource.cpp
@@ -464,7 +464,7 @@ status_t NuHTTPDataSource::getSize(off64_t *size) {
}
uint32_t NuHTTPDataSource::flags() {
- return kWantsPrefetching;
+ return kWantsPrefetching | kIsHTTPBasedSource;
}
// static
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
index ad1f342..588a74d 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -218,7 +218,7 @@ status_t ChromiumHTTPDataSource::getSize(off64_t *size) {
}
uint32_t ChromiumHTTPDataSource::flags() {
- return kWantsPrefetching;
+ return kWantsPrefetching | kIsHTTPBasedSource;
}
// static
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index 31fc0e5..2d6cb84 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -47,10 +47,14 @@ struct NuCachedSource2 : public DataSource {
size_t cachedSize();
size_t approxDataRemaining(status_t *finalStatus);
- status_t setCacheStatCollectFreq(int32_t freqMs);
void resumeFetchingIfNecessary();
+
+ // The following methods are supported only if the
+ // data source is HTTP-based; otherwise, ERROR_UNSUPPORTED
+ // is returned.
status_t getEstimatedBandwidthKbps(int32_t *kbps);
+ status_t setCacheStatCollectFreq(int32_t freqMs);
protected:
virtual ~NuCachedSource2();