Bug 1495569: Create answers with a=mid even if the offer did not have a=mid r=mjf,jib

Bug 1495569 - Part 0: web-platform-test that verifies handling of offer without mid.
Bug 1495569 - Part 1: Ensure that answers are created with the transceiver's mid when the offer did not have a mid.

Differential Revision: https://phabricator.services.mozilla.com/D8853

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Byron Campen [:bwc] 2018-10-17 18:50:45 +00:00
parent 27419e1f5b
commit 37b133bd26
2 changed files with 44 additions and 0 deletions

View File

@ -652,6 +652,15 @@ JsepSessionImpl::CreateAnswerMsection(const JsepAnswerOptions& options,
return NS_OK;
}
MOZ_ASSERT(transceiver.IsAssociated());
if (msection.GetAttributeList().GetMid().empty()) {
msection.GetAttributeList().SetAttribute(
new SdpStringAttribute(SdpAttribute::kMidAttribute,
transceiver.GetMid()));
}
MOZ_ASSERT(transceiver.GetMid() == msection.GetAttributeList().GetMid());
SdpSetupAttribute::Role role;
rv = DetermineAnswererSetupRole(remoteMsection, &role);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -506,6 +506,40 @@
hasProps(pc.getTransceivers(), []);
};
const checkNoMidOffer = async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
t.add_cleanup(() => stopTracks(stream));
const track = stream.getAudioTracks()[0];
pc1.addTrack(track, stream);
const offer = await pc1.createOffer();
await pc1.setLocalDescription(offer);
// Remove mid attr
offer.sdp = offer.sdp.replace("a=mid:", "a=unknownattr:");
await pc2.setRemoteDescription(offer);
hasPropsAndUniqueMids(pc2.getTransceivers(),
[
{
receiver: {track: {kind: "audio"}},
sender: {track: null},
direction: "recvonly",
currentDirection: null,
stopped: false
}
]);
const answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
await pc1.setRemoteDescription(answer);
};
const checkAddTransceiverNoTrackDoesntPair = async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
@ -2212,6 +2246,7 @@ const tests = [
checkAddTransceiverWithSetRemoteOfferSending,
checkAddTransceiverWithSetRemoteOfferNoSend,
checkAddTransceiverBadKind,
checkNoMidOffer,
checkSetDirection,
checkCurrentDirection,
checkSendrecvWithNoSendTrack,