OPAL  Version 3.10.4
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: 24719 $
28  * $Author: rjongbloed $
29  * $Date: 2010-09-23 18:55:55 -0500 (Thu, 23 Sep 2010) $
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/buildopts.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:
112  IAX2EndPoint(
114  unsigned short port = 4569
115  );
116 
118  ~IAX2EndPoint();
120 
127  virtual PBoolean NewIncomingConnection(
128  OpalTransport * transport
129  );
130 
160  virtual PSafePtr<OpalConnection> MakeConnection(
161  OpalCall & call,
162  const PString & party,
163  void * userData = NULL,
164  unsigned int options = 0,
165  OpalConnection::StringOptions * stringOptions = NULL
166  );
167 
172  OpalCall & call,
173  const PString & token,
174  void * userData,
175  const PString & remoteParty,
176  const PString & remotePartyName = PString::Empty()
177  );
179 
184  PBoolean Initialise();
185 
187  virtual void IncomingEthernetFrame (IAX2Frame *frame);
188 
194  PBoolean ConectionForFrameIsAlive(IAX2Frame *f);
195 
202  PINDEX NextSrcCallNumber(IAX2Processor * processor);
203 
207 
209  WORD ListenPortNumber() { return 4569; }
210 
213 
216 
218  PString GetLocalUserName() { return localUserName; }
219 
221  PString GetLocalNumber() { return localNumber; }
222 
224  void SetLocalUserName(PString newValue);
225 
227  void SetLocalNumber(PString newValue);
228 
230  PString & GetPassword() { return password; }
231 
233  void SetPassword(PString newValue);
234 
242 
245 
247  void StartRinging(PString remoteCaller);
248 
261  IAX2Frame *f
262  );
263 
269  void OnEstablished(
270  OpalConnection & con
271  );
272 
278  virtual void OnReleased(
279  OpalConnection & connection
280  );
281 
291  virtual OpalMediaFormatList GetMediaFormats() const;
292 
295 
297  PINDEX GetPreferredCodec(OpalMediaFormatList & list);
298 
301  void GetCodecLengths(PINDEX src, PINDEX &compressedBytes, PINDEX &duration);
302 
310  userIndex = 1,
313  portIndex = 4,
317  };
318 
325  static PStringArray DissectRemoteParty(const PString & other);
326 
331 
334  void ReportTransmitterLists(PString & answer, bool getFullReport = false);
335 
338 
344  void Register(
345  const PString & host,
346  const PString & username,
347  const PString & password = PString::Empty(),
348  PINDEX requestedRefreshTime = 60
349  );
350 
353  };
354 
357  virtual void OnRegistered(
358  const PString & host,
359  const PString & userName,
360  PBoolean isFailure,
362 
365  void Unregister(
366  const PString & host,
367  const PString & username);
368 
371  };
372 
377  virtual void OnUnregistered(
378  const PString & host,
379  const PString & userName,
380  PBoolean isFailure,
382 
383 
385  PBoolean IsRegistered(const PString & host, const PString & username);
386 
388  PINDEX GetRegistrationsCount();
389 
391  PString BuildUrl(
392  const PString & host,
393  const PString & userName = PString::Empty(),
394  const PString & extension = PString::Empty(),
395  const PString & context = PString::Empty(),
396  const PString & transport = PString::Empty()
397  );
398 
400  PBoolean InitialisedOK() { return (transmitter != NULL) && (receiver != NULL); }
401 
405  { return packetsReadFromEthernet.GetSize() > 0; }
407 
408  protected:
416 
420 
422  PUDPSocket *sock;
423 
425  unsigned short localPort;
426 
429 
431  PMutex callNumbLock;
432 
435 
437  PString localUserName;
438 
440  PString localNumber;
441 
443  PString password;
444 
447 
450 
454 
463 
472  PBoolean ProcessFrameInConnection(IAX2Frame *f, const PString & token);
473 
481 
494  PStringToString tokenTable;
495 
499  PReadWriteMutex mutexTokenTable;
500 
503  PAtomicInteger callsEstablished;
504 
507 
510 
515  PArrayObjects regProcessors;
516 
517 };
518 
519 
520 #endif // OPAL_IAX2
521 
522 #endif // OPAL_IAX2_IAX2EP_H
523 
524 /* The comment below is magic for those who use emacs to edit this file.
525  * With the comment below, the tab key does auto indent to 2 spaces.
526  *
527  * Local Variables:
528  * mode:c
529  * c-basic-offset:2
530  * End:
531  */
532