MJPEGVideoSource.hh

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) Massimo Cora' 2006 <maxcvs@email.it>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 
00020 //
00021 // Class: MJPEGVideoSource
00022 #ifndef _MJPEGVIDEOSOURCE_H_
00023 #define _MJPEGVIDEOSOURCE_H_
00024 
00025 // livemedia
00026 #include <GroupsockHelper.hh>
00027 #include <liveMedia.hh>
00028 #include <JPEGVideoSource.hh>
00029 
00030 // opencv
00031 #include <cv.h>
00032 #include <highgui.h>
00033 
00034 #include <time.h>
00035 
00036 #include "OStreamConfig.hh"
00037 #include "BaseInputVideo.hh"
00038 #include "OStreamVideoEncoder.hh"
00039 
00047 #define JPEG_HEADER_MAX_SIZE 623
00048 
00053 #define OUTPUT_PACKET_BUFFER_MAXSIZE    512000
00054 
00062 class MJPEGVideoSource : public JPEGVideoSource
00063 {
00064 public:
00079         static MJPEGVideoSource*
00080                 createNew( UsageEnvironment& env, BaseInputVideo* input_video, 
00081                                   int stream_id = 0, int frame_rate = 25, 
00082                                   int encoder_internal_buf_size = 1000000 );
00083 
00084         virtual ~MJPEGVideoSource();
00085         
00086 protected:
00091         MJPEGVideoSource( UsageEnvironment& env, BaseInputVideo* input_video, 
00092                                           int stream_id, int frame_rate, int encoder_internal_buf_size);
00093         
00094 private:                // functions
00098         void doGetNextFrame();
00099         
00101         void deliverFrame();
00102         
00104         void  startCapture();
00105 
00109         u_int8_t type();
00110         
00115         u_int8_t qFactor();
00116         
00121         u_int8_t width();                       // # pixels/8 (or 0 for 2048 pixels)
00122         
00127         u_int8_t height();                      // # pixels/8 (or 0 for 2048 pixels)
00128 
00136         u_int8_t const* quantizationTables( u_int8_t& precision, u_int16_t& length );
00137         
00138         
00145         int setParamsFromHeader( const unsigned char* fJPEGHeader );
00146         
00148         Boolean isJPEGVideoSource() const;
00149         
00150 private:                // data 
00152         bool _initialized;
00153 
00154         /* Time per frame */
00155         unsigned fTimePerFrame;
00156         
00158         unsigned int fPreferredFrameSize;
00159 
00164         const unsigned char* _encoded_frame;
00165         
00167         struct timeval fLastCaptureTime;
00168         
00170         int _fps;
00171         
00173         int _frame_rate_millis;
00174         
00176         u_int8_t fLastQFactor, fLastWidth, fLastHeight;
00177         
00179         u_int8_t *qTable;
00180 
00182         int _encoder_internal_buf_size;
00183         
00185         int _stream_id;
00186         
00188         BaseInputVideo *_input_video;
00189         
00191         OStreamVideoEncoder *_video_encoder;       
00192         
00193 #ifdef __LINUX__
00194         struct timezone Idunno; 
00195 #else
00196         int Idunno;
00197 #endif
00198         
00199         
00200 };
00201 
00202 
00203 #endif  //_MJPEGVIDEOSOURCE_H_
00204 

Generated on Tue Dec 26 10:32:38 2006 for Omnimeeting by  doxygen 1.4.7