OpenH323 1.18.0
|
00001 /* 00002 * H.323 protocol handler 00003 * 00004 * Open H323 Library 00005 * 00006 * Copyright (c) 2001 March Networks Corporation 00007 * Copyright (c) 1999-2000 Equivalence Pty. Ltd. 00008 * 00009 * The contents of this file are subject to the Mozilla Public License 00010 * Version 1.0 (the "License"); you may not use this file except in 00011 * compliance with the License. You may obtain a copy of the License at 00012 * http://www.mozilla.org/MPL/ 00013 * 00014 * Software distributed under the License is distributed on an "AS IS" 00015 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00016 * the License for the specific language governing rights and limitations 00017 * under the License. 00018 * 00019 * The Original Code is Open H323 Library. 00020 * 00021 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00022 * 00023 * Contributor(s): Guilhem Tardy (gtardy@salyens.com) 00024 * 00025 * $Log: ffh263codec.h,v $ 00026 * Revision 1.9 2005/11/30 13:05:01 csoutheren 00027 * Changed tags for Doxygen 00028 * 00029 * Revision 1.8 2004/05/12 23:18:44 csoutheren 00030 * Adjusted copyright notices for ffh263 and rfc2190 files 00031 * 00032 * Revision 1.7 2004/04/23 03:50:36 csoutheren 00033 * Added missing start comment and repaired inadvertant change to #ifdef 00034 * 00035 * Revision 1.6 2004/04/22 22:34:59 csoutheren 00036 * Fixed mispelling of Guilhem Tardy - my apologies to him 00037 * 00038 * Revision 1.5 2004/04/22 22:24:17 csoutheren 00039 * Fixed wrong usage of pragma message 00040 * 00041 * Revision 1.4 2004/04/22 14:22:20 csoutheren 00042 * Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet 00043 * Many thanks to them for their contributions. 00044 * 00045 * Revision 1.3 2003/08/04 00:03:16 dereksmithies 00046 * Reorganise tests for enabled 00047 * 00048 * Revision 1.2 2003/07/31 05:08:24 dereksmithies 00049 * Switch to manual packet fragment technique. Much more reliable, especially so on windows. 00050 * 00051 * Revision 1.1 2003/07/24 05:23:06 dereksmithies 00052 * Move ffmpeg h263 support to this file, and designate non standard. 00053 * 00054 * Revision 1.12 2003/06/06 05:18:54 dereksmithies 00055 * Fix startup delay bug. Remove all large packets from the network. Improve reliability. 00056 * 00057 * Revision 1.11 2003/05/27 09:22:55 dereksmithies 00058 * Updates for code revisions in h263 codec 00059 * 00060 * Revision 1.10 2003/05/14 13:47:58 rjongbloed 00061 * Removed static "initialisation" function as this should be done 00062 * internally and not in the application. 00063 * 00064 * Revision 1.9 2003/05/05 11:59:21 robertj 00065 * Changed to use autoconf style selection of options and subsystems. 00066 * 00067 * Revision 1.8 2003/05/02 04:22:10 craigs 00068 * Added lots of extra H.263 support 00069 * 00070 * Revision 1.7 2003/04/27 09:16:38 rogerh 00071 * use PBYTE_ORDER instead of endian.h 00072 * 00073 * Revision 1.6 2003/04/21 21:50:22 dereks 00074 * Implement suggestion from Guilhem Tardy. Many thanks. 00075 * 00076 * Revision 1.5 2003/04/16 04:26:57 dereks 00077 * Initial release of h263 codec, which utilises the ffmpeg library. 00078 * Thanks to Guilhem Tardy, and to AliceStreet. 00079 * 00080 * Revision 1.4 2002/09/16 01:14:15 robertj 00081 * Added #define so can select if #pragma interface/implementation is used on 00082 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00083 * 00084 * Revision 1.3 2002/09/03 06:19:36 robertj 00085 * Normalised the multi-include header prevention ifdef/define symbol. 00086 * 00087 * Revision 1.2 2002/08/05 10:03:47 robertj 00088 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00089 * 00090 * Revision 1.1 2002/05/19 22:32:46 dereks 00091 * Initial release of stub file for h263 codec. Thanks Guilhem Tardy. 00092 * 00093 * 00094 * 00095 */ 00096 00097 /* 00098 * Initial release notes from Guilhem Tardy:: 00099 * 00100 * Added support for video capabilities & codec, only tested under Linux! 00101 * The code for varying bit rate is copied from h261codec.cxx, 00102 * until it is moved to a separate file common to both video codecs. 00103 * 00104 */ 00105 00106 #ifndef __OPAL_FFH263CODEC_H 00107 #define __OPAL_FFH263CODEC_H 00108 00109 #ifdef P_USE_PRAGMA 00110 #pragma interface 00111 #endif 00112 00113 #ifdef H323_RFC2190_AVCODEC 00114 #pragma message ("Non-standard H.263 codecs disabled as RFC2190 H.263 is enabled") 00115 #elif defined(H323_AVCODEC) 00116 00117 struct AVCodec; 00118 struct AVCodecContext; 00119 struct AVFrame; 00120 00122 00125 class H323_FFH263Capability : public H323NonStandardVideoCapability 00126 { 00127 PCLASSINFO(H323_FFH263Capability, H323NonStandardVideoCapability) 00128 00129 public: 00134 H323_FFH263Capability( 00135 unsigned sqcifMPI, 00136 unsigned qcifMPI, 00137 unsigned cifMPI, 00138 unsigned cif4MPI, 00139 unsigned cif16MPI, 00140 unsigned maxBitRate = 850, 00141 unsigned videoFrameRate = 25); 00143 00148 virtual PObject * Clone() const; 00150 00159 virtual unsigned GetSubType() const; 00160 00163 virtual PString GetFormatName() const; 00165 00175 virtual BOOL OnSendingPDU( 00176 H245_VideoCapability & pdu 00177 ) const; 00178 00186 virtual BOOL OnSendingPDU( 00187 H245_VideoMode & pdu 00188 ) const; 00189 00197 virtual BOOL OnReceivedPDU( 00198 const H245_VideoCapability & pdu 00199 ); 00200 00203 virtual H323Codec * CreateCodec( 00204 H323Codec::Direction direction 00205 ) const; 00206 00207 00209 00210 protected: 00211 00212 signed sqcifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00213 signed qcifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00214 signed cifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00215 signed cif4MPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00216 signed cif16MPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00217 00218 unsigned maxBitRate; // units of bit/s 00219 unsigned videoFrameRate; // frames per second. 00220 00221 }; 00223 00224 class H263Packet : public PObject 00225 { 00226 PCLASSINFO(H263Packet, PObject) 00227 00228 public: 00229 H263Packet(void *newData, int newSize); 00230 ~H263Packet(); 00231 00232 int GetSize() { return size; } 00233 00234 void *GetData() { return data; } 00235 00236 private: 00237 void *data; 00238 int size; 00239 }; 00240 00242 00243 PDECLARE_LIST(H263FragmentList, H263Packet) 00244 #if 0 //This makes emacs bracket matching code happy. 00245 { 00246 #endif 00247 public: 00248 ~H263FragmentList(); 00249 00250 PINDEX GetFragmentsRemaining(); 00251 00252 PINDEX GetFragmentIndex(); 00253 00254 PINDEX GetFragmentsTotal(); 00255 00256 virtual H263Packet *GetNextFragment(); 00257 00258 void AppendH263Packet(H263Packet *packet); 00259 00260 void AppendH263Packet(unsigned char *data, int size); 00261 00262 void EmptyList(); 00263 00264 private: 00265 PINDEX nPackets; 00266 }; 00267 00268 00270 00272 class H323_FFH263Codec : public H323VideoCodec 00273 { 00274 PCLASSINFO(H323_FFH263Codec, H323VideoCodec) 00275 00276 public: 00279 H323_FFH263Codec( 00280 Direction direction, 00281 unsigned sqcifMPI, 00282 unsigned qcifMPI, 00283 unsigned cifMPI, 00284 unsigned cif4MPI, 00285 unsigned cif16MPI, 00286 unsigned maxBitRate, 00287 unsigned videoFrameRate 00288 ); 00289 00290 ~H323_FFH263Codec(); 00291 00308 virtual BOOL Read( 00309 BYTE * buffer, 00310 unsigned & length, 00311 RTP_DataFrame & rtpFrame 00312 ); 00313 00326 virtual BOOL Write( 00327 const BYTE * buffer, 00328 unsigned length, 00329 const RTP_DataFrame & rtp, 00330 unsigned & written 00331 ); 00332 00335 virtual unsigned GetFrameRate() const { return timestampDelta; } 00336 00342 void SetTxQualityLevel(int qLevel); 00343 00347 void SetBackgroundFill(int fillLevel); 00348 00352 virtual void OnLostPartialPicture(); 00353 00358 virtual void OnLostPicture(); 00359 00365 static void RtpCallback(void *data, int size, int packetNumber); 00366 00367 protected: 00368 BOOL Resize(int width, int height); 00369 00370 BOOL RenderFrame(); 00371 BOOL RenderFrame(const void * buffer); 00372 00373 BOOL RenderFrame(AVFrame *pict); 00374 BOOL RawToPict(AVFrame *pict); 00375 00376 void InitialiseCodec(); 00377 void CloseCodec(); 00378 00379 H263FragmentList partialPackets; //used for rebuilding H263 frame from source. 00380 PINDEX currentFragment; // " " " 00381 00382 PBYTEArray encFrameBuffer; 00383 PBYTEArray rawFrameBuffer; 00384 00385 PINDEX encFrameLen; 00386 PINDEX rawFrameLen; 00387 00388 unsigned timestampDelta; 00389 00390 AVCodec *codec; 00391 AVCodecContext *context; 00392 AVFrame *picture; 00393 00394 PTime startTime; 00395 PINDEX bitsSent; 00396 00397 unsigned lastebits; 00398 }; 00399 00400 #endif // H323_AVCODEC 00401 00402 #endif // __OPAL_FFH263CODEC_H 00403 00404