Package io.antmedia.recorder
Class Frame
java.lang.Object
io.antmedia.recorder.Frame
- All Implemented Interfaces:
AutoCloseable
,org.bytedeco.javacpp.indexer.Indexable
A class to manage the data of audio and video frames. It it used by
CanvasFrame
, FrameGrabber
, FrameRecorder
, and their
subclasses. We can also make the link with other APIs, such as Android,
Java 2D, FFmpeg, and OpenCV, via a FrameConverter
.- Author:
- Samuel Audet
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Constants defining data type in the frame. -
Field Summary
Modifier and TypeFieldDescriptionint
private ByteBuffer
Buffer to hold a data stream associated with a frame.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.static final int
Constants to be used forimageDepth
.Buffer[]
Buffers to hold image pixels from multiple channels for a video frame.protected int
protected int
protected int
protected int
protected int
Information associated with theimage
field.boolean
A flag set by a FrameGrabber or a FrameRecorder to indicate a key frame.private Object
The underlying data object, for example, Pointer, AVFrame, IplImage, or Mat.char
The type of the image frame ('I', 'P', 'B', etc).private int
Information associated with thesamples
field.private Buffer[]
Buffers to hold audio samples from multiple channels for an audio frame.int
Stream number the audio|video|other data is associated with.long
Timestamp of the frame creation in microseconds.The type of the stream. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Care must be taken if this method is to be used in conjunction with movie recordings.private static org.bytedeco.javacpp.Pointer
cloneBufferArray
(Buffer[] srcBuffers, Buffer[] clonedBuffers) This private method takes a buffer array as input and returns a deep copy.void
close()
<I extends org.bytedeco.javacpp.indexer.Indexer>
IReturnscreateIndexer(true, 0)
.<I extends org.bytedeco.javacpp.indexer.Indexer>
IcreateIndexer
(boolean direct) <I extends org.bytedeco.javacpp.indexer.Indexer>
IcreateIndexer
(boolean direct, int i) Returns anIndexer
for the ith image plane.getData()
int
int
int
int
int
int
Buffer[]
getTypes()
Returns types of data containing in the framestatic int
pixelSize
(int depth) ReturnsMath.abs(depth) / 8
.void
setData
(ByteBuffer data) void
setSampleRate
(int sampleRate) void
setSamples
(Buffer[] samples)
-
Field Details
-
keyFrame
public boolean keyFrameA flag set by a FrameGrabber or a FrameRecorder to indicate a key frame. -
pictType
public char pictTypeThe type of the image frame ('I', 'P', 'B', etc). -
DEPTH_BYTE
public static final int DEPTH_BYTEConstants to be used forimageDepth
.- See Also:
-
DEPTH_UBYTE
public static final int DEPTH_UBYTEConstants to be used forimageDepth
.- See Also:
-
DEPTH_SHORT
public static final int DEPTH_SHORTConstants to be used forimageDepth
.- See Also:
-
DEPTH_USHORT
public static final int DEPTH_USHORTConstants to be used forimageDepth
.- See Also:
-
DEPTH_INT
public static final int DEPTH_INTConstants to be used forimageDepth
.- See Also:
-
DEPTH_LONG
public static final int DEPTH_LONGConstants to be used forimageDepth
.- See Also:
-
DEPTH_FLOAT
public static final int DEPTH_FLOATConstants to be used forimageDepth
.- See Also:
-
DEPTH_DOUBLE
public static final int DEPTH_DOUBLEConstants to be used forimageDepth
.- See Also:
-
imageWidth
protected int imageWidthInformation associated with theimage
field. -
imageHeight
protected int imageHeight -
imageDepth
protected int imageDepth -
imageChannels
protected int imageChannels -
imageStride
protected int imageStride -
image
Buffers to hold image pixels from multiple channels for a video frame. Most of the software supports packed data only, but an array is provided to allow users to store images in a planar format as well. -
sampleRate
private int sampleRateInformation associated with thesamples
field. -
audioChannels
public int audioChannels -
samples
Buffers to hold audio samples from multiple channels for an audio frame. -
data
Buffer to hold a data stream associated with a frame. -
streamIndex
public int streamIndexStream number the audio|video|other data is associated with. -
type
The type of the stream. -
opaque
The underlying data object, for example, Pointer, AVFrame, IplImage, or Mat. -
timestamp
public long timestampTimestamp of the frame creation in microseconds.
-
-
Constructor Details
-
Frame
public Frame()Empty constructor. -
Frame
public Frame(int width, int height, int depth, int channels) Allocates a new packed image frame in native memory where rows are 8-byte aligned. -
Frame
public Frame(int width, int height, int depth, int channels, int imageStride)
-
-
Method Details
-
pixelSize
public static int pixelSize(int depth) ReturnsMath.abs(depth) / 8
. -
createIndexer
public <I extends org.bytedeco.javacpp.indexer.Indexer> I createIndexer()ReturnscreateIndexer(true, 0)
. -
createIndexer
public <I extends org.bytedeco.javacpp.indexer.Indexer> I createIndexer(boolean direct) - Specified by:
createIndexer
in interfaceorg.bytedeco.javacpp.indexer.Indexable
-
createIndexer
public <I extends org.bytedeco.javacpp.indexer.Indexer> I createIndexer(boolean direct, int i) Returns anIndexer
for the ith image plane. -
clone
Care must be taken if this method is to be used in conjunction with movie recordings. Cloning a frame containing a full HD picture (alpha channel included) would take 1920 x 1080 * 4 = 8.294.400 Bytes. Expect a heap overflow exception when using this method without cleaning up. -
cloneBufferArray
private static org.bytedeco.javacpp.Pointer cloneBufferArray(Buffer[] srcBuffers, Buffer[] clonedBuffers) This private method takes a buffer array as input and returns a deep copy. It is assumed that all buffers in the input array are of the same subclass.- Parameters:
srcBuffers
- - Buffer array to be clonedclonedBuffers
- - Buffer array to fill with clones- Returns:
- Opaque object to store
-
getTypes
Returns types of data containing in the frame -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getImageWidth
public int getImageWidth() -
getImageHeight
public int getImageHeight() -
getImageDepth
public int getImageDepth() -
getImageChannels
public int getImageChannels() -
getImageStride
public int getImageStride() -
getOpaque
-
getSamples
-
setSamples
-
getSampleRate
public int getSampleRate() -
setSampleRate
public void setSampleRate(int sampleRate) -
getData
-
setData
-