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 #ifndef IAX_CONNECTION_H
00110 #define IAX_CONNECTION_H
00111
00112 #ifndef _PTLIB_H
00113 #include <ptlib.h>
00114 #endif
00115
00116 #include <opal/buildopts.h>
00117
00118 #include <opal/connection.h>
00119
00120 #include <iax2/frame.h>
00121 #include <iax2/iax2jitter.h>
00122 #include <iax2/iedata.h>
00123 #include <iax2/processor.h>
00124 #include <iax2/callprocessor.h>
00125 #include <iax2/safestrings.h>
00126 #include <iax2/sound.h>
00127
00128 class IAX2EndPoint;
00129
00130
00132
00138 class IAX2Connection : public OpalConnection
00139 {
00140 PCLASSINFO(IAX2Connection, OpalConnection);
00141
00142 public:
00145
00148 IAX2Connection(
00149 OpalCall & call,
00150 IAX2EndPoint & endpoint,
00151 const PString & token,
00152 void *userData,
00153 const PString & remoteParty,
00154 const PString & remotePartyName = PString::Empty()
00155 );
00156
00160 ~IAX2Connection();
00162
00171 virtual bool IsNetworkConnection() const { return true; }
00172
00180 virtual bool TransferConnection(
00181 const PString & remoteParty
00182 );
00183
00202 virtual void OnReleased();
00203
00214 OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
00215
00217 void EndCallNow(
00218 CallEndReason reason = EndedByLocalUser
00219 );
00220
00221 OpalConnection::SendUserInputModes GetRealSendUserInputMode() const;
00222
00224 void SendDtmf(const PString & dtmf);
00225
00227 virtual PBoolean SendUserInputString(const PString & value );
00228
00230 virtual PBoolean SendUserInputTone(char tone, unsigned duration );
00231
00233 PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
00234
00243 virtual void AnsweringCall(
00244 AnswerCallResponse response
00245 );
00246
00254 void OnConnected();
00255
00267 virtual PBoolean SetConnected();
00268
00283 void OnEstablished();
00284
00299 virtual void Release( CallEndReason reason = EndedByLocalUser
00300 );
00301
00313 PBoolean SetAlerting(
00314 const PString & calleeName,
00315 PBoolean withMedia
00316 );
00317
00325 OpalMediaStream * CreateMediaStream(
00326 const OpalMediaFormat & mediaFormat,
00327 unsigned sessionID,
00328 PBoolean isSource
00329 );
00330
00341 void SetCallToken(PString newToken);
00342
00344 PString GetCallToken() { return iax2Processor.GetCallToken(); }
00345
00348 void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
00349
00353 void PutSoundPacketToNetwork(PBYTEArray *sund);
00354
00357 void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
00358
00363 PBoolean ReadSoundPacket(RTP_DataFrame & packet);
00364
00366 IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
00367
00369 IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
00370
00372 const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
00373
00378 void OnSetUp();
00379
00380 PBoolean OnIncomingCall(
00381 unsigned int options,
00382 OpalConnection::StringOptions * stringOptions
00383 );
00384
00385
00393 PBoolean SetUpConnection();
00394
00395
00399 PINDEX GetSupportedCodecs();
00400
00404 PINDEX GetPreferredCodec();
00405
00408 void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
00409
00410
00418 unsigned int ChooseCodec();
00419
00421 virtual PBoolean IsConnectionOnHold();
00422
00424 virtual bool RetrieveConnection();
00425
00427 virtual bool HoldConnection();
00428
00430 void RemoteHoldConnection();
00431
00433 void RemoteRetrieveConnection();
00434
00441 void SetUserName(PString & inUserName) { userName = inUserName; };
00442
00444 PString GetUserName() const { return userName; };
00445
00452 void SetPassword(PString & inPassword) { password = inPassword; };
00453
00455 PString GetPassword() const { return password; };
00456
00457
00467 virtual PBoolean ForwardCall(
00468 const PString & forwardParty
00469 );
00470
00474 void IncomingEthernetFrame (IAX2Frame *frame);
00475
00479
00480
00482 IAX2EndPoint & GetEndPoint() { return endpoint; }
00483
00486 void ReportStatistics();
00487
00488
00489 protected:
00490
00492 PString userName;
00493
00495 PString password;
00496
00500
00502 IAX2EndPoint &endpoint;
00503
00506 OpalMediaFormatList remoteMediaFormats;
00507
00510 OpalMediaFormatList localMediaFormats;
00511
00513 IAX2CallProcessor & iax2Processor;
00514
00516 PBoolean local_hold;
00517
00519 PBoolean remote_hold;
00520
00522
00525 IAX2JitterBuffer jitterBuffer;
00526
00534 RTP_DataFrame::PayloadTypes opalPayloadType;
00535
00536 friend class IAX2CallProcessor;
00537 };
00538
00539
00541
00542
00543
00544 #endif // IAX_CONNECTION_H
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556