OpenH323 1.18.0
|
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.42 2005/11/30 13:05:00 csoutheren 00031 * Changed tags for Doxygen 00032 * 00033 * Revision 1.41 2004/07/03 05:47:45 rjongbloed 00034 * Added virtual function for determining RTP payload type used in an H.323 channel, 00035 * also some added bullet proofing for exception conditions, thanks Guilhem Tardy 00036 * 00037 * Revision 1.40 2002/09/16 01:14:15 robertj 00038 * Added #define so can select if #pragma interface/implementation is used on 00039 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00040 * 00041 * Revision 1.39 2002/09/03 06:19:36 robertj 00042 * Normalised the multi-include header prevention ifdef/define symbol. 00043 * 00044 * Revision 1.38 2002/08/05 10:03:47 robertj 00045 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00046 * 00047 * Revision 1.37 2002/06/25 08:30:08 robertj 00048 * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using 00049 * the OLC dataType silenceSuppression field so does not send SID frames 00050 * to receiver codecs that do not understand them. 00051 * 00052 * Revision 1.36 2002/05/23 04:53:54 robertj 00053 * Added function to remove a filter from logical channel. 00054 * 00055 * Revision 1.35 2002/05/10 05:46:46 robertj 00056 * Added session ID to the data logical channel class. 00057 * 00058 * Revision 1.34 2002/05/02 07:56:24 robertj 00059 * Added automatic clearing of call if no media (RTP data) is transferred in a 00060 * configurable (default 5 minutes) amount of time. 00061 * 00062 * Revision 1.33 2002/05/02 06:28:50 robertj 00063 * Fixed problem with external RTP channels not fast starting. 00064 * 00065 * Revision 1.32 2002/04/17 05:56:28 robertj 00066 * Added trace output of H323Channel::Direction enum. 00067 * 00068 * Revision 1.31 2002/02/09 04:39:01 robertj 00069 * Changes to allow T.38 logical channels to use single transport which is 00070 * now owned by the OpalT38Protocol object instead of H323Channel. 00071 * 00072 * Revision 1.30 2002/02/05 08:13:20 robertj 00073 * Added ability to not have addresses when external RTP channel created. 00074 * 00075 * Revision 1.29 2002/01/22 22:48:21 robertj 00076 * Fixed RFC2833 support (transmitter) requiring large rewrite 00077 * 00078 * Revision 1.28 2002/01/17 07:04:57 robertj 00079 * Added support for RFC2833 embedded DTMF in the RTP stream. 00080 * 00081 * Revision 1.27 2002/01/17 00:10:37 robertj 00082 * Fixed double copy of rtpPayloadType in RTP channel, caused much confusion. 00083 * 00084 * Revision 1.26 2002/01/14 05:18:16 robertj 00085 * Fixed typo on external RTP channel constructor. 00086 * 00087 * Revision 1.25 2002/01/10 05:13:50 robertj 00088 * Added support for external RTP stacks, thanks NuMind Software Systems. 00089 * 00090 * Revision 1.24 2001/10/23 02:18:06 dereks 00091 * Initial release of CU30 video codec. 00092 * 00093 * Revision 1.23 2001/07/24 02:26:53 robertj 00094 * Added start for handling reverse channels. 00095 * 00096 * Revision 1.22 2001/07/17 04:44:29 robertj 00097 * Partial implementation of T.120 and T.38 logical channels. 00098 * 00099 * Revision 1.21 2001/02/09 05:16:24 robertj 00100 * Added #pragma interface for GNU C++. 00101 * 00102 * Revision 1.20 2001/01/25 07:27:14 robertj 00103 * Major changes to add more flexible OpalMediaFormat class to normalise 00104 * all information about media types, especially codecs. 00105 * 00106 * Revision 1.19 2000/10/19 04:05:20 robertj 00107 * Added compare function for logical channel numbers, thanks Yuriy Ershov. 00108 * 00109 * Revision 1.18 2000/09/22 01:35:02 robertj 00110 * Added support for handling LID's that only do symmetric codecs. 00111 * 00112 * Revision 1.17 2000/08/31 08:15:32 robertj 00113 * Added support for dynamic RTP payload types in H.245 OpenLogicalChannel negotiations. 00114 * 00115 * Revision 1.16 2000/08/21 02:50:19 robertj 00116 * Fixed race condition if close call just as slow start media channels are opening. 00117 * 00118 * Revision 1.15 2000/06/15 01:46:13 robertj 00119 * Added channel pause (aka mute) functions. 00120 * 00121 * Revision 1.14 2000/05/18 11:53:33 robertj 00122 * Changes to support doc++ documentation generation. 00123 * 00124 * Revision 1.13 2000/05/02 04:32:23 robertj 00125 * Fixed copyright notice comment. 00126 * 00127 * Revision 1.12 1999/12/23 23:02:34 robertj 00128 * File reorganision for separating RTP from H.323 and creation of LID for VPB support. 00129 * 00130 * Revision 1.11 1999/11/19 09:06:30 robertj 00131 * Changed to close down logical channel if get a transmit codec error. 00132 * 00133 * Revision 1.10 1999/11/06 05:37:44 robertj 00134 * Complete rewrite of termination of connection to avoid numerous race conditions. 00135 * 00136 * Revision 1.9 1999/09/08 04:05:48 robertj 00137 * Added support for video capabilities & codec, still needs the actual codec itself! 00138 * 00139 * Revision 1.8 1999/08/31 12:34:18 robertj 00140 * Added gatekeeper support. 00141 * 00142 * Revision 1.7 1999/07/09 06:09:49 robertj 00143 * Major implementation. An ENORMOUS amount of stuff added everywhere. 00144 * 00145 * Revision 1.6 1999/06/14 05:15:55 robertj 00146 * Changes for using RTP sessions correctly in H323 Logical Channel context 00147 * 00148 * Revision 1.5 1999/06/13 12:41:14 robertj 00149 * Implement logical channel transmitter. 00150 * Fixed H245 connect on receiving call. 00151 * 00152 * Revision 1.4 1999/06/09 05:26:19 robertj 00153 * Major restructuring of classes. 00154 * 00155 * Revision 1.3 1999/06/06 06:06:36 robertj 00156 * Changes for new ASN compiler and v2 protocol ASN files. 00157 * 00158 * Revision 1.2 1999/04/26 06:14:46 craigs 00159 * Initial implementation for RTP decoding and lots of stuff 00160 * As a whole, these changes are called "First Noise" 00161 * 00162 * Revision 1.1 1999/01/16 01:31:07 robertj 00163 * Initial revision 00164 * 00165 */ 00166 00167 #ifndef __OPAL_CHANNELS_H 00168 #define __OPAL_CHANNELS_H 00169 00170 #ifdef P_USE_PRAGMA 00171 #pragma interface 00172 #endif 00173 00174 00175 #include "rtp.h" 00176 #include "transports.h" 00177 00178 00179 class H245_OpenLogicalChannel; 00180 class H245_OpenLogicalChannelAck; 00181 class H245_OpenLogicalChannel_forwardLogicalChannelParameters; 00182 class H245_OpenLogicalChannel_reverseLogicalChannelParameters; 00183 class H245_H2250LogicalChannelParameters; 00184 class H245_H2250LogicalChannelAckParameters; 00185 class H245_MiscellaneousCommand_type; 00186 class H245_MiscellaneousIndication_type; 00187 00188 class H323EndPoint; 00189 class H323Connection; 00190 class H323Capability; 00191 class H323Codec; 00192 class H323_RTP_Session; 00193 00194 00195 00197 00201 class H323ChannelNumber : public PObject 00202 { 00203 PCLASSINFO(H323ChannelNumber, PObject); 00204 00205 public: 00206 H323ChannelNumber() { number = 0; fromRemote = FALSE; } 00207 H323ChannelNumber(unsigned number, BOOL fromRemote); 00208 00209 virtual PObject * Clone() const; 00210 virtual PINDEX HashFunction() const; 00211 virtual void PrintOn(ostream & strm) const; 00212 virtual Comparison Compare(const PObject & obj) const; 00213 00214 H323ChannelNumber & operator++(int); 00215 operator unsigned() const { return number; } 00216 BOOL IsFromRemote() const { return fromRemote; } 00217 00218 protected: 00219 unsigned number; 00220 BOOL fromRemote; 00221 }; 00222 00223 00230 class H323Channel : public PObject 00231 { 00232 PCLASSINFO(H323Channel, PObject); 00233 00234 public: 00239 H323Channel( 00240 H323Connection & connection, 00241 const H323Capability & capability 00242 ); 00243 00248 ~H323Channel(); 00250 00253 virtual void PrintOn( 00254 ostream & strm 00255 ) const; 00257 00260 enum Directions { 00261 IsBidirectional, 00262 IsTransmitter, 00263 IsReceiver, 00264 NumDirections 00265 }; 00266 #if PTRACING 00267 friend ostream & operator<<(ostream & out, Directions dir); 00268 #endif 00269 00274 virtual Directions GetDirection() const = 0; 00275 00281 virtual unsigned GetSessionID() const; 00282 00290 virtual BOOL SetInitialBandwidth(); 00291 00296 virtual BOOL Open(); 00297 00300 virtual BOOL Start() = 0; 00301 00304 virtual void CleanUpOnTermination(); 00305 00308 virtual BOOL IsRunning() const; 00309 00316 virtual void Receive() = 0; 00317 00324 virtual void Transmit() = 0; 00325 00328 virtual BOOL OnSendingPDU( 00329 H245_OpenLogicalChannel & openPDU 00330 ) const = 0; 00331 00337 virtual void OnSendOpenAck( 00338 const H245_OpenLogicalChannel & open, 00339 H245_OpenLogicalChannelAck & ack 00340 ) const; 00341 00348 virtual BOOL OnReceivedPDU( 00349 const H245_OpenLogicalChannel & pdu, 00350 unsigned & errorCode 00351 ); 00352 00359 virtual BOOL OnReceivedAckPDU( 00360 const H245_OpenLogicalChannelAck & pdu 00361 ); 00362 00366 virtual void OnFlowControl( 00367 long bitRateRestriction 00368 ); 00369 00373 virtual void OnMiscellaneousCommand( 00374 const H245_MiscellaneousCommand_type & type 00375 ); 00376 00380 virtual void OnMiscellaneousIndication( 00381 const H245_MiscellaneousIndication_type & type 00382 ); 00383 00387 virtual void OnJitterIndication( 00388 DWORD jitter, 00389 int skippedFrameCount, 00390 int additionalBuffer 00391 ); 00392 00397 void SendMiscCommand(unsigned command); 00399 00404 const H323ChannelNumber & GetNumber() const { return number; } 00405 00408 void SetNumber(const H323ChannelNumber & num) { number = num; } 00409 00412 const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; } 00413 00416 void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; } 00417 00420 unsigned GetBandwidthUsed() const { return bandwidthUsed; } 00421 00424 BOOL SetBandwidthUsed( 00425 unsigned bandwidth 00426 ); 00427 00430 const H323Capability & GetCapability() const { return *capability; } 00431 00434 H323Codec * GetCodec() const; 00435 00444 BOOL IsPaused() const { return paused; } 00445 00454 void SetPause( 00455 BOOL pause 00456 ) { paused = pause; } 00458 00459 protected: 00460 H323EndPoint & endpoint; 00461 H323Connection & connection; 00462 H323Capability * capability; 00463 H323ChannelNumber number; 00464 H323ChannelNumber reverseChannel; 00465 H323Codec * codec; 00466 PThread * receiveThread; 00467 PThread * transmitThread; 00468 BOOL opened; 00469 BOOL paused; 00470 BOOL terminating; 00471 00472 private: 00473 unsigned bandwidthUsed; 00474 }; 00475 00476 00477 PLIST(H323LogicalChannelList, H323Channel); 00478 00479 00480 00487 class H323UnidirectionalChannel : public H323Channel 00488 { 00489 PCLASSINFO(H323UnidirectionalChannel, H323Channel); 00490 00491 public: 00496 H323UnidirectionalChannel( 00497 H323Connection & connection, 00498 const H323Capability & capability, 00499 Directions direction 00500 ); 00502 00509 virtual Directions GetDirection() const; 00510 00515 virtual BOOL Start(); 00517 00518 protected: 00519 BOOL receiver; 00520 }; 00521 00522 00529 class H323BidirectionalChannel : public H323Channel 00530 { 00531 PCLASSINFO(H323BidirectionalChannel, H323Channel); 00532 00533 public: 00538 H323BidirectionalChannel( 00539 H323Connection & connection, 00540 const H323Capability & capability 00541 ); 00543 00550 virtual Directions GetDirection() const; 00551 00556 virtual BOOL Start(); 00558 }; 00559 00560 00562 00565 class H323_RealTimeChannel : public H323UnidirectionalChannel 00566 { 00567 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel); 00568 00569 public: 00574 H323_RealTimeChannel( 00575 H323Connection & connection, 00576 const H323Capability & capability, 00577 Directions direction 00578 ); 00580 00585 virtual BOOL OnSendingPDU( 00586 H245_OpenLogicalChannel & openPDU 00587 ) const; 00588 00592 virtual void OnSendOpenAck( 00593 const H245_OpenLogicalChannel & open, 00594 H245_OpenLogicalChannelAck & ack 00595 ) const; 00596 00604 virtual BOOL OnReceivedPDU( 00605 const H245_OpenLogicalChannel & pdu, 00606 unsigned & errorCode 00607 ); 00608 00616 virtual BOOL OnReceivedAckPDU( 00617 const H245_OpenLogicalChannelAck & pdu 00618 ); 00620 00625 virtual BOOL OnSendingPDU( 00626 H245_H2250LogicalChannelParameters & param 00627 ) const = 0; 00628 00632 virtual void OnSendOpenAck( 00633 H245_H2250LogicalChannelAckParameters & param 00634 ) const = 0; 00635 00642 virtual BOOL OnReceivedPDU( 00643 const H245_H2250LogicalChannelParameters & param, 00644 unsigned & errorCode 00645 ) = 0; 00646 00653 virtual BOOL OnReceivedAckPDU( 00654 const H245_H2250LogicalChannelAckParameters & param 00655 ) = 0; 00656 00661 virtual RTP_DataFrame::PayloadTypes GetRTPPayloadType() const; 00662 00665 virtual BOOL SetDynamicRTPPayloadType( 00666 int newType 00667 ); 00669 00670 protected: 00671 RTP_DataFrame::PayloadTypes rtpPayloadType; 00672 }; 00673 00674 00676 00679 class H323_RTPChannel : public H323_RealTimeChannel 00680 { 00681 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel); 00682 00683 public: 00688 H323_RTPChannel( 00689 H323Connection & connection, 00690 const H323Capability & capability, 00691 Directions direction, 00692 RTP_Session & rtp 00693 ); 00694 00696 ~H323_RTPChannel(); 00698 00703 virtual void CleanUpOnTermination(); 00704 00709 virtual unsigned GetSessionID() const; 00710 00713 virtual BOOL Open(); 00714 00721 virtual void Receive(); 00722 00729 virtual void Transmit(); 00731 00736 virtual BOOL OnSendingPDU( 00737 H245_H2250LogicalChannelParameters & param 00738 ) const; 00739 00743 virtual void OnSendOpenAck( 00744 H245_H2250LogicalChannelAckParameters & param 00745 ) const; 00746 00753 virtual BOOL OnReceivedPDU( 00754 const H245_H2250LogicalChannelParameters & param, 00755 unsigned & errorCode 00756 ); 00757 00764 virtual BOOL OnReceivedAckPDU( 00765 const H245_H2250LogicalChannelAckParameters & param 00766 ); 00768 00769 void AddFilter( 00770 const PNotifier & filterFunction 00771 ); 00772 void RemoveFilter( 00773 const PNotifier & filterFunction 00774 ); 00775 00776 PTimeInterval GetSilenceDuration() const; 00777 00778 00779 protected: 00780 RTP_Session & rtpSession; 00781 H323_RTP_Session & rtpCallbacks; 00782 00783 PLIST(FilterList, PNotifier); 00784 FilterList filters; 00785 PMutex filterMutex; 00786 00787 PTimeInterval silenceStartTick; 00788 }; 00789 00790 00792 00796 class H323_ExternalRTPChannel : public H323_RealTimeChannel 00797 { 00798 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel); 00799 00800 public: 00805 H323_ExternalRTPChannel( 00806 H323Connection & connection, 00807 const H323Capability & capability, 00808 Directions direction, 00809 unsigned sessionID 00810 ); 00813 H323_ExternalRTPChannel( 00814 H323Connection & connection, 00815 const H323Capability & capability, 00816 Directions direction, 00817 unsigned sessionID, 00818 const H323TransportAddress & data, 00819 const H323TransportAddress & control 00820 ); 00823 H323_ExternalRTPChannel( 00824 H323Connection & connection, 00825 const H323Capability & capability, 00826 Directions direction, 00827 unsigned sessionID, 00828 const PIPSocket::Address & ip, 00829 WORD dataPort 00830 ); 00832 00839 virtual unsigned GetSessionID() const; 00840 00843 virtual BOOL Start(); 00844 00847 virtual BOOL IsRunning() const; 00848 00855 virtual void Receive(); 00856 00863 virtual void Transmit(); 00865 00870 virtual BOOL OnSendingPDU( 00871 H245_H2250LogicalChannelParameters & param 00872 ) const; 00873 00877 virtual void OnSendOpenAck( 00878 H245_H2250LogicalChannelAckParameters & param 00879 ) const; 00880 00887 virtual BOOL OnReceivedPDU( 00888 const H245_H2250LogicalChannelParameters & param, 00889 unsigned & errorCode 00890 ); 00891 00898 virtual BOOL OnReceivedAckPDU( 00899 const H245_H2250LogicalChannelAckParameters & param 00900 ); 00902 00903 void SetExternalAddress( 00904 const H323TransportAddress & data, 00905 const H323TransportAddress & control 00906 ); 00907 00908 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; } 00909 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; } 00910 00911 BOOL GetRemoteAddress( 00912 PIPSocket::Address & ip, 00913 WORD & dataPort 00914 ) const; 00915 00916 protected: 00917 unsigned sessionID; 00918 H323TransportAddress externalMediaAddress; 00919 H323TransportAddress externalMediaControlAddress; 00920 H323TransportAddress remoteMediaAddress; 00921 H323TransportAddress remoteMediaControlAddress; 00922 00923 BOOL isRunning; 00924 }; 00925 00926 00928 00935 class H323DataChannel : public H323UnidirectionalChannel 00936 { 00937 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel); 00938 00939 public: 00944 H323DataChannel( 00945 H323Connection & connection, 00946 const H323Capability & capability, 00947 Directions direction, 00948 unsigned sessionID 00949 ); 00950 00953 ~H323DataChannel(); 00955 00960 virtual void CleanUpOnTermination(); 00961 00966 virtual unsigned GetSessionID() const; 00967 00970 virtual BOOL OnSendingPDU( 00971 H245_OpenLogicalChannel & openPDU 00972 ) const; 00973 00977 virtual void OnSendOpenAck( 00978 const H245_OpenLogicalChannel & open, 00979 H245_OpenLogicalChannelAck & ack 00980 ) const; 00981 00989 virtual BOOL OnReceivedPDU( 00990 const H245_OpenLogicalChannel & pdu, 00991 unsigned & errorCode 00992 ); 00993 01001 virtual BOOL OnReceivedAckPDU( 01002 const H245_OpenLogicalChannelAck & pdu 01003 ); 01005 01014 virtual BOOL CreateListener(); 01015 01023 virtual BOOL CreateTransport(); 01025 01026 protected: 01027 unsigned sessionID; 01028 H323Listener * listener; 01029 BOOL autoDeleteListener; 01030 H323Transport * transport; 01031 BOOL autoDeleteTransport; 01032 BOOL separateReverseChannel; 01033 }; 01034 01035 01036 #endif // __OPAL_CHANNELS_H 01037 01038