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 #ifndef OPAL_IAX2_IAX2CON_H
00033 #define OPAL_IAX2_IAX2CON_H
00034
00035 #ifndef _PTLIB_H
00036 #include <ptlib.h>
00037 #endif
00038
00039 #include <opal/buildopts.h>
00040
00041 #if OPAL_IAX2
00042
00043 #include <opal/connection.h>
00044
00045 #include <iax2/frame.h>
00046 #include <iax2/iax2jitter.h>
00047 #include <iax2/iedata.h>
00048 #include <iax2/processor.h>
00049 #include <iax2/callprocessor.h>
00050 #include <iax2/safestrings.h>
00051 #include <iax2/sound.h>
00052
00053 class IAX2EndPoint;
00054
00055
00057
00063 class IAX2Connection : public OpalConnection
00064 {
00065 PCLASSINFO(IAX2Connection, OpalConnection);
00066
00067 public:
00070
00073 IAX2Connection(
00074 OpalCall & call,
00075 IAX2EndPoint & endpoint,
00076 const PString & token,
00077 void *userData,
00078 const PString & remoteParty,
00079 const PString & remotePartyName = PString::Empty()
00080 );
00081
00085 ~IAX2Connection();
00087
00091 void StartOperation();
00092
00101 virtual bool IsNetworkConnection() const { return true; }
00102
00110 virtual bool TransferConnection(
00111 const PString & remoteParty
00112 );
00113
00132 virtual void OnReleased();
00133
00144 OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
00145
00147 void EndCallNow(
00148 CallEndReason reason = EndedByLocalUser
00149 );
00150
00151 OpalConnection::SendUserInputModes GetRealSendUserInputMode() const;
00152
00154 void SendDtmf(const PString & dtmf);
00155
00157 virtual PBoolean SendUserInputString(const PString & value );
00158
00160 virtual PBoolean SendUserInputTone(char tone, unsigned duration );
00161
00163 PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
00164
00173 virtual void AnsweringCall(
00174 AnswerCallResponse response
00175 );
00176
00184 void OnConnected();
00185
00197 virtual PBoolean SetConnected();
00198
00213 void OnEstablished();
00214
00229 virtual void Release( CallEndReason reason = EndedByLocalUser
00230 );
00231
00243 PBoolean SetAlerting(
00244 const PString & calleeName,
00245 PBoolean withMedia
00246 );
00247
00255 virtual OpalMediaStream * CreateMediaStream(
00256 const OpalMediaFormat & mediaFormat,
00257 unsigned sessionID,
00258 PBoolean isSource
00259 );
00260
00271 void SetCallToken(PString newToken);
00272
00274 PString GetCallToken() { return iax2Processor.GetCallToken(); }
00275
00278 void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
00279
00283 void PutSoundPacketToNetwork(PBYTEArray *sund);
00284
00287 void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
00288
00293 PBoolean ReadSoundPacket(RTP_DataFrame & packet);
00294
00296 IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
00297
00299 IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
00300
00302 const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
00303
00308 void OnSetUp();
00309
00310
00318 PBoolean SetUpConnection();
00319
00320
00324 PINDEX GetSupportedCodecs();
00325
00329 PINDEX GetPreferredCodec();
00330
00333 void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
00334
00335
00343 unsigned int ChooseCodec();
00344
00346 virtual PBoolean IsConnectionOnHold();
00347
00349 virtual bool RetrieveConnection();
00350
00352 virtual bool HoldConnection();
00353
00355 void RemoteHoldConnection();
00356
00358 void RemoteRetrieveConnection();
00359
00366 void SetUserName(PString & inUserName) { userName = inUserName; };
00367
00369 PString GetUserName() const { return userName; };
00370
00377 void SetPassword(PString & inPassword) { password = inPassword; };
00378
00380 PString GetPassword() const { return password; };
00381
00382
00392 virtual PBoolean ForwardCall(
00393 const PString & forwardParty
00394 );
00395
00399 void IncomingEthernetFrame (IAX2Frame *frame);
00400
00404
00405
00407 IAX2EndPoint & GetEndPoint() { return endpoint; }
00408
00411 void ReportStatistics();
00412
00413
00414 protected:
00415
00417 PString userName;
00418
00420 PString password;
00421
00425
00427 IAX2EndPoint &endpoint;
00428
00431 OpalMediaFormatList remoteMediaFormats;
00432
00435 OpalMediaFormatList localMediaFormats;
00436
00438 IAX2CallProcessor & iax2Processor;
00439
00441 PBoolean local_hold;
00442
00444 PBoolean remote_hold;
00445
00447
00450 IAX2JitterBuffer jitterBuffer;
00451
00459 RTP_DataFrame::PayloadTypes opalPayloadType;
00460
00461 friend class IAX2CallProcessor;
00462 };
00463
00464
00466
00467
00468 #endif // OPAL_IAX2
00469
00470 #endif // OPAL_IAX2_IAX2CON_H
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480