h323caps.h

Go to the documentation of this file.
00001 /*
00002  * h323caps.h
00003  *
00004  * H.323 protocol handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1998-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  * Portions of this code were written with the assisance of funding from
00025  * Vovida Networks, Inc. http://www.vovida.com.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: h323caps.h,v $
00030  * Revision 2.22  2007/09/19 10:43:00  csoutheren
00031  * Exposed G.7231 capability class
00032  * Added macros to create empty transcoders and capabilities
00033  *
00034  * Revision 2.21  2007/09/12 04:19:53  rjongbloed
00035  * CHanges to avoid creation of long duration OpalMediaFormat instances, eg in
00036  *   the plug in capabilities, that then do not get updated values from the master
00037  *   list, or worse from the user modified master list, causing much confusion.
00038  *
00039  * Revision 2.20  2007/06/22 06:29:13  rjongbloed
00040  * Fixed GCC warnings.
00041  *
00042  * Revision 2.19  2007/06/22 05:49:12  rjongbloed
00043  * Major codec API update:
00044  *   Automatically map OpalMediaOptions to SIP/SDP FMTP parameters.
00045  *   Automatically map OpalMediaOptions to H.245 Generic Capability parameters.
00046  *   Largely removed need to distinguish between SIP and H.323 codecs.
00047  *   New mechanism for setting OpalMediaOptions from within a plug in.
00048  * Fixed removal of H.323 capabilities just because media format name is a
00049  *   substring of capability name.
00050  * Fixed inadequacies in H.245 Generic Capabilities (must be able to
00051  *   distinguish between TCS, OLC and ReqMode).
00052  *
00053  * Revision 2.18  2007/04/10 05:15:53  rjongbloed
00054  * Fixed issue with use of static C string variables in DLL environment,
00055  *   must use functional interface for correct initialisation.
00056  *
00057  * Revision 2.17  2006/08/11 07:52:01  csoutheren
00058  * Fix problem with media format factory in VC 2005
00059  * Fixing problems with Speex codec
00060  * Remove non-portable usages of PFactory code
00061  *
00062  * Revision 2.16  2006/07/24 14:03:38  csoutheren
00063  * Merged in audio and video plugins from CVS branch PluginBranch
00064  *
00065  * Revision 2.15.4.3  2006/04/10 06:24:29  csoutheren
00066  * Backport from CVS head up to Plugin_Merge3
00067  *
00068  * Revision 2.15.4.2  2006/04/06 01:21:17  csoutheren
00069  * More implementation of video codec plugins
00070  *
00071  * Revision 2.15.4.1  2006/03/23 07:55:18  csoutheren
00072  * Audio plugin H.323 capability merging completed.
00073  * GSM, LBC, G.711 working. Speex and LPC-10 are not
00074  *
00075  * Revision 2.15  2005/11/30 13:35:26  csoutheren
00076  * Changed tags for Doxygen
00077  *
00078  * Revision 2.14  2005/02/21 12:19:45  rjongbloed
00079  * Added new "options list" to the OpalMediaFormat class.
00080  *
00081  * Revision 2.13  2004/09/01 12:21:27  rjongbloed
00082  * Added initialisation of H323EndPoints capability table to be all codecs so can
00083  *   correctly build remote caps from fqast connect params. This had knock on effect
00084  *   with const keywords added in numerous places.
00085  *
00086  * Revision 2.12  2004/02/19 10:46:43  rjongbloed
00087  * Merged OpenH323 version 1.13.1 changes.
00088  *
00089  * Revision 2.11  2002/11/10 11:33:16  robertj
00090  * Updated to OpenH323 v1.10.3
00091  *
00092  * Revision 2.10  2002/09/16 02:52:33  robertj
00093  * Added #define so can select if #pragma interface/implementation is used on
00094  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00095  *
00096  * Revision 2.9  2002/09/04 06:01:46  robertj
00097  * Updated to OpenH323 v1.9.6
00098  *
00099  * Revision 2.8  2002/07/01 04:56:29  robertj
00100  * Updated to OpenH323 v1.9.1
00101  *
00102  * Revision 2.7  2002/02/19 07:44:13  robertj
00103  * Added function to set teh RTP payload type for the capability.
00104  *
00105  * Revision 2.6  2002/02/11 09:32:11  robertj
00106  * Updated to openH323 v1.8.0
00107  *
00108  * Revision 2.5  2002/01/22 04:59:04  robertj
00109  * Update from OpenH323, RFC2833 support
00110  *
00111  * Revision 2.4  2002/01/14 06:35:56  robertj
00112  * Updated to OpenH323 v1.7.9
00113  *
00114  * Revision 2.3  2001/11/02 10:45:19  robertj
00115  * Updated to OpenH323 v1.7.3
00116  *
00117  * Revision 2.2  2001/10/05 00:22:13  robertj
00118  * Updated to PWLib 1.2.0 and OpenH323 1.7.0
00119  *
00120  * Revision 2.1  2001/08/01 05:12:04  robertj
00121  * Major changes to H.323 capabilities, uses OpalMediaFormat for base name.
00122  * Added "known" codecs capability clases.
00123  *
00124  * Revision 2.0  2001/07/27 15:48:24  robertj
00125  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00126  *
00127  * Revision 1.40  2003/10/27 06:03:39  csoutheren
00128  * Added support for QoS
00129  *   Thanks to Henry Harrison of AliceStreet
00130  *
00131  * Revision 1.39  2003/06/06 02:13:10  rjongbloed
00132  * Changed non-standard capability semantics so can use C style strings as
00133  *   the embedded data block (ie automatically call strlen)
00134  *
00135  * Revision 1.38  2003/04/28 07:00:00  robertj
00136  * Fixed problem with compiler(s) not correctly initialising static globals
00137  *
00138  * Revision 1.37  2003/04/27 23:49:21  craigs
00139  * Fixed some comments and made list of registered codecs
00140  * available outside h323caps.cxx
00141  *
00142  * Revision 1.36  2002/11/09 04:24:01  robertj
00143  * Fixed minor documentation errors.
00144  *
00145  * Revision 1.35  2002/09/16 01:14:15  robertj
00146  * Added #define so can select if #pragma interface/implementation is used on
00147  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00148  *
00149  * Revision 1.34  2002/09/03 06:19:36  robertj
00150  * Normalised the multi-include header prevention ifdef/define symbol.
00151  *
00152  * Revision 1.33  2002/08/05 10:03:47  robertj
00153  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00154  *
00155  * Revision 1.32  2002/05/29 03:55:17  robertj
00156  * Added protocol version number checking infrastructure, primarily to improve
00157  *   interoperability with stacks that are unforgiving of new features.
00158  *
00159  * Revision 1.31  2002/05/10 05:44:50  robertj
00160  * Added the max bit rate field to the data channel capability class.
00161  *
00162  * Revision 1.30  2002/01/22 06:25:02  robertj
00163  * Moved payload type to ancestor so any capability can adjust it on logical channel.
00164  *
00165  * Revision 1.29  2002/01/17 07:04:57  robertj
00166  * Added support for RFC2833 embedded DTMF in the RTP stream.
00167  *
00168  * Revision 1.28  2002/01/16 05:37:41  robertj
00169  * Added missing mode change functions on non standard capabilities.
00170  *
00171  * Revision 1.27  2002/01/09 00:21:36  robertj
00172  * Changes to support outgoing H.245 RequstModeChange.
00173  *
00174  * Revision 1.26  2001/12/22 01:44:05  robertj
00175  * Added more support for H.245 RequestMode operation.
00176  *
00177  * Revision 1.25  2001/10/24 01:20:34  robertj
00178  * Added code to help with static linking of H323Capability names database.
00179  *
00180  * Revision 1.24  2001/09/21 02:48:51  robertj
00181  * Added default implementation for PDU encode/decode for codecs
00182  *   that have simple integer as frames per packet.
00183  *
00184  * Revision 1.23  2001/09/11 10:21:40  robertj
00185  * Added direction field to capabilities, thanks Nick Hoath.
00186  *
00187  * Revision 1.22  2001/07/19 09:50:40  robertj
00188  * Added code for default session ID on data channel being three.
00189  *
00190  * Revision 1.21  2001/07/17 04:44:29  robertj
00191  * Partial implementation of T.120 and T.38 logical channels.
00192  *
00193  * Revision 1.20  2001/05/21 07:20:47  robertj
00194  * Removed redundent class name in declaration.
00195  *
00196  * Revision 1.19  2001/05/14 05:56:26  robertj
00197  * Added H323 capability registration system so can add capabilities by
00198  *   string name instead of having to instantiate explicit classes.
00199  *
00200  * Revision 1.18  2001/05/02 16:22:21  rogerh
00201  * Add IsAllow() for a single capability to check if it is in the
00202  * capabilities set. This fixes the bug where OpenH323 would accept
00203  * incoming H261 video even when told not to accept it.
00204  *
00205  * Revision 1.17  2001/03/16 23:00:21  robertj
00206  * Improved validation of codec selection against capability set, thanks Chris Purvis.
00207  *
00208  * Revision 1.16  2001/02/09 05:16:24  robertj
00209  * Added #pragma interface for GNU C++.
00210  *
00211  * Revision 1.15  2001/01/25 07:27:14  robertj
00212  * Major changes to add more flexible OpalMediaFormat class to normalise
00213  *   all information about media types, especially codecs.
00214  *
00215  * Revision 1.14  2001/01/09 23:05:22  robertj
00216  * Fixed inability to have 2 non standard codecs in capability table.
00217  *
00218  * Revision 1.13  2000/10/16 08:49:30  robertj
00219  * Added single function to add all UserInput capability types.
00220  *
00221  * Revision 1.12  2000/08/23 14:23:11  craigs
00222  * Added prototype support for Microsoft GSM codec
00223  *
00224  * Revision 1.11  2000/07/13 12:25:47  robertj
00225  * Fixed problems with fast start frames per packet adjustment.
00226  *
00227  * Revision 1.10  2000/07/10 16:01:50  robertj
00228  * Started fixing capability set merging, still more to do.
00229  *
00230  * Revision 1.9  2000/07/04 01:16:49  robertj
00231  * Added check for capability allowed in "combinations" set, still needs more done yet.
00232  *
00233  * Revision 1.8  2000/06/03 03:16:47  robertj
00234  * Fixed using the wrong capability table (should be connections) for some operations.
00235  *
00236  * Revision 1.7  2000/05/23 11:32:27  robertj
00237  * Rewrite of capability table to combine 2 structures into one and move functionality into that class
00238  *    allowing some normalisation of usage across several applications.
00239  * Changed H323Connection so gets a copy of capabilities instead of using endponts, allows adjustments
00240  *    to be done depending on the remote client application.
00241  *
00242  * Revision 1.6  2000/05/18 11:53:34  robertj
00243  * Changes to support doc++ documentation generation.
00244  *
00245  * Revision 1.5  2000/05/10 04:05:26  robertj
00246  * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
00247  *
00248  * Revision 1.4  2000/05/02 04:32:24  robertj
00249  * Fixed copyright notice comment.
00250  *
00251  * Revision 1.3  2000/04/05 19:01:12  robertj
00252  * Added function so can change desired transmit packet size.
00253  *
00254  * Revision 1.2  2000/03/21 03:06:47  robertj
00255  * Changes to make RTP TX of exact numbers of frames in some codecs.
00256  *
00257  * Revision 1.1  1999/12/23 23:02:35  robertj
00258  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00259  *
00260  */
00261 
00262 #ifndef __OPAL_H323CAPS_H
00263 #define __OPAL_H323CAPS_H
00264 
00265 #ifdef P_USE_PRAGMA
00266 #pragma interface
00267 #endif
00268 
00269 
00270 #include <opal/mediafmt.h>
00271 #include <h323/channels.h>
00272 
00273 
00274 /* The following classes have forward references to avoid including the VERY
00275    large header files for H225 and H245. If an application requires access
00276    to the protocol classes they can include them, but for simple usage their
00277    inclusion can be avoided.
00278  */
00279 class PASN_Choice;
00280 class H245_Capability;
00281 class H245_DataType;
00282 class H245_ModeElement;
00283 class H245_AudioCapability;
00284 class H245_AudioMode;
00285 class H245_VideoCapability;
00286 class H245_VideoMode;
00287 class H245_DataApplicationCapability;
00288 class H245_DataMode;
00289 class H245_DataProtocolCapability;
00290 class H245_H2250LogicalChannelParameters;
00291 class H245_TerminalCapabilitySet;
00292 class H245_NonStandardParameter;
00293 class H323Connection;
00294 class H323Capabilities;
00295 class H245_CapabilityIdentifier;
00296 class H245_GenericCapability;
00297 class H245_GenericParameter;
00298 
00300 
00314 class H323Capability : public PObject
00315 {
00316   PCLASSINFO(H323Capability, PObject);
00317 
00318   public:
00323     H323Capability();
00325 
00331     Comparison Compare(const PObject & obj) const;
00332 
00335     void PrintOn(ostream & strm) const;
00337 
00340     enum MainTypes {
00342       e_Audio,
00344       e_Video,
00346       e_Data,
00348       e_UserInput,
00350       e_NumMainTypes
00351     };
00352 
00358     virtual MainTypes GetMainType() const = 0;
00359 
00363     virtual unsigned  GetSubType()  const = 0;
00364 
00367     virtual PString GetFormatName() const = 0;
00369 
00375     static H323Capability * Create(
00376       const PString & name     
00377     );
00378 
00387     virtual unsigned GetDefaultSessionID() const;
00388 
00397     virtual void SetTxFramesInPacket(
00398       unsigned frames   
00399     );
00400 
00405     virtual unsigned GetTxFramesInPacket() const;
00406 
00411     virtual unsigned GetRxFramesInPacket() const;
00412 
00418     virtual H323Channel * CreateChannel(
00419       H323Connection & connection,    
00420       H323Channel::Directions dir,    
00421       unsigned sessionID,             
00422       const H245_H2250LogicalChannelParameters * param
00424     ) const = 0;
00426 
00429     enum CommandType {
00430       e_TCS,
00431       e_OLC,
00432       e_ReqMode
00433     };
00434 
00442     virtual BOOL OnSendingPDU(
00443       H245_Capability & pdu  
00444     ) const = 0;
00445 
00453     virtual BOOL OnSendingPDU(
00454       H245_DataType & pdu  
00455     ) const = 0;
00456 
00464     virtual BOOL OnSendingPDU(
00465       H245_ModeElement & pdu  
00466     ) const = 0;
00467 
00480     virtual BOOL OnReceivedPDU(
00481       const H245_Capability & pdu 
00482     );
00483 
00491     virtual BOOL OnReceivedPDU(
00492       const H245_DataType & pdu,  
00493       BOOL receiver               
00494     ) = 0;
00495 
00498     virtual BOOL IsMatch(
00499       const PASN_Choice & subTypePDU  
00500     ) const;
00501 
00509     virtual BOOL IsUsable(
00510       const H323Connection & connection
00511     ) const;
00513 
00516     enum CapabilityDirection {
00517       e_Unknown,
00518       e_Receive,
00519       e_Transmit,
00520       e_ReceiveAndTransmit,
00521       e_NoDirection,
00522       NumCapabilityDirections
00523     };
00524 
00527     CapabilityDirection GetCapabilityDirection() const { return capabilityDirection; }
00528 
00531     void SetCapabilityDirection(
00532       CapabilityDirection dir   
00533     ) { capabilityDirection = dir; }
00534 
00536     unsigned GetCapabilityNumber() const { return assignedCapabilityNumber; }
00537 
00539     void SetCapabilityNumber(unsigned num) { assignedCapabilityNumber = num; }
00540 
00543     OpalMediaFormat GetMediaFormat() const;
00544 
00546     RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; }
00547 
00549     void SetPayloadType(RTP_DataFrame::PayloadTypes pt) { rtpPayloadType = pt; }
00550 
00552     virtual void AttachQoS(RTP_QOS *) { }
00554 
00555 #if PTRACING
00556     friend ostream & operator<<(ostream & o , MainTypes t);
00557     friend ostream & operator<<(ostream & o , CapabilityDirection d);
00558 #endif
00559 
00560   protected:
00561     OpalMediaFormat & GetWritableMediaFormat();
00562 
00563     unsigned            assignedCapabilityNumber;  
00564     CapabilityDirection capabilityDirection;
00565     RTP_DataFrame::PayloadTypes rtpPayloadType;
00566 
00567   private:
00568     OpalMediaFormat     mediaFormat;
00569 
00570   friend class H323Capabilities;
00571 };
00572 
00573 
00574 
00583 class H323NonStandardCapabilityInfo
00584 {
00585   public:
00586     typedef PObject::Comparison (*CompareFuncType)(struct PluginCodec_H323NonStandardCodecData *);
00587 
00590     H323NonStandardCapabilityInfo(
00591       CompareFuncType compareFunc,
00592       const BYTE * dataBlock,         
00593       PINDEX dataSize                 
00594     );
00595 
00598     H323NonStandardCapabilityInfo(
00599       const BYTE * dataBlock,         
00600       PINDEX dataSize,                
00601       PINDEX comparisonOffset = 0,    
00602       PINDEX comparisonLength = P_MAX_INDEX  
00603     );
00604 
00607     H323NonStandardCapabilityInfo(
00608       const PString & oid,
00609       const BYTE * dataBlock,         
00610       PINDEX dataSize,                
00611       PINDEX comparisonOffset = 0,
00612       PINDEX comparisonLength = P_MAX_INDEX
00613     );
00614 
00617     H323NonStandardCapabilityInfo(
00618       BYTE country,                  
00619       BYTE extension,                
00620       WORD maufacturer,              
00621       const BYTE * dataBlock,         
00622       PINDEX dataSize,                
00623       PINDEX comparisonOffset = 0,    
00624       PINDEX comparisonLength = P_MAX_INDEX  
00625     );
00626 
00629     virtual ~H323NonStandardCapabilityInfo();
00630 
00635     virtual BOOL OnSendingPDU(
00636       PBYTEArray & data  
00637     ) const;
00638 
00643     virtual BOOL OnReceivedPDU(
00644       const PBYTEArray & data  
00645     );
00646 
00647     BOOL IsMatch(const H245_NonStandardParameter & param) const;
00648 
00649     PObject::Comparison CompareParam(
00650       const H245_NonStandardParameter & param
00651     ) const;
00652 
00653   protected:
00654     BOOL OnSendingNonStandardPDU(
00655       PASN_Choice & pdu,
00656       unsigned nonStandardTag
00657     ) const;
00658     BOOL OnReceivedNonStandardPDU(
00659       const PASN_Choice & pdu,
00660       unsigned nonStandardTag
00661     );
00662 
00663     PObject::Comparison CompareInfo(
00664       const H323NonStandardCapabilityInfo & obj
00665     ) const;
00666     PObject::Comparison CompareData(
00667       const PBYTEArray & data  
00668     ) const;
00669 
00670     PString    oid;
00671     BYTE       t35CountryCode;
00672     BYTE       t35Extension;
00673     WORD       manufacturerCode;
00674     PBYTEArray nonStandardData;
00675     PINDEX     comparisonOffset;
00676     PINDEX     comparisonLength;
00677     CompareFuncType compareFunc;
00678 };
00679 
00689 class H323GenericCapabilityInfo
00690 {
00691   public:
00692     H323GenericCapabilityInfo(
00693       const PString & id,     
00694       PINDEX maxBitRate = 0   
00695     );
00696     H323GenericCapabilityInfo(const H323GenericCapabilityInfo & obj);
00697     virtual ~H323GenericCapabilityInfo();
00698 
00699   protected:
00700     virtual BOOL OnSendingGenericPDU(
00701       H245_GenericCapability & pdu,
00702       const OpalMediaFormat & mediaFormat,
00703       H323Capability::CommandType type
00704     ) const;
00705     virtual BOOL OnReceivedGenericPDU(
00706       OpalMediaFormat & mediaFormat,
00707       const H245_GenericCapability & pdu,
00708       H323Capability::CommandType type
00709     );
00710 
00711     BOOL IsMatch(
00712       const H245_GenericCapability & param  
00713     ) const;
00714     PObject::Comparison CompareInfo(
00715       const H323GenericCapabilityInfo & obj
00716     ) const;
00717 
00718 
00719     H245_CapabilityIdentifier * identifier;
00720     unsigned                    maxBitRate;
00721 };
00722 
00729 class H323RealTimeCapability : public H323Capability
00730 {
00731   PCLASSINFO(H323RealTimeCapability, H323Capability);
00732 
00733   public:
00738     virtual H323Channel * CreateChannel(
00739       H323Connection & connection,    
00740       H323Channel::Directions dir,    
00741       unsigned sessionID,             
00742       const H245_H2250LogicalChannelParameters * param
00744     ) const;
00745 
00746     H323RealTimeCapability();
00747     H323RealTimeCapability(const H323RealTimeCapability &rtc);
00748     virtual ~H323RealTimeCapability();
00749     void AttachQoS(RTP_QOS * _rtpqos);
00750 
00751   protected:
00752     RTP_QOS * rtpqos;
00754 };
00755 
00756 #if OPAL_AUDIO
00757 
00764 class H323AudioCapability : public H323RealTimeCapability
00765 {
00766   PCLASSINFO(H323AudioCapability, H323RealTimeCapability);
00767 
00768   public:
00773     H323AudioCapability();
00775 
00781     virtual MainTypes GetMainType() const;
00783 
00794     virtual unsigned GetDefaultSessionID() const;
00795 
00804     virtual void SetTxFramesInPacket(
00805       unsigned frames   
00806     );
00807 
00813     virtual unsigned GetTxFramesInPacket() const;
00814 
00820     virtual unsigned GetRxFramesInPacket() const;
00822 
00833     virtual BOOL OnSendingPDU(
00834       H245_Capability & pdu  
00835     ) const;
00836 
00845     virtual BOOL OnSendingPDU(
00846       H245_DataType & pdu  
00847     ) const;
00848 
00857     virtual BOOL OnSendingPDU(
00858       H245_ModeElement & pdu  
00859     ) const;
00860 
00869     virtual BOOL OnSendingPDU(
00870       H245_AudioCapability & pdu,  
00871       unsigned packetSize          
00872     ) const;
00873     virtual BOOL OnSendingPDU(
00874       H245_AudioCapability & pdu,  
00875       unsigned packetSize,         
00876       CommandType type             
00877     ) const;
00878 
00887     virtual BOOL OnSendingPDU(
00888       H245_AudioMode & pdu  
00889     ) const;
00890 
00902     virtual BOOL OnReceivedPDU(
00903       const H245_Capability & pdu  
00904     );
00905 
00915     virtual BOOL OnReceivedPDU(
00916       const H245_DataType & pdu,  
00917       BOOL receiver               
00918     );
00919 
00928     virtual BOOL OnReceivedPDU(
00929       const H245_AudioCapability & pdu,  
00930       unsigned & packetSize              
00931     );
00932     virtual BOOL OnReceivedPDU(
00933       const H245_AudioCapability & pdu,  
00934       unsigned & packetSize,             
00935       CommandType type                   
00936     );
00938 };
00939 
00940 
00948 class H323NonStandardAudioCapability : public H323AudioCapability,
00949                                        public H323NonStandardCapabilityInfo
00950 {
00951   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
00952 
00953   public:
00956     H323NonStandardAudioCapability(
00957       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
00958       const BYTE * dataBlock,         
00959       PINDEX dataSize                 
00960     );
00963     H323NonStandardAudioCapability(
00964       const BYTE * dataBlock = NULL,  
00965       PINDEX dataSize = 0,            
00966       PINDEX comparisonOffset = 0,    
00967       PINDEX comparisonLength = P_MAX_INDEX  
00968      );
00969 
00972     H323NonStandardAudioCapability(
00973       const PString & oid,            
00974       const BYTE * dataBlock = NULL,  
00975       PINDEX dataSize = 0,            
00976       PINDEX comparisonOffset = 0,    
00977       PINDEX comparisonLength = P_MAX_INDEX  
00978     );
00979 
00982     H323NonStandardAudioCapability(
00983       BYTE country,                   
00984       BYTE extension,                 
00985       WORD maufacturer,               
00986       const BYTE * dataBlock = NULL,  
00987       PINDEX dataSize = 0,            
00988       PINDEX comparisonOffset = 0,    
00989       PINDEX comparisonLength = P_MAX_INDEX  
00990     );
00992 
00998     Comparison Compare(const PObject & obj) const;
01000 
01008     virtual unsigned GetSubType() const;
01010 
01021     virtual BOOL OnSendingPDU(
01022       H245_AudioCapability & pdu,  
01023       unsigned packetSize          
01024     ) const;
01025 
01034     virtual BOOL OnSendingPDU(
01035       H245_AudioMode & pdu  
01036     ) const;
01037 
01046     virtual BOOL OnReceivedPDU(
01047       const H245_AudioCapability & pdu,  
01048       unsigned & packetSize              
01049     );
01050 
01053     virtual BOOL IsMatch(
01054       const PASN_Choice & subTypePDU  
01055     ) const;
01057 };
01058 
01066 class H323GenericAudioCapability : public H323AudioCapability,
01067                                    public H323GenericCapabilityInfo
01068 {
01069   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
01070 
01071   public:
01076     H323GenericAudioCapability(
01077       const PString & capabilityId,    
01078       PINDEX maxBitRate = 0                
01079     );
01081 
01087     Comparison Compare(const PObject & obj) const;
01089 
01097     virtual unsigned GetSubType() const;
01099 
01110     virtual BOOL OnSendingPDU(
01111       H245_AudioCapability & pdu,  
01112       unsigned packetSize,         
01113       CommandType type             
01114     ) const;
01115 
01124     virtual BOOL OnSendingPDU(
01125       H245_AudioMode & pdu  
01126     ) const;
01127 
01136     virtual BOOL OnReceivedPDU(
01137       const H245_AudioCapability & pdu,  
01138       unsigned & packetSize,             
01139       CommandType type                   
01140     );
01141 
01144     virtual BOOL IsMatch(
01145       const PASN_Choice & subTypePDU  
01146     ) const;
01148 };
01149 
01150 #endif  // OPAL_AUDIO
01151 
01152 #if OPAL_VIDEO
01153 
01160 class H323VideoCapability : public H323RealTimeCapability
01161 {
01162   PCLASSINFO(H323VideoCapability, H323RealTimeCapability);
01163 
01164   public:
01170     virtual MainTypes GetMainType() const;
01172 
01183     virtual unsigned GetDefaultSessionID() const;
01185 
01196     virtual BOOL OnSendingPDU(
01197       H245_Capability & pdu  
01198     ) const;
01199 
01208     virtual BOOL OnSendingPDU(
01209       H245_DataType & pdu  
01210     ) const;
01211 
01220     virtual BOOL OnSendingPDU(
01221       H245_ModeElement & pdu  
01222     ) const;
01223 
01231     virtual BOOL OnSendingPDU(
01232       H245_VideoCapability & pdu  
01233     ) const;
01234     virtual BOOL OnSendingPDU(
01235       H245_VideoCapability & pdu,  
01236       CommandType type             
01237     ) const;
01238 
01247     virtual BOOL OnSendingPDU(
01248       H245_VideoMode & pdu  
01249     ) const = 0;
01250 
01260     virtual BOOL OnReceivedPDU(
01261       const H245_Capability & pdu  
01262     );
01263 
01271     virtual BOOL OnReceivedPDU(
01272       const H245_DataType & pdu,  
01273       BOOL receiver               
01274     );
01275 
01283     virtual BOOL OnReceivedPDU(
01284       const H245_VideoCapability & pdu  
01285     );
01286     virtual BOOL OnReceivedPDU(
01287       const H245_VideoCapability & pdu,  
01288       CommandType type                   
01289     );
01291 };
01292 
01293 
01301 class H323NonStandardVideoCapability : public H323VideoCapability,
01302                                        public H323NonStandardCapabilityInfo
01303 {
01304   PCLASSINFO(H323NonStandardVideoCapability, H323VideoCapability);
01305 
01306   public:
01309     H323NonStandardVideoCapability(
01310       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
01311       const BYTE * dataBlock,         
01312       PINDEX dataSize                 
01313     );
01316     H323NonStandardVideoCapability(
01317       const BYTE * dataBlock = NULL,  
01318       PINDEX dataSize = 0,            
01319       PINDEX comparisonOffset = 0,    
01320       PINDEX comparisonLength = P_MAX_INDEX  
01321     );
01322 
01325     H323NonStandardVideoCapability(
01326       const PString & oid,            
01327       const BYTE * dataBlock = NULL,  
01328       PINDEX dataSize = 0,            
01329       PINDEX comparisonOffset = 0,    
01330       PINDEX comparisonLength = P_MAX_INDEX  
01331     );
01332 
01335     H323NonStandardVideoCapability(
01336       BYTE country,                   
01337       BYTE extension,                 
01338       WORD maufacturer,               
01339       const BYTE * dataBlock = NULL,  
01340       PINDEX dataSize = 0,            
01341       PINDEX comparisonOffset = 0,    
01342       PINDEX comparisonLength = P_MAX_INDEX  
01343     );
01345 
01351     Comparison Compare(const PObject & obj) const;
01353 
01362     virtual unsigned GetSubType() const;
01364 
01375     virtual BOOL OnSendingPDU(
01376       H245_VideoCapability & pdu  
01377     ) const;
01378 
01387     virtual BOOL OnSendingPDU(
01388       H245_VideoMode & pdu  
01389     ) const;
01390 
01399     virtual BOOL OnReceivedPDU(
01400       const H245_VideoCapability & pdu  
01401     );
01402 
01405     virtual BOOL IsMatch(
01406       const PASN_Choice & subTypePDU  
01407     ) const;
01409 };
01410 
01418 class H323GenericVideoCapability : public H323VideoCapability,
01419                                    public H323GenericCapabilityInfo
01420 {
01421   PCLASSINFO(H323GenericVideoCapability, H323VideoCapability);
01422 
01423   public:
01428     H323GenericVideoCapability(
01429       const PString & capabilityId,    
01430       PINDEX maxBitRate = 0            
01431     );
01433 
01439     Comparison Compare(const PObject & obj) const;
01441 
01449     virtual unsigned GetSubType() const;
01451 
01462     virtual BOOL OnSendingPDU(
01463       H245_VideoCapability & pdu,  
01464       CommandType type             
01465     ) const;
01466 
01475     virtual BOOL OnSendingPDU(
01476       H245_VideoMode & pdu  
01477     ) const;
01478 
01487     virtual BOOL OnReceivedPDU(
01488       const H245_VideoCapability & pdu,  
01489       CommandType type                   
01490     );
01492 
01495     virtual BOOL IsMatch(
01496       const PASN_Choice & subTypePDU  
01497     ) const;
01498 };
01499 
01500 #endif  // OPAL_VIDEO
01501 
01508 class H323DataCapability : public H323Capability
01509 {
01510   PCLASSINFO(H323DataCapability, H323Capability);
01511 
01512   public:
01517     H323DataCapability(
01518       unsigned maxBitRate = 0  
01519     );
01521 
01527     virtual MainTypes GetMainType() const;
01529 
01539     virtual unsigned GetDefaultSessionID() const;
01541 
01552     virtual BOOL OnSendingPDU(
01553       H245_Capability & pdu  
01554     ) const;
01555 
01564     virtual BOOL OnSendingPDU(
01565       H245_DataType & pdu  
01566     ) const;
01567 
01576     virtual BOOL OnSendingPDU(
01577       H245_ModeElement & pdu  
01578     ) const;
01579 
01587     virtual BOOL OnSendingPDU(
01588       H245_DataApplicationCapability & pdu  
01589     ) const;
01590     virtual BOOL OnSendingPDU(
01591       H245_DataApplicationCapability & pdu, 
01592       CommandType type                      
01593     ) const;
01594 
01603     virtual BOOL OnSendingPDU(
01604       H245_DataMode & pdu  
01605     ) const = 0;
01606 
01616     virtual BOOL OnReceivedPDU(
01617       const H245_Capability & pdu  
01618     );
01619 
01627     virtual BOOL OnReceivedPDU(
01628       const H245_DataType & pdu,  
01629       BOOL receiver               
01630     );
01631 
01639     virtual BOOL OnReceivedPDU(
01640       const H245_DataApplicationCapability & pdu  
01641     );
01642     virtual BOOL OnReceivedPDU(
01643       const H245_DataApplicationCapability & pdu, 
01644       CommandType type                            
01645     );
01647 
01648   protected:
01649     unsigned maxBitRate;
01650 };
01651 
01652 
01660 class H323NonStandardDataCapability : public H323DataCapability,
01661                                       public H323NonStandardCapabilityInfo
01662 {
01663   PCLASSINFO(H323NonStandardDataCapability, H323DataCapability);
01664 
01665   public:
01670     H323NonStandardDataCapability(
01671       unsigned maxBitRate,            
01672       const BYTE * dataBlock = NULL,  
01673       PINDEX dataSize = 0,            
01674       PINDEX comparisonOffset = 0,    
01675       PINDEX comparisonLength = P_MAX_INDEX  
01676     );
01677 
01680     H323NonStandardDataCapability(
01681       unsigned maxBitRate,            
01682       const PString & oid,            
01683       const BYTE * dataBlock = NULL,  
01684       PINDEX dataSize = 0,            
01685       PINDEX comparisonOffset = 0,    
01686       PINDEX comparisonLength = P_MAX_INDEX  
01687     );
01688 
01691     H323NonStandardDataCapability(
01692       unsigned maxBitRate,            
01693       BYTE country,                   
01694       BYTE extension,                 
01695       WORD maufacturer,               
01696       const BYTE * dataBlock = NULL,  
01697       PINDEX dataSize = 0,            
01698       PINDEX comparisonOffset = 0,    
01699       PINDEX comparisonLength = P_MAX_INDEX  
01700     );
01702 
01708     Comparison Compare(const PObject & obj) const;
01710 
01719     virtual unsigned GetSubType() const;
01721 
01732     virtual BOOL OnSendingPDU(
01733       H245_DataApplicationCapability & pdu  
01734     ) const;
01735 
01744     virtual BOOL OnSendingPDU(
01745       H245_DataMode & pdu  
01746     ) const;
01747 
01756     virtual BOOL OnReceivedPDU(
01757       const H245_DataApplicationCapability & pdu  
01758     );
01759 
01762     virtual BOOL IsMatch(
01763       const PASN_Choice & subTypePDU  
01764     ) const;
01766 };
01767 
01768 
01770 // Known audio codecs
01771 
01774 class H323_G711Capability : public H323AudioCapability
01775 {
01776   PCLASSINFO(H323_G711Capability, H323AudioCapability)
01777 
01778   public:
01780     enum Mode {
01782       ALaw,
01784       muLaw
01785     };
01787     enum Speed {
01789       At64k,
01791       At56k
01792     };
01793 
01798     H323_G711Capability(
01799       Mode mode = muLaw,    
01800       Speed speed = At64k   
01801     );
01803 
01808     virtual PObject * Clone() const;
01810 
01819     virtual unsigned GetSubType() const;
01820 
01823     virtual PString GetFormatName() const;
01825 
01826   protected:
01827     Mode     mode;
01828     Speed    speed;
01829 };
01830 
01831 #if 0
01832 
01835 class H323_G728Capability : public H323AudioCapability
01836 {
01837   PCLASSINFO(H323_G728Capability, H323AudioCapability)
01838 
01839   public:
01844     H323_G728Capability();
01846 
01851     virtual PObject * Clone() const;
01853 
01859     virtual unsigned GetSubType() const;
01860 
01863     virtual PString GetFormatName() const;
01865 };
01866 
01867 
01870 class H323_G729Capability : public H323AudioCapability
01871 {
01872   PCLASSINFO(H323_G729Capability, H323AudioCapability)
01873 
01874   public:
01876     enum Mode {
01877       e_Normal,
01878       e_AnnexA,
01879       e_AnnexB,
01880       e_AnnexA_AnnexB
01881     };
01882 
01887     H323_G729Capability(
01888       Mode mode 
01889     );
01891 
01896     virtual PObject * Clone() const;
01898 
01904     virtual unsigned GetSubType() const;
01905 
01908     virtual PString GetFormatName() const;
01910 
01911   protected:
01912     Mode mode;
01913 };
01914 
01915 
01918 class H323_G7231Capability : public H323AudioCapability
01919 {
01920   PCLASSINFO(H323_G7231Capability, H323AudioCapability)
01921 
01922   public:
01927     H323_G7231Capability(
01928       BOOL allowSIDFrames = TRUE   
01929     );
01931 
01936     virtual PObject * Clone() const;
01938 
01944     virtual unsigned GetSubType() const;
01945 
01948     virtual PString GetFormatName() const;
01950 
01960     virtual BOOL OnSendingPDU(
01961       H245_AudioCapability & pdu,  
01962       unsigned packetSize          
01963     ) const;
01964 
01972     virtual BOOL OnReceivedPDU(
01973       const H245_AudioCapability & pdu,  
01974       unsigned & packetSize              
01975     );
01977 
01978   protected:
01979     BOOL allowSIDFrames;
01980 };
01981 
01982 
01985 class H323_GSM0610Capability : public H323AudioCapability
01986 {
01987   PCLASSINFO(H323_GSM0610Capability, H323AudioCapability)
01988 
01989   public:
01994     H323_GSM0610Capability();
01996 
02001     virtual PObject * Clone() const;
02003 
02012     virtual unsigned GetSubType() const;
02013 
02016     virtual PString GetFormatName() const;
02017 
02026     virtual void SetTxFramesInPacket(
02027       unsigned frames   
02028     );
02030 
02040     virtual BOOL OnSendingPDU(
02041       H245_AudioCapability & pdu,  
02042       unsigned packetSize          
02043     ) const;
02044 
02052     virtual BOOL OnReceivedPDU(
02053       const H245_AudioCapability & pdu,  
02054       unsigned & packetSize              
02055     );
02057 };
02058 
02059 #endif
02060 
02061 
02063 
02066 class H323_UserInputCapability : public H323Capability
02067 {
02068   PCLASSINFO(H323_UserInputCapability, H323Capability);
02069 
02070   public:
02073     enum SubTypes {
02074       BasicString,
02075       IA5String,
02076       GeneralString,
02077       SignalToneH245,
02078       HookFlashH245,
02079       SignalToneRFC2833,
02080       NumSubTypes
02081     };
02082     static const char * GetSubTypeName(SubTypes subType);
02083     friend ostream & operator<<(ostream & strm, SubTypes subType) { return strm << GetSubTypeName(subType); }
02084 
02089     H323_UserInputCapability(
02090       SubTypes subType
02091     );
02093 
02098     virtual PObject * Clone() const;
02100 
02108     virtual MainTypes GetMainType() const;
02109 
02113     virtual unsigned  GetSubType()  const;
02114 
02117     virtual PString GetFormatName() const;
02119 
02127     virtual H323Channel * CreateChannel(
02128       H323Connection & connection,    
02129       H323Channel::Directions dir,    
02130       unsigned sessionID,             
02131       const H245_H2250LogicalChannelParameters * param
02133     ) const;
02135 
02145     virtual BOOL OnSendingPDU(
02146       H245_Capability & pdu  
02147     ) const;
02148 
02156     virtual BOOL OnSendingPDU(
02157       H245_DataType & pdu  
02158     ) const;
02159 
02168     virtual BOOL OnSendingPDU(
02169       H245_ModeElement & pdu  
02170     ) const;
02171 
02181     virtual BOOL OnReceivedPDU(
02182       const H245_Capability & pdu  
02183     );
02184 
02192     virtual BOOL OnReceivedPDU(
02193       const H245_DataType & pdu,  
02194       BOOL receiver               
02195     );
02196 
02205     virtual BOOL IsUsable(
02206       const H323Connection & connection
02207     ) const;
02209 
02210     static void AddAllCapabilities(
02211       H323Capabilities & capabilities,        
02212       PINDEX descriptorNum,   
02213       PINDEX simultaneous     
02214     );
02215 
02216   protected:
02217     SubTypes subType;
02218 };
02219 
02220 
02221 
02223 
02224 PLIST(H323CapabilitiesList, H323Capability);
02225 
02226 PARRAY(H323CapabilitiesListArray, H323CapabilitiesList);
02227 
02228 class H323SimultaneousCapabilities : public H323CapabilitiesListArray
02229 {
02230   PCLASSINFO(H323SimultaneousCapabilities, H323CapabilitiesListArray);
02231   public:
02232     BOOL SetSize(PINDEX newSize);
02233 };
02234 
02235 
02236 PARRAY(H323CapabilitiesSetArray, H323SimultaneousCapabilities);
02237 
02238 
02239 class H323CapabilitiesSet : public H323CapabilitiesSetArray
02240 {
02241   PCLASSINFO(H323CapabilitiesSet, H323CapabilitiesSetArray);
02242   public:
02244     BOOL SetSize(PINDEX newSize);
02245 };
02246 
02247 
02250 class H323Capabilities : public PObject
02251 {
02252     PCLASSINFO(H323Capabilities, PObject);
02253   public:
02258     H323Capabilities();
02259 
02262     H323Capabilities(
02263       const H323Connection & connection,      
02264       const H245_TerminalCapabilitySet & pdu  
02265     );
02266 
02271     H323Capabilities(
02272       const H323Capabilities & original 
02273     );
02274 
02279     H323Capabilities & operator=(
02280       const H323Capabilities & original 
02281     );
02283 
02288     void PrintOn(
02289       ostream & strm    
02290     ) const;
02292 
02297     PINDEX GetSize() const { return table.GetSize(); }
02298 
02301     H323Capability & operator[](PINDEX i) const { return table[i]; }
02302 
02323     PINDEX SetCapability(
02324       PINDEX descriptorNum, 
02325       PINDEX simultaneous,  
02326       H323Capability * cap  
02327     );
02328 
02331     PINDEX AddMediaFormat(
02332       PINDEX descriptorNum,    
02333       PINDEX simultaneous,     
02334       const OpalMediaFormat & mediaFormat 
02335     );
02336 
02341     PINDEX AddAllCapabilities(
02342       PINDEX descriptorNum,    
02343       PINDEX simultaneous,     
02344       const PString & name,    
02345       BOOL exact = FALSE       
02346     );
02347 
02348     // this function is retained for backwards compatibility
02349     PINDEX AddAllCapabilities(
02350       const H323EndPoint &,    
02351       PINDEX descriptorNum,    
02352       PINDEX simultaneous,     
02353       const PString & name,    
02354       BOOL exact = FALSE       
02355     )
02356     { return AddAllCapabilities(descriptorNum, simultaneous, name, exact); }
02357 
02366     void Add(
02367       H323Capability * capability   
02368     );
02369 
02376     H323Capability * Copy(
02377       const H323Capability & capability   
02378     );
02379 
02384     void Remove(
02385       H323Capability * capability   
02386     );
02387 
02392     void Remove(
02393       const PString & formatName   
02394     );
02395 
02399     void Remove(
02400       const PStringArray & formatNames  
02401     );
02402 
02405     void RemoveAll();
02406 
02414     H323Capability * FindCapability(
02415       unsigned capabilityNumber
02416     ) const;
02417 
02433     H323Capability * FindCapability(
02434       const PString & formatName, 
02435       H323Capability::CapabilityDirection direction = H323Capability::e_Unknown,
02437       BOOL exact = FALSE       
02438     ) const;
02439 
02445     H323Capability * FindCapability(
02446       H323Capability::CapabilityDirection direction 
02447     ) const;
02448 
02456     H323Capability * FindCapability(
02457       const H323Capability & capability 
02458     ) const;
02459 
02465     H323Capability * FindCapability(
02466       const H245_Capability & cap  
02467     ) const;
02468 
02474     H323Capability * FindCapability(
02475       const H245_DataType & dataType  
02476     ) const;
02477 
02483     H323Capability * FindCapability(
02484       const H245_ModeElement & modeElement  
02485     ) const;
02486 
02492     H323Capability * FindCapability(
02493       H323Capability::MainTypes mainType, 
02494       unsigned subType = UINT_MAX         
02495     ) const;
02496 
02499     void BuildPDU(
02500       const H323Connection & connection,  
02501       H245_TerminalCapabilitySet & pdu    
02502     ) const;
02503 
02506     BOOL Merge(
02507       const H323Capabilities & newCaps
02508     );
02509 
02516     void Reorder(
02517       const PStringArray & preferenceOrder  
02518     );
02519 
02522     BOOL IsAllowed(
02523       const H323Capability & capability
02524     );
02525 
02528     BOOL IsAllowed(
02529       unsigned capabilityNumber
02530     );
02531 
02534     BOOL IsAllowed(
02535       const H323Capability & capability1,
02536       const H323Capability & capability2
02537     );
02538 
02541     BOOL IsAllowed(
02542       unsigned capabilityNumber1,
02543       unsigned capabilityNumber2
02544     );
02545 
02548     OpalMediaFormatList GetMediaFormats() const;
02550 
02551   protected:
02552     H323CapabilitiesList table;
02553     H323CapabilitiesSet  set;
02554 };
02555 
02556 
02558 
02559 /* New capability registration macros based on abstract factories
02560  */
02561 typedef PFactory<H323Capability, std::string> H323CapabilityFactory;
02562 
02563 #define H323_REGISTER_CAPABILITY(cls, capName)   static H323CapabilityFactory::Worker<cls> cls##Factory(capName, true); \
02564 
02565 #endif // __OPAL_H323CAPS_H
02566 
02567 

Generated on Fri Mar 7 06:33:31 2008 for OPAL by  doxygen 1.5.1