diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java new file mode 100644 index 0000000000..569790d2b9 --- /dev/null +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java @@ -0,0 +1,48 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package androidx.media3.transformer; + +import androidx.media3.common.MediaItem; +import androidx.media3.common.util.UnstableApi; +import com.google.common.collect.ImmutableList; + +/** A {@link MediaItem} with the transformations to apply to it. */ +@UnstableApi +public class EditedMediaItem { + + /* package */ final MediaItem mediaItem; + /* package */ final Effects effects; + + /** + * Creates an instance with no {@link Effects}. + * + * @param mediaItem The {@link MediaItem} to edit. + */ + public EditedMediaItem(MediaItem mediaItem) { + this(mediaItem, new Effects(ImmutableList.of(), ImmutableList.of())); + } + + /** + * Creates an instance. + * + * @param mediaItem The {@link MediaItem} to edit. + * @param effects The {@link Effects} to apply to the {@code mediaItem}. + */ + public EditedMediaItem(MediaItem mediaItem, Effects effects) { + this.mediaItem = mediaItem; + this.effects = effects; + } +} diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java new file mode 100644 index 0000000000..c6b2348753 --- /dev/null +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Effects.java @@ -0,0 +1,65 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package androidx.media3.transformer; + +import androidx.media3.common.Effect; +import androidx.media3.common.FrameProcessor; +import androidx.media3.common.MediaItem; +import androidx.media3.common.audio.AudioProcessor; +import androidx.media3.common.util.UnstableApi; +import androidx.media3.effect.GlEffectsFrameProcessor; +import com.google.common.collect.ImmutableList; + +/** Effects to apply to a {@link MediaItem}. */ +@UnstableApi +public final class Effects { + + /* package */ final ImmutableList audioProcessors; + /* package */ final ImmutableList videoEffects; + /* package */ final FrameProcessor.Factory frameProcessorFactory; + + /** + * Creates an instance using a {@link GlEffectsFrameProcessor.Factory}. + * + *

This is equivalent to calling {@link Effects#Effects(ImmutableList, ImmutableList, + * FrameProcessor.Factory)} with a {@link GlEffectsFrameProcessor.Factory}. + */ + public Effects( + ImmutableList audioProcessors, ImmutableList videoEffects) { + this(audioProcessors, videoEffects, new GlEffectsFrameProcessor.Factory()); + } + + /** + * 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, after {@linkplain + * TransformationRequest.Builder#setFlattenForSlowMotion(boolean) slow-motion flattening}. + * @param frameProcessorFactory The {@link FrameProcessor.Factory} for the {@link FrameProcessor} + * to use when applying the {@code videoEffects} to the video frames. + */ + public Effects( + ImmutableList audioProcessors, + ImmutableList videoEffects, + FrameProcessor.Factory frameProcessorFactory) { + this.audioProcessors = audioProcessors; + this.videoEffects = videoEffects; + this.frameProcessorFactory = frameProcessorFactory; + } +}