From d5035123b47e3f9ef006b16f8bf9b823a4bf1223 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 --- .../media3/transformer/Composition.java | 15 ++++--- .../media3/transformer/EditedMediaItem.java | 45 +++++++++++-------- .../transformer/EditedMediaItemSequence.java | 5 ++- .../androidx/media3/transformer/Effects.java | 29 +++++++----- 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Composition.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Composition.java index 5ae31c32ba..456bba467d 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Composition.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Composition.java @@ -28,16 +28,19 @@ import com.google.common.collect.ImmutableList; @UnstableApi 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/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java index b2effd7cfa..5ddb30d140 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java @@ -88,19 +88,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 @@ -150,11 +138,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/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItemSequence.java b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItemSequence.java index b9c4cbacf6..3085a98b61 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItemSequence.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItemSequence.java @@ -26,12 +26,13 @@ import com.google.common.collect.ImmutableList; @UnstableApi 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/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java index 5fcb0f63ef..0c42845541 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java @@ -27,9 +27,22 @@ import com.google.common.collect.ImmutableList; @UnstableApi 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}. @@ -45,13 +58,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,