# channels.h

Go to the documentation of this file.

    00001 /*
    00002  * channels.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: 28351 $
    00030  * $Author: rjongbloed $
    00031  * $Date: 2012-09-13 19:58:35 -0500 (Thu, 13 Sep 2012) $
    00032  */
    00033
    00034 #ifndef OPAL_H323_CHANNELS_H
    00035 #define OPAL_H323_CHANNELS_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 <rtp/rtp.h>
    00046 #include <h323/transaddr.h>
    00047 #include <opal/mediastrm.h>
    00048
    00049
    00050 class H245_OpenLogicalChannel;
    00051 class H245_OpenLogicalChannelAck;
    00052 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
    00053 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
    00054 class H245_H2250LogicalChannelParameters;
    00055 class H245_H2250LogicalChannelAckParameters;
    00056 class H245_ArrayOf_GenericInformation;
    00057 class H245_MiscellaneousCommand_type;
    00058 class H245_MiscellaneousIndication_type;
    00059
    00060 class H323EndPoint;
    00061 class H323Connection;
    00062 class H323Capability;
    00063
    00064
    00066
    00070 class H323ChannelNumber : public PObject
    00071 {
    00072   PCLASSINFO(H323ChannelNumber, PObject);
    00073
    00074   public:
    00075     H323ChannelNumber() { number = 0; fromRemote = false; }
    00076     H323ChannelNumber(unsigned number, PBoolean fromRemote);
    00077
    00078     virtual PObject * Clone() const;
    00079     virtual PINDEX HashFunction() const;
    00080     virtual void PrintOn(ostream & strm) const;
    00081     virtual Comparison Compare(const PObject & obj) const;
    00082
    00083     H323ChannelNumber & operator++(int);
    00084     operator unsigned() const { return number; }
    00085     PBoolean IsFromRemote() const { return fromRemote; }
    00086
    00087   protected:
    00088     unsigned number;
    00089     PBoolean     fromRemote;
    00090 };
    00091
    00092
    00099 class H323Channel : public PObject
    00100 {
    00101   PCLASSINFO(H323Channel, PObject);
    00102
    00103   public:
    00108     H323Channel(
    00109       H323Connection & connection,
    00110       const H323Capability & capability
    00111     );
    00112
    00117     ~H323Channel();
    00119
    00122     virtual void PrintOn(
    00123       ostream & strm
    00124     ) const;
    00126
    00129     enum Directions {
    00130       IsBidirectional,
    00131       IsTransmitter,
    00132       IsReceiver,
    00133       NumDirections
    00134     };
    00135 #if PTRACING
    00136     friend ostream & operator<<(ostream & out, Directions dir);
    00137 #endif
    00138
    00143     virtual Directions GetDirection() const = 0;
    00144
    00150     virtual unsigned GetSessionID() const;
    00151
    00158     virtual bool SetSessionID(
    00159       unsigned sessionID
    00160     );
    00161
    00168     virtual PBoolean GetMediaTransportAddress(
    00169       OpalTransportAddress & data,
    00170       OpalTransportAddress & control
    00171     ) const;
    00172
    00180     virtual PBoolean SetInitialBandwidth() = 0;
    00181
    00188     virtual bool PreOpen();
    00189
    00194     virtual PBoolean Open();
    00195
    00198     virtual void Close();
    00199
    00202     PBoolean IsOpen() const { return opened && m_terminating == 0; }
    00203
    00211     virtual OpalMediaStreamPtr GetMediaStream() const;
    00212
    00216     virtual void SetMediaStream(OpalMediaStreamPtr mediaStream);
    00217
    00218
    00221     virtual PBoolean OnSendingPDU(
    00222       H245_OpenLogicalChannel & openPDU
    00223     ) const = 0;
    00224
    00230     virtual void OnSendOpenAck(
    00231       const H245_OpenLogicalChannel & open,
    00232       H245_OpenLogicalChannelAck & ack
    00233     ) const;
    00234
    00241     virtual PBoolean OnReceivedPDU(
    00242       const H245_OpenLogicalChannel & pdu,
    00243       unsigned & errorCode
    00244     );
    00245
    00252     virtual PBoolean OnReceivedAckPDU(
    00253       const H245_OpenLogicalChannelAck & pdu
    00254     );
    00255
    00259     virtual void OnFlowControl(
    00260       long bitRateRestriction
    00261     );
    00262
    00266     virtual void OnMiscellaneousCommand(
    00267       const H245_MiscellaneousCommand_type & type
    00268     );
    00269
    00273     virtual void OnMiscellaneousIndication(
    00274       const H245_MiscellaneousIndication_type & type
    00275     );
    00276
    00280     virtual void OnJitterIndication(
    00281       DWORD jitter,
    00282       int skippedFrameCount,
    00283       int additionalBuffer
    00284     );
    00286
    00291     const H323ChannelNumber & GetNumber() const { return number; }
    00292
    00295     void SetNumber(const H323ChannelNumber & num) { number = num; }
    00296
    00299     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
    00300
    00303     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
    00304
    00307     OpalBandwidth GetBandwidthUsed() const { return m_bandwidthUsed; }
    00308
    00311     bool SetBandwidthUsed(
    00312       OpalBandwidth bandwidth
    00313     );
    00314
    00317     const H323Capability & GetCapability() const { return *capability; }
    00319
    00320   protected:
    00321     virtual void InternalClose();
    00322
    00323     H323EndPoint         & endpoint;
    00324     H323Connection       & connection;
    00325     H323Capability       * capability;
    00326     H323ChannelNumber      number;
    00327     H323ChannelNumber      reverseChannel;
    00328     bool                   opened;
    00329     PAtomicInteger         m_terminating;
    00330
    00331   private:
    00332     OpalBandwidth m_bandwidthUsed;
    00333 };
    00334
    00335
    00336 PLIST(H323LogicalChannelList, H323Channel);
    00337
    00338
    00339
    00346 class H323UnidirectionalChannel : public H323Channel
    00347 {
    00348   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
    00349
    00350   public:
    00355     H323UnidirectionalChannel(
    00356       H323Connection & connection,
    00357       const H323Capability & capability,
    00358       Directions direction
    00359     );
    00360
    00363     ~H323UnidirectionalChannel();
    00365
    00372     virtual Directions GetDirection() const;
    00373
    00381     virtual PBoolean SetInitialBandwidth();
    00382
    00389     virtual bool PreOpen();
    00390
    00393     virtual PBoolean Open();
    00395
    00398     OpalMediaFormat GetMediaFormat() const { return m_mediaFormat; }
    00399
    00403     virtual OpalMediaStreamPtr GetMediaStream() const;
    00404
    00408     virtual void SetMediaStream(OpalMediaStreamPtr mediaStream);
    00410
    00411
    00412   protected:
    00413     virtual void InternalClose();
    00414
    00415     bool               receiver;
    00416     OpalMediaFormat    m_mediaFormat;
    00417     OpalMediaStreamPtr m_mediaStream;
    00418 };
    00419
    00420
    00427 class H323BidirectionalChannel : public H323Channel
    00428 {
    00429   PCLASSINFO(H323BidirectionalChannel, H323Channel);
    00430
    00431   public:
    00436     H323BidirectionalChannel(
    00437       H323Connection & connection,
    00438       const H323Capability & capability
    00439     );
    00441
    00448     virtual Directions GetDirection() const;
    00450 };
    00451
    00452
    00454
    00457 class H323_RealTimeChannel : public H323UnidirectionalChannel
    00458 {
    00459   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
    00460
    00461   public:
    00466     H323_RealTimeChannel(
    00467       H323Connection & connection,
    00468       const H323Capability & capability,
    00469       Directions direction
    00470     );
    00472
    00477     virtual PBoolean OnSendingPDU(
    00478       H245_OpenLogicalChannel & openPDU
    00479     ) const;
    00480
    00484     virtual void OnSendOpenAck(
    00485       const H245_OpenLogicalChannel & open,
    00486       H245_OpenLogicalChannelAck & ack
    00487     ) const;
    00488
    00489     virtual void OnSendOpenAck(
    00490       H245_H2250LogicalChannelAckParameters & param
    00491     ) const;
    00492
    00493
    00501     virtual PBoolean OnReceivedPDU(
    00502       const H245_OpenLogicalChannel & pdu,
    00503       unsigned & errorCode
    00504     );
    00505
    00513     virtual PBoolean OnReceivedAckPDU(
    00514       const H245_OpenLogicalChannelAck & pdu
    00515     );
    00517
    00522     virtual PBoolean OnSendingPDU(
    00523       H245_H2250LogicalChannelParameters & param
    00524     ) const;
    00525
    00528     virtual PBoolean OnSendingAltPDU(
    00529       H245_ArrayOf_GenericInformation & alternate
    00530     ) const = 0;
    00531
    00542     virtual PBoolean OnReceivedPDU(
    00543       const H245_H2250LogicalChannelParameters & param,
    00544       unsigned & errorCode
    00545     );
    00546
    00553     virtual PBoolean OnReceivedAckPDU(
    00554       const H245_H2250LogicalChannelAckParameters & param
    00555     );
    00556
    00559     virtual PBoolean OnReceivedAckAltPDU(
    00560       const H245_ArrayOf_GenericInformation & alternate
    00561     ) = 0;
    00562
    00563     RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const;
    00565 };
    00566
    00567
    00569
    00576 class H323DataChannel : public H323UnidirectionalChannel
    00577 {
    00578   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
    00579
    00580   public:
    00585     H323DataChannel(
    00586       H323Connection & connection,
    00587       const H323Capability & capability,
    00588       Directions direction,
    00589       unsigned sessionID
    00590     );
    00591
    00594     ~H323DataChannel();
    00596
    00601     virtual unsigned GetSessionID() const;
    00602
    00605     virtual PBoolean OnSendingPDU(
    00606       H245_OpenLogicalChannel & openPDU
    00607     ) const;
    00608
    00612     virtual void OnSendOpenAck(
    00613       const H245_OpenLogicalChannel & open,
    00614       H245_OpenLogicalChannelAck & ack
    00615     ) const;
    00616
    00624     virtual PBoolean OnReceivedPDU(
    00625       const H245_OpenLogicalChannel & pdu,
    00626       unsigned & errorCode
    00627     );
    00628
    00636     virtual PBoolean OnReceivedAckPDU(
    00637       const H245_OpenLogicalChannelAck & pdu
    00638     );
    00640
    00649     virtual PBoolean CreateListener();
    00650
    00658     virtual PBoolean CreateTransport();
    00660
    00661   protected:
    00662     virtual void InternalClose();
    00663
    00664     unsigned        sessionID;
    00665     H323Listener  * listener;
    00666     PBoolean            autoDeleteListener;
    00667     H323Transport * transport;
    00668     PBoolean            autoDeleteTransport;
    00669     PBoolean            separateReverseChannel;
    00670 };
    00671
    00672
    00673 #endif // OPAL_H323
    00674
    00675 #endif // OPAL_H323_CHANNELS_H
    00676
    00677