bool MyCCDialog::onOtherReply(const AmSipReply& reply) { DBG("OnOtherReply \n"); if (state == CC_Dialing) { if (reply.code < 200) { DBG("Callee is trying... code %d\n", reply.code); } else if(reply.code < 300){ if (getCalleeStatus() == Connected) { state = CC_Connected; startAccounting(); // clear audio input and output setInOut(NULL, NULL); // detach from media processor (not in RTP path any more) AmMediaProcessor::instance()->removeSession(this); // set the call timer setTimer(TIMERID_CREDIT_TIMEOUT, credit); } } else { DBG("Callee final error with code %d\n",reply.code); addToPlaylist(MyCCFactory::DialFailed); number = ""; state = CC_Collecting_Number; } } // we dont call // AmB2BCallerSession::onOtherReply(reply); // as it tears down the call if callee could // not be reached return false; }
void MyCCDialog::onDtmf(int event, int duration) { DBG("MyCCDialog::onDtmf, got event %d, duration %d.\n", event, duration); switch (state) { case CC_Collecting_PIN: { // flush the playlist (stop playing) // if a key is entered playlist.flush(); if(event <10) { pin +=int2str(event); DBG("pin is now '%s'\n", pin.c_str()); } else { AmArg di_args,ret; di_args.push(pin.c_str()); cc_acc->invoke("getCredit", di_args, ret); credit = ret.get(0).asInt(); if (credit < 0) { addToPlaylist(MyCCFactory::IncorrectPIN); pin = ""; } else if (credit == 0) { addToPlaylist(MyCCFactory::OutOfCredit); pin = ""; } else { number = ""; state = CC_Collecting_Number; addToPlaylist(MyCCFactory::EnterNumber); } } } break; case CC_Collecting_Number: { // flush the playlist (stop playing) // if a key is entered playlist.flush(); if(event <10) { number +=int2str(event); DBG("number is now '%s'\n", number.c_str()); } else { if (getCalleeStatus() == None) { state = CC_Dialing; connectCallee(number + " <sip:" + number+ MyCCFactory::ConnectSuffix + ">", "sip:"+number+MyCCFactory::ConnectSuffix); addToPlaylist(MyCCFactory::Dialing); } } } break; case CC_Dialing: case CC_Connected: default: break; }; }
void C2DCallerDialog::process(AmEvent* event) { AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event); if(audio_event && audio_event->event_id == AmAudioEvent::cleared) { if(getCalleeStatus() != None) return; AmMediaProcessor::instance()->removeSession(this); connectCallee(string("<") + callee_uri + ">", callee_uri); return; } AmB2BCallerSession::process(event); }
void ServiceLineCallerDialog::onDtmf(int event, int duration) { DBG("DTMF event %d duration %d\n", event, duration); if (getCalleeStatus() != None) return; if ((event < 10) && (event >= 0) && (!ServiceLineFactory::callee_numbers[event].empty())) { connectCallee("sip:"+ServiceLineFactory::callee_numbers[event]+"@"+ServiceLineFactory::GWDomain, "sip:"+ServiceLineFactory::callee_numbers[event]+"@"+ServiceLineFactory::GWDomain, "sip:"+ServiceLineFactory::GWUser+"@"+ServiceLineFactory::GWDomain, "sip:"+ServiceLineFactory::GWUser+"@"+ServiceLineFactory::GWDomain); } return; }
bool CallTimerDialog::onOtherReply(const AmSipReply& reply) { bool ret = false; if (m_state == BB_Dialing) { if (reply.code < 200) { DBG("Callee is trying... code %d\n", reply.code); } else if(reply.code < 300) { if(getCalleeStatus() == Connected) { m_state = BB_Connected; setInOut(NULL, NULL); // startAccounting(); // set the call timer AmArg di_args,ret; di_args.push(TIMERID_CALL_TIMER); di_args.push((int)call_time); // in seconds di_args.push(dlg.local_tag.c_str()); m_user_timer->invoke("setTimer", di_args, ret); } } else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) { DBG("Stopping leg A on 487 from B with 487\n"); dlg.reply(invite_req, 487, "Request terminated"); setStopped(); ret = true; } else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) { DBG("Callee final error in connected state with code %d\n",reply.code); terminateLeg(); } else if (reply.code >= 300 && m_state == BB_Dialing) { DBG("Callee final error with code %d\n",reply.code); AmB2BCallerSession::onOtherReply(reply); // reset into non-b2b mode to get possible INVITE again sip_relay_only = false; } else { DBG("Callee final error with code %d\n",reply.code); AmB2BCallerSession::onOtherReply(reply); } } return ret; }
void AnnounceCallerDialog::process(AmEvent* event) { AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event); if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){ if (getCalleeStatus() != None) return; // detach this session from the media // because we will stay in signaling only AmMediaProcessor::instance()->removeSession(this); connectCallee(callee_addr, callee_uri); return; } AmB2BCallerSession::process(event); }
bool SWPrepaidSIPDialog::onOtherReply(const AmSipReply& reply) { bool ret = false; if (m_state == CC_Dialing) { if (reply.code < 200) { DBG("Callee is trying... code %d\n", reply.code); } else if(reply.code < 300) { if(getCalleeStatus() == Connected) { m_state = CC_Connected; startAccounting(); setInOut(NULL, NULL); // set the call timer AmArg di_args,ret; di_args.push(TIMERID_CREDIT_TIMEOUT); di_args.push(m_credit); // in seconds di_args.push(dlg.local_tag.c_str()); m_user_timer->invoke("setTimer", di_args, ret); } } else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) { DBG("Canceling leg A on 487 from B"); dlg.reply(m_localreq, 487, "Call terminated"); setStopped(); ret = true; } else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) { DBG("Callee final error in connected state with code %d\n",reply.code); terminateLeg(); } else { DBG("Callee final error with code %d\n",reply.code); AmB2BCallerSession::onOtherReply(reply); } } return ret; }