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
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
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