OPAL  Version 3.12.9
iax2con.h
Go to the documentation of this file.
1 /*
2  *
3  * Inter Asterisk Exchange 2
4  *
5  * Open Phone Abstraction Library (OPAL)
6  *
7  * Describes the IAX2 extension of the OpalConnection class.
8  *
9  * Copyright (c) 2005 Indranet Technologies Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Indranet Technologies Ltd.
24  *
25  * The author of this code is Derek J Smithies
26  *
27  * $Revision: 27079 $
28  * $Author: rjongbloed $
29  * $Date: 2012-03-01 16:12:01 +1100 (Thu, 01 Mar 2012) $
30  */
31 
32 #ifndef OPAL_IAX2_IAX2CON_H
33 #define OPAL_IAX2_IAX2CON_H
34 
35 #ifndef _PTLIB_H
36 #include <ptlib.h>
37 #endif
38 
39 #include <opal/buildopts.h>
40 
41 #if OPAL_IAX2
42 
43 #include <opal/connection.h>
44 #include <rtp/jitter.h>
45 
46 #include <iax2/frame.h>
47 #include <iax2/iedata.h>
48 #include <iax2/processor.h>
49 #include <iax2/callprocessor.h>
50 #include <iax2/safestrings.h>
51 #include <iax2/sound.h>
52 
53 class IAX2EndPoint;
54 
55 
57 
64 {
65  PCLASSINFO(IAX2Connection, OpalConnection);
66 
67  public:
70 
74  OpalCall & call,
76  const PString & token,
77  void *userData,
78  const PString & remoteParty,
79  const PString & remotePartyName = PString::Empty()
80  );
81 
87 
91  void StartOperation();
92 
101  virtual bool IsNetworkConnection() const { return true; }
102 
110  virtual bool TransferConnection(
111  const PString & remoteParty
112  );
113 
132  virtual void OnReleased();
133 
145 
147  void EndCallNow(
148  CallEndReason reason = EndedByLocalUser
149  );
150 
152  void SendDtmf(const PString & dtmf);
153 
155  virtual PBoolean SendUserInputString(const PString & value );
156 
158  virtual PBoolean SendUserInputTone(char tone, unsigned duration );
159 
162 
171  virtual void AnsweringCall(
172  AnswerCallResponse response
173  );
174 
182  void OnConnected();
183 
195  virtual PBoolean SetConnected();
196 
211  void OnEstablished();
212 
224  PBoolean SetAlerting(
225  const PString & calleeName,
226  PBoolean withMedia
227  );
228 
237  const OpalMediaFormat & mediaFormat,
238  unsigned sessionID,
239  PBoolean isSource
240  );
241 
252  void SetCallToken(PString newToken);
253 
255  PString GetCallToken() { return iax2Processor.GetCallToken(); }
256 
260 
264  void PutSoundPacketToNetwork(PBYTEArray *sund);
265 
268  void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
269 
274  PBoolean ReadSoundPacket(RTP_DataFrame & packet);
275 
278 
281 
283  const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
284 
289  void OnSetUp();
290 
291 
299  PBoolean SetUpConnection();
300 
301 
305  PINDEX GetSupportedCodecs();
306 
310  PINDEX GetPreferredCodec();
311 
314  void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
315 
316 
324  unsigned int ChooseCodec();
325 
333  virtual bool Hold(
334  bool fromRemote,
335  bool placeOnHold
336  );
337 
342  virtual bool IsOnHold(
343  bool fromRemote
344  );
345 
347  void RemoteHoldConnection();
348 
351 
358  void SetUserName(PString & inUserName) { userName = inUserName; };
359 
361  PString GetUserName() const { return userName; };
362 
369  void SetPassword(PString & inPassword) { password = inPassword; };
370 
372  PString GetPassword() const { return password; };
373 
374 
384  virtual PBoolean ForwardCall(
385  const PString & forwardParty
386  );
387 
391  void IncomingEthernetFrame (IAX2Frame *frame);
392 
396  //static PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
397 
400 
403  void ReportStatistics();
404 
405 
406  protected:
407 
409  PString userName;
410 
412  PString password;
413 
417 
420 
424 
428 
431 
433  PBoolean local_hold;
434 
436  PBoolean remote_hold;
437 
439 
443 
452 
453  friend class IAX2CallProcessor;
454 };
455 
456 
458 
459 
460 #endif // OPAL_IAX2
461 
462 #endif // OPAL_IAX2_IAX2CON_H
463 
464 /* The comment below is magic for those who use emacs to edit this file.
465  * With the comment below, the tab key does auto indent to 2 spaces.
466  *
467  * Local Variables:
468  * mode:c
469  * c-basic-offset:2
470  * End:
471  */