D:/Storage/CVS_Head/h323plus/include/channels.h

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.1  2007/08/06 20:50:48  shorne
00031  * First commit of h323plus
00032  *
00033  * Revision 1.42.4.1  2007/05/23 06:58:01  shorne
00034  * Nat Support for EP's nested behind same NAT
00035  *
00036  * Revision 1.42  2005/11/30 13:05:00  csoutheren
00037  * Changed tags for Doxygen
00038  *
00039  * Revision 1.41  2004/07/03 05:47:45  rjongbloed
00040  * Added virtual function for determining RTP payload type used in an H.323 channel,
00041  *    also some added bullet proofing for exception conditions, thanks Guilhem Tardy
00042  *
00043  * Revision 1.40  2002/09/16 01:14:15  robertj
00044  * Added #define so can select if #pragma interface/implementation is used on
00045  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00046  *
00047  * Revision 1.39  2002/09/03 06:19:36  robertj
00048  * Normalised the multi-include header prevention ifdef/define symbol.
00049  *
00050  * Revision 1.38  2002/08/05 10:03:47  robertj
00051  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00052  *
00053  * Revision 1.37  2002/06/25 08:30:08  robertj
00054  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00055  *   the OLC dataType silenceSuppression field so does not send SID frames
00056  *   to receiver codecs that do not understand them.
00057  *
00058  * Revision 1.36  2002/05/23 04:53:54  robertj
00059  * Added function to remove a filter from logical channel.
00060  *
00061  * Revision 1.35  2002/05/10 05:46:46  robertj
00062  * Added session ID to the data logical channel class.
00063  *
00064  * Revision 1.34  2002/05/02 07:56:24  robertj
00065  * Added automatic clearing of call if no media (RTP data) is transferred in a
00066  *   configurable (default 5 minutes) amount of time.
00067  *
00068  * Revision 1.33  2002/05/02 06:28:50  robertj
00069  * Fixed problem with external RTP channels not fast starting.
00070  *
00071  * Revision 1.32  2002/04/17 05:56:28  robertj
00072  * Added trace output of H323Channel::Direction enum.
00073  *
00074  * Revision 1.31  2002/02/09 04:39:01  robertj
00075  * Changes to allow T.38 logical channels to use single transport which is
00076  *   now owned by the OpalT38Protocol object instead of H323Channel.
00077  *
00078  * Revision 1.30  2002/02/05 08:13:20  robertj
00079  * Added ability to not have addresses when external RTP channel created.
00080  *
00081  * Revision 1.29  2002/01/22 22:48:21  robertj
00082  * Fixed RFC2833 support (transmitter) requiring large rewrite
00083  *
00084  * Revision 1.28  2002/01/17 07:04:57  robertj
00085  * Added support for RFC2833 embedded DTMF in the RTP stream.
00086  *
00087  * Revision 1.27  2002/01/17 00:10:37  robertj
00088  * Fixed double copy of rtpPayloadType in RTP channel, caused much confusion.
00089  *
00090  * Revision 1.26  2002/01/14 05:18:16  robertj
00091  * Fixed typo on external RTP channel constructor.
00092  *
00093  * Revision 1.25  2002/01/10 05:13:50  robertj
00094  * Added support for external RTP stacks, thanks NuMind Software Systems.
00095  *
00096  * Revision 1.24  2001/10/23 02:18:06  dereks
00097  * Initial release of CU30 video codec.
00098  *
00099  * Revision 1.23  2001/07/24 02:26:53  robertj
00100  * Added start for handling reverse channels.
00101  *
00102  * Revision 1.22  2001/07/17 04:44:29  robertj
00103  * Partial implementation of T.120 and T.38 logical channels.
00104  *
00105  * Revision 1.21  2001/02/09 05:16:24  robertj
00106  * Added #pragma interface for GNU C++.
00107  *
00108  * Revision 1.20  2001/01/25 07:27:14  robertj
00109  * Major changes to add more flexible OpalMediaFormat class to normalise
00110  *   all information about media types, especially codecs.
00111  *
00112  * Revision 1.19  2000/10/19 04:05:20  robertj
00113  * Added compare function for logical channel numbers, thanks Yuriy Ershov.
00114  *
00115  * Revision 1.18  2000/09/22 01:35:02  robertj
00116  * Added support for handling LID's that only do symmetric codecs.
00117  *
00118  * Revision 1.17  2000/08/31 08:15:32  robertj
00119  * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations.
00120  *
00121  * Revision 1.16  2000/08/21 02:50:19  robertj
00122  * Fixed race condition if close call just as slow start media channels are opening.
00123  *
00124  * Revision 1.15  2000/06/15 01:46:13  robertj
00125  * Added channel pause (aka mute) functions.
00126  *
00127  * Revision 1.14  2000/05/18 11:53:33  robertj
00128  * Changes to support doc++ documentation generation.
00129  *
00130  * Revision 1.13  2000/05/02 04:32:23  robertj
00131  * Fixed copyright notice comment.
00132  *
00133  * Revision 1.12  1999/12/23 23:02:34  robertj
00134  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00135  *
00136  * Revision 1.11  1999/11/19 09:06:30  robertj
00137  * Changed to close down logical channel if get a transmit codec error.
00138  *
00139  * Revision 1.10  1999/11/06 05:37:44  robertj
00140  * Complete rewrite of termination of connection to avoid numerous race conditions.
00141  *
00142  * Revision 1.9  1999/09/08 04:05:48  robertj
00143  * Added support for video capabilities & codec, still needs the actual codec itself!
00144  *
00145  * Revision 1.8  1999/08/31 12:34:18  robertj
00146  * Added gatekeeper support.
00147  *
00148  * Revision 1.7  1999/07/09 06:09:49  robertj
00149  * Major implementation. An ENORMOUS amount of stuff added everywhere.
00150  *
00151  * Revision 1.6  1999/06/14 05:15:55  robertj
00152  * Changes for using RTP sessions correctly in H323 Logical Channel context
00153  *
00154  * Revision 1.5  1999/06/13 12:41:14  robertj
00155  * Implement logical channel transmitter.
00156  * Fixed H245 connect on receiving call.
00157  *
00158  * Revision 1.4  1999/06/09 05:26:19  robertj
00159  * Major restructuring of classes.
00160  *
00161  * Revision 1.3  1999/06/06 06:06:36  robertj
00162  * Changes for new ASN compiler and v2 protocol ASN files.
00163  *
00164  * Revision 1.2  1999/04/26 06:14:46  craigs
00165  * Initial implementation for RTP decoding and lots of stuff
00166  * As a whole, these changes are called "First Noise"
00167  *
00168  * Revision 1.1  1999/01/16 01:31:07  robertj
00169  * Initial revision
00170  *
00171  */
00172 
00173 #ifndef __OPAL_CHANNELS_H
00174 #define __OPAL_CHANNELS_H
00175 
00176 #ifdef P_USE_PRAGMA
00177 #pragma interface
00178 #endif
00179 
00180 
00181 #include "rtp.h"
00182 #include "transports.h"
00183 
00184 
00185 class H245_OpenLogicalChannel;
00186 class H245_OpenLogicalChannelAck;
00187 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00188 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00189 class H245_H2250LogicalChannelParameters;
00190 class H245_H2250LogicalChannelAckParameters;
00191 class H245_ArrayOf_GenericInformation;
00192 class H245_MiscellaneousCommand_type;
00193 class H245_MiscellaneousIndication_type;
00194 
00195 class H323EndPoint;
00196 class H323Connection;
00197 class H323Capability;
00198 class H323Codec;
00199 class H323_RTP_Session;
00200 
00201 
00202 
00204 
00208 class H323ChannelNumber : public PObject
00209 {
00210   PCLASSINFO(H323ChannelNumber, PObject);
00211 
00212   public:
00213     H323ChannelNumber() { number = 0; fromRemote = FALSE; }
00214     H323ChannelNumber(unsigned number, BOOL fromRemote);
00215 
00216     virtual PObject * Clone() const;
00217     virtual PINDEX HashFunction() const;
00218     virtual void PrintOn(ostream & strm) const;
00219     virtual Comparison Compare(const PObject & obj) const;
00220 
00221     H323ChannelNumber & operator++(int);
00222     operator unsigned() const { return number; }
00223     BOOL IsFromRemote() const { return fromRemote; }
00224     
00225   protected:
00226     unsigned number;
00227     BOOL     fromRemote;
00228 };
00229 
00230 
00237 class H323Channel : public PObject
00238 {
00239   PCLASSINFO(H323Channel, PObject);
00240 
00241   public:
00246     H323Channel(
00247       H323Connection & connection,        
00248       const H323Capability & capability   
00249     );
00250 
00255     ~H323Channel();
00257 
00260     virtual void PrintOn(
00261       ostream & strm
00262     ) const;
00264 
00267     enum Directions {
00268       IsBidirectional,
00269       IsTransmitter,
00270       IsReceiver,
00271       NumDirections
00272     };
00273 #if PTRACING
00274     friend ostream & operator<<(ostream & out, Directions dir);
00275 #endif
00276 
00281     virtual Directions GetDirection() const = 0;
00282 
00288     virtual unsigned GetSessionID() const;
00289 
00297     virtual BOOL SetInitialBandwidth();
00298 
00303     virtual BOOL Open();
00304 
00307     virtual BOOL Start() = 0;
00308 
00311     virtual void CleanUpOnTermination();
00312 
00315     virtual BOOL IsRunning() const;
00316 
00323     virtual void Receive() = 0;
00324 
00331     virtual void Transmit() = 0;
00332 
00335     virtual BOOL OnSendingPDU(
00336       H245_OpenLogicalChannel & openPDU  
00337     ) const = 0;
00338 
00344     virtual void OnSendOpenAck(
00345       const H245_OpenLogicalChannel & open,   
00346       H245_OpenLogicalChannelAck & ack        
00347     ) const;
00348 
00355     virtual BOOL OnReceivedPDU(
00356       const H245_OpenLogicalChannel & pdu,    
00357       unsigned & errorCode                    
00358     );
00359 
00366     virtual BOOL OnReceivedAckPDU(
00367       const H245_OpenLogicalChannelAck & pdu  
00368     );
00369 
00373     virtual void OnFlowControl(
00374       long bitRateRestriction   
00375     );
00376 
00380     virtual void OnMiscellaneousCommand(
00381       const H245_MiscellaneousCommand_type & type  
00382     );
00383 
00387     virtual void OnMiscellaneousIndication(
00388       const H245_MiscellaneousIndication_type & type  
00389     );
00390 
00394     virtual void OnJitterIndication(
00395       DWORD jitter,           
00396       int skippedFrameCount,  
00397       int additionalBuffer    
00398     );
00399 
00404     void SendMiscCommand(unsigned command);
00406 
00411     const H323ChannelNumber & GetNumber() const { return number; }
00412 
00415     void SetNumber(const H323ChannelNumber & num) { number = num; }
00416 
00419     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00420 
00423     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00424 
00427     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00428 
00431     BOOL SetBandwidthUsed(
00432       unsigned bandwidth  
00433     );
00434 
00437     const H323Capability & GetCapability() const { return *capability; }
00438 
00441     H323Codec * GetCodec() const;
00442 
00451     BOOL IsPaused() const { return paused; }
00452 
00461     void SetPause(
00462       BOOL pause   
00463     ) { paused = pause; }
00465 
00466   protected:
00467     H323EndPoint         & endpoint;
00468     H323Connection       & connection;
00469     H323Capability       * capability;
00470     H323ChannelNumber      number;
00471     H323ChannelNumber      reverseChannel;
00472     H323Codec            * codec;
00473     PThread              * receiveThread;
00474     PThread              * transmitThread;
00475     BOOL                   opened;
00476     BOOL                   paused;
00477     BOOL                   terminating;
00478 
00479   private:
00480     unsigned bandwidthUsed;
00481 };
00482 
00483 
00484 PLIST(H323LogicalChannelList, H323Channel);
00485 
00486 
00487 
00494 class H323UnidirectionalChannel : public H323Channel
00495 {
00496   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00497 
00498   public:
00503     H323UnidirectionalChannel(
00504       H323Connection & connection,        
00505       const H323Capability & capability,  
00506       Directions direction                
00507     );
00509 
00516     virtual Directions GetDirection() const;
00517 
00522     virtual BOOL Start();
00524 
00525   protected:
00526     BOOL receiver;
00527 };
00528 
00529 
00536 class H323BidirectionalChannel : public H323Channel
00537 {
00538   PCLASSINFO(H323BidirectionalChannel, H323Channel);
00539 
00540   public:
00545     H323BidirectionalChannel(
00546       H323Connection & connection,        
00547       const H323Capability & capability   
00548     );
00550 
00557     virtual Directions GetDirection() const;
00558 
00563     virtual BOOL Start();
00565 };
00566 
00567 
00569 
00572 class H323_RealTimeChannel : public H323UnidirectionalChannel
00573 {
00574   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00575 
00576   public:
00581     H323_RealTimeChannel(
00582       H323Connection & connection,        
00583       const H323Capability & capability,  
00584       Directions direction                
00585     );
00587 
00592     virtual BOOL OnSendingPDU(
00593       H245_OpenLogicalChannel & openPDU  
00594     ) const;
00595 
00599     virtual void OnSendOpenAck(
00600       const H245_OpenLogicalChannel & open,   
00601       H245_OpenLogicalChannelAck & ack        
00602     ) const;
00603 
00611     virtual BOOL OnReceivedPDU(
00612       const H245_OpenLogicalChannel & pdu,    
00613       unsigned & errorCode                    
00614     );
00615 
00623     virtual BOOL OnReceivedAckPDU(
00624       const H245_OpenLogicalChannelAck & pdu 
00625     );
00627 
00632     virtual BOOL OnSendingPDU(
00633       H245_H2250LogicalChannelParameters & param  
00634     ) const = 0;
00635 
00638         virtual BOOL OnSendingAltPDU(
00639           H245_ArrayOf_GenericInformation & alternate  
00640         ) const = 0;
00641 
00645     virtual void OnSendOpenAck(
00646       H245_H2250LogicalChannelAckParameters & param 
00647     ) const = 0;
00648 
00651         virtual void OnSendOpenAckAlt(
00652           H245_ArrayOf_GenericInformation & alternate  
00653         ) const = 0;
00654 
00661     virtual BOOL OnReceivedPDU(
00662       const H245_H2250LogicalChannelParameters & param, 
00663       unsigned & errorCode                              
00664     ) = 0;
00665 
00668         virtual BOOL OnReceivedAltPDU(
00669           const H245_ArrayOf_GenericInformation & alternate  
00670         ) = 0;
00671 
00678     virtual BOOL OnReceivedAckPDU(
00679       const H245_H2250LogicalChannelAckParameters & param 
00680     ) = 0;
00681 
00684         virtual BOOL OnReceivedAckAltPDU(
00685           const H245_ArrayOf_GenericInformation & alternate  
00686         ) = 0;
00687 
00692     virtual RTP_DataFrame::PayloadTypes GetRTPPayloadType() const;
00693 
00696     virtual BOOL SetDynamicRTPPayloadType(
00697       int newType  
00698     );
00700 
00701   protected:
00702     RTP_DataFrame::PayloadTypes rtpPayloadType;
00703 };
00704 
00705 
00707 
00710 class H323_RTPChannel : public H323_RealTimeChannel
00711 {
00712   PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00713 
00714   public:
00719     H323_RTPChannel(
00720       H323Connection & connection,        
00721       const H323Capability & capability,  
00722       Directions direction,               
00723       RTP_Session & rtp                   
00724     );
00725 
00727     ~H323_RTPChannel();
00729 
00734     virtual void CleanUpOnTermination();
00735 
00740     virtual unsigned GetSessionID() const;
00741 
00744     virtual BOOL Open();
00745 
00752     virtual void Receive();
00753 
00760     virtual void Transmit();
00762 
00767     virtual BOOL OnSendingPDU(
00768       H245_H2250LogicalChannelParameters & param  
00769     ) const;
00770 
00773         virtual BOOL OnSendingAltPDU(
00774           H245_ArrayOf_GenericInformation & alternate  
00775         ) const;
00776 
00780     virtual void OnSendOpenAck(
00781       H245_H2250LogicalChannelAckParameters & param 
00782     ) const;
00783 
00786         virtual void OnSendOpenAckAlt(
00787           H245_ArrayOf_GenericInformation & alternate  
00788         ) const;
00789 
00796     virtual BOOL OnReceivedPDU(
00797       const H245_H2250LogicalChannelParameters & param, 
00798       unsigned & errorCode                              
00799     );
00800 
00803         virtual BOOL OnReceivedAltPDU(
00804           const H245_ArrayOf_GenericInformation & alternate  
00805         );
00806 
00813     virtual BOOL OnReceivedAckPDU(
00814       const H245_H2250LogicalChannelAckParameters & param 
00815     );
00816 
00819         virtual BOOL OnReceivedAckAltPDU(
00820           const H245_ArrayOf_GenericInformation & alternate  
00821         );
00823 
00824     void AddFilter(
00825       const PNotifier & filterFunction
00826     );
00827     void RemoveFilter(
00828       const PNotifier & filterFunction
00829     );
00830 
00831     PTimeInterval GetSilenceDuration() const;
00832 
00833 
00834   protected:
00835     RTP_Session      & rtpSession;
00836     H323_RTP_Session & rtpCallbacks;
00837 
00838     PLIST(FilterList, PNotifier);
00839     FilterList filters;
00840     PMutex     filterMutex;
00841 
00842     PTimeInterval silenceStartTick;
00843 };
00844 
00845 
00847 
00851 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00852 {
00853   PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00854 
00855   public:
00860     H323_ExternalRTPChannel(
00861       H323Connection & connection,        
00862       const H323Capability & capability,  
00863       Directions direction,               
00864       unsigned sessionID                  
00865     );
00868     H323_ExternalRTPChannel(
00869       H323Connection & connection,        
00870       const H323Capability & capability,  
00871       Directions direction,               
00872       unsigned sessionID,                 
00873       const H323TransportAddress & data,  
00874       const H323TransportAddress & control
00875     );
00878     H323_ExternalRTPChannel(
00879       H323Connection & connection,        
00880       const H323Capability & capability,  
00881       Directions direction,               
00882       unsigned sessionID,                 
00883       const PIPSocket::Address & ip,      
00884       WORD dataPort                       
00885     );
00887 
00894     virtual unsigned GetSessionID() const;
00895 
00898     virtual BOOL Start();
00899 
00902     virtual BOOL IsRunning() const;
00903 
00910     virtual void Receive();
00911 
00918     virtual void Transmit();
00920 
00925     virtual BOOL OnSendingPDU(
00926       H245_H2250LogicalChannelParameters & param  
00927     ) const;
00928 
00932     virtual void OnSendOpenAck(
00933       H245_H2250LogicalChannelAckParameters & param 
00934     ) const;
00935 
00942     virtual BOOL OnReceivedPDU(
00943       const H245_H2250LogicalChannelParameters & param, 
00944       unsigned & errorCode                              
00945     );
00946 
00953     virtual BOOL OnReceivedAckPDU(
00954       const H245_H2250LogicalChannelAckParameters & param 
00955     );
00957 
00958     void SetExternalAddress(
00959       const H323TransportAddress & data,  
00960       const H323TransportAddress & control
00961     );
00962 
00963     const H323TransportAddress & GetRemoteMediaAddress()        const { return remoteMediaAddress; }
00964     const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00965 
00966     BOOL GetRemoteAddress(
00967       PIPSocket::Address & ip,
00968       WORD & dataPort
00969     ) const;
00970 
00971   protected:
00972     unsigned             sessionID;
00973     H323TransportAddress externalMediaAddress;
00974     H323TransportAddress externalMediaControlAddress;
00975     H323TransportAddress remoteMediaAddress;
00976     H323TransportAddress remoteMediaControlAddress;
00977 
00978     BOOL isRunning;
00979 };
00980 
00981 
00983 
00990 class H323DataChannel : public H323UnidirectionalChannel
00991 {
00992   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00993 
00994   public:
00999     H323DataChannel(
01000       H323Connection & connection,        
01001       const H323Capability & capability,  
01002       Directions direction,               
01003       unsigned sessionID                  
01004     );
01005 
01008     ~H323DataChannel();
01010 
01015     virtual void CleanUpOnTermination();
01016 
01021     virtual unsigned GetSessionID() const;
01022 
01025     virtual BOOL OnSendingPDU(
01026       H245_OpenLogicalChannel & openPDU  
01027     ) const;
01028 
01032     virtual void OnSendOpenAck(
01033       const H245_OpenLogicalChannel & open,   
01034       H245_OpenLogicalChannelAck & ack        
01035     ) const;
01036 
01044     virtual BOOL OnReceivedPDU(
01045       const H245_OpenLogicalChannel & pdu,    
01046       unsigned & errorCode                    
01047     );
01048 
01056     virtual BOOL OnReceivedAckPDU(
01057       const H245_OpenLogicalChannelAck & pdu 
01058     );
01060 
01069     virtual BOOL CreateListener();
01070 
01078     virtual BOOL CreateTransport();
01080 
01081   protected:
01082     unsigned        sessionID;
01083     H323Listener  * listener;
01084     BOOL            autoDeleteListener;
01085     H323Transport * transport;
01086     BOOL            autoDeleteTransport;
01087     BOOL            separateReverseChannel;
01088 };
01089 
01090 
01091 #endif // __OPAL_CHANNELS_H
01092 
01093 

Generated on Thu Oct 25 13:41:58 2007 for h323plus by  doxygen 1.5.2