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 #ifndef _H263PLUSVIDEOSOURCE_H_ 00021 #define _H263PLUSVIDEOSOURCE_H_ 00022 00023 00024 // livemedia 00025 #include <GroupsockHelper.hh> 00026 #include <liveMedia.hh> 00027 #include <JPEGVideoSource.hh> 00028 00029 // opencv 00030 #include <cv.h> 00031 #include <highgui.h> 00032 00033 #include <time.h> 00034 00035 #include "OStreamConfig.hh" 00036 #include "BaseInputVideo.hh" 00037 #include "OStreamVideoEncoder.hh" 00038 00039 00041 #define OUTPUT_PACKET_BUFFER_MAXSIZE 512000 00042 00050 class H263plusVideoSource : public FramedSource 00051 { 00052 public: 00053 00068 static H263plusVideoSource* 00069 createNew( UsageEnvironment& env, BaseInputVideo* input_video, int stream_id = 0, 00070 int frame_rate = 25, int encoder_internal_buf_size = 1000000 ); 00071 00072 protected: 00077 H263plusVideoSource( UsageEnvironment& env, BaseInputVideo* input_video, int stream_id, 00078 int frame_rate, int encoder_internal_buf_size ); 00079 virtual ~H263plusVideoSource(); 00080 00081 private: // functions 00085 void doGetNextFrame(); 00086 00088 void deliverFrame(); 00089 00091 void startCapture(); 00092 00093 private: // data 00095 bool _initialized; 00096 00098 int _fps; 00099 00101 int _frame_rate_millis; 00102 00104 unsigned int fPreferredFrameSize; 00105 00111 const unsigned char* _encoded_frame; 00112 00114 struct timeval fLastCaptureTime; 00115 00117 int _encoder_internal_buf_size; 00118 00120 int _stream_id; 00121 00123 BaseInputVideo *_input_video; 00124 00126 OStreamVideoEncoder *_video_encoder; 00127 00128 #ifdef __LINUX__ 00129 struct timezone Idunno; 00130 #else 00131 int Idunno; 00132 #endif 00133 00134 }; 00135 00136 00137 #endif //_H263PLUSVIDEOSOURCE_H_ 00138