OPAL
Version 3.14.3
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
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: 29536 $
28
* $Author: rjongbloed $
29
* $Date: 2013-04-19 18:55:15 +1000 (Fri, 19 Apr 2013) $
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_config.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
57
class
IAX2CallProcessor
:
public
IAX2Processor
58
{
59
PCLASSINFO(
IAX2CallProcessor
,
IAX2Processor
);
60
61
public
:
62
64
IAX2CallProcessor
(
IAX2EndPoint
& ep);
65
67
virtual
~IAX2CallProcessor
();
68
70
void
AssignConnection
(
IAX2Connection
* _con);
71
74
void
PutSoundPacketToNetwork
(PBYTEArray *sund);
75
77
IAX2Encryption
&
GetEncryptionInfo
() {
return
encryption
; }
78
80
void
ClearCall
(
OpalConnection::CallEndReason
releaseReason = OpalConnection::EndedByLocalUser);
81
86
virtual
void
OnReleased
();
87
91
void
SendDtmf
(
const
PString & dtmfs);
92
96
void
SendText
(
const
PString & text);
97
104
virtual
PBoolean
SetUpConnection
();
105
108
PBoolean
Matches
(
IAX2Frame
*frame) {
return
remote
== (frame->
GetRemoteInfo
()); }
109
112
virtual
void
PrintOn
(ostream & strm)
const
;
113
116
void
ReportStatistics
();
117
119
PBoolean
MatchingLocalCallNumber
(PINDEX compare) {
return
(compare ==
remote
.
SourceCallNumber
()); }
120
122
unsigned
short
GetSelectedCodec
() {
return
(
unsigned
short
)
selectedCodec
; }
123
128
void
AcceptIncomingCall
();
129
140
virtual
PBoolean
SetAlerting
(
141
const
PString & calleeName,
142
PBoolean withMedia
143
) ;
144
148
void
Hangup
(PString messageToSend);
149
152
PBoolean
IsCallTerminating
() {
return
callStatus
&
callTerminating
; }
153
155
void
SendHold
();
156
158
void
SendHoldRelease
();
159
166
void
SetUserName
(PString & inUserName) {
userName
= inUserName; };
167
169
PString
GetUserName
()
const
;
170
173
PString
GetCallingName
()
const
{
return
callingName
; }
174
181
void
SetPassword
(PString & inPassword) {
password
= inPassword; };
182
184
PString
GetPassword
()
const
{
return
password
; };
185
188
void
SendTransfer
(
189
const
PString & calledNumber,
190
const
PString & calledContext = PString::Empty());
191
194
void
StartStatusCheckTimer
(PINDEX msToWait = 10000 );
196
203
virtual
PBoolean
IncomingMessageOutOfOrder
(
IAX2FullFrame
*ff);
204
208
void
SendAnswerMessageToRemoteNode
();
209
210
protected
:
211
213
IAX2Connection
*
con
;
214
219
PBoolean
RemoteSelectedCodecOk
();
220
224
void
CheckForHangupMessages
();
225
227
void
ProcessNetworkFrame
(
IAX2Frame
* src);
228
231
void
ProcessNetworkFrame
(
IAX2MiniFrame
* src);
232
235
void
ProcessNetworkFrame
(
IAX2FullFrame
* src);
236
239
void
ProcessNetworkFrame
(
IAX2FullFrameDtmf
* src);
240
243
void
ProcessNetworkFrame
(
IAX2FullFrameVoice
* src);
244
247
void
ProcessNetworkFrame
(
IAX2FullFrameVideo
* src);
248
251
void
ProcessNetworkFrame
(
IAX2FullFrameSessionControl
* src);
252
255
void
ProcessNetworkFrame
(
IAX2FullFrameNull
* src);
256
263
virtual
PBoolean
ProcessNetworkFrame
(
IAX2FullFrameProtocol
* src);
264
267
void
ProcessNetworkFrame
(
IAX2FullFrameText
* src);
268
271
void
ProcessNetworkFrame
(
IAX2FullFrameImage
* src);
272
275
void
ProcessNetworkFrame
(
IAX2FullFrameHtml
* src);
276
279
void
ProcessNetworkFrame
(
IAX2FullFrameCng
* src);
280
283
virtual
void
ProcessLists
();
284
286
void
ConnectToRemoteNode
(PString & destination);
287
289
void
SendDtmfMessage
(
char
message);
290
292
void
SendTextMessage
(PString & message);
293
296
void
SendSoundMessage
(PBYTEArray *sound);
297
299
void
SendTransferMessage
();
300
302
void
SendQuelchMessage
();
303
305
void
SendUnQuelchMessage
();
306
308
void
IncAudioFramesSent
() { ++
audioFramesSent
; }
309
311
void
IncAudioFramesRcvd
() { ++
audioFramesRcvd
; }
312
314
void
IncVideoFramesSent
() { ++
videoFramesSent
; }
315
317
void
IncVideoFramesRcvd
() { ++
videoFramesRcvd
; }
318
321
void
RemoteNodeHasAnswered
();
322
326
void
CallStopSounds
();
327
330
void
ReceivedHookFlash
();
331
334
void
RemoteNodeIsBusy
();
335
338
void
ProcessIncomingAudioFrame
(
IAX2Frame
*newFrame);
339
342
void
ProcessIncomingVideoFrame
(
IAX2Frame
*newFrame);
343
346
void
ProcessIaxCmdNew
(
IAX2FullFrameProtocol
*src);
347
350
void
ProcessIaxCmdAck
(
IAX2FullFrameProtocol
*src);
351
354
void
ProcessIaxCmdHangup
(
IAX2FullFrameProtocol
*src);
355
358
void
ProcessIaxCmdReject
(
IAX2FullFrameProtocol
*src);
359
362
void
ProcessIaxCmdAccept
(
IAX2FullFrameProtocol
*src);
363
366
void
ProcessIaxCmdAuthReq
(
IAX2FullFrameProtocol
*src);
367
370
void
ProcessIaxCmdAuthRep
(
IAX2FullFrameProtocol
*src);
371
374
void
ProcessIaxCmdInval
(
IAX2FullFrameProtocol
*src);
375
378
void
ProcessIaxCmdDpReq
(
IAX2FullFrameProtocol
*src);
379
382
void
ProcessIaxCmdDpRep
(
IAX2FullFrameProtocol
*src);
383
386
void
ProcessIaxCmdDial
(
IAX2FullFrameProtocol
*src);
387
390
void
ProcessIaxCmdTxreq
(
IAX2FullFrameProtocol
*src);
391
394
void
ProcessIaxCmdTxcnt
(
IAX2FullFrameProtocol
*src);
395
398
void
ProcessIaxCmdTxacc
(
IAX2FullFrameProtocol
*src);
399
402
void
ProcessIaxCmdTxready
(
IAX2FullFrameProtocol
*src);
403
406
void
ProcessIaxCmdTxrel
(
IAX2FullFrameProtocol
*src);
407
410
void
ProcessIaxCmdTxrej
(
IAX2FullFrameProtocol
*src);
411
414
void
ProcessIaxCmdQuelch
(
IAX2FullFrameProtocol
*src);
415
418
void
ProcessIaxCmdUnquelch
(
IAX2FullFrameProtocol
*src);
419
422
void
ProcessIaxCmdPage
(
IAX2FullFrameProtocol
*src);
423
426
void
ProcessIaxCmdMwi
(
IAX2FullFrameProtocol
*src);
427
430
void
ProcessIaxCmdUnsupport
(
IAX2FullFrameProtocol
*src);
431
434
void
ProcessIaxCmdTransfer
(
IAX2FullFrameProtocol
*src);
435
438
void
ProcessIaxCmdProvision
(
IAX2FullFrameProtocol
*src);
439
442
void
ProcessIaxCmdFwDownl
(
IAX2FullFrameProtocol
*src);
443
446
void
ProcessIaxCmdFwData
(
IAX2FullFrameProtocol
*src);
447
454
void
ProcessIaxCmdCallToken
(
IAX2FullFrameProtocol
*src);
455
461
IAX2FullFrameProtocol
*
BuildNewFrameForSending
(
IAX2FullFrameProtocol
*inReplyTo = NULL);
462
464
PAtomicInteger
audioFramesSent
;
465
467
PAtomicInteger
audioFramesRcvd
;
468
470
PAtomicInteger
videoFramesSent
;
471
473
PAtomicInteger
videoFramesRcvd
;
474
476
SafeString
remotePhoneNumber
;
477
479
SafeStrings
callList
;
480
484
SafeString
dtmfText
;
485
488
SafeStrings
textList
;
489
491
SafeStrings
dtmfNetworkList
;
492
494
SafeStrings
hangList
;
495
497
PBoolean
holdCall
;
498
500
PBoolean
holdReleaseCall
;
501
504
IAX2SoundList
soundWaitingForTransmission
;
505
511
enum
SoundBufferState
{
512
BufferToSmall
,
513
Normal
,
514
BufferToBig
515
};
516
518
SoundBufferState
soundBufferState
;
519
522
PINDEX
lastFullFrameTimeStamp
;
523
525
PBoolean
audioCanFlow
;
526
529
unsigned
int
selectedCodec
;
530
532
enum
CallStatus
{
533
callNewed
= 1 << 0,
534
callSentRinging
= 1 << 1,
535
callRegistered
= 1 << 2,
536
callAuthorised
= 1 << 3,
537
callAccepted
= 1 << 4,
538
callRinging
= 1 << 5,
539
callAnswered
= 1 << 6,
540
callTerminating
= 1 << 7
541
};
542
544
unsigned
short
callStatus
;
545
547
void
SetCallSentRinging
(PBoolean newValue =
true
)
548
{
if
(newValue)
callStatus
|=
callSentRinging
;
else
callStatus
&= ~
callSentRinging
; }
549
551
void
SetCallNewed
(PBoolean newValue =
true
)
552
{
if
(newValue)
callStatus
|=
callNewed
;
else
callStatus
&= ~
callNewed
; }
553
555
void
SetCallRegistered
(PBoolean newValue =
true
)
556
{
if
(newValue)
callStatus
|=
callRegistered
;
else
callStatus
&= ~
callRegistered
; }
557
559
void
SetCallAuthorised
(PBoolean newValue =
true
)
560
{
if
(newValue)
callStatus
|=
callAuthorised
;
else
callStatus
&= ~
callAuthorised
; }
561
563
void
SetCallAccepted
(PBoolean newValue =
true
)
564
{
if
(newValue)
callStatus
|=
callAccepted
;
else
callStatus
&= ~
callAccepted
; }
565
567
void
SetCallRinging
(PBoolean newValue =
true
)
568
{
if
(newValue)
callStatus
|=
callRinging
;
else
callStatus
&= ~
callRinging
; }
569
571
void
SetCallAnswered
(PBoolean newValue =
true
)
572
{
if
(newValue)
callStatus
|=
callAnswered
;
else
callStatus
&= ~
callAnswered
; }
573
575
void
SetCallTerminating
(PBoolean newValue =
true
)
576
{
if
(newValue)
callStatus
|=
callTerminating
;
else
callStatus
&= ~
callTerminating
; }
577
579
PBoolean
IsCallHappening
() {
return
callStatus
> 0; }
580
583
PBoolean
IsCallNewed
() {
return
callStatus
&
callNewed
; }
584
587
PBoolean
IsCallSentRinging
() {
return
callStatus
&
callSentRinging
; }
588
590
PBoolean
IsCallRegistered
() {
return
callStatus
&
callRegistered
; }
591
593
PBoolean
IsCallAuthorised
() {
return
callStatus
&
callAuthorised
; }
594
596
PBoolean
IsCallAccepted
() {
return
callStatus
&
callAccepted
; }
597
599
PBoolean
IsCallRinging
() {
return
callStatus
&
callRinging
; }
600
602
PBoolean
IsCallAnswered
() {
return
callStatus
&
callAnswered
; }
603
604
#ifdef DOC_PLUS_PLUS
605
611
void
OnStatusCheck
(PTimer &, INT);
612
#else
613
PDECLARE_NOTIFIER(PTimer,
IAX2CallProcessor
,
OnStatusCheck
);
614
#endif
615
617
void
DoStatusCheck
();
618
621
void
RemoteNodeIsRinging
();
622
626
void
RingingWasAcked
();
627
632
void
AnswerWasAcked
();
633
637
PBoolean
firstMediaFrame
;
638
641
PBoolean
answerCallNow
;
642
647
PBoolean
statusCheckOtherEnd
;
648
650
PTimer
statusCheckTimer
;
651
654
PINDEX
audioFrameDuration
;
655
657
PINDEX
audioCompressedBytes
;
658
662
PBoolean
audioFramesNotStarted
;
663
666
void
CheckForRemoteCapabilities
(
IAX2FullFrameProtocol
*src);
667
670
virtual
void
OnNoResponseTimeout
();
671
673
virtual
void
ProcessFullFrame
(
IAX2FullFrame
& fullFrame);
674
677
PString
callingName
;
678
681
PString
callingExtension
;
682
684
PString
callingDnid
;
685
688
PString
callingContext
;
689
693
PString
userName
;
694
698
PString
password
;
699
701
PMutex
transferMutex
;
702
704
PBoolean
doTransfer
;
705
707
PString
transferCalledNumber
;
708
710
PString
transferCalledContext
;
711
716
PBoolean
suppressHangupFrame
;
717
};
718
720
721
/* The comment below is magic for those who use emacs to edit this file.
722
* With the comment below, the tab key does auto indent to 2 spaces.
723
*
724
* Local Variables:
725
* mode:c
726
* c-basic-offset:2
727
* End:
728
*/
729
730
731
#endif // OPAL_IAX2
732
733
#endif // OPAL_IAX2_CALLPROCESSOR_H
include
iax2
callprocessor.h
Generated on Fri Oct 10 2014 21:36:57 for OPAL by
1.8.3.1