const RegisteredPrefixId* registerPrefix(const Name& prefix, shared_ptr<InterestFilterRecord> filter, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, uint64_t flags, const nfd::CommandOptions& options) { nfd::ControlParameters params; params.setName(prefix); params.setFlags(flags); auto prefixToRegister = make_shared<RegisteredPrefix>(prefix, filter, options); m_face.m_nfdController->start<nfd::RibRegisterCommand>( params, [=] (const nfd::ControlParameters&) { this->afterPrefixRegistered(prefixToRegister, onSuccess); }, [=] (const nfd::ControlResponse& resp) { onFailure(prefixToRegister->getPrefix(), resp.getText()); }, options); return reinterpret_cast<const RegisteredPrefixId*>(prefixToRegister.get()); }
//! Load a plan into the vehicle //! @param[in] plan_id name of the plan //! @param[in] arg argument which may either be a maneuver or a plan specification //! @param[in] plan_startup true if a plan will start right after //! @return true if plan is successfully loaded bool loadPlan(const std::string& plan_id, const IMC::Message* arg, bool plan_startup = false) { if ((initMode() && !plan_startup) || execMode()) { onFailure(DTR("cannot load plan now")); return false; } std::string info; if (!parseArg(plan_id, arg, info)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan load failed: ") + info); return false; } IMC::PlanStatistics ps; if (!parsePlan(plan_startup, ps)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan parse failed: ") + m_reply.info); return false; } // reply with statistics m_reply.arg.set(ps); m_reply.plan_id = m_spec.plan_id; m_pcs.plan_id = m_spec.plan_id; onSuccess(DTR("plan loaded"), false); return true; }
void SIPCall::startAllMedia() { if (isSecure() && not transport_->isSecure()) { RING_ERR("[call:%s] Can't perform secure call over insecure SIP transport", getCallId().c_str()); onFailure(EPROTONOSUPPORT); return; } auto slots = sdp_->getMediaSlots(); unsigned ice_comp_id = 0; bool peer_holding {true}; int slotN = -1; for (const auto& slot : slots) { ++slotN; const auto& local = slot.first; const auto& remote = slot.second; if (local.type != remote.type) { RING_ERR("[call:%s] [SDP:slot#%u] Inconsistent media types between local and remote", getCallId().c_str(), slotN); continue; } RtpSession* rtp = local.type == MEDIA_AUDIO ? static_cast<RtpSession*>(avformatrtp_.get()) #ifdef RING_VIDEO : static_cast<RtpSession*>(&videortp_); #else : nullptr; #endif if (not rtp) continue; if (!local.codec) { RING_WARN("[call:%s] [SDP:slot#%u] Missing local codec", getCallId().c_str(), slotN); continue; } if (!remote.codec) { RING_WARN("[call:%s] [SDP:slot#%u] Missing remote codec", getCallId().c_str(), slotN); continue; } peer_holding &= remote.holding; if (isSecure() && (not local.crypto || not remote.crypto)) { RING_ERR("[call:%s] [SDP:slot#%u] Can't perform secure call over insecure RTP transport", getCallId().c_str(), slotN); continue; } #ifdef RING_VIDEO if (local.type == MEDIA_VIDEO) videortp_.switchInput(videoInput_); #endif rtp->updateMedia(remote, local); if (isIceRunning()) { rtp->start(newIceSocket(ice_comp_id + 0), newIceSocket(ice_comp_id + 1)); ice_comp_id += 2; } else rtp->start(); switch (local.type) { #ifdef RING_VIDEO case MEDIA_VIDEO: isVideoMuted_ = videoInput_.empty(); break; #endif case MEDIA_AUDIO: isAudioMuted_ = not rtp->isSending(); break; default: break; } }
//! Load a plan into the vehicle //! @param[in] plan_id name of the plan //! @param[in] arg argument which may either be a maneuver or a plan specification //! @param[in] plan_startup true if a plan will start right after //! @return true if plan is successfully loaded bool loadPlan(const std::string& plan_id, const IMC::Message* arg, bool plan_startup = false) { if ((initMode() && !plan_startup) || execMode()) { onFailure(DTR("cannot load plan now")); return false; } if (arg) { if (arg->getId() == DUNE_IMC_PLANSPECIFICATION) { const IMC::PlanSpecification* given_plan = static_cast<const IMC::PlanSpecification*>(arg); m_spec = *given_plan; m_spec.setSourceEntity(getEntityId()); } else { // Quick plan IMC::PlanManeuver spec_man; const IMC::Maneuver* man = static_cast<const IMC::Maneuver*>(arg); if (man) { spec_man.maneuver_id = arg->getName(); spec_man.data.set(*man); m_spec.clear(); m_spec.maneuvers.setParent(&m_spec); m_spec.plan_id = plan_id; m_spec.start_man_id = arg->getName(); m_spec.maneuvers.push_back(spec_man); } else { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan load failed: undefined maneuver or plan")); return false; } } } else { // Search DB m_spec.clear(); if (!lookForPlan(plan_id, m_spec)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan load failed: ") + m_reply.info); return false; } } if (!parsePlan(plan_startup)) { changeMode(IMC::PlanControlState::PCS_READY, DTR("plan validation failed: ") + m_reply.info); return false; } m_pcs.plan_id = m_spec.plan_id; if (plan_startup) onSuccess(DTR("plan loaded"), false); else changeMode(IMC::PlanControlState::PCS_READY, DTR("plan loaded")); return true; }