nsresult PeerConnectionMedia::ActivateOrRemoveTransports(const JsepSession& aSession, const bool forceIceTcp) { for (const auto& transceiver : aSession.GetTransceivers()) { if (!transceiver->HasLevel()) { continue; } std::string ufrag; std::string pwd; std::vector<std::string> candidates; size_t components = 0; RefPtr<JsepTransport> transport = transceiver->mTransport; unsigned level = transceiver->GetLevel(); if (transport->mComponents && (!transceiver->HasBundleLevel() || (transceiver->BundleLevel() == level))) { CSFLogDebug(LOGTAG, "ACTIVATING TRANSPORT! - PC %s: level=%u components=%u", mParentHandle.c_str(), (unsigned)level, (unsigned)transport->mComponents); ufrag = transport->mIce->GetUfrag(); pwd = transport->mIce->GetPassword(); candidates = transport->mIce->GetCandidates(); components = transport->mComponents; if (forceIceTcp) { candidates.erase(std::remove_if(candidates.begin(), candidates.end(), [](const std::string & s) { return s.find(" UDP ") != std::string::npos || s.find(" udp ") != std::string::npos; }), candidates.end()); } } RUN_ON_THREAD( GetSTSThread(), WrapRunnable(RefPtr<PeerConnectionMedia>(this), &PeerConnectionMedia::ActivateOrRemoveTransport_s, transceiver->GetLevel(), components, ufrag, pwd, candidates), NS_DISPATCH_NORMAL); } // We can have more streams than m-lines due to rollback. RUN_ON_THREAD( GetSTSThread(), WrapRunnable(RefPtr<PeerConnectionMedia>(this), &PeerConnectionMedia::RemoveTransportsAtOrAfter_s, aSession.GetTransceivers().size()), NS_DISPATCH_NORMAL); return NS_OK; }
nsresult PeerConnectionMedia::UpdateTransceiverTransports(const JsepSession& aSession) { for (const auto& transceiver : aSession.GetTransceivers()) { nsresult rv = UpdateTransportFlows(*transceiver); if (NS_FAILED(rv)) { return rv; } } for (const auto& transceiverImpl : mTransceivers) { transceiverImpl->UpdateTransport(*this); } return NS_OK; }
void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) { for (const auto& transceiver : aSession.GetTransceivers()) { if (!transceiver->HasLevel()) { continue; } RefPtr<JsepTransport> transport = transceiver->mTransport; RUN_ON_THREAD( GetSTSThread(), WrapRunnable(RefPtr<PeerConnectionMedia>(this), &PeerConnectionMedia::EnsureTransport_s, transceiver->GetLevel(), transport->mComponents), NS_DISPATCH_NORMAL); } GatherIfReady(); }