void CallTimerDialog::onBye(const AmSipRequest& req) { if (m_state == BB_Connected) { // stopAccounting(); } terminateOtherLeg(); setStopped(); }
void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev) { if(ev->event_id == B2ABConnectLeg){ try { B2ABConnectLegEvent* co_ev = dynamic_cast<B2ABConnectLegEvent*>(ev); assert(co_ev); dlg.local_party = co_ev->local_party; dlg.local_uri = co_ev->local_uri; dlg.remote_party = co_ev->remote_party; dlg.remote_uri = co_ev->remote_uri; // set outbound proxy as next hop if (!AmConfig::OutboundProxy.empty()) dlg.next_hop = AmConfig::OutboundProxy; setCallgroup(co_ev->callgroup); setNegotiateOnReply(true); if (sendInvite(co_ev->headers)) { throw string("INVITE could not be sent\n"); } return; } catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(e.code,e.reason)); setStopped(); } catch(const string& err){ ERROR("startSession: %s\n",err.c_str()); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,err)); setStopped(); } catch(...){ ERROR("unexpected exception\n"); relayEvent(new B2ABConnectOtherLegExceptionEvent(500,"unexpected exception")); setStopped(); } } AmB2ABSession::onB2ABEvent(ev); }
void MyCCDialog::onBye(const AmSipRequest& req) { DBG("onBye: stopSession\n"); if (state == CC_Connected) { stopAccounting(); } terminateOtherLeg(); setStopped(); }
void AmB2BCalleeSession::onB2BEvent(B2BEvent* ev) { if(ev->event_id == B2BConnectLeg){ B2BConnectEvent* co_ev = dynamic_cast<B2BConnectEvent*>(ev); if (!co_ev) return; MONITORING_LOG3(getLocalTag().c_str(), "b2b_leg", getOtherId().c_str(), "to", co_ev->remote_party.c_str(), "ruri", co_ev->remote_uri.c_str()); dlg->setRemoteParty(co_ev->remote_party); dlg->setRemoteUri(co_ev->remote_uri); if (co_ev->relayed_invite) { AmSipRequest fake_req; fake_req.method = SIP_METH_INVITE; fake_req.cseq = co_ev->r_cseq; relayed_req[dlg->cseq] = fake_req; } AmMimeBody body(co_ev->body); try { updateLocalBody(body); } catch (const string& s) { relayError(SIP_METH_INVITE, co_ev->r_cseq, co_ev->relayed_invite, 500, SIP_REPLY_SERVER_INTERNAL_ERROR); throw; } int res = dlg->sendRequest(SIP_METH_INVITE, &body, co_ev->hdrs, SIP_FLAGS_VERBATIM); if (res < 0) { DBG("sending INVITE failed, relaying back error reply\n"); relayError(SIP_METH_INVITE, co_ev->r_cseq, co_ev->relayed_invite, res); if (co_ev->relayed_invite) relayed_req.erase(dlg->cseq); setStopped(); return; } saveSessionDescription(co_ev->body); // save CSeq of establising INVITE est_invite_cseq = dlg->cseq - 1; est_invite_other_cseq = co_ev->r_cseq; return; } AmB2BSession::onB2BEvent(ev); }
bool AmB2BSession::onOtherBye(const AmSipRequest& req) { DBG("onOtherBye()\n"); // don't call terminateLeg(), as BYE will be sent end-to-end setStopped(); clearRtpReceiverRelay(); return false; }
void Click2TransSession::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method) { DBG("sip reply: code=%i; reason=%s; status=%i", reply.code, reply.reason.c_str(), dlg.getStatus()); if(dialog->isOutgoing() || dialog->isTransferring()) { DBG("sip reply for outgoing invite"); switch(dlg.getStatus()) { case AmSipDialog::Connected: { DBG("connected: connecting audio"); acceptAudio(reply.body, reply.hdrs); //bridge media Click2TransSession* otherLeg = dialog->getOtherLeg(this); AmMediaProcessor::instance()->removeSession(otherLeg); dialog->connectSession(this); dialog->connectSession(otherLeg); AmMediaProcessor::instance()->addSession(this, callgroup); AmMediaProcessor::instance()->addSession(otherLeg, callgroup); if(dialog->isTransferring()) { //sunny day transfer complete dialog->outgoing(); DBG("sending bye to tranferer"); Click2TransSession* t = dialog->removeTransferer(); t->dlg.bye(); DBG("setting tranferer to stopped"); t->setStopped(); } break; } default: { DBG("TODO not implemented");//nothing to do } } } else if(dialog->isTerminated()) { DBG("setting session to stopped"); setStopped(); } else { DBG("TODO expected isOutgoing() to be true");//never called } AmSession::onSipReply(reply, old_dlg_status, trans_method); }
void CallBackDialog::onSessionStart(const AmSipRequest& req) { if (state != CBNone) { // reinvite AmB2ABCallerSession::onSessionStart(req); return; } ERROR("incoming calls not supported!\n"); setStopped(); dlg.bye(); }
void CallTimerDialog::onCancel() { if(dlg.getStatus() == AmSipDialog::Pending) { DBG("Wait for leg B to terminate"); } else { DBG("Canceling leg A on CANCEL since dialog is not pending"); dlg.reply(invite_req, 487, "Request terminated"); setStopped(); } }
void SWPrepaidSIPDialog::onCancel() { if(dlg.getStatus() == AmSipDialog::Pending) { DBG("Wait for leg B to terminate"); } else { DBG("Canceling leg A on CANCEL since dialog is not pending"); dlg.reply(m_localreq, 487, "Call terminated"); setStopped(); } }
bool WaitAnim::step() { assert(isRunning()); if (m_Duration != -1 && Player::get()->getFrameTime()-m_StartTime > m_Duration) { setStopped(); m_pThis = WaitAnimPtr(); return true; } else { return false; } }
void AnnouncementDialog::process(AmEvent* event) { AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event); if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){ dlg.bye(); setStopped(); return; } AmSession::process(event); }
void ParallelAnim::abort() { if (isRunning()) { vector<AnimPtr>::iterator it; for (it=m_RunningAnims.begin(); it != m_RunningAnims.end(); ++it) { (*it)->abort(); } m_RunningAnims.clear(); setStopped(); ParallelAnimPtr tempThis = m_This; m_This = ParallelAnimPtr(); tempThis = ParallelAnimPtr(); } }
void AmSession::onInvite(const AmSipRequest& req) { try { string sdp_reply; acceptAudio(req.body,req.hdrs,&sdp_reply); if(dlg.reply(req,200,"OK", "application/sdp",sdp_reply) != 0) throw AmSession::Exception(500,"could not send response"); }catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); setStopped(); AmSipDialog::reply_error(req,e.code,e.reason); } }
void StateWidget::keyPressEvent( QKeyEvent* e ) { switch( e->key() ) { case Qt::Key_Select: e->accept(); togglePlaying(); break; case KEY_SELECT_HOLD: e->accept(); setStopped(); break; default: QWidget::keyPressEvent(e); break; } }
LLApp::~LLApp() { #if !LL_WINDOWS delete sSigChildCount; sSigChildCount = NULL; #endif setStopped(); // HACK: wait for the error thread to clean itself ms_sleep(20); if (mThreadErrorp) { delete mThreadErrorp; mThreadErrorp = NULL; } LLCommon::cleanupClass(); }
void GWSession::onSessionStart(const AmSipRequest& req) { DBG("GWSession::onSessionStart\n"); try { string sdp_reply; acceptAudio(req.body,req.hdrs,&sdp_reply); if(dlg.reply(req,200,"OK Isdn side state is: CONNECTED", "application/sdp",sdp_reply) != 0) throw AmSession::Exception(500,"could not send response"); }catch(const AmSession::Exception& e){ ERROR("%i %s\n",e.code,e.reason.c_str()); setStopped(); dlg.reply(req,e.code,e.reason); return; } DBG("GWSession::onSessionStart Setting Audio\n"); setInOut((AmAudio *)(m_OtherLeg),(AmAudio *)(m_OtherLeg)); AmSession::onSessionStart(req); AmMediaProcessor::instance()->addSession(this, callgroup); }
void DSMCall::onSipReply(const AmSipRequest& req, const AmSipReply& reply, AmBasicSipDialog::Status old_dlg_status) { if (checkVar(DSM_ENABLE_REPLY_EVENTS, DSM_TRUE)) { map<string, string> params; params["code"] = int2str(reply.code); params["reason"] = reply.reason; params["hdrs"] = reply.hdrs; params["cseq"] = int2str(reply.cseq); params["dlg_status"] = dlg->getStatusStr(); params["old_dlg_status"] = AmBasicSipDialog::getStatusStr(old_dlg_status); // pass AmSipReply for use by mod_dlg (? sending ACK?) DSMSipReply* dsm_reply = new DSMSipReply(&reply); avar[DSM_AVAR_REPLY] = AmArg(dsm_reply); engine.runEvent(this, this, DSMCondition::SipReply, ¶ms); delete dsm_reply; avar.erase(DSM_AVAR_REPLY); if (checkParam(DSM_PROCESSED, DSM_TRUE, ¶ms)) { DBG("DSM script processed SIP reply '%u %s', returning\n", reply.code, reply.reason.c_str()); return; } } AmB2BCallerSession::onSipReply(req, 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, this, DSMCondition::FailedCall, ¶ms); setStopped(); } }
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 EarlyAnnounceDialog::process(AmEvent* event) { AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event); if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)) { DBG("AmAudioEvent::cleared\n"); unsigned int code_i = 404; string reason = "Not Found"; string iptel_app_param = getHeader(localreq.hdrs, PARAM_HDR); if (iptel_app_param.length()) { string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code"); if (code.length() && str2i(code, code_i)) { ERROR("while parsing Final-Reply-Code parameter\n"); } reason = get_header_keyvalue(iptel_app_param,"Final-Reply-Reason"); } else { string code = getHeader(localreq.hdrs,"P-Final-Reply-Code"); if (code.length() && str2i(code, code_i)) { ERROR("while parsing P-Final-Reply-Code\n"); } string h_reason = getHeader(localreq.hdrs,"P-Final-Reply-Reason"); if (h_reason.length()) { INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. "); INFO("Use '%s: Final-Reply-Code=<code>;" "Final-Reply-Reason=<rs>' instead.\n",PARAM_HDR); reason = h_reason; } } DBG("Replying with code %d %s\n", code_i, reason.c_str()); dlg.reply(localreq, code_i, reason); setStopped(); return; } AmSession::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; }
LLApp::~LLApp() { #if !LL_WINDOWS delete sSigChildCount; sSigChildCount = NULL; #endif // reclaim live file memory std::for_each(mLiveFiles.begin(), mLiveFiles.end(), DeletePointer()); mLiveFiles.clear(); setStopped(); // HACK: wait for the error thread to clean itself ms_sleep(20); if (mThreadErrorp) { delete mThreadErrorp; mThreadErrorp = NULL; } LLCommon::cleanupClass(); }
void Click2TransSession::onBye(const AmSipRequest& req) { DBG("bye received"); if(!dialog->isTerminated()) { //one call leg has hung up; unbridge media and send bye to other connected call leg DBG("terminating media"); dialog->terminate(); Click2TransSession* otherLeg = dialog->getOtherLeg(this); AmMediaProcessor::instance()->removeSession(this); AmMediaProcessor::instance()->removeSession(otherLeg); dialog->disconnectSession(this); dialog->disconnectSession(otherLeg); DBG("sending bye to other leg"); otherLeg->dlg.bye(); DBG("setting session to stopped"); setStopped(); } AmSession::onBye(req); }
void Click2TransSession::onSessionStart(const AmSipRequest& req) { if(dialog->isIncoming()) { DBG("incoming session"); try { std::string sdp_reply; acceptAudio(req.body,req.hdrs,&sdp_reply); if(dlg.reply(req, 200,"OK INVITER IS CONNECTED", "application/sdp", sdp_reply) != 0) { throw AmSession::Exception(500,"could not send response"); } } catch(const AmSession::Exception& e) { ERROR("%i %s\n",e.code,e.reason.c_str()); setStopped(); dlg.reply(req,e.code,e.reason); return; } DBG("playing ringtone to inviter"); setInOut(NULL,ringTone.get()); AmSession::onSessionStart(req); AmMediaProcessor::instance()->addSession(this, callgroup); postEvent(new DialoutEvent(DoConnect));//TODO cleanup this allocation? } else if(dialog->isOutgoing()) { DBG("outgoing session"); //nothing to do } }
void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) { try { string sdp_reply; acceptAudio(req.body,req.hdrs,&sdp_reply); if(dlg.reply(req,183,"Session Progress", "application/sdp",sdp_reply) != 0){ throw AmSession::Exception(500,"could not reply"); } else { invite_req = req; } } catch(const AmSession::Exception& e) { ERROR("%i %s\n",e.code,e.reason.c_str()); setStopped(); AmSipDialog::reply_error(req,e.code,e.reason); } }
void VoiceboxDialog::process(AmEvent* ev) { // audio events AmAudioEvent* audio_ev = dynamic_cast<AmAudioEvent*>(ev); if (audio_ev && audio_ev->event_id == AmAudioEvent::noAudio) { DBG("########## noAudio event #########\n"); if (Bye == state) { closeMailbox(); dlg->bye(); setStopped(); } return; } AmPlaylistSeparatorEvent* pl_ev = dynamic_cast<AmPlaylistSeparatorEvent*>(ev); if (pl_ev) { DBG("########## Playlist separator ####\n"); if (Prompting == state) { if (pl_ev->event_id == PLAYLIST_SEPARATOR_MSG_BEGIN){ // mark message as saved saveCurMessage(); // now we can accept action on the message DBG("Changed state to MsgAction.\n"); state = MsgAction; } } return; } AmSession::process(ev); }
StateWidget::StateWidget( PlayerControl* control, QWidget* parent ) : QWidget( parent ), m_control( control ) { static const int HOLD_THRESHOLD = 500; QVBoxLayout *layout = new QVBoxLayout; layout->setMargin( 0 ); m_label = new QMediaStateLabel; layout->addWidget( m_label ); setLayout( layout ); connect( control, SIGNAL(stateChanged(PlayerControl::State)), this, SLOT(setState(PlayerControl::State)) ); m_holdtimer = new QTimer( this ); connect( m_holdtimer, SIGNAL(timeout()), this, SLOT(setStopped()) ); m_holdtimer->setInterval( HOLD_THRESHOLD ); m_holdtimer->setSingleShot( true ); new KeyHold( Qt::Key_Select, KEY_SELECT_HOLD, HOLD_THRESHOLD, this, this ); }
void AmSession::onSystemEvent(AmSystemEvent* ev) { if (ev->sys_event == AmSystemEvent::ServerShutdown) { setStopped(); return; } }
void AmSession::onBye(const AmSipRequest& req) { setStopped(); }
void AmSession::onCancel(const AmSipRequest& cancel) { dlg->bye(); setStopped(); }
void AmSession::onAudioEvent(AmAudioEvent* audio_ev) { if (audio_ev->event_id == AmAudioEvent::cleared) setStopped(); }