commit 7aeef47671133760672f881b38117cb4070f32b3 Author: Igor Oliveira igt0@torproject.org Date: Mon Jun 4 05:15:00 2018 +0300
Bug 1459420 - HLS Player doesn't use the centralized Proxy Selector r=mcomella GeckoHlsPlayer uses the default http ExoPlayer handler, called DefaultHttpDataSource. It uses URL::openConnection instead of the Firefox ProxySelector.
This patch updates the ExoPlayer DefaultHttpDataSource to use the ProxySelector. --- .../exoplayer2/upstream/DefaultHttpDataSource.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java index 599cdddeb91f..75e1f675c5eb 100644 --- a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java +++ b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java @@ -31,6 +31,7 @@ import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.NoRouteToHostException; import java.net.ProtocolException; +import java.net.URISyntaxException; import java.net.URL; import java.util.List; import java.util.Map; @@ -38,6 +39,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern;
+import org.mozilla.gecko.util.ProxySelector; + /** * An {@link HttpDataSource} that uses Android's {@link HttpURLConnection}. * <p> @@ -193,6 +196,8 @@ public class DefaultHttpDataSource implements HttpDataSource { } catch (IOException e) { throw new HttpDataSourceException("Unable to connect to " + dataSpec.uri.toString(), e, dataSpec, HttpDataSourceException.TYPE_OPEN); + } catch (URISyntaxException e) { + throw new HttpDataSourceException("URI invalid: " + dataSpec.uri.toString(), dataSpec, HttpDataSourceException.TYPE_OPEN); }
int responseCode; @@ -337,7 +342,7 @@ public class DefaultHttpDataSource implements HttpDataSource { /** * Establishes a connection, following redirects to do so where permitted. */ - private HttpURLConnection makeConnection(DataSpec dataSpec) throws IOException { + private HttpURLConnection makeConnection(DataSpec dataSpec) throws IOException, URISyntaxException { URL url = new URL(dataSpec.uri.toString()); byte[] postBody = dataSpec.postBody; long position = dataSpec.position; @@ -389,8 +394,14 @@ public class DefaultHttpDataSource implements HttpDataSource { * @param followRedirects Whether to follow redirects. */ private HttpURLConnection makeConnection(URL url, byte[] postBody, long position, - long length, boolean allowGzip, boolean followRedirects) throws IOException { - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + long length, boolean allowGzip, boolean followRedirects) throws IOException, URISyntaxException { + /** + * Tor Project modified the way the connection object was created. For the sake of + * simplicity, instead of duplicating the whole file we changed the connection object + * to use the ProxySelector. + */ + HttpURLConnection connection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(url.toURI()); + connection.setConnectTimeout(connectTimeoutMillis); connection.setReadTimeout(readTimeoutMillis); if (defaultRequestProperties != null) {