Skip to content

Commit

Permalink
Bug 1550177 - Part 3: There is no need to dispatch these calls to STS…
Browse files Browse the repository at this point in the history
…, because MediaTransportHandler does that for us. r=mjf

Differential Revision: https://phabricator.services.mozilla.com/D30993
  • Loading branch information
docfaraday committed Jun 19, 2019
1 parent 26fb44e commit c38364a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 60 deletions.
82 changes: 25 additions & 57 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,11 @@ nsresult PeerConnectionMedia::Init() {
void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
for (const auto& transceiver : aSession.GetTransceivers()) {
if (transceiver->HasOwnTransport()) {
RUN_ON_THREAD(
GetSTSThread(),
WrapRunnable(mTransportHandler,
&MediaTransportHandler::EnsureProvisionalTransport,
transceiver->mTransport.mTransportId,
transceiver->mTransport.mLocalUfrag,
transceiver->mTransport.mLocalPwd,
transceiver->mTransport.mComponents),
NS_DISPATCH_NORMAL);
mTransportHandler->EnsureProvisionalTransport(
transceiver->mTransport.mTransportId,
transceiver->mTransport.mLocalUfrag,
transceiver->mTransport.mLocalPwd,
transceiver->mTransport.mComponents);
}
}

Expand All @@ -241,11 +237,7 @@ nsresult PeerConnectionMedia::UpdateTransports(const JsepSession& aSession,
}
}

RUN_ON_THREAD(GetSTSThread(),
WrapRunnable(mTransportHandler,
&MediaTransportHandler::RemoveTransportsExcept,
finalTransports),
NS_DISPATCH_NORMAL);
mTransportHandler->RemoveTransportsExcept(finalTransports);

for (const auto& transceiverImpl : mTransceivers) {
transceiverImpl->UpdateTransport();
Expand Down Expand Up @@ -299,16 +291,11 @@ void PeerConnectionMedia::UpdateTransport(const JsepTransceiver& aTransceiver,
digests.emplace_back(ss.str(), fingerprint.fingerprint);
}

RUN_ON_THREAD(
GetSTSThread(),
WrapRunnable(
mTransportHandler, &MediaTransportHandler::ActivateTransport,
transport.mTransportId, transport.mLocalUfrag, transport.mLocalPwd,
components, ufrag, pwd, keyDer, certDer,
mParent->Identity()->auth_type(),
transport.mDtls->GetRole() == JsepDtlsTransport::kJsepDtlsClient,
digests, mParent->PrivacyRequested()),
NS_DISPATCH_NORMAL);
mTransportHandler->ActivateTransport(
transport.mTransportId, transport.mLocalUfrag, transport.mLocalPwd,
components, ufrag, pwd, keyDer, certDer, mParent->Identity()->auth_type(),
transport.mDtls->GetRole() == JsepDtlsTransport::kJsepDtlsClient, digests,
mParent->PrivacyRequested());

for (auto& candidate : candidates) {
AddIceCandidate("candidate:" + candidate, transport.mTransportId, ufrag);
Expand Down Expand Up @@ -344,34 +331,23 @@ nsresult PeerConnectionMedia::UpdateMediaPipelines() {
}

void PeerConnectionMedia::StartIceChecks(const JsepSession& aSession) {
nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
RefPtr<PeerConnectionMedia>(this), &PeerConnectionMedia::StartIceChecks_s,
aSession.IsIceControlling(), aSession.IsOfferer(),
aSession.RemoteIsIceLite(),
// Copy, just in case API changes to return a ref
std::vector<std::string>(aSession.GetIceOptions())));

PerformOrEnqueueIceCtxOperation(runnable);
}

