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: 19627 $
00030  * $Author: csoutheren $
00031  * $Date: 2008-02-29 03:56:48 +0000 (Fri, 29 Feb 2008) $
00032  */
00033 
00034 #ifndef __OPAL_CHANNELS_H
00035 #define __OPAL_CHANNELS_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 
00042 #include <rtp/rtp.h>
00043 #include <h323/transaddr.h>
00044 #include <opal/mediastrm.h>
00045 
00046 
00047 class H245_OpenLogicalChannel;
00048 class H245_OpenLogicalChannelAck;
00049 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00050 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00051 class H245_H2250LogicalChannelParameters;
00052 class H245_H2250LogicalChannelAckParameters;
00053 class H245_MiscellaneousCommand_type;
00054 class H245_MiscellaneousIndication_type;
00055 
00056 class H323EndPoint;
00057 class H323Connection;
00058 class H323Capability;
00059 class H323_RTP_Session;
00060 
00061 
00063 
00067 class H323ChannelNumber : public PObject
00068 {
00069   PCLASSINFO(H323ChannelNumber, PObject);
00070 
00071   public:
00072     H323ChannelNumber() { number = 0; fromRemote = PFalse; }
00073     H323ChannelNumber(unsigned number, PBoolean fromRemote);
00074 
00075     virtual PObject * Clone() const;
00076     virtual PINDEX HashFunction() const;
00077     virtual void PrintOn(ostream & strm) const;
00078     virtual Comparison Compare(const PObject & obj) const;
00079 
00080     H323ChannelNumber & operator++(int);
00081     operator unsigned() const { return number; }
00082     PBoolean IsFromRemote() const { return fromRemote; }
00083     
00084   protected:
00085     unsigned number;
00086     PBoolean     fromRemote;
00087 };
00088 
00089 
00096 class H323Channel : public PObject
00097 {
00098   PCLASSINFO(H323Channel, PObject);
00099 
00100   public:
00105     H323Channel(
00106       H323Connection & connection,        
00107       const H323Capability & capability   
00108     );
00109 
00114     ~H323Channel();
00116 
00119     virtual void PrintOn(
00120       ostream & strm
00121     ) const;
00123 
00126     enum Directions {
00127       IsBidirectional,
00128       IsTransmitter,
00129       IsReceiver,
00130       NumDirections
00131     };
00132 #if PTRACING
00133     friend ostream & operator<<(ostream & out, Directions dir);
00134 #endif
00135 
00140     virtual Directions GetDirection() const = 0;
00141 
00147     virtual unsigned GetSessionID() const;
00148 
00155     virtual PBoolean GetMediaTransportAddress(
00156       OpalTransportAddress & data,        
00157       OpalTransportAddress & control      
00158     ) const;
00159 
00167     virtual PBoolean SetInitialBandwidth() = 0;
00168 
00173     virtual PBoolean Open();
00174 
00177     virtual PBoolean Start() = 0;
00178 
00181     virtual void Close();
00182 
00185     PBoolean IsOpen() const { return opened && !terminating; }
00186 
00194     virtual OpalMediaStreamPtr GetMediaStream() const;
00195 
00196 
00199     virtual PBoolean OnSendingPDU(
00200       H245_OpenLogicalChannel & openPDU  
00201     ) const = 0;
00202 
00208     virtual void OnSendOpenAck(
00209       const H245_OpenLogicalChannel & open,   
00210       H245_OpenLogicalChannelAck & ack        
00211     ) const;
00212 
00219     virtual PBoolean OnReceivedPDU(
00220       const H245_OpenLogicalChannel & pdu,    
00221       unsigned & errorCode                    
00222     );
00223 
00230     virtual PBoolean OnReceivedAckPDU(
00231       const H245_OpenLogicalChannelAck & pdu  
00232     );
00233 
00237     virtual void OnFlowControl(
00238       long bitRateRestriction   
00239     );
00240 
00244     virtual void OnMiscellaneousCommand(
00245       const H245_MiscellaneousCommand_type & type  
00246     );
00247 
00251     virtual void OnMiscellaneousIndication(
00252       const H245_MiscellaneousIndication_type & type  
00253     );
00254 
00258     virtual void OnJitterIndication(
00259       DWORD jitter,           
00260       int skippedFrameCount,  
00261       int additionalBuffer    
00262     );
00264 
00269     const H323ChannelNumber & GetNumber() const { return number; }
00270 
00273     void SetNumber(const H323ChannelNumber & num) { number = num; }
00274 
00277     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00278 
00281     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00282 
00285     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00286 
00289     PBoolean SetBandwidthUsed(
00290       unsigned bandwidth  
00291     );
00292 
00295     const H323Capability & GetCapability() const { return *capability; }
00296 
00305     PBoolean IsPaused() const { return paused; }
00306 
00315     void SetPause(
00316       PBoolean pause   
00317     ) { paused = pause; }
00319 
00320     virtual void OnMediaCommand(OpalMediaCommand &) { }
00321 
00322   protected:
00323     H323EndPoint         & endpoint;
00324     H323Connection       & connection;
00325     H323Capability       * capability;
00326     H323ChannelNumber      number;
00327     H323ChannelNumber      reverseChannel;
00328     PBoolean                   opened;
00329     PBoolean                   paused;
00330     PBoolean                   terminating;
00331 
00332   private:
00333     unsigned bandwidthUsed;
00334 };
00335 
00336 
00337 PLIST(H323LogicalChannelList, H323Channel);
00338 
00339 
00340 
00347 class H323UnidirectionalChannel : public H323Channel
00348 {
00349   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00350 
00351   public:
00356     H323UnidirectionalChannel(
00357       H323Connection & connection,        
00358       const H323Capability & capability,  
00359       Directions direction                
00360     );
00361 
00364     ~H323UnidirectionalChannel();
00366 
00373     virtual Directions GetDirection() const;
00374 
00382     virtual PBoolean SetInitialBandwidth();
00383 
00386     virtual PBoolean Open();
00387 
00392     virtual PBoolean Start();
00393 
00396     virtual void Close();
00397 
00401     virtual void OnMiscellaneousCommand(
00402       const H245_MiscellaneousCommand_type & type  
00403     );
00405 
00411     virtual OpalMediaStreamPtr GetMediaStream() const;
00413 
00414     void OnMediaCommand(OpalMediaCommand & command);
00415 
00416   protected:
00417     bool               receiver;
00418     OpalMediaStreamPtr mediaStream;
00419 };
00420 
00421 
00428 class H323BidirectionalChannel : public H323Channel
00429 {
00430   PCLASSINFO(H323BidirectionalChannel, H323Channel);
00431 
00432   public:
00437     H323BidirectionalChannel(
00438       H323Connection & connection,        
00439       const H323Capability & capability   
00440     );
00442 
00449     virtual Directions GetDirection() const;
00450 
00455     virtual PBoolean Start();
00457 };
00458 
00459 
00461 
00464 class H323_RealTimeChannel : public H323UnidirectionalChannel
00465 {
00466   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00467 
00468   public:
00473     H323_RealTimeChannel(
00474       H323Connection & connection,        
00475       const H323Capability & capability,  
00476       Directions direction                
00477     );
00479 
00484     virtual PBoolean OnSendingPDU(
00485       H245_OpenLogicalChannel & openPDU  
00486     ) const;
00487 
00491     virtual void OnSendOpenAck(
00492       const H245_OpenLogicalChannel & open,   
00493       H245_OpenLogicalChannelAck & ack        
00494     ) const;
00495 
00503     virtual PBoolean OnReceivedPDU(
00504       const H245_OpenLogicalChannel & pdu,    
00505       unsigned & errorCode                    
00506     );
00507 
00515     virtual PBoolean OnReceivedAckPDU(
00516       const H245_OpenLogicalChannelAck & pdu 
00517     );
00519 
00524     virtual PBoolean OnSendingPDU(
00525       H245_H2250LogicalChannelParameters & param  
00526     ) const = 0;
00527 
00531     virtual void OnSendOpenAck(
00532       H245_H2250LogicalChannelAckParameters & param 
00533     ) const = 0;
00534 
00541     virtual PBoolean OnReceivedPDU(
00542       const H245_H2250LogicalChannelParameters & param, 
00543       unsigned & errorCode                              
00544     ) = 0;
00545 
00552     virtual PBoolean OnReceivedAckPDU(
00553       const H245_H2250LogicalChannelAckParameters & param 
00554     ) = 0;
00555 
00558     virtual PBoolean SetDynamicRTPPayloadType(
00559       int newType  
00560     );
00561 
00562     RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00564 
00565   protected:
00566     RTP_DataFrame::PayloadTypes rtpPayloadType;
00567 };
00568 
00569 
00571 
00574 class H323_RTPChannel : public H323_RealTimeChannel
00575 {
00576   PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00577 
00578   public:
00583     H323_RTPChannel(
00584       H323Connection & connection,        
00585       const H323Capability & capability,  
00586       Directions direction,               
00587       RTP_Session & rtp                   
00588     );
00589 
00591     ~H323_RTPChannel();
00593 
00600     virtual unsigned GetSessionID() const;
00602 
00607     virtual PBoolean OnSendingPDU(
00608       H245_H2250LogicalChannelParameters & param  
00609     ) const;
00610 
00614     virtual void OnSendOpenAck(
00615       H245_H2250LogicalChannelAckParameters & param 
00616     ) const;
00617 
00624     virtual PBoolean OnReceivedPDU(
00625       const H245_H2250LogicalChannelParameters & param, 
00626       unsigned & errorCode                              
00627     );
00628 
00635     virtual PBoolean OnReceivedAckPDU(
00636       const H245_H2250LogicalChannelAckParameters & param 
00637     );
00639 
00640   protected:
00641     RTP_Session      & rtpSession;
00642     H323_RTP_Session & rtpCallbacks;
00643 };
00644 
00645 
00647 
00651 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00652 {
00653   PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00654 
00655   public:
00660     H323_ExternalRTPChannel(
00661       H323Connection & connection,        
00662       const H323Capability & capability,  
00663       Directions direction,               
00664       unsigned sessionID                  
00665     );
00668     H323_ExternalRTPChannel(
00669       H323Connection & connection,        
00670       const H323Capability & capability,  
00671       Directions direction,               
00672       unsigned sessionID,                 
00673       const H323TransportAddress & data,  
00674       const H323TransportAddress & control
00675     );
00678     H323_ExternalRTPChannel(
00679       H323Connection & connection,        
00680       const H323Capability & capability,  
00681       Directions direction,               
00682       unsigned sessionID,                 
00683       const PIPSocket::Address & ip,      
00684       WORD dataPort                       
00685     );
00687 
00694     virtual unsigned GetSessionID() const;
00695 
00702     virtual PBoolean GetMediaTransportAddress(
00703       OpalTransportAddress & data,        
00704       OpalTransportAddress & control      
00705     ) const;
00706 
00709     virtual PBoolean Start();
00710 
00717     virtual void Receive();
00718 
00725     virtual void Transmit();
00727 
00732     virtual PBoolean OnSendingPDU(
00733       H245_H2250LogicalChannelParameters & param  
00734     ) const;
00735 
00739     virtual void OnSendOpenAck(
00740       H245_H2250LogicalChannelAckParameters & param 
00741     ) const;
00742 
00749     virtual PBoolean OnReceivedPDU(
00750       const H245_H2250LogicalChannelParameters & param, 
00751       unsigned & errorCode                              
00752     );
00753 
00760     virtual PBoolean OnReceivedAckPDU(
00761       const H245_H2250LogicalChannelAckParameters & param 
00762     );
00764 
00765     void SetExternalAddress(
00766       const H323TransportAddress & data,  
00767       const H323TransportAddress & control
00768     );
00769 
00770     const H323TransportAddress & GetRemoteMediaAddress()        const { return remoteMediaAddress; }
00771     const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00772 
00773     PBoolean GetRemoteAddress(
00774       PIPSocket::Address & ip,
00775       WORD & dataPort
00776     ) const;
00777 
00778   protected:
00779     void Construct(H323Connection & conn, unsigned id);
00780 
00781     unsigned             sessionID;
00782     H323TransportAddress externalMediaAddress;
00783     H323TransportAddress externalMediaControlAddress;
00784     H323TransportAddress remoteMediaAddress;
00785     H323TransportAddress remoteMediaControlAddress;
00786 };
00787 
00788 
00790 
00797 class H323DataChannel : public H323UnidirectionalChannel
00798 {
00799   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00800 
00801   public:
00806     H323DataChannel(
00807       H323Connection & connection,        
00808       const H323Capability & capability,  
00809       Directions direction,               
00810       unsigned sessionID                  
00811     );
00812 
00815     ~H323DataChannel();
00817 
00822     virtual void Close();
00823 
00828     virtual unsigned GetSessionID() const;
00829 
00832     virtual PBoolean OnSendingPDU(
00833       H245_OpenLogicalChannel & openPDU  
00834     ) const;
00835 
00839     virtual void OnSendOpenAck(
00840       const H245_OpenLogicalChannel & open,   
00841       H245_OpenLogicalChannelAck & ack        
00842     ) const;
00843 
00851     virtual PBoolean OnReceivedPDU(
00852       const H245_OpenLogicalChannel & pdu,    
00853       unsigned & errorCode                    
00854     );
00855 
00863     virtual PBoolean OnReceivedAckPDU(
00864       const H245_OpenLogicalChannelAck & pdu 
00865     );
00867 
00876     virtual PBoolean CreateListener();
00877 
00885     virtual PBoolean CreateTransport();
00887 
00888   protected:
00889     unsigned        sessionID;
00890     H323Listener  * listener;
00891     PBoolean            autoDeleteListener;
00892     H323Transport * transport;
00893     PBoolean            autoDeleteTransport;
00894     PBoolean            separateReverseChannel;
00895 };
00896 
00897 
00898 #endif // __OPAL_CHANNELS_H
00899 
00900 

Generated on Mon Sep 15 11:48:42 2008 for OPAL by  doxygen 1.5.1