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
#ifndef __OPAL_H323NEG_H
00140
#define __OPAL_H323NEG_H
00141
00142
#ifdef P_USE_PRAGMA
00143
#pragma interface
00144
#endif
00145
00146
00147
#include "h323pdu.h"
00148
#include "channels.h"
00149
00150
00151
00153
00156 class H245Negotiator :
public PObject
00157 {
00158 PCLASSINFO(
H245Negotiator, PObject);
00159
00160
public:
00161
H245Negotiator(
H323EndPoint &
endpoint,
H323Connection &
connection);
00162
00163
protected:
00164
PDECLARE_NOTIFIER(PTimer,
H245Negotiator, HandleTimeout);
00165
00166 H323EndPoint & endpoint;
00167 H323Connection & connection;
00168 PTimer
replyTimer;
00169 PMutex
mutex;
00170 };
00171
00172
00175 class H245NegMasterSlaveDetermination :
public H245Negotiator
00176 {
00177 PCLASSINFO(
H245NegMasterSlaveDetermination,
H245Negotiator);
00178
00179
public:
00180
H245NegMasterSlaveDetermination(
H323EndPoint & endpoint,
H323Connection & connection);
00181
00182 BOOL
Start(BOOL renegotiate);
00183
void Stop();
00184 BOOL
HandleIncoming(
const H245_MasterSlaveDetermination & pdu);
00185 BOOL
HandleAck(
const H245_MasterSlaveDeterminationAck & pdu);
00186 BOOL
HandleReject(
const H245_MasterSlaveDeterminationReject & pdu);
00187 BOOL
HandleRelease(
const H245_MasterSlaveDeterminationRelease & pdu);
00188
void HandleTimeout(PTimer &, INT);
00189
00190 BOOL
IsMaster()
const {
return status ==
e_DeterminedMaster; }
00191 BOOL
IsDetermined()
const {
return state ==
e_Idle &&
status !=
e_Indeterminate; }
00192
00193
protected:
00194 BOOL
Restart();
00195
00196 enum States {
00197
e_Idle,
e_Outgoing,
e_Incoming,
00198
e_NumStates
00199 } state;
00200
#if PTRACING
00201
static const char *
const StateNames[e_NumStates];
00202
friend ostream & operator<<(ostream & o, States s) {
return o << StateNames[s]; }
00203
#endif
00204
00205 DWORD
determinationNumber;
00206 unsigned retryCount;
00207
00208 enum MasterSlaveStatus {
00209
e_Indeterminate,
e_DeterminedMaster,
e_DeterminedSlave,
00210
e_NumStatuses
00211 } status;
00212
#if PTRACING
00213
static const char *
const StatusNames[e_NumStatuses];
00214
friend ostream & operator<<(ostream & o , MasterSlaveStatus s) {
return o << StatusNames[s]; }
00215
#endif
00216
};
00217
00218
00221 class H245NegTerminalCapabilitySet :
public H245Negotiator
00222 {
00223 PCLASSINFO(
H245NegTerminalCapabilitySet,
H245Negotiator);
00224
00225
public:
00226
H245NegTerminalCapabilitySet(
H323EndPoint & endpoint,
H323Connection & connection);
00227
00228 BOOL
Start(BOOL renegotiate, BOOL empty = FALSE);
00229
void Stop();
00230 BOOL
HandleIncoming(
const H245_TerminalCapabilitySet & pdu);
00231 BOOL
HandleAck(
const H245_TerminalCapabilitySetAck & pdu);
00232 BOOL
HandleReject(
const H245_TerminalCapabilitySetReject & pdu);
00233 BOOL
HandleRelease(
const H245_TerminalCapabilitySetRelease & pdu);
00234
void HandleTimeout(PTimer &, INT);
00235
00236 BOOL
HasSentCapabilities()
const {
return state ==
e_Sent; }
00237 BOOL
HasReceivedCapabilities()
const {
return receivedCapabilites; }
00238
00239
protected:
00240 enum States {
00241
e_Idle,
e_InProgress,
e_Sent,
00242
e_NumStates
00243 } state;
00244
#if PTRACING
00245
static const char *
const StateNames[e_NumStates];
00246
friend ostream & operator<<(ostream & o, States s) {
return o << StateNames[s]; }
00247
#endif
00248
00249 unsigned inSequenceNumber;
00250 unsigned outSequenceNumber;
00251
00252 BOOL
receivedCapabilites;
00253 };
00254
00255
00258 class H245NegLogicalChannel :
public H245Negotiator
00259 {
00260 PCLASSINFO(
H245NegLogicalChannel,
H245Negotiator);
00261
00262
public:
00263
H245NegLogicalChannel(
H323EndPoint & endpoint,
00264
H323Connection & connection,
00265
const H323ChannelNumber &
channelNumber);
00266
H245NegLogicalChannel(
H323EndPoint & endpoint,
00267
H323Connection & connection,
00268
H323Channel &
channel);
00269
~H245NegLogicalChannel();
00270
00271
virtual BOOL
Open(
00272
const H323Capability & capability,
00273
unsigned sessionID,
00274
unsigned replacementFor = 0
00275 );
00276
virtual BOOL
Close();
00277
virtual BOOL
HandleOpen(
const H245_OpenLogicalChannel & pdu);
00278
virtual BOOL
HandleOpenAck(
const H245_OpenLogicalChannelAck & pdu);
00279
virtual BOOL
HandleOpenConfirm(
const H245_OpenLogicalChannelConfirm & pdu);
00280
virtual BOOL
HandleReject(
const H245_OpenLogicalChannelReject & pdu);
00281
virtual BOOL
HandleClose(
const H245_CloseLogicalChannel & pdu);
00282
virtual BOOL
HandleCloseAck(
const H245_CloseLogicalChannelAck & pdu);
00283
virtual BOOL
HandleRequestClose(
const H245_RequestChannelClose & pdu);
00284
virtual BOOL
HandleRequestCloseAck(
const H245_RequestChannelCloseAck & pdu);
00285
virtual BOOL
HandleRequestCloseReject(
const H245_RequestChannelCloseReject & pdu);
00286
virtual BOOL
HandleRequestCloseRelease(
const H245_RequestChannelCloseRelease & pdu);
00287
virtual void HandleTimeout(PTimer &, INT);
00288
00289
H323Channel *
GetChannel();
00290
00291
00292
protected:
00293
virtual BOOL
OpenWhileLocked(
00294
const H323Capability & capability,
00295
unsigned sessionID,
00296
unsigned replacementFor = 0
00297 );
00298
virtual BOOL
CloseWhileLocked();
00299
virtual void Release();
00300
00301
00302 H323Channel * channel;
00303
00304 H323ChannelNumber channelNumber;
00305
00306 enum States {
00307
e_Released,
00308
e_AwaitingEstablishment,
00309
e_Established,
00310
e_AwaitingRelease,
00311
e_AwaitingConfirmation,
00312
e_AwaitingResponse,
00313
e_NumStates
00314 } state;
00315
#if PTRACING
00316
static const char *
const StateNames[e_NumStates];
00317
friend ostream & operator<<(ostream & o, States s) {
return o << StateNames[s]; }
00318
#endif
00319
00320
00321
friend class H245NegLogicalChannels;
00322 };
00323
00324
00325
PDICTIONARY(H245LogicalChannelDict,
H323ChannelNumber,
H245NegLogicalChannel);
00326
00329 class H245NegLogicalChannels :
public H245Negotiator
00330 {
00331 PCLASSINFO(
H245NegLogicalChannels,
H245Negotiator);
00332
00333
public:
00334
H245NegLogicalChannels(
H323EndPoint & endpoint,
H323Connection & connection);
00335
00336
virtual void Add(
H323Channel & channel);
00337
00338
virtual BOOL
Open(
00339
const H323Capability & capability,
00340
unsigned sessionID,
00341
unsigned replacementFor = 0
00342 );
00343
virtual BOOL
Close(
unsigned channelNumber, BOOL fromRemote);
00344
virtual BOOL
HandleOpen(
const H245_OpenLogicalChannel & pdu);
00345
virtual BOOL
HandleOpenAck(
const H245_OpenLogicalChannelAck & pdu);
00346
virtual BOOL
HandleOpenConfirm(
const H245_OpenLogicalChannelConfirm & pdu);
00347
virtual BOOL
HandleReject(
const H245_OpenLogicalChannelReject & pdu);
00348
virtual BOOL
HandleClose(
const H245_CloseLogicalChannel & pdu);
00349
virtual BOOL
HandleCloseAck(
const H245_CloseLogicalChannelAck & pdu);
00350
virtual BOOL
HandleRequestClose(
const H245_RequestChannelClose & pdu);
00351
virtual BOOL
HandleRequestCloseAck(
const H245_RequestChannelCloseAck & pdu);
00352
virtual BOOL
HandleRequestCloseReject(
const H245_RequestChannelCloseReject & pdu);
00353
virtual BOOL
HandleRequestCloseRelease(
const H245_RequestChannelCloseRelease & pdu);
00354
00355
H323ChannelNumber GetNextChannelNumber();
00356 PINDEX
GetSize()
const {
return channels.GetSize(); }
00357
H323Channel * GetChannelAt(PINDEX i);
00358
H323Channel * FindChannel(
unsigned channelNumber, BOOL fromRemote);
00359
H245NegLogicalChannel & GetNegLogicalChannelAt(PINDEX i);
00360
H245NegLogicalChannel * FindNegLogicalChannel(
unsigned channelNumber, BOOL fromRemote);
00361
H323Channel * FindChannelBySession(
unsigned rtpSessionId, BOOL fromRemote);
00362
void RemoveAll();
00363
00364
protected:
00365 H323ChannelNumber lastChannelNumber;
00366 H245LogicalChannelDict
channels;
00367 };
00368
00369
00372 class H245NegRequestMode :
public H245Negotiator
00373 {
00374 PCLASSINFO(
H245NegRequestMode,
H245Negotiator);
00375
00376
public:
00377
H245NegRequestMode(
H323EndPoint & endpoint,
H323Connection & connection);
00378
00379
virtual BOOL
StartRequest(
const PString & newModes);
00380
virtual BOOL StartRequest(
const H245_ArrayOf_ModeDescription & newModes);
00381
virtual BOOL
HandleRequest(
const H245_RequestMode & pdu);
00382
virtual BOOL
HandleAck(
const H245_RequestModeAck & pdu);
00383
virtual BOOL
HandleReject(
const H245_RequestModeReject & pdu);
00384
virtual BOOL
HandleRelease(
const H245_RequestModeRelease & pdu);
00385
virtual void HandleTimeout(PTimer &, INT);
00386
00387
protected:
00388 BOOL
awaitingResponse;
00389 unsigned inSequenceNumber;
00390 unsigned outSequenceNumber;
00391 };
00392
00393
00396 class H245NegRoundTripDelay :
public H245Negotiator
00397 {
00398 PCLASSINFO(
H245NegRoundTripDelay,
H245Negotiator);
00399
00400
public:
00401
H245NegRoundTripDelay(
H323EndPoint & endpoint,
H323Connection & connection);
00402
00403 BOOL
StartRequest();
00404 BOOL
HandleRequest(
const H245_RoundTripDelayRequest & pdu);
00405 BOOL
HandleResponse(
const H245_RoundTripDelayResponse & pdu);
00406
void HandleTimeout(PTimer &, INT);
00407
00408 PTimeInterval
GetRoundTripDelay()
const {
return roundTripTime; }
00409 BOOL
IsRemoteOffline()
const {
return retryCount == 0; }
00410
00411
protected:
00412 BOOL
awaitingResponse;
00413 unsigned sequenceNumber;
00414 PTimeInterval
tripStartTime;
00415 PTimeInterval
roundTripTime;
00416 unsigned retryCount;
00417 };
00418
00419
00420
#endif // __OPAL_H323NEG_H
00421
00422