|
@@ -78,6 +78,7 @@ bool PeerConnection::hasMedia() const {
|
|
|
}
|
|
|
|
|
|
void PeerConnection::setLocalDescription(Description::Type type) {
|
|
|
+ std::unique_lock signalingLock(impl()->signalingMutex);
|
|
|
PLOG_VERBOSE << "Setting local description, type=" << Description::typeToString(type);
|
|
|
|
|
|
SignalingState signalingState = impl()->signalingState.load();
|
|
@@ -144,6 +145,7 @@ void PeerConnection::setLocalDescription(Description::Type type) {
|
|
|
impl()->processLocalDescription(std::move(local));
|
|
|
|
|
|
impl()->changeSignalingState(newSignalingState);
|
|
|
+ signalingLock.unlock();
|
|
|
|
|
|
if (impl()->gatheringState == GatheringState::New) {
|
|
|
iceTransport->gatherLocalCandidates(impl()->localBundleMid());
|
|
@@ -151,6 +153,7 @@ void PeerConnection::setLocalDescription(Description::Type type) {
|
|
|
}
|
|
|
|
|
|
void PeerConnection::setRemoteDescription(Description description) {
|
|
|
+ std::unique_lock signalingLock(impl()->signalingMutex);
|
|
|
PLOG_VERBOSE << "Setting remote description: " << string(description);
|
|
|
|
|
|
if (description.type() == Description::Type::Rollback) {
|
|
@@ -182,7 +185,9 @@ void PeerConnection::setRemoteDescription(Description description) {
|
|
|
if (description.type() == Description::Type::Offer) {
|
|
|
// The ICE agent will automatically initiate a rollback when a peer that had previously
|
|
|
// created an offer receives an offer from the remote peer
|
|
|
- setLocalDescription(Description::Type::Rollback);
|
|
|
+ impl()->rollbackLocalDescription();
|
|
|
+ impl()->changeSignalingState(SignalingState::Stable);
|
|
|
+ signalingState = SignalingState::Stable;
|
|
|
newSignalingState = SignalingState::HaveRemoteOffer;
|
|
|
break;
|
|
|
}
|
|
@@ -221,6 +226,7 @@ void PeerConnection::setRemoteDescription(Description description) {
|
|
|
impl()->processRemoteDescription(std::move(description));
|
|
|
|
|
|
impl()->changeSignalingState(newSignalingState);
|
|
|
+ signalingLock.unlock();
|
|
|
|
|
|
if (type == Description::Type::Offer) {
|
|
|
// This is an offer, we need to answer
|
|
@@ -233,6 +239,7 @@ void PeerConnection::setRemoteDescription(Description description) {
|
|
|
}
|
|
|
|
|
|
void PeerConnection::addRemoteCandidate(Candidate candidate) {
|
|
|
+ std::unique_lock signalingLock(impl()->signalingMutex);
|
|
|
PLOG_VERBOSE << "Adding remote candidate: " << string(candidate);
|
|
|
impl()->processRemoteCandidate(std::move(candidate));
|
|
|
}
|