Commit 656556b8 by andrewlewis Committed by Oliver Woodman

Clean up naming for GLSurfaceViews

PiperOrigin-RevId: 277896757
parent 242a0053
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
`C.MSG_SET_OUTPUT_BUFFER_RENDERER`. `C.MSG_SET_OUTPUT_BUFFER_RENDERER`.
* Use `VideoDecoderRenderer` as an implementation of * Use `VideoDecoderRenderer` as an implementation of
`VideoDecoderOutputBufferRenderer`, instead of `VideoDecoderSurfaceView`. `VideoDecoderOutputBufferRenderer`, instead of `VideoDecoderSurfaceView`.
* Rename `spherical_view` surface type to `spherical_gl_surface_view`.
* Add automatic audio becoming noisy handling to `SimpleExoPlayer`, * Add automatic audio becoming noisy handling to `SimpleExoPlayer`,
available through `SimpleExoPlayer.setHandleAudioBecomingNoisy`. available through `SimpleExoPlayer.setHandleAudioBecomingNoisy`.
* Post `AudioFocusManager.onAudioFocusChange` events to eventHandler, avoiding * Post `AudioFocusManager.onAudioFocusChange` events to eventHandler, avoiding
......
...@@ -69,7 +69,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray; ...@@ -69,7 +69,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.DebugTextViewHelper; import com.google.android.exoplayer2.ui.DebugTextViewHelper;
import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.ui.spherical.SphericalSurfaceView; import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.util.ErrorMessageProvider; import com.google.android.exoplayer2.util.ErrorMessageProvider;
...@@ -193,7 +193,7 @@ public class PlayerActivity extends AppCompatActivity ...@@ -193,7 +193,7 @@ public class PlayerActivity extends AppCompatActivity
finish(); finish();
return; return;
} }
((SphericalSurfaceView) playerView.getVideoSurfaceView()).setDefaultStereoMode(stereoMode); ((SphericalGLSurfaceView) playerView.getVideoSurfaceView()).setDefaultStereoMode(stereoMode);
} }
if (savedInstanceState != null) { if (savedInstanceState != null) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</style> </style>
<style name="PlayerTheme.Spherical"> <style name="PlayerTheme.Spherical">
<item name="surface_type">spherical_view</item> <item name="surface_type">spherical_gl_surface_view</item>
</style> </style>
</resources> </resources>
...@@ -96,9 +96,10 @@ gets from the libgav1 decoder: ...@@ -96,9 +96,10 @@ gets from the libgav1 decoder:
* GL rendering using GL shader for color space conversion * GL rendering using GL shader for color space conversion
* If you are using `SimpleExoPlayer` with `PlayerView`, enable this option by * If you are using `SimpleExoPlayer` with `PlayerView`, enable this option by
setting `surface_type` of `PlayerView` to be `video_decoder_surface_view`. setting `surface_type` of `PlayerView` to be
`video_decoder_gl_surface_view`.
* Otherwise, enable this option by sending `Libgav1VideoRenderer` a message * Otherwise, enable this option by sending `Libgav1VideoRenderer` a message
of type `C.MSG_SET_OUTPUT_BUFFER_RENDERER` with an instance of of type `C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER` with an instance of
`VideoDecoderOutputBufferRenderer` as its object. `VideoDecoderOutputBufferRenderer` as its object.
* Native rendering using `ANativeWindow` * Native rendering using `ANativeWindow`
......
...@@ -47,8 +47,8 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener; ...@@ -47,8 +47,8 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
* <ul> * <ul>
* <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload * <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload
* should be the target {@link Surface}, or null. * should be the target {@link Surface}, or null.
* <li>Message with type {@link C#MSG_SET_OUTPUT_BUFFER_RENDERER} to set the output buffer * <li>Message with type {@link C#MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
* renderer. The message payload should be the target {@link * buffer renderer. The message payload should be the target {@link
* VideoDecoderOutputBufferRenderer}, or null. * VideoDecoderOutputBufferRenderer}, or null.
* </ul> * </ul>
*/ */
...@@ -186,7 +186,7 @@ public class Libgav1VideoRenderer extends SimpleDecoderVideoRenderer { ...@@ -186,7 +186,7 @@ public class Libgav1VideoRenderer extends SimpleDecoderVideoRenderer {
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException { public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
if (messageType == C.MSG_SET_SURFACE) { if (messageType == C.MSG_SET_SURFACE) {
setOutputSurface((Surface) message); setOutputSurface((Surface) message);
} else if (messageType == C.MSG_SET_OUTPUT_BUFFER_RENDERER) { } else if (messageType == C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message); setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message);
} else { } else {
super.handleMessage(messageType, message); super.handleMessage(messageType, message);
......
...@@ -114,9 +114,10 @@ gets from the libvpx decoder: ...@@ -114,9 +114,10 @@ gets from the libvpx decoder:
* GL rendering using GL shader for color space conversion * GL rendering using GL shader for color space conversion
* If you are using `SimpleExoPlayer` with `PlayerView`, enable this option by * If you are using `SimpleExoPlayer` with `PlayerView`, enable this option by
setting `surface_type` of `PlayerView` to be `video_decoder_surface_view`. setting `surface_type` of `PlayerView` to be
`video_decoder_gl_surface_view`.
* Otherwise, enable this option by sending `LibvpxVideoRenderer` a message of * Otherwise, enable this option by sending `LibvpxVideoRenderer` a message of
type `C.MSG_SET_OUTPUT_BUFFER_RENDERER` with an instance of type `C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER` with an instance of
`VideoDecoderOutputBufferRenderer` as its object. `VideoDecoderOutputBufferRenderer` as its object.
* Native rendering using `ANativeWindow` * Native rendering using `ANativeWindow`
......
...@@ -32,7 +32,7 @@ import com.google.android.exoplayer2.source.MediaSource; ...@@ -32,7 +32,7 @@ import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.video.VideoDecoderSurfaceView; import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -123,8 +123,8 @@ public class VpxPlaybackTest { ...@@ -123,8 +123,8 @@ public class VpxPlaybackTest {
.createMediaSource(uri); .createMediaSource(uri);
player player
.createMessage(videoRenderer) .createMessage(videoRenderer)
.setType(C.MSG_SET_OUTPUT_BUFFER_RENDERER) .setType(C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER)
.setPayload(new VideoDecoderSurfaceView(context).getOutputBufferRenderer()) .setPayload(new VideoDecoderGLSurfaceView(context).getVideoDecoderOutputBufferRenderer())
.send(); .send();
player.prepare(mediaSource); player.prepare(mediaSource);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
......
...@@ -47,8 +47,8 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener; ...@@ -47,8 +47,8 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
* <ul> * <ul>
* <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload * <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload
* should be the target {@link Surface}, or null. * should be the target {@link Surface}, or null.
* <li>Message with type {@link C#MSG_SET_OUTPUT_BUFFER_RENDERER} to set the output buffer * <li>Message with type {@link C#MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
* renderer. The message payload should be the target {@link * buffer renderer. The message payload should be the target {@link
* VideoDecoderOutputBufferRenderer}, or null. * VideoDecoderOutputBufferRenderer}, or null.
* </ul> * </ul>
*/ */
...@@ -267,7 +267,7 @@ public class LibvpxVideoRenderer extends SimpleDecoderVideoRenderer { ...@@ -267,7 +267,7 @@ public class LibvpxVideoRenderer extends SimpleDecoderVideoRenderer {
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException { public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
if (messageType == C.MSG_SET_SURFACE) { if (messageType == C.MSG_SET_SURFACE) {
setOutputSurface((Surface) message); setOutputSurface((Surface) message);
} else if (messageType == C.MSG_SET_OUTPUT_BUFFER_RENDERER) { } else if (messageType == C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message); setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message);
} else if (messageType == C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER) { } else if (messageType == C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER) {
frameMetadataListener = (VideoFrameMetadataListener) message; frameMetadataListener = (VideoFrameMetadataListener) message;
......
...@@ -834,8 +834,12 @@ public final class C { ...@@ -834,8 +834,12 @@ public final class C {
* The type of a message that can be passed to a {@link SimpleDecoderVideoRenderer} via {@link * The type of a message that can be passed to a {@link SimpleDecoderVideoRenderer} via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be the target {@link * ExoPlayer#createMessage(Target)}. The message payload should be the target {@link
* VideoDecoderOutputBufferRenderer}, or null. * VideoDecoderOutputBufferRenderer}, or null.
*
* <p>This message is intended only for use with extension renderers that expect a {@link
* VideoDecoderOutputBufferRenderer}. For other use cases, an output surface should be passed via
* {@link #MSG_SET_SURFACE} instead.
*/ */
public static final int MSG_SET_OUTPUT_BUFFER_RENDERER = 8; public static final int MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER = 8;
/** /**
* 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
......
...@@ -283,11 +283,16 @@ public interface Player { ...@@ -283,11 +283,16 @@ public interface Player {
void clearVideoTextureView(TextureView textureView); void clearVideoTextureView(TextureView textureView);
/** /**
* Sets the output buffer renderer. * Sets the video decoder output buffer renderer. This is intended for use only with extension
* renderers that accept {@link C#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 outputBufferRenderer The output buffer renderer. * @param videoDecoderOutputBufferRenderer The video decoder output buffer renderer, or {@code
* null} to clear the output buffer renderer.
*/ */
void setOutputBufferRenderer(VideoDecoderOutputBufferRenderer outputBufferRenderer); void setVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer);
} }
/** The text component of a {@link Player}. */ /** The text component of a {@link Player}. */
......
...@@ -610,15 +610,16 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -610,15 +610,16 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void setOutputBufferRenderer(VideoDecoderOutputBufferRenderer outputBufferRenderer) { public void setVideoDecoderOutputBufferRenderer(
@Nullable VideoDecoderOutputBufferRenderer videoDecoderOutputBufferRenderer) {
verifyApplicationThread(); verifyApplicationThread();
setVideoSurface(null); setVideoSurface(null);
for (Renderer renderer : renderers) { for (Renderer renderer : renderers) {
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) { if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
player player
.createMessage(renderer) .createMessage(renderer)
.setType(C.MSG_SET_OUTPUT_BUFFER_RENDERER) .setType(C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER)
.setPayload(outputBufferRenderer) .setPayload(videoDecoderOutputBufferRenderer)
.send(); .send();
} }
} }
......
...@@ -20,27 +20,28 @@ import android.opengl.GLSurfaceView; ...@@ -20,27 +20,28 @@ import android.opengl.GLSurfaceView;
import android.util.AttributeSet; import android.util.AttributeSet;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** A GLSurfaceView extension that scales itself to the given aspect ratio. */ /**
public class VideoDecoderSurfaceView extends GLSurfaceView { * GLSurfaceView for rendering video output. To render video in this view, call {@link
* #getVideoDecoderOutputBufferRenderer()} to get a {@link VideoDecoderOutputBufferRenderer} that
* will render video decoder output buffers in this view.
*
* <p>This view is intended for use only with extension renderers. For other use cases a {@link
* android.view.SurfaceView} or {@link android.view.TextureView} should be used instead.
*/
public class VideoDecoderGLSurfaceView extends GLSurfaceView {
private final VideoDecoderRenderer renderer; private final VideoDecoderRenderer renderer;
/** /** @param context A {@link Context}. */
* Creates VideoDecoderSurfaceView. public VideoDecoderGLSurfaceView(Context context) {
*
* @param context A {@link Context}.
*/
public VideoDecoderSurfaceView(Context context) {
this(context, /* attrs= */ null); this(context, /* attrs= */ null);
} }
/** /**
* Creates VideoDecoderSurfaceView.
*
* @param context A {@link Context}. * @param context A {@link Context}.
* @param attrs Custom attributes. * @param attrs Custom attributes.
*/ */
public VideoDecoderSurfaceView(Context context, @Nullable AttributeSet attrs) { public VideoDecoderGLSurfaceView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs); super(context, attrs);
renderer = new VideoDecoderRenderer(this); renderer = new VideoDecoderRenderer(this);
setPreserveEGLContextOnPause(true); setPreserveEGLContextOnPause(true);
...@@ -49,12 +50,8 @@ public class VideoDecoderSurfaceView extends GLSurfaceView { ...@@ -49,12 +50,8 @@ public class VideoDecoderSurfaceView extends GLSurfaceView {
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
} }
/** /** Returns the {@link VideoDecoderOutputBufferRenderer} that will render frames in this view. */
* Returns the output buffer renderer used. public VideoDecoderOutputBufferRenderer getVideoDecoderOutputBufferRenderer() {
*
* @return {@link VideoDecoderOutputBuffer}.
*/
public VideoDecoderOutputBufferRenderer getOutputBufferRenderer() {
return renderer; return renderer;
} }
} }
...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.video; ...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.video;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.GlUtil;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
...@@ -97,6 +98,7 @@ import javax.microedition.khronos.opengles.GL10; ...@@ -97,6 +98,7 @@ import javax.microedition.khronos.opengles.GL10;
private int[] previousWidths; private int[] previousWidths;
private int[] previousStrides; private int[] previousStrides;
@Nullable
private VideoDecoderOutputBuffer renderedOutputBuffer; // Accessed only from the GL thread. private VideoDecoderOutputBuffer renderedOutputBuffer; // Accessed only from the GL thread.
public VideoDecoderRenderer(GLSurfaceView surfaceView) { public VideoDecoderRenderer(GLSurfaceView surfaceView) {
......
...@@ -59,12 +59,12 @@ import com.google.android.exoplayer2.trackselection.TrackSelection; ...@@ -59,12 +59,12 @@ import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
import com.google.android.exoplayer2.ui.spherical.SingleTapListener; import com.google.android.exoplayer2.ui.spherical.SingleTapListener;
import com.google.android.exoplayer2.ui.spherical.SphericalSurfaceView; import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ErrorMessageProvider; import com.google.android.exoplayer2.util.ErrorMessageProvider;
import com.google.android.exoplayer2.util.RepeatModeUtil; import com.google.android.exoplayer2.util.RepeatModeUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderSurfaceView; import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
import com.google.android.exoplayer2.video.VideoListener; import com.google.android.exoplayer2.video.VideoListener;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
...@@ -131,11 +131,11 @@ import java.util.List; ...@@ -131,11 +131,11 @@ import java.util.List;
* <li>Default: {@code fit} * <li>Default: {@code fit}
* </ul> * </ul>
* <li><b>{@code surface_type}</b> - The type of surface view used for video playbacks. Valid * <li><b>{@code surface_type}</b> - The type of surface view used for video playbacks. Valid
* values are {@code surface_view}, {@code texture_view}, {@code spherical_view} and {@code * values are {@code surface_view}, {@code texture_view}, {@code spherical_gl_surface_view},
* none}. Using {@code none} is recommended for audio only applications, since creating the * {@code video_decoder_gl_surface_view} and {@code none}. Using {@code none} is recommended
* surface can be expensive. Using {@code surface_view} is recommended for video applications. * for audio only applications, since creating the surface can be expensive. Using {@code
* Note, TextureView can only be used in a hardware accelerated window. When rendered in * surface_view} is recommended for video applications. Note, TextureView can only be used in
* software, TextureView will draw nothing. * a hardware accelerated window. When rendered in software, TextureView will draw nothing.
* <ul> * <ul>
* <li>Corresponding method: None * <li>Corresponding method: None
* <li>Default: {@code surface_view} * <li>Default: {@code surface_view}
...@@ -276,8 +276,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -276,8 +276,8 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
private static final int SURFACE_TYPE_NONE = 0; private static final int SURFACE_TYPE_NONE = 0;
private static final int SURFACE_TYPE_SURFACE_VIEW = 1; private static final int SURFACE_TYPE_SURFACE_VIEW = 1;
private static final int SURFACE_TYPE_TEXTURE_VIEW = 2; private static final int SURFACE_TYPE_TEXTURE_VIEW = 2;
private static final int SURFACE_TYPE_MONO360_VIEW = 3; private static final int SURFACE_TYPE_SPHERICAL_GL_SURFACE_VIEW = 3;
private static final int SURFACE_TYPE_VIDEO_GL_SURFACE_VIEW = 4; private static final int SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW = 4;
// LINT.ThenChange(../../../../../../res/values/attrs.xml) // LINT.ThenChange(../../../../../../res/values/attrs.xml)
@Nullable private final AspectRatioFrameLayout contentFrame; @Nullable private final AspectRatioFrameLayout contentFrame;
...@@ -409,13 +409,13 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -409,13 +409,13 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
case SURFACE_TYPE_TEXTURE_VIEW: case SURFACE_TYPE_TEXTURE_VIEW:
surfaceView = new TextureView(context); surfaceView = new TextureView(context);
break; break;
case SURFACE_TYPE_MONO360_VIEW: case SURFACE_TYPE_SPHERICAL_GL_SURFACE_VIEW:
SphericalSurfaceView sphericalSurfaceView = new SphericalSurfaceView(context); SphericalGLSurfaceView sphericalGLSurfaceView = new SphericalGLSurfaceView(context);
sphericalSurfaceView.setSingleTapListener(componentListener); sphericalGLSurfaceView.setSingleTapListener(componentListener);
surfaceView = sphericalSurfaceView; surfaceView = sphericalGLSurfaceView;
break; break;
case SURFACE_TYPE_VIDEO_GL_SURFACE_VIEW: case SURFACE_TYPE_VIDEO_DECODER_GL_SURFACE_VIEW:
surfaceView = new VideoDecoderSurfaceView(context); surfaceView = new VideoDecoderGLSurfaceView(context);
break; break;
default: default:
surfaceView = new SurfaceView(context); surfaceView = new SurfaceView(context);
...@@ -547,10 +547,10 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -547,10 +547,10 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
oldVideoComponent.removeVideoListener(componentListener); oldVideoComponent.removeVideoListener(componentListener);
if (surfaceView instanceof TextureView) { if (surfaceView instanceof TextureView) {
oldVideoComponent.clearVideoTextureView((TextureView) surfaceView); oldVideoComponent.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalSurfaceView) { } else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalSurfaceView) surfaceView).setVideoComponent(null); ((SphericalGLSurfaceView) surfaceView).setVideoComponent(null);
} else if (surfaceView instanceof VideoDecoderSurfaceView) { } else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
oldVideoComponent.setOutputBufferRenderer(null); oldVideoComponent.setVideoDecoderOutputBufferRenderer(null);
} else if (surfaceView instanceof SurfaceView) { } else if (surfaceView instanceof SurfaceView) {
oldVideoComponent.clearVideoSurfaceView((SurfaceView) surfaceView); oldVideoComponent.clearVideoSurfaceView((SurfaceView) surfaceView);
} }
...@@ -575,11 +575,11 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -575,11 +575,11 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
if (newVideoComponent != null) { if (newVideoComponent != null) {
if (surfaceView instanceof TextureView) { if (surfaceView instanceof TextureView) {
newVideoComponent.setVideoTextureView((TextureView) surfaceView); newVideoComponent.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SphericalSurfaceView) { } else if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalSurfaceView) surfaceView).setVideoComponent(newVideoComponent); ((SphericalGLSurfaceView) surfaceView).setVideoComponent(newVideoComponent);
} else if (surfaceView instanceof VideoDecoderSurfaceView) { } else if (surfaceView instanceof VideoDecoderGLSurfaceView) {
newVideoComponent.setOutputBufferRenderer( newVideoComponent.setVideoDecoderOutputBufferRenderer(
((VideoDecoderSurfaceView) surfaceView).getOutputBufferRenderer()); ((VideoDecoderGLSurfaceView) surfaceView).getVideoDecoderOutputBufferRenderer());
} else if (surfaceView instanceof SurfaceView) { } else if (surfaceView instanceof SurfaceView) {
newVideoComponent.setVideoSurfaceView((SurfaceView) surfaceView); newVideoComponent.setVideoSurfaceView((SurfaceView) surfaceView);
} }
...@@ -1049,12 +1049,15 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -1049,12 +1049,15 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
* <li>{@link SurfaceView} by default, or if the {@code surface_type} attribute is set to {@code * <li>{@link SurfaceView} by default, or if the {@code surface_type} attribute is set to {@code
* surface_view}. * surface_view}.
* <li>{@link TextureView} if {@code surface_type} is {@code texture_view}. * <li>{@link TextureView} if {@code surface_type} is {@code texture_view}.
* <li>{@link SphericalSurfaceView} if {@code surface_type} is {@code spherical_view}. * <li>{@link SphericalGLSurfaceView} if {@code surface_type} is {@code
* spherical_gl_surface_view}.
* <li>{@link VideoDecoderGLSurfaceView} if {@code surface_type} is {@code
* video_decoder_gl_surface_view}.
* <li>{@code null} if {@code surface_type} is {@code none}. * <li>{@code null} if {@code surface_type} is {@code none}.
* </ul> * </ul>
* *
* @return The {@link SurfaceView}, {@link TextureView}, {@link SphericalSurfaceView} or {@code * @return The {@link SurfaceView}, {@link TextureView}, {@link SphericalGLSurfaceView}, {@link
* null}. * VideoDecoderGLSurfaceView} or {@code null}.
*/ */
@Nullable @Nullable
public View getVideoSurfaceView() { public View getVideoSurfaceView() {
...@@ -1122,34 +1125,34 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -1122,34 +1125,34 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
/** /**
* Should be called when the player is visible to the user and if {@code surface_type} is {@code * Should be called when the player is visible to the user and if {@code surface_type} is {@code
* spherical_view}. It is the counterpart to {@link #onPause()}. * spherical_gl_surface_view}. It is the counterpart to {@link #onPause()}.
* *
* <p>This method should typically be called in {@code Activity.onStart()}, or {@code * <p>This method should typically be called in {@code Activity.onStart()}, or {@code
* Activity.onResume()} for API versions &lt;= 23. * Activity.onResume()} for API versions &lt;= 23.
*/ */
public void onResume() { public void onResume() {
if (surfaceView instanceof SphericalSurfaceView) { if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalSurfaceView) surfaceView).onResume(); ((SphericalGLSurfaceView) surfaceView).onResume();
} }
} }
/** /**
* Should be called when the player is no longer visible to the user and if {@code surface_type} * Should be called when the player is no longer visible to the user and if {@code surface_type}
* is {@code spherical_view}. It is the counterpart to {@link #onResume()}. * is {@code spherical_gl_surface_view}. It is the counterpart to {@link #onResume()}.
* *
* <p>This method should typically be called in {@code Activity.onStop()}, or {@code * <p>This method should typically be called in {@code Activity.onStop()}, or {@code
* Activity.onPause()} for API versions &lt;= 23. * Activity.onPause()} for API versions &lt;= 23.
*/ */
public void onPause() { public void onPause() {
if (surfaceView instanceof SphericalSurfaceView) { if (surfaceView instanceof SphericalGLSurfaceView) {
((SphericalSurfaceView) surfaceView).onPause(); ((SphericalGLSurfaceView) surfaceView).onPause();
} }
} }
/** /**
* Called when there's a change in the aspect ratio of the content being displayed. The default * Called when there's a change in the aspect ratio of the content being displayed. The default
* implementation sets the aspect ratio of the content frame to that of the content, unless the * implementation sets the aspect ratio of the content frame to that of the content, unless the
* content view is a {@link SphericalSurfaceView} in which case the frame's aspect ratio is * content view is a {@link SphericalGLSurfaceView} in which case the frame's aspect ratio is
* cleared. * cleared.
* *
* @param contentAspectRatio The aspect ratio of the content. * @param contentAspectRatio The aspect ratio of the content.
...@@ -1162,7 +1165,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider ...@@ -1162,7 +1165,7 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
@Nullable View contentView) { @Nullable View contentView) {
if (contentFrame != null) { if (contentFrame != null) {
contentFrame.setAspectRatio( contentFrame.setAspectRatio(
contentView instanceof SphericalSurfaceView ? 0 : contentAspectRatio); contentView instanceof SphericalGLSurfaceView ? 0 : contentAspectRatio);
} }
} }
......
...@@ -51,7 +51,7 @@ import javax.microedition.khronos.opengles.GL10; ...@@ -51,7 +51,7 @@ import javax.microedition.khronos.opengles.GL10;
* apply the touch and sensor rotations in the correct order or the user's touch manipulations won't * apply the touch and sensor rotations in the correct order or the user's touch manipulations won't
* match what they expect. * match what they expect.
*/ */
public final class SphericalSurfaceView extends GLSurfaceView { public final class SphericalGLSurfaceView extends GLSurfaceView {
// Arbitrary vertical field of view. // Arbitrary vertical field of view.
private static final int FIELD_OF_VIEW_DEGREES = 90; private static final int FIELD_OF_VIEW_DEGREES = 90;
...@@ -73,11 +73,11 @@ public final class SphericalSurfaceView extends GLSurfaceView { ...@@ -73,11 +73,11 @@ public final class SphericalSurfaceView extends GLSurfaceView {
@Nullable private Surface surface; @Nullable private Surface surface;
@Nullable private Player.VideoComponent videoComponent; @Nullable private Player.VideoComponent videoComponent;
public SphericalSurfaceView(Context context) { public SphericalGLSurfaceView(Context context) {
this(context, null); this(context, null);
} }
public SphericalSurfaceView(Context context, @Nullable AttributeSet attributeSet) { public SphericalGLSurfaceView(Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet); super(context, attributeSet);
mainHandler = new Handler(Looper.getMainLooper()); mainHandler = new Handler(Looper.getMainLooper());
......
...@@ -75,7 +75,7 @@ import androidx.annotation.Nullable; ...@@ -75,7 +75,7 @@ import androidx.annotation.Nullable;
this.listener = listener; this.listener = listener;
this.pxPerDegrees = pxPerDegrees; this.pxPerDegrees = pxPerDegrees;
gestureDetector = new GestureDetector(context, this); gestureDetector = new GestureDetector(context, this);
roll = SphericalSurfaceView.UPRIGHT_ROLL; roll = SphericalGLSurfaceView.UPRIGHT_ROLL;
} }
public void setSingleTapListener(@Nullable SingleTapListener listener) { public void setSingleTapListener(@Nullable SingleTapListener listener) {
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<enum name="none" value="0"/> <enum name="none" value="0"/>
<enum name="surface_view" value="1"/> <enum name="surface_view" value="1"/>
<enum name="texture_view" value="2"/> <enum name="texture_view" value="2"/>
<enum name="spherical_view" value="3"/> <enum name="spherical_gl_surface_view" value="3"/>
<enum name="video_decoder_surface_view" value="4"/> <enum name="video_decoder_gl_surface_view" value="4"/>
</attr> </attr>
<!-- Must be kept in sync with RepeatModeUtil --> <!-- Must be kept in sync with RepeatModeUtil -->
......
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