libcvd
Public Member Functions | List of all members
CVD::ServerPushJpegBuffer< C > Class Template Reference

Play a server push stream as a video stream. More...

#include <serverpushjpegbuffer.h>

Inheritance diagram for CVD::ServerPushJpegBuffer< C >:
Inheritance graph
[legend]
Collaboration diagram for CVD::ServerPushJpegBuffer< C >:
Collaboration graph
[legend]

Public Member Functions

 ServerPushJpegBuffer (std::istream &i, bool warnings_=0, int eat_frames=0)
 Construct a ServerPushJpegBuffer from an istream. More...
 
virtual ImageRef size ()
 The size of the VideoFrames returned by this buffer.
 
LocalVideoFrame< C > * get_frame ()
 Returns the next frame from the buffer. This function blocks until a frame is ready.
 
void put_frame (VideoFrame< C > *f)
 Tell the buffer that you are finished with this frame. More...
 
bool frame_pending ()
 Is there a frame waiting in the buffer? This function does not block. More...
 
void seek_to (double)
 Go to a particular point in the video buffer (only implemented in buffers of recorded video) More...
 
double frame_rate ()
 This value is not currently correct.
 
- Public Member Functions inherited from CVD::LocalVideoBuffer< C >
 LocalVideoBuffer (typename VideoBufferType::Type t)
 
- Public Member Functions inherited from CVD::VideoBuffer< C >
 VideoBuffer (VideoBufferType::Type _type)
 Construct the buffer with the known semantics.
 
virtual void flush ()
 Flush all old frames out of the video buffer, on a flushable buffer, causing the next get_frame() to sleep until a frame arrives. More...
 
VideoBufferType::Type type ()
 Returns the type of the video stream. More...
 
- Public Member Functions inherited from CVD::RawVideoBuffer
virtual RawVideoBuffersource_buffer ()
 Which video grabber provides the source images for this video grabber. More...
 
RawVideoBufferroot_buffer ()
 Follow the chain of video grabbers back as far as at will go. More...
 

Detailed Description

template<class C>
class CVD::ServerPushJpegBuffer< C >

Play a server push stream as a video stream.

This is a standard used by a number of HTTP based security cameras. The format is as follows:

--ImageSeparator\n
Content-Type: image/jpeg\r\n
Content-Length: 123456789\r\n
\r\n
<123456789 bytes of JPEG go here>\r\n

This exact format is from the InVision IQEye series of cameras. Other cameras have a different image separator, and do not miss the carriage return.

The buffer reads a number of frames from the stream on initiation (by default 10), in order to flush the camera's inbuilt buffer. With some cameras, changing the video size does not flush the buffer, so the first few frames will be of the incorrect size. After flushing the buffer, the size of the first frame is taken to be the size of the video stream. If spurious frames arrive of a different size later, these will be ignored.

WARNING: error checking is currently very minimal. The result of failure will probably result in an exception being thrown from the JPEG loader.

Parameters
TThe pixel type of the frames to provide (usually CVD::Rgb<CVD::byte> or CVD::byte. If the image files are of a different type, they will be automatically converted (see Image loading and saving, and format conversion).

Constructor & Destructor Documentation

◆ ServerPushJpegBuffer()

template<class C >
CVD::ServerPushJpegBuffer< C >::ServerPushJpegBuffer ( std::istream &  i,
bool  warnings_ = 0,
int  eat_frames = 0 
)
inline

Construct a ServerPushJpegBuffer from an istream.

The istream

Parameters
iThe stream to use for video.
warningsWhether to print warnings if mis-sized frames arrive.
eat_framesNumber of frames to discard on initialization.

Member Function Documentation

◆ frame_pending()

template<class C >
bool CVD::ServerPushJpegBuffer< C >::frame_pending ( )
inlinevirtual

Is there a frame waiting in the buffer? This function does not block.

See is_live and is_flushable.

Implements CVD::LocalVideoBuffer< C >.

◆ put_frame()

template<class C >
void CVD::ServerPushJpegBuffer< C >::put_frame ( VideoFrame< C > *  f)
inlinevirtual

Tell the buffer that you are finished with this frame.

Typically the VideoBuffer then destroys the frame.

Parameters
fThe frame that you are finished with.

Implements CVD::LocalVideoBuffer< C >.

◆ seek_to()

template<class C >
void CVD::ServerPushJpegBuffer< C >::seek_to ( double  )
inlinevirtual

Go to a particular point in the video buffer (only implemented in buffers of recorded video)

Parameters
tThe frame time in seconds

Reimplemented from CVD::LocalVideoBuffer< C >.


The documentation for this class was generated from the following file: