diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 9a19edf804..d0aa4d58af 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -44,7 +44,7 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitia import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.offline.DownloadRequest; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.ui.StyledPlayerControlView; @@ -261,7 +261,7 @@ public class PlayerActivity extends AppCompatActivity intent.getBooleanExtra(IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA, false); RenderersFactory renderersFactory = DemoUtil.buildRenderersFactory(/* context= */ this, preferExtensionDecoders); - MediaSourceFactory mediaSourceFactory = + MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(dataSourceFactory) .setAdsLoaderProvider(this::getAdsLoader) .setAdViewProvider(playerView); diff --git a/docs/ad-insertion.md b/docs/ad-insertion.md index 090d0e49d9..142de570a4 100644 --- a/docs/ad-insertion.md +++ b/docs/ad-insertion.md @@ -49,7 +49,7 @@ build and inject a `DefaultMediaSourceFactory` configured with an `AdsLoader.Provider` and an `AdViewProvider` when creating the player: ~~~ -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(context) .setAdsLoaderProvider(adsLoaderProvider) .setAdViewProvider(playerView); diff --git a/docs/customization.md b/docs/customization.md index 6be6d39e77..5ac250ce72 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -14,10 +14,10 @@ Components common to all `ExoPlayer` implementations are: * `MediaSource` instances that define media to be played, load the media, and from which the loaded media can be read. `MediaSource` instances are created - from `MediaItem`s by a `MediaSourceFactory` inside the player. They can also + from `MediaItem`s by a `MediaSource.Factory` inside the player. They can also be passed directly to the player using the [media source based playlist API]. -* A `MediaSourceFactory` that converts `MediaItem`s to `MediaSource`s. The - `MediaSourceFactory` is injected when the player is created. +* A `MediaSource.Factory` that converts `MediaItem`s to `MediaSource`s. The + `MediaSource.Factory` is injected when the player is created. * `Renderer`s that render individual components of the media. `Renderer`s are injected when the player is created. * A `TrackSelector` that selects tracks provided by the `MediaSource` to be @@ -245,9 +245,9 @@ required. Some use cases for custom implementations are: appropriate if you wish to obtain media samples to feed to renderers in a custom way, or if you wish to implement custom `MediaSource` compositing behavior. -* `MediaSourceFactory` – Implementing a custom `MediaSourceFactory` allows - an application to customize the way in which `MediaSource`s are created from - `MediaItem`s. +* `MediaSource.Factory` – Implementing a custom `MediaSource.Factory` + allows an application to customize the way in which `MediaSource`s are created + from `MediaItem`s. * `DataSource` – ExoPlayer’s upstream package already contains a number of `DataSource` implementations for different use cases. You may want to implement you own `DataSource` class to load data in another way, such as over diff --git a/docs/drm.md b/docs/drm.md index 4b64640989..0ab2118e99 100644 --- a/docs/drm.md +++ b/docs/drm.md @@ -85,7 +85,7 @@ building the media item. If an app wants to customise the `DrmSessionManager` used for playback, they can implement a `DrmSessionManagerProvider` and pass this to the -`MediaSourceFactory` which is [used when building the player]. The provider can +`MediaSource.Factory` which is [used when building the player]. The provider can choose whether to instantiate a new manager instance each time or not. To always use the same instance: @@ -93,7 +93,7 @@ use the same instance: DrmSessionManager customDrmSessionManager = new CustomDrmSessionManager(/* ... */); // Pass a drm session manager provider to the media source factory. -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(dataSourceFactory) .setDrmSessionManagerProvider(mediaItem -> customDrmSessionManager); ~~~ diff --git a/docs/media-items.md b/docs/media-items.md index f1c342c2a5..f57b3b9392 100644 --- a/docs/media-items.md +++ b/docs/media-items.md @@ -4,7 +4,7 @@ title: Media items The [playlist API][] is based on `MediaItem`s, which can be conveniently built using `MediaItem.Builder`. Inside the player, media items are converted into -playable `MediaSource`s by a `MediaSourceFactory`. Without +playable `MediaSource`s by a `MediaSource.Factory`. Without [custom configuration]({{ site.baseurl }}/media-sources.html#customizing-media-source-creation), this conversion is carried out by a `DefaultMediaSourceFactory`, which is capable of building complex media sources corresponding to the properties of the diff --git a/docs/media-sources.md b/docs/media-sources.md index 7cfde4af3b..15435baf74 100644 --- a/docs/media-sources.md +++ b/docs/media-sources.md @@ -6,7 +6,7 @@ redirect_from: In ExoPlayer every piece of media is represented by a `MediaItem`. However internally, the player needs `MediaSource` instances to play the content. The -player creates these from media items using a `MediaSourceFactory`. +player creates these from media items using a `MediaSource.Factory`. By default the player uses a `DefaultMediaSourceFactory`, which can create instances of the following content `MediaSource` implementations: @@ -27,13 +27,13 @@ customization. ## Customizing media source creation ## -When building the player, a `MediaSourceFactory` can be injected. For example, if -an app wants to insert ads and use a `CacheDataSource.Factory` to support +When building the player, a `MediaSource.Factory` can be injected. For example, +if an app wants to insert ads and use a `CacheDataSource.Factory` to support caching, an instance of `DefaultMediaSourceFactory` can be configured to match these requirements and injected during player construction: ~~~ -MediaSourceFactory mediaSourceFactory = +MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(cacheDataSourceFactory) .setAdsLoaderProvider(adsLoaderProvider) .setAdViewProvider(playerView); @@ -47,7 +47,7 @@ The [`DefaultMediaSourceFactory` JavaDoc]({{ site.baseurl }}/doc/reference/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.html) describes the available options in more detail. -It's also possible to inject a custom `MediaSourceFactory` implementation, for +It's also possible to inject a custom `MediaSource.Factory` implementation, for example to support creation of a custom media source type. The factory's `createMediaSource(MediaItem)` will be called to create a media source for each media item that is @@ -57,7 +57,7 @@ media item that is The [`ExoPlayer`] interface defines additional playlist methods that accept media sources rather than media items. This makes it possible to bypass the -player's internal `MediaSourceFactory` and pass media source instances to the +player's internal `MediaSource.Factory` and pass media source instances to the player directly: ~~~ diff --git a/docs/shrinking.md b/docs/shrinking.md index 7c97c9ea29..f8eb4ffbf6 100644 --- a/docs/shrinking.md +++ b/docs/shrinking.md @@ -106,9 +106,9 @@ ExoPlayer player = ## Custom `MediaSource` instantiation ## -If your app is using a custom `MediaSourceFactory` and you want +If your app is using a custom `MediaSource.Factory` and you want `DefaultMediaSourceFactory` to be removed by code stripping, you should pass -your `MediaSourceFactory` directly to the `ExoPlayer.Builder` constructor. +your `MediaSource.Factory` directly to the `ExoPlayer.Builder` constructor. ~~~ ExoPlayer player = @@ -117,13 +117,13 @@ ExoPlayer player = {: .language-java} If your app is using `MediaSource`s directly instead of `MediaItem`s you should -pass `MediaSourceFactory.UNSUPPORTED` to the `ExoPlayer.Builder` constructor, to -ensure `DefaultMediaSourceFactory` and `DefaultExtractorsFactory` can be +pass `MediaSource.Factory.UNSUPPORTED` to the `ExoPlayer.Builder` constructor, +to ensure `DefaultMediaSourceFactory` and `DefaultExtractorsFactory` can be stripped by code shrinking. ~~~ ExoPlayer player = - new ExoPlayer.Builder(context, MediaSourceFactory.UNSUPPORTED).build(); + new ExoPlayer.Builder(context, MediaSource.Factory.UNSUPPORTED).build(); ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory( dataSourceFactory, customExtractorsFactory) diff --git a/docs/transforming-media.md b/docs/transforming-media.md index db0e893839..a3c112f77a 100644 --- a/docs/transforming-media.md +++ b/docs/transforming-media.md @@ -41,7 +41,7 @@ transformer.startTransformation(inputMediaItem, outputPath); ~~~ {: .language-java} -Other parameters, such as the `MediaSourceFactory`, can be passed to the +Other parameters, such as the `MediaSource.Factory`, can be passed to the builder. `startTransformation` receives a `MediaItem` describing the input, and a path or diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index fa1ac96881..f9564154ca 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -46,7 +46,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Timeline; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsMediaSource; import com.google.android.exoplayer2.ui.AdViewProvider; @@ -222,7 +222,7 @@ public final class ImaAdsLoader implements AdsLoader { /** * Sets the MIME types to prioritize for linear ad media. If not specified, MIME types supported - * by the {@link MediaSourceFactory adMediaSourceFactory} used to construct the {@link + * by the {@link MediaSource.Factory adMediaSourceFactory} used to construct the {@link * AdsMediaSource} will be used. * * @param adMediaMimeTypes The MIME types to prioritize for linear ad media. May contain {@link diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java index e6ff11dfd9..53b196fbb9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java @@ -43,7 +43,6 @@ import com.google.android.exoplayer2.extractor.ExtractorsFactory; import com.google.android.exoplayer2.metadata.MetadataRenderer; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.source.ShuffleOrder; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.TextRenderer; @@ -77,7 +76,7 @@ import java.util.List; *
Use {@link #Builder(Context, RenderersFactory)}, {@link #Builder(Context, - * MediaSourceFactory)} or {@link #Builder(Context, RenderersFactory, MediaSourceFactory)} + * MediaSource.Factory)} or {@link #Builder(Context, RenderersFactory, MediaSource.Factory)} * instead, if you intend to provide a custom {@link RenderersFactory}, {@link * ExtractorsFactory} or {@link DefaultMediaSourceFactory}. This is to ensure that ProGuard or * R8 can remove ExoPlayer's {@link DefaultRenderersFactory}, {@link DefaultExtractorsFactory} @@ -407,7 +406,7 @@ public interface ExoPlayer extends Player { *
See {@link #Builder(Context)} for a list of default values. * @@ -474,12 +473,12 @@ public interface ExoPlayer extends Player { * @param mediaSourceFactory A factory for creating a {@link MediaSource} from a {@link * MediaItem}. */ - public Builder(Context context, MediaSourceFactory mediaSourceFactory) { + public Builder(Context context, MediaSource.Factory mediaSourceFactory) { this(context, () -> new DefaultRenderersFactory(context), () -> mediaSourceFactory); } /** - * Creates a builder with a custom {@link RenderersFactory} and {@link MediaSourceFactory}. + * Creates a builder with a custom {@link RenderersFactory} and {@link MediaSource.Factory}. * *
See {@link #Builder(Context)} for a list of default values.
*
@@ -494,7 +493,9 @@ public interface ExoPlayer extends Player {
* MediaItem}.
*/
public Builder(
- Context context, RenderersFactory renderersFactory, MediaSourceFactory mediaSourceFactory) {
+ Context context,
+ RenderersFactory renderersFactory,
+ MediaSource.Factory mediaSourceFactory) {
this(context, () -> renderersFactory, () -> mediaSourceFactory);
}
@@ -507,7 +508,7 @@ public interface ExoPlayer extends Player {
* @param context A {@link Context}.
* @param renderersFactory A factory for creating {@link Renderer Renderers} to be used by the
* player.
- * @param mediaSourceFactory A {@link MediaSourceFactory}.
+ * @param mediaSourceFactory A {@link MediaSource.Factory}.
* @param trackSelector A {@link TrackSelector}.
* @param loadControl A {@link LoadControl}.
* @param bandwidthMeter A {@link BandwidthMeter}.
@@ -516,7 +517,7 @@ public interface ExoPlayer extends Player {
public Builder(
Context context,
RenderersFactory renderersFactory,
- MediaSourceFactory mediaSourceFactory,
+ MediaSource.Factory mediaSourceFactory,
TrackSelector trackSelector,
LoadControl loadControl,
BandwidthMeter bandwidthMeter,
@@ -534,7 +535,7 @@ public interface ExoPlayer extends Player {
private Builder(
Context context,
Supplier This is equivalent to using {@link #retrieveMetadata(MediaSourceFactory, MediaItem)} with a
+ * This is equivalent to using {@link #retrieveMetadata(MediaSource.Factory, MediaItem)} with a
* {@link DefaultMediaSourceFactory} and a {@link DefaultExtractorsFactory} with {@link
* Mp4Extractor#FLAG_READ_MOTION_PHOTO_METADATA} and {@link Mp4Extractor#FLAG_READ_SEF_DATA} set.
*
@@ -67,13 +66,13 @@ public final class MetadataRetriever {
*
* This method is thread-safe.
*
- * @param mediaSourceFactory mediaSourceFactory The {@link MediaSourceFactory} to use to read the
+ * @param mediaSourceFactory mediaSourceFactory The {@link MediaSource.Factory} to use to read the
* data.
* @param mediaItem The {@link MediaItem} whose metadata should be retrieved.
* @return A {@link ListenableFuture} of the result.
*/
public static ListenableFuture This implementation delegates calls to {@link #createMediaSource(MediaItem)} to the following
* factories:
@@ -92,6 +92,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
* configuration}, {@link #setAdsLoaderProvider} and {@link #setAdViewProvider} need to be called to
* configure the factory with the required providers.
*/
+@SuppressWarnings("deprecation") // Implement deprecated type for backwards compatibility.
public final class DefaultMediaSourceFactory implements MediaSourceFactory {
/** @deprecated Use {@link AdsLoader.Provider} instead. */
@@ -103,7 +104,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
private final DataSource.Factory dataSourceFactory;
private final DelegateFactoryLoader delegateFactoryLoader;
- @Nullable private final MediaSourceFactory serverSideDaiMediaSourceFactory;
+ @Nullable private final MediaSource.Factory serverSideDaiMediaSourceFactory;
@Nullable private AdsLoader.Provider adsLoaderProvider;
@Nullable private AdViewProvider adViewProvider;
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
@@ -157,13 +158,13 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* for requesting media data.
* @param extractorsFactory An {@link ExtractorsFactory} used to extract progressive media from
* its container.
- * @param serverSideDaiMediaSourceFactory A {@link MediaSourceFactory} for creating server side
+ * @param serverSideDaiMediaSourceFactory A {@link MediaSource.Factory} for creating server side
* inserted ad media sources.
*/
public DefaultMediaSourceFactory(
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
- @Nullable MediaSourceFactory serverSideDaiMediaSourceFactory) {
+ @Nullable MediaSource.Factory serverSideDaiMediaSourceFactory) {
this.dataSourceFactory = dataSourceFactory;
// Temporary until factory registration is agreed upon.
this.serverSideDaiMediaSourceFactory = serverSideDaiMediaSourceFactory;
@@ -309,7 +310,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
Util.inferContentTypeForUriAndMimeType(
mediaItem.localConfiguration.uri, mediaItem.localConfiguration.mimeType);
@Nullable
- MediaSourceFactory mediaSourceFactory = delegateFactoryLoader.getMediaSourceFactory(type);
+ MediaSource.Factory mediaSourceFactory = delegateFactoryLoader.getMediaSourceFactory(type);
checkStateNotNull(
mediaSourceFactory, "No suitable media source factory found for content type: " + type);
@@ -435,10 +436,10 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
private static final class DelegateFactoryLoader {
private final DataSource.Factory dataSourceFactory;
private final ExtractorsFactory extractorsFactory;
- private final Map If not set, {@link DefaultDrmSessionManagerProvider} is used.
+ *
+ * @return This factory, for convenience.
+ */
+ Factory setDrmSessionManagerProvider(
+ @Nullable DrmSessionManagerProvider drmSessionManagerProvider);
+
+ /**
+ * Sets an optional {@link LoadErrorHandlingPolicy}.
+ *
+ * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}, or {@code null} to use the
+ * {@link DefaultLoadErrorHandlingPolicy}.
+ * @return This factory, for convenience.
+ */
+ Factory setLoadErrorHandlingPolicy(@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy);
+
+ /**
+ * Returns the {@link C.ContentType content types} supported by media sources created by this
+ * factory.
+ */
+ @C.ContentType
+ int[] getSupportedTypes();
+
+ /**
+ * Creates a new {@link MediaSource} with the specified {@link MediaItem}.
+ *
+ * @param mediaItem The media item to play.
+ * @return The new {@link MediaSource media source}.
+ */
+ MediaSource createMediaSource(MediaItem mediaItem);
+ }
+
/** A caller of media sources, which will be notified of source events. */
interface MediaSourceCaller {
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
index 54d9eb2658..04e7712608 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
@@ -18,14 +18,12 @@ package com.google.android.exoplayer2.source;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem;
-import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
-import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
-import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
-/** Factory for creating {@link MediaSource MediaSources} from {@link MediaItem MediaItems}. */
-public interface MediaSourceFactory {
+/** @deprecated Use {@link MediaSource.Factory}. */
+@Deprecated
+public interface MediaSourceFactory extends MediaSource.Factory {
/**
* An instance that throws {@link UnsupportedOperationException} from {@link #createMediaSource}
@@ -56,40 +54,4 @@ public interface MediaSourceFactory {
throw new UnsupportedOperationException();
}
};
-
- /**
- * Sets the {@link DrmSessionManagerProvider} used to obtain a {@link DrmSessionManager} for a
- * {@link MediaItem}.
- *
- * If not set, {@link DefaultDrmSessionManagerProvider} is used.
- *
- * @return This factory, for convenience.
- */
- MediaSourceFactory setDrmSessionManagerProvider(
- @Nullable DrmSessionManagerProvider drmSessionManagerProvider);
-
- /**
- * Sets an optional {@link LoadErrorHandlingPolicy}.
- *
- * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}, or {@code null} to use the
- * {@link DefaultLoadErrorHandlingPolicy}.
- * @return This factory, for convenience.
- */
- MediaSourceFactory setLoadErrorHandlingPolicy(
- @Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy);
-
- /**
- * Returns the {@link C.ContentType content types} supported by media sources created by this
- * factory.
- */
- @C.ContentType
- int[] getSupportedTypes();
-
- /**
- * Creates a new {@link MediaSource} with the specified {@link MediaItem}.
- *
- * @param mediaItem The media item to play.
- * @return The new {@link MediaSource media source}.
- */
- MediaSource createMediaSource(MediaItem mediaItem);
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
index 53b2c90108..cf17a0bdb4 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
@@ -50,6 +50,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
implements ProgressiveMediaPeriod.Listener {
/** Factory for {@link ProgressiveMediaSource}s. */
+ @SuppressWarnings("deprecation") // Implement deprecated type for backwards compatibility.
public static final class Factory implements MediaSourceFactory {
private final DataSource.Factory dataSourceFactory;
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java
index 09208060a1..4667cbea05 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/AdsMediaSource.java
@@ -35,7 +35,6 @@ import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
-import com.google.android.exoplayer2.source.MediaSourceFactory;
import com.google.android.exoplayer2.ui.AdViewProvider;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSpec;
@@ -127,7 +126,7 @@ public final class AdsMediaSource extends CompositeMediaSource
If specifying a {@link MediaSourceFactory} using {@link - * Transformer.Builder#setMediaSourceFactory(MediaSourceFactory)}, make sure that {@link + *
If specifying a {@link MediaSource.Factory} using {@link + * Transformer.Builder#setMediaSourceFactory(MediaSource.Factory)}, make sure that {@link * Mp4Extractor#FLAG_READ_SEF_DATA} is set on the {@link Mp4Extractor} used. Otherwise, the slow * motion metadata will be ignored and the input won't be flattened. * diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java index 636a137d52..fc4a96957b 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java @@ -51,7 +51,6 @@ import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor; import com.google.android.exoplayer2.metadata.MetadataOutput; import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.MediaSourceFactory; import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.util.Clock; @@ -93,7 +92,7 @@ public final class Transformer { private @MonotonicNonNull Context context; // Optional fields. - private @MonotonicNonNull MediaSourceFactory mediaSourceFactory; + private MediaSource.@MonotonicNonNull Factory mediaSourceFactory; private Muxer.Factory muxerFactory; private boolean removeAudio; private boolean removeVideo; @@ -171,14 +170,14 @@ public final class Transformer { } /** - * Sets the {@link MediaSourceFactory} to be used to retrieve the inputs to transform. The + * Sets the {@link MediaSource.Factory} to be used to retrieve the inputs to transform. The * default value is a {@link DefaultMediaSourceFactory} built with the context provided in * {@link #Builder(Context) the constructor}. * - * @param mediaSourceFactory A {@link MediaSourceFactory}. + * @param mediaSourceFactory A {@link MediaSource.Factory}. * @return This builder. */ - public Builder setMediaSourceFactory(MediaSourceFactory mediaSourceFactory) { + public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; } @@ -471,7 +470,7 @@ public final class Transformer { public static final int PROGRESS_STATE_NO_TRANSFORMATION = 4; private final Context context; - private final MediaSourceFactory mediaSourceFactory; + private final MediaSource.Factory mediaSourceFactory; private final Muxer.Factory muxerFactory; private final boolean removeAudio; private final boolean removeVideo; @@ -490,7 +489,7 @@ public final class Transformer { private Transformer( Context context, - MediaSourceFactory mediaSourceFactory, + MediaSource.Factory mediaSourceFactory, Muxer.Factory muxerFactory, boolean removeAudio, boolean removeVideo, diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java index 53a0f7eeba..42b2da9fd1 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java @@ -27,6 +27,8 @@ import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.util.Util; /** Fake {@link MediaSourceFactory} that creates a {@link FakeMediaSource}. */ +// Implement and return deprecated type for backwards compatibility. +@SuppressWarnings("deprecation") public final class FakeMediaSourceFactory implements MediaSourceFactory { /** The window UID used by media sources that are created by the factory. */ diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java index 9a668f0186..b607c52723 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestExoPlayerBuilder.java @@ -27,7 +27,7 @@ import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.analytics.AnalyticsCollector; -import com.google.android.exoplayer2.source.MediaSourceFactory; +import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; @@ -46,7 +46,7 @@ public class TestExoPlayerBuilder { private BandwidthMeter bandwidthMeter; @Nullable private Renderer[] renderers; @Nullable private RenderersFactory renderersFactory; - @Nullable private MediaSourceFactory mediaSourceFactory; + @Nullable private MediaSource.Factory mediaSourceFactory; private boolean useLazyPreparation; private @MonotonicNonNull Looper looper; private long seekBackIncrementMs; @@ -222,21 +222,21 @@ public class TestExoPlayerBuilder { } /** - * Returns the {@link MediaSourceFactory} that will be used by the player, or null if no {@link - * MediaSourceFactory} has been set yet and no default is available. + * Returns the {@link MediaSource.Factory} that will be used by the player, or null if no {@link + * MediaSource.Factory} has been set yet and no default is available. */ @Nullable - public MediaSourceFactory getMediaSourceFactory() { + public MediaSource.Factory getMediaSourceFactory() { return mediaSourceFactory; } /** - * Sets the {@link MediaSourceFactory} to be used by the player. + * Sets the {@link MediaSource.Factory} to be used by the player. * - * @param mediaSourceFactory The {@link MediaSourceFactory} to be used by the player. + * @param mediaSourceFactory The {@link MediaSource.Factory} to be used by the player. * @return This builder. */ - public TestExoPlayerBuilder setMediaSourceFactory(MediaSourceFactory mediaSourceFactory) { + public TestExoPlayerBuilder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; }