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.53  2006/09/05 23:56:57  csoutheren
00031  * Convert media format and capability factories to use std::string
00032  *
00033  * Revision 1.52  2006/05/16 11:36:01  shorne
00034  * added AEC support and  H323VdieoCapability default constructor
00035  *
00036  * Revision 1.51  2005/11/30 13:05:01  csoutheren
00037  * Changed tags for Doxygen
00038  *
00039  * Revision 1.50  2005/06/07 07:09:13  csoutheren
00040  * Removed compiler warnings on Windows
00041  *
00042  * Revision 1.49  2005/06/07 03:22:22  csoutheren
00043  * Added patch 1198741 with support for plugin codecs with generic capabilities
00044  * Added patch 1198754 with support for setting quality level on audio codecs
00045  * Added patch 1198760 with GSM-AMR codec support
00046  * Many thanks to Richard van der Hoff for his work
00047  *
00048  * Revision 1.48  2005/01/03 06:25:52  csoutheren
00049  * Added extensive support for disabling code modules at compile time
00050  *
00051  * Revision 1.47  2004/08/24 14:23:09  csoutheren
00052  * Fixed problem with plugin codecs using capability compare functions
00053  *
00054  * Revision 1.46  2004/06/30 12:31:09  rjongbloed
00055  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00056  *   of issues with startup orders and Windows DLL multiple instances.
00057  *
00058  * Revision 1.45  2004/06/08 01:20:28  csoutheren
00059  * Provide backwards compatibility for applications using old capability API
00060  *
00061  * Revision 1.44  2004/06/01 05:47:58  csoutheren
00062  * Changed capability table to use abstract factory routines rather than internal linked list
00063  *
00064  * Revision 1.43  2004/05/13 12:49:32  rjongbloed
00065  * Fixed usage of the compare function in non-standard capabilities.
00066  *
00067  * Revision 1.42  2004/04/03 10:38:24  csoutheren
00068  * Added in initial cut at codec plugin code. Branches are for wimps :)
00069  *
00070  * Revision 1.41.2.1  2004/03/31 11:11:58  csoutheren
00071  * Initial public release of plugin codec code
00072  *
00073  * Revision 1.41  2004/03/02 11:48:14  rjongbloed
00074  * Fixed correct capability table matching when FindCapability with a mode change,
00075  *   uses different enum so needs translation table.
00076  *
00077  * Revision 1.40  2003/10/27 06:03:39  csoutheren
00078  * Added support for QoS
00079  *   Thanks to Henry Harrison of AliceStreet
00080  *
00081  * Revision 1.39  2003/06/06 02:13:10  rjongbloed
00082  * Changed non-standard capability semantics so can use C style strings as
00083  *   the embedded data block (ie automatically call strlen)
00084  *
00085  * Revision 1.38  2003/04/28 07:00:00  robertj
00086  * Fixed problem with compiler(s) not correctly initialising static globals
00087  *
00088  * Revision 1.37  2003/04/27 23:49:21  craigs
00089  * Fixed some comments and made list of registered codecs
00090  * available outside h323caps.cxx
00091  *
00092  * Revision 1.36  2002/11/09 04:24:01  robertj
00093  * Fixed minor documentation errors.
00094  *
00095  * Revision 1.35  2002/09/16 01:14:15  robertj
00096  * Added #define so can select if #pragma interface/implementation is used on
00097  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00098  *
00099  * Revision 1.34  2002/09/03 06:19:36  robertj
00100  * Normalised the multi-include header prevention ifdef/define symbol.
00101  *
00102  * Revision 1.33  2002/08/05 10:03:47  robertj
00103  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00104  *
00105  * Revision 1.32  2002/05/29 03:55:17  robertj
00106  * Added protocol version number checking infrastructure, primarily to improve
00107  *   interoperability with stacks that are unforgiving of new features.
00108  *
00109  * Revision 1.31  2002/05/10 05:44:50  robertj
00110  * Added the max bit rate field to the data channel capability class.
00111  *
00112  * Revision 1.30  2002/01/22 06:25:02  robertj
00113  * Moved payload type to ancestor so any capability can adjust it on logical channel.
00114  *
00115  * Revision 1.29  2002/01/17 07:04:57  robertj
00116  * Added support for RFC2833 embedded DTMF in the RTP stream.
00117  *
00118  * Revision 1.28  2002/01/16 05:37:41  robertj
00119  * Added missing mode change functions on non standard capabilities.
00120  *
00121  * Revision 1.27  2002/01/09 00:21:36  robertj
00122  * Changes to support outgoing H.245 RequstModeChange.
00123  *
00124  * Revision 1.26  2001/12/22 01:44:05  robertj
00125  * Added more support for H.245 RequestMode operation.
00126  *
00127  * Revision 1.25  2001/10/24 01:20:34  robertj
00128  * Added code to help with static linking of H323Capability names database.
00129  *
00130  * Revision 1.24  2001/09/21 02:48:51  robertj
00131  * Added default implementation for PDU encode/decode for codecs
00132  *   that have simple integer as frames per packet.
00133  *
00134  * Revision 1.23  2001/09/11 10:21:40  robertj
00135  * Added direction field to capabilities, thanks Nick Hoath.
00136  *
00137  * Revision 1.22  2001/07/19 09:50:40  robertj
00138  * Added code for default session ID on data channel being three.
00139  *
00140  * Revision 1.21  2001/07/17 04:44:29  robertj
00141  * Partial implementation of T.120 and T.38 logical channels.
00142  *
00143  * Revision 1.20  2001/05/21 07:20:47  robertj
00144  * Removed redundent class name in declaration.
00145  *
00146  * Revision 1.19  2001/05/14 05:56:26  robertj
00147  * Added H323 capability registration system so can add capabilities by
00148  *   string name instead of having to instantiate explicit classes.
00149  *
00150  * Revision 1.18  2001/05/02 16:22:21  rogerh
00151  * Add IsAllow() for a single capability to check if it is in the
00152  * capabilities set. This fixes the bug where OpenH323 would accept
00153  * incoming H261 video even when told not to accept it.
00154  *
00155  * Revision 1.17  2001/03/16 23:00:21  robertj
00156  * Improved validation of codec selection against capability set, thanks Chris Purvis.
00157  *
00158  * Revision 1.16  2001/02/09 05:16:24  robertj
00159  * Added #pragma interface for GNU C++.
00160  *
00161  * Revision 1.15  2001/01/25 07:27:14  robertj
00162  * Major changes to add more flexible OpalMediaFormat class to normalise
00163  *   all information about media types, especially codecs.
00164  *
00165  * Revision 1.14  2001/01/09 23:05:22  robertj
00166  * Fixed inability to have 2 non standard codecs in capability table.
00167  *
00168  * Revision 1.13  2000/10/16 08:49:30  robertj
00169  * Added single function to add all UserInput capability types.
00170  *
00171  * Revision 1.12  2000/08/23 14:23:11  craigs
00172  * Added prototype support for Microsoft GSM codec
00173  *
00174  * Revision 1.11  2000/07/13 12:25:47  robertj
00175  * Fixed problems with fast start frames per packet adjustment.
00176  *
00177  * Revision 1.10  2000/07/10 16:01:50  robertj
00178  * Started fixing capability set merging, still more to do.
00179  *
00180  * Revision 1.9  2000/07/04 01:16:49  robertj
00181  * Added check for capability allowed in "combinations" set, still needs more done yet.
00182  *
00183  * Revision 1.8  2000/06/03 03:16:47  robertj
00184  * Fixed using the wrong capability table (should be connections) for some operations.
00185  *
00186  * Revision 1.7  2000/05/23 11:32:27  robertj
00187  * Rewrite of capability table to combine 2 structures into one and move functionality into that class
00188  *    allowing some normalisation of usage across several applications.
00189  * Changed H323Connection so gets a copy of capabilities instead of using endponts, allows adjustments
00190  *    to be done depending on the remote client application.
00191  *
00192  * Revision 1.6  2000/05/18 11:53:34  robertj
00193  * Changes to support doc++ documentation generation.
00194  *
00195  * Revision 1.5  2000/05/10 04:05:26  robertj
00196  * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
00197  *
00198  * Revision 1.4  2000/05/02 04:32:24  robertj
00199  * Fixed copyright notice comment.
00200  *
00201  * Revision 1.3  2000/04/05 19:01:12  robertj
00202  * Added function so can change desired transmit packet size.
00203  *
00204  * Revision 1.2  2000/03/21 03:06:47  robertj
00205  * Changes to make RTP TX of exact numbers of frames in some codecs.
00206  *
00207  * Revision 1.1  1999/12/23 23:02:35  robertj
00208  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00209  *
00210  */
00211 
00212 #ifndef __OPAL_H323CAPS_H
00213 #define __OPAL_H323CAPS_H
00214 
00215 #ifdef P_USE_PRAGMA
00216 #pragma interface
00217 #endif
00218 
00219 
00220 #include "codecs.h"
00221 #include "channels.h"
00222 
00223 
00224 /* The following classes have forward references to avoid including the VERY
00225    large header files for H225 and H245. If an application requires access
00226    to the protocol classes they can include them, but for simple usage their
00227    inclusion can be avoided.
00228  */
00229 class PASN_Choice;
00230 class H245_Capability;
00231 class H245_DataType;
00232 class H245_ModeElement;
00233 class H245_AudioCapability;
00234 class H245_AudioMode;
00235 class H245_VideoCapability;
00236 class H245_VideoMode;
00237 class H245_DataApplicationCapability;
00238 class H245_DataMode;
00239 class H245_DataProtocolCapability;
00240 class H245_GenericCapability;
00241 class H245_CapabilityIdentifier;
00242 class H245_GenericParameter;
00243 class H245_H2250LogicalChannelParameters;
00244 class H245_H223LogicalChannelParameters;
00245 class H245_TerminalCapabilitySet;
00246 class H245_NonStandardParameter;
00247 class H323Connection;
00248 class H323Capabilities;
00249 
00250 
00251 
00253 
00267 class H323Capability : public PObject
00268 {
00269   PCLASSINFO(H323Capability, PObject);
00270 
00271   public:
00276     H323Capability();
00278 
00284     Comparison Compare(const PObject & obj) const;
00285 
00288     void PrintOn(ostream & strm) const;
00290 
00293     enum MainTypes {
00295       e_Audio,
00297       e_Video,
00299       e_Data,
00301       e_UserInput,
00303       e_NumMainTypes
00304     };
00305 
00311     virtual MainTypes GetMainType() const = 0;
00312 
00316     virtual unsigned  GetSubType()  const = 0;
00317 
00320     virtual PString GetFormatName() const = 0;
00322 
00328     static H323Capability * Create(
00329       const PString & name    
00330     );
00331 
00335     static H323Capability * Create(
00336       H323EndPoint &,         
00337       const PString & name    
00338     )
00339     { return Create(name); }
00340 
00349     virtual unsigned GetDefaultSessionID() const;
00350 
00359     virtual void SetTxFramesInPacket(
00360       unsigned frames   
00361     );
00362 
00367     virtual unsigned GetTxFramesInPacket() const;
00368 
00373     virtual unsigned GetRxFramesInPacket() const;
00374 
00380     virtual H323Channel * CreateChannel(
00381       H323Connection & connection,    
00382       H323Channel::Directions dir,    
00383       unsigned sessionID,             
00384       const H245_H2250LogicalChannelParameters * param
00386     ) const = 0;
00387 
00390     virtual H323Codec * CreateCodec(
00391       H323Codec::Direction direction  
00392     ) const = 0;
00394 
00404     virtual BOOL OnSendingPDU(
00405       H245_Capability & pdu  
00406     ) const = 0;
00407 
00415     virtual BOOL OnSendingPDU(
00416       H245_DataType & pdu  
00417     ) const = 0;
00418 
00426     virtual BOOL OnSendingPDU(
00427       H245_ModeElement & pdu  
00428     ) const = 0;
00429 
00442     virtual BOOL OnReceivedPDU(
00443       const H245_Capability & pdu 
00444     );
00445 
00453     virtual BOOL OnReceivedPDU(
00454       const H245_DataType & pdu,  
00455       BOOL receiver               
00456     ) = 0;
00457 
00458 
00461     virtual BOOL IsGenericMatch(
00462       const H245_GenericCapability & /*param*/  
00463       ) const { return FALSE; }
00464     
00467     virtual BOOL IsNonStandardMatch(
00468       const H245_NonStandardParameter & param  
00469     ) const;
00470 
00478     virtual BOOL IsUsable(
00479       const H323Connection & connection
00480     ) const;
00482 
00485     enum CapabilityDirection {
00486       e_Unknown,
00487       e_Receive,
00488       e_Transmit,
00489       e_ReceiveAndTransmit,
00490       e_NoDirection,
00491       NumCapabilityDirections
00492     };
00493 
00496     CapabilityDirection GetCapabilityDirection() const { return capabilityDirection; }
00497 
00500     void SetCapabilityDirection(
00501       CapabilityDirection dir   
00502     ) { capabilityDirection = dir; }
00503 
00505     unsigned GetCapabilityNumber() const { return assignedCapabilityNumber; }
00506 
00508     void SetCapabilityNumber(unsigned num) { assignedCapabilityNumber = num; }
00509 
00511     RTP_DataFrame::PayloadTypes GetPayloadType() const { return rtpPayloadType; }
00512 
00514     virtual void AttachQoS(RTP_QOS *)
00515     {}
00517 
00518 #if PTRACING
00519     friend ostream & operator<<(ostream & o , MainTypes t);
00520     friend ostream & operator<<(ostream & o , CapabilityDirection d);
00521 #endif
00522 
00523   protected:
00524     unsigned assignedCapabilityNumber;  
00525     CapabilityDirection capabilityDirection;
00526     RTP_DataFrame::PayloadTypes rtpPayloadType;
00527 };
00528 
00529 
00530 
00540 class H323NonStandardCapabilityInfo
00541 {
00542   public:
00543     typedef PObject::Comparison (*CompareFuncType)(struct PluginCodec_H323NonStandardCodecData *);
00544 
00547     H323NonStandardCapabilityInfo(
00548       CompareFuncType compareFunc,
00549       const BYTE * dataBlock,         
00550       PINDEX dataSize                 
00551     );
00552 
00553     H323NonStandardCapabilityInfo(
00554       const BYTE * dataBlock,         
00555       PINDEX dataSize,                
00556       PINDEX comparisonOffset = 0,    
00557       PINDEX comparisonLength = P_MAX_INDEX    
00558     );
00559 
00562     H323NonStandardCapabilityInfo(
00563       const PString & oid,
00564       const BYTE * dataBlock,         
00565       PINDEX dataSize,                
00566       PINDEX comparisonOffset = 0,
00567       PINDEX comparisonLength = P_MAX_INDEX
00568     );
00569 
00572     H323NonStandardCapabilityInfo(
00573       BYTE country,                  
00574       BYTE extension,                
00575       WORD maufacturer,              
00576       const BYTE * dataBlock,        
00577       PINDEX dataSize,               
00578       PINDEX comparisonOffset = 0,   
00579       PINDEX comparisonLength = P_MAX_INDEX  
00580     );
00581 
00584     virtual ~H323NonStandardCapabilityInfo();
00585 
00590     virtual BOOL OnSendingPDU(
00591       PBYTEArray & data  
00592     ) const;
00593 
00598     virtual BOOL OnReceivedPDU(
00599       const PBYTEArray & data  
00600     );
00601 
00602   protected:
00603     BOOL OnSendingNonStandardPDU(
00604       PASN_Choice & pdu,
00605       unsigned nonStandardTag
00606     ) const;
00607     BOOL OnReceivedNonStandardPDU(
00608       const PASN_Choice & pdu,
00609       unsigned nonStandardTag
00610     );
00611 
00612     PObject::Comparison CompareParam(
00613       const H245_NonStandardParameter & param
00614     ) const;
00615     PObject::Comparison CompareInfo(
00616       const H323NonStandardCapabilityInfo & obj
00617     ) const;
00618     PObject::Comparison CompareData(
00619       const PBYTEArray & data  
00620     ) const;
00621 
00622     PString    oid;
00623     BYTE       t35CountryCode;
00624     BYTE       t35Extension;
00625     WORD       manufacturerCode;
00626     PBYTEArray nonStandardData;
00627     PINDEX     comparisonOffset;
00628     PINDEX     comparisonLength;
00629     CompareFuncType compareFunc;
00630 };
00631 
00632 
00642 class H323GenericCapabilityInfo
00643 {
00644   public:
00645     H323GenericCapabilityInfo(
00646         const PString &capabilityId,    
00647         PINDEX maxBitRate = 0         
00648         );
00649     H323GenericCapabilityInfo(const H323GenericCapabilityInfo &obj);
00650     virtual ~H323GenericCapabilityInfo();
00651 
00654     virtual BOOL IsGenericMatch(
00655       const H245_GenericCapability & param  
00656     ) const;
00657 
00660     virtual BOOL AddIntegerGenericParameter(
00661         BOOL collapsing,
00662         int standardId,
00663         int type, 
00664         long int value );
00665 
00666     
00667   protected:
00668     virtual BOOL OnSendingGenericPDU(H245_GenericCapability & pdu) const;
00669     virtual BOOL OnReceivedGenericPDU(const H245_GenericCapability &pdu);
00670 
00671     PObject::Comparison CompareInfo(
00672         const H323GenericCapabilityInfo & obj
00673         ) const;
00674 
00675     PINDEX maxBitRate;
00676     H245_CapabilityIdentifier *capId;
00677 
00678     /* parameters sent in the TerminalCapabilitySet and OpenLogicalChannel
00679        messages */
00680     PList<H245_GenericParameter> collapsingParameters;
00681     PList<H245_GenericParameter> nonCollapsingParameters;
00682 };
00683 
00684     
00691 class PAec;
00692 class H323RealTimeCapability : public H323Capability
00693 {
00694   PCLASSINFO(H323RealTimeCapability, H323Capability);
00695 
00696   public:
00701     virtual H323Channel * CreateChannel(
00702       H323Connection & connection,    
00703       H323Channel::Directions dir,    
00704       unsigned sessionID,             
00705       const H245_H2250LogicalChannelParameters * param
00707     ) const;
00708 
00709     H323RealTimeCapability();
00710     H323RealTimeCapability(const H323RealTimeCapability &rtc);
00711     virtual ~H323RealTimeCapability();
00712     virtual void AttachQoS(RTP_QOS * _rtpqos);
00713 
00714   protected:
00715     RTP_QOS * rtpqos;
00716 
00717 
00719 };
00720 
00721 #ifndef NO_H323_AUDIO_CODECS
00722 
00729 class H323AudioCapability : public H323RealTimeCapability
00730 {
00731   PCLASSINFO(H323AudioCapability, H323RealTimeCapability);
00732 
00733   public:
00738     H323AudioCapability(
00739       unsigned rxPacketSize, 
00740       unsigned txPacketSize  
00741     );
00743 
00749     virtual MainTypes GetMainType() const;
00751 
00762     virtual unsigned GetDefaultSessionID() const;
00763 
00772     virtual void SetTxFramesInPacket(
00773       unsigned frames   
00774     );
00775 
00781     virtual unsigned GetTxFramesInPacket() const;
00782 
00788     virtual unsigned GetRxFramesInPacket() const;
00790 
00801     virtual BOOL OnSendingPDU(
00802       H245_Capability & pdu  
00803     ) const;
00804 
00813     virtual BOOL OnSendingPDU(
00814       H245_DataType & pdu  
00815     ) const;
00816 
00825     virtual BOOL OnSendingPDU(
00826       H245_ModeElement & pdu  
00827     ) const;
00828 
00837     virtual BOOL OnSendingPDU(
00838       H245_AudioCapability & pdu,  
00839       unsigned packetSize          
00840     ) const;
00841 
00850     virtual BOOL OnSendingPDU(
00851       H245_AudioMode & pdu  
00852     ) const;
00853 
00865     virtual BOOL OnReceivedPDU(
00866       const H245_Capability & pdu  
00867     );
00868 
00878     virtual BOOL OnReceivedPDU(
00879       const H245_DataType & pdu,  
00880       BOOL receiver               
00881     );
00882 
00891     virtual BOOL OnReceivedPDU(
00892       const H245_AudioCapability & pdu,  
00893       unsigned & packetSize              
00894     );
00896 
00897   protected:
00898     unsigned rxFramesInPacket;
00899     unsigned txFramesInPacket;
00900 };
00901 
00902 
00910 class H323NonStandardAudioCapability : public H323AudioCapability,
00911                                        public H323NonStandardCapabilityInfo
00912 {
00913   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
00914 
00915   public:
00920     H323NonStandardAudioCapability(
00921       unsigned maxPacketSize,         
00922       unsigned desiredPacketSize,     
00923       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
00924       const BYTE * dataBlock,         
00925       PINDEX dataSize                 
00926     );
00927     H323NonStandardAudioCapability(
00928       unsigned maxPacketSize,         
00929       unsigned desiredPacketSize,     
00930       const BYTE * dataBlock,         
00931       PINDEX dataSize,                
00932       PINDEX comparisonOffset = 0,    
00933       PINDEX comparisonLength = P_MAX_INDEX     
00934      );
00938     H323NonStandardAudioCapability(
00939       unsigned maxPacketSize,         
00940       unsigned desiredPacketSize,     
00941       H323EndPoint &,
00942       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
00943       const BYTE * dataBlock,         
00944       PINDEX dataSize                 
00945     );
00946     H323NonStandardAudioCapability(
00947       unsigned maxPacketSize,         
00948       unsigned desiredPacketSize,     
00949       H323EndPoint &,
00950       const BYTE * dataBlock,         
00951       PINDEX dataSize,                
00952       PINDEX comparisonOffset = 0,    
00953       PINDEX comparisonLength = P_MAX_INDEX         
00954      );
00955 
00958     H323NonStandardAudioCapability(
00959       unsigned maxPacketSize,         
00960       unsigned desiredPacketSize,     
00961       const PString & oid,            
00962       const BYTE * dataBlock,         
00963       PINDEX dataSize,                
00964       PINDEX comparisonOffset = 0,    
00965       PINDEX comparisonLength = P_MAX_INDEX  
00966     );
00967 
00970     H323NonStandardAudioCapability(
00971       unsigned maxPacketSize,         
00972       unsigned desiredPacketSize,     
00973       BYTE country,                   
00974       BYTE extension,                 
00975       WORD maufacturer,               
00976       const BYTE * dataBlock,         
00977       PINDEX dataSize,                
00978       PINDEX comparisonOffset = 0,        
00979       PINDEX comparisonLength = P_MAX_INDEX        
00980     );
00982 
00988     Comparison Compare(const PObject & obj) const;
00990 
00998     virtual unsigned GetSubType() const;
01000 
01011     virtual BOOL OnSendingPDU(
01012       H245_AudioCapability & pdu,  
01013       unsigned packetSize          
01014     ) const;
01015 
01024     virtual BOOL OnSendingPDU(
01025       H245_AudioMode & pdu  
01026     ) const;
01027 
01036     virtual BOOL OnReceivedPDU(
01037       const H245_AudioCapability & pdu,  
01038       unsigned & packetSize              
01039     );
01040 
01043     virtual BOOL IsNonStandardMatch(
01044       const H245_NonStandardParameter & param  
01045     ) const;
01047 };
01048 
01056 class H323GenericAudioCapability : public H323AudioCapability,
01057                                    public H323GenericCapabilityInfo
01058 {
01059   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
01060 
01061   public:
01066     H323GenericAudioCapability(
01067       unsigned maxPacketSize,         
01068       unsigned desiredPacketSize,     
01069       const PString &capabilityId,    
01070       PINDEX maxBitRate = 0           
01071       );
01072 
01074 
01080     Comparison Compare(const PObject & obj) const;
01082 
01090     virtual unsigned GetSubType() const;
01092 
01103     virtual BOOL OnSendingPDU(
01104       H245_AudioCapability & pdu,  
01105       unsigned packetSize          
01106     ) const;
01107 
01116     virtual BOOL OnReceivedPDU(
01117       const H245_AudioCapability & pdu,  
01118       unsigned & packetSize              
01119     );
01120 
01123     virtual BOOL IsGenericMatch(
01124       const H245_GenericCapability & param  
01125       ) const { return H323GenericCapabilityInfo::IsGenericMatch(param); }
01126 
01128 };
01129 
01130 #endif
01131 
01132 #ifndef NO_H323_VIDEO
01133 
01140 class H323VideoCapability : public H323RealTimeCapability
01141 {
01142   PCLASSINFO(H323VideoCapability, H323RealTimeCapability);
01143 
01144   public:
01149     H323VideoCapability();
01151 
01156     virtual MainTypes GetMainType() const;
01158 
01169     virtual unsigned GetDefaultSessionID() const;
01171 
01182     virtual BOOL OnSendingPDU(
01183       H245_Capability & pdu  
01184     ) const;
01185 
01194     virtual BOOL OnSendingPDU(
01195       H245_DataType & pdu  
01196     ) const;
01197 
01206     virtual BOOL OnSendingPDU(
01207       H245_ModeElement & pdu  
01208     ) const;
01209 
01217     virtual BOOL OnSendingPDU(
01218       H245_VideoCapability & pdu  
01219     ) const = 0;
01220 
01229     virtual BOOL OnSendingPDU(
01230       H245_VideoMode & pdu  
01231     ) const = 0;
01232 
01242     virtual BOOL OnReceivedPDU(
01243       const H245_Capability & pdu  
01244     );
01245 
01253     virtual BOOL OnReceivedPDU(
01254       const H245_DataType & pdu,  
01255       BOOL receiver               
01256     );
01257 
01265     virtual BOOL OnReceivedPDU(
01266       const H245_VideoCapability & pdu  
01267     ) = 0;
01269 };
01270 
01271 
01279 class H323NonStandardVideoCapability : public H323VideoCapability,
01280                                        public H323NonStandardCapabilityInfo
01281 {
01282   PCLASSINFO(H323NonStandardVideoCapability, H323VideoCapability);
01283 
01284   public:
01289     H323NonStandardVideoCapability(
01290       const BYTE * dataBlock,         
01291       PINDEX dataSize,                
01292       PINDEX comparisonOffset = 0,    
01293       PINDEX comparisonLength = P_MAX_INDEX  
01294     );
01295 
01299     H323NonStandardVideoCapability(
01300       H323EndPoint &,
01301       const BYTE * dataBlock,         
01302       PINDEX dataSize,                
01303       PINDEX comparisonOffset = 0,    
01304       PINDEX comparisonLength = P_MAX_INDEX  
01305     );
01306 
01309     H323NonStandardVideoCapability(
01310       const PString & oid,            
01311       const BYTE * dataBlock,         
01312       PINDEX dataSize,                
01313       PINDEX comparisonOffset = 0,    
01314       PINDEX comparisonLength = P_MAX_INDEX  
01315     );
01316 
01319     H323NonStandardVideoCapability(
01320       BYTE country,                   
01321       BYTE extension,                 
01322       WORD maufacturer,               
01323       const BYTE * dataBlock,         
01324       PINDEX dataSize,                
01325       PINDEX comparisonOffset = 0,    
01326       PINDEX comparisonLength = P_MAX_INDEX  
01327     );
01329 
01335     Comparison Compare(const PObject & obj) const;
01337 
01346     virtual unsigned GetSubType() const;
01348 
01359     virtual BOOL OnSendingPDU(
01360       H245_VideoCapability & pdu  
01361     ) const;
01362 
01371     virtual BOOL OnSendingPDU(
01372       H245_VideoMode & pdu  
01373     ) const;
01374 
01383     virtual BOOL OnReceivedPDU(
01384       const H245_VideoCapability & pdu  
01385     );
01386 
01389     virtual BOOL IsNonStandardMatch(
01390       const H245_NonStandardParameter & param  
01391     ) const;
01393 };
01394 
01402 class H323GenericVideoCapability : public H323VideoCapability,
01403                                    public H323GenericCapabilityInfo
01404 {
01405   PCLASSINFO(H323GenericVideoCapability, H323VideoCapability);
01406 
01407   public:
01412     H323GenericVideoCapability(
01413         const PString &capabilityId,    
01414         PINDEX maxBitRate = 0           
01415     );
01417 
01423     Comparison Compare(const PObject & obj) const;
01425 
01434     virtual unsigned GetSubType() const;
01436 
01447     virtual BOOL OnSendingPDU(
01448       H245_VideoCapability & pdu  
01449     ) const;
01450 
01459     virtual BOOL OnSendingPDU(
01460       H245_VideoMode & pdu  
01461     ) const;
01462 
01471     virtual BOOL OnReceivedPDU(
01472       const H245_VideoCapability & pdu  
01473     );
01474 
01477    virtual BOOL IsGenericMatch(
01478      const H245_GenericCapability & param  
01479      ) const { return H323GenericCapabilityInfo::IsGenericMatch(param); }
01481 };
01482 
01483 #endif
01484 
01485 
01492 class H323DataCapability : public H323Capability
01493 {
01494   PCLASSINFO(H323DataCapability, H323Capability);
01495 
01496   public:
01501     H323DataCapability(
01502       unsigned maxBitRate = 0  
01503     );
01505 
01511     virtual MainTypes GetMainType() const;
01513 
01523     virtual unsigned GetDefaultSessionID() const;
01524 
01528     virtual H323Codec * CreateCodec(
01529       H323Codec::Direction direction  
01530     ) const;
01532 
01543     virtual BOOL OnSendingPDU(
01544       H245_Capability & pdu  
01545     ) const;
01546 
01555     virtual BOOL OnSendingPDU(
01556       H245_DataType & pdu  
01557     ) const;
01558 
01567     virtual BOOL OnSendingPDU(
01568       H245_ModeElement & pdu  
01569     ) const;
01570 
01578     virtual BOOL OnSendingPDU(
01579       H245_DataApplicationCapability & pdu  
01580     ) const = 0;
01581 
01590     virtual BOOL OnSendingPDU(
01591       H245_DataMode & pdu  
01592     ) const = 0;
01593 
01603     virtual BOOL OnReceivedPDU(
01604       const H245_Capability & pdu  
01605     );
01606 
01614     virtual BOOL OnReceivedPDU(
01615       const H245_DataType & pdu,  
01616       BOOL receiver               
01617     );
01618 
01626     virtual BOOL OnReceivedPDU(
01627       const H245_DataApplicationCapability & pdu  
01628     ) = 0;
01630 
01631   protected:
01632     unsigned maxBitRate;
01633 };
01634 
01635 
01643 class H323NonStandardDataCapability : public H323DataCapability,
01644                                       public H323NonStandardCapabilityInfo
01645 {
01646   PCLASSINFO(H323NonStandardDataCapability, H323DataCapability);
01647 
01648   public:
01653     H323NonStandardDataCapability(
01654       unsigned maxBitRate,            
01655       const BYTE * dataBlock,         
01656       PINDEX dataSize,                
01657       PINDEX comparisonOffset = 0,    
01658       PINDEX comparisonLength = P_MAX_INDEX  
01659     );
01660 
01663     H323NonStandardDataCapability(
01664       unsigned maxBitRate,            
01665       const PString & oid,            
01666       const BYTE * dataBlock,         
01667       PINDEX dataSize,                
01668       PINDEX comparisonOffset = 0,    
01669       PINDEX comparisonLength = P_MAX_INDEX  
01670     );
01671 
01674     H323NonStandardDataCapability(
01675       unsigned maxBitRate,            
01676       BYTE country,                   
01677       BYTE extension,                 
01678       WORD maufacturer,               
01679       const BYTE * dataBlock,         
01680       PINDEX dataSize,                
01681       PINDEX comparisonOffset = 0,    
01682       PINDEX comparisonLength = P_MAX_INDEX  
01683     );
01685 
01691     Comparison Compare(const PObject & obj) const;
01693 
01702     virtual unsigned GetSubType() const;
01704 
01715     virtual BOOL OnSendingPDU(
01716       H245_DataApplicationCapability & pdu  
01717     ) const;
01718 
01727     virtual BOOL OnSendingPDU(
01728       H245_DataMode & pdu  
01729     ) const;
01730 
01739     virtual BOOL OnReceivedPDU(
01740       const H245_DataApplicationCapability & pdu  
01741     );
01742 
01745     virtual BOOL IsNonStandardMatch(
01746       const H245_NonStandardParameter & param  
01747     ) const;
01749 };
01750 
01751 #ifndef NO_H323_AUDIO_CODECS
01752 
01754 // The simplest codec is the G.711 PCM codec.
01755 
01758 class H323_G711Capability : public H323AudioCapability
01759 {
01760   PCLASSINFO(H323_G711Capability, H323AudioCapability)
01761 
01762   public:
01764     enum Mode {
01766       ALaw,
01768       muLaw
01769     };
01771     enum Speed {
01773       At64k,
01775       At56k
01776     };
01777 
01782     H323_G711Capability(
01783       Mode mode = muLaw,    
01784       Speed speed = At64k   
01785     );
01787 
01792     virtual PObject * Clone() const;
01794 
01803     virtual unsigned GetSubType() const;
01804 
01807     virtual PString GetFormatName() const;
01809 
01814     virtual H323Codec * CreateCodec(
01815       H323Codec::Direction direction  
01816     ) const;
01818 
01819   protected:
01820     Mode     mode;
01821     Speed    speed;
01822 };
01823 
01824 #endif // NO_H323_AUDIO_CODECS
01825 
01826 
01828 
01831 class H323_UserInputCapability : public H323Capability
01832 {
01833   PCLASSINFO(H323_UserInputCapability, H323Capability);
01834 
01835   public:
01838     enum SubTypes {
01839       BasicString,
01840       IA5String,
01841       GeneralString,
01842       SignalToneH245,
01843       HookFlashH245,
01844       SignalToneRFC2833,
01845       NumSubTypes
01846     };
01847     static const char * const SubTypeNames[NumSubTypes];
01848 
01853     H323_UserInputCapability(
01854       SubTypes subType
01855     );
01857 
01862     virtual PObject * Clone() const;
01864 
01872     virtual MainTypes GetMainType() const;
01873 
01877     virtual unsigned  GetSubType()  const;
01878 
01881     virtual PString GetFormatName() const;
01883 
01891     virtual H323Channel * CreateChannel(
01892       H323Connection & connection,    
01893       H323Channel::Directions dir,    
01894       unsigned sessionID,             
01895       const H245_H2250LogicalChannelParameters * param
01897     ) const;
01898 
01901     virtual H323Codec * CreateCodec(
01902       H323Codec::Direction direction  
01903     ) const;
01905 
01915     virtual BOOL OnSendingPDU(
01916       H245_Capability & pdu  
01917     ) const;
01918 
01926     virtual BOOL OnSendingPDU(
01927       H245_DataType & pdu  
01928     ) const;
01929 
01938     virtual BOOL OnSendingPDU(
01939       H245_ModeElement & pdu  
01940     ) const;
01941 
01951     virtual BOOL OnReceivedPDU(
01952       const H245_Capability & pdu  
01953     );
01954 
01962     virtual BOOL OnReceivedPDU(
01963       const H245_DataType & pdu,  
01964       BOOL receiver               
01965     );
01966 
01975     virtual BOOL IsUsable(
01976       const H323Connection & connection
01977     ) const;
01979 
01980     static void AddAllCapabilities(
01981       H323Capabilities & capabilities,        
01982       PINDEX descriptorNum,   
01983       PINDEX simultaneous     
01984     );
01985 
01986   protected:
01987     SubTypes subType;
01988 };
01989 
01990 
01991 
01993 
01994 PLIST(H323CapabilitiesList, H323Capability);
01995 
01996 PARRAY(H323CapabilitiesListArray, H323CapabilitiesList);
01997 
01998 class H323SimultaneousCapabilities : public H323CapabilitiesListArray
01999 {
02000   PCLASSINFO(H323SimultaneousCapabilities, H323CapabilitiesListArray);
02001   public:
02002     BOOL SetSize(PINDEX newSize);
02003 };
02004 
02005 
02006 PARRAY(H323CapabilitiesSetArray, H323SimultaneousCapabilities);
02007 
02008 
02009 class H323CapabilitiesSet : public H323CapabilitiesSetArray
02010 {
02011   PCLASSINFO(H323CapabilitiesSet, H323CapabilitiesSetArray);
02012   public:
02014     BOOL SetSize(PINDEX newSize);
02015 };
02016 
02017 
02020 class H323Capabilities : public PObject
02021 {
02022     PCLASSINFO(H323Capabilities, PObject);
02023   public:
02028     H323Capabilities();
02029 
02032     H323Capabilities(
02033       const H323Connection & connection,      
02034       const H245_TerminalCapabilitySet & pdu  
02035     );
02036 
02041     H323Capabilities(
02042       const H323Capabilities & original 
02043     );
02044 
02049     H323Capabilities & operator=(
02050       const H323Capabilities & original 
02051     );
02053 
02058     void PrintOn(
02059       ostream & strm    
02060     ) const;
02062 
02067     PINDEX GetSize() const { return table.GetSize(); }
02068 
02071     H323Capability & operator[](PINDEX i) const { return table[i]; }
02072 
02093     PINDEX SetCapability(
02094       PINDEX descriptorNum, 
02095       PINDEX simultaneous,  
02096       H323Capability * cap  
02097     );
02098 
02103     PINDEX AddAllCapabilities(
02104       PINDEX descriptorNum, 
02105       PINDEX simultaneous,  
02106       const PString & name  
02107     );
02108     PINDEX AddAllCapabilities(
02109       H323EndPoint &,
02110       PINDEX descriptorNum, 
02111       PINDEX simultaneous,  
02112       const PString & name  
02113     )
02114     { return AddAllCapabilities(descriptorNum, simultaneous, name); }
02115 
02124     void Add(
02125       H323Capability * capability   
02126     );
02127 
02134     H323Capability * Copy(
02135       const H323Capability & capability   
02136     );
02137 
02142     void Remove(
02143       H323Capability * capability   
02144     );
02145 
02150     void Remove(
02151       const PString & formatName   
02152     );
02153 
02157     void Remove(
02158       const PStringArray & formatNames  
02159     );
02160 
02163     void RemoveAll();
02164 
02172     H323Capability * FindCapability(
02173       unsigned capabilityNumber
02174     ) const;
02175 
02191     H323Capability * FindCapability(
02192       const PString & formatName, 
02193       H323Capability::CapabilityDirection direction = H323Capability::e_Unknown
02195     ) const;
02196 
02202     H323Capability * FindCapability(
02203       H323Capability::CapabilityDirection direction 
02204     ) const;
02205 
02213     H323Capability * FindCapability(
02214       const H323Capability & capability 
02215     ) const;
02216 
02222     H323Capability * FindCapability(
02223       const H245_Capability & cap  
02224     ) const;
02225 
02231     H323Capability * FindCapability(
02232       const H245_DataType & dataType  
02233     ) const;
02234 
02240     H323Capability * FindCapability(
02241       const H245_ModeElement & modeElement  
02242     ) const;
02243 
02249     H323Capability * FindCapability(
02250       H323Capability::MainTypes mainType, 
02251       const PASN_Choice & subTypePDU,     
02252       const unsigned * translationTable   
02253     ) const;
02254 
02260     H323Capability * FindCapability(
02261       H323Capability::MainTypes mainType, 
02262       unsigned subType = UINT_MAX         
02263     ) const;
02264 
02267     void BuildPDU(
02268       const H323Connection & connection,  
02269       H245_TerminalCapabilitySet & pdu    
02270     ) const;
02271 
02274     BOOL Merge(
02275       const H323Capabilities & newCaps
02276     );
02277 
02284     void Reorder(
02285       const PStringArray & preferenceOrder  
02286     );
02287 
02290     BOOL IsAllowed(
02291       const H323Capability & capability
02292     );
02293 
02296     BOOL IsAllowed(
02297       unsigned capabilityNumber
02298     );
02299 
02302     BOOL IsAllowed(
02303       const H323Capability & capability1,
02304       const H323Capability & capability2
02305     );
02306 
02309     BOOL IsAllowed(
02310       unsigned capabilityNumber1,
02311       unsigned capabilityNumber2
02312     );
02314 
02315   protected:
02316     H323CapabilitiesList table;
02317     H323CapabilitiesSet  set;
02318 };
02319 
02320 
02322 
02323 typedef PFactory<H323Capability, std::string> H323CapabilityFactory;
02324 
02325 #define H323_REGISTER_CAPABILITY(cls, capName)   static H323CapabilityFactory::Worker<cls> cls##Factory(capName, true); \
02326 
02327 #define H323_DEFINE_CAPABILITY(cls, capName, fmtName) \
02328 class cls : public H323Capability { \
02329   public: \
02330     cls() : H323Capability() { } \
02331     PString GetFormatName() const \
02332     { return fmtName; } \
02333 }; \
02334 H323_REGISTER_CAPABILITY(cls, capName) \
02335 
02336 #define H323_DEFINE_CAPABILITY_FROM(cls, ancestor, capName, fmtName) \
02337 class cls : public ancestor { \
02338   public: \
02339     cls() : ancestor() { } \
02340     PString GetFormatName() const \
02341     { return fmtName; } \
02342 }; \
02343 H323_REGISTER_CAPABILITY(cls, capName) \
02344 
02345 #endif // __OPAL_H323CAPS_H
02346 
02347 

Generated on Wed Feb 6 09:02:38 2008 for OpenH323 by  doxygen 1.5.4