00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
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