OPAL  Version 3.10.4
callprocessor.h
Go to the documentation of this file.
1 /*
2  *
3  * Inter Asterisk Exchange 2
4  *
5  * The core routine which determines the processing of packets for one call.
6  *
7  * Open Phone Abstraction Library (OPAL)
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: 24722 $
28  * $Author: dereksmithies $
29  * $Date: 2010-09-23 23:32:35 -0500 (Thu, 23 Sep 2010) $
30  */
31 
32 #ifndef OPAL_IAX2_CALLPROCESSOR_H
33 #define OPAL_IAX2_CALLPROCESSOR_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 
45 #include <iax2/processor.h>
46 #include <iax2/frame.h>
47 #include <iax2/iedata.h>
48 #include <iax2/remote.h>
49 #include <iax2/safestrings.h>
50 #include <iax2/sound.h>
51 
52 class IAX2Connection;
53 
58 {
59  PCLASSINFO(IAX2CallProcessor, IAX2Processor);
60 
61  public:
62 
65 
67  virtual ~IAX2CallProcessor();
68 
70  void AssignConnection(IAX2Connection * _con);
71 
74  void PutSoundPacketToNetwork(PBYTEArray *sund);
75 
78 
81 
84 
89  virtual void OnReleased();
90 
94  void SendDtmf(const PString & dtmfs);
95 
99  void SendText(const PString & text);
100 
107  virtual PBoolean SetUpConnection();
108 
111  PBoolean Matches(IAX2Frame *frame) { return remote == (frame->GetRemoteInfo()); }
112 
115  virtual void PrintOn(ostream & strm) const;
116 
119  void ReportStatistics();
120 
122  PBoolean MatchingLocalCallNumber(PINDEX compare) { return (compare == remote.SourceCallNumber()); }
123 
125  unsigned short GetSelectedCodec() { return (unsigned short) selectedCodec; }
126 
131  void AcceptIncomingCall();
132 
143  virtual PBoolean SetAlerting(
144  const PString & calleeName,
145  PBoolean withMedia
146  ) ;
147 
151  void Hangup(PString messageToSend);
152 
156 
158  void SendHold();
159 
161  void SendHoldRelease();
162 
169  void SetUserName(PString & inUserName) { userName = inUserName; };
170 
172  PString GetUserName() const;
173 
176  PString GetCallingName() const { return callingName; }
177 
184  void SetPassword(PString & inPassword) { password = inPassword; };
185 
187  PString GetPassword() const { return password; };
188 
191  void SendTransfer(
192  const PString & calledNumber,
193  const PString & calledContext = PString::Empty());
194 
197  void StartStatusCheckTimer(PINDEX msToWait = 10000 );
199 
206  virtual PBoolean IncomingMessageOutOfOrder(IAX2FullFrame *ff);
207 
212 
213  protected:
214 
217 
222  PBoolean RemoteSelectedCodecOk();
223 
227  void CheckForHangupMessages();
228 
230  void ProcessNetworkFrame(IAX2Frame * src);
231 
235 
239 
243 
247 
251 
255 
259 
266  virtual PBoolean ProcessNetworkFrame(IAX2FullFrameProtocol * src);
267 
271 
275 
279 
283 
286  virtual void ProcessLists();
287 
289  void ConnectToRemoteNode(PString & destination);
290 
292  void SendDtmfMessage(char message);
293 
295  void SendTextMessage(PString & message);
296 
299  void SendSoundMessage(PBYTEArray *sound);
300 
302  void SendTransferMessage();
303 
305  void SendQuelchMessage();
306 
308  void SendUnQuelchMessage();
309 
312 
315 
318 
321 
324  void RemoteNodeHasAnswered();
325 
329  void CallStopSounds();
330 
333  void ReceivedHookFlash();
334 
337  void RemoteNodeIsBusy();
338 
341  void ProcessIncomingAudioFrame(IAX2Frame *newFrame);
342 
345  void ProcessIncomingVideoFrame(IAX2Frame *newFrame);
346 
350 
354 
358 
362 
366 
370 
374 
378 
382 
386 
390 
394 
398 
402 
406 
410 
414 
418 
422 
426 
430 
434 
438 
442 
446 
450 
458 
465 
467  PAtomicInteger audioFramesSent;
468 
470  PAtomicInteger audioFramesRcvd;
471 
473  PAtomicInteger videoFramesSent;
474 
476  PAtomicInteger videoFramesRcvd;
477 
480 
483 
488 
492 
495 
498 
500  PBoolean holdCall;
501 
503  PBoolean holdReleaseCall;
504 
508 
518  };
519 
522 
526 
528  PBoolean audioCanFlow;
529 
532  unsigned int selectedCodec;
533 
535  enum CallStatus {
536  callNewed = 1 << 0,
537  callSentRinging = 1 << 1,
538  callRegistered = 1 << 2,
539  callAuthorised = 1 << 3,
540  callAccepted = 1 << 4,
541  callRinging = 1 << 5,
542  callAnswered = 1 << 6,
543  callTerminating = 1 << 7
544  };
545 
547  unsigned short callStatus;
548 
550  void SetCallSentRinging(PBoolean newValue = true)
551  { if (newValue) callStatus |= callSentRinging; else callStatus &= ~callSentRinging; }
552 
554  void SetCallNewed(PBoolean newValue = true)
555  { if (newValue) callStatus |= callNewed; else callStatus &= ~callNewed; }
556 
558  void SetCallRegistered(PBoolean newValue = true)
559  { if (newValue) callStatus |= callRegistered; else callStatus &= ~callRegistered; }
560 
562  void SetCallAuthorised(PBoolean newValue = true)
563  { if (newValue) callStatus |= callAuthorised; else callStatus &= ~callAuthorised; }
564 
566  void SetCallAccepted(PBoolean newValue = true)
567  { if (newValue) callStatus |= callAccepted; else callStatus &= ~callAccepted; }
568 
570  void SetCallRinging(PBoolean newValue = true)
571  { if (newValue) callStatus |= callRinging; else callStatus &= ~callRinging; }
572 
574  void SetCallAnswered(PBoolean newValue = true)
575  { if (newValue) callStatus |= callAnswered; else callStatus &= ~callAnswered; }
576 
578  void SetCallTerminating(PBoolean newValue = true)
579  { if (newValue) callStatus |= callTerminating; else callStatus &= ~callTerminating; }
580 
582  PBoolean IsCallHappening() { return callStatus > 0; }
583 
586  PBoolean IsCallNewed() { return callStatus & callNewed; }
587 
591 
593  PBoolean IsCallRegistered() { return callStatus & callRegistered; }
594 
596  PBoolean IsCallAuthorised() { return callStatus & callAuthorised; }
597 
599  PBoolean IsCallAccepted() { return callStatus & callAccepted; }
600 
602  PBoolean IsCallRinging() { return callStatus & callRinging; }
603 
605  PBoolean IsCallAnswered() { return callStatus & callAnswered; }
606 
607 #ifdef DOC_PLUS_PLUS
608 
614  void OnStatusCheck(PTimer &, INT);
615 #else
616  PDECLARE_NOTIFIER(PTimer, IAX2CallProcessor, OnStatusCheck);
617 #endif
618 
620  void DoStatusCheck();
621 
624  void RemoteNodeIsRinging();
625 
629  void RingingWasAcked();
630 
635  void AnswerWasAcked();
636 
640  PBoolean firstMediaFrame;
641 
644  PBoolean answerCallNow;
645 
651 
654 
658 
661 
666 
670 
673  virtual void OnNoResponseTimeout();
674 
676  virtual void ProcessFullFrame(IAX2FullFrame & fullFrame);
677 
680  PString callingName;
681 
685 
687  PString callingDnid;
688 
691  PString callingContext;
692 
696  PString userName;
697 
701  PString password;
702 
705 
707  PBoolean doTransfer;
708 
711 
714 
720 };
721 
723 
724 /* The comment below is magic for those who use emacs to edit this file.
725  * With the comment below, the tab key does auto indent to 2 spaces.
726  *
727  * Local Variables:
728  * mode:c
729  * c-basic-offset:2
730  * End:
731  */
732 
733 
734 #endif // OPAL_IAX2
735 
736 #endif // OPAL_IAX2_CALLPROCESSOR_H