5
#include "B2BCallManager.hxx"
12
B2BCallManager::B2BCallManager(resip::DialogUsageManager& dum, AuthorizationManager *authorizationManager, CDRHandler& cdrHandler) : dum(dum), authorizationManager(authorizationManager), cdrHandler(cdrHandler) {
14
mustStopCalls = false;
17
B2BCallManager::~B2BCallManager() {
20
void B2BCallManager::setAuthorizationManager(AuthorizationManager *authorizationManager) {
21
this->authorizationManager = authorizationManager;
24
TaskManager::TaskResult B2BCallManager::doTaskProcessing() {
28
B2BUA_LOG_NOTICE("notifying calls to stop");
29
list<B2BCall *>::iterator call = calls.begin();
30
while(call != calls.end()) {
31
(*call)->onStopping();
34
mustStopCalls = false;
38
list<B2BCall *>::iterator i = calls.begin();
39
while(i != calls.end()) {
40
(*i)->checkProgress(now, stopping);
41
if((*i)->isComplete()) {
49
if(stopping && calls.begin() == calls.end()) {
50
B2BUA_LOG_NOTICE("no (more) calls in progress");
51
return TaskManager::TaskComplete;
53
return TaskManager::TaskNotComplete;
56
void B2BCallManager::stop() {
61
bool B2BCallManager::isStopping() {
65
void B2BCallManager::onNewCall(MyAppDialog *aLegDialog, const resip::NameAddr& sourceAddr, const resip::Uri& destinationAddr, const resip::Data& authRealm, const resip::Data& authUser, const resip::Data& authPassword, const resip::Data& srcIp, const resip::Data& contextId, const resip::Data& accountId, const resip::Data& baseIp, const resip::Data& controlId) {
67
B2BCall *call = new B2BCall(cdrHandler, dum, *authorizationManager, aLegDialog, sourceAddr, destinationAddr, authRealm, authUser, authPassword, srcIp, contextId, accountId, baseIp, controlId);
69
calls.push_back(call);
73
void B2BCallManager::logStats() {
74
int preDial = 0, dialing = 0, connected = 0, finishing = 0, unknown = 0;
75
list<B2BCall *>::iterator call = calls.begin();
76
while(call != calls.end()) {
77
switch((*call)->getStatus()) {
78
case B2BCall::PreDial:
81
case B2BCall::Dialing:
84
case B2BCall::Connected:
87
case B2BCall::Finishing:
96
B2BUA_LOG_NOTICE("call info: preDial = %d, dialing = %d, connected = %d, finishing = %d, unknown = %d, total = %d", preDial, dialing, connected, finishing, unknown, (preDial + dialing + connected + finishing + unknown));
99
/* ====================================================================
101
* Copyright 2012 Daniel Pocock. All rights reserved.
103
* Redistribution and use in source and binary forms, with or without
104
* modification, are permitted provided that the following conditions
107
* 1. Redistributions of source code must retain the above copyright
108
* notice, this list of conditions and the following disclaimer.
110
* 2. Redistributions in binary form must reproduce the above copyright
111
* notice, this list of conditions and the following disclaimer in
112
* the documentation and/or other materials provided with the
115
* 3. Neither the name of the author(s) nor the names of any contributors
116
* may be used to endorse or promote products derived from this software
117
* without specific prior written permission.
119
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
120
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
121
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
122
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
123
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
124
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
125
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
126
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
127
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
128
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
131
* ====================================================================