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