Agora Java API Reference for Android
|
Public Member Functions | |
TextureSource (EglBase.Context sharedContext, int width, int height) | |
boolean | onInitialize (IVideoFrameConsumer observer) |
boolean | onStart () |
void | onStop () |
void | onDispose () |
int | getBufferType () |
void | onTextureFrameAvailable (int oesTextureId, float[] transformMatrix, long timestampNs) |
SurfaceTexture | getSurfaceTexture () |
EglBase.Context | getEglContext () |
void | release () |
Protected Member Functions | |
abstract boolean | onCapturerOpened () |
abstract boolean | onCapturerStarted () |
abstract void | onCapturerStopped () |
abstract void | onCapturerClosed () |
Protected Attributes | |
WeakReference< IVideoFrameConsumer > | mConsumer |
SurfaceTextureHelper | mSurfaceTextureHelper |
int | mWidth |
int | mHeight |
int | mPixelFormat |
The TextureSource interface includes SurfaceTextureHelper and IVideoFrameConsumer methods to implement customized textured video source operations.
SurfaceTexture can be created by SurfaceTextureHelper, and used to capture a video frame and convert it into a texture to be sent to RtcEngine. With the TextureSource interface, you only need to care about the following:
boolean io.agora.rtc.mediaio.TextureSource.onInitialize | ( | IVideoFrameConsumer | observer | ) |
Initializes the video source.
You can enable the camera or initialize the video source and then pass the return value to inform the media engine whether the video source is ready.
mConsumer | The IVideoFrameConsumer object that the media engine passes to you. You need to reserve this object, and pass the video frame to the media engine through this object once the video source is initialized. |
Implements io.agora.rtc.mediaio.IVideoSource.
boolean io.agora.rtc.mediaio.TextureSource.onStart | ( | ) |
Enables the video source.
The SDK triggers this callback when the underlying media engine is ready to start video streaming. You should start the video source to capture the video frame. Once the frame is ready, use IVideoFrameConsumer to consume the video frame.
Implements io.agora.rtc.mediaio.IVideoSource.
void io.agora.rtc.mediaio.TextureSource.onStop | ( | ) |
Stops the video source.
The SDK triggers this callback when the media engine stops streaming. You should then stop capturing and consuming the video frame. After calling this method, the video frames are discarded by the media engine.
Implements io.agora.rtc.mediaio.IVideoSource.
void io.agora.rtc.mediaio.TextureSource.onDispose | ( | ) |
Releases the video source.
The SDK triggers this callback when IVideoFrameConsumer is released by the media engine. You can now release the video source as well as IVideoFrameconsumer.
Implements io.agora.rtc.mediaio.IVideoSource.
int io.agora.rtc.mediaio.TextureSource.getBufferType | ( | ) |
Gets the buffer type.
The SDK triggers this callback to get the buffer type of the video source when it is being initialized. You need to specify one buffer type and then pass it to the media engine.
Implements io.agora.rtc.mediaio.IVideoSource.
void io.agora.rtc.mediaio.TextureSource.onTextureFrameAvailable | ( | int | oesTextureId, |
float [] | transformMatrix, | ||
long | timestampNs | ||
) |
Monitors SurfaceTexture.
This method creates a listener to monitor the new video frame of SurfaceTexture, and starts or ends monitoring by calling startListening or stopListening.
Implements io.agora.rtc.mediaio.SurfaceTextureHelper.OnTextureFrameAvailableListener.
SurfaceTexture io.agora.rtc.mediaio.TextureSource.getSurfaceTexture | ( | ) |
Gets SurfaceTexture.
This method gets the created texture. If you are in the GL environment or a thread is required, call getEglContext and getHandler.
EglBase.Context io.agora.rtc.mediaio.TextureSource.getEglContext | ( | ) |
Gets EGLContextHandle.
The SDK triggers this callback to return the native handle of EGLContext if you are using OpenGL and have your own EGLContxt. You can share your EGLContext using the Texture ID returned by the SDK in your own EGLContext.
void io.agora.rtc.mediaio.TextureSource.release | ( | ) |
Releases SurfaceTexture.
Call this method to release relevant resources when SurfaceTexture is no longer needed.