Move setMediaSourceFactory to ExoPlayerAssetLoader
The MediaSourceFactory won't be used by the other AssetLoaders In order to do that, ExoPlayerAssetLoader has been made public, and the DefaultAssetLoaderFactory has become a wrapper around ExoPlayerAssetLoader. PiperOrigin-RevId: 496386853
This commit is contained in:
parent
ce766d7622
commit
cd70a5cef5
@ -20,7 +20,6 @@ import android.content.Context;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
|
||||||
@ -34,10 +33,15 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|||||||
*/
|
*/
|
||||||
public interface AssetLoader {
|
public interface AssetLoader {
|
||||||
|
|
||||||
/** A factory for {@link AssetLoader} instances. */
|
/**
|
||||||
|
* A factory for {@link AssetLoader} instances.
|
||||||
|
*
|
||||||
|
* <p>The setters in this interface will be called with the values used to build and start the
|
||||||
|
* {@link Transformer}.
|
||||||
|
*/
|
||||||
interface Factory {
|
interface Factory {
|
||||||
|
|
||||||
/** Sets the context. */
|
/** Sets the {@link Context}. */
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
Factory setContext(Context context);
|
Factory setContext(Context context);
|
||||||
|
|
||||||
@ -76,10 +80,6 @@ public interface AssetLoader {
|
|||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
Factory setFlattenVideoForSlowMotion(boolean flattenVideoForSlowMotion);
|
Factory setFlattenVideoForSlowMotion(boolean flattenVideoForSlowMotion);
|
||||||
|
|
||||||
/** Sets the {@link MediaSource.Factory} to be used to retrieve the samples. */
|
|
||||||
@CanIgnoreReturnValue
|
|
||||||
Factory setMediaSourceFactory(MediaSource.Factory mediaSourceFactory);
|
|
||||||
|
|
||||||
/** Sets the {@link Codec.DecoderFactory} to be used to decode the samples (if necessary). */
|
/** Sets the {@link Codec.DecoderFactory} to be used to decode the samples (if necessary). */
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
Factory setDecoderFactory(Codec.DecoderFactory decoderFactory);
|
Factory setDecoderFactory(Codec.DecoderFactory decoderFactory);
|
||||||
@ -111,7 +111,7 @@ public interface AssetLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A listener of asset loader events.
|
* A listener of {@link AssetLoader} events.
|
||||||
*
|
*
|
||||||
* <p>This listener is typically used in the following way:
|
* <p>This listener is typically used in the following way:
|
||||||
*
|
*
|
||||||
|
@ -16,112 +16,79 @@
|
|||||||
|
|
||||||
package com.google.android.exoplayer2.transformer;
|
package com.google.android.exoplayer2.transformer;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
|
||||||
/** The default {@link AssetLoader.Factory} implementation. */
|
/** The default {@link AssetLoader.Factory} implementation. */
|
||||||
public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
|
public final class DefaultAssetLoaderFactory implements AssetLoader.Factory {
|
||||||
|
|
||||||
@Nullable private Context context;
|
private final AssetLoader.Factory assetLoaderFactory;
|
||||||
@Nullable private MediaItem mediaItem;
|
|
||||||
private boolean removeAudio;
|
/** Creates an instance. */
|
||||||
private boolean removeVideo;
|
public DefaultAssetLoaderFactory() {
|
||||||
private boolean flattenVideoForSlowMotion;
|
assetLoaderFactory = new ExoPlayerAssetLoader.Factory();
|
||||||
@Nullable private MediaSource.Factory mediaSourceFactory;
|
}
|
||||||
@Nullable private Codec.DecoderFactory decoderFactory;
|
|
||||||
@Nullable private Looper looper;
|
|
||||||
@Nullable private AssetLoader.Listener listener;
|
|
||||||
@Nullable private Clock clock;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setContext(Context context) {
|
public AssetLoader.Factory setContext(Context context) {
|
||||||
this.context = context;
|
return assetLoaderFactory.setContext(context);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setMediaItem(MediaItem mediaItem) {
|
public AssetLoader.Factory setMediaItem(MediaItem mediaItem) {
|
||||||
this.mediaItem = mediaItem;
|
return assetLoaderFactory.setMediaItem(mediaItem);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setRemoveAudio(boolean removeAudio) {
|
public AssetLoader.Factory setRemoveAudio(boolean removeAudio) {
|
||||||
this.removeAudio = removeAudio;
|
return assetLoaderFactory.setRemoveAudio(removeAudio);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setRemoveVideo(boolean removeVideo) {
|
public AssetLoader.Factory setRemoveVideo(boolean removeVideo) {
|
||||||
this.removeVideo = removeVideo;
|
return assetLoaderFactory.setRemoveVideo(removeVideo);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setFlattenVideoForSlowMotion(boolean flattenVideoForSlowMotion) {
|
public AssetLoader.Factory setFlattenVideoForSlowMotion(boolean flattenVideoForSlowMotion) {
|
||||||
this.flattenVideoForSlowMotion = flattenVideoForSlowMotion;
|
assetLoaderFactory.setFlattenVideoForSlowMotion(flattenVideoForSlowMotion);
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@CanIgnoreReturnValue
|
|
||||||
public AssetLoader.Factory setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) {
|
|
||||||
this.mediaSourceFactory = mediaSourceFactory;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setDecoderFactory(Codec.DecoderFactory decoderFactory) {
|
public AssetLoader.Factory setDecoderFactory(Codec.DecoderFactory decoderFactory) {
|
||||||
this.decoderFactory = decoderFactory;
|
return assetLoaderFactory.setDecoderFactory(decoderFactory);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setLooper(Looper looper) {
|
public AssetLoader.Factory setLooper(Looper looper) {
|
||||||
this.looper = looper;
|
return assetLoaderFactory.setLooper(looper);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setListener(AssetLoader.Listener listener) {
|
public AssetLoader.Factory setListener(AssetLoader.Listener listener) {
|
||||||
this.listener = listener;
|
return assetLoaderFactory.setListener(listener);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public AssetLoader.Factory setClock(Clock clock) {
|
public AssetLoader.Factory setClock(Clock clock) {
|
||||||
this.clock = clock;
|
return assetLoaderFactory.setClock(clock);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AssetLoader createAssetLoader() {
|
public AssetLoader createAssetLoader() {
|
||||||
return new ExoPlayerAssetLoader(
|
return assetLoaderFactory.createAssetLoader();
|
||||||
checkStateNotNull(context),
|
|
||||||
checkStateNotNull(mediaItem),
|
|
||||||
removeAudio,
|
|
||||||
removeVideo,
|
|
||||||
flattenVideoForSlowMotion,
|
|
||||||
checkStateNotNull(mediaSourceFactory),
|
|
||||||
checkStateNotNull(decoderFactory),
|
|
||||||
checkStateNotNull(looper),
|
|
||||||
checkStateNotNull(listener),
|
|
||||||
checkStateNotNull(clock));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,13 @@ import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STA
|
|||||||
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION;
|
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION;
|
||||||
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_UNAVAILABLE;
|
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_UNAVAILABLE;
|
||||||
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_WAITING_FOR_AVAILABILITY;
|
import static com.google.android.exoplayer2.transformer.Transformer.PROGRESS_STATE_WAITING_FOR_AVAILABILITY;
|
||||||
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
@ -40,21 +42,146 @@ import com.google.android.exoplayer2.RenderersFactory;
|
|||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
|
import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
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.MediaSource;
|
||||||
import com.google.android.exoplayer2.text.TextOutput;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
||||||
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
|
||||||
/* package */ final class ExoPlayerAssetLoader implements AssetLoader {
|
/** An {@link AssetLoader} implementation that uses an {@link ExoPlayer} to load samples. */
|
||||||
|
public final class ExoPlayerAssetLoader implements AssetLoader {
|
||||||
|
|
||||||
|
/** An {@link AssetLoader.Factory} for {@link ExoPlayerAssetLoader} instances. */
|
||||||
|
public static final class Factory implements AssetLoader.Factory {
|
||||||
|
|
||||||
|
@Nullable private Context context;
|
||||||
|
@Nullable private MediaItem mediaItem;
|
||||||
|
private boolean removeAudio;
|
||||||
|
private boolean removeVideo;
|
||||||
|
private boolean flattenVideoForSlowMotion;
|
||||||
|
@Nullable private MediaSource.Factory mediaSourceFactory;
|
||||||
|
@Nullable private Codec.DecoderFactory decoderFactory;
|
||||||
|
@Nullable private Looper looper;
|
||||||
|
@Nullable private AssetLoader.Listener listener;
|
||||||
|
@Nullable private Clock clock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance.
|
||||||
|
*
|
||||||
|
* <p>The {@link ExoPlayerAssetLoader} instances produced use a {@link
|
||||||
|
* DefaultMediaSourceFactory} built with the context provided in {@linkplain
|
||||||
|
* #setContext(Context)}.
|
||||||
|
*/
|
||||||
|
public Factory() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance.
|
||||||
|
*
|
||||||
|
* @param mediaSourceFactory The {@link MediaSource.Factory} to be used to retrieve the samples
|
||||||
|
* to transform.
|
||||||
|
*/
|
||||||
|
public Factory(MediaSource.Factory mediaSourceFactory) {
|
||||||
|
this.mediaSourceFactory = mediaSourceFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setContext(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setMediaItem(MediaItem mediaItem) {
|
||||||
|
this.mediaItem = mediaItem;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setRemoveAudio(boolean removeAudio) {
|
||||||
|
this.removeAudio = removeAudio;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setRemoveVideo(boolean removeVideo) {
|
||||||
|
this.removeVideo = removeVideo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setFlattenVideoForSlowMotion(boolean flattenVideoForSlowMotion) {
|
||||||
|
this.flattenVideoForSlowMotion = flattenVideoForSlowMotion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setDecoderFactory(Codec.DecoderFactory decoderFactory) {
|
||||||
|
this.decoderFactory = decoderFactory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setLooper(Looper looper) {
|
||||||
|
this.looper = looper;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setListener(AssetLoader.Listener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
public AssetLoader.Factory setClock(Clock clock) {
|
||||||
|
this.clock = clock;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AssetLoader createAssetLoader() {
|
||||||
|
Context context = checkStateNotNull(this.context);
|
||||||
|
if (mediaSourceFactory == null) {
|
||||||
|
DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory();
|
||||||
|
if (flattenVideoForSlowMotion) {
|
||||||
|
defaultExtractorsFactory.setMp4ExtractorFlags(Mp4Extractor.FLAG_READ_SEF_DATA);
|
||||||
|
}
|
||||||
|
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
|
||||||
|
}
|
||||||
|
return new ExoPlayerAssetLoader(
|
||||||
|
context,
|
||||||
|
checkStateNotNull(mediaItem),
|
||||||
|
removeAudio,
|
||||||
|
removeVideo,
|
||||||
|
flattenVideoForSlowMotion,
|
||||||
|
mediaSourceFactory,
|
||||||
|
checkStateNotNull(decoderFactory),
|
||||||
|
checkStateNotNull(looper),
|
||||||
|
checkStateNotNull(listener),
|
||||||
|
checkStateNotNull(clock));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final MediaItem mediaItem;
|
private final MediaItem mediaItem;
|
||||||
private final ExoPlayer player;
|
private final ExoPlayer player;
|
||||||
|
|
||||||
private @Transformer.ProgressState int progressState;
|
private @Transformer.ProgressState int progressState;
|
||||||
|
|
||||||
public ExoPlayerAssetLoader(
|
private ExoPlayerAssetLoader(
|
||||||
Context context,
|
Context context,
|
||||||
MediaItem mediaItem,
|
MediaItem mediaItem,
|
||||||
boolean removeAudio,
|
boolean removeAudio,
|
||||||
|
@ -140,10 +140,10 @@ public final class TransformationRequest {
|
|||||||
* <li>The recording frame rate of the video is 120 or 240 fps.
|
* <li>The recording frame rate of the video is 120 or 240 fps.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>If specifying a {@link MediaSource.Factory} using {@link
|
* <p>If using an {@link ExoPlayerAssetLoader.Factory} with a provided {@link
|
||||||
* Transformer.Builder#setMediaSourceFactory(MediaSource.Factory)}, make sure that {@link
|
* MediaSource.Factory}, make sure that {@link Mp4Extractor#FLAG_READ_SEF_DATA} is set on the
|
||||||
* Mp4Extractor#FLAG_READ_SEF_DATA} is set on the {@link Mp4Extractor} used. Otherwise, the slow
|
* {@link Mp4Extractor} used. Otherwise, the slow motion metadata will be ignored and the input
|
||||||
* motion metadata will be ignored and the input won't be flattened.
|
* won't be flattened.
|
||||||
*
|
*
|
||||||
* <p>Using slow motion flattening together with {@link
|
* <p>Using slow motion flattening together with {@link
|
||||||
* com.google.android.exoplayer2.MediaItem.ClippingConfiguration} is not supported yet.
|
* com.google.android.exoplayer2.MediaItem.ClippingConfiguration} is not supported yet.
|
||||||
|
@ -34,9 +34,6 @@ import com.google.android.exoplayer2.audio.SonicAudioProcessor;
|
|||||||
import com.google.android.exoplayer2.effect.GlEffect;
|
import com.google.android.exoplayer2.effect.GlEffect;
|
||||||
import com.google.android.exoplayer2.effect.GlEffectsFrameProcessor;
|
import com.google.android.exoplayer2.effect.GlEffectsFrameProcessor;
|
||||||
import com.google.android.exoplayer2.effect.GlMatrixTransformation;
|
import com.google.android.exoplayer2.effect.GlMatrixTransformation;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
|
||||||
import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor;
|
|
||||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.util.DebugViewProvider;
|
import com.google.android.exoplayer2.util.DebugViewProvider;
|
||||||
@ -53,7 +50,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A transformer to transform media inputs.
|
* A transformer to transform media inputs.
|
||||||
@ -89,7 +85,6 @@ public final class Transformer {
|
|||||||
private boolean removeVideo;
|
private boolean removeVideo;
|
||||||
private boolean forceSilentAudio;
|
private boolean forceSilentAudio;
|
||||||
private ListenerSet<Transformer.Listener> listeners;
|
private ListenerSet<Transformer.Listener> listeners;
|
||||||
private MediaSource.@MonotonicNonNull Factory mediaSourceFactory;
|
|
||||||
private AssetLoader.Factory assetLoaderFactory;
|
private AssetLoader.Factory assetLoaderFactory;
|
||||||
private Codec.DecoderFactory decoderFactory;
|
private Codec.DecoderFactory decoderFactory;
|
||||||
private Codec.EncoderFactory encoderFactory;
|
private Codec.EncoderFactory encoderFactory;
|
||||||
@ -130,7 +125,6 @@ public final class Transformer {
|
|||||||
this.removeVideo = transformer.removeVideo;
|
this.removeVideo = transformer.removeVideo;
|
||||||
this.forceSilentAudio = transformer.forceSilentAudio;
|
this.forceSilentAudio = transformer.forceSilentAudio;
|
||||||
this.listeners = transformer.listeners;
|
this.listeners = transformer.listeners;
|
||||||
this.mediaSourceFactory = transformer.mediaSourceFactory;
|
|
||||||
this.assetLoaderFactory = transformer.assetLoaderFactory;
|
this.assetLoaderFactory = transformer.assetLoaderFactory;
|
||||||
this.decoderFactory = transformer.decoderFactory;
|
this.decoderFactory = transformer.decoderFactory;
|
||||||
this.encoderFactory = transformer.encoderFactory;
|
this.encoderFactory = transformer.encoderFactory;
|
||||||
@ -292,21 +286,6 @@ public final class Transformer {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the {@link MediaSource.Factory} to be used to retrieve the inputs to transform.
|
|
||||||
*
|
|
||||||
* <p>The default value is a {@link DefaultMediaSourceFactory} built with the context provided
|
|
||||||
* in {@linkplain #Builder(Context) the constructor}.
|
|
||||||
*
|
|
||||||
* @param mediaSourceFactory A {@link MediaSource.Factory}.
|
|
||||||
* @return This builder.
|
|
||||||
*/
|
|
||||||
@CanIgnoreReturnValue
|
|
||||||
public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) {
|
|
||||||
this.mediaSourceFactory = mediaSourceFactory;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link AssetLoader.Factory} to be used to retrieve the samples to transform.
|
* Sets the {@link AssetLoader.Factory} to be used to retrieve the samples to transform.
|
||||||
*
|
*
|
||||||
@ -476,13 +455,6 @@ public final class Transformer {
|
|||||||
if (transformationRequest.videoMimeType != null) {
|
if (transformationRequest.videoMimeType != null) {
|
||||||
checkSampleMimeType(transformationRequest.videoMimeType);
|
checkSampleMimeType(transformationRequest.videoMimeType);
|
||||||
}
|
}
|
||||||
if (mediaSourceFactory == null) {
|
|
||||||
DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory();
|
|
||||||
if (transformationRequest.flattenForSlowMotion) {
|
|
||||||
defaultExtractorsFactory.setMp4ExtractorFlags(Mp4Extractor.FLAG_READ_SEF_DATA);
|
|
||||||
}
|
|
||||||
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
|
|
||||||
}
|
|
||||||
return new Transformer(
|
return new Transformer(
|
||||||
context,
|
context,
|
||||||
transformationRequest,
|
transformationRequest,
|
||||||
@ -492,7 +464,6 @@ public final class Transformer {
|
|||||||
removeVideo,
|
removeVideo,
|
||||||
forceSilentAudio,
|
forceSilentAudio,
|
||||||
listeners,
|
listeners,
|
||||||
mediaSourceFactory,
|
|
||||||
assetLoaderFactory,
|
assetLoaderFactory,
|
||||||
decoderFactory,
|
decoderFactory,
|
||||||
encoderFactory,
|
encoderFactory,
|
||||||
@ -618,7 +589,6 @@ public final class Transformer {
|
|||||||
private final boolean removeVideo;
|
private final boolean removeVideo;
|
||||||
private final boolean forceSilentAudio;
|
private final boolean forceSilentAudio;
|
||||||
private final ListenerSet<Transformer.Listener> listeners;
|
private final ListenerSet<Transformer.Listener> listeners;
|
||||||
private final MediaSource.Factory mediaSourceFactory;
|
|
||||||
private final AssetLoader.Factory assetLoaderFactory;
|
private final AssetLoader.Factory assetLoaderFactory;
|
||||||
private final FrameProcessor.Factory frameProcessorFactory;
|
private final FrameProcessor.Factory frameProcessorFactory;
|
||||||
private final Muxer.Factory muxerFactory;
|
private final Muxer.Factory muxerFactory;
|
||||||
@ -637,7 +607,6 @@ public final class Transformer {
|
|||||||
boolean removeVideo,
|
boolean removeVideo,
|
||||||
boolean forceSilentAudio,
|
boolean forceSilentAudio,
|
||||||
ListenerSet<Listener> listeners,
|
ListenerSet<Listener> listeners,
|
||||||
MediaSource.Factory mediaSourceFactory,
|
|
||||||
AssetLoader.Factory assetLoaderFactory,
|
AssetLoader.Factory assetLoaderFactory,
|
||||||
Codec.DecoderFactory decoderFactory,
|
Codec.DecoderFactory decoderFactory,
|
||||||
Codec.EncoderFactory encoderFactory,
|
Codec.EncoderFactory encoderFactory,
|
||||||
@ -659,7 +628,6 @@ public final class Transformer {
|
|||||||
this.removeVideo = removeVideo;
|
this.removeVideo = removeVideo;
|
||||||
this.forceSilentAudio = forceSilentAudio;
|
this.forceSilentAudio = forceSilentAudio;
|
||||||
this.listeners = listeners;
|
this.listeners = listeners;
|
||||||
this.mediaSourceFactory = mediaSourceFactory;
|
|
||||||
this.assetLoaderFactory = assetLoaderFactory;
|
this.assetLoaderFactory = assetLoaderFactory;
|
||||||
this.decoderFactory = decoderFactory;
|
this.decoderFactory = decoderFactory;
|
||||||
this.encoderFactory = encoderFactory;
|
this.encoderFactory = encoderFactory;
|
||||||
@ -802,7 +770,6 @@ public final class Transformer {
|
|||||||
removeAudio,
|
removeAudio,
|
||||||
removeVideo,
|
removeVideo,
|
||||||
forceSilentAudio,
|
forceSilentAudio,
|
||||||
mediaSourceFactory,
|
|
||||||
assetLoaderFactory,
|
assetLoaderFactory,
|
||||||
decoderFactory,
|
decoderFactory,
|
||||||
encoderFactory,
|
encoderFactory,
|
||||||
|
@ -35,7 +35,6 @@ import com.google.android.exoplayer2.audio.AudioProcessor;
|
|||||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
|
import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.util.ConditionVariable;
|
import com.google.android.exoplayer2.util.ConditionVariable;
|
||||||
import com.google.android.exoplayer2.util.DebugViewProvider;
|
import com.google.android.exoplayer2.util.DebugViewProvider;
|
||||||
@ -126,7 +125,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
boolean removeAudio,
|
boolean removeAudio,
|
||||||
boolean removeVideo,
|
boolean removeVideo,
|
||||||
boolean forceSilentAudio,
|
boolean forceSilentAudio,
|
||||||
MediaSource.Factory mediaSourceFactory,
|
|
||||||
AssetLoader.Factory assetLoaderFactory,
|
AssetLoader.Factory assetLoaderFactory,
|
||||||
Codec.DecoderFactory decoderFactory,
|
Codec.DecoderFactory decoderFactory,
|
||||||
Codec.EncoderFactory encoderFactory,
|
Codec.EncoderFactory encoderFactory,
|
||||||
@ -158,7 +156,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
.setRemoveAudio(removeAudio)
|
.setRemoveAudio(removeAudio)
|
||||||
.setRemoveVideo(removeVideo)
|
.setRemoveVideo(removeVideo)
|
||||||
.setFlattenVideoForSlowMotion(transformationRequest.flattenForSlowMotion)
|
.setFlattenVideoForSlowMotion(transformationRequest.flattenForSlowMotion)
|
||||||
.setMediaSourceFactory(mediaSourceFactory)
|
|
||||||
.setDecoderFactory(this.decoderFactory)
|
.setDecoderFactory(this.decoderFactory)
|
||||||
.setLooper(internalLooper)
|
.setLooper(internalLooper)
|
||||||
.setListener(componentListener)
|
.setListener(componentListener)
|
||||||
|
@ -533,10 +533,11 @@ public final class TransformerEndToEndTest {
|
|||||||
MediaSource.Factory mediaSourceFactory =
|
MediaSource.Factory mediaSourceFactory =
|
||||||
new DefaultMediaSourceFactory(
|
new DefaultMediaSourceFactory(
|
||||||
context, new SlowExtractorsFactory(/* delayBetweenReadsMs= */ 10));
|
context, new SlowExtractorsFactory(/* delayBetweenReadsMs= */ 10));
|
||||||
|
AssetLoader.Factory assetLoaderFactory = new ExoPlayerAssetLoader.Factory(mediaSourceFactory);
|
||||||
Muxer.Factory muxerFactory = new TestMuxerFactory(/* maxDelayBetweenSamplesMs= */ 1);
|
Muxer.Factory muxerFactory = new TestMuxerFactory(/* maxDelayBetweenSamplesMs= */ 1);
|
||||||
Transformer transformer =
|
Transformer transformer =
|
||||||
createTransformerBuilder(/* enableFallback= */ false)
|
createTransformerBuilder(/* enableFallback= */ false)
|
||||||
.setMediaSourceFactory(mediaSourceFactory)
|
.setAssetLoaderFactory(assetLoaderFactory)
|
||||||
.setMuxerFactory(muxerFactory)
|
.setMuxerFactory(muxerFactory)
|
||||||
.build();
|
.build();
|
||||||
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
|
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user