00001 /* 00002 * h261codec.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): Michele Piccini (michele@piccini.com). 00025 * Derek Smithies (derek@indranet.co.nz) 00026 * 00027 * $Log: h261codec.h,v $ 00028 * Revision 1.35 2004/01/02 00:31:42 dereksmithies 00029 * Fix test on presence/absence of video. 00030 * 00031 * Revision 1.34 2003/12/14 10:42:29 rjongbloed 00032 * Changes for compilability without video support. 00033 * 00034 * Revision 1.33 2003/10/02 23:37:56 dereksmithies 00035 * Add fix for fast update problem in h261 codec. Thanks to Martin André for doing the initial legwork. 00036 * 00037 * Revision 1.32 2003/04/03 23:54:11 robertj 00038 * Added fast update to H.261 codec, thanks Gustavo García Bernardo 00039 * 00040 * Revision 1.31 2002/12/16 09:11:15 robertj 00041 * Added new video bit rate control, thanks Walter H. Whitlock 00042 * 00043 * Revision 1.30 2002/09/16 01:14:15 robertj 00044 * Added #define so can select if #pragma interface/implementation is used on 00045 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00046 * 00047 * Revision 1.29 2002/09/03 06:19:36 robertj 00048 * Normalised the multi-include header prevention ifdef/define symbol. 00049 * 00050 * Revision 1.28 2002/08/05 10:03:47 robertj 00051 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00052 * 00053 * Revision 1.27 2002/01/09 06:06:37 robertj 00054 * Fixed setting of RTP timestamp values on video transmission. 00055 * 00056 * Revision 1.26 2002/01/09 00:21:36 robertj 00057 * Changes to support outgoing H.245 RequstModeChange. 00058 * 00059 * Revision 1.25 2001/12/04 04:26:03 robertj 00060 * Added code to allow change of video quality in H.261, thanks Damian Sandras 00061 * 00062 * Revision 1.24 2001/10/23 02:18:06 dereks 00063 * Initial release of CU30 video codec. 00064 * 00065 * Revision 1.23 2001/09/25 03:14:47 dereks 00066 * Add constant bitrate control for the h261 video codec. 00067 * Thanks Tiziano Morganti for the code to set bit rate. Good work! 00068 * 00069 * Revision 1.22 2001/05/25 01:10:26 dereks 00070 * Remove unnecessary packet receive variable. 00071 * Alter the position of the check for change in frame size. 00072 * 00073 * Revision 1.21 2001/02/09 05:16:24 robertj 00074 * Added #pragma interface for GNU C++. 00075 * 00076 * Revision 1.20 2001/01/25 07:27:14 robertj 00077 * Major changes to add more flexible OpalMediaFormat class to normalise 00078 * all information about media types, especially codecs. 00079 * 00080 * Revision 1.19 2000/12/19 22:33:44 dereks 00081 * Adjust so that the video channel is used for reading/writing raw video 00082 * data, which better modularizes the video codec. 00083 * 00084 * Revision 1.18 2000/08/21 04:45:06 dereks 00085 * Fix dangling pointer that caused segfaults for windows&unix users. 00086 * Improved the test image which is used when video grabber won't open. 00087 * Added code to handle setting of video Tx Quality. 00088 * Added code to set the number of background blocks sent with every frame. 00089 * 00090 * Revision 1.17 2000/07/04 13:00:36 craigs 00091 * Fixed problem with selecting large and small video sizes 00092 * 00093 * Revision 1.16 2000/05/18 11:53:33 robertj 00094 * Changes to support doc++ documentation generation. 00095 * 00096 * Revision 1.15 2000/05/10 04:05:26 robertj 00097 * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn. 00098 * 00099 * Revision 1.14 2000/05/02 04:32:24 robertj 00100 * Fixed copyright notice comment. 00101 * 00102 * Revision 1.13 2000/03/30 23:10:50 robertj 00103 * Fixed error in comments regarding GetFramerate() function. 00104 * 00105 * Revision 1.12 2000/03/21 03:06:47 robertj 00106 * Changes to make RTP TX of exact numbers of frames in some codecs. 00107 * 00108 * Revision 1.11 2000/02/04 05:00:08 craigs 00109 * Changes for video transmission 00110 * 00111 * Revision 1.10 2000/01/13 04:03:45 robertj 00112 * Added video transmission 00113 * 00114 * Revision 1.9 1999/12/23 23:02:34 robertj 00115 * File reorganision for separating RTP from H.323 and creation of LID for VPB support. 00116 * 00117 * Revision 1.8 1999/11/29 08:59:56 craigs 00118 * Added new stuff for new video codec interface 00119 * 00120 * Revision 1.7 1999/11/01 00:52:00 robertj 00121 * Fixed various problems in video, especially ability to pass error return value. 00122 * 00123 * Revision 1.6 1999/10/08 09:59:02 robertj 00124 * Rewrite of capability for sending multiple audio frames 00125 * 00126 * Revision 1.5 1999/10/08 04:58:37 robertj 00127 * Added capability for sending multiple audio frames in single RTP packet 00128 * 00129 * Revision 1.4 1999/09/21 14:03:41 robertj 00130 * Changed RTP data frame parameter in Write() to be const. 00131 * 00132 * Revision 1.3 1999/09/21 08:12:50 craigs 00133 * Added support for video codecs and H261 00134 * 00135 * Revision 1.2 1999/09/18 13:27:24 craigs 00136 * Added ability disable jitter buffer for codecs 00137 * Added ability to access entire RTP frame from codec Write 00138 * 00139 * Revision 1.1 1999/09/08 04:05:48 robertj 00140 * Added support for video capabilities & codec, still needs the actual codec itself! 00141 * 00142 */ 00143 00144 #ifndef __OPAL_H261CODEC_H 00145 #define __OPAL_H261CODEC_H 00146 00147 #ifdef P_USE_PRAGMA 00148 #pragma interface 00149 #endif 00150 00151 00152 #include "h323caps.h" 00153 00154 #ifndef NO_H323_VIDEO 00155 00156 00157 class P64Decoder; 00158 class P64Encoder; 00159 00160 00161 00163 00166 class H323_H261Capability : public H323VideoCapability 00167 { 00168 PCLASSINFO(H323_H261Capability, H323VideoCapability) 00169 00170 public: 00175 H323_H261Capability( 00176 unsigned qcifMPI, 00177 unsigned cifMPI, 00178 BOOL temporalSpatialTradeOffCapability = TRUE, 00179 BOOL stillImageTransmission = FALSE, 00180 unsigned maxBitRate = 850 00181 ); 00183 00188 virtual PObject * Clone() const; 00190 00191 00196 Comparison Compare(const PObject & obj) const; 00198 00207 virtual unsigned GetSubType() const; 00208 00211 virtual PString GetFormatName() const; 00213 00223 virtual BOOL OnSendingPDU( 00224 H245_VideoCapability & pdu 00225 ) const; 00226 00234 virtual BOOL OnSendingPDU( 00235 H245_VideoMode & pdu 00236 ) const; 00237 00245 virtual BOOL OnReceivedPDU( 00246 const H245_VideoCapability & pdu 00247 ); 00248 00251 virtual H323Codec * CreateCodec( 00252 H323Codec::Direction direction 00253 ) const; 00254 00257 BOOL GetTemporalSpatialTradeOffCapability() const 00258 { return temporalSpatialTradeOffCapability; } 00259 00262 BOOL GetStillImageTransmission() const 00263 { return stillImageTransmission; } 00264 00267 unsigned GetMaxBitRate() const 00268 { return maxBitRate; } 00269 00272 unsigned GetQCIFMPI() const 00273 { return qcifMPI; } 00274 00277 unsigned GetCIFMPI() const 00278 { return cifMPI; } 00279 00281 00282 protected: 00283 unsigned qcifMPI; // 1..4 units 1/29.97 Hz 00284 unsigned cifMPI; // 1..4 units 1/29.97 Hz 00285 BOOL temporalSpatialTradeOffCapability; 00286 unsigned maxBitRate; // units of 100 bit/s 00287 BOOL stillImageTransmission; // Annex D of H.261 00288 }; 00289 00290 00293 class H323_H261Codec : public H323VideoCodec 00294 { 00295 PCLASSINFO(H323_H261Codec, H323VideoCodec) 00296 00297 public: 00300 H323_H261Codec( 00301 Direction direction, 00302 BOOL isqCIF 00303 ); 00304 ~H323_H261Codec(); 00305 00322 virtual BOOL Read( 00323 BYTE * buffer, 00324 unsigned & length, 00325 RTP_DataFrame & rtpFrame 00326 ); 00327 00340 virtual BOOL Write( 00341 const BYTE * buffer, 00342 unsigned length, 00343 const RTP_DataFrame & rtp, 00344 unsigned & written 00345 ); 00346 00349 virtual unsigned GetFrameRate() const { return timestampDelta; } 00350 00356 void SetTxQualityLevel(int qLevel); 00357 00361 void SetTxMinQuality(int qlevel); 00362 00366 void SetTxMaxQuality(int qlevel); 00367 00371 void SetBackgroundFill(int fillLevel); 00372 00376 virtual void OnFastUpdatePicture(); 00377 00381 virtual void OnLostPartialPicture(); 00382 00386 virtual void OnLostPicture(); 00387 00389 //There is a problem with the H261codec. It needs to be able to 00390 //carry out two tasks. 1)Grab data from the camera. 00391 //2)Render data from an array. 00392 //Thus, we either: two PVideoChannels, or one PVideoChannel to both 00393 //grab and render. 00394 //We use one PVideoChannel, which is not consistant with elsewhere, 00395 //but enables us to (later) have a grab and display process irrespective 00396 //of there being a H323 connection. 00397 00398 00399 protected: 00400 BOOL Resize(int width, int height); 00401 BOOL Redraw(); 00402 BOOL RenderFrame(); 00403 00404 BOOL doFastUpdate; 00405 PMutex fastUpdateMutex; 00406 00407 P64Decoder * videoDecoder; 00408 P64Encoder * videoEncoder; 00409 00410 int now; 00411 BYTE * rvts; 00412 int ndblk, nblk; 00413 unsigned timestampDelta; 00414 }; 00415 00416 00417 #endif // __OPAL_H261CODEC_H 00418 00419 00420 #endif // NO_H323_VIDEO 00421 00422