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/connection.h>
00117
00118 #include <iax2/frame.h>
00119 #include <iax2/iax2jitter.h>
00120 #include <iax2/iedata.h>
00121 #include <iax2/processor.h>
00122 #include <iax2/callprocessor.h>
00123 #include <iax2/safestrings.h>
00124 #include <iax2/sound.h>
00125
00126 class IAX2EndPoint;
00127
00128
00130
00136 class IAX2Connection : public OpalConnection
00137 {
00138 PCLASSINFO(IAX2Connection, OpalConnection);
00139
00140 public:
00143
00146 IAX2Connection(
00147 OpalCall & call,
00148 IAX2EndPoint & endpoint,
00149 const PString & token,
00150 void *userData,
00151 const PString & remoteParty,
00152 const PString & remotePartyName = PString::Empty()
00153 );
00154
00158 ~IAX2Connection();
00160
00169 virtual bool IsNetworkConnection() const { return true; }
00170
00178 virtual bool TransferConnection(
00179 const PString & remoteParty
00180 );
00181
00200 virtual void OnReleased();
00201
00212 OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
00213
00215 void EndCallNow(
00216 CallEndReason reason = EndedByLocalUser
00217 );
00218
00219 OpalConnection::SendUserInputModes GetRealSendUserInputMode() const;
00220
00222 void SendDtmf(const PString & dtmf);
00223
00225 virtual PBoolean SendUserInputString(const PString & value );
00226
00228 virtual PBoolean SendUserInputTone(char tone, unsigned duration );
00229
00231 PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
00232
00241 virtual void AnsweringCall(
00242 AnswerCallResponse response
00243 );
00244
00252 void OnConnected();
00253
00265 virtual PBoolean SetConnected();
00266
00281 void OnEstablished();
00282
00297 virtual void Release( CallEndReason reason = EndedByLocalUser
00298 );
00299
00311 PBoolean SetAlerting(
00312 const PString & calleeName,
00313 PBoolean withMedia
00314 );
00315
00323 OpalMediaStream * CreateMediaStream(
00324 const OpalMediaFormat & mediaFormat,
00325 unsigned sessionID,
00326 PBoolean isSource
00327 );
00328
00339 void SetCallToken(PString newToken);
00340
00342 PString GetCallToken() { return iax2Processor.GetCallToken(); }
00343
00346 void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
00347
00351 void PutSoundPacketToNetwork(PBYTEArray *sund);
00352
00355 void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
00356
00361 PBoolean ReadSoundPacket(RTP_DataFrame & packet);
00362
00364 IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
00365
00367 IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
00368
00370 const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
00371
00376 void OnSetUp();
00377
00378 PBoolean OnIncomingCall(
00379 unsigned int options,
00380 OpalConnection::StringOptions * stringOptions
00381 );
00382
00383
00391 PBoolean SetUpConnection();
00392
00393
00397 PINDEX GetSupportedCodecs();
00398
00402 PINDEX GetPreferredCodec();
00403
00406 void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
00407
00408
00416 unsigned int ChooseCodec();
00417
00419 virtual PBoolean IsConnectionOnHold();
00420
00422 virtual bool RetrieveConnection();
00423
00425 virtual bool HoldConnection();
00426
00428 void RemoteHoldConnection();
00429
00431 void RemoteRetrieveConnection();
00432
00439 void SetUserName(PString & inUserName) { userName = inUserName; };
00440
00442 PString GetUserName() const { return userName; };
00443
00450 void SetPassword(PString & inPassword) { password = inPassword; };
00451
00453 PString GetPassword() const { return password; };
00454
00455
00465 virtual PBoolean ForwardCall(
00466 const PString & forwardParty
00467 );
00468
00472 void IncomingEthernetFrame (IAX2Frame *frame);
00473
00477
00478
00480 IAX2EndPoint & GetEndPoint() { return endpoint; }
00481
00484 void ReportStatistics();
00485
00486
00487 protected:
00488
00490 PString userName;
00491
00493 PString password;
00494
00498
00500 IAX2EndPoint &endpoint;
00501
00504 OpalMediaFormatList remoteMediaFormats;
00505
00508 OpalMediaFormatList localMediaFormats;
00509
00511 IAX2CallProcessor & iax2Processor;
00512
00514 PBoolean local_hold;
00515
00517 PBoolean remote_hold;
00518
00520
00523 IAX2JitterBuffer jitterBuffer;
00524
00532 RTP_DataFrame::PayloadTypes opalPayloadType;
00533
00534 friend class IAX2CallProcessor;
00535 };
00536
00537
00539
00540
00541
00542 #endif // IAX_CONNECTION_H
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554