OPAL  Version 3.14.3
iax2ep.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 OpalEndpoint 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: 29665 $
28  * $Author: rjongbloed $
29  * $Date: 2013-05-08 18:41:11 +1000 (Wed, 08 May 2013) $
30  */
31 
32 #ifndef OPAL_IAX2_IAX2EP_H
33 #define OPAL_IAX2_IAX2EP_H
34 
35 #ifndef _PTLIB_H
36 #include <ptlib.h>
37 #endif
38 
39 #ifdef P_USE_PRAGMA
40 #pragma interface
41 #endif
42 
43 #include <opal_config.h>
44 
45 #if OPAL_IAX2
46 
47 #include <opal/endpoint.h>
48 #include <iax2/iax2con.h>
49 #include <iax2/processor.h>
50 #include <iax2/regprocessor.h>
51 #include <iax2/specialprocessor.h>
52 
53 class IAX2Receiver;
54 class IAX2Transmit;
55 class IAX2Processor;
56 
60 class IAX2IncomingEthernetFrames : public PThread
61 {
62  PCLASSINFO(IAX2IncomingEthernetFrames, PThread);
63 public:
64 
69 
72 
75  /*The method which gets everythig to happen */
76  virtual void Main();
77 
79  void Assign(IAX2EndPoint *ep);
80 
83  void ProcessList() { activate.Signal(); }
84 
86  void Terminate();
87 
89  protected:
92 
94  PSyncPoint activate;
95 
97  PBoolean keepGoing;
98 };
99 
100 
101 
102 
105 {
106  PCLASSINFO(IAX2EndPoint, OpalEndPoint);
107  public:
108  enum { DefaultUdpPort = 4569 };
109 
113  IAX2EndPoint(
115  );
116 
118  ~IAX2EndPoint();
120 
126  virtual PString GetDefaultTransport() const;
127 
130  virtual WORD GetDefaultSignalPort() const;
131 
132 
162  virtual PSafePtr<OpalConnection> MakeConnection(
163  OpalCall & call,
164  const PString & party,
165  void * userData = NULL,
166  unsigned int options = 0,
167  OpalConnection::StringOptions * stringOptions = NULL
168  );
169 
174  OpalCall & call,
175  const PString & token,
176  void * userData,
177  const PString & remoteParty,
178  const PString & remotePartyName = PString::Empty()
179  );
181 
186  PBoolean Initialise();
187 
189  virtual void IncomingEthernetFrame (IAX2Frame *frame);
190 
196  PBoolean ConectionForFrameIsAlive(IAX2Frame *f);
197 
204  PINDEX NextSrcCallNumber(IAX2Processor * processor);
205 
209 
211  WORD ListenPortNumber() { return 4569; }
212 
215 
218 
220  PString GetLocalUserName() { return localUserName; }
221 
223  PString GetLocalNumber() { return localNumber; }
224 
226  void SetLocalUserName(PString newValue);
227 
229  void SetLocalNumber(PString newValue);
230 
232  PString & GetPassword() { return password; }
233 
235  void SetPassword(PString newValue);
236 
244 
247 
249  void StartRinging(PString remoteCaller);
250 
263  IAX2Frame *f
264  );
265 
271  void OnEstablished(
272  OpalConnection & con
273  );
274 
280  virtual void OnReleased(
281  OpalConnection & connection
282  );
283 
293  virtual OpalMediaFormatList GetMediaFormats() const;
294 
297 
299  PINDEX GetPreferredCodec(OpalMediaFormatList & list);
300 
303  void GetCodecLengths(PINDEX src, PINDEX &compressedBytes, PINDEX &duration);
304 
312  userIndex = 1,
315  portIndex = 4,
319  };
320 
327  static PStringArray DissectRemoteParty(const PString & other);
328 
333 
336  void ReportTransmitterLists(PString & answer, bool getFullReport = false);
337 
340 
346  void Register(
347  const PString & host,
348  const PString & username,
349  const PString & password = PString::Empty(),
350  PINDEX requestedRefreshTime = 60
351  );
352 
355  };
356 
359  virtual void OnRegistered(
360  const PString & host,
361  const PString & userName,
362  PBoolean isFailure,
364 
367  void Unregister(
368  const PString & host,
369  const PString & username);
370 
373  };
374 
379  virtual void OnUnregistered(
380  const PString & host,
381  const PString & userName,
382  PBoolean isFailure,
384 
385 
387  PBoolean IsRegistered(const PString & host, const PString & username);
388 
390  PINDEX GetRegistrationsCount();
391 
393  PString BuildUrl(
394  const PString & host,
395  const PString & userName = PString::Empty(),
396  const PString & extension = PString::Empty(),
397  const PString & context = PString::Empty(),
398  const PString & transport = PString::Empty()
399  );
400 
402  PBoolean InitialisedOK() { return (transmitter != NULL) && (receiver != NULL); }
403 
407  { return packetsReadFromEthernet.GetSize() > 0; }
409 
410  protected:
418 
422 
424  PUDPSocket *sock;
425 
428 
430  PMutex callNumbLock;
431 
434 
436  PString localUserName;
437 
439  PString localNumber;
440 
442  PString password;
443 
446 
449 
453 
462 
471  PBoolean ProcessFrameInConnection(IAX2Frame *f, const PString & token);
472 
480 
493  PStringToString tokenTable;
494 
498  PReadWriteMutex mutexTokenTable;
499 
502  PAtomicInteger callsEstablished;
503 
506 
509 
514  PArrayObjects regProcessors;
515 
516 };
517 
518 
519 #endif // OPAL_IAX2
520 
521 #endif // OPAL_IAX2_IAX2EP_H
522 
523 /* The comment below is magic for those who use emacs to edit this file.
524  * With the comment below, the tab key does auto indent to 2 spaces.
525  *
526  * Local Variables:
527  * mode:c
528  * c-basic-offset:2
529  * End:
530  */
531