Fixed mid on local candidates

This commit is contained in:
Paul-Louis Ageneau
2020-11-29 15:57:49 +01:00
parent 244c834992
commit 452b742adc
4 changed files with 19 additions and 7 deletions

View File

@ -157,6 +157,8 @@ private:
void processLocalCandidate(Candidate candidate);
void processRemoteDescription(Description description);
void processRemoteCandidate(Candidate candidate);
string localBundleMid() const;
void triggerDataChannel(std::weak_ptr<DataChannel> weakDataChannel);
void triggerTrack(std::shared_ptr<Track> track);
bool changeState(State state);

View File

@ -168,7 +168,9 @@ bool IceTransport::addRemoteCandidate(const Candidate &candidate) {
return juice_add_remote_candidate(mAgent.get(), string(candidate).c_str()) >= 0;
}
void IceTransport::gatherLocalCandidates() {
void IceTransport::gatherLocalCandidates(string mid) {
mMid = std::move(mid);
// Change state now as candidates calls can be synchronous
changeGatheringState(GatheringState::InProgress);
@ -582,7 +584,9 @@ bool IceTransport::addRemoteCandidate(const Candidate &candidate) {
return ret > 0;
}
void IceTransport::gatherLocalCandidates() {
void IceTransport::gatherLocalCandidates(string mid) {
mMid = std::move(mid);
// Change state now as candidates calls can be synchronous
changeGatheringState(GatheringState::InProgress);

View File

@ -56,7 +56,7 @@ public:
Description getLocalDescription(Description::Type type) const;
void setRemoteDescription(const Description &description);
bool addRemoteCandidate(const Candidate &candidate);
void gatherLocalCandidates();
void gatherLocalCandidates(string mid);
std::optional<string> getLocalAddress() const;
std::optional<string> getRemoteAddress() const;

View File

@ -189,13 +189,14 @@ void PeerConnection::setLocalDescription(Description::Type type) {
auto iceTransport = initIceTransport();
Description localDescription = iceTransport->getLocalDescription(type);
processLocalDescription(std::move(localDescription));
Description local = iceTransport->getLocalDescription(type);
processLocalDescription(std::move(local));
changeSignalingState(newSignalingState);
if (mGatheringState == GatheringState::New)
iceTransport->gatherLocalCandidates();
if (mGatheringState == GatheringState::New) {
iceTransport->gatherLocalCandidates(localBundleMid());
}
}
void PeerConnection::setRemoteDescription(Description description) {
@ -1145,6 +1146,11 @@ void PeerConnection::processRemoteCandidate(Candidate candidate) {
}
}
string PeerConnection::localBundleMid() const {
std::lock_guard lock(mLocalDescriptionMutex);
return mLocalDescription ? mLocalDescription->bundleMid() : "0";
}
void PeerConnection::triggerDataChannel(weak_ptr<DataChannel> weakDataChannel) {
auto dataChannel = weakDataChannel.lock();
if (!dataChannel)