Package tvi.webrtc
Class TextureBufferImpl
- java.lang.Object
-
- tvi.webrtc.TextureBufferImpl
-
- All Implemented Interfaces:
RefCounted,VideoFrame.Buffer,VideoFrame.TextureBuffer
public class TextureBufferImpl extends java.lang.Object implements 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
Constructors Constructor Description TextureBufferImpl(int width, int height, VideoFrame.TextureBuffer.Type type, int id, android.graphics.Matrix transformMatrix, android.os.Handler toI420Handler, YuvConverter yuvConverter, java.lang.Runnable releaseCallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextureBufferImplapplyTransformMatrix(android.graphics.Matrix transformMatrix, int newWidth, int newHeight)Create a new TextureBufferImpl with an applied transform matrix and a new size.VideoFrame.BuffercropAndScale(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight)Crops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|.intgetHeight()intgetTextureId()android.os.HandlergetToI420Handler()android.graphics.MatrixgetTransformMatrix()Retrieve the transform matrix associated with the frame.VideoFrame.TextureBuffer.TypegetType()intgetUnscaledHeight()Returns the height of the texture in memory.intgetUnscaledWidth()Returns the width of the texture in memory.intgetWidth()Resolution of the buffer in pixels.YuvConvertergetYuvConverter()voidrelease()Decreases ref count by one.voidretain()Increases ref count by one.VideoFrame.I420BuffertoI420()Returns a memory-backed frame in I420 format.
-
-
-
Constructor Detail
-
TextureBufferImpl
public TextureBufferImpl(int width, int height, VideoFrame.TextureBuffer.Type type, int id, android.graphics.Matrix transformMatrix, android.os.Handler toI420Handler, YuvConverter yuvConverter, @Nullable java.lang.Runnable releaseCallback)
-
-
Method Detail
-
getType
public VideoFrame.TextureBuffer.Type getType()
- Specified by:
getTypein interfaceVideoFrame.TextureBuffer
-
getTextureId
public int getTextureId()
- Specified by:
getTextureIdin interfaceVideoFrame.TextureBuffer
-
getTransformMatrix
public android.graphics.Matrix getTransformMatrix()
Description copied from interface:VideoFrame.TextureBufferRetrieve 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:
getTransformMatrixin interfaceVideoFrame.TextureBuffer
-
getWidth
public int getWidth()
Description copied from interface:VideoFrame.BufferResolution of the buffer in pixels.- Specified by:
getWidthin interfaceVideoFrame.Buffer
-
getHeight
public int getHeight()
- Specified by:
getHeightin interfaceVideoFrame.Buffer
-
toI420
public VideoFrame.I420Buffer toI420()
Description copied from interface:VideoFrame.BufferReturns 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.- Specified by:
toI420in interfaceVideoFrame.Buffer
-
retain
public void retain()
Description copied from interface:RefCountedIncreases ref count by one.- Specified by:
retainin interfaceRefCounted- Specified by:
retainin interfaceVideoFrame.Buffer
-
release
public void release()
Description copied from interface:RefCountedDecreases ref count by one. When the ref count reaches zero, resources related to the object will be freed.- Specified by:
releasein interfaceRefCounted- Specified by:
releasein interfaceVideoFrame.Buffer
-
cropAndScale
public VideoFrame.Buffer cropAndScale(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight)
Description copied from interface:VideoFrame.BufferCrops a region defined by |cropx|, |cropY|, |cropWidth| and |cropHeight|. Scales it to size |scaleWidth| x |scaleHeight|.- Specified by:
cropAndScalein 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
public YuvConverter 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.
-
-