Skip to content

Commit

Permalink
Remove VideoDecoderOutputBufferRenderer from Player interface
Browse files Browse the repository at this point in the history
The VideoDecoderOutputBufferRenderer will be set
automatically when setVideoSurfaceView is called on a
VideoDecoderGLSurfaceView.

#player-to-common

PiperOrigin-RevId: 351742601
  • Loading branch information
krocard authored and icbaker committed Jan 15, 2021
1 parent 6084a55 commit 789a211
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 69 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
`MediaItem.playbackProperties.subtitles`
([#8430](https://github.com/google/ExoPlayer/issues/8430)).
* Remove `ExoPlaybackException.OutOfMemoryError`.
* Remove `setVideoDecoderOutputBufferRenderer` from Player API.
Clients should use `setOutputSurface` directly instead.
* Extractors:
* Populate codecs string for H.264/AVC in MP4, Matroska and FLV streams to
allow decoder capability checks based on codec profile/level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.google.android.exoplayer2.trackselection.TrackSelectorInterface;
import com.google.android.exoplayer2.util.MutableFlags;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
Expand Down Expand Up @@ -310,30 +309,6 @@ interface VideoComponent {
* @param textureView The texture view to clear.
*/
void clearVideoTextureView(@Nullable TextureView textureView);

/**
* Sets the video decoder output buffer renderer. This is intended for use only with extension
* renderers that accept {@link Renderer#MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER}. For most
* use cases, an output surface or view should be passed via {@link #setVideoSurface(Surface)}
* or {@link #setVideoSurfaceView(SurfaceView)} instead.
*
* @param videoDecoderOutputBufferRenderer The video decoder output buffer renderer, or {@code
* null} to clear the output buffer renderer.
*/
void setVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer);

/** Clears the video decoder output buffer renderer. */
void clearVideoDecoderOutputBufferRenderer();

/**
* Clears the video decoder output buffer renderer if it matches the one passed. Else does
* nothing.
*
* @param videoDecoderOutputBufferRenderer The video decoder output buffer renderer to clear.
*/
void clearVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer);
}

/** The text component of a {@link Player}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
Expand Down Expand Up @@ -590,7 +591,6 @@ public SimpleExoPlayer build() {
@Nullable private Format videoFormat;
@Nullable private Format audioFormat;
@Nullable private AudioTrack keepSessionIdAudioTrack;
@Nullable private VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer;
@Nullable private Surface surface;
private boolean ownsSurface;
@C.VideoScalingMode private int videoScalingMode;
Expand Down Expand Up @@ -804,7 +804,7 @@ public void setVideoSurface(@Nullable Surface surface) {
verifyApplicationThread();
removeSurfaceCallbacks();
if (surface != null) {
clearVideoDecoderOutputBufferRenderer();
setVideoDecoderOutputBufferRenderer(/* videoDecoderOutputBufferRenderer= */ null);
}
setVideoSurfaceInternal(surface, /* ownsSurface= */ false);
int newSurfaceSize = surface == null ? 0 : C.LENGTH_UNSET;
Expand All @@ -816,7 +816,7 @@ public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {
verifyApplicationThread();
removeSurfaceCallbacks();
if (surfaceHolder != null) {
clearVideoDecoderOutputBufferRenderer();
setVideoDecoderOutputBufferRenderer(/* videoDecoderOutputBufferRenderer= */ null);
}
this.surfaceHolder = surfaceHolder;
if (surfaceHolder == null) {
Expand Down Expand Up @@ -846,20 +846,37 @@ public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder) {

@Override
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView) {
setVideoSurfaceHolder(surfaceView == null ? null : surfaceView.getHolder());
verifyApplicationThread();
if (surfaceView instanceof VideoDecoderGLSurfaceView) {
VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer =
((VideoDecoderGLSurfaceView) surfaceView).getVideoDecoderOutputBufferRenderer();
clearVideoSurface();
surfaceHolder = surfaceView.getHolder();
setVideoDecoderOutputBufferRenderer(videoDecoderOutputBufferRenderer);
} else {
setVideoSurfaceHolder(surfaceView == null ? null : surfaceView.getHolder());
}
}

@Override
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView) {
clearVideoSurfaceHolder(surfaceView == null ? null : surfaceView.getHolder());
verifyApplicationThread();
if (surfaceView instanceof VideoDecoderGLSurfaceView) {
if (surfaceView.getHolder() == surfaceHolder) {
setVideoDecoderOutputBufferRenderer(null);
surfaceHolder = null;
}
} else {
clearVideoSurfaceHolder(surfaceView == null ? null : surfaceView.getHolder());
}
}

