Package tvi.webrtc
Class SurfaceEglRenderer
java.lang.Object
tvi.webrtc.EglRenderer
tvi.webrtc.SurfaceEglRenderer
- All Implemented Interfaces:
android.view.SurfaceHolder.Callback
,VideoSink
Display the video stream on a Surface.
renderFrame() is asynchronous to avoid blocking the calling thread.
This class is thread safe and handles access from potentially three different threads:
Interaction from the main app in init, release and setMirror.
Interaction from C++ rtc::VideoSinkInterface in renderFrame.
Interaction from SurfaceHolder lifecycle in surfaceCreated, surfaceChanged, and surfaceDestroyed.
-
Nested Class Summary
Nested classes/interfaces inherited from class tvi.webrtc.EglRenderer
EglRenderer.ErrorCallback, EglRenderer.FrameListener
-
Field Summary
Fields inherited from class tvi.webrtc.EglRenderer
name
-
Constructor Summary
ConstructorDescriptionSurfaceEglRenderer
(String name) In order to render something, you must first call init(). -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
init
(EglBase.Context sharedContext, int[] configAttributes, RendererCommon.GlDrawer drawer) Same as above with usePresentationTimeStamp set to false.void
init
(EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents, int[] configAttributes, RendererCommon.GlDrawer drawer) Initialize this class, sharing resources with `sharedContext`.void
onFrame
(VideoFrame frame) Implementations should call frame.retain() if they need to hold a reference to the frame after this function returns.void
void
setFpsReduction
(float fps) Limit render framerate.void
surfaceChanged
(android.view.SurfaceHolder holder, int format, int width, int height) void
surfaceCreated
(android.view.SurfaceHolder holder) void
surfaceDestroyed
(android.view.SurfaceHolder holder) Methods inherited from class tvi.webrtc.EglRenderer
addFrameListener, addFrameListener, addFrameListener, clearImage, clearImage, createEglSurface, createEglSurface, init, printStackTrace, release, releaseEglSurface, removeFrameListener, setErrorCallback, setLayoutAspectRatio, setMirror, setMirrorVertically
-
Constructor Details
-
SurfaceEglRenderer
In order to render something, you must first call init().
-
-
Method Details
-
init
public void init(EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents, int[] configAttributes, RendererCommon.GlDrawer drawer) Initialize this class, sharing resources with `sharedContext`. The custom `drawer` will be used for drawing frames on the EGLSurface. This class is responsible for calling release() on `drawer`. It is allowed to call init() to reinitialize the renderer after a previous init()/release() cycle. -
init
public void init(EglBase.Context sharedContext, int[] configAttributes, RendererCommon.GlDrawer drawer) Description copied from class:EglRenderer
Same as above with usePresentationTimeStamp set to false.- Overrides:
init
in classEglRenderer
- See Also:
-
setFpsReduction
public void setFpsReduction(float fps) Limit render framerate.- Overrides:
setFpsReduction
in classEglRenderer
- Parameters:
fps
- Limit render framerate to this value, or use Float.POSITIVE_INFINITY to disable fps reduction.
-
disableFpsReduction
public void disableFpsReduction()- Overrides:
disableFpsReduction
in classEglRenderer
-
pauseVideo
public void pauseVideo()- Overrides:
pauseVideo
in classEglRenderer
-
onFrame
Description copied from interface:VideoSink
Implementations should call frame.retain() if they need to hold a reference to the frame after this function returns. Each call to retain() should be followed by a call to frame.release() when the reference is no longer needed.- Specified by:
onFrame
in interfaceVideoSink
- Overrides:
onFrame
in classEglRenderer
-
surfaceCreated
public void surfaceCreated(android.view.SurfaceHolder holder) - Specified by:
surfaceCreated
in interfaceandroid.view.SurfaceHolder.Callback
-
surfaceDestroyed
public void surfaceDestroyed(android.view.SurfaceHolder holder) - Specified by:
surfaceDestroyed
in interfaceandroid.view.SurfaceHolder.Callback
-
surfaceChanged
public void surfaceChanged(android.view.SurfaceHolder holder, int format, int width, int height) - Specified by:
surfaceChanged
in interfaceandroid.view.SurfaceHolder.Callback
-