FFmpegVideoProvider
FFmpegVideoProvider is used to store, obtain, and control stream data. It only supports storing data of the AVPacket type; The data in AVPacket can be YUV, H264, or MJPEG. All of its APIs are thread-safe.
API Instructions
namespace com { namespace sunplus { namespace media {
class FFmpegVideoProvider {
public:
FFmpegVideoProvider(AVStream* avStream, int maxQueueSize = 4);
~FFmpegVideoProvider();
public:
void prepare();
void destroy();
AVStream* getAVStream();
void setPutFrameInterval(int interval);
int putFrame(AVPacket* packet);
int getFrame(AVPacket*& packet);
};
}}}
Constructors
FFmpegVideoProvider(AVStream* avStream, int maxQueueSize = 4);
prepare
Initialize the internal queue. You can only putFrame/getFrame after preparing.
/**
* Initialize the internal queue.
* You can only putFrame/getFrame after preparing.
*/
void prepare();
destroy
Empty the cached data and release the related resources. After destroying, the putFrame/getFrame returns a failure.
getAVStream
Get AVStream to get the stream info of the cached data. Please refer to the getAVStream of FFmpegV4L2VideoSource.
setPutFrameInterval
Set the put frame interval, which can be used to implement frame rate control. It is invalid for H264 data.
putFrame
Create a new packet that references the same data as the src packet, then push the new packet into the queue. The src packet must be freed with av_packet_unref()+av_packet_free() when it is no longer needed.
Sample
Â
getFrame
Get cached frame from the queue, which is a thread-safe API. After successfully obtaining the packet, it must be freed with av_packet_unref()+av_packet_free() when it is no longer needed.
Sample
Sample Code
Please refer to the sample code of FFmpegV4L2VideoSource.