00001 /* 00002 * h261codec.h 00003 * 00004 * H.323 protocol handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1999-2001 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 2.19 2005/11/30 13:35:26 csoutheren 00029 * Changed tags for Doxygen 00030 * 00031 * Revision 2.18 2005/09/16 07:08:22 dsandras 00032 * Forgot to commit that file yesterday. Declare new variable. 00033 * 00034 * Revision 2.17 2005/09/02 14:31:41 csoutheren 00035 * Use inline function to work around compiler foo in gcc 00036 * 00037 * Revision 2.16 2005/08/28 07:59:17 rjongbloed 00038 * Converted OpalTranscoder to use factory, requiring sme changes in making sure 00039 * OpalMediaFormat instances are initialised before use. 00040 * 00041 * Revision 2.15 2005/08/23 12:46:27 rjongbloed 00042 * Fix some decoder issues, now get inital frame displayed! 00043 * 00044 * Revision 2.14 2005/08/20 09:01:56 rjongbloed 00045 * H.261 port to OPAL model 00046 * 00047 * Revision 2.13 2005/02/21 12:19:45 rjongbloed 00048 * Added new "options list" to the OpalMediaFormat class. 00049 * 00050 * Revision 2.12 2004/03/11 06:54:25 csoutheren 00051 * Added ability to disable SIP or H.323 stacks 00052 * 00053 * Revision 2.11 2004/02/19 10:46:43 rjongbloed 00054 * Merged OpenH323 version 1.13.1 changes. 00055 * 00056 * Revision 2.10 2003/03/17 10:26:59 robertj 00057 * Added video support. 00058 * 00059 * Revision 2.9 2003/01/07 04:39:52 robertj 00060 * Updated to OpenH323 v1.11.2 00061 * 00062 * Revision 2.8 2002/11/10 23:21:26 robertj 00063 * Fixed capability class usage in static variable macros. 00064 * 00065 * Revision 2.7 2002/11/10 11:33:16 robertj 00066 * Updated to OpenH323 v1.10.3 00067 * 00068 * Revision 2.6 2002/09/16 02:52:33 robertj 00069 * Added #define so can select if #pragma interface/implementation is used on 00070 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00071 * 00072 * Revision 2.5 2002/09/04 06:01:46 robertj 00073 * Updated to OpenH323 v1.9.6 00074 * 00075 * Revision 2.4 2002/01/14 06:35:56 robertj 00076 * Updated to OpenH323 v1.7.9 00077 * 00078 * Revision 2.3 2001/11/02 10:45:19 robertj 00079 * Updated to OpenH323 v1.7.3 00080 * 00081 * Revision 2.2 2001/10/05 00:22:13 robertj 00082 * Updated to PWLib 1.2.0 and OpenH323 1.7.0 00083 * 00084 * Revision 2.1 2001/08/01 05:03:09 robertj 00085 * Changes to allow control of linking software transcoders, use macros 00086 * to force linking. 00087 * Allowed codecs to be used without H.,323 being linked by using the 00088 * new NO_H323 define. 00089 * Major changes to H.323 capabilities, uses OpalMediaFormat for base name. 00090 * 00091 * Revision 2.0 2001/07/27 15:48:24 robertj 00092 * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL) 00093 * 00094 * Revision 1.35 2004/01/02 00:31:42 dereksmithies 00095 * Fix test on presence/absence of video. 00096 * 00097 * Revision 1.34 2003/12/14 10:42:29 rjongbloed 00098 * Changes for compilability without video support. 00099 * 00100 * Revision 1.33 2003/10/02 23:37:56 dereksmithies 00101 * Add fix for fast update problem in h261 codec. Thanks to Martin André for doing the initial legwork. 00102 * 00103 * Revision 1.32 2003/04/03 23:54:11 robertj 00104 * Added fast update to H.261 codec, thanks Gustavo García Bernardo 00105 * 00106 * Revision 1.31 2002/12/16 09:11:15 robertj 00107 * Added new video bit rate control, thanks Walter H. Whitlock 00108 * 00109 * Revision 1.30 2002/09/16 01:14:15 robertj 00110 * Added #define so can select if #pragma interface/implementation is used on 00111 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00112 * 00113 * Revision 1.29 2002/09/03 06:19:36 robertj 00114 * Normalised the multi-include header prevention ifdef/define symbol. 00115 * 00116 * Revision 1.28 2002/08/05 10:03:47 robertj 00117 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00118 * 00119 * Revision 1.27 2002/01/09 06:06:37 robertj 00120 * Fixed setting of RTP timestamp values on video transmission. 00121 * 00122 * Revision 1.26 2002/01/09 00:21:36 robertj 00123 * Changes to support outgoing H.245 RequstModeChange. 00124 * 00125 * Revision 1.25 2001/12/04 04:26:03 robertj 00126 * Added code to allow change of video quality in H.261, thanks Damian Sandras 00127 * 00128 * Revision 1.24 2001/10/23 02:18:06 dereks 00129 * Initial release of CU30 video codec. 00130 * 00131 * Revision 1.23 2001/09/25 03:14:47 dereks 00132 * Add constant bitrate control for the h261 video codec. 00133 * Thanks Tiziano Morganti for the code to set bit rate. Good work! 00134 * 00135 * Revision 1.22 2001/05/25 01:10:26 dereks 00136 * Remove unnecessary packet receive variable. 00137 * Alter the position of the check for change in frame size. 00138 * 00139 * Revision 1.21 2001/02/09 05:16:24 robertj 00140 * Added #pragma interface for GNU C++. 00141 * 00142 * Revision 1.20 2001/01/25 07:27:14 robertj 00143 * Major changes to add more flexible OpalMediaFormat class to normalise 00144 * all information about media types, especially codecs. 00145 * 00146 * Revision 1.19 2000/12/19 22:33:44 dereks 00147 * Adjust so that the video channel is used for reading/writing raw video 00148 * data, which better modularizes the video codec. 00149 * 00150 * Revision 1.18 2000/08/21 04:45:06 dereks 00151 * Fix dangling pointer that caused segfaults for windows&unix users. 00152 * Improved the test image which is used when video grabber won't open. 00153 * Added code to handle setting of video Tx Quality. 00154 * Added code to set the number of background blocks sent with every frame. 00155 * 00156 * Revision 1.17 2000/07/04 13:00:36 craigs 00157 * Fixed problem with selecting large and small video sizes 00158 * 00159 * Revision 1.16 2000/05/18 11:53:33 robertj 00160 * Changes to support doc++ documentation generation. 00161 * 00162 * Revision 1.15 2000/05/10 04:05:26 robertj 00163 * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn. 00164 * 00165 * Revision 1.14 2000/05/02 04:32:24 robertj 00166 * Fixed copyright notice comment. 00167 * 00168 * Revision 1.13 2000/03/30 23:10:50 robertj 00169 * Fixed error in comments regarding GetFramerate() function. 00170 * 00171 * Revision 1.12 2000/03/21 03:06:47 robertj 00172 * Changes to make RTP TX of exact numbers of frames in some codecs. 00173 * 00174 * Revision 1.11 2000/02/04 05:00:08 craigs 00175 * Changes for video transmission 00176 * 00177 * Revision 1.10 2000/01/13 04:03:45 robertj 00178 * Added video transmission 00179 * 00180 * Revision 1.9 1999/12/23 23:02:34 robertj 00181 * File reorganision for separating RTP from H.323 and creation of LID for VPB support. 00182 * 00183 * Revision 1.8 1999/11/29 08:59:56 craigs 00184 * Added new stuff for new video codec interface 00185 * 00186 * Revision 1.7 1999/11/01 00:52:00 robertj 00187 * Fixed various problems in video, especially ability to pass error return value. 00188 * 00189 * Revision 1.6 1999/10/08 09:59:02 robertj 00190 * Rewrite of capability for sending multiple audio frames 00191 * 00192 * Revision 1.5 1999/10/08 04:58:37 robertj 00193 * Added capability for sending multiple audio frames in single RTP packet 00194 * 00195 * Revision 1.4 1999/09/21 14:03:41 robertj 00196 * Changed RTP data frame parameter in Write() to be const. 00197 * 00198 * Revision 1.3 1999/09/21 08:12:50 craigs 00199 * Added support for video codecs and H261 00200 * 00201 * Revision 1.2 1999/09/18 13:27:24 craigs 00202 * Added ability disable jitter buffer for codecs 00203 * Added ability to access entire RTP frame from codec Write 00204 * 00205 * Revision 1.1 1999/09/08 04:05:48 robertj 00206 * Added support for video capabilities & codec, still needs the actual codec itself! 00207 * 00208 */ 00209 00210 #ifndef __OPAL_H261CODEC_H 00211 #define __OPAL_H261CODEC_H 00212 00213 #ifdef P_USE_PRAGMA 00214 #pragma interface 00215 #endif 00216 00217 #include <opal/buildopts.h> 00218 00219 #ifndef NO_OPAL_VIDEO 00220 00221 #include <codec/vidcodec.h> 00222 00223 #ifndef NO_H323 00224 #include <h323/h323caps.h> 00225 #endif 00226 00227 class P64Decoder; 00228 class P64Encoder; 00229 00230 #define OPAL_H261_QCIF "H.261(QCIF)" 00231 #define OPAL_H261_CIF "H.261(CIF)" 00232 00233 extern const OpalVideoFormat & GetOpalH261_QCIF(); 00234 extern const OpalVideoFormat & GetOpalH261_CIF(); 00235 00236 #define OpalH261_QCIF GetOpalH261_QCIF() 00237 #define OpalH261_CIF GetOpalH261_CIF() 00238 00239 00241 00242 #ifndef NO_H323 00243 00246 class H323_H261Capability : public H323VideoCapability 00247 { 00248 PCLASSINFO(H323_H261Capability, H323VideoCapability) 00249 00250 public: 00255 H323_H261Capability( 00256 unsigned qcifMPI, 00257 unsigned cifMPI, 00258 BOOL temporalSpatialTradeOffCapability = FALSE, 00259 BOOL stillImageTransmission = FALSE, 00260 unsigned maxBitRate = 850 00261 ); 00263 00268 virtual PObject * Clone() const; 00269 00272 Comparison Compare(const PObject & obj) const; 00274 00283 virtual unsigned GetSubType() const; 00284 00287 virtual PString GetFormatName() const; 00289 00299 virtual BOOL OnSendingPDU( 00300 H245_VideoCapability & pdu 00301 ) const; 00302 00310 virtual BOOL OnSendingPDU( 00311 H245_VideoMode & pdu 00312 ) const; 00313 00321 virtual BOOL OnReceivedPDU( 00322 const H245_VideoCapability & pdu 00323 ); 00324 00327 BOOL GetTemporalSpatialTradeOffCapability() const 00328 { return temporalSpatialTradeOffCapability; } 00329 00332 BOOL GetStillImageTransmission() const 00333 { return stillImageTransmission; } 00334 00337 unsigned GetMaxBitRate() const 00338 { return maxBitRate; } 00339 00342 unsigned GetQCIFMPI() const 00343 { return qcifMPI; } 00344 00347 unsigned GetCIFMPI() const 00348 { return cifMPI; } 00349 00355 void SetTxQualityLevel(int qLevel); 00357 00358 protected: 00359 unsigned qcifMPI; // 1..4 units 1/29.97 Hz 00360 unsigned cifMPI; // 1..4 units 1/29.97 Hz 00361 BOOL temporalSpatialTradeOffCapability; 00362 00363 unsigned maxBitRate; // units of 100 bit/s 00364 BOOL stillImageTransmission; // Annex D of H.261 00365 }; 00366 00367 #define OPAL_REGISTER_H261_H323 \ 00368 H323_REGISTER_CAPABILITY_FUNCTION(H323_H261_CIF, OPAL_H261_CIF, H323_NO_EP_VAR) \ 00369 { return new H323_H261Capability(0, 1); } \ 00370 H323_REGISTER_CAPABILITY_FUNCTION(H323_H261_QCIF, OPAL_H261_QCIF, H323_NO_EP_VAR) \ 00371 { return new H323_H261Capability(1, 0); } 00372 00373 #else // ifndef NO_H323 00374 00375 #define OPAL_REGISTER_H261_H323 00376 00377 #endif // ifndef NO_H323 00378 00379 00381 00382 class Opal_H261_YUV420P : public OpalVideoTranscoder { 00383 public: 00384 Opal_H261_YUV420P(); 00385 ~Opal_H261_YUV420P(); 00386 virtual PINDEX GetOptimalDataFrameSize(BOOL input) const; 00387 virtual BOOL ConvertFrames(const RTP_DataFrame & src, RTP_DataFrameList & dst); 00388 protected: 00389 P64Decoder * videoDecoder; 00390 WORD expectedSequenceNumber; 00391 BYTE * rvts; 00392 int ndblk, nblk; 00393 int now; 00394 BOOL packetReceived; 00395 }; 00396 00397 00398 class Opal_YUV420P_H261 : public OpalVideoTranscoder { 00399 public: 00400 Opal_YUV420P_H261(); 00401 ~Opal_YUV420P_H261(); 00402 virtual PINDEX GetOptimalDataFrameSize(BOOL input) const; 00403 virtual BOOL ConvertFrames(const RTP_DataFrame & src, RTP_DataFrameList & dst); 00404 protected: 00405 P64Encoder * videoEncoder; 00406 PTimeInterval newTime; 00407 }; 00408 00409 00411 00412 #define OPAL_REGISTER_H261() \ 00413 OPAL_REGISTER_H261_H323 \ 00414 OpalTranscoderFactory::Worker<Opal_H261_YUV420P> Opal_H261_YUV420P_QCIF(OpalCreateMediaFormatPair(OpalH261_QCIF, OpalYUV420P)); \ 00415 OpalTranscoderFactory::Worker<Opal_YUV420P_H261> Opal_YUV420P_H261_QCIF(OpalCreateMediaFormatPair(OpalYUV420P, OpalH261_QCIF)); \ 00416 OpalTranscoderFactory::Worker<Opal_H261_YUV420P> Opal_H261_YUV420P_CIF (OpalCreateMediaFormatPair(OpalH261_CIF, OpalYUV420P)); \ 00417 OpalTranscoderFactory::Worker<Opal_YUV420P_H261> Opal_YUV420P_H261_CIF (OpalCreateMediaFormatPair(OpalYUV420P, OpalH261_CIF)) 00418 00419 00420 #endif // __OPAL_H261CODEC_H 00421 00422 00423 #endif // NO_OPAL_VIDEO 00424 00425