Commit dc6cc455 by ibaker Committed by Ian Baker

Remove `@Nullable` from some `Dash/Hls/SsMediaSource.Factory` methods

The null-behaviour of these methods creates a minimization footgun,
because **any** call to these setters will prevent R8 from removing
the default implementation (even if it's never used by the app) - this
is because R8 can't tell the default implementation is only used if the
parameter is `null`.

Follow-up to https://github.com/google/ExoPlayer/commit/57182ac7bd32db54d11fd41e21338a2bbfaf043c

PiperOrigin-RevId: 450395941
parent 57182ac7
...@@ -216,11 +216,13 @@ public final class DashMediaSource extends BaseMediaSource { ...@@ -216,11 +216,13 @@ public final class DashMediaSource extends BaseMediaSource {
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
public Factory setCompositeSequenceableLoaderFactory( public Factory setCompositeSequenceableLoaderFactory(
@Nullable CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory = this.compositeSequenceableLoaderFactory =
compositeSequenceableLoaderFactory != null checkNotNull(
? compositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
: new DefaultCompositeSequenceableLoaderFactory(); "DashMediaSource.Factory#setCompositeSequenceableLoaderFactory no longer handles null"
+ " by instantiating a new DefaultCompositeSequenceableLoaderFactory. Explicitly"
+ " construct and pass an instance in order to retain the old behavior.");
return this; return this;
} }
......
...@@ -187,41 +187,40 @@ public final class HlsMediaSource extends BaseMediaSource ...@@ -187,41 +187,40 @@ public final class HlsMediaSource extends BaseMediaSource
} }
/** /**
* Sets the factory from which playlist parsers will be obtained. The default value is a {@link * Sets the factory from which playlist parsers will be obtained.
* DefaultHlsPlaylistParserFactory}.
* *
* @param playlistParserFactory An {@link HlsPlaylistParserFactory}. * @param playlistParserFactory An {@link HlsPlaylistParserFactory}.
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
public Factory setPlaylistParserFactory( public Factory setPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory) {
@Nullable HlsPlaylistParserFactory playlistParserFactory) {
this.playlistParserFactory = this.playlistParserFactory =
playlistParserFactory != null checkNotNull(
? playlistParserFactory playlistParserFactory,
: new DefaultHlsPlaylistParserFactory(); "HlsMediaSource.Factory#setPlaylistParserFactory no longer handles null by"
+ " instantiating a new DefaultHlsPlaylistParserFactory. Explicitly"
+ " construct and pass an instance in order to retain the old behavior.");
return this; return this;
} }
/** /**
* Sets the {@link HlsPlaylistTracker} factory. The default value is {@link * Sets the {@link HlsPlaylistTracker} factory.
* DefaultHlsPlaylistTracker#FACTORY}.
* *
* @param playlistTrackerFactory A factory for {@link HlsPlaylistTracker} instances. * @param playlistTrackerFactory A factory for {@link HlsPlaylistTracker} instances.
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
public Factory setPlaylistTrackerFactory( public Factory setPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory) {
@Nullable HlsPlaylistTracker.Factory playlistTrackerFactory) {
this.playlistTrackerFactory = this.playlistTrackerFactory =
playlistTrackerFactory != null checkNotNull(
? playlistTrackerFactory playlistTrackerFactory,
: DefaultHlsPlaylistTracker.FACTORY; "HlsMediaSource.Factory#setPlaylistTrackerFactory no longer handles null by"
+ " defaulting to DefaultHlsPlaylistTracker.FACTORY. Explicitly"
+ " pass a reference to this instance in order to retain the old behavior.");
return this; return this;
} }
/** /**
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source * Sets the factory to create composite {@link SequenceableLoader}s for when this media source
* loads data from multiple streams (video, audio etc...). The default is an instance of {@link * loads data from multiple streams (video, audio etc...).
* DefaultCompositeSequenceableLoaderFactory}.
* *
* @param compositeSequenceableLoaderFactory A factory to create composite {@link * @param compositeSequenceableLoaderFactory A factory to create composite {@link
* SequenceableLoader}s for when this media source loads data from multiple streams (video, * SequenceableLoader}s for when this media source loads data from multiple streams (video,
...@@ -229,11 +228,13 @@ public final class HlsMediaSource extends BaseMediaSource ...@@ -229,11 +228,13 @@ public final class HlsMediaSource extends BaseMediaSource
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
public Factory setCompositeSequenceableLoaderFactory( public Factory setCompositeSequenceableLoaderFactory(
@Nullable CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory = this.compositeSequenceableLoaderFactory =
compositeSequenceableLoaderFactory != null checkNotNull(
? compositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
: new DefaultCompositeSequenceableLoaderFactory(); "HlsMediaSource.Factory#setCompositeSequenceableLoaderFactory no longer handles null"
+ " by instantiating a new DefaultCompositeSequenceableLoaderFactory. Explicitly"
+ " construct and pass an instance in order to retain the old behavior.");
return this; return this;
} }
......
...@@ -173,8 +173,7 @@ public final class SsMediaSource extends BaseMediaSource ...@@ -173,8 +173,7 @@ public final class SsMediaSource extends BaseMediaSource
/** /**
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source * Sets the factory to create composite {@link SequenceableLoader}s for when this media source
* loads data from multiple streams (video, audio etc.). The default is an instance of {@link * loads data from multiple streams (video, audio etc.).
* DefaultCompositeSequenceableLoaderFactory}.
* *
* @param compositeSequenceableLoaderFactory A factory to create composite {@link * @param compositeSequenceableLoaderFactory A factory to create composite {@link
* SequenceableLoader}s for when this media source loads data from multiple streams (video, * SequenceableLoader}s for when this media source loads data from multiple streams (video,
...@@ -182,11 +181,13 @@ public final class SsMediaSource extends BaseMediaSource ...@@ -182,11 +181,13 @@ public final class SsMediaSource extends BaseMediaSource
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
public Factory setCompositeSequenceableLoaderFactory( public Factory setCompositeSequenceableLoaderFactory(
@Nullable CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory = this.compositeSequenceableLoaderFactory =
compositeSequenceableLoaderFactory != null checkNotNull(
? compositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
: new DefaultCompositeSequenceableLoaderFactory(); "SsMediaSource.Factory#setCompositeSequenceableLoaderFactory no longer handles null"
+ " by instantiating a new DefaultCompositeSequenceableLoaderFactory. Explicitly"
+ " construct and pass an instance in order to retain the old behavior.");
return this; return this;
} }
......
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