# 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: 27461 $
    00030  * $Author: rjongbloed $
    00031  * $Date: 2012-04-17 13:11:41 -0500 (Tue, 17 Apr 2012) $
    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
    00075
    00089 class H323Capability : public PObject
    00090 {
    00091   PCLASSINFO(H323Capability, PObject);
    00092
    00093   public:
    00098     H323Capability();
    00100
    00106     Comparison Compare(const PObject & obj) const;
    00107
    00110     void PrintOn(ostream & strm) const;
    00112
    00115     enum MainTypes {
    00117       e_Audio,
    00119       e_Video,
    00121       e_Data,
    00123       e_UserInput,
    00125       e_GenericControl,
    00127       e_NumMainTypes
    00128     };
    00129
    00135     virtual MainTypes GetMainType() const = 0;
    00136
    00140     virtual unsigned  GetSubType()  const = 0;
    00141
    00144     virtual PString GetFormatName() const = 0;
    00146
    00152     static H323Capability * Create(
    00153       const PString & name
    00154     );
    00155
    00156     enum {
    00157       DefaultAudioSessionID = 1,
    00158       DefaultVideoSessionID = 2,
    00159       DefaultDataSessionID  = 3,
    00160       DefaultH224SessionID  = 4
    00161     };
    00162
    00171     virtual unsigned GetDefaultSessionID() const;
    00172
    00181     virtual void SetTxFramesInPacket(
    00182       unsigned frames
    00183     );
    00184
    00189     virtual unsigned GetTxFramesInPacket() const;
    00190
    00195     virtual unsigned GetRxFramesInPacket() const;
    00196
    00202     virtual H323Channel * CreateChannel(
    00203       H323Connection & connection,
    00204       H323Channel::Directions dir,
    00205       unsigned sessionID,
    00206       const H245_H2250LogicalChannelParameters * param
    00208     ) const = 0;
    00210
    00213     enum CommandType {
    00214       e_TCS,
    00215       e_OLC,
    00216       e_ReqMode
    00217     };
    00218
    00226     virtual PBoolean OnSendingPDU(
    00227       H245_Capability & pdu
    00228     ) const = 0;
    00229
    00237     virtual PBoolean OnSendingPDU(
    00238       H245_DataType & pdu
    00239     ) const;
    00240
    00248     virtual PBoolean OnSendingPDU(
    00249       H245_ModeElement & pdu
    00250     ) const = 0;
    00251
    00264     virtual PBoolean OnReceivedPDU(
    00265       const H245_Capability & pdu
    00266     );
    00267
    00275     virtual PBoolean OnReceivedPDU(
    00276       const H245_DataType & pdu,
    00277       PBoolean receiver
    00278     );
    00279
    00282     virtual PBoolean IsMatch(
    00283       const PASN_Choice & subTypePDU,
    00284       const PString & mediaPacketization
    00285     ) const;
    00286
    00294     virtual PBoolean IsUsable(
    00295       const H323Connection & connection
    00296     ) const;
    00298
    00301     enum CapabilityDirection {
    00302       e_Unknown,
    00303       e_Receive,
    00304       e_Transmit,
    00305       e_ReceiveAndTransmit,
    00306       e_NoDirection,
    00307       NumCapabilityDirections
    00308     };
    00309
    00312     CapabilityDirection GetCapabilityDirection() const { return capabilityDirection; }
    00313
    00316     void SetCapabilityDirection(
    00317       CapabilityDirection dir
    00318     ) { capabilityDirection = dir; }
    00319
    00321     unsigned GetCapabilityNumber() const { return assignedCapabilityNumber; }
    00322
    00324     void SetCapabilityNumber(unsigned num) { assignedCapabilityNumber = num; }
    00325
    00328     OpalMediaFormat GetMediaFormat() const;
    00329
    00332     bool UpdateMediaFormat(
    00333       const OpalMediaFormat & format
    00334     );
    00335
    00337     RTP_DataFrame::PayloadTypes GetPayloadType() const { return GetMediaFormat().GetPayloadType(); }
    00338
    00340     void SetPayloadType(RTP_DataFrame::PayloadTypes pt) { GetWritableMediaFormat().SetPayloadType(pt); }
    00341
    00343     virtual void AttachQoS(RTP_QOS *) { }
    00345
    00346 #if PTRACING
    00347     friend ostream & operator<<(ostream & o , MainTypes t);
    00348     friend ostream & operator<<(ostream & o , CapabilityDirection d);
    00349 #endif
    00350
    00351   protected:
    00352     OpalMediaFormat & GetWritableMediaFormat() const;
    00353
    00354     unsigned            assignedCapabilityNumber;
    00355     CapabilityDirection capabilityDirection;
    00356
    00357   private:
    00358     mutable OpalMediaFormat m_mediaFormat;
    00359     P_REMOVE_VIRTUAL(PBoolean, IsMatch(const PASN_Choice &) const, false);
    00360
    00361   friend class H323Capabilities;
    00362 };
    00363
    00364
    00365
    00374 class H323NonStandardCapabilityInfo
    00375 {
    00376   public:
    00377     typedef PObject::Comparison (*CompareFuncType)(struct PluginCodec_H323NonStandardCodecData *);
    00378
    00381     H323NonStandardCapabilityInfo(
    00382       CompareFuncType compareFunc,
    00383       const BYTE * dataBlock,
    00384       PINDEX dataSize
    00385     );
    00386
    00389     H323NonStandardCapabilityInfo(
    00390       const BYTE * dataBlock,
    00391       PINDEX dataSize,
    00392       PINDEX comparisonOffset = 0,
    00393       PINDEX comparisonLength = P_MAX_INDEX
    00394     );
    00395
    00398     H323NonStandardCapabilityInfo(
    00399       const PString & oid,
    00400       const BYTE * dataBlock,
    00401       PINDEX dataSize,
    00402       PINDEX comparisonOffset = 0,
    00403       PINDEX comparisonLength = P_MAX_INDEX
    00404     );
    00405
    00408     H323NonStandardCapabilityInfo(
    00409       BYTE country,
    00410       BYTE extension,
    00411       WORD maufacturer,
    00412       const BYTE * dataBlock,
    00413       PINDEX dataSize,
    00414       PINDEX comparisonOffset = 0,
    00415       PINDEX comparisonLength = P_MAX_INDEX
    00416     );
    00417
    00420     virtual ~H323NonStandardCapabilityInfo();
    00421
    00426     virtual PBoolean OnSendingPDU(
    00427       PBYTEArray & data
    00428     ) const;
    00429
    00434     virtual PBoolean OnReceivedPDU(
    00435       const PBYTEArray & data
    00436     );
    00437
    00438     PBoolean IsMatch(const H245_NonStandardParameter & param) const;
    00439
    00440     PObject::Comparison CompareParam(
    00441       const H245_NonStandardParameter & param
    00442     ) const;
    00443
    00444   protected:
    00445     PBoolean OnSendingNonStandardPDU(
    00446       PASN_Choice & pdu,
    00447       unsigned nonStandardTag
    00448     ) const;
    00449     PBoolean OnReceivedNonStandardPDU(
    00450       const PASN_Choice & pdu,
    00451       unsigned nonStandardTag
    00452     );
    00453
    00454     PObject::Comparison CompareInfo(
    00455       const H323NonStandardCapabilityInfo & obj
    00456     ) const;
    00457     PObject::Comparison CompareData(
    00458       const PBYTEArray & data
    00459     ) const;
    00460
    00461     PString    oid;
    00462     BYTE       t35CountryCode;
    00463     BYTE       t35Extension;
    00464     WORD       manufacturerCode;
    00465     PBYTEArray nonStandardData;
    00466     PINDEX     comparisonOffset;
    00467     PINDEX     comparisonLength;
    00468     CompareFuncType compareFunc;
    00469 };
    00470
    00480 class H323GenericCapabilityInfo
    00481 {
    00482   public:
    00483     H323GenericCapabilityInfo(
    00484       const PString & id,
    00485       unsigned maxBitRate = 0
    00486     );
    00487
    00488     virtual ~H323GenericCapabilityInfo() { }
    00489
    00490   protected:
    00491     virtual PBoolean OnSendingGenericPDU(
    00492       H245_GenericCapability & pdu,
    00493       const OpalMediaFormat & mediaFormat,
    00494       H323Capability::CommandType type
    00495     ) const;
    00496     virtual PBoolean OnReceivedGenericPDU(
    00497       OpalMediaFormat & mediaFormat,
    00498       const H245_GenericCapability & pdu,
    00499       H323Capability::CommandType type
    00500     );
    00501
    00502     PBoolean IsMatch(
    00503       const H245_GenericCapability & param
    00504     ) const;
    00505     PObject::Comparison CompareInfo(
    00506       const H323GenericCapabilityInfo & obj
    00507     ) const;
    00508
    00509
    00510     PString  m_identifier;
    00511     unsigned maxBitRate;
    00512 };
    00513
    00520 class H323RealTimeCapability : public H323Capability
    00521 {
    00522   PCLASSINFO(H323RealTimeCapability, H323Capability);
    00523
    00524   public:
    00529     virtual H323Channel * CreateChannel(
    00530       H323Connection & connection,
    00531       H323Channel::Directions dir,
    00532       unsigned sessionID,
    00533       const H245_H2250LogicalChannelParameters * param
    00535     ) const;
    00536
    00537     H323RealTimeCapability();
    00538     H323RealTimeCapability(const H323RealTimeCapability &rtc);
    00539     virtual ~H323RealTimeCapability();
    00540     void AttachQoS(RTP_QOS * _rtpqos);
    00541
    00542   protected:
    00543     RTP_QOS * rtpqos;
    00545 };
    00546
    00547
    00554 class H323AudioCapability : public H323RealTimeCapability
    00555 {
    00556   PCLASSINFO(H323AudioCapability, H323RealTimeCapability);
    00557
    00558   public:
    00563     H323AudioCapability();
    00565
    00571     virtual MainTypes GetMainType() const;
    00573
    00584     virtual unsigned GetDefaultSessionID() const;
    00585
    00594     virtual void SetTxFramesInPacket(
    00595       unsigned frames
    00596     );
    00597
    00603     virtual unsigned GetTxFramesInPacket() const;
    00604
    00610     virtual unsigned GetRxFramesInPacket() const;
    00612
    00623     virtual PBoolean OnSendingPDU(
    00624       H245_Capability & pdu
    00625     ) const;
    00626
    00635     virtual PBoolean OnSendingPDU(
    00636       H245_DataType & pdu
    00637     ) const;
    00638
    00647     virtual PBoolean OnSendingPDU(
    00648       H245_ModeElement & pdu
    00649     ) const;
    00650
    00659     virtual PBoolean OnSendingPDU(
    00660       H245_AudioCapability & pdu,
    00661       unsigned packetSize
    00662     ) const;
    00663     virtual PBoolean OnSendingPDU(
    00664       H245_AudioCapability & pdu,
    00665       unsigned packetSize,
    00666       CommandType type
    00667     ) const;
    00668
    00677     virtual PBoolean OnSendingPDU(
    00678       H245_AudioMode & pdu
    00679     ) const;
    00680
    00692     virtual PBoolean OnReceivedPDU(
    00693       const H245_Capability & pdu
    00694     );
    00695
    00705     virtual PBoolean OnReceivedPDU(
    00706       const H245_DataType & pdu,
    00707       PBoolean receiver
    00708     );
    00709
    00718     virtual PBoolean OnReceivedPDU(
    00719       const H245_AudioCapability & pdu,
    00720       unsigned & packetSize
    00721     );
    00722     virtual PBoolean OnReceivedPDU(
    00723       const H245_AudioCapability & pdu,
    00724       unsigned & packetSize,
    00725       CommandType type
    00726     );
    00728 };
    00729
    00730
    00738 class H323NonStandardAudioCapability : public H323AudioCapability,
    00739                                        public H323NonStandardCapabilityInfo
    00740 {
    00741   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
    00742
    00743   public:
    00746     H323NonStandardAudioCapability(
    00747       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
    00748       const BYTE * dataBlock,
    00749       PINDEX dataSize
    00750     );
    00753     H323NonStandardAudioCapability(
    00754       const BYTE * dataBlock = NULL,
    00755       PINDEX dataSize = 0,
    00756       PINDEX comparisonOffset = 0,
    00757       PINDEX comparisonLength = P_MAX_INDEX
    00758      );
    00759
    00762     H323NonStandardAudioCapability(
    00763       const PString & oid,
    00764       const BYTE * dataBlock = NULL,
    00765       PINDEX dataSize = 0,
    00766       PINDEX comparisonOffset = 0,
    00767       PINDEX comparisonLength = P_MAX_INDEX
    00768     );
    00769
    00772     H323NonStandardAudioCapability(
    00773       BYTE country,
    00774       BYTE extension,
    00775       WORD maufacturer,
    00776       const BYTE * dataBlock = NULL,
    00777       PINDEX dataSize = 0,
    00778       PINDEX comparisonOffset = 0,
    00779       PINDEX comparisonLength = P_MAX_INDEX
    00780     );
    00782
    00788     Comparison Compare(const PObject & obj) const;
    00790
    00798     virtual unsigned GetSubType() const;
    00800
    00811     virtual PBoolean OnSendingPDU(
    00812       H245_AudioCapability & pdu,
    00813       unsigned packetSize
    00814     ) const;
    00815
    00824     virtual PBoolean OnSendingPDU(
    00825       H245_AudioMode & pdu
    00826     ) const;
    00827
    00836     virtual PBoolean OnReceivedPDU(
    00837       const H245_AudioCapability & pdu,
    00838       unsigned & packetSize
    00839     );
    00840
    00843     virtual PBoolean IsMatch(
    00844       const PASN_Choice & subTypePDU,
    00845       const PString & mediaPacketization
    00846     ) const;
    00848 };
    00849
    00857 class H323GenericAudioCapability : public H323AudioCapability,
    00858                                    public H323GenericCapabilityInfo
    00859 {
    00860   PCLASSINFO(H323NonStandardAudioCapability, H323AudioCapability);
    00861
    00862   public:
    00867     H323GenericAudioCapability(
    00868       const PString & capabilityId,
    00869       PINDEX maxBitRate = 0
    00870     );
    00872
    00878     Comparison Compare(const PObject & obj) const;
    00880
    00888     virtual unsigned GetSubType() const;
    00890
    00901     virtual PBoolean OnSendingPDU(
    00902       H245_AudioCapability & pdu,
    00903       unsigned packetSize,
    00904       CommandType type
    00905     ) const;
    00906
    00915     virtual PBoolean OnSendingPDU(
    00916       H245_AudioMode & pdu
    00917     ) const;
    00918
    00927     virtual PBoolean OnReceivedPDU(
    00928       const H245_AudioCapability & pdu,
    00929       unsigned & packetSize,
    00930       CommandType type
    00931     );
    00932
    00935     virtual PBoolean IsMatch(
    00936       const PASN_Choice & subTypePDU,
    00937       const PString & mediaPacketization
    00938     ) const;
    00940 };
    00941
    00942
    00943 #if OPAL_VIDEO
    00944
    00951 class H323VideoCapability : public H323RealTimeCapability
    00952 {
    00953   PCLASSINFO(H323VideoCapability, H323RealTimeCapability);
    00954
    00955   public:
    00961     virtual MainTypes GetMainType() const;
    00963
    00974     virtual unsigned GetDefaultSessionID() const;
    00976
    00987     virtual PBoolean OnSendingPDU(
    00988       H245_Capability & pdu
    00989     ) const;
    00990
    00999     virtual PBoolean OnSendingPDU(
    01000       H245_DataType & pdu
    01001     ) const;
    01002
    01011     virtual PBoolean OnSendingPDU(
    01012       H245_ModeElement & pdu
    01013     ) const;
    01014
    01022     virtual PBoolean OnSendingPDU(
    01023       H245_VideoCapability & pdu
    01024     ) const;
    01025     virtual PBoolean OnSendingPDU(
    01026       H245_VideoCapability & pdu,
    01027       CommandType type
    01028     ) const;
    01029
    01038     virtual PBoolean OnSendingPDU(
    01039       H245_VideoMode & pdu
    01040     ) const = 0;
    01041
    01051     virtual PBoolean OnReceivedPDU(
    01052       const H245_Capability & pdu
    01053     );
    01054
    01062     virtual PBoolean OnReceivedPDU(
    01063       const H245_DataType & pdu,
    01064       PBoolean receiver
    01065     );
    01066
    01074     virtual PBoolean OnReceivedPDU(
    01075       const H245_VideoCapability & pdu
    01076     );
    01077     virtual PBoolean OnReceivedPDU(
    01078       const H245_VideoCapability & pdu,
    01079       CommandType type
    01080     );
    01082 };
    01083
    01084
    01092 class H323NonStandardVideoCapability : public H323VideoCapability,
    01093                                        public H323NonStandardCapabilityInfo
    01094 {
    01095   PCLASSINFO(H323NonStandardVideoCapability, H323VideoCapability);
    01096
    01097   public:
    01100     H323NonStandardVideoCapability(
    01101       H323NonStandardCapabilityInfo::CompareFuncType compareFunc,
    01102       const BYTE * dataBlock,
    01103       PINDEX dataSize
    01104     );
    01107     H323NonStandardVideoCapability(
    01108       const BYTE * dataBlock = NULL,
    01109       PINDEX dataSize = 0,
    01110       PINDEX comparisonOffset = 0,
    01111       PINDEX comparisonLength = P_MAX_INDEX
    01112     );
    01113
    01116     H323NonStandardVideoCapability(
    01117       const PString & oid,
    01118       const BYTE * dataBlock = NULL,
    01119       PINDEX dataSize = 0,
    01120       PINDEX comparisonOffset = 0,
    01121       PINDEX comparisonLength = P_MAX_INDEX
    01122     );
    01123
    01126     H323NonStandardVideoCapability(
    01127       BYTE country,
    01128       BYTE extension,
    01129       WORD maufacturer,
    01130       const BYTE * dataBlock = NULL,
    01131       PINDEX dataSize = 0,
    01132       PINDEX comparisonOffset = 0,
    01133       PINDEX comparisonLength = P_MAX_INDEX
    01134     );
    01136
    01142     Comparison Compare(const PObject & obj) const;
    01144
    01153     virtual unsigned GetSubType() const;
    01155
    01166     virtual PBoolean OnSendingPDU(
    01167       H245_VideoCapability & pdu
    01168     ) const;
    01169
    01178     virtual PBoolean OnSendingPDU(
    01179       H245_VideoMode & pdu
    01180     ) const;
    01181
    01190     virtual PBoolean OnReceivedPDU(
    01191       const H245_VideoCapability & pdu
    01192     );
    01193
    01196     virtual PBoolean IsMatch(
    01197       const PASN_Choice & subTypePDU,
    01198       const PString & mediaPacketization
    01199     ) const;
    01201 };
    01202
    01210 class H323GenericVideoCapability : public H323VideoCapability,
    01211                                    public H323GenericCapabilityInfo
    01212 {
    01213   PCLASSINFO(H323GenericVideoCapability, H323VideoCapability);
    01214
    01215   public:
    01220     H323GenericVideoCapability(
    01221       const PString & capabilityId,
    01222       PINDEX maxBitRate = 0
    01223     );
    01225
    01231     Comparison Compare(const PObject & obj) const;
    01233
    01241     virtual unsigned GetSubType() const;
    01243
    01254     virtual PBoolean OnSendingPDU(
    01255       H245_VideoCapability & pdu,
    01256       CommandType type
    01257     ) const;
    01258
    01267     virtual PBoolean OnSendingPDU(
    01268       H245_VideoMode & pdu
    01269     ) const;
    01270
    01279     virtual PBoolean OnReceivedPDU(
    01280       const H245_VideoCapability & pdu,
    01281       CommandType type
    01282     );
    01283
    01286     virtual PBoolean IsMatch(
    01287       const PASN_Choice & subTypePDU,
    01288       const PString & mediaPacketization
    01289     ) const;
    01291 };
    01292
    01293
    01294 #if OPAL_H239
    01295
    01298 class H323ExtendedVideoCapability : public H323GenericVideoCapability
    01299 {
    01300   PCLASSINFO(H323ExtendedVideoCapability, H323GenericVideoCapability);
    01301
    01302   public:
    01307     H323ExtendedVideoCapability(
    01308       const PString & identifier
    01309     );
    01311
    01319     virtual unsigned GetSubType() const;
    01321
    01332     virtual PBoolean OnSendingPDU(
    01333       H245_VideoCapability & pdu,
    01334       CommandType type
    01335     ) const;
    01336
    01345     virtual PBoolean OnSendingPDU(
    01346       H245_VideoMode & pdu
    01347     ) const;
    01348
    01357     virtual PBoolean OnReceivedPDU(
    01358       const H245_VideoCapability & pdu,
    01359       CommandType type
    01360     );
    01361
    01364     virtual PBoolean IsMatch(
    01365       const PASN_Choice & subTypePDU,
    01366       const PString & mediaPacketization
    01367     ) const;
    01369
    01370   protected:
    01371     OpalMediaFormatList m_videoFormats;
    01372 };
    01373
    01374
    01376
    01379 class H323GenericControlCapability : public H323Capability,
    01380                                      public H323GenericCapabilityInfo
    01381 {
    01382   PCLASSINFO(H323GenericControlCapability, H323Capability);
    01383
    01384   public:
    01389     H323GenericControlCapability(
    01390       const PString & identifier
    01391     );
    01393
    01399     virtual MainTypes GetMainType() const;
    01400
    01406     virtual unsigned GetSubType() const;
    01408
    01419     virtual PBoolean OnSendingPDU(
    01420       H245_Capability & pdu
    01421     ) const;
    01422
    01430     virtual PBoolean OnSendingPDU(
    01431       H245_ModeElement & pdu
    01432     ) const;
    01433
    01443     virtual PBoolean OnReceivedPDU(
    01444       const H245_Capability & pdu
    01445     );
    01446
    01449     virtual PBoolean IsMatch(
    01450       const PASN_Choice & subTypePDU,
    01451       const PString & mediaPacketization
    01452     ) const;
    01454
    01462     virtual H323Channel * CreateChannel(
    01463       H323Connection & connection,
    01464       H323Channel::Directions dir,
    01465       unsigned sessionID,
    01466       const H245_H2250LogicalChannelParameters * param
    01468     ) const;
    01470 };
    01471
    01472
    01474
    01475 class H323H239VideoCapability : public H323ExtendedVideoCapability
    01476 {
    01477   PCLASSINFO(H323H239VideoCapability, H323ExtendedVideoCapability);
    01478
    01479   public:
    01484     H323H239VideoCapability(
    01485       const OpalMediaFormat & videoFormat
    01486     );
    01488
    01494     Comparison Compare(const PObject & obj) const;
    01495
    01498     virtual PObject * Clone() const;
    01499
    01502     void PrintOn(ostream & strm) const;
    01504
    01509     virtual PString GetFormatName() const;
    01511
    01522     virtual PBoolean OnSendingPDU(
    01523       H245_VideoCapability & pdu,
    01524       CommandType type
    01525     ) const;
    01526
    01535     virtual PBoolean OnReceivedPDU(
    01536       const H245_VideoCapability & pdu,
    01537       CommandType type
    01538     );
    01540 };
    01541
    01542
    01544
    01545 class H323H239ControlCapability : public H323GenericControlCapability
    01546 {
    01547   PCLASSINFO(H323H239ControlCapability, H323GenericControlCapability);
    01548
    01549   public:
    01554     H323H239ControlCapability();
    01556
    01561     virtual PObject * Clone() const;
    01563
    01568     virtual PString GetFormatName() const;
    01570 };
    01571
    01572
    01573 #endif  // OPAL_H239
    01574
    01575 #endif  // OPAL_VIDEO
    01576
    01577
    01584 class H323DataCapability : public H323Capability
    01585 {
    01586   PCLASSINFO(H323DataCapability, H323Capability);
    01587
    01588   public:
    01593     H323DataCapability(
    01594       unsigned maxBitRate = 0
    01595     );
    01597
    01603     virtual MainTypes GetMainType() const;
    01605
    01615     virtual unsigned GetDefaultSessionID() const;
    01617
    01628     virtual PBoolean OnSendingPDU(
    01629       H245_Capability & pdu
    01630     ) const;
    01631
    01640     virtual PBoolean OnSendingPDU(
    01641       H245_DataType & pdu
    01642     ) const;
    01643
    01652     virtual PBoolean OnSendingPDU(
    01653       H245_ModeElement & pdu
    01654     ) const;
    01655
    01663     virtual PBoolean OnSendingPDU(
    01664       H245_DataApplicationCapability & pdu
    01665     ) const;
    01666     virtual PBoolean OnSendingPDU(
    01667       H245_DataApplicationCapability & pdu,
    01668       CommandType type
    01669     ) const;
    01670
    01679     virtual PBoolean OnSendingPDU(
    01680       H245_DataMode & pdu
    01681     ) const = 0;
    01682
    01692     virtual PBoolean OnReceivedPDU(
    01693       const H245_Capability & pdu
    01694     );
    01695
    01703     virtual PBoolean OnReceivedPDU(
    01704       const H245_DataType & pdu,
    01705       PBoolean receiver
    01706     );
    01707
    01715     virtual PBoolean OnReceivedPDU(
    01716       const H245_DataApplicationCapability & pdu
    01717     );
    01718     virtual PBoolean OnReceivedPDU(
    01719       const H245_DataApplicationCapability & pdu,
    01720       CommandType type
    01721     );
    01723
    01724   protected:
    01725     unsigned maxBitRate;
    01726 };
    01727
    01728
    01736 class H323NonStandardDataCapability : public H323DataCapability,
    01737                                       public H323NonStandardCapabilityInfo
    01738 {
    01739   PCLASSINFO(H323NonStandardDataCapability, H323DataCapability);
    01740
    01741   public:
    01746     H323NonStandardDataCapability(
    01747       unsigned maxBitRate,
    01748       const BYTE * dataBlock = NULL,
    01749       PINDEX dataSize = 0,
    01750       PINDEX comparisonOffset = 0,
    01751       PINDEX comparisonLength = P_MAX_INDEX
    01752     );
    01753
    01756     H323NonStandardDataCapability(
    01757       unsigned maxBitRate,
    01758       const PString & oid,
    01759       const BYTE * dataBlock = NULL,
    01760       PINDEX dataSize = 0,
    01761       PINDEX comparisonOffset = 0,
    01762       PINDEX comparisonLength = P_MAX_INDEX
    01763     );
    01764
    01767     H323NonStandardDataCapability(
    01768       unsigned maxBitRate,
    01769       BYTE country,
    01770       BYTE extension,
    01771       WORD maufacturer,
    01772       const BYTE * dataBlock = NULL,
    01773       PINDEX dataSize = 0,
    01774       PINDEX comparisonOffset = 0,
    01775       PINDEX comparisonLength = P_MAX_INDEX
    01776     );
    01778
    01784     Comparison Compare(const PObject & obj) const;
    01786
    01795     virtual unsigned GetSubType() const;
    01797
    01808     virtual PBoolean OnSendingPDU(
    01809       H245_DataApplicationCapability & pdu
    01810     ) const;
    01811
    01820     virtual PBoolean OnSendingPDU(
    01821       H245_DataMode & pdu
    01822     ) const;
    01823
    01832     virtual PBoolean OnReceivedPDU(
    01833       const H245_DataApplicationCapability & pdu
    01834     );
    01835
    01838     virtual PBoolean IsMatch(
    01839       const PASN_Choice & subTypePDU,
    01840       const PString & mediaPacketization
    01841     ) const;
    01843 };
    01844
    01845
    01847 // Known audio codecs
    01848
    01851 class H323_G711Capability : public H323AudioCapability
    01852 {
    01853   PCLASSINFO(H323_G711Capability, H323AudioCapability)
    01854
    01855   public:
    01857     enum Mode {
    01859       ALaw,
    01861       muLaw
    01862     };
    01864     enum Speed {
    01866       At64k,
    01868       At56k
    01869     };
    01870
    01875     H323_G711Capability(
    01876       Mode mode = muLaw,
    01877       Speed speed = At64k
    01878     );
    01880
    01885     virtual PObject * Clone() const;
    01887
    01896     virtual unsigned GetSubType() const;
    01897
    01900     virtual PString GetFormatName() const;
    01902
    01903   protected:
    01904     Mode     mode;
    01905     Speed    speed;
    01906 };
    01907
    01909
    01912 class H323_UserInputCapability : public H323Capability
    01913 {
    01914   PCLASSINFO(H323_UserInputCapability, H323Capability);
    01915
    01916   public:
    01919     enum SubTypes {
    01920       BasicString,
    01921       IA5String,
    01922       GeneralString,
    01923       SignalToneH245,
    01924       HookFlashH245,
    01925       SignalToneRFC2833,
    01926       NumSubTypes
    01927     };
    01928     static const char * GetSubTypeName(SubTypes subType);
    01929     friend ostream & operator<<(ostream & strm, SubTypes subType) { return strm << GetSubTypeName(subType); }
    01930
    01935     H323_UserInputCapability(
    01936       SubTypes subType
    01937     );
    01939
    01944     virtual PObject * Clone() const;
    01946
    01954     virtual MainTypes GetMainType() const;
    01955
    01959     virtual unsigned  GetSubType()  const;
    01960
    01963     virtual PString GetFormatName() const;
    01965
    01973     virtual H323Channel * CreateChannel(
    01974       H323Connection & connection,
    01975       H323Channel::Directions dir,
    01976       unsigned sessionID,
    01977       const H245_H2250LogicalChannelParameters * param
    01979     ) const;
    01981
    01991     virtual PBoolean OnSendingPDU(
    01992       H245_Capability & pdu
    01993     ) const;
    01994
    02002     virtual PBoolean OnSendingPDU(
    02003       H245_DataType & pdu
    02004     ) const;
    02005
    02014     virtual PBoolean OnSendingPDU(
    02015       H245_ModeElement & pdu
    02016     ) const;
    02017
    02027     virtual PBoolean OnReceivedPDU(
    02028       const H245_Capability & pdu
    02029     );
    02030
    02038     virtual PBoolean OnReceivedPDU(
    02039       const H245_DataType & pdu,
    02040       PBoolean receiver
    02041     );
    02042
    02051     virtual PBoolean IsUsable(
    02052       const H323Connection & connection
    02053     ) const;
    02055
    02056     static void AddAllCapabilities(
    02057       H323Capabilities & capabilities,
    02058       PINDEX descriptorNum,
    02059       PINDEX simultaneous,
    02060       bool includeRFC2833 = true
    02061     );
    02062
    02063   protected:
    02064     SubTypes subType;
    02065 };
    02066
    02067
    02068
    02070
    02071 PARRAY(H323CapabilitiesList, H323Capability);
    02072
    02073 PARRAY(H323CapabilitiesListArray, H323CapabilitiesList);
    02074
    02075 class H323SimultaneousCapabilities : public H323CapabilitiesListArray
    02076 {
    02077   PCLASSINFO(H323SimultaneousCapabilities, H323CapabilitiesListArray);
    02078   public:
    02079     PBoolean SetSize(PINDEX newSize);
    02080 };
    02081
    02082
    02083 PARRAY(H323CapabilitiesSetArray, H323SimultaneousCapabilities);
    02084
    02085
    02086 class H323CapabilitiesSet : public H323CapabilitiesSetArray
    02087 {
    02088   PCLASSINFO(H323CapabilitiesSet, H323CapabilitiesSetArray);
    02089   public:
    02091     PBoolean SetSize(PINDEX newSize);
    02092 };
    02093
    02094
    02097 class H323Capabilities : public PObject
    02098 {
    02099     PCLASSINFO(H323Capabilities, PObject);
    02100   public:
    02105     H323Capabilities();
    02106
    02109     H323Capabilities(
    02110       const H323Connection & connection,
    02111       const H245_TerminalCapabilitySet & pdu
    02112     );
    02113
    02118     H323Capabilities(
    02119       const H323Capabilities & original
    02120     );
    02121
    02126     H323Capabilities & operator=(
    02127       const H323Capabilities & original
    02128     );
    02130
    02135     void PrintOn(
    02136       ostream & strm
    02137     ) const;
    02139
    02144     PINDEX GetSize() const { return table.GetSize(); }
    02145
    02148     H323Capability & operator[](PINDEX i) const { return table[i]; }
    02149
    02170     PINDEX SetCapability(
    02171       PINDEX descriptorNum,
    02172       PINDEX simultaneous,
    02173       H323Capability * cap
    02174     );
    02175
    02178     PINDEX AddMediaFormat(
    02179       PINDEX descriptorNum,
    02180       PINDEX simultaneous,
    02181       const OpalMediaFormat & mediaFormat
    02182     );
    02183
    02188     PINDEX AddAllCapabilities(
    02189       PINDEX descriptorNum,
    02190       PINDEX simultaneous,
    02191       const PString & name,
    02192       PBoolean exact = false
    02193     );
    02194
    02195     // this function is retained for backwards compatibility
    02196     PINDEX AddAllCapabilities(
    02197       const H323EndPoint &,
    02198       PINDEX descriptorNum,
    02199       PINDEX simultaneous,
    02200       const PString & name,
    02201       PBoolean exact = false
    02202     )
    02203     { return AddAllCapabilities(descriptorNum, simultaneous, name, exact); }
    02204
    02213     void Add(
    02214       H323Capability * capability
    02215     );
    02216
    02223     H323Capability * Copy(
    02224       const H323Capability & capability
    02225     );
    02226
    02231     void Remove(
    02232       H323Capability * capability
    02233     );
    02234
    02239     void Remove(
    02240       const PString & formatName
    02241     );
    02242
    02246     void Remove(
    02247       const PStringArray & formatNames
    02248     );
    02249
    02252     void RemoveAll();
    02253
    02261     H323Capability * FindCapability(
    02262       unsigned capabilityNumber
    02263     ) const;
    02264
    02280     H323Capability * FindCapability(
    02281       const PString & formatName,
    02282       H323Capability::CapabilityDirection direction = H323Capability::e_Unknown,
    02284       PBoolean exact = false
    02285     ) const;
    02286
    02292     H323Capability * FindCapability(
    02293       H323Capability::CapabilityDirection direction
    02294     ) const;
    02295
    02303     H323Capability * FindCapability(
    02304       const H323Capability & capability
    02305     ) const;
    02306
    02312     H323Capability * FindCapability(
    02313       const H245_Capability & cap
    02314     ) const;
    02315
    02321     H323Capability * FindCapability(
    02322       const H245_DataType & dataType,
    02323       const PString & mediaPacketization = PString::Empty()
    02324     ) const;
    02325
    02331     H323Capability * FindCapability(
    02332       const H245_ModeElement & modeElement,
    02333       const PString & mediaPacketization = PString::Empty()
    02334     ) const;
    02335
    02341     H323Capability * FindCapability(
    02342       H323Capability::MainTypes mainType,
    02343       unsigned subType = UINT_MAX
    02344     ) const;
    02345
    02348     void BuildPDU(
    02349       const H323Connection & connection,
    02350       H245_TerminalCapabilitySet & pdu
    02351     ) const;
    02352
    02355     PBoolean Merge(
    02356       const H323Capabilities & newCaps
    02357     );
    02358
    02365     void Reorder(
    02366       const PStringArray & preferenceOrder
    02367     );
    02368
    02371     PBoolean IsAllowed(
    02372       const H323Capability & capability
    02373     );
    02374
    02377     PBoolean IsAllowed(
    02378       unsigned capabilityNumber
    02379     );
    02380
    02383     PBoolean IsAllowed(
    02384       const H323Capability & capability1,
    02385       const H323Capability & capability2
    02386     );
    02387
    02390     PBoolean IsAllowed(
    02391       unsigned capabilityNumber1,
    02392       unsigned capabilityNumber2
    02393     );
    02394
    02397     OpalMediaFormatList GetMediaFormats() const;
    02398
    02399     const PStringSet & GetMediaPacketizations() const { return m_mediaPacketizations; }
    02401
    02402   protected:
    02403     H323CapabilitiesList table;
    02404     H323CapabilitiesSet  set;
    02405     PStringSet           m_mediaPacketizations;
    02406 };
    02407
    02408
    02410
    02411 /* New capability registration macros based on abstract factories
    02412  */
    02413 typedef PFactory<H323Capability, std::string> H323CapabilityFactory;
    02414
    02415 #define H323_REGISTER_CAPABILITY(cls, capName)   static H323CapabilityFactory::Worker<cls> cls##Factory(capName, true); \
    02416
    02417
    02418 #endif // OPAL_H323
    02419
    02420 #endif // OPAL_H323_H323CAPS_H
    02421
    02422