MJPEGVideoSource Class Reference

#include <MJPEGVideoSource.hh>

Collaboration diagram for MJPEGVideoSource:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class will take IplImages from a video source and then will encode them into JPEG images. Concatenating them will result in a Motion-JPEG stream. This class will subclass the event-driven library LiveMedia. Derives JPEGVideoSource.

Definition at line 62 of file MJPEGVideoSource.hh.

Public Member Functions

virtual ~MJPEGVideoSource ()

Static Public Member Functions

static MJPEGVideoSourcecreateNew (UsageEnvironment &env, BaseInputVideo *input_video, int stream_id=0, int frame_rate=25, int encoder_internal_buf_size=1000000)
 Static method.

Protected Member Functions

 MJPEGVideoSource (UsageEnvironment &env, BaseInputVideo *input_video, int stream_id, int frame_rate, int encoder_internal_buf_size)
 Constructor.

Private Member Functions

void doGetNextFrame ()
 Inherited function. Used to process next frame to send.
void deliverFrame ()
 Provides RTP encapsulation.
void startCapture ()
 Captures a IplImage and encode it to a JPEG memory buffer.
u_int8_t type ()
u_int8_t qFactor ()
 Quality factor of JPEG image.
u_int8_t width ()
 Width of image.
u_int8_t height ()
 Height of image.
u_int8_t const * quantizationTables (u_int8_t &precision, u_int16_t &length)
 If "qFactor()" returns a value >= 128, then this function is called to tell us the quantization tables that are being used.
int setParamsFromHeader (const unsigned char *fJPEGHeader)
 Try to find width and height markers and grab their values.
Boolean isJPEGVideoSource () const
 redefined virtual functions

Private Attributes

bool _initialized
 Specify whether the class is initialized or not.
unsigned fTimePerFrame
unsigned int fPreferredFrameSize
 Preferred size of current frame to send.
const unsigned char * _encoded_frame
 It will just hold the pointer of the internal_buffer of OStreamVideoEncoder.
timeval fLastCaptureTime
 Contains the last capture time.
int _fps
 Frames per second.
int _frame_rate_millis
 Equals at 1000/frame_rate.
u_int8_t fLastQFactor
 Quality factor, width and height of the jpeg image.
u_int8_t fLastWidth
u_int8_t fLastHeight
u_int8_t * qTable
 Quantization tables.
int _encoder_internal_buf_size
 Size of the internal buffer used for encoding.
int _stream_id
 Stream id.
BaseInputVideo_input_video
 BaseInputVideo class instance pointer.
OStreamVideoEncoder_video_encoder
 OStreamVideoEncoder class instance pointer.
int Idunno


Constructor & Destructor Documentation

MJPEGVideoSource::~MJPEGVideoSource (  )  [virtual]

Definition at line 123 of file MJPEGVideoSource.cpp.

References _encoded_frame, _initialized, _video_encoder, NULL, and qTable.

MJPEGVideoSource::MJPEGVideoSource ( UsageEnvironment &  env,
BaseInputVideo input_video,
int  stream_id,
int  frame_rate,
int  encoder_internal_buf_size 
) [protected]

See also:
createNew

Definition at line 36 of file MJPEGVideoSource.cpp.

References _frame_rate_millis, _initialized, _input_video, _video_encoder, BaseInputVideo::init_device(), NULL, OUTPUT_PACKET_BUFFER_MAXSIZE, and qTable.

Referenced by createNew().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

MJPEGVideoSource * MJPEGVideoSource::createNew ( UsageEnvironment &  env,
BaseInputVideo input_video,
int  stream_id = 0,
int  frame_rate = 25,
int  encoder_internal_buf_size = 1000000 
) [static]

Parameters:
env UsageEnvironment, see LiveMedia doc. here http://www.live555.com/liveMedia/public/doxygen/html
input_video A BaseInputVideo class, can be a MultiVideoSource or a SingleVideoSource kind of class.
stream_id Stream id that will identify this MJPEGVideoSource incapsulator class. It defaults to 0.
frame_rate Frames Per Second value. Number of frames per time unit.
encoder_internal_buf_size Encoder internal buffer size. Memory to alloc for encoding purposes. Defaults to 1000000.
Returns:
New instance of MJPEGVideoSource.
See also:
H263plusVideoSource

Definition at line 61 of file MJPEGVideoSource.cpp.

References MJPEGVideoSource().

Referenced by OStreamOnDemandSMS::createNewStreamSource().

Here is the call graph for this function:

Here is the caller graph for this function:

void MJPEGVideoSource::deliverFrame (  )  [private]

Definition at line 174 of file MJPEGVideoSource.cpp.

References _encoded_frame, DEBUG_PRINT, fLastCaptureTime, fPreferredFrameSize, setParamsFromHeader(), and startCapture().

Referenced by doGetNextFrame().

Here is the call graph for this function:

Here is the caller graph for this function:

void MJPEGVideoSource::doGetNextFrame (  )  [private]

Definition at line 164 of file MJPEGVideoSource.cpp.

References _frame_rate_millis, CV_WAIT_KEY, and deliverFrame().

Here is the call graph for this function:

u_int8_t MJPEGVideoSource::height (  )  [private]

Returns:
Height of image.

Definition at line 248 of file MJPEGVideoSource.cpp.