void PeerConnectionMedia::StartIceChecks_s(
bool aIsControlling, bool aIsOfferer, bool aIsIceLite,
const std::vector<std::string>& aIceOptionsList) {
CSFLogDebug(LOGTAG, "Starting ICE Checking");

std::vector<std::string> attributes;
if (aIsIceLite) {
if (aSession.RemoteIsIceLite()) {
attributes.push_back("ice-lite");
}

if (!aIceOptionsList.empty()) {
if (!aSession.GetIceOptions().empty()) {
attributes.push_back("ice-options:");
for (const auto& option : aIceOptionsList) {
for (const auto& option : aSession.GetIceOptions()) {
attributes.back() += option + ' ';
}
}

mTransportHandler->StartIceChecks(aIsControlling, aIsOfferer, attributes);
nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
mTransportHandler, &MediaTransportHandler::StartIceChecks,
aSession.IsIceControlling(), aSession.IsOfferer(), attributes));

PerformOrEnqueueIceCtxOperation(runnable);
}

bool PeerConnectionMedia::GetPrefDefaultAddressOnly() const {
Expand Down Expand Up @@ -401,27 +377,19 @@ void PeerConnectionMedia::AddIceCandidate(const std::string& aCandidate,
const std::string& aTransportId,
const std::string& aUfrag) {
MOZ_ASSERT(!aTransportId.empty());
RUN_ON_THREAD(
GetSTSThread(),
WrapRunnable(mTransportHandler, &MediaTransportHandler::AddIceCandidate,
aTransportId, aCandidate, aUfrag),
NS_DISPATCH_NORMAL);
mTransportHandler->AddIceCandidate(aTransportId, aCandidate, aUfrag);
}

void PeerConnectionMedia::UpdateNetworkState(bool online) {
RUN_ON_THREAD(
GetSTSThread(),
WrapRunnable(mTransportHandler,
&MediaTransportHandler::UpdateNetworkState, online),
NS_DISPATCH_NORMAL);
mTransportHandler->UpdateNetworkState(online);
}

void PeerConnectionMedia::FlushIceCtxOperationQueueIfReady() {
ASSERT_ON_THREAD(mMainThread);

if (IsIceCtxReady()) {
for (auto& mQueuedIceCtxOperation : mQueuedIceCtxOperations) {
GetSTSThread()->Dispatch(mQueuedIceCtxOperation, NS_DISPATCH_NORMAL);
mQueuedIceCtxOperation->Run();
}
mQueuedIceCtxOperations.clear();
}
Expand All @@ -432,7 +400,7 @@ void PeerConnectionMedia::PerformOrEnqueueIceCtxOperation(
ASSERT_ON_THREAD(mMainThread);

if (IsIceCtxReady()) {
GetSTSThread()->Dispatch(runnable, NS_DISPATCH_NORMAL);
runnable->Run();
} else {
mQueuedIceCtxOperations.push_back(runnable);
}
Expand All @@ -445,12 +413,12 @@ void PeerConnectionMedia::GatherIfReady() {
mQueuedIceCtxOperations.clear();
nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
RefPtr<PeerConnectionMedia>(this),
&PeerConnectionMedia::EnsureIceGathering_s, GetPrefDefaultAddressOnly()));
&PeerConnectionMedia::EnsureIceGathering, GetPrefDefaultAddressOnly()));

PerformOrEnqueueIceCtxOperation(runnable);
}

void PeerConnectionMedia::EnsureIceGathering_s(bool aDefaultRouteOnly) {
void PeerConnectionMedia::EnsureIceGathering(bool aDefaultRouteOnly) {
if (mProxyConfig) {
// Note that this could check if PrivacyRequested() is set on the PC and
// remove "webrtc" from the ALPN list. But that would only work if the PC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
void GatherIfReady();
void FlushIceCtxOperationQueueIfReady();
void PerformOrEnqueueIceCtxOperation(nsIRunnable* runnable);
void EnsureIceGathering_s(bool aDefaultRouteOnly);
void StartIceChecks_s(bool aIsControlling, bool aIsOfferer, bool aIsIceLite,
const std::vector<std::string>& aIceOptionsList);
void EnsureIceGathering(bool aDefaultRouteOnly);

bool GetPrefDefaultAddressOnly() const;

Expand Down

0 comments on commit c38364a

Please sign in to comment.