Skip to content

Commit

Permalink
Add EditedMediaItem class
Browse files Browse the repository at this point in the history
This class will be used in a follow-up CL.

PiperOrigin-RevId: 502615323
  • Loading branch information
kim-vde authored and christosts committed Jan 18, 2023
1 parent 5461d5c commit 6b6e499
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 com.google.android.exoplayer2.transformer;

import com.google.android.exoplayer2.MediaItem;
import com.google.common.collect.ImmutableList;

/** A {@link MediaItem} with the transformations to apply to it. */
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 com.google.android.exoplayer2.transformer;

import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.effect.GlEffectsFrameProcessor;
import com.google.android.exoplayer2.util.Effect;
import com.google.android.exoplayer2.util.FrameProcessor;
import com.google.common.collect.ImmutableList;

/** Effects to apply to a {@link MediaItem}. */
public final class Effects {

/* package */ final ImmutableList<AudioProcessor> audioProcessors;
/* package */ final ImmutableList<Effect> videoEffects;
/* package */ final FrameProcessor.Factory frameProcessorFactory;

/**
* Creates an instance using a {@link GlEffectsFrameProcessor.Factory}.
*
* <p>This is equivalent to calling {@link Effects#Effects(ImmutableList, ImmutableList,
* FrameProcessor.Factory)} with a {@link GlEffectsFrameProcessor.Factory}.
*/
public Effects(
ImmutableList<AudioProcessor> audioProcessors, ImmutableList<Effect> 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<AudioProcessor> audioProcessors,
ImmutableList<Effect> videoEffects,
FrameProcessor.Factory frameProcessorFactory) {
this.audioProcessors = audioProcessors;
this.videoEffects = videoEffects;
this.frameProcessorFactory = frameProcessorFactory;
}
}

0 comments on commit 6b6e499

Please sign in to comment.