OpenH323 1.18.0
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-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  * 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 1.51  2005/11/30 13:05:01  csoutheren
00031  * Changed tags for Doxygen
00032  *
00033  * Revision 1.50  2005/06/07 07:09:13  csoutheren
00034  * Removed compiler warnings on Windows
00035  *
00036  * Revision 1.49  2005/06/07 03:22:22  csoutheren
00037  * Added patch 1198741 with support for plugin codecs with generic capabilities
00038  * Added patch 1198754 with support for setting quality level on audio codecs
00039  * Added patch 1198760 with GSM-AMR codec support
00040  * Many thanks to Richard van der Hoff for his work
00041  *
00042  * Revision 1.48  2005/01/03 06:25:52  csoutheren
00043  * Added extensive support for disabling code modules at compile time
00044  *
00045  * Revision 1.47  2004/08/24 14:23:09  csoutheren
00046  * Fixed problem with plugin codecs using capability compare functions
00047  *
00048  * Revision 1.46  2004/06/30 12:31:09  rjongbloed
00049  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00050  *   of issues with startup orders and Windows DLL multiple instances.
00051  *
00052  * Revision 1.45  2004/06/08 01:20:28  csoutheren
00053  * Provide backwards compatibility for applications using old capability API
00054  *
00055  * Revision 1.44  2004/06/01 05:47:58  csoutheren
00056  * Changed capability table to use abstract factory routines rather than internal linked list
00057  *
00058  * Revision 1.43  2004/05/13 12:49:32  rjongbloed
00059  * Fixed usage of the compare function in non-standard capabilities.
00060  *
00061  * Revision 1.42  2004/04/03 10:38:24  csoutheren
00062  * Added in initial cut at codec plugin code. Branches are for wimps :)
00063  *
00064  * Revision 1.41.2.1  2004/03/31 11:11:58  csoutheren
00065  * Initial public release of plugin codec code
00066  *
00067  * Revision 1.41  2004/03/02 11:48:14  rjongbloed
00068  * Fixed correct capability table matching when FindCapability with a mode change,
00069  *   uses different enum so needs translation table.
00070  *
00071  * Revision 1.40  2003/10/27 06:03:39  csoutheren
00072  * Added support for QoS
00073  *   Thanks to Henry Harrison of AliceStreet
00074  *
00075  * Revision 1.39  2003/06/06 02:13:10  rjongbloed
00076  * Changed non-standard capability semantics so can use C style strings as
00077  *   the embedded data block (ie automatically call strlen)
00078  *
00079  * Revision 1.38  2003/04/28 07:00:00  robertj
00080  * Fixed problem with compiler(s) not correctly initialising static globals
00081  *
00082  * Revision 1.37  2003/04/27 23:49:21  craigs
00083  * Fixed some comments and made list of registered codecs
00084  * available outside h323caps.cxx
00085  *
00086  * Revision 1.36  2002/11/09 04:24:01  robertj
00087  * Fixed minor documentation errors.
00088  *
00089  * Revision 1.35  2002/09/16 01:14:15  robertj
00090  * Added #define so can select if #pragma interface/implementation is used on
00091  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00092  *
00093  * Revision 1.34  2002/09/03 06:19:36  robertj
00094  * Normalised the multi-include header prevention ifdef/define symbol.
00095  *
00096  * Revision 1.33  2002/08/05 10:03:47  robertj
00097  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00098  *
00099  * Revision 1.32  2002/05/29 03:55:17  robertj
00100  * Added protocol version number checking infrastructure, primarily to improve
00101  *   interoperability with stacks that are unforgiving of new features.
00102  *
00103  * Revision 1.31  2002/05/10 05:44:50  robertj
00104  * Added the max bit rate field to the data channel capability class.
00105  *
00106  * Revision 1.30  2002/01/22 06:25:02  robertj
00107  * Moved payload type to ancestor so any capability can adjust it on logical channel.
00108  *
00109  * Revision 1.29  2002/01/17 07:04:57  robertj
00110  * Added support for RFC2833 embedded DTMF in the RTP stream.
00111  *
00112  * Revision 1.28  2002/01/16 05:37:41  robertj
00113  * Added missing mode change functions on non standard capabilities.
00114  *
00115  * Revision 1.27  2002/01/09 00:21:36  robertj
00116  * Changes to support outgoing H.245 RequstModeChange.
00117  *
00118  * Revision 1.26  2001/12/22 01:44:05  robertj
00119  * Added more support for H.245 RequestMode operation.
00120  *
00121  * Revision 1.25  2001/10/24 01:20:34  robertj
00122  * Added code to help with static linking of H323Capability names database.
00123  *
00124  * Revision 1.24  2001/09/21 02:48:51  robertj
00125  * Added default implementation for PDU encode/decode for codecs
00126  *   that have simple integer as frames per packet.
00127  *
00128  * Revision 1.23  2001/09/11 10:21:40  robertj
00129  * Added direction field to capabilities, thanks Nick Hoath.
00130  *
00131  * Revision 1.22  2001/07/19 09:50:40  robertj
00132  * Added code for default session ID on data channel being three.
00133  *
00134  * Revision 1.21  2001/07/17 04:44:29  robertj
00135  * Partial implementation of T.120 and T.38 logical channels.
00136  *
00137  * Revision 1.20  2001/05/21 07:20:47  robertj
00138  * Removed redundent class name in declaration.
00139  *
00140  * Revision 1.19  2001/05/14 05:56:26  robertj
00141  * Added H323 capability registration system so can add capabilities by
00142  *   string name instead of having to instantiate explicit classes.
00143  *
00144  * Revision 1.18  2001/05/02 16:22:21  rogerh
00145  * Add IsAllow() for a single capability to check if it is in the
00146  * capabilities set. This fixes the bug where OpenH323 would accept
00147  * incoming H261 video even when told not to accept it.
00148  *
00149  * Revision 1.17  2001/03/16 23:00:21  robertj
00150  * Improved validation of codec selection against capability set, thanks Chris Purvis.
00151  *
00152  * Revision 1.16  2001/02/09 05:16:24  robertj
00153  * Added #pragma interface for GNU C++.
00154  *
00155  * Revision 1.15  2001/01/25 07:27:14  robertj
00156  * Major changes to add more flexible OpalMediaFormat class to normalise
00157  *   all information about media types, especially codecs.
00158  *
00159  * Revision 1.14  2001/01/09 23:05:22  robertj
00160  * Fixed inability to have 2 non standard codecs in capability table.
00161  *
00162  * Revision 1.13  2000/10/16 08:49:30  robertj
00163  * Added single function to add all UserInput capability types.
00164  *
00165  * Revision 1.12  2000/08/23 14:23:11  craigs
00166  * Added prototype support for Microsoft GSM codec
00167  *
00168  * Revision 1.11  2000/07/13 12:25:47  robertj
00169  * Fixed problems with fast start frames per packet adjustment.
00170  *
00171  * Revision 1.10  2000/07/10 16:01:50  robertj
00172  * Started fixing capability set merging, still more to do.
00173  *
00174  * Revision 1.9  2000/07/04 01:16:49  robertj
00175  * Added check for capability allowed in "combinations" set, still needs more done yet.
00176  *
00177  * Revision 1.8  2000/06/03 03:16:47  robertj
00178  * Fixed using the wrong capability table (should be connections) for some operations.
00179  *
00180  * Revision 1.7  2000/05/23 11:32:27  robertj
00181  * Rewrite of capability table to combine 2 structures into one and move functionality into that class
00182  *    allowing some normalisation of usage across several applications.
00183  * Changed H323Connection so gets a copy of capabilities instead of using endponts, allows adjustments
00184  *    to be done depending on the remote client application.
00185  *
00186  * Revision 1.6  2000/05/18 11:53:34  robertj
00187  * Changes to support doc++ documentation generation.
00188  *
00189  * Revision 1.5  2000/05/10 04:05:26  robertj
00190  * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
00191  *
00192  * Revision 1.4  2000/05/02 04:32:24  robertj
00193  * Fixed copyright notice comment.
00194  *
00195  * Revision 1.3  2000/04/05 19:01:12  robertj
00196  * Added function so can change desired transmit packet size.
00197  *
00198  * Revision 1.2  2000/03/21 03:06:47  robertj
00199  * Changes to make RTP TX of exact numbers of frames in some codecs.
00200  *
00201  * Revision 1.1  1999/12/23 23:02:35  robertj
00202  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00203  *
00204  */
00205 
00206 #ifndef __OPAL_H323CAPS_H
00207 #define __OPAL_H323CAPS_H
00208 
00209 #ifdef P_USE_PRAGMA
00210 #pragma interface
00211 #endif
00212 
00213 
00214 #include "codecs.h"
00215 #include "channels.h"
00216 
00217 
00218 /* The following classes have forward references to avoid including the VERY
00219    large header files for H225 and H245. If an application requires access
00220    to the protocol classes they can include them, but for simple usage their
00221    inclusion can be avoided.
00222  */
00223 class PASN_Choice;
00224 class H245_Capability;
00225 class H245_DataType;
00226 class H245_ModeElement;
00227 class H245_AudioCapability;
00228 class H245_AudioMode;
00229 class H245_VideoCapability;
00230 class H245_VideoMode;
00231 class H245_DataApplicationCapability;
00232 class H245_DataMode;
00233 class H245_DataProtocolCapability;
00234 class H245_GenericCapability;
00235 class H245_CapabilityIdentifier;
00236 class H245_GenericParameter;
00237 class H245_H2250LogicalChannelParameters;
00238 class H245_H223LogicalChannelParameters;
00239 class H245_TerminalCapabilitySet;
00240 class H245_NonStandardParameter;
00241 class H323Connection;
00242 class H323Capabilities;
00243 
00244 
00245 
00247 
00261 class H323Capability : public PObject
00262 {
00263   PCLASSINFO(H323Capability, PObject);
00264 
00265   public:
00270     H323Capability();
00272 
00278     Comparison Compare(const PObject & obj) const;
00279 
00282     void PrintOn(ostream & strm) const;
00284 
00287     enum MainTypes {
00289       e_Audio,
00291       e_Video,
00293       e_Data,
00295       e_UserInput,
00297       e_NumMainTypes
00298     };
00299 
00305     virtual MainTypes GetMainType() const = 0;
00306 
00310     virtual unsigned  GetSubType()  const = 0;
00311 
00314     virtual PString GetFormatName() const = 0;
00316 
00322     static H323Capability * Create(
00323       const PString & name    
00324     );
00325 
00329     static H323Capability * Create(
00330       H323EndPoint &,         
00331       const PString & name    
00332     )
00333     { return Create(name); }
00334 
00343     virtual unsigned GetDefaultSessionID() const;
00344 
00353     virtual void SetTxFramesInPacket(
00354       unsigned frames   
00355     );
00356 
00361     virtual unsigned GetTxFramesInPacket() const;
00362 
00367     virtual unsigned GetRxFramesInPacket() const;
00368 
00374     virtual H323Channel * CreateChannel(
00375       H323Connection & connection,    
00376       H323Channel::Directions dir,    
00377       unsigned sessionID,             
00378       const H245_H2250LogicalChannelParameters * param
00380     ) const = 0;
00381 
00384     virtual H323Codec * CreateCodec(
00385       H323Codec::Direction direction  
00386     ) const = 0;
00388 
00398     virtual BOOL OnSendingPDU(
00399       H245_Capability & pdu  
00400     ) const = 0;
00401 
00409     virtual BOOL OnSendingPDU(
00410       H245_DataType & pdu  
00411     ) const = 0;
00412 
00420     virtual BOOL OnSendingPDU(
00421       H245_ModeElement & pdu  
00422     ) const = 0;
00423 
00436     virtual BOOL OnReceivedPDU(
00437       const H245_Capability & pdu 
00438     );
00439 
00447     virtual BOOL OnReceivedPDU(
00448       const H245_DataType & pdu,  
00449       BOOL receiver               
00450     ) = 0;
00451 
00452 
00455     virtual BOOL IsGenericMatch(
00456       const H245_GenericCapability & /*param*/  
00457       ) const { return FALSE; }
00458     
00461     virtual BOOL IsNonStandardMatch(
00462       const H245_NonStandardParameter & param  
00463     ) const;
00464 
00472     virtual BOOL IsUsable(
00473       const H323Connection & connection
00474     ) const;
00476 
00479     enum CapabilityDirection {
00480       e_Unknown,
00481       e_Receive,
00482       e_Transmit,
00483       e_ReceiveAndTransmit,
00484       e_NoDirection,
00485       NumCapabilityDirections
00486     };
00487 
00490     CapabilityDirection GetCapabilityDirection() const { return capabilityDirection; }
00491 
00494     void SetCapabilityDirection(
00495       CapabilityDirection dir   
00496     ) { capabilityDirection = dir; }
00497 
00499     unsigned GetCapabilityNumber() const { return assignedCapabilityNumber; }
00500 
00502     void SetCapabilityNumber(unsigned num) { assignedCapabilityNumber = num; }
00503 
00505     RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; }
00506 
00508     virtual void AttachQoS(RTP_QOS *)
00509     {}
00511 
00512 #if PTRACING
00513     friend ostream & operator<<(ostream & o , MainTypes t);
00514     friend ostream & operator<<(ostream & o , CapabilityDirection d);
00515 #endif
00516 
00517   protected:
00518     unsigned assignedCapabilityNumber;  
00519     CapabilityDirection capabilityDirection;
00520     RTP_DataFrame::PayloadTypes rtpPayloadType;
00521 };
00522 
00523 
00524 
00534 class H323NonStandardCapabilityInfo
00535 {
00536   public:
00537     typedef PObject::Comparison (*CompareFuncType)(struct PluginCodec_H323NonStandardCodecData *);
00538 
00541     H323NonStandardCapabilityInfo(
00542       CompareFuncType compareFunc,
00543       const BYTE * dataBlock,         
00544       PINDEX dataSize                 
00545     );
00546 
00547     H323NonStandardCapabilityInfo(
00548       const BYTE * dataBlock,         
00549       PINDEX dataSize,                
00550       PINDEX comparisonOffset = 0,    
00551       PINDEX comparisonLength = P_MAX_INDEX    
00552     );
00553 
00556     H323NonStandardCapabilityInfo(
00557       const PString & oid,
00558       const BYTE * dataBlock,         
00559       PINDEX dataSize,                
00560       PINDEX comparisonOffset = 0,
00561       PINDEX comparisonLength = P_MAX_INDEX
00562     );
00563 
00566     H323NonStandardCapabilityInfo(
00567       BYTE country,                  
00568       BYTE extension,                
00569       WORD maufacturer,              
00570       const BYTE * dataBlock,        
00571       PINDEX dataSize,               
00572       PINDEX comparisonOffset = 0,   
00573       PINDEX comparisonLength = P_MAX_INDEX  
00574     );
00575 
00578     virtual ~H323NonStandardCapabilityInfo();
00579 
00584     virtual BOOL OnSendingPDU(
00585       PBYTEArray & data  
00586     ) const;
00587 
00592     virtual BOOL OnReceivedPDU(
00593       const PBYTEArray & data  
00594     );
00595 
00596   protected:
00597     BOOL OnSendingNonStandardPDU(
00598       PASN_Choice & pdu,
00599       unsigned nonStandardTag
00600     ) const;
00601     BOOL OnReceivedNonStandardPDU(
00602       const PASN_Choice & pdu,
00603       unsigned nonStandardTag
00604     );
00605 
00606     PObject::Comparison CompareParam(
00607       const H245_NonStandardParameter & param
00608     ) const;
00609     PObject::Comparison CompareInfo(
00610       const H323NonStandardCapabilityInfo & obj
00611     ) const;
00612     PObject::Comparison CompareData(
00613       const PBYTEArray & data  
00614     ) const;
00615 
00616     PString    oid;
00617     BYTE       t35CountryCode;
00618     BYTE       t35Extension;
00619     WORD       manufacturerCode;
00620     PBYTEArray nonStandardData;
00621     PINDEX     comparisonOffset;
00622     PINDEX     comparisonLength;
00623     CompareFuncType compareFunc;
00624 };
00625 
00626 
00636 class H323GenericCapabilityInfo
00637 {
00638   public:
00639     H323GenericCapabilityInfo(
00640         const PString &capabilityId,    
00641         PINDEX maxBitRate = 0         
00642         );
00643     H323GenericCapabilityInfo(const H323GenericCapabilityInfo &obj);
00644     virtual ~H323GenericCapabilityInfo();
00645 
00648     virtual BOOL IsGenericMatch(
00649       const H245_GenericCapability & param  
00650     ) const;
00651 
00654     virtual BOOL AddIntegerGenericParameter(
00655         BOOL collapsing,
00656         int standardId,
00657         int type, 
00658         long int value );
00659 
00660     
00661   protected:
00662     virtual BOOL OnSendingGenericPDU(H245_GenericCapability & pdu) const;
00663     virtual BOOL OnReceivedGenericPDU(const H245_GenericCapability &pdu);
00664 
00665     PObject::Comparison CompareInfo(
00666         const H323GenericCapabilityInfo & obj
00667         ) const;
00668 
00669     PINDEX maxBitRate;
00670     H245_CapabilityIdentifier *capId;
00671 
00672     /* parameters sent in the TerminalCapabilitySet and OpenLogicalChannel
00673        messages */
00674     PList<H245_GenericParameter> collapsingParameters;
00675     PList<H245_GenericParameter> nonCollapsingParameters;
00676 };
00677 
00678     
00685 class H323RealTimeCapability : public H323Capability
00686 {
00687   PCLASSINFO(H323RealTimeCapability, H323Capability);
00688 
00689   public:
00694     virtual H323Channel * CreateChannel(
00695       H323Connection & connection,    
00696       H323Channel::Directions dir,    
00697       unsigned sessionID,             
00698       const H245_H2250LogicalChannelParameters * param
00700     ) const;
00701 
00702     H323RealTimeCapability();
00703     H323RealTimeCapability(const H323RealTimeCapability &rtc);
00704     virtual ~H323RealTimeCapability();
00705     void AttachQoS(RTP_QOS * _rtpqos);
00706 
00707   protected:
00708     RTP_QOS * rtpqos;
00710 };
00711 
00712 #ifndef NO_H323_AUDIO_CODECS
00713 
00720 class H323AudioCapability : public H323RealTimeCapability
00721 {
00722   PCLASSINFO(H323AudioCapability, H323RealTimeCapability);
00723 
00724   public:
00729     H323AudioCapability(
00730       unsigned rxPacketSize, 
00731       unsigned txPacketSize  
00732     );
00734 
00740     virtual MainTypes GetMainType() const;
00742 
00753     virtual unsigned GetDefaultSessionID() const;
00754 
00763     virtual void SetTxFramesInPacket(
00764       unsigned frames   
00765     );
00766 
00772     virtual unsigned GetTxFramesInPacket() const;
00773 
00779     virtual unsigned GetRxFramesInPacket() const;
00781 
00792     virtual BOOL OnSendingPDU(
00793       H245_Capability & pdu  
00794     ) const;
00795 
00804     virtual BOOL OnSendingPDU(
00805       H245_DataType & pdu  
00806     ) const;
00807 
00816     virtual BOOL OnSendingPDU(
00817       H245_ModeElement & pdu  
00818     ) const;
00819 
00828     virtual BOOL OnSendingPDU(
00829       H245_AudioCapability & pdu,  
00830       unsigned packetSize          
00831     ) const;
00832 
00841     virtual BOOL OnSendingPDU(
00842       H245_AudioMode & pdu  
00843     ) const;
00844 
00856     virtual BOOL OnReceivedPDU(
00857       const H245_Capability & pdu  
00858     );
00859 
00869     virtual BOOL OnReceivedPDU(
00870       const H245_DataType & pdu,  
00871       BOOL receiver               
00872     );
00873 
00882     virtual BOOL OnReceivedPDU(
00883       const H245_AudioCapability & pdu,  
00884       unsigned & packetSize              
00885     );
00887 
00888   protected:
00889     unsigned rxFramesInPacket;
00890     unsigned txFramesInPacket;
00891 };
00892 
00893 
00901 class H323NonStandardAudioCapability : public H323AudioCapability,
00902                                        public H323NonStandardCapabilityInfo
00903 {
00904   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
00905 
00906   public:
00911     H323NonStandardAudioCapability(
00912       unsigned maxPacketSize,         
00913       unsigned desiredPacketSize,     
00914       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
00915       const BYTE * dataBlock,         
00916       PINDEX dataSize                 
00917     );
00918     H323NonStandardAudioCapability(
00919       unsigned maxPacketSize,         
00920       unsigned desiredPacketSize,     
00921       const BYTE * dataBlock,         
00922       PINDEX dataSize,                
00923       PINDEX comparisonOffset = 0,    
00924       PINDEX comparisonLength = P_MAX_INDEX     
00925      );
00929     H323NonStandardAudioCapability(
00930       unsigned maxPacketSize,         
00931       unsigned desiredPacketSize,     
00932       H323EndPoint &,
00933       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
00934       const BYTE * dataBlock,         
00935       PINDEX dataSize                 
00936     );
00937     H323NonStandardAudioCapability(
00938       unsigned maxPacketSize,         
00939       unsigned desiredPacketSize,     
00940       H323EndPoint &,
00941       const BYTE * dataBlock,         
00942       PINDEX dataSize,                
00943       PINDEX comparisonOffset = 0,    
00944       PINDEX comparisonLength = P_MAX_INDEX         
00945      );
00946 
00949     H323NonStandardAudioCapability(
00950       unsigned maxPacketSize,         
00951       unsigned desiredPacketSize,     
00952       const PString & oid,            
00953       const BYTE * dataBlock,         
00954       PINDEX dataSize,                
00955       PINDEX comparisonOffset = 0,    
00956       PINDEX comparisonLength = P_MAX_INDEX  
00957     );
00958 
00961     H323NonStandardAudioCapability(
00962       unsigned maxPacketSize,         
00963       unsigned desiredPacketSize,     
00964       BYTE country,                   
00965       BYTE extension,                 
00966       WORD maufacturer,               
00967       const BYTE * dataBlock,         
00968       PINDEX dataSize,                
00969       PINDEX comparisonOffset = 0,        
00970       PINDEX comparisonLength = P_MAX_INDEX        
00971     );
00973 
00979     Comparison Compare(const PObject & obj) const;
00981 
00989     virtual unsigned GetSubType() const;
00991 
01002     virtual BOOL OnSendingPDU(
01003       H245_AudioCapability & pdu,  
01004       unsigned packetSize          
01005     ) const;
01006 
01015     virtual BOOL OnSendingPDU(
01016       H245_AudioMode & pdu  
01017     ) const;
01018 
01027     virtual BOOL OnReceivedPDU(
01028       const H245_AudioCapability & pdu,  
01029       unsigned & packetSize              
01030     );
01031 
01034     virtual BOOL IsNonStandardMatch(
01035       const H245_NonStandardParameter & param  
01036     ) const;
01038 };
01039 
01047 class H323GenericAudioCapability : public H323AudioCapability,
01048                                    public H323GenericCapabilityInfo
01049 {
01050   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
01051 
01052   public:
01057     H323GenericAudioCapability(
01058       unsigned maxPacketSize,         
01059       unsigned desiredPacketSize,     
01060       const PString &capabilityId,    
01061       PINDEX maxBitRate = 0           
01062       );
01063 
01065 
01071     Comparison Compare(const PObject & obj) const;
01073 
01081     virtual unsigned GetSubType() const;
01083 
01094     virtual BOOL OnSendingPDU(
01095       H245_AudioCapability & pdu,  
01096       unsigned packetSize          
01097     ) const;
01098 
01107     virtual BOOL OnReceivedPDU(
01108       const H245_AudioCapability & pdu,  
01109       unsigned & packetSize              
01110     );
01111 
01114     virtual BOOL IsGenericMatch(
01115       const H245_GenericCapability & param  
01116       ) const { return H323GenericCapabilityInfo::IsGenericMatch(param); }
01117 
01119 };
01120 
01121 #endif
01122 
01123 #ifndef NO_H323_VIDEO
01124 
01131 class H323VideoCapability : public H323RealTimeCapability
01132 {
01133   PCLASSINFO(H323VideoCapability, H323RealTimeCapability);
01134 
01135   public:
01141     virtual MainTypes GetMainType() const;
01143 
01154     virtual unsigned GetDefaultSessionID() const;
01156 
01167     virtual BOOL OnSendingPDU(
01168       H245_Capability & pdu  
01169     ) const;
01170 
01179     virtual BOOL OnSendingPDU(
01180       H245_DataType & pdu  
01181     ) const;
01182 
01191     virtual BOOL OnSendingPDU(
01192       H245_ModeElement & pdu  
01193     ) const;
01194 
01202     virtual BOOL OnSendingPDU(
01203       H245_VideoCapability & pdu  
01204     ) const = 0;
01205 
01214     virtual BOOL OnSendingPDU(
01215       H245_VideoMode & pdu  
01216     ) const = 0;
01217 
01227     virtual BOOL OnReceivedPDU(
01228       const H245_Capability & pdu  
01229     );
01230 
01238     virtual BOOL OnReceivedPDU(
01239       const H245_DataType & pdu,  
01240       BOOL receiver               
01241     );
01242 
01250     virtual BOOL OnReceivedPDU(
01251       const H245_VideoCapability & pdu  
01252     ) = 0;
01254 };
01255 
01256 
01264 class H323NonStandardVideoCapability : public H323VideoCapability,
01265                                        public H323NonStandardCapabilityInfo
01266 {
01267   PCLASSINFO(H323NonStandardVideoCapability, H323VideoCapability);
01268 
01269   public:
01274     H323NonStandardVideoCapability(
01275       const BYTE * dataBlock,         
01276       PINDEX dataSize,                
01277       PINDEX comparisonOffset = 0,    
01278       PINDEX comparisonLength = P_MAX_INDEX  
01279     );
01280 
01284     H323NonStandardVideoCapability(
01285       H323EndPoint &,
01286       const BYTE * dataBlock,         
01287       PINDEX dataSize,                
01288       PINDEX comparisonOffset = 0,    
01289       PINDEX comparisonLength = P_MAX_INDEX  
01290     );
01291 
01294     H323NonStandardVideoCapability(
01295       const PString & oid,            
01296       const BYTE * dataBlock,         
01297       PINDEX dataSize,                
01298       PINDEX comparisonOffset = 0,    
01299       PINDEX comparisonLength = P_MAX_INDEX  
01300     );
01301 
01304     H323NonStandardVideoCapability(
01305       BYTE country,                   
01306       BYTE extension,                 
01307       WORD maufacturer,               
01308       const BYTE * dataBlock,         
01309       PINDEX dataSize,                
01310       PINDEX comparisonOffset = 0,    
01311       PINDEX comparisonLength = P_MAX_INDEX  
01312     );
01314 
01320     Comparison Compare(const PObject & obj) const;
01322 
01331     virtual unsigned GetSubType() const;
01333 
01344     virtual BOOL OnSendingPDU(
01345       H245_VideoCapability & pdu  
01346     ) const;
01347 
01356     virtual BOOL OnSendingPDU(
01357       H245_VideoMode & pdu  
01358     ) const;
01359 
01368     virtual BOOL OnReceivedPDU(
01369       const H245_VideoCapability & pdu  
01370     );
01371 
01374     virtual BOOL IsNonStandardMatch(
01375       const H245_NonStandardParameter & param  
01376     ) const;
01378 };
01379 
01387 class H323GenericVideoCapability : public H323VideoCapability,
01388                                    public H323GenericCapabilityInfo
01389 {
01390   PCLASSINFO(H323GenericVideoCapability, H323VideoCapability);
01391 
01392   public:
01397     H323GenericVideoCapability(
01398         const PString &capabilityId,    
01399         PINDEX maxBitRate = 0           
01400     );
01402 
01408     Comparison Compare(const PObject & obj) const;
01410 
01419     virtual unsigned GetSubType() const;
01421 
01432     virtual BOOL OnSendingPDU(
01433       H245_VideoCapability & pdu  
01434     ) const;
01435 
01444     virtual BOOL OnSendingPDU(
01445       H245_VideoMode & pdu  
01446     ) const;
01447 
01456     virtual BOOL OnReceivedPDU(
01457       const H245_VideoCapability & pdu  
01458     );
01459 
01462    virtual BOOL IsGenericMatch(
01463      const H245_GenericCapability & param  
01464      ) const { return H323GenericCapabilityInfo::IsGenericMatch(param); }
01466 };
01467 
01468 #endif
01469 
01470 
01477 class H323DataCapability : public H323Capability
01478 {
01479   PCLASSINFO(H323DataCapability, H323Capability);
01480 
01481   public:
01486     H323DataCapability(
01487       unsigned maxBitRate = 0  
01488     );
01490 
01496     virtual MainTypes GetMainType() const;
01498 
01508     virtual unsigned GetDefaultSessionID() const;
01509 
01513     virtual H323Codec * CreateCodec(
01514       H323Codec::Direction direction  
01515     ) const;
01517 
01528     virtual BOOL OnSendingPDU(
01529       H245_Capability & pdu  
01530     ) const;
01531 
01540     virtual BOOL OnSendingPDU(
01541       H245_DataType & pdu  
01542     ) const;
01543 
01552     virtual BOOL OnSendingPDU(
01553       H245_ModeElement & pdu  
01554     ) const;
01555 
01563     virtual BOOL OnSendingPDU(
01564       H245_DataApplicationCapability & pdu  
01565     ) const = 0;
01566 
01575     virtual BOOL OnSendingPDU(
01576       H245_DataMode & pdu  
01577     ) const = 0;
01578 
01588     virtual BOOL OnReceivedPDU(
01589       const H245_Capability & pdu  
01590     );
01591 
01599     virtual BOOL OnReceivedPDU(
01600       const H245_DataType & pdu,  
01601       BOOL receiver               
01602     );
01603 
01611     virtual BOOL OnReceivedPDU(
01612       const H245_DataApplicationCapability & pdu  
01613     ) = 0;
01615 
01616   protected:
01617     unsigned maxBitRate;
01618 };
01619 
01620 
01628 class H323NonStandardDataCapability : public H323DataCapability,
01629                                       public H323NonStandardCapabilityInfo
01630 {
01631   PCLASSINFO(H323NonStandardDataCapability, H323DataCapability);
01632 
01633   public:
01638     H323NonStandardDataCapability(
01639       unsigned maxBitRate,            
01640       const BYTE * dataBlock,         
01641       PINDEX dataSize,                
01642       PINDEX comparisonOffset = 0,    
01643       PINDEX comparisonLength = P_MAX_INDEX  
01644     );
01645 
01648     H323NonStandardDataCapability(
01649       unsigned maxBitRate,            
01650       const PString & oid,            
01651       const BYTE * dataBlock,         
01652       PINDEX dataSize,                
01653       PINDEX comparisonOffset = 0,    
01654       PINDEX comparisonLength = P_MAX_INDEX  
01655     );
01656 
01659     H323NonStandardDataCapability(
01660       unsigned maxBitRate,            
01661       BYTE country,                   
01662       BYTE extension,                 
01663       WORD maufacturer,               
01664       const BYTE * dataBlock,         
01665       PINDEX dataSize,                
01666       PINDEX comparisonOffset = 0,    
01667       PINDEX comparisonLength = P_MAX_INDEX  
01668     );
01670 
01676     Comparison Compare(const PObject & obj) const;
01678 
01687     virtual unsigned GetSubType() const;
01689 
01700     virtual BOOL OnSendingPDU(
01701       H245_DataApplicationCapability & pdu  
01702     ) const;
01703 
01712     virtual BOOL OnSendingPDU(
01713       H245_DataMode & pdu  
01714     ) const;
01715 
01724     virtual BOOL OnReceivedPDU(
01725       const H245_DataApplicationCapability & pdu  
01726     );
01727 
01730     virtual BOOL IsNonStandardMatch(
01731       const H245_NonStandardParameter & param  
01732     ) const;
01734 };
01735 
01736 #ifndef NO_H323_AUDIO_CODECS
01737 
01739 // The simplest codec is the G.711 PCM codec.
01740 
01743 class H323_G711Capability : public H323AudioCapability
01744 {
01745   PCLASSINFO(H323_G711Capability, H323AudioCapability)
01746 
01747   public:
01749     enum Mode {
01751       ALaw,
01753       muLaw
01754     };
01756     enum Speed {
01758       At64k,
01760       At56k
01761     };
01762 
01767     H323_G711Capability(
01768       Mode mode = muLaw,    
01769       Speed speed = At64k   
01770     );
01772 
01777     virtual PObject * Clone() const;
01779 
01788     virtual unsigned GetSubType() const;
01789 
01792     virtual PString GetFormatName() const;
01794 
01799     virtual H323Codec * CreateCodec(
01800       H323Codec::Direction direction  
01801     ) const;
01803 
01804   protected:
01805     Mode     mode;
01806     Speed    speed;
01807 };
01808 
01809 #endif // NO_H323_AUDIO_CODECS
01810 
01811 
01813 
01816 class H323_UserInputCapability : public H323Capability
01817 {
01818   PCLASSINFO(H323_UserInputCapability, H323Capability);
01819 
01820   public:
01823     enum SubTypes {
01824       BasicString,
01825       IA5String,
01826       GeneralString,
01827       SignalToneH245,
01828       HookFlashH245,
01829       SignalToneRFC2833,
01830       NumSubTypes
01831     };
01832     static const char * const SubTypeNames[NumSubTypes];
01833 
01838     H323_UserInputCapability(
01839       SubTypes subType
01840     );
01842 
01847     virtual PObject * Clone() const;
01849 
01857     virtual MainTypes GetMainType() const;
01858 
01862     virtual unsigned  GetSubType()  const;
01863 
01866     virtual PString GetFormatName() const;
01868 
01876     virtual H323Channel * CreateChannel(
01877       H323Connection & connection,    
01878       H323Channel::Directions dir,    
01879       unsigned sessionID,             
01880       const H245_H2250LogicalChannelParameters * param
01882     ) const;
01883 
01886     virtual H323Codec * CreateCodec(
01887       H323Codec::Direction direction  
01888     ) const;
01890 
01900     virtual BOOL OnSendingPDU(
01901       H245_Capability & pdu  
01902     ) const;
01903 
01911     virtual BOOL OnSendingPDU(
01912       H245_DataType & pdu  
01913     ) const;
01914 
01923     virtual BOOL OnSendingPDU(
01924       H245_ModeElement & pdu  
01925     ) const;
01926 
01936     virtual BOOL OnReceivedPDU(
01937       const H245_Capability & pdu  
01938     );
01939 
01947     virtual BOOL OnReceivedPDU(
01948       const H245_DataType & pdu,  
01949       BOOL receiver               
01950     );
01951 
01960     virtual BOOL IsUsable(
01961       const H323Connection & connection
01962     ) const;
01964 
01965     static void AddAllCapabilities(
01966       H323Capabilities & capabilities,        
01967       PINDEX descriptorNum,   
01968       PINDEX simultaneous     
01969     );
01970 
01971   protected:
01972     SubTypes subType;
01973 };
01974 
01975 
01976 
01978 
01979 PLIST(H323CapabilitiesList, H323Capability);
01980 
01981 PARRAY(H323CapabilitiesListArray, H323CapabilitiesList);
01982 
01983 class H323SimultaneousCapabilities : public H323CapabilitiesListArray
01984 {
01985   PCLASSINFO(H323SimultaneousCapabilities, H323CapabilitiesListArray);
01986   public:
01987     BOOL SetSize(PINDEX newSize);
01988 };
01989 
01990 
01991 PARRAY(H323CapabilitiesSetArray, H323SimultaneousCapabilities);
01992 
01993 
01994 class H323CapabilitiesSet : public H323CapabilitiesSetArray
01995 {
01996   PCLASSINFO(H323CapabilitiesSet, H323CapabilitiesSetArray);
01997   public:
01999     BOOL SetSize(PINDEX newSize);
02000 };
02001 
02002 
02005 class H323Capabilities : public PObject
02006 {
02007     PCLASSINFO(H323Capabilities, PObject);
02008   public:
02013     H323Capabilities();
02014 
02017     H323Capabilities(
02018       const H323Connection & connection,      
02019       const H245_TerminalCapabilitySet & pdu  
02020     );
02021 
02026     H323Capabilities(
02027       const H323Capabilities & original 
02028     );
02029 
02034     H323Capabilities & operator=(
02035       const H323Capabilities & original 
02036     );
02038 
02043     void PrintOn(
02044       ostream & strm    
02045     ) const;
02047 
02052     PINDEX GetSize() const { return table.GetSize(); }
02053 
02056     H323Capability & operator[](PINDEX i) const { return table[i]; }
02057 
02078     PINDEX SetCapability(
02079       PINDEX descriptorNum, 
02080       PINDEX simultaneous,  
02081       H323Capability * cap  
02082     );
02083 
02088     PINDEX AddAllCapabilities(
02089       PINDEX descriptorNum, 
02090       PINDEX simultaneous,  
02091       const PString & name  
02092     );
02093     PINDEX AddAllCapabilities(
02094       H323EndPoint &,
02095       PINDEX descriptorNum, 
02096       PINDEX simultaneous,  
02097       const PString & name  
02098     )
02099     { return AddAllCapabilities(descriptorNum, simultaneous, name); }
02100 
02109     void Add(
02110       H323Capability * capability   
02111     );
02112 
02119     H323Capability * Copy(
02120       const H323Capability & capability   
02121     );
02122 
02127     void Remove(
02128       H323Capability * capability   
02129     );
02130 
02135     void Remove(
02136       const PString & formatName   
02137     );
02138 
02142     void Remove(
02143       const PStringArray & formatNames  
02144     );
02145 
02148     void RemoveAll();
02149 
02157     H323Capability * FindCapability(
02158       unsigned capabilityNumber
02159     ) const;
02160 
02176     H323Capability * FindCapability(
02177       const PString & formatName, 
02178       H323Capability::CapabilityDirection direction = H323Capability::e_Unknown
02180     ) const;
02181 
02187     H323Capability * FindCapability(
02188       H323Capability::CapabilityDirection direction 
02189     ) const;
02190 
02198     H323Capability * FindCapability(
02199       const H323Capability & capability 
02200     ) const;
02201 
02207     H323Capability * FindCapability(
02208       const H245_Capability & cap  
02209     ) const;
02210 
02216     H323Capability * FindCapability(
02217       const H245_DataType & dataType  
02218     ) const;
02219 
02225     H323Capability * FindCapability(
02226       const H245_ModeElement & modeElement  
02227     ) const;
02228 
02234     H323Capability * FindCapability(
02235       H323Capability::MainTypes mainType, 
02236       const PASN_Choice & subTypePDU,     
02237       const unsigned * translationTable   
02238     ) const;
02239 
02245     H323Capability * FindCapability(
02246       H323Capability::MainTypes mainType, 
02247       unsigned subType = UINT_MAX         
02248     ) const;
02249 
02252     void BuildPDU(
02253       const H323Connection & connection,  
02254       H245_TerminalCapabilitySet & pdu    
02255     ) const;
02256 
02259     BOOL Merge(
02260       const H323Capabilities & newCaps
02261     );
02262 
02269     void Reorder(
02270       const PStringArray & preferenceOrder  
02271     );
02272 
02275     BOOL IsAllowed(
02276       const H323Capability & capability
02277     );
02278 
02281     BOOL IsAllowed(
02282       unsigned capabilityNumber
02283     );
02284 
02287     BOOL IsAllowed(
02288       const H323Capability & capability1,
02289       const H323Capability & capability2
02290     );
02291 
02294     BOOL IsAllowed(
02295       unsigned capabilityNumber1,
02296       unsigned capabilityNumber2
02297     );
02299 
02300   protected:
02301     H323CapabilitiesList table;
02302     H323CapabilitiesSet  set;
02303 };
02304 
02305 
02307 
02308 typedef PFactory<H323Capability> H323CapabilityFactory;
02309 
02310 #define H323_REGISTER_CAPABILITY(cls, capName)   static H323CapabilityFactory::Worker<cls> cls##Factory(capName, true); \
02311 
02312 #define H323_DEFINE_CAPABILITY(cls, capName, fmtName) \
02313 class cls : public H323Capability { \
02314   public: \
02315     cls() : H323Capability() { } \
02316     PString GetFormatName() const \
02317     { return fmtName; } \
02318 }; \
02319 H323_REGISTER_CAPABILITY(cls, capName) \
02320 
02321 #define H323_DEFINE_CAPABILITY_FROM(cls, ancestor, capName, fmtName) \
02322 class cls : public ancestor { \
02323   public: \
02324     cls() : ancestor() { } \
02325     PString GetFormatName() const \
02326     { return fmtName; } \
02327 }; \
02328 H323_REGISTER_CAPABILITY(cls, capName) \
02329 
02330 #endif // __OPAL_H323CAPS_H
02331 
02332