-
- All Implemented Interfaces:
-
java.lang.Runnable
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) public class RenderThread extends HandlerThread
RenderThread waits for the SphericalVideoPlayer's SurfaceTexture to be available then sets up a GL rendering context, creates an external texture for the video decoder to output to, asks for vsync updates from the Choreographer, attaches a frame available listener the video decode SurfaceTexture, then begins video playback.
Drag events from the main thread will be forwarded to the RenderThread's message queue so that it may update the view state.
SphericalSceneRenderer draws the 360 video scene each frame using the latest latched video texture frame.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
MSG_SURFACE_AVAILABLE
public final static int
MSG_SURFACE_CHANGED
public final static int
MSG_SURFACE_DESTROYED
public final static int
MSG_FRAME_AVAILABLE
public final static int
MSG_VSYNC
public final static int
MSG_ON_SCROLL
public final static int
MSG_SET_POSITION
public final static float
FOVY
public final static float
Z_NEAR
public final static float
Z_FAR
private SurfaceTexture.OnFrameAvailableListener
onFrameAvailableListener
-
Constructor Summary
Constructors Constructor Description RenderThread(RenderView renderView)
Constructs a new 360 video renderer.
-
Method Summary
Modifier and Type Method Description void
setOnFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener onFrameAvailableListener)
boolean
isVrMode()
Checks whether the renderer is currently configured to render the video in Google VR mode. void
setVrMode(boolean vrMode)
Sets whether the renderer should render the video in Google VR mode. void
notifySurfaceAvailable(Object surface, int width, int height)
Notifies the video render thread that the surface is available. void
notifySurfaceChanged(Surface surface, int width, int height)
Notifies the video render thread that the surface has changed. void
notifySurfaceDestroyed()
Notifies the video render thread that the surface has been destroyed. synchronized void
start()
Starts the render thread to run asynchronously. Surface
getVideoDecodeSurface()
Creates a new Surface that will be used to render the 360 video. -
Methods inherited from class android.os.HandlerThread
getLooper, getThreadId, quit, quitSafely, run
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, start, stop, suspend, toString, yield
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
RenderThread
RenderThread(RenderView renderView)
Constructs a new 360 video renderer.- Parameters:
renderView
- reference the surface view that owns this render thread.
-
-
Method Detail
-
setOnFrameAvailableListener
void setOnFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener onFrameAvailableListener)
-
isVrMode
boolean isVrMode()
Checks whether the renderer is currently configured to render the video in Google VR mode.
-
setVrMode
void setVrMode(boolean vrMode)
Sets whether the renderer should render the video in Google VR mode.
- Parameters:
vrMode
- true if Google VR mode should be enabled, otherwise false.
-
notifySurfaceAvailable
void notifySurfaceAvailable(Object surface, int width, int height)
Notifies the video render thread that the surface is available.
- Parameters:
surface
- reference to a android.view.SurfaceView or {android.view.TextureViewwidth
- the width of the surface.height
- the height of the surface.
-
notifySurfaceChanged
void notifySurfaceChanged(Surface surface, int width, int height)
Notifies the video render thread that the surface has changed.
- Parameters:
surface
- reference to a android.view.SurfaceView or {android.view.TextureViewwidth
- the new width of the surface.height
- the new height of the surface.
-
notifySurfaceDestroyed
void notifySurfaceDestroyed()
Notifies the video render thread that the surface has been destroyed.
-
start
synchronized void start()
Starts the render thread to run asynchronously.Overrides the base implementation to
-
getVideoDecodeSurface
Surface getVideoDecodeSurface()
Creates a new Surface that will be used to render the 360 video.
-
-
-
-