Commit a335c964 by bachinger Committed by Christos Tsilopoulos

Deprecate HttpDataSource.Factory.getDefaultRequestProperties

#exofixit

PiperOrigin-RevId: 347375323
parent 5aac1898
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
been handled and the values reported through callbacks are again been handled and the values reported through callbacks are again
completely consistent with the values obtained from the `Player` completely consistent with the values obtained from the `Player`
getters. getters.
* Deprecate `HttpDataSource.Factory.getDefaultRequestProperties` and add
`HttpDataSource.Factory.setDefaultRequestProperties` instead.
* Track selection: * Track selection:
* Add option to specify multiple preferred audio or text languages. * Add option to specify multiple preferred audio or text languages.
* Forward `Timeline` and `MediaPeriodId` to `TrackSelection.Factory`. * Forward `Timeline` and `MediaPeriodId` to `TrackSelection.Factory`.
......
...@@ -343,7 +343,7 @@ public final class CronetDataSourceFactory extends BaseFactory { ...@@ -343,7 +343,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
@Override @Override
protected HttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties protected HttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties
defaultRequestProperties) { defaultRequestProperties) {
CronetEngine cronetEngine = cronetEngineWrapper.getCronetEngine(); @Nullable CronetEngine cronetEngine = cronetEngineWrapper.getCronetEngine();
if (cronetEngine == null) { if (cronetEngine == null) {
return fallbackFactory.createDataSource(); return fallbackFactory.createDataSource();
} }
......
...@@ -343,8 +343,7 @@ public final class DataSpec { ...@@ -343,8 +343,7 @@ public final class DataSpec {
* header directly. * header directly.
* <li>Other headers set at the {@link HttpDataSource} layer. I.e., headers set using {@link * <li>Other headers set at the {@link HttpDataSource} layer. I.e., headers set using {@link
* HttpDataSource#setRequestProperty(String, String)}, and using {@link * HttpDataSource#setRequestProperty(String, String)}, and using {@link
* HttpDataSource.RequestProperties#set(String, String)} on the default properties obtained * HttpDataSource.Factory#setDefaultRequestProperties(Map)}.
* from {@link HttpDataSource.Factory#getDefaultRequestProperties()}.
* </ul> * </ul>
*/ */
public final Map<String, String> httpRequestHeaders; public final Map<String, String> httpRequestHeaders;
......
...@@ -42,43 +42,23 @@ public interface HttpDataSource extends DataSource { ...@@ -42,43 +42,23 @@ public interface HttpDataSource extends DataSource {
@Override @Override
HttpDataSource createDataSource(); HttpDataSource createDataSource();
/** /** @deprecated Use {@link #setDefaultRequestProperties(Map)} instead. */
* Gets the default request properties used by all {@link HttpDataSource}s created by the
* factory. Changes to the properties will be reflected in any future requests made by
* {@link HttpDataSource}s created by the factory.
*
* @return The default request properties of the factory.
*/
RequestProperties getDefaultRequestProperties();
/**
* Sets a default request header for {@link HttpDataSource} instances created by the factory.
*
* @deprecated Use {@link #getDefaultRequestProperties} instead.
* @param name The name of the header field.
* @param value The value of the field.
*/
@Deprecated @Deprecated
void setDefaultRequestProperty(String name, String value); RequestProperties getDefaultRequestProperties();
/** /**
* Clears a default request header for {@link HttpDataSource} instances created by the factory. * Sets the default request headers for {@link HttpDataSource} instances created by the factory.
* *
* @deprecated Use {@link #getDefaultRequestProperties} instead. * <p>The new request properties will be used for future requests made by {@link HttpDataSource
* @param name The name of the header field. * HttpDataSources} created by the factory, including instances that have already been created.
*/ * Modifying the {@code defaultRequestProperties} map after a call to this method will have no
@Deprecated * effect, and so it's necessary to call this method again each time the request properties need
void clearDefaultRequestProperty(String name); * to be updated.
/**
* Clears all default request headers for all {@link HttpDataSource} instances created by the
* factory.
* *
* @deprecated Use {@link #getDefaultRequestProperties} instead. * @param defaultRequestProperties The default request properties.
* @return This factory.
*/ */
@Deprecated Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties);
void clearAllDefaultRequestProperties();
} }
/** /**
...@@ -159,12 +139,9 @@ public interface HttpDataSource extends DataSource { ...@@ -159,12 +139,9 @@ public interface HttpDataSource extends DataSource {
} }
return requestPropertiesSnapshot; return requestPropertiesSnapshot;
} }
} }
/** /** Base implementation of {@link Factory} that sets default request properties. */
* Base implementation of {@link Factory} that sets default request properties.
*/
abstract class BaseFactory implements Factory { abstract class BaseFactory implements Factory {
private final RequestProperties defaultRequestProperties; private final RequestProperties defaultRequestProperties;
...@@ -178,30 +155,17 @@ public interface HttpDataSource extends DataSource { ...@@ -178,30 +155,17 @@ public interface HttpDataSource extends DataSource {
return createDataSourceInternal(defaultRequestProperties); return createDataSourceInternal(defaultRequestProperties);
} }
/** @deprecated Use {@link #setDefaultRequestProperties(Map)} instead. */
@Deprecated
@Override @Override
public final RequestProperties getDefaultRequestProperties() { public final RequestProperties getDefaultRequestProperties() {
return defaultRequestProperties; return defaultRequestProperties;
} }
/** @deprecated Use {@link #getDefaultRequestProperties} instead. */
@Deprecated
@Override
public final void setDefaultRequestProperty(String name, String value) {
defaultRequestProperties.set(name, value);
}
/** @deprecated Use {@link #getDefaultRequestProperties} instead. */
@Deprecated
@Override @Override
public final void clearDefaultRequestProperty(String name) { public final Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties) {
defaultRequestProperties.remove(name); this.defaultRequestProperties.clearAndSet(defaultRequestProperties);
} return this;
/** @deprecated Use {@link #getDefaultRequestProperties} instead. */
@Deprecated
@Override
public final void clearAllDefaultRequestProperties() {
defaultRequestProperties.clear();
} }
/** /**
...@@ -211,9 +175,8 @@ public interface HttpDataSource extends DataSource { ...@@ -211,9 +175,8 @@ public interface HttpDataSource extends DataSource {
* {@link HttpDataSource} instance. * {@link HttpDataSource} instance.
* @return A {@link HttpDataSource} instance. * @return A {@link HttpDataSource} instance.
*/ */
protected abstract HttpDataSource createDataSourceInternal(RequestProperties protected abstract HttpDataSource createDataSourceInternal(
defaultRequestProperties); RequestProperties defaultRequestProperties);
} }
/** A {@link Predicate} that rejects content types often used for pay-walls. */ /** A {@link Predicate} that rejects content types often used for pay-walls. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment