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 #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