Package org.webrtc
Class NV12Buffer
java.lang.Object
org.webrtc.NV12Buffer
- All Implemented Interfaces:
RefCounted
,VideoFrame.Buffer
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ByteBuffer
private final int
private final RefCountDelegate
private final int
private final int
private final int
-
Constructor Summary
ConstructorDescriptionNV12Buffer
(int width, int height, int stride, int sliceHeight, ByteBuffer buffer, Runnable releaseCallback) -
Method Summary
Modifier and TypeMethodDescriptioncropAndScale
(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight) Crops a region defined by `cropx`, `cropY`, `cropWidth` and `cropHeight`.int
int
getWidth()
Resolution of the buffer in pixels.private static void
nativeCropAndScale
(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight, ByteBuffer src, int srcWidth, int srcHeight, int srcStride, int srcSliceHeight, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV) 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 org.webrtc.VideoFrame.Buffer
getBufferType
-
Field Details
-
width
private final int width -
height
private final int height -
stride
private final int stride -
sliceHeight
private final int sliceHeight -
buffer
-
refCountDelegate
-
-
Constructor Details
-
NV12Buffer
public NV12Buffer(int width, int height, int stride, int sliceHeight, ByteBuffer buffer, @Nullable Runnable releaseCallback)
-
-
Method Details
-
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
-
nativeCropAndScale
private static void nativeCropAndScale(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight, ByteBuffer src, int srcWidth, int srcHeight, int srcStride, int srcSliceHeight, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV)
-