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: 21004 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-09-16 07:08:56 +0000 (Tue, 16 Sep 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 #include <opal/buildopts.h>
00042 
00043 #include <rtp/rtp.h>
00044 #include <h323/transaddr.h>
00045 #include <opal/mediastrm.h>
00046 
00047 
00048 class H245_OpenLogicalChannel;
00049 class H245_OpenLogicalChannelAck;
00050 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00051 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00052 class H245_H2250LogicalChannelParameters;
00053 class H245_H2250LogicalChannelAckParameters;
00054 class H245_MiscellaneousCommand_type;
00055 class H245_MiscellaneousIndication_type;
00056 
00057 class H323EndPoint;
00058 class H323Connection;
00059 class H323Capability;
00060 class H323_RTP_Session;
00061 
00062 
00064 
00068 class H323ChannelNumber : public PObject
00069 {
00070   PCLASSINFO(H323ChannelNumber, PObject);
00071 
00072   public:
00073     H323ChannelNumber() { number = 0; fromRemote = PFalse; }
00074     H323ChannelNumber(unsigned number, PBoolean fromRemote);
00075 
00076     virtual PObject * Clone() const;
00077     virtual PINDEX HashFunction() const;
00078     virtual void PrintOn(ostream & strm) const;
00079     virtual Comparison Compare(const PObject & obj) const;
00080 
00081     H323ChannelNumber & operator++(int);
00082     operator unsigned() const { return number; }
00083     PBoolean IsFromRemote() const { return fromRemote; }
00084     
00085   protected:
00086     unsigned number;
00087     PBoolean     fromRemote;
00088 };
00089 
00090 
00097 class H323Channel : public PObject
00098 {
00099   PCLASSINFO(H323Channel, PObject);
00100 
00101   public:
00106     H323Channel(
00107       H323Connection & connection,        
00108       const H323Capability & capability   
00109     );
00110 
00115     ~H323Channel();
00117 
00120     virtual void PrintOn(
00121       ostream & strm
00122     ) const;
00124 
00127     enum Directions {
00128       IsBidirectional,
00129       IsTransmitter,
00130       IsReceiver,
00131       NumDirections
00132     };
00133 #if PTRACING
00134     friend ostream & operator<<(ostream & out, Directions dir);
00135 #endif
00136 
00141     virtual Directions GetDirection() const = 0;
00142 
00148     virtual unsigned GetSessionID() const;
00149 
00156     virtual PBoolean GetMediaTransportAddress(
00157       OpalTransportAddress & data,        
00158       OpalTransportAddress & control      
00159     ) const;
00160 
00168     virtual PBoolean SetInitialBandwidth() = 0;
00169 
00174     virtual PBoolean Open();
00175 
00178     virtual PBoolean Start() = 0;
00179 
00182     virtual void Close();
00183 
00186     PBoolean IsOpen() const { return opened && !terminating; }
00187 
00195     virtual OpalMediaStreamPtr GetMediaStream() const;
00196 
00197 
00200     virtual PBoolean OnSendingPDU(
00201       H245_OpenLogicalChannel & openPDU  
00202     ) const = 0;
00203 
00209     virtual void OnSendOpenAck(
00210       const H245_OpenLogicalChannel & open,   
00211       H245_OpenLogicalChannelAck & ack        
00212     ) const;
00213 
00220     virtual PBoolean OnReceivedPDU(
00221       const H245_OpenLogicalChannel & pdu,    
00222       unsigned & errorCode                    
00223     );
00224 
00231     virtual PBoolean OnReceivedAckPDU(
00232       const H245_OpenLogicalChannelAck & pdu  
00233     );
00234 
00238     virtual void OnFlowControl(
00239       long bitRateRestriction   
00240     );
00241 
00245     virtual void OnMiscellaneousCommand(
00246       const H245_MiscellaneousCommand_type & type  
00247     );
00248 
00252     virtual void OnMiscellaneousIndication(
00253       const H245_MiscellaneousIndication_type & type  
00254     );
00255 
00259     virtual void OnJitterIndication(
00260       DWORD jitter,           
00261       int skippedFrameCount,  
00262       int additionalBuffer    
00263     );
00265 
00270     const H323ChannelNumber & GetNumber() const { return number; }
00271 
00274     void SetNumber(const H323ChannelNumber & num) { number = num; }
00275 
00278     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00279 
00282     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00283 
00286     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00287 
00290     PBoolean SetBandwidthUsed(
00291       unsigned bandwidth  
00292     );
00293 
00296     const H323Capability & GetCapability() const { return *capability; }
00297 
00306     PBoolean IsPaused() const { return paused; }
00307 
00316     void SetPause(
00317       PBoolean pause   
00318     ) { paused = pause; }
00320 
00321     virtual void OnMediaCommand(OpalMediaCommand &) { }
00322 
00323   protected:
00324     H323EndPoint         & endpoint;
00325     H323Connection       & connection;
00326     H323Capability       * capability;
00327     H323ChannelNumber      number;
00328     H323ChannelNumber      reverseChannel;
00329     PBoolean                   opened;
00330     PBoolean                   paused;
00331     PBoolean                   terminating;
00332 
00333   private:
00334     unsigned bandwidthUsed;
00335 };
00336 
00337 
00338 PLIST(H323LogicalChannelList, H323Channel);
00339 
00340 
00341 
00348 class H323UnidirectionalChannel : public H323Channel
00349 {
00350   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00351 
00352   public:
00357     H323UnidirectionalChannel(
00358       H323Connection & connection,        
00359       const H323Capability & capability,  
00360       Directions direction                
00361     );
00362 
00365     ~H323UnidirectionalChannel();
00367 
00374     virtual Directions GetDirection() const;
00375 
00383     virtual PBoolean SetInitialBandwidth();
00384 
00387     virtual PBoolean Open();
00388 
00393     virtual PBoolean Start();
00394 
00397     virtual void Close();
00398 
00402     virtual void OnMiscellaneousCommand(
00403       const H245_MiscellaneousCommand_type & type  
00404     );
00406 
00412     virtual OpalMediaStreamPtr GetMediaStream() const;
00414 
00415     void OnMediaCommand(OpalMediaCommand & command);
00416 
00417   protected:
00418     bool               receiver;
00419     OpalMediaStreamPtr mediaStream;
00420 };
00421 
00422 
00429 class H323BidirectionalChannel : public H323Channel
00430 {
00431   PCLASSINFO(H323BidirectionalChannel, H323Channel);
00432 
00433   public:
00438     H323BidirectionalChannel(
00439       H323Connection & connection,        
00440       const H323Capability & capability   
00441     );
00443 
00450     virtual Directions GetDirection() const;
00451 
00456     virtual PBoolean Start();
00458 };
00459 
00460 
00462 
00465 class H323_RealTimeChannel : public H323UnidirectionalChannel
00466 {
00467   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00468 
00469   public:
00474     H323_RealTimeChannel(
00475       H323Connection & connection,        
00476       const H323Capability & capability,  
00477       Directions direction                
00478     );
00480 
00485     virtual PBoolean OnSendingPDU(
00486       H245_OpenLogicalChannel & openPDU  
00487     ) const;
00488 
00492     virtual void OnSendOpenAck(
00493       const H245_OpenLogicalChannel & open,   
00494       H245_OpenLogicalChannelAck & ack        
00495     ) const;
00496 
00504     virtual PBoolean OnReceivedPDU(
00505       const H245_OpenLogicalChannel & pdu,    
00506       unsigned & errorCode                    
00507     );
00508 
00516     virtual PBoolean OnReceivedAckPDU(
00517       const H245_OpenLogicalChannelAck & pdu 
00518     );
00520 
00525     virtual PBoolean OnSendingPDU(
00526       H245_H2250LogicalChannelParameters & param  
00527     ) const = 0;
00528 
00532     virtual void OnSendOpenAck(
00533       H245_H2250LogicalChannelAckParameters & param 
00534     ) const = 0;
00535 
00542     virtual PBoolean OnReceivedPDU(
00543       const H245_H2250LogicalChannelParameters & param, 
00544       unsigned & errorCode                              
00545     ) = 0;
00546 
00553     virtual PBoolean OnReceivedAckPDU(
00554       const H245_H2250LogicalChannelAckParameters & param 
00555     ) = 0;
00556 
00559     virtual PBoolean SetDynamicRTPPayloadType(
00560       int newType  
00561     );
00562 
00563     RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00565 
00566   protected:
00567     RTP_DataFrame::PayloadTypes rtpPayloadType;
00568 };
00569 
00570 
00572 
00575 class H323_RTPChannel : public H323_RealTimeChannel
00576 {
00577   PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00578 
00579   public:
00584     H323_RTPChannel(
00585       H323Connection & connection,        
00586       const H323Capability & capability,  
00587       Directions direction,               
00588       RTP_Session & rtp                   
00589     );
00590 
00592     ~H323_RTPChannel();
00594 
00601     virtual unsigned GetSessionID() const;
00603 
00608     virtual PBoolean OnSendingPDU(
00609       H245_H2250LogicalChannelParameters & param  
00610     ) const;
00611 
00615     virtual void OnSendOpenAck(
00616       H245_H2250LogicalChannelAckParameters & param 
00617     ) const;
00618 
00625     virtual PBoolean OnReceivedPDU(
00626       const H245_H2250LogicalChannelParameters & param, 
00627       unsigned & errorCode                              
00628     );
00629 
00636     virtual PBoolean OnReceivedAckPDU(
00637       const H245_H2250LogicalChannelAckParameters & param 
00638     );
00640 
00641   protected:
00642     RTP_Session      & rtpSession;
00643     H323_RTP_Session & rtpCallbacks;
00644 };
00645 
00646 
00648 
00652 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00653 {
00654   PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00655 
00656   public:
00661     H323_ExternalRTPChannel(
00662       H323Connection & connection,        
00663       const H323Capability & capability,  
00664       Directions direction,               
00665       unsigned sessionID                  
00666     );
00669     H323_ExternalRTPChannel(
00670       H323Connection & connection,        
00671       const H323Capability & capability,  
00672       Directions direction,               
00673       unsigned sessionID,                 
00674       const H323TransportAddress & data,  
00675       const H323TransportAddress & control
00676     );
00679     H323_ExternalRTPChannel(
00680       H323Connection & connection,        
00681       const H323Capability & capability,  
00682       Directions direction,               
00683       unsigned sessionID,                 
00684       const PIPSocket::Address & ip,      
00685       WORD dataPort                       
00686     );
00688 
00695     virtual unsigned GetSessionID() const;
00696 
00703     virtual PBoolean GetMediaTransportAddress(
00704       OpalTransportAddress & data,        
00705       OpalTransportAddress & control      
00706     ) const;
00707 
00710     virtual PBoolean Start();
00711 
00718     virtual void Receive();
00719 
00726     virtual void Transmit();
00728 
00733     virtual PBoolean OnSendingPDU(
00734       H245_H2250LogicalChannelParameters & param  
00735     ) const;
00736 
00740     virtual void OnSendOpenAck(
00741       H245_H2250LogicalChannelAckParameters & param 
00742     ) const;
00743 
00750     virtual PBoolean OnReceivedPDU(
00751       const H245_H2250LogicalChannelParameters & param, 
00752       unsigned & errorCode                              
00753     );
00754 
00761     virtual PBoolean OnReceivedAckPDU(
00762       const H245_H2250LogicalChannelAckParameters & param 
00763     );
00765 
00766     void SetExternalAddress(
00767       const H323TransportAddress & data,  
00768       const H323TransportAddress & control
00769     );
00770 
00771     const H323TransportAddress & GetRemoteMediaAddress()        const { return remoteMediaAddress; }
00772     const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00773 
00774     PBoolean GetRemoteAddress(
00775       PIPSocket::Address & ip,
00776       WORD & dataPort
00777     ) const;
00778 
00779   protected:
00780     void Construct(H323Connection & conn, unsigned id);
00781 
00782     unsigned             sessionID;
00783     H323TransportAddress externalMediaAddress;
00784     H323TransportAddress externalMediaControlAddress;
00785     H323TransportAddress remoteMediaAddress;
00786     H323TransportAddress remoteMediaControlAddress;
00787 };
00788 
00789 
00791 
00798 class H323DataChannel : public H323UnidirectionalChannel
00799 {
00800   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00801 
00802   public:
00807     H323DataChannel(
00808       H323Connection & connection,        
00809       const H323Capability & capability,  
00810       Directions direction,               
00811       unsigned sessionID                  
00812     );
00813 
00816     ~H323DataChannel();
00818 
00823     virtual void Close();
00824 
00829     virtual unsigned GetSessionID() const;
00830 
00833     virtual PBoolean OnSendingPDU(
00834       H245_OpenLogicalChannel & openPDU  
00835     ) const;
00836 
00840     virtual void OnSendOpenAck(
00841       const H245_OpenLogicalChannel & open,   
00842       H245_OpenLogicalChannelAck & ack        
00843     ) const;
00844 
00852     virtual PBoolean OnReceivedPDU(
00853       const H245_OpenLogicalChannel & pdu,    
00854       unsigned & errorCode                    
00855     );
00856 
00864     virtual PBoolean OnReceivedAckPDU(
00865       const H245_OpenLogicalChannelAck & pdu 
00866     );
00868 
00877     virtual PBoolean CreateListener();
00878 
00886     virtual PBoolean CreateTransport();
00888 
00889   protected:
00890     unsigned        sessionID;
00891     H323Listener  * listener;
00892     PBoolean            autoDeleteListener;
00893     H323Transport * transport;
00894     PBoolean            autoDeleteTransport;
00895     PBoolean            separateReverseChannel;
00896 };
00897 
00898 
00899 #endif // __OPAL_CHANNELS_H
00900 
00901 

Generated on Mon Sep 22 12:24:21 2008 for OPAL by  doxygen 1.5.1