diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 52af28a047..ea8a8d3825 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -26,6 +26,9 @@
* Add `ConcatenatingMediaSource2` that allows combining multiple media
items into a single window
([#247](https://github.com/androidx/media/issues/247)).
+ * Add `ExoPlayer.setVideoEffects()` for using `Effect` during video
+ playback.
+* Extractors:
* Update `SampleQueue` to store `sourceId` as a `long` rather than an
`int`. This changes the signatures of public methods
`SampleQueue.sourceId` and `SampleQueue.peekSourceId`.
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java
index ace616b285..6c53b20e14 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java
@@ -37,6 +37,7 @@ import androidx.media3.common.AudioAttributes;
import androidx.media3.common.AuxEffectInfo;
import androidx.media3.common.C;
import androidx.media3.common.DeviceInfo;
+import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Player;
@@ -1530,6 +1531,25 @@ public interface ExoPlayer extends Player {
@UnstableApi
boolean getSkipSilenceEnabled();
+ /**
+ * Sets a {@link List} of {@linkplain Effect video effects} that will be applied to each video
+ * frame.
+ *
+ *
The following limitations exist for using {@linkplain Effect video effects}:
+ *
+ *
+ * - This feature works only with the default {@link MediaCodecVideoRenderer} and not custom
+ * or extension {@linkplain Renderer video renderers}.
+ *
- This feature does not work with DRM-protected contents.
+ *
- This method should be called before calling {@link #prepare}.
+ *
+ *
+ * @param videoEffects The {@link List} of {@linkplain Effect video effects} to apply.
+ */
+ @RequiresApi(18)
+ @UnstableApi
+ void setVideoEffects(List videoEffects);
+
/**
* Sets the {@link C.VideoScalingMode}.
*
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java
index 3b3996cf27..0e34b19fff 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java
@@ -30,6 +30,7 @@ import static androidx.media3.exoplayer.Renderer.MSG_SET_CHANGE_FRAME_RATE_STRAT
import static androidx.media3.exoplayer.Renderer.MSG_SET_PREFERRED_AUDIO_DEVICE;
import static androidx.media3.exoplayer.Renderer.MSG_SET_SCALING_MODE;
import static androidx.media3.exoplayer.Renderer.MSG_SET_SKIP_SILENCE_ENABLED;
+import static androidx.media3.exoplayer.Renderer.MSG_SET_VIDEO_EFFECTS;
import static androidx.media3.exoplayer.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
import static androidx.media3.exoplayer.Renderer.MSG_SET_VIDEO_OUTPUT;
import static androidx.media3.exoplayer.Renderer.MSG_SET_VIDEO_OUTPUT_RESOLUTION;
@@ -61,6 +62,7 @@ import androidx.media3.common.AuxEffectInfo;
import androidx.media3.common.BasePlayer;
import androidx.media3.common.C;
import androidx.media3.common.DeviceInfo;
+import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.IllegalSeekPositionException;
import androidx.media3.common.MediaItem;
@@ -1239,6 +1241,12 @@ import java.util.concurrent.TimeoutException;
return playbackInfo.timeline;
}
+ @Override
+ public void setVideoEffects(List videoEffects) {
+ verifyApplicationThread();
+ sendRendererMessage(TRACK_TYPE_VIDEO, MSG_SET_VIDEO_EFFECTS, videoEffects);
+ }
+
@Override
public void setVideoScalingMode(@C.VideoScalingMode int videoScalingMode) {
verifyApplicationThread();
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/Renderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/Renderer.java
index 3440c586e3..6d39bb1d64 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/Renderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/Renderer.java
@@ -40,6 +40,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;
/**
* Renders media read from a {@link SampleStream}.
@@ -86,8 +87,8 @@ public interface Renderer extends PlayerMessage.Target {
* #MSG_SET_SCALING_MODE}, {@link #MSG_SET_CHANGE_FRAME_RATE_STRATEGY}, {@link
* #MSG_SET_AUX_EFFECT_INFO}, {@link #MSG_SET_VIDEO_FRAME_METADATA_LISTENER}, {@link
* #MSG_SET_CAMERA_MOTION_LISTENER}, {@link #MSG_SET_SKIP_SILENCE_ENABLED}, {@link
- * #MSG_SET_AUDIO_SESSION_ID}, {@link #MSG_SET_WAKEUP_LISTENER} or {@link
- * #MSG_SET_VIDEO_OUTPUT_RESOLUTION}. May also be an app-defined value (see {@link
+ * #MSG_SET_AUDIO_SESSION_ID}, {@link #MSG_SET_WAKEUP_LISTENER}, {@link #MSG_SET_VIDEO_EFFECTS} or
+ * {@link #MSG_SET_VIDEO_OUTPUT_RESOLUTION}. May also be an app-defined value (see {@link
* #MSG_CUSTOM_BASE}).
*/
@Documented
@@ -107,6 +108,7 @@ public interface Renderer extends PlayerMessage.Target {
MSG_SET_SKIP_SILENCE_ENABLED,
MSG_SET_AUDIO_SESSION_ID,
MSG_SET_WAKEUP_LISTENER,
+ MSG_SET_VIDEO_EFFECTS,
MSG_SET_VIDEO_OUTPUT_RESOLUTION
})
public @interface MessageType {}
@@ -209,12 +211,17 @@ public interface Renderer extends PlayerMessage.Target {
* restore the default.
*/
int MSG_SET_PREFERRED_AUDIO_DEVICE = 12;
+ /**
+ * The type of a message that can be passed to a video renderer. The message payload should be a
+ * {@link List} containing {@linkplain Effect video effects}.
+ */
+ int MSG_SET_VIDEO_EFFECTS = 13;
/**
* The type of a message that can be passed to a video renderer to set the desired output
* resolution. The message payload should be a {@link Size} of the desired output width and
* height. Use this method only when playing with video {@linkplain Effect effects}.
*/
- int MSG_SET_VIDEO_OUTPUT_RESOLUTION = 13;
+ int MSG_SET_VIDEO_OUTPUT_RESOLUTION = 14;
/**
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to
* renderers. These custom constants must be greater than or equal to this value.
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java
index 5676ce7554..4fc2a3f440 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java
@@ -33,6 +33,7 @@ import androidx.media3.common.AuxEffectInfo;
import androidx.media3.common.BasePlayer;
import androidx.media3.common.C;
import androidx.media3.common.DeviceInfo;
+import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MediaMetadata;
@@ -664,6 +665,12 @@ public class SimpleExoPlayer extends BasePlayer
return player.getSkipSilenceEnabled();
}
+ @Override
+ public void setVideoEffects(List videoEffects) {
+ blockUntilConstructorFinished();
+ player.setVideoEffects(videoEffects);
+ }
+
@Override
public void setSkipSilenceEnabled(boolean skipSilenceEnabled) {
blockUntilConstructorFinished();
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
index d54ed55460..34290750fb 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java
@@ -688,6 +688,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
break;
+ case MSG_SET_VIDEO_EFFECTS:
+ @SuppressWarnings("unchecked")
+ List videoEffects = (List) checkNotNull(message);
+ frameProcessorManager.setVideoEffects(videoEffects);
+ break;
case MSG_SET_VIDEO_OUTPUT_RESOLUTION:
Size outputResolution = (Size) checkNotNull(message);
if (outputResolution.getWidth() != 0
diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java
index e1fa6e5034..9cfbac5a7d 100644
--- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java
+++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/StubExoPlayer.java
@@ -20,6 +20,7 @@ import android.os.Looper;
import androidx.annotation.Nullable;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.AuxEffectInfo;
+import androidx.media3.common.Effect;
import androidx.media3.common.Format;
import androidx.media3.common.Player;
import androidx.media3.common.PriorityTaskManager;
@@ -252,6 +253,11 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
throw new UnsupportedOperationException();
}
+ @Override
+ public void setVideoEffects(List videoEffects) {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public void setVideoScalingMode(int videoScalingMode) {
throw new UnsupportedOperationException();