@Override
public void setVideoTextureView(@Nullable TextureView textureView) {
verifyApplicationThread();
removeSurfaceCallbacks();
if (textureView != null) {
clearVideoDecoderOutputBufferRenderer();
setVideoDecoderOutputBufferRenderer(/* videoDecoderOutputBufferRenderer= */ null);
}
this.textureView = textureView;
if (textureView == null) {
Expand Down Expand Up @@ -890,32 +907,6 @@ public void clearVideoTextureView(@Nullable TextureView textureView) {
}
}

@Override
public void setVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer) {
verifyApplicationThread();
if (videoDecoderOutputBufferRenderer != null) {
clearVideoSurface();
}
setVideoDecoderOutputBufferRendererInternal(videoDecoderOutputBufferRenderer);
}

@Override
public void clearVideoDecoderOutputBufferRenderer() {
verifyApplicationThread();
setVideoDecoderOutputBufferRendererInternal(/* videoDecoderOutputBufferRenderer= */ null);
}

@Override
public void clearVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer) {
verifyApplicationThread();
if (videoDecoderOutputBufferRenderer != null
&& videoDecoderOutputBufferRenderer == this.videoDecoderOutputBufferRenderer) {
clearVideoDecoderOutputBufferRenderer();
}
}

@Override
public void addAudioListener(AudioListener listener) {
// Don't verify application thread. We allow calls to this method from any thread.
Expand Down Expand Up @@ -1945,13 +1936,12 @@ private void setVideoSurfaceInternal(@Nullable Surface surface, boolean ownsSurf
this.ownsSurface = ownsSurface;
}

private void setVideoDecoderOutputBufferRendererInternal(
private void setVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer) {
sendRendererMessage(
C.TRACK_TYPE_VIDEO,
Renderer.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER,
videoDecoderOutputBufferRenderer);
this.videoDecoderOutputBufferRenderer = videoDecoderOutputBufferRenderer;
}

private void maybeNotifySurfaceSizeChanged(int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,6 @@ public void setPlayer(@Nullable Player player) {
oldVideoComponent.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).setVideoComponent(null);
} else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
oldVideoComponent.setVideoDecoderOutputBufferRenderer(null);
} else if (surfaceView instanceof SurfaceView) {
oldVideoComponent.clearVideoSurfaceView((SurfaceView) surfaceView);
}
Expand All @@ -600,9 +598,6 @@ public void setPlayer(@Nullable Player player) {
newVideoComponent.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).setVideoComponent(newVideoComponent);
} else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
newVideoComponent.setVideoDecoderOutputBufferRenderer(
((VideoDecoderGLSurfaceView) surfaceView).getVideoDecoderOutputBufferRenderer());
} else if (surfaceView instanceof SurfaceView) {
newVideoComponent.setVideoSurfaceView((SurfaceView) surfaceView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,6 @@ public void setPlayer(@Nullable Player player) {
oldVideoComponent.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).setVideoComponent(null);
} else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
oldVideoComponent.setVideoDecoderOutputBufferRenderer(null);
} else if (surfaceView instanceof SurfaceView) {
oldVideoComponent.clearVideoSurfaceView((SurfaceView) surfaceView);
}
Expand All @@ -609,9 +607,6 @@ public void setPlayer(@Nullable Player player) {
newVideoComponent.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalGLSurfaceView) surfaceView).setVideoComponent(newVideoComponent);
} else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
newVideoComponent.setVideoDecoderOutputBufferRenderer(
((VideoDecoderGLSurfaceView) surfaceView).getVideoDecoderOutputBufferRenderer());
} else if (surfaceView instanceof SurfaceView) {
newVideoComponent.setVideoSurfaceView((SurfaceView) surfaceView);
}
Expand Down

0 comments on commit 789a211

Please sign in to comment.