OStreamVideoEncoder Class Reference

#include <OStreamVideoEncoder.hh>

List of all members.


Detailed Description

Utility class with reusable code. Depends on libavcodec/libavformat. Encodes a IplImage to encoded data [h263+, mjpeg]or, extendable, to other formats.

Definition at line 34 of file OStreamVideoEncoder.hh.

Public Member Functions

 OStreamVideoEncoder (unsigned int io_buf_size, ostream_encoding_type encoding_type, int video_width, int video_height, int fps=25, PixelFormat opencv_pix_fmt=PIX_FMT_BGR24)
 Constructor.
virtual ~OStreamVideoEncoder ()
const unsigned char * encode_video_frame (IplImage *image, int *out_size)
 Encode a IplImage to a buffer.

Private Member Functions

bool encoder_initialize ()
 Initialize the encoder.
AVFrame * create_avframe (int pixel_format)
 Create an AVFrame.
AVStream * create_video_stream (AVFormatContext *io_fmt_context, int codec_id)
 Create a video stream.
bool open_codec (AVStream *stream)
 Open the codec.

Private Attributes

bool _initialized
 Specify whether the class is initialized or not.
AVFrame * _ready_to_encode_frame
AVFrame * _opencv_frame
AVOutputFormat * _out_fmt
AVFormatContext * _out_fmt_context
AVStream * _video_stream
PixelFormat _opencv_pix_fmt
unsigned char * _internal_buffer
 Internal buffer used for conversions.
int _internal_buffer_size
int _encoding_type
int _video_height
int _video_width
int _fps


Constructor & Destructor Documentation

OStreamVideoEncoder::OStreamVideoEncoder ( unsigned int  io_buf_size,
ostream_encoding_type  encoding_type,
int  video_width,
int  video_height,
int  fps = 25,
PixelFormat  opencv_pix_fmt = PIX_FMT_BGR24 
)

Parameters:
io_buf_size Internal buffer size used to store encoded frames. This must be <= fMaxSize, or liveMedia libraries will crash. please note: in case you want to add some new encoding type be sure to check all the "switch ( _encoding_type )" lines you'll find in the implementation file and to add them the correct parameters.
encoding_type ostream_encoding_type parameter.
video_width Video width. In a future this parameter can be removed, coz this info is already inside the IplImage.
video_height Video height In a future this parameter can be removed, coz this info is already inside the IplImage.
fps Frame Per Second
opencv_pix_fmt Speaking about OpenCV and IplImages, they usually set BGR as their main format, but with the new display system, wxImage, it's better to have RGB format, so that we can avoid a conversion.

Definition at line 23 of file OStreamVideoEncoder.cpp.

References _initialized, _internal_buffer, _internal_buffer_size, DEBUG_PRINT, and encoder_initialize().

Here is the call graph for this function:

OStreamVideoEncoder::~OStreamVideoEncoder (  )  [virtual]

Definition at line 48 of file OStreamVideoEncoder.cpp.

References _internal_buffer.


Member Function Documentation

AVFrame * OStreamVideoEncoder::create_avframe ( int  pixel_format  )  [private]

Parameters:
pixel_format Pixel format of the resulting AVFrame. It's mainly used as temporary buffer for conversions.
Returns:
A new AVFrame.
See also:
ffmpeg doc.

Definition at line 82 of file OStreamVideoEncoder.cpp.

References _video_height, _video_width, and NULL.

Referenced by encoder_initialize().

Here is the caller graph for this function:

AVStream * OStreamVideoEncoder::create_video_stream ( AVFormatContext *  io_fmt_context,
int  codec_id 
) [private]

Parameters:
io_fmt_context Please refer to ffmpeg doc.
codec_id CodecID of ffmpeg.
Returns:
New AVStream.

Definition at line 106 of file OStreamVideoEncoder.cpp.

References _encoding_type, _fps, _video_height, _video_width, DEBUG_PRINT, NULL, OSTREAM_ENCODING_H263P, and OSTREAM_ENCODING_MJPEG.

Referenced by encoder_initialize().

Here is the caller graph for this function:

const unsigned char * OStreamVideoEncoder::encode_video_frame ( IplImage *  image,
int *  out_size 
)

