for outgoing calls, ringing/early/failed events.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1864 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 87494ffa45
commit 22ba41b066

@ -94,6 +94,14 @@ void DSMCall::onInvite(const AmSipRequest& req) {
DBG("session choose to not connect media\n");
run_session_invite = false; // don't accept audio
}
if (checkVar(DSM_ACCEPT_EARLY_SESSION, DSM_ACCEPT_EARLY_SESSION_FALSE)) {
DBG("session choose to not accept early session\n");
accept_early_session = false;
} else {
accept_early_session = true;
}
}
if (run_session_invite)
@ -124,6 +132,35 @@ void DSMCall::onOutgoingInvite(const string& headers) {
}
}
void DSMCall::onRinging(const AmSipReply& reply) {
map<string, string> params;
params["code"] = int2str(reply.code);
params["reason"] = reply.reason;
params["has_body"] = reply.body.empty() ?
"false" : "true";
engine.runEvent(this, DSMCondition::Ringing, &params);
// todo: local ringbacktone
}
void DSMCall::onEarlySessionStart(const AmSipReply& reply) {
map<string, string> params;
params["code"] = int2str(reply.code);
params["reason"] = reply.reason;
params["has_body"] = reply.body.empty() ?
"false" : "true";
engine.runEvent(this, DSMCondition::EarlySession, &params);
if (checkVar(DSM_CONNECT_EARLY_SESSION, DSM_CONNECT_EARLY_SESSION_FALSE)) {
DBG("call does not connect early session\n");
} else {
if (!getInput())
setInput(&playlist);
if (!getOutput())
setOutput(&playlist);
}
}
void DSMCall::onSessionStart(const AmSipRequest& req)
{
if (process_sessionstart) {
@ -208,6 +245,21 @@ void DSMCall::onCancel() {
}
}
void DSMCall::onSipReply(const AmSipReply& reply, int old_dlg_status) {
AmB2BCallerSession::onSipReply(reply,old_dlg_status);
if ((old_dlg_status < AmSipDialog::Connected) &&
(dlg.getStatus() == AmSipDialog::Disconnected)) {
DBG("Outbound call failed with reply %d %s.\n",
reply.code, reply.reason.c_str());
map<string, string> params;
params["code"] = int2str(reply.code);
params["reason"] = reply.reason;
engine.runEvent(this, DSMCondition::FailedCall, &params);
setStopped();
}
}
void DSMCall::process(AmEvent* event)
{

@ -73,6 +73,8 @@ public:
void onInvite(const AmSipRequest& req);
void onOutgoingInvite(const string& headers);
void onRinging(const AmSipReply& reply);
void onEarlySessionStart(const AmSipReply& reply);
void onSessionStart(const AmSipRequest& req);
void onSessionStart(const AmSipReply& rep);
void startSession();
@ -80,6 +82,7 @@ public:
void onBye(const AmSipRequest& req);
void onDtmf(int event, int duration_msec);
void onSipReply(const AmSipReply& reply, int old_dlg_status);
void process(AmEvent* event);
UACAuthCred* getCredentials();

@ -151,6 +151,15 @@ DSMCondition* DSMCoreModule::getCondition(const string& from_str) {
if (cmd == "sessionStart")
return new TestDSMCondition(params, DSMCondition::SessionStart);
if (cmd == "ringing")
return new TestDSMCondition(params, DSMCondition::Ringing);
if (cmd == "early")
return new TestDSMCondition(params, DSMCondition::EarlySession);
if (cmd == "failed")
return new TestDSMCondition(params, DSMCondition::FailedCall);
if (cmd == "B2B.otherReply")
return new TestDSMCondition(params, DSMCondition::B2BOtherReply);

@ -46,6 +46,12 @@ using std::map;
#define DSM_CONNECT_SESSION "connect_session" // todo: rethink these names
#define DSM_CONNECT_SESSION_FALSE "0"
#define DSM_ACCEPT_EARLY_SESSION "accept_early_session" // todo: rethink these names
#define DSM_ACCEPT_EARLY_SESSION_FALSE "0"
#define DSM_CONNECT_EARLY_SESSION "connect_early_session" // todo: rethink these names
#define DSM_CONNECT_EARLY_SESSION_FALSE "0"
#define DSM_ERRNO_FILE "file"
#define DSM_ERRNO_UNKNOWN_ARG "arg"
#define DSM_ERRNO_SCRIPT "script"

@ -59,6 +59,9 @@ class DSMCondition
Any,
Invite,
SessionStart,
Ringing,
EarlySession,
FailedCall,
Key,
Timer,

@ -198,9 +198,15 @@ conditions:
-- bye received:
hangup
-- execution is invite (with run_invite_event):
invite
-- execution is start of session (with run_invite_event, otherwise its always true):
-- event is invite (only with run_invite_event):
invite
-- event is ringing, 180 (only with run_invite_event):
ringing
-- event is early session, 183 (only with run_invite_event):
early
-- event is failed call (only with run_invite_event):
failed
-- event is start of session (with run_invite_event, otherwise its always true):
sessionStart
B2B.otherReply

Loading…
Cancel
Save