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  * $Log: channels.h,v $
00030  * Revision 2.14  2005/11/30 13:35:26  csoutheren
00031  * Changed tags for Doxygen
00032  *
00033  * Revision 2.13  2005/09/04 06:23:38  rjongbloed
00034  * Added OpalMediaCommand mechanism (via PNotifier) for media streams
00035  *   and media transcoders to send commands back to remote.
00036  *
00037  * Revision 2.12  2005/08/31 13:19:25  rjongbloed
00038  * Added mechanism for controlling media (especially codecs) including
00039  *   changing the OpalMediaFormat option list (eg bit rate) and a completely
00040  *   new OpalMediaCommand abstraction for things like video fast update.
00041  *
00042  * Revision 2.11  2002/11/10 11:33:16  robertj
00043  * Updated to OpenH323 v1.10.3
00044  *
00045  * Revision 2.10  2002/09/16 02:52:33  robertj
00046  * Added #define so can select if #pragma interface/implementation is used on
00047  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00048  *
00049  * Revision 2.9  2002/09/04 06:01:46  robertj
00050  * Updated to OpenH323 v1.9.6
00051  *
00052  * Revision 2.8  2002/07/01 04:56:29  robertj
00053  * Updated to OpenH323 v1.9.1
00054  *
00055  * Revision 2.7  2002/04/18 03:41:28  robertj
00056  * Fixed logical channel so does not delete media stream too early.
00057  *
00058  * Revision 2.6  2002/02/11 09:32:11  robertj
00059  * Updated to openH323 v1.8.0
00060  *
00061  * Revision 2.5  2002/02/11 07:37:21  robertj
00062  * Added media bypass for streams between compatible protocols.
00063  *
00064  * Revision 2.4  2002/01/22 04:56:55  robertj
00065  * Update from OpenH323, rev 1.26 to 1.28
00066  *
00067  * Revision 2.3  2002/01/14 06:35:56  robertj
00068  * Updated to OpenH323 v1.7.9
00069  *
00070  * Revision 2.2  2001/11/02 10:45:19  robertj
00071  * Updated to OpenH323 v1.7.3
00072  *
00073  * Revision 2.1  2001/10/15 04:30:09  robertj
00074  * Added delayed start of media patch threads.
00075  *
00076  * Revision 2.0  2001/07/27 15:48:24  robertj
00077  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00078  *
00079  * Revision 1.40  2002/09/16 01:14:15  robertj
00080  * Added #define so can select if #pragma interface/implementation is used on
00081  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00082  *
00083  * Revision 1.39  2002/09/03 06:19:36  robertj
00084  * Normalised the multi-include header prevention ifdef/define symbol.
00085  *
00086  * Revision 1.38  2002/08/05 10:03:47  robertj
00087  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00088  *
00089  * Revision 1.37  2002/06/25 08:30:08  robertj
00090  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00091  *   the OLC dataType silenceSuppression field so does not send SID frames
00092  *   to receiver codecs that do not understand them.
00093  *
00094  * Revision 1.36  2002/05/23 04:53:54  robertj
00095  * Added function to remove a filter from logical channel.
00096  *
00097  * Revision 1.35  2002/05/10 05:46:46  robertj
00098  * Added session ID to the data logical channel class.
00099  *
00100  * Revision 1.34  2002/05/02 07:56:24  robertj
00101  * Added automatic clearing of call if no media (RTP data) is transferred in a
00102  *   configurable (default 5 minutes) amount of time.
00103  *
00104  * Revision 1.33  2002/05/02 06:28:50  robertj
00105  * Fixed problem with external RTP channels not fast starting.
00106  *
00107  * Revision 1.32  2002/04/17 05:56:28  robertj
00108  * Added trace output of H323Channel::Direction enum.
00109  *
00110  * Revision 1.31  2002/02/09 04:39:01  robertj
00111  * Changes to allow T.38 logical channels to use single transport which is
00112  *   now owned by the OpalT38Protocol object instead of H323Channel.
00113  *
00114  * Revision 1.30  2002/02/05 08:13:20  robertj
00115  * Added ability to not have addresses when external RTP channel created.
00116  *
00117  * Revision 1.29  2002/01/22 22:48:21  robertj
00118  * Fixed RFC2833 support (transmitter) requiring large rewrite
00119  *
00120  * Revision 1.28  2002/01/17 07:04:57  robertj
00121  * Added support for RFC2833 embedded DTMF in the RTP stream.
00122  *
00123  * Revision 1.27  2002/01/17 00:10:37  robertj
00124  * Fixed double copy of rtpPayloadType in RTP channel, caused much confusion.
00125  *
00126  * Revision 1.26  2002/01/14 05:18:16  robertj
00127  * Fixed typo on external RTP channel constructor.
00128  *
00129  * Revision 1.25  2002/01/10 05:13:50  robertj
00130  * Added support for external RTP stacks, thanks NuMind Software Systems.
00131  *
00132  * Revision 1.24  2001/10/23 02:18:06  dereks
00133  * Initial release of CU30 video codec.
00134  *
00135  * Revision 1.23  2001/07/24 02:26:53  robertj
00136  * Added start for handling reverse channels.
00137  *
00138  * Revision 1.22  2001/07/17 04:44:29  robertj
00139  * Partial implementation of T.120 and T.38 logical channels.
00140  *
00141  * Revision 1.21  2001/02/09 05:16:24  robertj
00142  * Added #pragma interface for GNU C++.
00143  *
00144  * Revision 1.20  2001/01/25 07:27:14  robertj
00145  * Major changes to add more flexible OpalMediaFormat class to normalise
00146  *   all information about media types, especially codecs.
00147  *
00148  * Revision 1.19  2000/10/19 04:05:20  robertj
00149  * Added compare function for logical channel numbers, thanks Yuriy Ershov.
00150  *
00151  * Revision 1.18  2000/09/22 01:35:02  robertj
00152  * Added support for handling LID's that only do symmetric codecs.
00153  *
00154  * Revision 1.17  2000/08/31 08:15:32  robertj
00155  * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations.
00156  *
00157  * Revision 1.16  2000/08/21 02:50:19  robertj
00158  * Fixed race condition if close call just as slow start media channels are opening.
00159  *
00160  * Revision 1.15  2000/06/15 01:46:13  robertj
00161  * Added channel pause (aka mute) functions.
00162  *
00163  * Revision 1.14  2000/05/18 11:53:33  robertj
00164  * Changes to support doc++ documentation generation.
00165  *
00166  * Revision 1.13  2000/05/02 04:32:23  robertj
00167  * Fixed copyright notice comment.
00168  *
00169  * Revision 1.12  1999/12/23 23:02:34  robertj
00170  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00171  *
00172  * Revision 1.11  1999/11/19 09:06:30  robertj
00173  * Changed to close down logical channel if get a transmit codec error.
00174  *
00175  * Revision 1.10  1999/11/06 05:37:44  robertj
00176  * Complete rewrite of termination of connection to avoid numerous race conditions.
00177  *
00178  * Revision 1.9  1999/09/08 04:05:48  robertj
00179  * Added support for video capabilities & codec, still needs the actual codec itself!
00180  *
00181  * Revision 1.8  1999/08/31 12:34:18  robertj
00182  * Added gatekeeper support.
00183  *
00184  * Revision 1.7  1999/07/09 06:09:49  robertj
00185  * Major implementation. An ENORMOUS amount of stuff added everywhere.
00186  *
00187  * Revision 1.6  1999/06/14 05:15:55  robertj
00188  * Changes for using RTP sessions correctly in H323 Logical Channel context
00189  *
00190  * Revision 1.5  1999/06/13 12:41:14  robertj
00191  * Implement logical channel transmitter.
00192  * Fixed H245 connect on receiving call.
00193  *
00194  * Revision 1.4  1999/06/09 05:26:19  robertj
00195  * Major restructuring of classes.
00196  *
00197  * Revision 1.3  1999/06/06 06:06:36  robertj
00198  * Changes for new ASN compiler and v2 protocol ASN files.
00199  *
00200  * Revision 1.2  1999/04/26 06:14:46  craigs
00201  * Initial implementation for RTP decoding and lots of stuff
00202  * As a whole, these changes are called "First Noise"
00203  *
00204  * Revision 1.1  1999/01/16 01:31:07  robertj
00205  * Initial revision
00206  *
00207  */
00208 
00209 #ifndef __OPAL_CHANNELS_H
00210 #define __OPAL_CHANNELS_H
00211 
00212 #ifdef P_USE_PRAGMA
00213 #pragma interface
00214 #endif
00215 
00216 
00217 #include <rtp/rtp.h>
00218 #include <h323/transaddr.h>
00219 
00220 
00221 class OpalMediaStream;
00222 class OpalMediaCommand;
00223 
00224 class H245_OpenLogicalChannel;
00225 class H245_OpenLogicalChannelAck;
00226 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00227 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00228 class H245_H2250LogicalChannelParameters;
00229 class H245_H2250LogicalChannelAckParameters;
00230 class H245_MiscellaneousCommand_type;
00231 class H245_MiscellaneousIndication_type;
00232 
00233 class H323EndPoint;
00234 class H323Connection;
00235 class H323Capability;
00236 class H323_RTP_Session;
00237 
00238 
00240 
00244 class H323ChannelNumber : public PObject
00245 {
00246   PCLASSINFO(H323ChannelNumber, PObject);
00247 
00248   public:
00249     H323ChannelNumber() { number = 0; fromRemote = FALSE; }
00250     H323ChannelNumber(unsigned number, BOOL fromRemote);
00251 
00252     virtual PObject * Clone() const;
00253     virtual PINDEX HashFunction() const;
00254     virtual void PrintOn(ostream & strm) const;
00255     virtual Comparison Compare(const PObject & obj) const;
00256 
00257     H323ChannelNumber & operator++(int);
00258     operator unsigned() const { return number; }
00259     BOOL IsFromRemote() const { return fromRemote; }
00260     
00261   protected:
00262     unsigned number;
00263     BOOL     fromRemote;
00264 };
00265 
00266 
00273 class H323Channel : public PObject
00274 {
00275   PCLASSINFO(H323Channel, PObject);
00276 
00277   public:
00282     H323Channel(
00283       H323Connection & connection,        
00284       const H323Capability & capability   
00285     );
00286 
00291     ~H323Channel();
00293 
00296     virtual void PrintOn(
00297       ostream & strm
00298     ) const;
00300 
00303     enum Directions {
00304       IsBidirectional,
00305       IsTransmitter,
00306       IsReceiver,
00307       NumDirections
00308     };
00309 #if PTRACING
00310     friend ostream & operator<<(ostream & out, Directions dir);
00311 #endif
00312 
00317     virtual Directions GetDirection() const = 0;
00318 
00324     virtual unsigned GetSessionID() const;
00325 
00332     virtual BOOL GetMediaTransportAddress(
00333       OpalTransportAddress & data,        
00334       OpalTransportAddress & control      
00335     ) const;
00336 
00344     virtual BOOL SetInitialBandwidth() = 0;
00345 
00350     virtual BOOL Open();
00351 
00354     virtual BOOL Start() = 0;
00355 
00358     virtual void Close();
00359 
00362     BOOL IsOpen() const { return opened && !terminating; }
00363 
00367     virtual OpalMediaStream * GetMediaStream() const = 0;
00368 
00371     virtual BOOL OnSendingPDU(
00372       H245_OpenLogicalChannel & openPDU  
00373     ) const = 0;
00374 
00380     virtual void OnSendOpenAck(
00381       const H245_OpenLogicalChannel & open,   
00382       H245_OpenLogicalChannelAck & ack        
00383     ) const;
00384 
00391     virtual BOOL OnReceivedPDU(
00392       const H245_OpenLogicalChannel & pdu,    
00393       unsigned & errorCode                    
00394     );
00395 
00402     virtual BOOL OnReceivedAckPDU(
00403       const H245_OpenLogicalChannelAck & pdu  
00404     );
00405 
00409     virtual void OnFlowControl(
00410       long bitRateRestriction   
00411     );
00412 
00416     virtual void OnMiscellaneousCommand(
00417       const H245_MiscellaneousCommand_type & type  
00418     );
00419 
00423     virtual void OnMiscellaneousIndication(
00424       const H245_MiscellaneousIndication_type & type  
00425     );
00426 
00430     virtual void OnJitterIndication(
00431       DWORD jitter,           
00432       int skippedFrameCount,  
00433       int additionalBuffer    
00434     );
00436 
00441     const H323ChannelNumber & GetNumber() const { return number; }
00442 
00445     void SetNumber(const H323ChannelNumber & num) { number = num; }
00446 
00449     const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00450 
00453     void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00454 
00457     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00458 
00461     BOOL SetBandwidthUsed(
00462       unsigned bandwidth  
00463     );
00464 
00467     const H323Capability & GetCapability() const { return *capability; }
00468 
00477     BOOL IsPaused() const { return paused; }
00478 
00487     void SetPause(
00488       BOOL pause   
00489     ) { paused = pause; }
00491 
00492   protected:
00493     H323EndPoint         & endpoint;
00494     H323Connection       & connection;
00495     H323Capability       * capability;
00496     H323ChannelNumber      number;
00497     H323ChannelNumber      reverseChannel;
00498     BOOL                   opened;
00499     BOOL                   paused;
00500     BOOL                   terminating;
00501 
00502   private:
00503     unsigned bandwidthUsed;
00504 };
00505 
00506 
00507 PLIST(H323LogicalChannelList, H323Channel);
00508 
00509 
00510 
00517 class H323UnidirectionalChannel : public H323Channel
00518 {
00519   PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00520 
00521   public:
00526     H323UnidirectionalChannel(
00527       H323Connection & connection,        
00528       const H323Capability & capability,  
00529       Directions direction                
00530     );
00531 
00534     ~H323UnidirectionalChannel();
00536 
00543     virtual Directions GetDirection() const;
00544 
00552     virtual BOOL SetInitialBandwidth();
00553 
00556     virtual BOOL Open();
00557 
00562     virtual BOOL Start();
00563 
00566     virtual void Close();
00567 
00571     virtual void OnMiscellaneousCommand(
00572       const H245_MiscellaneousCommand_type & type  
00573     );
00575 
00581     virtual OpalMediaStream * GetMediaStream() const;
00583 
00584   protected:
00585     PDECLARE_NOTIFIER(OpalMediaCommand, H323UnidirectionalChannel, OnMediaCommand);
00586 
00587     BOOL              receiver;
00588     OpalMediaStream * mediaStream;
00589 };
00590 
00591 
00598 class H323BidirectionalChannel : public H323Channel
00599 {
00600   PCLASSINFO(H323BidirectionalChannel, H323Channel);
00601 
00602   public:
00607     H323BidirectionalChannel(
00608       H323Connection & connection,        
00609       const H323Capability & capability   
00610     );
00612 
00619     virtual Directions GetDirection() const;
00620 
00625     virtual BOOL Start();
00627 };
00628 
00629 
00631 
00634 class H323_RealTimeChannel : public H323UnidirectionalChannel
00635 {
00636   PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00637 
00638   public:
00643     H323_RealTimeChannel(
00644       H323Connection & connection,        
00645       const H323Capability & capability,  
00646       Directions direction                
00647     );
00649 
00654     virtual BOOL OnSendingPDU(
00655       H245_OpenLogicalChannel & openPDU  
00656     ) const;
00657 
00661     virtual void OnSendOpenAck(
00662       const H245_OpenLogicalChannel & open,   
00663       H245_OpenLogicalChannelAck & ack        
00664     ) const;
00665 
00673     virtual BOOL OnReceivedPDU(
00674       const H245_OpenLogicalChannel & pdu,    
00675       unsigned & errorCode                    
00676     );
00677 
00685     virtual BOOL OnReceivedAckPDU(
00686       const H245_OpenLogicalChannelAck & pdu 
00687     );
00689 
00694     virtual BOOL OnSendingPDU(
00695       H245_H2250LogicalChannelParameters & param  
00696     ) const = 0;
00697 
00701     virtual void OnSendOpenAck(
00702       H245_H2250LogicalChannelAckParameters & param 
00703     ) const = 0;
00704 
00711     virtual BOOL OnReceivedPDU(
00712       const H245_H2250LogicalChannelParameters & param, 
00713       unsigned & errorCode                              
00714     ) = 0;
00715 
00722     virtual BOOL OnReceivedAckPDU(
00723       const H245_H2250LogicalChannelAckParameters & param 
00724     ) = 0;
00725 
00728     virtual BOOL SetDynamicRTPPayloadType(
00729       int newType  
00730     );
00731 
00732     RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00734 
00735   protected:
00736     RTP_DataFrame::PayloadTypes rtpPayloadType;
00737 };
00738 
00739 
00741 
00744 class H323_RTPChannel : public H323_RealTimeChannel
00745 {
00746   PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00747 
00748   public:
00753     H323_RTPChannel(
00754       H323Connection & connection,        
00755       const H323Capability & capability,  
00756       Directions direction,               
00757       RTP_Session & rtp                   
00758     );
00759 
00761     ~H323_RTPChannel();
00763 
00770     virtual unsigned GetSessionID() const;
00772 
00777     virtual BOOL OnSendingPDU(
00778       H245_H2250LogicalChannelParameters & param  
00779     ) const;
00780 
00784     virtual void OnSendOpenAck(
00785       H245_H2250LogicalChannelAckParameters & param 
00786     ) const;
00787 
00794     virtual BOOL OnReceivedPDU(
00795       const H245_H2250LogicalChannelParameters & param, 
00796       unsigned & errorCode                              
00797     );
00798 
00805     virtual BOOL OnReceivedAckPDU(
00806       const H245_H2250LogicalChannelAckParameters & param 
00807     );
00809 
00810   protected:
00811     RTP_Session      & rtpSession;
00812     H323_RTP_Session & rtpCallbacks;
00813 };
00814 
00815 
00817 
00821 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00822 {
00823   PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00824 
00825   public:
00830     H323_ExternalRTPChannel(
00831       H323Connection & connection,        
00832       const H323Capability & capability,  
00833       Directions direction,               
00834       unsigned sessionID                  
00835     );
00838     H323_ExternalRTPChannel(
00839       H323Connection & connection,        
00840       const H323Capability & capability,  
00841       Directions direction,               
00842       unsigned sessionID,                 
00843       const H323TransportAddress & data,  
00844       const H323TransportAddress & control
00845     );
00848     H323_ExternalRTPChannel(
00849       H323Connection & connection,        
00850       const H323Capability & capability,  
00851       Directions direction,               
00852       unsigned sessionID,                 
00853       const PIPSocket::Address & ip,      
00854       WORD dataPort                       
00855     );
00857 
00864     virtual unsigned GetSessionID() const;
00865 
00872     virtual BOOL GetMediaTransportAddress(
00873       OpalTransportAddress & data,        
00874       OpalTransportAddress & control      
00875     ) const;
00876 
00879     virtual BOOL Start();
00880 
00887     virtual void Receive();
00888 
00895     virtual void Transmit();
00897 
00902     virtual BOOL OnSendingPDU(
00903       H245_H2250LogicalChannelParameters & param  
00904     ) const;
00905 
00909     virtual void OnSendOpenAck(
00910       H245_H2250LogicalChannelAckParameters & param 
00911     ) const;
00912 
00919     virtual BOOL OnReceivedPDU(
00920       const H245_H2250LogicalChannelParameters & param, 
00921       unsigned & errorCode                              
00922     );
00923 
00930     virtual BOOL OnReceivedAckPDU(
00931       const H245_H2250LogicalChannelAckParameters & param 
00932     );
00934 
00935     void SetExternalAddress(
00936       const H323TransportAddress & data,  
00937       const H323TransportAddress & control
00938     );
00939 
00940     const H323TransportAddress & GetRemoteMediaAddress()        const { return remoteMediaAddress; }
00941     const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00942 
00943     BOOL GetRemoteAddress(
00944       PIPSocket::Address & ip,
00945       WORD & dataPort
00946     ) const;
00947 
00948   protected:
00949     void Construct(unsigned id);
00950 
00951     unsigned             sessionID;
00952     H323TransportAddress externalMediaAddress;
00953     H323TransportAddress externalMediaControlAddress;
00954     H323TransportAddress remoteMediaAddress;
00955     H323TransportAddress remoteMediaControlAddress;
00956 };
00957 
00958 
00960 
00967 class H323DataChannel : public H323UnidirectionalChannel
00968 {
00969   PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00970 
00971   public:
00976     H323DataChannel(
00977       H323Connection & connection,        
00978       const H323Capability & capability,  
00979       Directions direction,               
00980       unsigned sessionID                  
00981     );
00982 
00985     ~H323DataChannel();
00987 
00992     virtual void Close();
00993 
00998     virtual unsigned GetSessionID() const;
00999 
01002     virtual BOOL OnSendingPDU(
01003       H245_OpenLogicalChannel & openPDU  
01004     ) const;
01005 
01009     virtual void OnSendOpenAck(
01010       const H245_OpenLogicalChannel & open,   
01011       H245_OpenLogicalChannelAck & ack        
01012     ) const;
01013 
01021     virtual BOOL OnReceivedPDU(
01022       const H245_OpenLogicalChannel & pdu,    
01023       unsigned & errorCode                    
01024     );
01025 
01033     virtual BOOL OnReceivedAckPDU(
01034       const H245_OpenLogicalChannelAck & pdu 
01035     );
01037 
01046     virtual BOOL CreateListener();
01047 
01055     virtual BOOL CreateTransport();
01057 
01058   protected:
01059     unsigned        sessionID;
01060     H323Listener  * listener;
01061     BOOL            autoDeleteListener;
01062     H323Transport * transport;
01063     BOOL            autoDeleteTransport;
01064     BOOL            separateReverseChannel;
01065 };
01066 
01067 
01068 #endif // __OPAL_CHANNELS_H
01069 
01070 

Generated on Mon Sep 25 16:19:33 2006 for OPAL by  doxygen 1.4.7