Move effect setters to VideoSink

PiperOrigin-RevId: 631011252
This commit is contained in:
kimvde 2024-05-06 05:21:22 -07:00 committed by Copybara-Service
parent 2c912aa697
commit 506944dcfd
4 changed files with 24 additions and 37 deletions

View File

@ -258,16 +258,6 @@ public final class CompositingVideoSinkProvider
return videoFrameReleaseControl;
}
@Override
public void setVideoEffects(List<Effect> videoEffects) {
videoSinkImpl.setVideoEffects(videoEffects);
}
@Override
public void setPendingVideoEffects(List<Effect> videoEffects) {
videoSinkImpl.setPendingVideoEffects(videoEffects);
}
@Override
public VideoSink getSink() {
return videoSinkImpl;
@ -679,6 +669,18 @@ public final class CompositingVideoSinkProvider
CompositingVideoSinkProvider.this.setPlaybackSpeed(speed);
}
@Override
public void setVideoEffects(List<Effect> videoEffects) {
setPendingVideoEffects(videoEffects);
maybeRegisterInputStream();
}
@Override
public void setPendingVideoEffects(List<Effect> videoEffects) {
this.videoEffects.clear();
this.videoEffects.addAll(videoEffects);
}
@Override
public void setStreamOffsetUs(long streamOffsetUs) {
pendingInputStreamOffsetChange = inputStreamOffsetUs != streamOffsetUs;
@ -771,21 +773,6 @@ public final class CompositingVideoSinkProvider
// Other methods
/** Sets the {@linkplain Effect video effects}. */
public void setVideoEffects(List<Effect> videoEffects) {
setPendingVideoEffects(videoEffects);
maybeRegisterInputStream();
}
/**
* Sets the {@linkplain Effect video effects} to apply when the next stream is {@linkplain
* #registerInputStream(int, Format) registered}.
*/
public void setPendingVideoEffects(List<Effect> videoEffects) {
this.videoEffects.clear();
this.videoEffects.addAll(videoEffects);
}
private void maybeSetStreamOffsetChange(long bufferPresentationTimeUs) {
if (pendingInputStreamOffsetChange) {
CompositingVideoSinkProvider.this.onStreamOffsetChange(

View File

@ -1104,7 +1104,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
/** Sets the {@linkplain Effect video effects} to apply. */
public void setVideoEffects(List<Effect> effects) {
videoSinkProvider.setVideoEffects(effects);
videoSink.setVideoEffects(effects);
hasEffects = true;
}

View File

@ -22,6 +22,7 @@ import android.view.Surface;
import androidx.annotation.FloatRange;
import androidx.annotation.IntDef;
import androidx.media3.common.C;
import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.VideoSize;
import androidx.media3.common.util.Clock;
@ -31,6 +32,7 @@ import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;
import java.util.concurrent.Executor;
/** A sink that consumes decoded video frames. */
@ -158,6 +160,15 @@ public interface VideoSink {
/** Sets the playback speed. */
void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed);
/** Sets {@linkplain Effect video effects} to apply immediately. */
void setVideoEffects(List<Effect> videoEffects);
/**
* Sets {@linkplain Effect video effects} to apply after the next stream is {@linkplain
* VideoSink#registerInputStream(int, Format) registered}.
*/
void setPendingVideoEffects(List<Effect> videoEffects);
/**
* Sets the offset, in microseconds, that is added to the video frames presentation timestamps
* from the player.

View File

@ -17,12 +17,10 @@
package androidx.media3.exoplayer.video;
import android.view.Surface;
import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.util.Clock;
import androidx.media3.common.util.Size;
import androidx.media3.common.util.UnstableApi;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
/** A provider of {@link VideoSink VideoSinks}. */
@ -47,15 +45,6 @@ public interface VideoSinkProvider {
*/
@Nullable VideoFrameReleaseControl getVideoFrameReleaseControl();
/** Sets video effects on this provider to apply immediately. */
void setVideoEffects(List<Effect> videoEffects);
/**
* Sets video effects on this provider to apply when the next stream is {@linkplain
* VideoSink#registerInputStream(int, Format) registered} on the {@link #getSink() VideoSink}.
*/
void setPendingVideoEffects(List<Effect> videoEffects);
/** Returns a {@link VideoSink} to forward video frames for processing. */
VideoSink getSink();