From 8caf8360536fe77f3543fd38f4e17b8fcd78106f Mon Sep 17 00:00:00 2001 From: kimvde Date: Tue, 31 Jan 2023 13:50:42 +0000 Subject: [PATCH] Make Composition fields public Transformer callbacks will take a Composition instead of a MediaItem. Apps should be able to see what this Composition contains. PiperOrigin-RevId: 505976561 --- .../exoplayer2/transformer/Composition.java | 15 ++++--- .../transformer/EditedMediaItem.java | 45 +++++++++++-------- .../transformer/EditedMediaItemSequence.java | 5 ++- .../exoplayer2/transformer/Effects.java | 29 +++++++----- 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Composition.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Composition.java index b830211553..c822c5e8b8 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Composition.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Composition.java @@ -26,16 +26,19 @@ import com.google.common.collect.ImmutableList; */ public final class Composition { - /* package */ final ImmutableList sequences; - /* package */ final Effects effects; + /** + * The {@link EditedMediaItemSequence} instances to compose. {@link MediaItem} instances from + * different sequences that are overlapping in time will be mixed in the output. + */ + public final ImmutableList sequences; + /** The {@link Effects} to apply to the composition. */ + public final Effects effects; /** * Creates an instance. * - * @param sequences The {@link EditedMediaItemSequence} instances to compose. {@link MediaItem} - * instances from different sequences that are overlapping in time will be mixed in the - * output. - * @param effects The {@link Effects} to apply to the composition. + * @param sequences The {@link #sequences}. + * @param effects The {@link #effects}. */ public Composition(ImmutableList sequences, Effects effects) { this.sequences = sequences; diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItem.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItem.java index 721d70a647..4abc2f82e6 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItem.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItem.java @@ -86,19 +86,7 @@ public final class EditedMediaItem { * *

The default value is {@code false}. * - *

The flattened output is obtained by removing the slow motion metadata and by actually - * slowing down the parts of the video and audio streams defined in this metadata. - * - *

Only Samsung Extension Format (SEF) slow motion metadata type is supported. Flattening has - * no effect if the input does not contain this metadata type. - * - *

For SEF slow motion media, the following assumptions are made on the input: - * - *

    - *
  • The input container format is (unfragmented) MP4. - *
  • The input contains an AVC video elementary stream with temporal SVC. - *
  • The recording frame rate of the video is 120 or 240 fps. - *
+ *

See {@link #flattenForSlowMotion} for more information about slow motion flattening. * *

If using an {@link ExoPlayerAssetLoader.Factory} with a provided {@link * MediaSource.Factory}, make sure that {@link Mp4Extractor#FLAG_READ_SEF_DATA} is set on the @@ -148,11 +136,32 @@ public final class EditedMediaItem { } } - /* package */ final MediaItem mediaItem; - /* package */ final boolean removeAudio; - /* package */ final boolean removeVideo; - /* package */ final boolean flattenForSlowMotion; - /* package */ final Effects effects; + /** The {@link MediaItem} on which transformations are applied. */ + public final MediaItem mediaItem; + /** Whether to remove the audio from the {@link #mediaItem}. */ + public final boolean removeAudio; + /** Whether to remove the video from the {@link #mediaItem}. */ + public final boolean removeVideo; + /** + * Whether to flatten the {@link #mediaItem} if it contains slow motion markers. + * + *

The flattened output is obtained by removing the slow motion metadata and by actually + * slowing down the parts of the video and audio streams defined in this metadata. + * + *

Only Samsung Extension Format (SEF) slow motion metadata type is supported. Flattening has + * no effect if the input does not contain this metadata type. + * + *

For SEF slow motion media, the following assumptions are made on the input: + * + *

    + *
  • The input container format is (unfragmented) MP4. + *
  • The input contains an AVC video elementary stream with temporal SVC. + *
  • The recording frame rate of the video is 120 or 240 fps. + *
+ */ + public final boolean flattenForSlowMotion; + /** The {@link Effects} to apply to the {@link #mediaItem}. */ + public final Effects effects; private EditedMediaItem( MediaItem mediaItem, diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItemSequence.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItemSequence.java index 49bdafc107..fcccc8efb9 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItemSequence.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/EditedMediaItemSequence.java @@ -24,12 +24,13 @@ import com.google.common.collect.ImmutableList; */ public final class EditedMediaItemSequence { - /* package */ final ImmutableList editedMediaItems; + /** The {@link EditedMediaItem} instances in the sequence. */ + public final ImmutableList editedMediaItems; /** * Creates an instance. * - * @param editedMediaItems The {@link EditedMediaItem} instances in the sequence. + * @param editedMediaItems The {@link #editedMediaItems}. */ public EditedMediaItemSequence(ImmutableList editedMediaItems) { this.editedMediaItems = editedMediaItems; diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Effects.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Effects.java index 12a458bde3..180cb5744e 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Effects.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Effects.java @@ -25,9 +25,22 @@ import com.google.common.collect.ImmutableList; /** Effects to apply to a {@link MediaItem}. */ public final class Effects { - /* package */ final ImmutableList audioProcessors; - /* package */ final ImmutableList videoEffects; - /* package */ final FrameProcessor.Factory frameProcessorFactory; + /** + * The list of {@linkplain AudioProcessor audio processors} to apply to audio buffers. They are + * applied in the order of the list, and buffers will only be modified by that {@link + * AudioProcessor} if it {@link AudioProcessor#isActive()} based on the current configuration. + */ + public final ImmutableList audioProcessors; + /** + * The list of {@linkplain Effect video effects} to apply to each frame. They are applied in the + * order of the list. + */ + public final ImmutableList videoEffects; + /** + * The {@link FrameProcessor.Factory} for the {@link FrameProcessor} to use when applying the + * {@code videoEffects} to the video frames. + */ + public final FrameProcessor.Factory frameProcessorFactory; /** * Creates an instance using a {@link GlEffectsFrameProcessor.Factory}. @@ -43,13 +56,9 @@ public final class Effects { /** * Creates an instance. * - * @param audioProcessors The list of {@link AudioProcessor} instances to apply to audio buffers. - * They are applied in the order of the list, and buffers will only be modified by that {@link - * AudioProcessor} if it {@link AudioProcessor#isActive()} based on the current configuration. - * @param videoEffects The list of {@link Effect} instances to apply to each video frame. They are - * applied in the order of the list. - * @param frameProcessorFactory The {@link FrameProcessor.Factory} for the {@link FrameProcessor} - * to use when applying the {@code videoEffects} to the video frames. + * @param audioProcessors The {@link #audioProcessors}. + * @param videoEffects The {@link #videoEffects}. + * @param frameProcessorFactory The {@link #frameProcessorFactory}. */ public Effects( ImmutableList audioProcessors,