From b7319a7eb0a06ef4fd3a0c9157ee63e637ad7aa1 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 29 May 2013 14:20:52 -0700 Subject: Update HTTP proxy configuration for all media playback inside stagefright. Change-Id: Ie0dd00045aba668d8b49da73224e7a7c9c04f69b related-to-bug: 8873723 (cherry picked from commit 2704965b8a1ff3b7450ff58ccecf86d8ec688c40) --- .../chromium_http/ChromiumHTTPDataSource.cpp | 6 ++++ .../chromium_http/chromium_http_stub.cpp | 5 +++ media/libstagefright/chromium_http/support.cpp | 39 ++++++++++++++++++++-- media/libstagefright/chromium_http/support.h | 14 ++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/chromium_http') diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp index 91ce175..a862d8b 100644 --- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp +++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp @@ -340,5 +340,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 832e86d..741cb1d 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -44,7 +44,7 @@ namespace android { static Mutex gNetworkThreadLock; static base::Thread *gNetworkThread = NULL; -static scoped_refptr gReqContext; +static scoped_refptr gReqContext; static scoped_ptr gNetworkChangeNotifier; bool logMessageHandler( @@ -169,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(), @@ -191,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() {} @@ -219,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; } 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 +#include #include +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; -- cgit v1.1