Deprecate ExoPlayer VideoComponent.

PiperOrigin-RevId: 392668736
This commit is contained in:
samrobinson 2021-08-24 16:28:12 +01:00 committed by kim-vde
parent d3cc98d368
commit 628e744e26
2 changed files with 158 additions and 120 deletions

View file

@ -185,170 +185,94 @@ public interface ExoPlayer extends Player {
boolean getSkipSilenceEnabled(); boolean getSkipSilenceEnabled();
} }
/** The video component of an {@link ExoPlayer}. */ /**
* @deprecated Use {@link ExoPlayer}, as the {@link VideoComponent} methods are defined by that
* interface.
*/
@Deprecated
interface VideoComponent { interface VideoComponent {
/** /** @deprecated Use {@link ExoPlayer#setVideoScalingMode(int)} instead. */
* Sets the {@link C.VideoScalingMode}. @Deprecated
*
* <p>The scaling mode only applies if a {@link MediaCodec}-based video {@link Renderer} is
* enabled and if the output surface is owned by a {@link SurfaceView}.
*
* @param videoScalingMode The {@link C.VideoScalingMode}.
*/
void setVideoScalingMode(@C.VideoScalingMode int videoScalingMode); void setVideoScalingMode(@C.VideoScalingMode int videoScalingMode);
/** Returns the {@link C.VideoScalingMode}. */ /** @deprecated Use {@link ExoPlayer#getVideoScalingMode()} instead. */
@Deprecated
@C.VideoScalingMode @C.VideoScalingMode
int getVideoScalingMode(); int getVideoScalingMode();
/** /** @deprecated Use {@link ExoPlayer#setVideoChangeFrameRateStrategy(int)} instead. */
* Sets a {@link C.VideoChangeFrameRateStrategy} that will be used by the player when provided @Deprecated
* with a video output {@link Surface}.
*
* <p>The strategy only applies if a {@link MediaCodec}-based video {@link Renderer} is enabled.
* Applications wishing to use {@link Surface#CHANGE_FRAME_RATE_ALWAYS} should set the mode to
* {@link C#VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF} to disable calls to {@link
* Surface#setFrameRate} from ExoPlayer, and should then call {@link Surface#setFrameRate}
* directly from application code.
*
* @param videoChangeFrameRateStrategy A {@link C.VideoChangeFrameRateStrategy}.
*/
void setVideoChangeFrameRateStrategy( void setVideoChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy); @C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy);
/** Returns the {@link C.VideoChangeFrameRateStrategy}. */ /** @deprecated Use {@link ExoPlayer#getVideoChangeFrameRateStrategy()} instead. */
@Deprecated
@C.VideoChangeFrameRateStrategy @C.VideoChangeFrameRateStrategy
int getVideoChangeFrameRateStrategy(); int getVideoChangeFrameRateStrategy();
/** /**
* Sets a listener to receive video frame metadata events. * @deprecated Use {@link ExoPlayer#setVideoFrameMetadataListener(VideoFrameMetadataListener)}
* * instead.
* <p>This method is intended to be called by the same component that sets the {@link Surface}
* onto which video will be rendered. If using ExoPlayer's standard UI components, this method
* should not be called directly from application code.
*
* @param listener The listener.
*/ */
@Deprecated
void setVideoFrameMetadataListener(VideoFrameMetadataListener listener); void setVideoFrameMetadataListener(VideoFrameMetadataListener listener);
/** /**
* Clears the listener which receives video frame metadata events if it matches the one passed. * @deprecated Use {@link ExoPlayer#clearVideoFrameMetadataListener(VideoFrameMetadataListener)}
* Else does nothing. * instead.
*
* @param listener The listener to clear.
*/ */
@Deprecated
void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener); void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener);
/** /** @deprecated Use {@link ExoPlayer#setCameraMotionListener(CameraMotionListener)} instead. */
* Sets a listener of camera motion events. @Deprecated
*
* @param listener The listener.
*/
void setCameraMotionListener(CameraMotionListener listener); void setCameraMotionListener(CameraMotionListener listener);
/** /**
* Clears the listener which receives camera motion events if it matches the one passed. Else * @deprecated Use {@link ExoPlayer#clearCameraMotionListener(CameraMotionListener)} instead.
* does nothing.
*
* @param listener The listener to clear.
*/ */
@Deprecated
void clearCameraMotionListener(CameraMotionListener listener); void clearCameraMotionListener(CameraMotionListener listener);
/** /** @deprecated Use {@link Player#clearVideoSurface()} instead. */
* Clears any {@link Surface}, {@link SurfaceHolder}, {@link SurfaceView} or {@link TextureView} @Deprecated
* currently set on the player.
*/
void clearVideoSurface(); void clearVideoSurface();
/** /** @deprecated Use {@link Player#clearVideoSurface(Surface)} instead. */
* Clears the {@link Surface} onto which video is being rendered if it matches the one passed. @Deprecated
* Else does nothing.
*
* @param surface The surface to clear.
*/
void clearVideoSurface(@Nullable Surface surface); void clearVideoSurface(@Nullable Surface surface);
/** /** @deprecated Use {@link Player#setVideoSurface(Surface)} instead. */
* Sets the {@link Surface} onto which video will be rendered. The caller is responsible for @Deprecated
* tracking the lifecycle of the surface, and must clear the surface by calling {@code
* setVideoSurface(null)} if the surface is destroyed.
*
* <p>If the surface is held by a {@link SurfaceView}, {@link TextureView} or {@link
* SurfaceHolder} then it's recommended to use {@link #setVideoSurfaceView(SurfaceView)}, {@link
* #setVideoTextureView(TextureView)} or {@link #setVideoSurfaceHolder(SurfaceHolder)} rather
* than this method, since passing the holder allows the player to track the lifecycle of the
* surface automatically.
*
* @param surface The {@link Surface}.
*/
void setVideoSurface(@Nullable Surface surface); void setVideoSurface(@Nullable Surface surface);
/** /** @deprecated Use {@link Player#setVideoSurfaceHolder(SurfaceHolder)} instead. */
* Sets the {@link SurfaceHolder} that holds the {@link Surface} onto which video will be @Deprecated
* rendered. The player will track the lifecycle of the surface automatically.
*
* <p>The thread that calls the {@link SurfaceHolder.Callback} methods must be the thread
* associated with {@link #getApplicationLooper()}.
*
* @param surfaceHolder The surface holder.
*/
void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder); void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder);
/** /** @deprecated Use {@link Player#clearVideoSurfaceHolder(SurfaceHolder)} instead. */
* Clears the {@link SurfaceHolder} that holds the {@link Surface} onto which video is being @Deprecated
* rendered if it matches the one passed. Else does nothing.
*
* @param surfaceHolder The surface holder to clear.
*/
void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder); void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder);
/** /** @deprecated Use {@link Player#setVideoSurfaceView(SurfaceView)} instead. */
* Sets the {@link SurfaceView} onto which video will be rendered. The player will track the @Deprecated
* lifecycle of the surface automatically.
*
* <p>The thread that calls the {@link SurfaceHolder.Callback} methods must be the thread
* associated with {@link #getApplicationLooper()}.
*
* @param surfaceView The surface view.
*/
void setVideoSurfaceView(@Nullable SurfaceView surfaceView); void setVideoSurfaceView(@Nullable SurfaceView surfaceView);
/** /** @deprecated Use {@link Player#clearVideoSurfaceView(SurfaceView)} instead. */
* Clears the {@link SurfaceView} onto which video is being rendered if it matches the one @Deprecated
* passed. Else does nothing.
*
* @param surfaceView The texture view to clear.
*/
void clearVideoSurfaceView(@Nullable SurfaceView surfaceView); void clearVideoSurfaceView(@Nullable SurfaceView surfaceView);
/** /** @deprecated Use {@link Player#setVideoTextureView(TextureView)} instead. */
* Sets the {@link TextureView} onto which video will be rendered. The player will track the @Deprecated
* lifecycle of the surface automatically.
*
* <p>The thread that calls the {@link TextureView.SurfaceTextureListener} methods must be the
* thread associated with {@link #getApplicationLooper()}.
*
* @param textureView The texture view.
*/
void setVideoTextureView(@Nullable TextureView textureView); void setVideoTextureView(@Nullable TextureView textureView);
/** /** @deprecated Use {@link Player#clearVideoTextureView(TextureView)} instead. */
* Clears the {@link TextureView} onto which video is being rendered if it matches the one @Deprecated
* passed. Else does nothing.
*
* @param textureView The texture view to clear.
*/
void clearVideoTextureView(@Nullable TextureView textureView); void clearVideoTextureView(@Nullable TextureView textureView);
/** /** @deprecated Use {@link Player#getVideoSize()} instead. */
* Gets the size of the video. @Deprecated
*
* <p>The width and height of size could be 0 if there is no video or the size has not been
* determined yet.
*
* @see Listener#onVideoSizeChanged(VideoSize)
*/
VideoSize getVideoSize(); VideoSize getVideoSize();
} }
@ -922,8 +846,12 @@ public interface ExoPlayer extends Player {
@Deprecated @Deprecated
AudioComponent getAudioComponent(); AudioComponent getAudioComponent();
/** Returns the component of this player for video output, or null if video is not supported. */ /**
* @deprecated Use {@link ExoPlayer}, as the {@link VideoComponent} methods are part of the
* interface.
*/
@Nullable @Nullable
@Deprecated
VideoComponent getVideoComponent(); VideoComponent getVideoComponent();
/** /**
@ -1139,6 +1067,73 @@ public interface ExoPlayer extends Player {
/** Returns whether skipping silences in the audio stream is enabled. */ /** Returns whether skipping silences in the audio stream is enabled. */
boolean getSkipSilenceEnabled(); boolean getSkipSilenceEnabled();
/**
* Sets the {@link C.VideoScalingMode}.
*
* <p>The scaling mode only applies if a {@link MediaCodec}-based video {@link Renderer} is
* enabled and if the output surface is owned by a {@link SurfaceView}.
*
* @param videoScalingMode The {@link C.VideoScalingMode}.
*/
void setVideoScalingMode(@C.VideoScalingMode int videoScalingMode);
/** Returns the {@link C.VideoScalingMode}. */
@C.VideoScalingMode
int getVideoScalingMode();
/**
* Sets a {@link C.VideoChangeFrameRateStrategy} that will be used by the player when provided
* with a video output {@link Surface}.
*
* <p>The strategy only applies if a {@link MediaCodec}-based video {@link Renderer} is enabled.
* Applications wishing to use {@link Surface#CHANGE_FRAME_RATE_ALWAYS} should set the mode to
* {@link C#VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF} to disable calls to {@link Surface#setFrameRate}
* from ExoPlayer, and should then call {@link Surface#setFrameRate} directly from application
* code.
*
* @param videoChangeFrameRateStrategy A {@link C.VideoChangeFrameRateStrategy}.
*/
void setVideoChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy);
/** Returns the {@link C.VideoChangeFrameRateStrategy}. */
@C.VideoChangeFrameRateStrategy
int getVideoChangeFrameRateStrategy();
/**
* Sets a listener to receive video frame metadata events.
*
* <p>This method is intended to be called by the same component that sets the {@link Surface}
* onto which video will be rendered. If using ExoPlayer's standard UI components, this method
* should not be called directly from application code.
*
* @param listener The listener.
*/
void setVideoFrameMetadataListener(VideoFrameMetadataListener listener);
/**
* Clears the listener which receives video frame metadata events if it matches the one passed.
* Else does nothing.
*
* @param listener The listener to clear.
*/
void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener);
/**
* Sets a listener of camera motion events.
*
* @param listener The listener.
*/
void setCameraMotionListener(CameraMotionListener listener);
/**
* Clears the listener which receives camera motion events if it matches the one passed. Else does
* nothing.
*
* @param listener The listener to clear.
*/
void clearCameraMotionListener(CameraMotionListener listener);
/** /**
* Creates a message that can be sent to a {@link PlayerMessage.Target}. By default, the message * Creates a message that can be sent to a {@link PlayerMessage.Target}. By default, the message
* will be delivered immediately without blocking on the playback thread. The default {@link * will be delivered immediately without blocking on the playback thread. The default {@link

View file

@ -42,7 +42,9 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoSize; import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.util.List; import java.util.List;
/** /**
@ -58,6 +60,7 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
@Deprecated
public VideoComponent getVideoComponent() { public VideoComponent getVideoComponent() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -313,6 +316,46 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void setVideoScalingMode(int videoScalingMode) {
throw new UnsupportedOperationException();
}
@Override
public int getVideoScalingMode() {
throw new UnsupportedOperationException();
}
@Override
public void setVideoChangeFrameRateStrategy(int videoChangeFrameRateStrategy) {
throw new UnsupportedOperationException();
}
@Override
public int getVideoChangeFrameRateStrategy() {
throw new UnsupportedOperationException();
}
@Override
public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener) {
throw new UnsupportedOperationException();
}
@Override
public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener) {
throw new UnsupportedOperationException();
}
@Override
public void setCameraMotionListener(CameraMotionListener listener) {
throw new UnsupportedOperationException();
}
@Override
public void clearCameraMotionListener(CameraMotionListener listener) {
throw new UnsupportedOperationException();
}
@Override @Override
public void setShuffleModeEnabled(boolean shuffleModeEnabled) { public void setShuffleModeEnabled(boolean shuffleModeEnabled) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();