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
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 #ifndef __OPAL_CHANNELS_H
00220 #define __OPAL_CHANNELS_H
00221
00222 #ifdef P_USE_PRAGMA
00223 #pragma interface
00224 #endif
00225
00226
00227 #include <rtp/rtp.h>
00228 #include <h323/transaddr.h>
00229
00230
00231 class OpalMediaStream;
00232 class OpalMediaCommand;
00233
00234 class H245_OpenLogicalChannel;
00235 class H245_OpenLogicalChannelAck;
00236 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00237 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00238 class H245_H2250LogicalChannelParameters;
00239 class H245_H2250LogicalChannelAckParameters;
00240 class H245_MiscellaneousCommand_type;
00241 class H245_MiscellaneousIndication_type;
00242
00243 class H323EndPoint;
00244 class H323Connection;
00245 class H323Capability;
00246 class H323_RTP_Session;
00247
00248
00250
00254 class H323ChannelNumber : public PObject
00255 {
00256 PCLASSINFO(H323ChannelNumber, PObject);
00257
00258 public:
00259 H323ChannelNumber() { number = 0; fromRemote = FALSE; }
00260 H323ChannelNumber(unsigned number, BOOL fromRemote);
00261
00262 virtual PObject * Clone() const;
00263 virtual PINDEX HashFunction() const;
00264 virtual void PrintOn(ostream & strm) const;
00265 virtual Comparison Compare(const PObject & obj) const;
00266
00267 H323ChannelNumber & operator++(int);
00268 operator unsigned() const { return number; }
00269 BOOL IsFromRemote() const { return fromRemote; }
00270
00271 protected:
00272 unsigned number;
00273 BOOL fromRemote;
00274 };
00275
00276
00283 class H323Channel : public PObject
00284 {
00285 PCLASSINFO(H323Channel, PObject);
00286
00287 public:
00292 H323Channel(
00293 H323Connection & connection,
00294 const H323Capability & capability
00295 );
00296
00301 ~H323Channel();
00303
00306 virtual void PrintOn(
00307 ostream & strm
00308 ) const;
00310
00313 enum Directions {
00314 IsBidirectional,
00315 IsTransmitter,
00316 IsReceiver,
00317 NumDirections
00318 };
00319 #if PTRACING
00320 friend ostream & operator<<(ostream & out, Directions dir);
00321 #endif
00322
00327 virtual Directions GetDirection() const = 0;
00328
00334 virtual unsigned GetSessionID() const;
00335
00342 virtual BOOL GetMediaTransportAddress(
00343 OpalTransportAddress & data,
00344 OpalTransportAddress & control
00345 ) const;
00346
00354 virtual BOOL SetInitialBandwidth() = 0;
00355
00360 virtual BOOL Open();
00361
00364 virtual BOOL Start() = 0;
00365
00368 virtual void Close();
00369
00372 BOOL IsOpen() const { return opened && !terminating; }
00373
00381 virtual OpalMediaStream * GetMediaStream(
00382 BOOL deleted = FALSE
00383 ) const = 0;
00384
00385
00388 virtual BOOL OnSendingPDU(
00389 H245_OpenLogicalChannel & openPDU
00390 ) const = 0;
00391
00397 virtual void OnSendOpenAck(
00398 const H245_OpenLogicalChannel & open,
00399 H245_OpenLogicalChannelAck & ack
00400 ) const;
00401
00408 virtual BOOL OnReceivedPDU(
00409 const H245_OpenLogicalChannel & pdu,
00410 unsigned & errorCode
00411 );
00412
00419 virtual BOOL OnReceivedAckPDU(
00420 const H245_OpenLogicalChannelAck & pdu
00421 );
00422
00426 virtual void OnFlowControl(
00427 long bitRateRestriction
00428 );
00429
00433 virtual void OnMiscellaneousCommand(
00434 const H245_MiscellaneousCommand_type & type
00435 );
00436
00440 virtual void OnMiscellaneousIndication(
00441 const H245_MiscellaneousIndication_type & type
00442 );
00443
00447 virtual void OnJitterIndication(
00448 DWORD jitter,
00449 int skippedFrameCount,
00450 int additionalBuffer
00451 );
00453
00458 const H323ChannelNumber & GetNumber() const { return number; }
00459
00462 void SetNumber(const H323ChannelNumber & num) { number = num; }
00463
00466 const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00467
00470 void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00471
00474 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00475
00478 BOOL SetBandwidthUsed(
00479 unsigned bandwidth
00480 );
00481
00484 const H323Capability & GetCapability() const { return *capability; }
00485
00494 BOOL IsPaused() const { return paused; }
00495
00504 void SetPause(
00505 BOOL pause
00506 ) { paused = pause; }
00508
00509 protected:
00510 H323EndPoint & endpoint;
00511 H323Connection & connection;
00512 H323Capability * capability;
00513 H323ChannelNumber number;
00514 H323ChannelNumber reverseChannel;
00515 BOOL opened;
00516 BOOL paused;
00517 BOOL terminating;
00518
00519 private:
00520 unsigned bandwidthUsed;
00521 };
00522
00523
00524 PLIST(H323LogicalChannelList, H323Channel);
00525
00526
00527
00534 class H323UnidirectionalChannel : public H323Channel
00535 {
00536 PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00537
00538 public:
00543 H323UnidirectionalChannel(
00544 H323Connection & connection,
00545 const H323Capability & capability,
00546 Directions direction
00547 );
00548
00551 ~H323UnidirectionalChannel();
00553
00560 virtual Directions GetDirection() const;
00561
00569 virtual BOOL SetInitialBandwidth();
00570
00573 virtual BOOL Open();
00574
00579 virtual BOOL Start();
00580
00583 virtual void Close();
00584
00588 virtual void OnMiscellaneousCommand(
00589 const H245_MiscellaneousCommand_type & type
00590 );
00592
00598 virtual OpalMediaStream * GetMediaStream(BOOL deleted = FALSE) const;
00600
00601 protected:
00602 PDECLARE_NOTIFIER(OpalMediaCommand, H323UnidirectionalChannel, OnMediaCommand);
00603
00604 BOOL receiver;
00605 mutable OpalMediaStream * mediaStream;
00606 };
00607
00608
00615 class H323BidirectionalChannel : public H323Channel
00616 {
00617 PCLASSINFO(H323BidirectionalChannel, H323Channel);
00618
00619 public:
00624 H323BidirectionalChannel(
00625 H323Connection & connection,
00626 const H323Capability & capability
00627 );
00629
00636 virtual Directions GetDirection() const;
00637
00642 virtual BOOL Start();
00644 };
00645
00646
00648
00651 class H323_RealTimeChannel : public H323UnidirectionalChannel
00652 {
00653 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00654
00655 public:
00660 H323_RealTimeChannel(
00661 H323Connection & connection,
00662 const H323Capability & capability,
00663 Directions direction
00664 );
00666
00671 virtual BOOL OnSendingPDU(
00672 H245_OpenLogicalChannel & openPDU
00673 ) const;
00674
00678 virtual void OnSendOpenAck(
00679 const H245_OpenLogicalChannel & open,
00680 H245_OpenLogicalChannelAck & ack
00681 ) const;
00682
00690 virtual BOOL OnReceivedPDU(
00691 const H245_OpenLogicalChannel & pdu,
00692 unsigned & errorCode
00693 );
00694
00702 virtual BOOL OnReceivedAckPDU(
00703 const H245_OpenLogicalChannelAck & pdu
00704 );
00706
00711 virtual BOOL OnSendingPDU(
00712 H245_H2250LogicalChannelParameters & param
00713 ) const = 0;
00714
00718 virtual void OnSendOpenAck(
00719 H245_H2250LogicalChannelAckParameters & param
00720 ) const = 0;
00721
00728 virtual BOOL OnReceivedPDU(
00729 const H245_H2250LogicalChannelParameters & param,
00730 unsigned & errorCode
00731 ) = 0;
00732
00739 virtual BOOL OnReceivedAckPDU(
00740 const H245_H2250LogicalChannelAckParameters & param
00741 ) = 0;
00742
00745 virtual BOOL SetDynamicRTPPayloadType(
00746 int newType
00747 );
00748
00749 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00751
00752 protected:
00753 RTP_DataFrame::PayloadTypes rtpPayloadType;
00754 };
00755
00756
00758
00761 class H323_RTPChannel : public H323_RealTimeChannel
00762 {
00763 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00764
00765 public:
00770 H323_RTPChannel(
00771 H323Connection & connection,
00772 const H323Capability & capability,
00773 Directions direction,
00774 RTP_Session & rtp
00775 );
00776
00778 ~H323_RTPChannel();
00780
00787 virtual unsigned GetSessionID() const;
00789
00794 virtual BOOL OnSendingPDU(
00795 H245_H2250LogicalChannelParameters & param
00796 ) const;
00797
00801 virtual void OnSendOpenAck(
00802 H245_H2250LogicalChannelAckParameters & param
00803 ) const;
00804
00811 virtual BOOL OnReceivedPDU(
00812 const H245_H2250LogicalChannelParameters & param,
00813 unsigned & errorCode
00814 );
00815
00822 virtual BOOL OnReceivedAckPDU(
00823 const H245_H2250LogicalChannelAckParameters & param
00824 );
00826
00827 protected:
00828 RTP_Session & rtpSession;
00829 H323_RTP_Session & rtpCallbacks;
00830 };
00831
00832
00834
00838 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00839 {
00840 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00841
00842 public:
00847 H323_ExternalRTPChannel(
00848 H323Connection & connection,
00849 const H323Capability & capability,
00850 Directions direction,
00851 unsigned sessionID
00852 );
00855 H323_ExternalRTPChannel(
00856 H323Connection & connection,
00857 const H323Capability & capability,
00858 Directions direction,
00859 unsigned sessionID,
00860 const H323TransportAddress & data,
00861 const H323TransportAddress & control
00862 );
00865 H323_ExternalRTPChannel(
00866 H323Connection & connection,
00867 const H323Capability & capability,
00868 Directions direction,
00869 unsigned sessionID,
00870 const PIPSocket::Address & ip,
00871 WORD dataPort
00872 );
00874
00881 virtual unsigned GetSessionID() const;
00882
00889 virtual BOOL GetMediaTransportAddress(
00890 OpalTransportAddress & data,
00891 OpalTransportAddress & control
00892 ) const;
00893
00896 virtual BOOL Start();
00897
00904 virtual void Receive();
00905
00912 virtual void Transmit();
00914
00919 virtual BOOL OnSendingPDU(
00920 H245_H2250LogicalChannelParameters & param
00921 ) const;
00922
00926 virtual void OnSendOpenAck(
00927 H245_H2250LogicalChannelAckParameters & param
00928 ) const;
00929
00936 virtual BOOL OnReceivedPDU(
00937 const H245_H2250LogicalChannelParameters & param,
00938 unsigned & errorCode
00939 );
00940
00947 virtual BOOL OnReceivedAckPDU(
00948 const H245_H2250LogicalChannelAckParameters & param
00949 );
00951
00952 void SetExternalAddress(
00953 const H323TransportAddress & data,
00954 const H323TransportAddress & control
00955 );
00956
00957 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
00958 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00959
00960 BOOL GetRemoteAddress(
00961 PIPSocket::Address & ip,
00962 WORD & dataPort
00963 ) const;
00964
00965 protected:
00966 void Construct(H323Connection & conn, unsigned id);
00967
00968 unsigned sessionID;
00969 H323TransportAddress externalMediaAddress;
00970 H323TransportAddress externalMediaControlAddress;
00971 H323TransportAddress remoteMediaAddress;
00972 H323TransportAddress remoteMediaControlAddress;
00973 };
00974
00975
00977
00984 class H323DataChannel : public H323UnidirectionalChannel
00985 {
00986 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00987
00988 public:
00993 H323DataChannel(
00994 H323Connection & connection,
00995 const H323Capability & capability,
00996 Directions direction,
00997 unsigned sessionID
00998 );
00999
01002 ~H323DataChannel();
01004
01009 virtual void Close();
01010
01015 virtual unsigned GetSessionID() const;
01016
01019 virtual BOOL OnSendingPDU(
01020 H245_OpenLogicalChannel & openPDU
01021 ) const;
01022
01026 virtual void OnSendOpenAck(
01027 const H245_OpenLogicalChannel & open,
01028 H245_OpenLogicalChannelAck & ack
01029 ) const;
01030
01038 virtual BOOL OnReceivedPDU(
01039 const H245_OpenLogicalChannel & pdu,
01040 unsigned & errorCode
01041 );
01042
01050 virtual BOOL OnReceivedAckPDU(
01051 const H245_OpenLogicalChannelAck & pdu
01052 );
01054
01063 virtual BOOL CreateListener();
01064
01072 virtual BOOL CreateTransport();
01074
01075 protected:
01076 unsigned sessionID;
01077 H323Listener * listener;
01078 BOOL autoDeleteListener;
01079 H323Transport * transport;
01080 BOOL autoDeleteTransport;
01081 BOOL separateReverseChannel;
01082 };
01083
01084
01085 #endif // __OPAL_CHANNELS_H
01086
01087