Parameters:
image IplImage. This is a "next" frame of a video stream.
out_size The size of the encoded buffer.
Returns:
A buffer, which is the next packet of an encoded video stream.
Note:
The returned buffer should not be modified or worst free. It's the internal pointer to a buffer of this class. We act like this for performances tasks.

Definition at line 245 of file OStreamVideoEncoder.cpp.

References _initialized, _internal_buffer_size, _opencv_frame, _video_stream, DEBUG_PRINT, and NULL.

Referenced by MJPEGVideoSource::startCapture(), and H263plusVideoSource::startCapture().

Here is the caller graph for this function:

bool OStreamVideoEncoder::encoder_initialize (  )  [private]

Returns:
true on success, false on insuccess.

Definition at line 154 of file OStreamVideoEncoder.cpp.

References _encoding_type, _opencv_frame, _opencv_pix_fmt, _out_fmt, _out_fmt_context, _ready_to_encode_frame, _video_stream, create_avframe(), create_video_stream(), DEBUG_PRINT, NULL, open_codec(), OSTREAM_ENCODING_H263P, and OSTREAM_ENCODING_MJPEG.

Referenced by OStreamVideoEncoder().

Here is the call graph for this function:

Here is the caller graph for this function:

bool OStreamVideoEncoder::open_codec ( AVStream *  stream  )  [private]

Definition at line 60 of file OStreamVideoEncoder.cpp.

References DEBUG_PRINT.

Referenced by encoder_initialize().

Here is the caller graph for this function:


Member Data Documentation

int OStreamVideoEncoder::_encoding_type [private]

See also:
ostream_encoding_type

Definition at line 124 of file OStreamVideoEncoder.hh.

Referenced by create_video_stream(), and encoder_initialize().

int OStreamVideoEncoder::_fps [private]

Definition at line 128 of file OStreamVideoEncoder.hh.

Referenced by create_video_stream().

bool OStreamVideoEncoder::_initialized [private]

Definition at line 102 of file OStreamVideoEncoder.hh.

Referenced by encode_video_frame(), and OStreamVideoEncoder().

unsigned char* OStreamVideoEncoder::_internal_buffer [private]

Definition at line 120 of file OStreamVideoEncoder.hh.

Referenced by OStreamVideoEncoder(), and ~OStreamVideoEncoder().

int OStreamVideoEncoder::_internal_buffer_size [private]

Definition at line 121 of file OStreamVideoEncoder.hh.

Referenced by encode_video_frame(), and OStreamVideoEncoder().

AVFrame * OStreamVideoEncoder::_opencv_frame [private]

Definition at line 105 of file OStreamVideoEncoder.hh.

Referenced by encode_video_frame(), and encoder_initialize().

PixelFormat OStreamVideoEncoder::_opencv_pix_fmt [private]

See also:
ffmpeg doc for this struct

Definition at line 117 of file OStreamVideoEncoder.hh.

Referenced by encoder_initialize().

AVOutputFormat* OStreamVideoEncoder::_out_fmt [private]

See also:
ffmpeg doc for this struct

Definition at line 108 of file OStreamVideoEncoder.hh.

Referenced by encoder_initialize().

AVFormatContext* OStreamVideoEncoder::_out_fmt_context [private]

See also:
ffmpeg doc for this struct

Definition at line 111 of file OStreamVideoEncoder.hh.

Referenced by encoder_initialize().

AVFrame* OStreamVideoEncoder::_ready_to_encode_frame [private]

See also:
ffmpeg doc for this struct

Definition at line 105 of file OStreamVideoEncoder.hh.

Referenced by encoder_initialize().

int OStreamVideoEncoder::_video_height [private]

Definition at line 126 of file OStreamVideoEncoder.hh.

Referenced by create_avframe(), and create_video_stream().

AVStream* OStreamVideoEncoder::_video_stream [private]

See also:
ffmpeg doc for this struct

Definition at line 114 of file OStreamVideoEncoder.hh.

Referenced by encode_video_frame(), and encoder_initialize().

int OStreamVideoEncoder::_video_width [private]

Definition at line 127 of file OStreamVideoEncoder.hh.

Referenced by create_avframe(), and create_video_stream().


The documentation for this class was generated from the following files:
Generated on Tue Dec 26 10:38:51 2006 for Omnimeeting by  doxygen 1.4.7