RetroShare/plugins/VOIP/gui/VideoProcessor.h
csoler b6089f3b91 Started implementation of Video Chat (not working yet!).
- GUI part is done
- implemented a very basic JPEG codec
- added echo frame in configuration panel
- created a video capture object that uses OpenCV (should be cross systems)
Remains to do:
- serialise and send frames through p3VoRS
- use a serious codec (e.g. Theora+x264)
- add icons to reflect camera state (failure/working/sending/...)
- compilation on windows 



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7449 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2014-07-13 13:57:25 +00:00

80 lines
2.0 KiB
C++

#pragma once
#include <stdint.h>
#include <QImage>
class QVideoOutputDevice ;
// This class decodes video from a stream. It keeps a queue of
// decoded frame that needs to be retrieved using the getNextImage() method.
//
class VideoDecoder
{
public:
VideoDecoder() { _output_device = NULL ;}
// Gets the next image to be displayed. Once returned, the image should
// be cleared from the incoming queue.
//
void setDisplayTarget(QVideoOutputDevice *odev) { _output_device = odev ; }
virtual void receiveEncodedData(const unsigned char *data,uint32_t size) ;
private:
QVideoOutputDevice *_output_device ;
std::list<QImage> _image_queue ;
// Incoming data is processed by a video codec and converted into images.
//
virtual QImage decodeData(const unsigned char *encoded_image,uint32_t encoded_image_size) = 0 ;
// This buffer accumulated incoming encoded data, until a full packet is obtained,
// since the stream might not send images at once. When incoming images are decoded, the
// data is removed from the buffer.
//
unsigned char *buffer ;
uint32_t buffer_size ;
};
// This class encodes video using a video codec (possibly homemade, or based on existing codecs)
// and produces a data stream that is sent to the network transfer service (e.g. p3VoRs).
//
class VideoEncoder
{
public:
VideoEncoder() { _echo_output_device = NULL ;}
// Takes the next image to be encoded.
//
virtual bool addImage(const QImage& Image) ;
protected:
//virtual bool sendEncodedData(unsigned char *mem,uint32_t size) = 0 ;
virtual void encodeData(const QImage& image) = 0 ;
unsigned char *buffer ;
uint32_t buffer_size ;
QVideoOutputDevice *_echo_output_device ;
};
// Now derive various image encoding/decoding algorithms.
//
class JPEGVideoDecoder: public VideoDecoder
{
protected:
virtual QImage decodeData(const unsigned char *encoded_image,uint32_t encoded_image_size) ;
};
class JPEGVideoEncoder: public VideoEncoder
{
public:
JPEGVideoEncoder() {}
protected:
virtual void encodeData(const QImage& Image) ;
};