References fLastHeight.

Boolean MJPEGVideoSource::isJPEGVideoSource (  )  const [private]

Definition at line 154 of file MJPEGVideoSource.cpp.

u_int8_t MJPEGVideoSource::qFactor (  )  [private]

Returns:
ffmpeg needs 195 to be returned.

Definition at line 255 of file MJPEGVideoSource.cpp.

u_int8_t const * MJPEGVideoSource::quantizationTables ( u_int8_t &  precision,
u_int16_t &  length 
) [private]

(The default implementation of this function just returns NULL.) "precision" and "length" are as defined in RFC 2435, section 3.1.8.

Returns:
Quantization tables that are being used

Definition at line 139 of file MJPEGVideoSource.cpp.

References NULL, and qTable.

int MJPEGVideoSource::setParamsFromHeader ( const unsigned char *  fJPEGHeader  )  [private]

Parameters:
fJPEGHeader JPEG memory buffer. Obviously the image header must be inside that buffer.
Returns:
-1 on error, >= 0 if went fine.

Definition at line 265 of file MJPEGVideoSource.cpp.

References DEBUG_PRINT, fLastHeight, fLastWidth, JPEG_HEADER_MAX_SIZE, NULL, and qTable.

Referenced by deliverFrame().

Here is the caller graph for this function:

void MJPEGVideoSource::startCapture (  )  [private]

Definition at line 70 of file MJPEGVideoSource.cpp.

References _encoded_frame, _encoder_internal_buf_size, _fps, _input_video, _stream_id, _video_encoder, DEBUG_PRINT, OStreamVideoEncoder::encode_video_frame(), fLastCaptureTime, fPreferredFrameSize, BaseInputVideo::get_next_frame(), BaseInputVideo::get_next_frame_by_stream_id(), Idunno, BaseInputVideo::is_multi_stream(), NULL, and OSTREAM_ENCODING_MJPEG.

Referenced by deliverFrame().

Here is the call graph for this function:

Here is the caller graph for this function:

u_int8_t MJPEGVideoSource::type (  )  [private]

Returns:
Type of the image. Usually it's 1 ( = JPEG)

Definition at line 234 of file MJPEGVideoSource.cpp.

u_int8_t MJPEGVideoSource::width (  )  [private]

Returns:
Width of image.

Definition at line 241 of file MJPEGVideoSource.cpp.

References fLastWidth.


Member Data Documentation

const unsigned char* MJPEGVideoSource::_encoded_frame [private]

In this particular MJPEG case it will contain jpeg header+data before it's sending

Definition at line 164 of file MJPEGVideoSource.hh.

Referenced by deliverFrame(), startCapture(), and ~MJPEGVideoSource().

int MJPEGVideoSource::_encoder_internal_buf_size [private]

Definition at line 182 of file MJPEGVideoSource.hh.

Referenced by startCapture().

int MJPEGVideoSource::_fps [private]

Definition at line 170 of file MJPEGVideoSource.hh.

Referenced by startCapture().

int MJPEGVideoSource::_frame_rate_millis [private]

Definition at line 173 of file MJPEGVideoSource.hh.

Referenced by doGetNextFrame(), and MJPEGVideoSource().

bool MJPEGVideoSource::_initialized [private]

Definition at line 152 of file MJPEGVideoSource.hh.

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

BaseInputVideo* MJPEGVideoSource::_input_video [private]

Definition at line 188 of file MJPEGVideoSource.hh.

Referenced by MJPEGVideoSource(), and startCapture().

int MJPEGVideoSource::_stream_id [private]

Definition at line 185 of file MJPEGVideoSource.hh.

Referenced by startCapture().

OStreamVideoEncoder* MJPEGVideoSource::_video_encoder [private]

Definition at line 191 of file MJPEGVideoSource.hh.

Referenced by MJPEGVideoSource(), startCapture(), and ~MJPEGVideoSource().

struct timeval MJPEGVideoSource::fLastCaptureTime [private]

Useful for internal packet ordering.

Definition at line 167 of file MJPEGVideoSource.hh.

Referenced by deliverFrame(), and startCapture().

u_int8_t MJPEGVideoSource::fLastHeight [private]

Definition at line 176 of file MJPEGVideoSource.hh.

Referenced by height(), and setParamsFromHeader().

u_int8_t MJPEGVideoSource::fLastQFactor [private]

Definition at line 176 of file MJPEGVideoSource.hh.

u_int8_t MJPEGVideoSource::fLastWidth [private]

Definition at line 176 of file MJPEGVideoSource.hh.

Referenced by setParamsFromHeader(), and width().

unsigned int MJPEGVideoSource::fPreferredFrameSize [private]

Definition at line 158 of file MJPEGVideoSource.hh.

Referenced by deliverFrame(), and startCapture().

unsigned MJPEGVideoSource::fTimePerFrame [private]

Definition at line 155 of file MJPEGVideoSource.hh.

int MJPEGVideoSource::Idunno [private]

Definition at line 196 of file MJPEGVideoSource.hh.

Referenced by startCapture().

u_int8_t* MJPEGVideoSource::qTable [private]

Definition at line 179 of file MJPEGVideoSource.hh.

Referenced by MJPEGVideoSource(), quantizationTables(), setParamsFromHeader(), and ~MJPEGVideoSource().


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