Commit e6bf908b by claincly Committed by Ian Baker

Add render messages for setting video output resolution

An AndroidTest is needed to test the message sending from ExoPlayerImpl to
a video renderer (MCVR in this case). The test will be added later.

PiperOrigin-RevId: 493602259
parent 03276d1e
...@@ -28,6 +28,7 @@ import static com.google.android.exoplayer2.Renderer.MSG_SET_SCALING_MODE; ...@@ -28,6 +28,7 @@ import static com.google.android.exoplayer2.Renderer.MSG_SET_SCALING_MODE;
import static com.google.android.exoplayer2.Renderer.MSG_SET_SKIP_SILENCE_ENABLED; import static com.google.android.exoplayer2.Renderer.MSG_SET_SKIP_SILENCE_ENABLED;
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER; import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT; import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT;
import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT_RESOLUTION;
import static com.google.android.exoplayer2.Renderer.MSG_SET_VOLUME; import static com.google.android.exoplayer2.Renderer.MSG_SET_VOLUME;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
...@@ -2945,6 +2946,8 @@ import java.util.concurrent.TimeoutException; ...@@ -2945,6 +2946,8 @@ import java.util.concurrent.TimeoutException;
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
maybeNotifySurfaceSizeChanged(width, height); maybeNotifySurfaceSizeChanged(width, height);
sendRendererMessage(
TRACK_TYPE_VIDEO, MSG_SET_VIDEO_OUTPUT_RESOLUTION, Pair.create(width, height));
} }
@Override @Override
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2;
import static java.lang.annotation.ElementType.TYPE_USE; import static java.lang.annotation.ElementType.TYPE_USE;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.util.Pair;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -25,6 +26,7 @@ import com.google.android.exoplayer2.analytics.PlayerId; ...@@ -25,6 +26,7 @@ import com.google.android.exoplayer2.analytics.PlayerId;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.audio.AuxEffectInfo; import com.google.android.exoplayer2.audio.AuxEffectInfo;
import com.google.android.exoplayer2.source.SampleStream; import com.google.android.exoplayer2.source.SampleStream;
import com.google.android.exoplayer2.util.Effect;
import com.google.android.exoplayer2.util.MediaClock; import com.google.android.exoplayer2.util.MediaClock;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer; import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
...@@ -80,8 +82,9 @@ public interface Renderer extends PlayerMessage.Target { ...@@ -80,8 +82,9 @@ public interface Renderer extends PlayerMessage.Target {
* #MSG_SET_SCALING_MODE}, {@link #MSG_SET_CHANGE_FRAME_RATE_STRATEGY}, {@link * #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_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_CAMERA_MOTION_LISTENER}, {@link #MSG_SET_SKIP_SILENCE_ENABLED}, {@link
* #MSG_SET_AUDIO_SESSION_ID} or {@link #MSG_SET_WAKEUP_LISTENER}. May also be an app-defined * #MSG_SET_AUDIO_SESSION_ID}, {@link #MSG_SET_WAKEUP_LISTENER} or {@link
* value (see {@link #MSG_CUSTOM_BASE}). * #MSG_SET_VIDEO_OUTPUT_RESOLUTION}. May also be an app-defined value (see {@link
* #MSG_CUSTOM_BASE}).
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
...@@ -99,7 +102,8 @@ public interface Renderer extends PlayerMessage.Target { ...@@ -99,7 +102,8 @@ public interface Renderer extends PlayerMessage.Target {
MSG_SET_CAMERA_MOTION_LISTENER, MSG_SET_CAMERA_MOTION_LISTENER,
MSG_SET_SKIP_SILENCE_ENABLED, MSG_SET_SKIP_SILENCE_ENABLED,
MSG_SET_AUDIO_SESSION_ID, MSG_SET_AUDIO_SESSION_ID,
MSG_SET_WAKEUP_LISTENER MSG_SET_WAKEUP_LISTENER,
MSG_SET_VIDEO_OUTPUT_RESOLUTION
}) })
public @interface MessageType {} public @interface MessageType {}
/** /**
...@@ -202,6 +206,13 @@ public interface Renderer extends PlayerMessage.Target { ...@@ -202,6 +206,13 @@ public interface Renderer extends PlayerMessage.Target {
*/ */
int MSG_SET_PREFERRED_AUDIO_DEVICE = 12; int MSG_SET_PREFERRED_AUDIO_DEVICE = 12;
/** /**
* 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 Pair} containing the desired output width
* and height, in {@link Integer} instances. Use this method only when playing with video {@link
* Effect}.
*/
int MSG_SET_VIDEO_OUTPUT_RESOLUTION = 13;
/**
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to * 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. * renderers. These custom constants must be greater than or equal to this value.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment