Package tvi.webrtc
Class TextureBufferImpl
java.lang.Object
tvi.webrtc.TextureBufferImpl
- All Implemented Interfaces:
RefCounted
,VideoFrame.Buffer
,VideoFrame.TextureBuffer
Android texture buffer that glues together the necessary information together with a generic
release callback. ToI420() is implemented by providing a Handler and a YuvConverter.
-
Nested Class Summary
Nested classes/interfaces inherited from interface tvi.webrtc.VideoFrame.TextureBuffer
VideoFrame.TextureBuffer.Type
-
Constructor Summary
ConstructorDescriptionTextureBufferImpl
(int width, int height, VideoFrame.TextureBuffer.Type type, int id, android.graphics.Matrix transformMatrix, android.os.Handler toI420Handler, YuvConverter yuvConverter, Runnable releaseCallback) -
Method Summary
Modifier and TypeMethodDescriptionapplyTransformMatrix
(android.graphics.Matrix transformMatrix, int newWidth, int newHeight) Create a new TextureBufferImpl with an applied transform matrix and a new size.cropAndScale
(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight) Crops a region defined by `cropx`, `cropY`, `cropWidth` and `cropHeight`.int
int
android.os.Handler
android.graphics.Matrix
Retrieve the transform matrix associated with the frame.getType()
int
Returns the height of the texture in memory.int
Returns the width of the texture in memory.int
getWidth()
Resolution of the buffer in pixels.void
release()
Decreases ref count by one.void
retain()
Increases ref count by one.toI420()
Returns a memory-backed frame in I420 format.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface tvi.webrtc.VideoFrame.Buffer
getBufferType
-
Constructor Details
-
TextureBufferImpl
public TextureBufferImpl(int width, int height, VideoFrame.TextureBuffer.Type type, int id, android.graphics.Matrix transformMatrix, android.os.Handler toI420Handler, YuvConverter yuvConverter, @Nullable Runnable releaseCallback)
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceVideoFrame.TextureBuffer
-
getTextureId
public int getTextureId()- Specified by:
getTextureId
in interfaceVideoFrame.TextureBuffer
-
getTransformMatrix
public android.graphics.Matrix getTransformMatrix()Description copied from interface:VideoFrame.TextureBuffer
Retrieve the transform matrix associated with the frame. This transform matrix maps 2D homogeneous coordinates of the form (s, t, 1) with s and t in the inclusive range [0, 1] to the coordinate that should be used to sample that location from the buffer.- Specified by:
getTransformMatrix
in interfaceVideoFrame.TextureBuffer
-
getWidth
public int getWidth()Description copied from interface:VideoFrame.Buffer
Resolution of the buffer in pixels.- Specified by:
getWidth
in interfaceVideoFrame.Buffer
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceVideoFrame.Buffer
-
toI420
Description copied from interface:VideoFrame.Buffer
Returns a memory-backed frame in I420 format. If the pixel data is in another format, a conversion will take place. All implementations must provide a fallback to I420 for compatibility with e.g. the internal WebRTC software encoders.Conversion may fail, for example if reading the pixel data from a texture fails. If the conversion fails, null is returned.
- Specified by:
toI420
in interfaceVideoFrame.Buffer
-
retain
public void retain()Description copied from interface:RefCounted
Increases ref count by one.- Specified by:
retain
in interfaceRefCounted
- Specified by:
retain
in interfaceVideoFrame.Buffer
-
release
public void release()Description copied from interface:RefCounted
Decreases ref count by one. When the ref count reaches zero, resources related to the object will be freed.- Specified by:
release
in interfaceRefCounted
- Specified by:
release
in interfaceVideoFrame.Buffer
-
cropAndScale
public VideoFrame.Buffer cropAndScale(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight) Description copied from interface:VideoFrame.Buffer
Crops a region defined by `cropx`, `cropY`, `cropWidth` and `cropHeight`. Scales it to size `scaleWidth` x `scaleHeight`.- Specified by:
cropAndScale
in interfaceVideoFrame.Buffer
-
getUnscaledWidth
public int getUnscaledWidth()Returns the width of the texture in memory. This should only be used for downscaling, and you should still respect the width from getWidth(). -
getUnscaledHeight
public int getUnscaledHeight()Returns the height of the texture in memory. This should only be used for downscaling, and you should still respect the height from getHeight(). -
getToI420Handler
public android.os.Handler getToI420Handler() -
getYuvConverter
-
applyTransformMatrix
public TextureBufferImpl applyTransformMatrix(android.graphics.Matrix transformMatrix, int newWidth, int newHeight) Create a new TextureBufferImpl with an applied transform matrix and a new size. The existing buffer is unchanged. The given transform matrix is applied first when texture coordinates are still in the unmodified [0, 1] range.- Specified by:
applyTransformMatrix
in interfaceVideoFrame.TextureBuffer
-