diff options
Diffstat (limited to 'media/libstagefright/chromium_http')
5 files changed, 78 insertions, 18 deletions
diff --git a/media/libstagefright/chromium_http/Android.mk b/media/libstagefright/chromium_http/Android.mk index 2c6d84c..f26f386 100644 --- a/media/libstagefright/chromium_http/Android.mk +++ b/media/libstagefright/chromium_http/Android.mk @@ -22,6 +22,7 @@ LOCAL_SHARED_LIBRARIES += \ libchromium_net \ libutils \ libcutils \ + liblog \ libstagefright_foundation \ libstagefright \ libdrmframework diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp index 32a0ec8..7e5c280 100644 --- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp +++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp @@ -65,7 +65,10 @@ status_t ChromiumHTTPDataSource::connect( if (getUID(&uid)) { mDelegate->setUID(uid); } + +#if defined(LOG_NDEBUG) && !LOG_NDEBUG LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect on behalf of uid %d", uid); +#endif return connect_l(uri, headers, offset); } @@ -78,8 +81,10 @@ status_t ChromiumHTTPDataSource::connect_l( disconnect_l(); } - LOG_PRI(ANDROID_LOG_INFO, LOG_TAG, +#if defined(LOG_NDEBUG) && !LOG_NDEBUG + LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect to <URL suppressed> @%lld", offset); +#endif mURI = uri; mContentType = String8("application/octet-stream"); @@ -103,6 +108,11 @@ status_t ChromiumHTTPDataSource::connect_l( return mState == CONNECTED ? OK : mIOResult; } +void ChromiumHTTPDataSource::onRedirect(const char *url) { + Mutex::Autolock autoLock(mLock); + mURI = url; +} + void ChromiumHTTPDataSource::onConnectionEstablished( int64_t contentSize, const char *contentType) { Mutex::Autolock autoLock(mLock); @@ -335,5 +345,11 @@ status_t ChromiumHTTPDataSource::reconnectAtOffset(off64_t offset) { return err; } +// static +status_t ChromiumHTTPDataSource::UpdateProxyConfig( + const char *host, int32_t port, const char *exclusionList) { + return SfDelegate::UpdateProxyConfig(host, port, exclusionList); +} + } // namespace android diff --git a/media/libstagefright/chromium_http/chromium_http_stub.cpp b/media/libstagefright/chromium_http/chromium_http_stub.cpp index 560a61f..289f6de 100644 --- a/media/libstagefright/chromium_http/chromium_http_stub.cpp +++ b/media/libstagefright/chromium_http/chromium_http_stub.cpp @@ -26,6 +26,11 @@ HTTPBase *createChromiumHTTPDataSource(uint32_t flags) { return new ChromiumHTTPDataSource(flags); } +status_t UpdateChromiumHTTPDataSourceProxyConfig( + const char *host, int32_t port, const char *exclusionList) { + return ChromiumHTTPDataSource::UpdateProxyConfig(host, port, exclusionList); +} + DataSource *createDataUriSource(const char *uri) { return new DataUriSource(uri); } diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp index 13ae3df..3b33212 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -36,15 +36,15 @@ #include "include/ChromiumHTTPDataSource.h" #include <cutils/log.h> -#include <cutils/properties.h> #include <media/stagefright/MediaErrors.h> +#include <media/stagefright/Utils.h> #include <string> namespace android { static Mutex gNetworkThreadLock; static base::Thread *gNetworkThread = NULL; -static scoped_refptr<net::URLRequestContext> gReqContext; +static scoped_refptr<SfRequestContext> gReqContext; static scoped_ptr<net::NetworkChangeNotifier> gNetworkChangeNotifier; bool logMessageHandler( @@ -150,25 +150,13 @@ uint32 SfNetLog::NextID() { } net::NetLog::LogLevel SfNetLog::GetLogLevel() const { - return LOG_ALL; + return LOG_BASIC; } //////////////////////////////////////////////////////////////////////////////// SfRequestContext::SfRequestContext() { - AString ua; - ua.append("stagefright/1.2 (Linux;Android "); - -#if (PROPERTY_VALUE_MAX < 8) -#error "PROPERTY_VALUE_MAX must be at least 8" -#endif - - char value[PROPERTY_VALUE_MAX]; - property_get("ro.build.version.release", value, "Unknown"); - ua.append(value); - ua.append(")"); - - mUserAgent = ua.c_str(); + mUserAgent = MakeUserAgent().c_str(); set_net_log(new SfNetLog()); @@ -181,8 +169,10 @@ SfRequestContext::SfRequestContext() { set_ssl_config_service( net::SSLConfigService::CreateSystemSSLConfigService()); + mProxyConfigService = new net::ProxyConfigServiceAndroid; + set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( - new net::ProxyConfigServiceAndroid, net_log())); + mProxyConfigService, net_log())); set_http_transaction_factory(new net::HttpCache( host_resolver(), @@ -203,6 +193,31 @@ const std::string &SfRequestContext::GetUserAgent(const GURL &url) const { return mUserAgent; } +status_t SfRequestContext::updateProxyConfig( + const char *host, int32_t port, const char *exclusionList) { + Mutex::Autolock autoLock(mProxyConfigLock); + + if (host == NULL || *host == '\0') { + MY_LOGV("updateProxyConfig NULL"); + + std::string proxy; + std::string exList; + mProxyConfigService->UpdateProxySettings(proxy, exList); + } else { +#if !defined(LOG_NDEBUG) || LOG_NDEBUG == 0 + LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, + "updateProxyConfig %s:%d, exclude '%s'", + host, port, exclusionList); +#endif + + std::string proxy = StringPrintf("%s:%d", host, port).c_str(); + std::string exList = exclusionList; + mProxyConfigService->UpdateProxySettings(proxy, exList); + } + + return OK; +} + //////////////////////////////////////////////////////////////////////////////// SfNetworkLibrary::SfNetworkLibrary() {} @@ -231,6 +246,14 @@ SfDelegate::~SfDelegate() { CHECK(mURLRequest == NULL); } +// static +status_t SfDelegate::UpdateProxyConfig( + const char *host, int32_t port, const char *exclusionList) { + InitializeNetworkThreadIfNecessary(); + + return gReqContext->updateProxyConfig(host, port, exclusionList); +} + void SfDelegate::setOwner(ChromiumHTTPDataSource *owner) { mOwner = owner; } @@ -246,6 +269,7 @@ bool SfDelegate::getUID(uid_t *uid) const { void SfDelegate::OnReceivedRedirect( net::URLRequest *request, const GURL &new_url, bool *defer_redirect) { MY_LOGV("OnReceivedRedirect"); + mOwner->onRedirect(new_url.spec().c_str()); } void SfDelegate::OnAuthRequired( diff --git a/media/libstagefright/chromium_http/support.h b/media/libstagefright/chromium_http/support.h index d2c5bc0..975a1d3 100644 --- a/media/libstagefright/chromium_http/support.h +++ b/media/libstagefright/chromium_http/support.h @@ -27,8 +27,13 @@ #include "net/base/io_buffer.h" #include <utils/KeyedVector.h> +#include <utils/Mutex.h> #include <utils/String8.h> +namespace net { + struct ProxyConfigServiceAndroid; +}; + namespace android { struct SfNetLog : public net::NetLog { @@ -55,8 +60,14 @@ struct SfRequestContext : public net::URLRequestContext { virtual const std::string &GetUserAgent(const GURL &url) const; + status_t updateProxyConfig( + const char *host, int32_t port, const char *exclusionList); + private: + Mutex mProxyConfigLock; + std::string mUserAgent; + net::ProxyConfigServiceAndroid *mProxyConfigService; DISALLOW_EVIL_CONSTRUCTORS(SfRequestContext); }; @@ -120,6 +131,9 @@ struct SfDelegate : public net::URLRequest::Delegate { virtual void OnReadCompleted(net::URLRequest *request, int bytes_read); + static status_t UpdateProxyConfig( + const char *host, int32_t port, const char *exclusionList); + private: typedef Delegate inherited; |