Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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-2000 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  * $Log: channels.h,v $
00030  * Revision 1.41  2004/07/03 05:47:45  rjongbloed
00031  * Added virtual function for determining RTP payload type used in an H.323 channel,
00032  *    also some added bullet proofing for exception conditions, thanks Guilhem Tardy
00033  *
00034  * Revision 1.40  2002/09/16 01:14:15  robertj
00035  * Added #define so can select if #pragma interface/implementation is used on
00036  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00037  *
00038  * Revision 1.39  2002/09/03 06:19:36  robertj
00039  * Normalised the multi-include header prevention ifdef/define symbol.
00040  *
00041  * Revision 1.38  2002/08/05 10:03:47  robertj
00042  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00043  *
00044  * Revision 1.37  2002/06/25 08:30:08  robertj
00045  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00046  *   the OLC dataType silenceSuppression field so does not send SID frames
00047  *   to receiver codecs that do not understand them.
00048  *
00049  * Revision 1.36  2002/05/23 04:53:54  robertj
00050  * Added function to remove a filter from logical channel.
00051  *
00052  * Revision 1.35  2002/05/10 05:46:46  robertj
00053  * Added session ID to the data logical channel class.
00054  *
00055  * Revision 1.34  2002/05/02 07:56:24  robertj
00056  * Added automatic clearing of call if no media (RTP data) is transferred in a
00057  *   configurable (default 5 minutes) amount of time.
00058  *
00059  * Revision 1.33  2002/05/02 06:28:50  robertj
00060  * Fixed problem with external RTP channels not fast starting.
00061  *
00062  * Revision 1.32  2002/04/17 05:56:28  robertj
00063  * Added trace output of H323Channel::Direction enum.
00064  *
00065  * Revision 1.31  2002/02/09 04:39:01  robertj
00066  * Changes to allow T.38 logical channels to use single transport which is
00067  *   now owned by the OpalT38Protocol object instead of H323Channel.
00068  *
00069  * Revision 1.30  2002/02/05 08:13:20  robertj
00070  * Added ability to not have addresses when external RTP channel created.
00071  *
00072  * Revision 1.29  2002/01/22 22:48:21  robertj
00073  * Fixed RFC2833 support (transmitter) requiring large rewrite
00074  *
00075  * Revision 1.28  2002/01/17 07:04:57  robertj
00076  * Added support for RFC2833 embedded DTMF in the RTP stream.
00077  *
00078  * Revision 1.27  2002/01/17 00:10:37  robertj
00079  * Fixed double copy of rtpPayloadType in RTP channel, caused much confusion.
00080  *
00081  * Revision 1.26  2002/01/14 05:18:16  robertj
00082  * Fixed typo on external RTP channel constructor.
00083  *
00084  * Revision 1.25  2002/01/10 05:13:50  robertj
00085  * Added support for external RTP stacks, thanks NuMind Software Systems.
00086  *
00087  * Revision 1.24  2001/10/23 02:18:06  dereks
00088  * Initial release of CU30 video codec.
00089  *
00090  * Revision 1.23  2001/07/24 02:26:53  robertj
00091  * Added start for handling reverse channels.
00092  *
00093  * Revision 1.22  2001/07/17 04:44:29  robertj
00094  * Partial implementation of T.120 and T.38 logical channels.
00095  *
00096  * Revision 1.21  2001/02/09 05:16:24  robertj
00097  * Added #pragma interface for GNU C++.
00098  *
00099  * Revision 1.20  2001/01/25 07:27:14  robertj
00100  * Major changes to add more flexible OpalMediaFormat class to normalise
00101  *   all information about media types, especially codecs.
00102  *
00103  * Revision 1.19  2000/10/19 04:05:20  robertj
00104  * Added compare function for logical channel numbers, thanks Yuriy Ershov.
00105  *
00106  * Revision 1.18  2000/09/22 01:35:02  robertj
00107  * Added support for handling LID's that only do symmetric codecs.
00108  *
00109  * Revision 1.17  2000/08/31 08:15:32  robertj
00110  * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations.
00111  *
00112  * Revision 1.16  2000/08/21 02:50:19  robertj
00113  * Fixed race condition if close call just as slow start media channels are opening.
00114  *
00115  * Revision 1.15  2000/06/15 01:46:13  robertj
00116  * Added channel pause (aka mute) functions.
00117  *
00118  * Revision 1.14  2000/05/18 11:53:33  robertj
00119  * Changes to support doc++ documentation generation.
00120  *
00121  * Revision 1.13  2000/05/02 04:32:23  robertj
00122  * Fixed copyright notice comment.
00123  *
00124  * Revision 1.12  1999/12/23 23:02:34  robertj
00125  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00126  *
00127  * Revision 1.11  1999/11/19 09:06:30  robertj
00128  * Changed to close down logical channel if get a transmit codec error.
00129  *
00130  * Revision 1.10  1999/11/06 05:37:44  robertj
00131  * Complete rewrite of termination of connection to avoid numerous race conditions.
00132  *
00133  * Revision 1.9  1999/09/08 04:05:48  robertj
00134  * Added support for video capabilities & codec, still needs the actual codec itself!
00135  *
00136  * Revision 1.8  1999/08/31 12:34:18  robertj
00137  * Added gatekeeper support.
00138  *
00139  * Revision 1.7  1999/07/09 06:09:49  robertj
00140  * Major implementation. An ENORMOUS amount of stuff added everywhere.
00141  *
00142  * Revision 1.6  1999/06/14 05:15:55  robertj
00143  * Changes for using RTP sessions correctly in H323 Logical Channel context
00144  *
00145  * Revision 1.5  1999/06/13 12:41:14  robertj
00146  * Implement logical channel transmitter.
00147  * Fixed H245 connect on receiving call.
00148  *
00149  * Revision 1.4  1999/06/09 05:26:19  robertj
00150  * Major restructuring of classes.
00151  *
00152  * Revision 1.3  1999/06/06 06:06:36  robertj
00153  * Changes for new ASN compiler and v2 protocol ASN files.
00154  *
00155  * Revision 1.2  1999/04/26 06:14:46  craigs
00156  * Initial implementation for RTP decoding and lots of stuff
00157  * As a whole, these changes are called "First Noise"
00158  *
00159  * Revision 1.1  1999/01/16 01:31:07  robertj
00160  * Initial revision
00161  *
00162  */
00163 
00164 #ifndef __OPAL_CHANNELS_H
00165 #define __OPAL_CHANNELS_H
00166 
00167 #ifdef P_USE_PRAGMA
00168 #pragma interface
00169 #endif
00170 
00171 
00172 #include "rtp.h"
00173 #include "transports.h"
00174 
00175 
00176 class H245_OpenLogicalChannel;
00177 class H245_OpenLogicalChannelAck;
00178 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00179 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00180 class H245_H2250LogicalChannelParameters;
00181 class H245_H2250LogicalChannelAckParameters;
00182 class H245_MiscellaneousCommand_type;
00183 class H245_MiscellaneousIndication_type;
00184 
00185 class H323EndPoint;
00186 class H323Connection;
00187 class H323Capability;
00188 class H323Codec;
00189 class H323_RTP_Session;
00190 
00191 
00192 
00194 
00198 class H323ChannelNumber : public PObject
00199 {
00200   PCLASSINFO(H323ChannelNumber, PObject);
00201 
00202   public:
00203     H323ChannelNumber() { number = 0; fromRemote = FALSE; }
00204     H323ChannelNumber(unsigned number, BOOL fromRemote);
00205 
00206     virtual PObject * Clone() const;
00207     virtual PINDEX HashFunction() const;
00208     virtual void PrintOn(ostream & strm) const;
00209     virtual Comparison Compare(const PObject & obj) const;
00210 
00211     H323ChannelNumber & operator++(int);
00212     operator unsigned() const { return number; }
00213     BOOL IsFromRemote() const { return fromRemote; }
00214     
00215   protected:
00216     unsigned number;
00217     BOOL     fromRemote;
00218 };
00219 
00220 
00227 class H323Channel : public PObject
00228 {
00229   PCLASSINFO(H323Channel, PObject);
00230 
00231   public:
00236     H323Channel(
00237       H323Connection & connection,        
00238       const H323Capability & capability   
00239     );
00240 
00245     ~H323Channel();
00247 
00250     virtual void PrintOn(
00251       ostream & strm
00252     ) const;
00254 
00257     enum Directions {
00258       IsBidirectional,
00259       IsTransmitter,
00260       IsReceiver,
00261       NumDirections
00262     };
00263 #if PTRACING
00264     friend ostream & operator<<(ostream & out, Directions dir);
00265 #endif
00266 
00271     virtual Directions GetDirection() const = 0;
00272 
00278     virtual unsigned GetSessionID() const;
00279 
00287     virtual BOOL SetInitialBandwidth();
00288 
00293     virtual BOOL Open();
00294 
00297     virtual BOOL Start() = 0;
00298 
00301     virtual void CleanUpOnTermination();
00302 
00305     virtual BOOL IsRunning() const;
00306 
00313     virtual void Receive() = 0;
00314 
00321     virtual void Transmit() = 0;
00322 
00325     virtual BOOL OnSendingPDU(
00326       H245_OpenLogicalChannel & openPDU  
00327     ) const = 0;
00328 
00334     virtual void OnSendOpenAck(
00335       const H245_OpenLogicalChannel & open,   
00336       H245_OpenLogicalChannelAck & ack        
00337     ) const;
00338 
00345     virtual BOOL OnReceivedPDU(
00346       const H245_OpenLogicalChannel & pdu,    
00347       unsigned & errorCode                    
00348     );
00349 
00356     virtual BOOL OnReceivedAckPDU(
00357       const H245_OpenLogicalChannelAck & pdu  
00358     );
00359 
00363     virtual void OnFlowControl(
00364       long bitRateRestriction   
00365     );
00366 
00370     virtual void OnMiscellaneousCommand(
00371       const H245_MiscellaneousCommand_type & type  
00372     );
00373 
00377     virtual void OnMiscellaneousIndication(
00378       const H245_MiscellaneousIndication_type & type  
00379     );
00380 
00384     virtual void OnJitterIndication(
00385       DWORD jitter,           
00386       int skippedFrameCount,  
00387       int additionalBuffer    
00388     );
00389 
00394     void SendMiscCommand(unsigned command);
00396 
00401     const H323ChannelNumber & GetNumber() const { return number; }
00402 
00405     void SetNumber(const H323ChannelNumber & num) { number = num; }
00406 
00409     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00410 
00413     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00414 
00417     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00418 
00421     BOOL SetBandwidthUsed(
00422       unsigned bandwidth  
00423     );
00424 
00427     const H323Capability & GetCapability() const { return *capability; }
00428 
00431     H323Codec * GetCodec() const;
00432 
00441     BOOL IsPaused() const { return paused; }
00442 
00451     void SetPause(
00452       BOOL pause   
00453     ) { paused = pause; }
00455 
00456   protected:
00457     H323EndPoint         & endpoint;
00458     H323Connection       & connection;
00459     H323Capability       * capability;
00460     H323ChannelNumber      number;
00461     H323ChannelNumber      reverseChannel;
00462     H323Codec            * codec;
00463     PThread              * receiveThread;
00464     PThread              * transmitThread;
00465     BOOL                   opened;
00466     BOOL                   paused;
00467     BOOL                   terminating;
00468 
00469   private:
00470     unsigned bandwidthUsed;
00471 };
00472 
00473 
00474 PLIST(H323LogicalChannelList, H323Channel);
00475 
00476 
00477 
00484 class H323UnidirectionalChannel : public H323Channel
00485 {
00486   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00487 
00488   public:
00493     H323UnidirectionalChannel(
00494       H323Connection & connection,        
00495       const H323Capability & capability,  
00496       Directions direction                
00497     );
00499 
00506     virtual Directions GetDirection() const;
00507 
00512     virtual BOOL Start();
00514 
00515   protected:
00516     BOOL receiver;
00517 };
00518 
00519 
00526 class H323BidirectionalChannel : public H323Channel
00527 {
00528   PCLASSINFO(H323BidirectionalChannel, H323Channel);
00529 
00530   public:
00535     H323BidirectionalChannel(
00536       H323Connection & connection,        
00537       const H323Capability & capability   
00538     );
00540 
00547     virtual Directions GetDirection() const;
00548 
00553     virtual BOOL Start();
00555 };
00556 
00557 
00559 
00562 class H323_RealTimeChannel : public H323UnidirectionalChannel
00563 {
00564   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00565 
00566   public:
00571     H323_RealTimeChannel(
00572       H323Connection & connection,        
00573       const H323Capability & capability,  
00574       Directions direction                
00575     );
00577 
00582     virtual BOOL OnSendingPDU(
00583       H245_OpenLogicalChannel & openPDU  
00584     ) const;
00585 
00589     virtual void OnSendOpenAck(
00590       const H245_OpenLogicalChannel & open,   
00591       H245_OpenLogicalChannelAck & ack        
00592     ) const;
00593 
00601     virtual BOOL OnReceivedPDU(
00602       const H245_OpenLogicalChannel & pdu,    
00603       unsigned & errorCode                    
00604     );
00605 
00613     virtual BOOL OnReceivedAckPDU(
00614       const H245_OpenLogicalChannelAck & pdu 
00615     );
00617 
00622     virtual BOOL OnSendingPDU(
00623       H245_H2250LogicalChannelParameters & param  
00624     ) const = 0;
00625 
00629     virtual void OnSendOpenAck(
00630       H245_H2250LogicalChannelAckParameters & param 
00631     ) const = 0;
00632 
00639     virtual BOOL OnReceivedPDU(
00640       const H245_H2250LogicalChannelParameters & param, 
00641       unsigned & errorCode                              
00642     ) = 0;
00643 
00650     virtual BOOL OnReceivedAckPDU(
00651       const H245_H2250LogicalChannelAckParameters & param 
00652     ) = 0;
00653 
00658     virtual RTP_DataFrame::PayloadTypes GetRTPPayloadType() const;
00659 
00662     virtual BOOL SetDynamicRTPPayloadType(
00663       int newType  
00664     );
00666 
00667   protected:
00668     RTP_DataFrame::PayloadTypes rtpPayloadType;
00669 };
00670 
00671 
00673 
00676 class H323_RTPChannel : public H323_RealTimeChannel
00677 {
00678   PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00679 
00680   public:
00685     H323_RTPChannel(
00686       H323Connection & connection,        
00687       const H323Capability & capability,  
00688       Directions direction,               
00689       RTP_Session & rtp                   
00690     );
00691 
00693     ~H323_RTPChannel();
00695 
00700     virtual void CleanUpOnTermination();
00701 
00706     virtual unsigned GetSessionID() const;
00707 
00710     virtual BOOL Open();
00711 
00718     virtual void Receive();
00719 
00726     virtual void Transmit();
00728 
00733     virtual BOOL OnSendingPDU(
00734       H245_H2250LogicalChannelParameters & param  
00735     ) const;
00736 
00740     virtual void OnSendOpenAck(
00741       H245_H2250LogicalChannelAckParameters & param 
00742     ) const;
00743 
00750     virtual BOOL OnReceivedPDU(
00751       const H245_H2250LogicalChannelParameters & param, 
00752       unsigned & errorCode                              
00753     );
00754 
00761     virtual BOOL OnReceivedAckPDU(
00762       const H245_H2250LogicalChannelAckParameters & param 
00763     );
00765 
00766     void AddFilter(
00767       const PNotifier & filterFunction
00768     );
00769     void RemoveFilter(
00770       const PNotifier & filterFunction
00771     );
00772 
00773     PTimeInterval GetSilenceDuration() const;
00774 
00775 
00776   protected:
00777     RTP_Session      & rtpSession;
00778     H323_RTP_Session & rtpCallbacks;
00779 
00780     PLIST(FilterList, PNotifier);
00781     FilterList filters;
00782     PMutex     filterMutex;
00783 
00784     PTimeInterval silenceStartTick;
00785 };
00786 
00787 
00789 
00793 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00794 {
00795   PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00796 
00797   public:
00802     H323_ExternalRTPChannel(
00803       H323Connection & connection,        
00804       const H323Capability & capability,  
00805       Directions direction,               
00806       unsigned sessionID                  
00807     );
00810     H323_ExternalRTPChannel(
00811       H323Connection & connection,        
00812       const H323Capability & capability,  
00813       Directions direction,               
00814       unsigned sessionID,                 
00815       const H323TransportAddress & data,  
00816       const H323TransportAddress & control
00817     );
00820     H323_ExternalRTPChannel(
00821       H323Connection & connection,        
00822       const H323Capability & capability,  
00823       Directions direction,               
00824       unsigned sessionID,                 
00825       const PIPSocket::Address & ip,      
00826       WORD dataPort                       
00827     );
00829 
00836     virtual unsigned GetSessionID() const;
00837 
00840     virtual BOOL Start();
00841 
00844     virtual BOOL IsRunning() const;
00845 
00852     virtual void Receive();
00853 
00860     virtual void Transmit();
00862 
00867     virtual BOOL OnSendingPDU(
00868       H245_H2250LogicalChannelParameters & param  
00869     ) const;
00870 
00874     virtual void OnSendOpenAck(
00875       H245_H2250LogicalChannelAckParameters & param 
00876     ) const;
00877 
00884     virtual BOOL OnReceivedPDU(
00885       const H245_H2250LogicalChannelParameters & param, 
00886       unsigned & errorCode                              
00887     );
00888 
00895     virtual BOOL OnReceivedAckPDU(
00896       const H245_H2250LogicalChannelAckParameters & param 
00897     );
00899 
00900     void SetExternalAddress(
00901       const H323TransportAddress & data,  
00902       const H323TransportAddress & control
00903     );
00904 
00905     const H323TransportAddress & GetRemoteMediaAddress()        const { return remoteMediaAddress; }
00906     const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00907 
00908     BOOL GetRemoteAddress(
00909       PIPSocket::Address & ip,
00910       WORD & dataPort
00911     ) const;
00912 
00913   protected:
00914     unsigned             sessionID;
00915     H323TransportAddress externalMediaAddress;
00916     H323TransportAddress externalMediaControlAddress;
00917     H323TransportAddress remoteMediaAddress;
00918     H323TransportAddress remoteMediaControlAddress;
00919 
00920     BOOL isRunning;
00921 };
00922 
00923 
00925 
00932 class H323DataChannel : public H323UnidirectionalChannel
00933 {
00934   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00935 
00936   public:
00941     H323DataChannel(
00942       H323Connection & connection,        
00943       const H323Capability & capability,  
00944       Directions direction,               
00945       unsigned sessionID                  
00946     );
00947 
00950     ~H323DataChannel();
00952 
00957     virtual void CleanUpOnTermination();
00958 
00963     virtual unsigned GetSessionID() const;
00964 
00967     virtual BOOL OnSendingPDU(
00968       H245_OpenLogicalChannel & openPDU  
00969     ) const;
00970 
00974     virtual void OnSendOpenAck(
00975       const H245_OpenLogicalChannel & open,   
00976       H245_OpenLogicalChannelAck & ack        
00977     ) const;
00978 
00986     virtual BOOL OnReceivedPDU(
00987       const H245_OpenLogicalChannel & pdu,    
00988       unsigned & errorCode                    
00989     );
00990 
00998     virtual BOOL OnReceivedAckPDU(
00999       const H245_OpenLogicalChannelAck & pdu 
01000     );
01002 
01011     virtual BOOL CreateListener();
01012 
01020     virtual BOOL CreateTransport();
01022 
01023   protected:
01024     unsigned        sessionID;
01025     H323Listener  * listener;
01026     BOOL            autoDeleteListener;
01027     H323Transport * transport;
01028     BOOL            autoDeleteTransport;
01029     BOOL            separateReverseChannel;
01030 };
01031 
01032 
01033 #endif // __OPAL_CHANNELS_H
01034 
01035 

Generated on Sat Mar 5 14:58:49 2005 for OpenH323 by  doxygen 1.4.1