OpenH323 1.18.0
|
00001 /* 00002 * h263codec.h 00003 * 00004 * H.323 protocol handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1999-2000 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): Guilhem Tardy (gtardy@marchnetworks.com) 00025 * 00026 * $Log: h263codec.h,v $ 00027 * Revision 1.17 2005/11/30 13:05:01 csoutheren 00028 * Changed tags for Doxygen 00029 * 00030 * Revision 1.16 2004/04/22 22:35:00 csoutheren 00031 * Fixed mispelling of Guilhem Tardy - my apologies to him 00032 * 00033 * Revision 1.15 2004/04/22 14:22:20 csoutheren 00034 * Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet 00035 * Many thanks to them for their contributions. 00036 * 00037 * Revision 1.14 2003/08/04 00:03:22 dereksmithies 00038 * Reorganise tests for enabled 00039 * 00040 * Revision 1.13 2003/07/24 08:08:42 dereksmithies 00041 * Update to use vich263 codec, instead of ffmpeg. 00042 * 00043 * Revision 1.12 2003/06/06 05:18:54 dereksmithies 00044 * Fix startup delay bug. Remove all large packets from the network. Improve reliability. 00045 * 00046 * Revision 1.11 2003/05/27 09:22:55 dereksmithies 00047 * Updates for code revisions in h263 codec 00048 * 00049 * Revision 1.10 2003/05/14 13:47:58 rjongbloed 00050 * Removed static "initialisation" function as this should be done 00051 * internally and not in the application. 00052 * 00053 * Revision 1.9 2003/05/05 11:59:21 robertj 00054 * Changed to use autoconf style selection of options and subsystems. 00055 * 00056 * Revision 1.8 2003/05/02 04:22:10 craigs 00057 * Added lots of extra H.263 support 00058 * 00059 * Revision 1.7 2003/04/27 09:16:38 rogerh 00060 * use PBYTE_ORDER instead of endian.h 00061 * 00062 * Revision 1.6 2003/04/21 21:50:22 dereks 00063 * Implement suggestion from Guilhem Tardy. Many thanks. 00064 * 00065 * Revision 1.5 2003/04/16 04:26:57 dereks 00066 * Initial release of h263 codec, which utilises the ffmpeg library. 00067 * Thanks to Guilhem Tardy, and to AliceStreet. 00068 * 00069 * Revision 1.4 2002/09/16 01:14:15 robertj 00070 * Added #define so can select if #pragma interface/implementation is used on 00071 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00072 * 00073 * Revision 1.3 2002/09/03 06:19:36 robertj 00074 * Normalised the multi-include header prevention ifdef/define symbol. 00075 * 00076 * Revision 1.2 2002/08/05 10:03:47 robertj 00077 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00078 * 00079 * Revision 1.1 2002/05/19 22:32:46 dereks 00080 * Initial release of stub file for h263 codec. Thanks Guilhem Tardy. 00081 * 00082 * 00083 * 00084 */ 00085 00086 /* 00087 * Initial release notes from Guilhem Tardy:: 00088 * 00089 * Added support for video capabilities & codec, only tested under Linux! 00090 * The code for varying bit rate is copied from h261codec.cxx, 00091 * until it is moved to a separate file common to both video codecs. 00092 * 00093 */ 00094 00095 #ifndef __OPAL_H263CODEC_H 00096 #define __OPAL_H263CODEC_H 00097 00098 #ifdef P_USE_PRAGMA 00099 #pragma interface 00100 #endif 00101 00102 #include <openh323buildopts.h> 00103 00104 00105 #include "h323caps.h" 00106 00107 #if defined(H323_VICH263) || defined(H323_RFC2190_AVCODEC) 00108 00109 class H263Decoder; 00110 class H263Encoder; 00111 00113 00117 class H323_H263Capability : public H323VideoCapability 00118 { 00119 PCLASSINFO(H323_H263Capability, H323VideoCapability) 00120 00121 public: 00126 H323_H263Capability( 00127 unsigned sqcifMPI, 00128 unsigned qcifMPI, 00129 unsigned cifMPI, 00130 unsigned cif4MPI, 00131 unsigned cif16MPI, 00132 unsigned maxBitRate = 850, 00133 unsigned videoFrameRate = 25, 00134 BOOL unrestrictedVector = FALSE, 00135 BOOL arithmeticCoding = FALSE, 00136 BOOL advancedPrediction = FALSE, 00137 BOOL pbFrames = FALSE, 00138 BOOL temporalSpatialTradeOff = TRUE, 00139 unsigned hrd_B = 0, 00140 unsigned bppMaxKb = 0, 00141 unsigned slowSqcifMPI = 0, 00142 unsigned slowQcifMPI = 0, 00143 unsigned slowCifMPI = 0, 00144 unsigned slowCif4MPI = 0, 00145 unsigned slowCif16MPI = 0, 00146 BOOL errorCompensation = FALSE 00147 ); 00149 00154 virtual PObject * Clone() const; 00156 00157 00162 Comparison Compare(const PObject & obj) const; 00164 00173 virtual unsigned GetSubType() const; 00174 00177 virtual PString GetFormatName() const; 00179 00189 virtual BOOL OnSendingPDU( 00190 H245_VideoCapability & pdu 00191 ) const; 00192 00200 virtual BOOL OnSendingPDU( 00201 H245_VideoMode & pdu 00202 ) const; 00203 00211 virtual BOOL OnReceivedPDU( 00212 const H245_VideoCapability & pdu 00213 ); 00214 00217 virtual H323Codec * CreateCodec( 00218 H323Codec::Direction direction 00219 ) const; 00220 00221 #if 0 00222 00224 unsigned GetSQCIFMPI() const 00225 { return sqcifMPI); } 00226 00229 unsigned GetQCIFMPI() const 00230 { return qcifMPI; } 00231 00234 unsigned GetCIFMPI() const 00235 { return cifMPI; } 00236 00239 unsigned GetCIF4MPI() const 00240 { return cif4MPI; } 00241 00244 unsigned GetCIF16MPI() const 00245 { return cif16MPI; } 00246 00249 unsigned GetMaxBitRate() const 00250 { return maxBitRate; } 00251 00254 BOOL GetUnrestrictedVectorCapability() const 00255 { return unrestrictedVector; } 00256 00259 BOOL GetArithmeticCodingCapability() const 00260 { return arithmeticCoding; } 00261 00264 BOOL GetAdvancedPredictionCapability() const 00265 { return advancedPrediction; } 00266 00269 BOOL GetPbFramesCapability() const 00270 { return pbFrames; } 00271 00274 BOOL GetTemporalSpatialTradeOffCapability() const 00275 { return temporalSpatialTradeOff; } 00276 00279 BOOL GetHrd_B() const 00280 { return hrd_B; } 00281 00284 BOOL GetBppMaxKb() const 00285 { return bppMaxKb; } 00286 00289 unsigned GetSlowSQCIFMPI() const 00290 { return (sqcifMPI<0?-sqcifMPI:0); } 00291 00294 unsigned GetSlowQCIFMPI() const 00295 { return (qcifMPI<0?-qcifMPI:0); } 00296 00299 unsigned GetSlowCIFMPI() const 00300 { return (cifMPI<0?-cifMPI:0); } 00301 00304 unsigned GetSlowCIF4MPI() const 00305 { return (cif4MPI<0?-cif4MPI:0); } 00306 00309 unsigned GetSlowCIF16MPI() const 00310 { return (cif16MPI<0?-cif16MPI:0); } 00311 00314 BOOL GetErrorCompensationCapability() const 00315 { return errorCompensation; } 00316 #endif 00317 00319 00320 protected: 00321 // H.263 v1 00322 signed sqcifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00323 signed qcifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00324 signed cifMPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00325 signed cif4MPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00326 signed cif16MPI; // {1..3600 units seconds/frame, 1..32 units 1/29.97 Hz} 00327 00328 unsigned maxBitRate; // units of bit/s 00329 unsigned videoFrameRate; // frames per second. 00330 00331 BOOL unrestrictedVector; 00332 BOOL arithmeticCoding; 00333 BOOL advancedPrediction; 00334 BOOL pbFrames; 00335 BOOL temporalSpatialTradeOff; 00336 00337 long unsigned hrd_B; // units of 128 bits 00338 unsigned bppMaxKb; // units of 1024 bits 00339 00340 BOOL errorCompensation; 00341 }; 00342 00344 00346 class H323_H263Codec : public H323VideoCodec 00347 { 00348 PCLASSINFO(H323_H263Codec, H323VideoCodec) 00349 00350 public: 00353 H323_H263Codec( 00354 Direction direction, 00355 unsigned sqcifMPI, 00356 unsigned qcifMPI, 00357 unsigned cifMPI, 00358 unsigned cif4MPI, 00359 unsigned cif16MPI, 00360 unsigned maxBitRate, 00361 unsigned videoFrameRate 00362 ); 00363 00364 ~H323_H263Codec(); 00365 00382 virtual BOOL Read( 00383 BYTE * buffer, 00384 unsigned & length, 00385 RTP_DataFrame & rtpFrame 00386 ); 00387 00400 virtual BOOL Write( 00401 const BYTE * buffer, 00402 unsigned length, 00403 const RTP_DataFrame & rtp, 00404 unsigned & written 00405 ); 00406 00409 virtual unsigned GetFrameRate() const { return timestampDelta; } 00410 00416 void SetTxQualityLevel(int qLevel); 00417 00421 void SetBackgroundFill(int fillLevel); 00422 00426 virtual void OnLostPartialPicture(); 00427 00432 virtual void OnLostPicture(); 00433 00439 static void RtpCallback(void *data, int size, int packetNumber); 00440 00441 protected: 00442 BOOL Resize(int width, int height); 00443 00444 BOOL RenderFrame(); 00445 BOOL RenderFrame(const void * buffer); 00446 00447 00448 00449 void InitialiseCodec(); 00450 void CloseCodec(); 00451 00452 00453 unsigned timestampDelta; 00454 00455 H263Decoder *videoDecoder; 00456 H263Encoder *videoEncoder; 00457 00458 int now; 00459 BYTE * rvts; 00460 int ndblk, nblk; 00461 00462 PTime startTime; 00463 PINDEX bitsSent; 00464 00465 unsigned lastebits; 00466 }; 00467 00468 #endif // H323_VICH263 00469 #endif // __OPAL_H263CODEC_H 00470 00471 00472 00473