# 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  * $Revision: 29635 $
    00030  * $Author: rjongbloed $
    00031  * $Date: 2013-05-02 12:58:06 -0500 (Thu, 02 May 2013) $
    00032  */
    00033
    00034 #ifndef OPAL_H323_H323CAPS_H
    00035 #define OPAL_H323_H323CAPS_H
    00036
    00037 #ifdef P_USE_PRAGMA
    00038 #pragma interface
    00039 #endif
    00040
    00041 #include <opal/buildopts.h>
    00042
    00043 #if OPAL_H323
    00044
    00045 #include <opal/mediafmt.h>
    00046 #include <h323/channels.h>
    00047
    00048
    00049 /* The following classes have forward references to avoid including the VERY
    00050    large header files for H225 and H245. If an application requires access
    00051    to the protocol classes they can include them, but for simple usage their
    00052    inclusion can be avoided.
    00053  */
    00054 class PASN_Choice;
    00055 class H245_Capability;
    00056 class H245_DataType;
    00057 class H245_ModeElement;
    00058 class H245_AudioCapability;
    00059 class H245_AudioMode;
    00060 class H245_VideoCapability;
    00061 class H245_VideoMode;
    00062 class H245_DataApplicationCapability;
    00063 class H245_DataMode;
    00064 class H245_DataProtocolCapability;
    00065 class H245_H2250LogicalChannelParameters;
    00066 class H245_TerminalCapabilitySet;
    00067 class H245_NonStandardParameter;
    00068 class H323Connection;
    00069 class H323Capabilities;
    00070 class H245_CapabilityIdentifier;
    00071 class H245_GenericCapability;
    00072 class H245_GenericParameter;
    00073
    00074
    00075 #if OPAL_H239
    00076   const OpalMediaFormat & GetH239VideoMediaFormat();
    00077 #endif
    00078
    00079
    00081
    00095 class H323Capability : public PObject
    00096 {
    00097   PCLASSINFO(H323Capability, PObject);
    00098
    00099   public:
    00104     H323Capability();
    00106
    00112     Comparison Compare(const PObject & obj) const;
    00113
    00116     void PrintOn(ostream & strm) const;
    00118
    00121     enum MainTypes {
    00123       e_Audio,
    00125       e_Video,
    00127       e_Data,
    00129       e_UserInput,
    00131       e_GenericControl,
    00133       e_NumMainTypes
    00134     };
    00135
    00141     virtual MainTypes GetMainType() const = 0;
    00142
    00146     virtual unsigned  GetSubType()  const = 0;
    00147
    00150     virtual PString GetFormatName() const = 0;
    00152
    00158     static H323Capability * Create(
    00159       const PString & name
    00160     );
    00161
    00162     enum {
    00163       DefaultAudioSessionID = 1,
    00164       DefaultVideoSessionID = 2,
    00165       DefaultDataSessionID  = 3,
    00166       DefaultH224SessionID  = 4
    00167     };
    00168
    00177     virtual unsigned GetDefaultSessionID() const;
    00178
    00187     virtual void SetTxFramesInPacket(
    00188       unsigned frames
    00189     );
    00190
    00195     virtual unsigned GetTxFramesInPacket() const;
    00196
    00201     virtual unsigned GetRxFramesInPacket() const;
    00202
    00208     virtual H323Channel * CreateChannel(
    00209       H323Connection & connection,
    00210       H323Channel::Directions dir,
    00211       unsigned sessionID,
    00212       const H245_H2250LogicalChannelParameters * param
    00214     ) const = 0;
    00216
    00219     enum CommandType {
    00220       e_TCS,
    00221       e_OLC,
    00222       e_ReqMode
    00223     };
    00224
    00232     virtual PBoolean OnSendingPDU(
    00233       H245_Capability & pdu
    00234     ) const = 0;
    00235
    00243     virtual PBoolean OnSendingPDU(
    00244       H245_DataType & pdu
    00245     ) const;
    00246
    00254     virtual PBoolean OnSendingPDU(
    00255       H245_ModeElement & pdu
    00256     ) const = 0;
    00257
    00270     virtual PBoolean OnReceivedPDU(
    00271       const H245_Capability & pdu
    00272     );
    00273
    00281     virtual PBoolean OnReceivedPDU(
    00282       const H245_DataType & pdu,
    00283       PBoolean receiver
    00284     );
    00285
    00288     virtual PBoolean IsMatch(
    00289       const PASN_Choice & subTypePDU,
    00290       const PString & mediaPacketization
    00291     ) const;
    00292
    00300     virtual PBoolean IsUsable(
    00301       const H323Connection & connection
    00302     ) const;
    00304
    00307     enum CapabilityDirection {
    00308       e_Unknown,
    00309       e_Receive,
    00310       e_Transmit,
    00311       e_ReceiveAndTransmit,
    00312       e_NoDirection,
    00313       NumCapabilityDirections
    00314     };
    00315
    00318     CapabilityDirection GetCapabilityDirection() const { return capabilityDirection; }
    00319
    00322     void SetCapabilityDirection(
    00323       CapabilityDirection dir
    00324     ) { capabilityDirection = dir; }
    00325
    00327     unsigned GetCapabilityNumber() const { return assignedCapabilityNumber; }
    00328
    00330     void SetCapabilityNumber(unsigned num) { assignedCapabilityNumber = num; }
    00331
    00334     OpalMediaFormat GetMediaFormat() const;
    00335
    00338     bool UpdateMediaFormat(
    00339       const OpalMediaFormat & format
    00340     );
    00341
    00343     RTP_DataFrame::PayloadTypes GetPayloadType() const { return GetMediaFormat().GetPayloadType(); }
    00344
    00346     void SetPayloadType(RTP_DataFrame::PayloadTypes pt) { GetWritableMediaFormat().SetPayloadType(pt); }
    00348
    00349 #if PTRACING
    00350     friend ostream & operator<<(ostream & o , MainTypes t);
    00351     friend ostream & operator<<(ostream & o , CapabilityDirection d);
    00352 #endif
    00353
    00354   protected:
    00355     OpalMediaFormat & GetWritableMediaFormat() const;
    00356
    00357     unsigned            assignedCapabilityNumber;
    00358     CapabilityDirection capabilityDirection;
    00359
    00360     mutable OpalMediaFormat m_mediaFormat;
    00361
    00362   private:
    00363     P_REMOVE_VIRTUAL(PBoolean, IsMatch(const PASN_Choice &) const, false);
    00364
    00365   friend class H323Capabilities;
    00366 };
    00367
    00368
    00369
    00378 class H323NonStandardCapabilityInfo
    00379 {
    00380   public:
    00381     typedef PObject::Comparison (*CompareFuncType)(struct PluginCodec_H323NonStandardCodecData *);
    00382
    00385     H323NonStandardCapabilityInfo(
    00386       CompareFuncType compareFunc,
    00387       const BYTE * dataBlock,
    00388       PINDEX dataSize
    00389     );
    00390
    00393     H323NonStandardCapabilityInfo(
    00394       const BYTE * dataBlock,
    00395       PINDEX dataSize,
    00396       PINDEX comparisonOffset = 0,
    00397       PINDEX comparisonLength = P_MAX_INDEX
    00398     );
    00399
    00402     H323NonStandardCapabilityInfo(
    00403       const PString & oid,
    00404       const BYTE * dataBlock,
    00405       PINDEX dataSize,
    00406       PINDEX comparisonOffset = 0,
    00407       PINDEX comparisonLength = P_MAX_INDEX
    00408     );
    00409
    00412     H323NonStandardCapabilityInfo(
    00413       BYTE country,
    00414       BYTE extension,
    00415       WORD maufacturer,
    00416       const BYTE * dataBlock,
    00417       PINDEX dataSize,
    00418       PINDEX comparisonOffset = 0,
    00419       PINDEX comparisonLength = P_MAX_INDEX
    00420     );
    00421
    00424     virtual ~H323NonStandardCapabilityInfo();
    00425
    00430     virtual PBoolean OnSendingPDU(
    00431       PBYTEArray & data
    00432     ) const;
    00433
    00438     virtual PBoolean OnReceivedPDU(
    00439       const PBYTEArray & data
    00440     );
    00441
    00442     PBoolean IsMatch(const H245_NonStandardParameter & param) const;
    00443
    00444     PObject::Comparison CompareParam(
    00445       const H245_NonStandardParameter & param
    00446     ) const;
    00447
    00448   protected:
    00449     PBoolean OnSendingNonStandardPDU(
    00450       PASN_Choice & pdu,
    00451       unsigned nonStandardTag
    00452     ) const;
    00453     PBoolean OnReceivedNonStandardPDU(
    00454       const PASN_Choice & pdu,
    00455       unsigned nonStandardTag
    00456     );
    00457
    00458     PObject::Comparison CompareInfo(
    00459       const H323NonStandardCapabilityInfo & obj
    00460     ) const;
    00461     PObject::Comparison CompareData(
    00462       const PBYTEArray & data
    00463     ) const;
    00464
    00465     PString    oid;
    00466     BYTE       t35CountryCode;
    00467     BYTE       t35Extension;
    00468     WORD       manufacturerCode;
    00469     PBYTEArray nonStandardData;
    00470     PINDEX     comparisonOffset;
    00471     PINDEX     comparisonLength;
    00472     CompareFuncType compareFunc;
    00473 };
    00474
    00484 class H323GenericCapabilityInfo
    00485 {
    00486   public:
    00487     H323GenericCapabilityInfo(
    00488       const PString & id,
    00489       unsigned maxBitRate = 0
    00490     );
    00491
    00492     virtual ~H323GenericCapabilityInfo() { }
    00493
    00494   protected:
    00495     virtual PBoolean OnSendingGenericPDU(
    00496       H245_GenericCapability & pdu,
    00497       const OpalMediaFormat & mediaFormat,
    00498       H323Capability::CommandType type
    00499     ) const;
    00500     virtual PBoolean OnReceivedGenericPDU(
    00501       OpalMediaFormat & mediaFormat,
    00502       const H245_GenericCapability & pdu,
    00503       H323Capability::CommandType type
    00504     );
    00505
    00506     PBoolean IsMatch(
    00507       const OpalMediaFormat & mediaFormat,
    00508       const H245_GenericCapability & param
    00509     ) const;
    00510     PObject::Comparison CompareInfo(
    00511       const H323GenericCapabilityInfo & obj
    00512     ) const;
    00513
    00514
    00515     PString  m_identifier;
    00516     unsigned m_maxBitRate;
    00517 };
    00518
    00525 class H323RealTimeCapability : public H323Capability
    00526 {
    00527   PCLASSINFO(H323RealTimeCapability, H323Capability);
    00528
    00529   public:
    00534     virtual H323Channel * CreateChannel(
    00535       H323Connection & connection,
    00536       H323Channel::Directions dir,
    00537       unsigned sessionID,
    00538       const H245_H2250LogicalChannelParameters * param
    00540     ) const;
    00541
    00542     H323RealTimeCapability();
    00543     H323RealTimeCapability(const H323RealTimeCapability &rtc);
    00544     virtual ~H323RealTimeCapability();
    00546 };
    00547
    00548
    00555 class H323AudioCapability : public H323RealTimeCapability
    00556 {
    00557   PCLASSINFO(H323AudioCapability, H323RealTimeCapability);
    00558
    00559   public:
    00564     H323AudioCapability();
    00566
    00572     virtual MainTypes GetMainType() const;
    00574
    00585     virtual unsigned GetDefaultSessionID() const;
    00586
    00595     virtual void SetTxFramesInPacket(
    00596       unsigned frames
    00597     );
    00598
    00604     virtual unsigned GetTxFramesInPacket() const;
    00605
    00611     virtual unsigned GetRxFramesInPacket() const;
    00613
    00624     virtual PBoolean OnSendingPDU(
    00625       H245_Capability & pdu
    00626     ) const;
    00627
    00636     virtual PBoolean OnSendingPDU(
    00637       H245_DataType & pdu
    00638     ) const;
    00639
    00648     virtual PBoolean OnSendingPDU(
    00649       H245_ModeElement & pdu
    00650     ) const;
    00651
    00660     virtual PBoolean OnSendingPDU(
    00661       H245_AudioCapability & pdu,
    00662       unsigned packetSize
    00663     ) const;
    00664     virtual PBoolean OnSendingPDU(
    00665       H245_AudioCapability & pdu,
    00666       unsigned packetSize,
    00667       CommandType type
    00668     ) const;
    00669
    00678     virtual PBoolean OnSendingPDU(
    00679       H245_AudioMode & pdu
    00680     ) const;
    00681
    00693     virtual PBoolean OnReceivedPDU(
    00694       const H245_Capability & pdu
    00695     );
    00696
    00706     virtual PBoolean OnReceivedPDU(
    00707       const H245_DataType & pdu,
    00708       PBoolean receiver
    00709     );
    00710
    00719     virtual PBoolean OnReceivedPDU(
    00720       const H245_AudioCapability & pdu,
    00721       unsigned & packetSize
    00722     );
    00723     virtual PBoolean OnReceivedPDU(
    00724       const H245_AudioCapability & pdu,
    00725       unsigned & packetSize,
    00726       CommandType type
    00727     );
    00729 };
    00730
    00731
    00739 class H323NonStandardAudioCapability : public H323AudioCapability,
    00740                                        public H323NonStandardCapabilityInfo
    00741 {
    00742   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
    00743
    00744   public:
    00747     H323NonStandardAudioCapability(
    00748       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
    00749       const BYTE * dataBlock,
    00750       PINDEX dataSize
    00751     );
    00754     H323NonStandardAudioCapability(
    00755       const BYTE * dataBlock = NULL,
    00756       PINDEX dataSize = 0,
    00757       PINDEX comparisonOffset = 0,
    00758       PINDEX comparisonLength = P_MAX_INDEX
    00759      );
    00760
    00763     H323NonStandardAudioCapability(
    00764       const PString & oid,
    00765       const BYTE * dataBlock = NULL,
    00766       PINDEX dataSize = 0,
    00767       PINDEX comparisonOffset = 0,
    00768       PINDEX comparisonLength = P_MAX_INDEX
    00769     );
    00770
    00773     H323NonStandardAudioCapability(
    00774       BYTE country,
    00775       BYTE extension,
    00776       WORD maufacturer,
    00777       const BYTE * dataBlock = NULL,
    00778       PINDEX dataSize = 0,
    00779       PINDEX comparisonOffset = 0,
    00780       PINDEX comparisonLength = P_MAX_INDEX
    00781     );
    00783
    00789     Comparison Compare(const PObject & obj) const;
    00791
    00799     virtual unsigned GetSubType() const;
    00801
    00812     virtual PBoolean OnSendingPDU(
    00813       H245_AudioCapability & pdu,
    00814       unsigned packetSize
    00815     ) const;
    00816
    00825     virtual PBoolean OnSendingPDU(
    00826       H245_AudioMode & pdu
    00827     ) const;
    00828
    00837     virtual PBoolean OnReceivedPDU(
    00838       const H245_AudioCapability & pdu,
    00839       unsigned & packetSize
    00840     );
    00841
    00844     virtual PBoolean IsMatch(
    00845       const PASN_Choice & subTypePDU,
    00846       const PString & mediaPacketization
    00847     ) const;
    00849 };
    00850
    00858 class H323GenericAudioCapability : public H323AudioCapability,
    00859                                    public H323GenericCapabilityInfo
    00860 {
    00861   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
    00862
    00863   public:
    00868     H323GenericAudioCapability(
    00869       const PString & capabilityId,
    00870       unsigned fixedBitRate
    00871     );
    00873
    00879     Comparison Compare(const PObject & obj) const;
    00881
    00889     virtual unsigned GetSubType() const;
    00891
    00902     virtual PBoolean OnSendingPDU(
    00903       H245_AudioCapability & pdu,
    00904       unsigned packetSize,
    00905       CommandType type
    00906     ) const;
    00907
    00916     virtual PBoolean OnSendingPDU(
    00917       H245_AudioMode & pdu
    00918     ) const;
    00919
    00928     virtual PBoolean OnReceivedPDU(
    00929       const H245_AudioCapability & pdu,
    00930       unsigned & packetSize,
    00931       CommandType type
    00932     );
    00933
    00936     virtual PBoolean IsMatch(
    00937       const PASN_Choice & subTypePDU,
    00938       const PString & mediaPacketization
    00939     ) const;
    00941
    00942   protected:
    00943     bool m_fixedBitRate;
    00944 };
    00945
    00946
    00947 template <const char * oid, const OpalAudioFormat & fmtFunc(), unsigned fixedBitRate = 0>
    00948 class H323GenericAudioCapabilityTemplate : public H323GenericAudioCapability
    00949 {
    00950   public:
    00951     H323GenericAudioCapabilityTemplate()
    00952       : H323GenericAudioCapability(oid, fixedBitRate)
    00953     {
    00954     }
    00955
    00956     virtual PObject * Clone() const
    00957     {
    00958       return new H323GenericAudioCapabilityTemplate(*this);
    00959     }
    00960
    00961     virtual PString GetFormatName() const
    00962     {
    00963       return fmtFunc();
    00964     }
    00965 };
    00966
    00967
    00968 #if OPAL_VIDEO
    00969
    00976 class H323VideoCapability : public H323RealTimeCapability
    00977 {
    00978   PCLASSINFO(H323VideoCapability, H323RealTimeCapability);
    00979
    00980   public:
    00986     virtual MainTypes GetMainType() const;
    00988
    00999     virtual unsigned GetDefaultSessionID() const;
    01001
    01012     virtual PBoolean OnSendingPDU(
    01013       H245_Capability & pdu
    01014     ) const;
    01015
    01024     virtual PBoolean OnSendingPDU(
    01025       H245_DataType & pdu
    01026     ) const;
    01027
    01036     virtual PBoolean OnSendingPDU(
    01037       H245_ModeElement & pdu
    01038     ) const;
    01039
    01047     virtual PBoolean OnSendingPDU(
    01048       H245_VideoCapability & pdu
    01049     ) const;
    01050     virtual PBoolean OnSendingPDU(
    01051       H245_VideoCapability & pdu,
    01052       CommandType type
    01053     ) const;
    01054
    01063     virtual PBoolean OnSendingPDU(
    01064       H245_VideoMode & pdu
    01065     ) const;
    01066
    01076     virtual PBoolean OnReceivedPDU(
    01077       const H245_Capability & pdu
    01078     );
    01079
    01087     virtual PBoolean OnReceivedPDU(
    01088       const H245_DataType & pdu,
    01089       PBoolean receiver
    01090     );
    01091
    01099     virtual PBoolean OnReceivedPDU(
    01100       const H245_VideoCapability & pdu
    01101     );
    01102     virtual PBoolean OnReceivedPDU(
    01103       const H245_VideoCapability & pdu,
    01104       CommandType type
    01105     );
    01107 };
    01108
    01109
    01117 class H323NonStandardVideoCapability : public H323VideoCapability,
    01118                                        public H323NonStandardCapabilityInfo
    01119 {
    01120   PCLASSINFO(H323NonStandardVideoCapability, H323VideoCapability);
    01121
    01122   public:
    01125     H323NonStandardVideoCapability(
    01126       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
    01127       const BYTE * dataBlock,
    01128       PINDEX dataSize
    01129     );
    01132     H323NonStandardVideoCapability(
    01133       const BYTE * dataBlock = NULL,
    01134       PINDEX dataSize = 0,
    01135       PINDEX comparisonOffset = 0,
    01136       PINDEX comparisonLength = P_MAX_INDEX
    01137     );
    01138
    01141     H323NonStandardVideoCapability(
    01142       const PString & oid,
    01143       const BYTE * dataBlock = NULL,
    01144       PINDEX dataSize = 0,
    01145       PINDEX comparisonOffset = 0,
    01146       PINDEX comparisonLength = P_MAX_INDEX
    01147     );
    01148
    01151     H323NonStandardVideoCapability(
    01152       BYTE country,
    01153       BYTE extension,
    01154       WORD maufacturer,
    01155       const BYTE * dataBlock = NULL,
    01156       PINDEX dataSize = 0,
    01157       PINDEX comparisonOffset = 0,
    01158       PINDEX comparisonLength = P_MAX_INDEX
    01159     );
    01161
    01167     Comparison Compare(const PObject & obj) const;
    01169
    01178     virtual unsigned GetSubType() const;
    01180
    01191     virtual PBoolean OnSendingPDU(
    01192       H245_VideoCapability & pdu
    01193     ) const;
    01194
    01203     virtual PBoolean OnSendingPDU(
    01204       H245_VideoMode & pdu
    01205     ) const;
    01206
    01215     virtual PBoolean OnReceivedPDU(
    01216       const H245_VideoCapability & pdu
    01217     );
    01218
    01221     virtual PBoolean IsMatch(
    01222       const PASN_Choice & subTypePDU,
    01223       const PString & mediaPacketization
    01224     ) const;
    01226 };
    01227
    01235 class H323GenericVideoCapability : public H323VideoCapability,
    01236                                    public H323GenericCapabilityInfo
    01237 {
    01238   PCLASSINFO(H323GenericVideoCapability, H323VideoCapability);
    01239
    01240   public:
    01245     H323GenericVideoCapability(
    01246       const PString & capabilityId,
    01247       PINDEX maxBitRate = 0
    01248     );
    01250
    01256     Comparison Compare(const PObject & obj) const;
    01258
    01266     virtual unsigned GetSubType() const;
    01268
    01279     virtual PBoolean OnSendingPDU(
    01280       H245_VideoCapability & pdu,
    01281       CommandType type
    01282     ) const;
    01283
    01292     virtual PBoolean OnSendingPDU(
    01293       H245_VideoMode & pdu
    01294     ) const;
    01295
    01304     virtual PBoolean OnReceivedPDU(
    01305       const H245_VideoCapability & pdu,
    01306       CommandType type
    01307     );
    01308
    01311     virtual PBoolean IsMatch(
    01312       const PASN_Choice & subTypePDU,
    01313       const PString & mediaPacketization
    01314     ) const;
    01316 };
    01317
    01318
    01319 template <const char * oid, const OpalVideoFormat & fmtFunc()>
    01320 class H323GenericVideoCapabilityTemplate : public H323GenericVideoCapability
    01321 {
    01322   public:
    01323     H323GenericVideoCapabilityTemplate()
    01324       : H323GenericVideoCapability(oid)
    01325     {
    01326     }
    01327
    01328     virtual PObject * Clone() const
    01329     {
    01330       return new H323GenericVideoCapabilityTemplate(*this);
    01331     }
    01332
    01333     virtual PString GetFormatName() const
    01334     {
    01335       return fmtFunc();
    01336     }
    01337 };
    01338
    01339
    01340 #if OPAL_H239
    01341
    01344 class H323ExtendedVideoCapability : public H323GenericVideoCapability
    01345 {
    01346   PCLASSINFO(H323ExtendedVideoCapability, H323GenericVideoCapability);
    01347
    01348   public:
    01353     H323ExtendedVideoCapability(
    01354       const PString & identifier
    01355     );
    01357
    01365     virtual unsigned GetSubType() const;
    01367
    01378     virtual PBoolean OnSendingPDU(
    01379       H245_VideoCapability & pdu,
    01380       CommandType type
    01381     ) const;
    01382
    01391     virtual PBoolean OnSendingPDU(
    01392       H245_VideoMode & pdu
    01393     ) const;
    01394
    01403     virtual PBoolean OnReceivedPDU(
    01404       const H245_VideoCapability & pdu,
    01405       CommandType type
    01406     );
    01407
    01410     virtual PBoolean IsMatch(
    01411       const PASN_Choice & subTypePDU,
    01412       const PString & mediaPacketization
    01413     ) const;
    01415
    01416   protected:
    01417     OpalMediaFormatList m_videoFormats;
    01418 };
    01419
    01420
    01422
    01425 class H323GenericControlCapability : public H323Capability,
    01426                                      public H323GenericCapabilityInfo
    01427 {
    01428   PCLASSINFO(H323GenericControlCapability, H323Capability);
    01429
    01430   public:
    01435     H323GenericControlCapability(
    01436       const PString & identifier
    01437     );
    01439
    01445     virtual MainTypes GetMainType() const;
    01446
    01452     virtual unsigned GetSubType() const;
    01454
    01465     virtual PBoolean OnSendingPDU(
    01466       H245_Capability & pdu
    01467     ) const;
    01468
    01476     virtual PBoolean OnSendingPDU(
    01477       H245_ModeElement & pdu
    01478     ) const;
    01479
    01489     virtual PBoolean OnReceivedPDU(
    01490       const H245_Capability & pdu
    01491     );
    01492
    01495     virtual PBoolean IsMatch(
    01496       const PASN_Choice & subTypePDU,
    01497       const PString & mediaPacketization
    01498     ) const;
    01500
    01508     virtual H323Channel * CreateChannel(
    01509       H323Connection & connection,
    01510       H323Channel::Directions dir,
    01511       unsigned sessionID,
    01512       const H245_H2250LogicalChannelParameters * param
    01514     ) const;
    01516 };
    01517
    01518
    01520
    01521 class H323H239VideoCapability : public H323ExtendedVideoCapability
    01522 {
    01523   PCLASSINFO(H323H239VideoCapability, H323ExtendedVideoCapability);
    01524
    01525   public:
    01530     H323H239VideoCapability(
    01531       const OpalMediaFormat & videoFormat
    01532     );
    01534
    01540     Comparison Compare(const PObject & obj) const;
    01541
    01544     virtual PObject * Clone() const;
    01546
    01551     virtual PString GetFormatName() const;
    01553
    01564     virtual PBoolean OnSendingPDU(
    01565       H245_VideoCapability & pdu,
    01566       CommandType type
    01567     ) const;
    01568
    01577     virtual PBoolean OnReceivedPDU(
    01578       const H245_VideoCapability & pdu,
    01579       CommandType type
    01580     );
    01582 };
    01583
    01584
    01586
    01587 class H323H239ControlCapability : public H323GenericControlCapability
    01588 {
    01589   PCLASSINFO(H323H239ControlCapability, H323GenericControlCapability);
    01590
    01591   public:
    01596     H323H239ControlCapability();
    01598
    01603     virtual PObject * Clone() const;
    01605
    01610     virtual PString GetFormatName() const;
    01612 };
    01613
    01614
    01615 #endif  // OPAL_H239
    01616
    01617 #endif  // OPAL_VIDEO
    01618
    01619
    01626 class H323DataCapability : public H323Capability
    01627 {
    01628   PCLASSINFO(H323DataCapability, H323Capability);
    01629
    01630   public:
    01635     H323DataCapability(
    01636       unsigned maxBitRate = 0
    01637     );
    01639
    01645     virtual MainTypes GetMainType() const;
    01647
    01657     virtual unsigned GetDefaultSessionID() const;
    01659
    01670     virtual PBoolean OnSendingPDU(
    01671       H245_Capability & pdu
    01672     ) const;
    01673
    01682     virtual PBoolean OnSendingPDU(
    01683       H245_DataType & pdu
    01684     ) const;
    01685
    01694     virtual PBoolean OnSendingPDU(
    01695       H245_ModeElement & pdu
    01696     ) const;
    01697
    01705     virtual PBoolean OnSendingPDU(
    01706       H245_DataApplicationCapability & pdu
    01707     ) const;
    01708     virtual PBoolean OnSendingPDU(
    01709       H245_DataApplicationCapability & pdu,
    01710       CommandType type
    01711     ) const;
    01712
    01721     virtual PBoolean OnSendingPDU(
    01722       H245_DataMode & pdu
    01723     ) const = 0;
    01724
    01734     virtual PBoolean OnReceivedPDU(
    01735       const H245_Capability & pdu
    01736     );
    01737
    01745     virtual PBoolean OnReceivedPDU(
    01746       const H245_DataType & pdu,
    01747       PBoolean receiver
    01748     );
    01749
    01757     virtual PBoolean OnReceivedPDU(
    01758       const H245_DataApplicationCapability & pdu
    01759     );
    01760     virtual PBoolean OnReceivedPDU(
    01761       const H245_DataApplicationCapability & pdu,
    01762       CommandType type
    01763     );
    01765
    01766   protected:
    01767     unsigned maxBitRate;
    01768 };
    01769
    01770
    01778 class H323NonStandardDataCapability : public H323DataCapability,
    01779                                       public H323NonStandardCapabilityInfo
    01780 {
    01781   PCLASSINFO(H323NonStandardDataCapability, H323DataCapability);
    01782
    01783   public:
    01788     H323NonStandardDataCapability(
    01789       unsigned maxBitRate,
    01790       const BYTE * dataBlock = NULL,
    01791       PINDEX dataSize = 0,
    01792       PINDEX comparisonOffset = 0,
    01793       PINDEX comparisonLength = P_MAX_INDEX
    01794     );
    01795
    01798     H323NonStandardDataCapability(
    01799       unsigned maxBitRate,
    01800       const PString & oid,
    01801       const BYTE * dataBlock = NULL,
    01802       PINDEX dataSize = 0,
    01803       PINDEX comparisonOffset = 0,
    01804       PINDEX comparisonLength = P_MAX_INDEX
    01805     );
    01806
    01809     H323NonStandardDataCapability(
    01810       unsigned maxBitRate,
    01811       BYTE country,
    01812       BYTE extension,
    01813       WORD maufacturer,
    01814       const BYTE * dataBlock = NULL,
    01815       PINDEX dataSize = 0,
    01816       PINDEX comparisonOffset = 0,
    01817       PINDEX comparisonLength = P_MAX_INDEX
    01818     );
    01820
    01826     Comparison Compare(const PObject & obj) const;
    01828
    01837     virtual unsigned GetSubType() const;
    01839
    01850     virtual PBoolean OnSendingPDU(
    01851       H245_DataApplicationCapability & pdu
    01852     ) const;
    01853
    01862     virtual PBoolean OnSendingPDU(
    01863       H245_DataMode & pdu
    01864     ) const;
    01865
    01874     virtual PBoolean OnReceivedPDU(
    01875       const H245_DataApplicationCapability & pdu
    01876     );
    01877
    01880     virtual PBoolean IsMatch(
    01881       const PASN_Choice & subTypePDU,
    01882       const PString & mediaPacketization
    01883     ) const;
    01885 };
    01886
    01887
    01889 // Known audio codecs
    01890
    01893 class H323_G711Capability : public H323AudioCapability
    01894 {
    01895   PCLASSINFO(H323_G711Capability, H323AudioCapability)
    01896
    01897   public:
    01899     enum Mode {
    01901       ALaw,
    01903       muLaw
    01904     };
    01906     enum Speed {
    01908       At64k,
    01910       At56k
    01911     };
    01912
    01917     H323_G711Capability(
    01918       Mode mode = muLaw,
    01919       Speed speed = At64k
    01920     );
    01922
    01927     virtual PObject * Clone() const;
    01929
    01938     virtual unsigned GetSubType() const;
    01939
    01942     virtual PString GetFormatName() const;
    01944
    01945   protected:
    01946     Mode     mode;
    01947     Speed    speed;
    01948 };
    01949
    01951
    01954 class H323_UserInputCapability : public H323Capability
    01955 {
    01956   PCLASSINFO(H323_UserInputCapability, H323Capability);
    01957
    01958   public:
    01961     enum SubTypes {
    01962       BasicString,
    01963       IA5String,
    01964       GeneralString,
    01965       SignalToneH245,
    01966       HookFlashH245,
    01967       SignalToneRFC2833,
    01968       NumSubTypes
    01969     };
    01970     static const char * GetSubTypeName(SubTypes subType);
    01971     friend ostream & operator<<(ostream & strm, SubTypes subType) { return strm << GetSubTypeName(subType); }
    01972
    01977     H323_UserInputCapability(
    01978       SubTypes subType
    01979     );
    01981
    01986     virtual PObject * Clone() const;
    01988
    01996     virtual MainTypes GetMainType() const;
    01997
    02001     virtual unsigned  GetSubType()  const;
    02002
    02005     virtual PString GetFormatName() const;
    02007
    02015     virtual H323Channel * CreateChannel(
    02016       H323Connection & connection,
    02017       H323Channel::Directions dir,
    02018       unsigned sessionID,
    02019       const H245_H2250LogicalChannelParameters * param
    02021     ) const;
    02023
    02033     virtual PBoolean OnSendingPDU(
    02034       H245_Capability & pdu
    02035     ) const;
    02036
    02044     virtual PBoolean OnSendingPDU(
    02045       H245_DataType & pdu
    02046     ) const;
    02047
    02056     virtual PBoolean OnSendingPDU(
    02057       H245_ModeElement & pdu
    02058     ) const;
    02059
    02069     virtual PBoolean OnReceivedPDU(
    02070       const H245_Capability & pdu
    02071     );
    02072
    02080     virtual PBoolean OnReceivedPDU(
    02081       const H245_DataType & pdu,
    02082       PBoolean receiver
    02083     );
    02084
    02093     virtual PBoolean IsUsable(
    02094       const H323Connection & connection
    02095     ) const;
    02097
    02098     static void AddAllCapabilities(
    02099       H323Capabilities & capabilities,
    02100       PINDEX descriptorNum,
    02101       PINDEX simultaneous,
    02102       bool includeRFC2833 = true
    02103     );
    02104
    02105   protected:
    02106     SubTypes subType;
    02107 };
    02108
    02109
    02110
    02112
    02113 PARRAY(H323CapabilitiesList, H323Capability);
    02114
    02115 PARRAY(H323CapabilitiesListArray, H323CapabilitiesList);
    02116
    02117 class H323SimultaneousCapabilities : public H323CapabilitiesListArray
    02118 {
    02119   PCLASSINFO(H323SimultaneousCapabilities, H323CapabilitiesListArray);
    02120   public:
    02121     PBoolean SetSize(PINDEX newSize);
    02122 };
    02123
    02124
    02125 PARRAY(H323CapabilitiesSetArray, H323SimultaneousCapabilities);
    02126
    02127
    02128 class H323CapabilitiesSet : public H323CapabilitiesSetArray
    02129 {
    02130   PCLASSINFO(H323CapabilitiesSet, H323CapabilitiesSetArray);
    02131   public:
    02133     PBoolean SetSize(PINDEX newSize);
    02134 };
    02135
    02136
    02139 class H323Capabilities : public PObject
    02140 {
    02141     PCLASSINFO(H323Capabilities, PObject);
    02142   public:
    02147     H323Capabilities();
    02148
    02151     H323Capabilities(
    02152       const H323Connection & connection,
    02153       const H245_TerminalCapabilitySet & pdu
    02154     );
    02155
    02160     H323Capabilities(
    02161       const H323Capabilities & original
    02162     );
    02163
    02168     H323Capabilities & operator=(
    02169       const H323Capabilities & original
    02170     );
    02172
    02177     void PrintOn(
    02178       ostream & strm
    02179     ) const;
    02181
    02186     PINDEX GetSize() const { return table.GetSize(); }
    02187
    02190     H323Capability & operator[](PINDEX i) const { return table[i]; }
    02191
    02212     PINDEX SetCapability(
    02213       PINDEX descriptorNum,
    02214       PINDEX simultaneous,
    02215       H323Capability * cap
    02216     );
    02217
    02220     PINDEX AddMediaFormat(
    02221       PINDEX descriptorNum,
    02222       PINDEX simultaneous,
    02223       const OpalMediaFormat & mediaFormat,
    02224       H323Capability::CapabilityDirection direction =
    02225                 H323Capability::e_Receive
    02226     );
    02227
    02232     PINDEX AddAllCapabilities(
    02233       PINDEX descriptorNum,
    02234       PINDEX simultaneous,
    02235       const PString & name,
    02236       PBoolean exact = false
    02237     );
    02238
    02239     // this function is retained for backwards compatibility
    02240     PINDEX AddAllCapabilities(
    02241       const H323EndPoint &,
    02242       PINDEX descriptorNum,
    02243       PINDEX simultaneous,
    02244       const PString & name,
    02245       PBoolean exact = false
    02246     )
    02247     { return AddAllCapabilities(descriptorNum, simultaneous, name, exact); }
    02248
    02257     void Add(
    02258       H323Capability * capability
    02259     );
    02260
    02267     H323Capability * Copy(
    02268       const H323Capability & capability
    02269     );
    02270
    02275     void Remove(
    02276       H323Capability * capability
    02277     );
    02278
    02283     void Remove(
    02284       const PString & formatName
    02285     );
    02286
    02290     void Remove(
    02291       const PStringArray & formatNames
    02292     );
    02293
    02296     void RemoveAll();
    02297
    02305     H323Capability * FindCapability(
    02306       unsigned capabilityNumber
    02307     ) const;
    02308
    02324     H323Capability * FindCapability(
    02325       const PString & formatName,
    02326       H323Capability::CapabilityDirection direction = H323Capability::e_Unknown,
    02328       PBoolean exact = false
    02329     ) const;
    02330
    02336     H323Capability * FindCapability(
    02337       H323Capability::CapabilityDirection direction
    02338     ) const;
    02339
    02347     H323Capability * FindCapability(
    02348       const H323Capability & capability
    02349     ) const;
    02350
    02356     H323Capability * FindCapability(
    02357       const H245_Capability & cap
    02358     ) const;
    02359
    02365     H323Capability * FindCapability(
    02366       const H245_DataType & dataType,
    02367       const PString & mediaPacketization = PString::Empty()
    02368     ) const;
    02369
    02375     H323Capability * FindCapability(
    02376       const H245_ModeElement & modeElement,
    02377       const PString & mediaPacketization = PString::Empty()
    02378     ) const;
    02379
    02385     H323Capability * FindCapability(
    02386       H323Capability::MainTypes mainType,
    02387       unsigned subType = UINT_MAX
    02388     ) const;
    02389
    02392     void BuildPDU(
    02393       const H323Connection & connection,
    02394       H245_TerminalCapabilitySet & pdu
    02395     ) const;
    02396
    02399     PBoolean Merge(
    02400       const H323Capabilities & newCaps
    02401     );
    02402
    02409     void Reorder(
    02410       const PStringArray & preferenceOrder
    02411     );
    02412
    02415     PBoolean IsAllowed(
    02416       const H323Capability & capability
    02417     );
    02418
    02421     PBoolean IsAllowed(
    02422       unsigned capabilityNumber
    02423     );
    02424
    02427     PBoolean IsAllowed(
    02428       const H323Capability & capability1,
    02429       const H323Capability & capability2
    02430     );
    02431
    02434     PBoolean IsAllowed(
    02435       unsigned capabilityNumber1,
    02436       unsigned capabilityNumber2
    02437     );
    02438
    02441     OpalMediaFormatList GetMediaFormats() const;
    02442
    02443     const PStringSet & GetMediaPacketizations() const { return m_mediaPacketizations; }
    02445
    02446   protected:
    02447     H323CapabilitiesList table;
    02448     H323CapabilitiesSet  set;
    02449     PStringSet           m_mediaPacketizations;
    02450 };
    02451
    02452
    02454
    02455 /* New capability registration macros based on abstract factories
    02456  */
    02457 typedef PFactory<H323Capability, std::string> H323CapabilityFactory;
    02458
    02459 #define H323_REGISTER_CAPABILITY(cls, capName)   static H323CapabilityFactory::Worker<cls> cls##Factory(capName, true); \
    02460
    02461
    02462 #endif // OPAL_H323
    02463
    02464 #endif // OPAL_H323_H323CAPS_H
    02465
    02466