OPAL Version 3.10.2
|
00001 /* 00002 * 00003 * Inter Asterisk Exchange 2 00004 * 00005 * Open Phone Abstraction Library (OPAL) 00006 * 00007 * Describes the IAX2 extension of the OpalConnection class. 00008 * 00009 * Copyright (c) 2005 Indranet Technologies Ltd. 00010 * 00011 * The contents of this file are subject to the Mozilla Public License 00012 * Version 1.0 (the "License"); you may not use this file except in 00013 * compliance with the License. You may obtain a copy of the License at 00014 * http://www.mozilla.org/MPL/ 00015 * 00016 * Software distributed under the License is distributed on an "AS IS" 00017 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00018 * the License for the specific language governing rights and limitations 00019 * under the License. 00020 * 00021 * The Original Code is Open Phone Abstraction Library. 00022 * 00023 * The Initial Developer of the Original Code is Indranet Technologies Ltd. 00024 * 00025 * The author of this code is Derek J Smithies 00026 * 00027 * $Revision: 24606 $ 00028 * $Author: dereksmithies $ 00029 * $Date: 2010-07-28 22:51:05 -0500 (Wed, 28 Jul 2010) $ 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 #include <rtp/jitter.h> 00045 00046 #include <iax2/frame.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 00152 void SendDtmf(const PString & dtmf); 00153 00155 virtual PBoolean SendUserInputString(const PString & value ); 00156 00158 virtual PBoolean SendUserInputTone(char tone, unsigned duration ); 00159 00161 PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); } 00162 00171 virtual void AnsweringCall( 00172 AnswerCallResponse response 00173 ); 00174 00182 void OnConnected(); 00183 00195 virtual PBoolean SetConnected(); 00196 00211 void OnEstablished(); 00212 00227 virtual void Release( CallEndReason reason = EndedByLocalUser 00228 ); 00229 00241 PBoolean SetAlerting( 00242 const PString & calleeName, 00243 PBoolean withMedia 00244 ); 00245 00253 virtual OpalMediaStream * CreateMediaStream( 00254 const OpalMediaFormat & mediaFormat, 00255 unsigned sessionID, 00256 PBoolean isSource 00257 ); 00258 00269 void SetCallToken(PString newToken); 00270 00272 PString GetCallToken() { return iax2Processor.GetCallToken(); } 00273 00276 void TransmitFrameToRemoteEndpoint(IAX2Frame *src); 00277 00281 void PutSoundPacketToNetwork(PBYTEArray *sund); 00282 00285 void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame); 00286 00291 PBoolean ReadSoundPacket(RTP_DataFrame & packet); 00292 00294 IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); } 00295 00297 IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); } 00298 00300 const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); } 00301 00306 void OnSetUp(); 00307 00308 00316 PBoolean SetUpConnection(); 00317 00318 00322 PINDEX GetSupportedCodecs(); 00323 00327 PINDEX GetPreferredCodec(); 00328 00331 void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format); 00332 00333 00341 unsigned int ChooseCodec(); 00342 00350 virtual bool Hold( 00351 bool fromRemote, 00352 bool placeOnHold 00353 ); 00354 00359 virtual bool IsOnHold( 00360 bool fromRemote 00361 ); 00362 00364 void RemoteHoldConnection(); 00365 00367 void RemoteRetrieveConnection(); 00368 00375 void SetUserName(PString & inUserName) { userName = inUserName; }; 00376 00378 PString GetUserName() const { return userName; }; 00379 00386 void SetPassword(PString & inPassword) { password = inPassword; }; 00387 00389 PString GetPassword() const { return password; }; 00390 00391 00401 virtual PBoolean ForwardCall( 00402 const PString & forwardParty 00403 ); 00404 00408 void IncomingEthernetFrame (IAX2Frame *frame); 00409 00413 //static PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame); 00414 00416 IAX2EndPoint & GetEndPoint() { return endpoint; } 00417 00420 void ReportStatistics(); 00421 00422 00423 protected: 00424 00426 PString userName; 00427 00429 PString password; 00430 00434 00436 IAX2EndPoint &endpoint; 00437 00440 OpalMediaFormatList remoteMediaFormats; 00441 00444 OpalMediaFormatList localMediaFormats; 00445 00447 IAX2CallProcessor & iax2Processor; 00448 00450 PBoolean local_hold; 00451 00453 PBoolean remote_hold; 00454 00456 00459 OpalJitterBuffer jitterBuffer; 00460 00468 RTP_DataFrame::PayloadTypes opalPayloadType; 00469 00470 friend class IAX2CallProcessor; 00471 }; 00472 00473 00475 00476 00477 #endif // OPAL_IAX2 00478 00479 #endif // OPAL_IAX2_IAX2CON_H 00480 00481 /* The comment below is magic for those who use emacs to edit this file. 00482 * With the comment below, the tab key does auto indent to 2 spaces. 00483 * 00484 * Local Variables: 00485 * mode:c 00486 * c-basic-offset:2 00487 * End: 00488 */