// We need to verify that at least one candidate has been (or will be) gathered. function waitForAnIceCandidate(pc) { returnnew Promise(resolve => { if (!pc.localRequiresTrickleIce || pc._new_local_ice_candidates.length) {
resolve();
} else { // In some circumstances, especially when both PCs are on the same // browser, even though we are connected, the connection can be // established without receiving a single candidate from one or other // peer. So we wait for at least one...
pc._pc.addEventListener("icecandidate", resolve);
}
}).then(() => {
ok(
pc._local_ice_candidates.length,
pc + " received local trickle ICE candidates"
);
isnot(
pc._pc.iceGatheringState,
GATH_NEW,
pc + " ICE gathering state is not 'new'"
);
});
}
async function checkTrackStats(pc, track, outbound) { const audio = track.kind == "audio"; const msg =
`${pc} stats ${outbound ? "outbound " : "inbound "}` +
`${audio ? "audio" : "video"} rtp track id ${track.id}`; const stats = await pc.getStats(track);
ok(
pc.hasStat(stats, {
type: outbound ? "outbound-rtp" : "inbound-rtp",
kind: audio ? "audio" : "video",
}),
`${msg} - found expected stats`
);
ok(
!pc.hasStat(stats, {
type: outbound ? "inbound-rtp" : "outbound-rtp",
}),
`${msg} - did not find extra stats with wrong direction`
);
ok(
!pc.hasStat(stats, {
kind: audio ? "video" : "audio",
}),
`${msg} - did not find extra stats with wrong media type`
);
}
// Commands run once at the beginning of each test, even when performing a // renegotiation test. var commandsPeerConnectionInitial = [ function PC_LOCAL_SETUP_ICE_LOGGER(test) {
test.pcLocal.logIceConnectionState();
},
function PC_REMOTE_SETUP_ICE_LOGGER(test) {
test.pcRemote.logIceConnectionState();
},
function PC_LOCAL_SETUP_SIGNALING_LOGGER(test) {
test.pcLocal.logSignalingState();
},
function PC_REMOTE_SETUP_SIGNALING_LOGGER(test) {
test.pcRemote.logSignalingState();
},
function PC_LOCAL_SETUP_TRACK_HANDLER(test) {
test.pcLocal.setupTrackEventHandler();
},
function PC_REMOTE_SETUP_TRACK_HANDLER(test) {
test.pcRemote.setupTrackEventHandler();
},
function PC_LOCAL_CHECK_INITIAL_SIGNALINGSTATE(test) {
is(
test.pcLocal.signalingState,
STABLE, "Initial local signalingState is 'stable'"
);
},
function PC_REMOTE_CHECK_INITIAL_SIGNALINGSTATE(test) {
is(
test.pcRemote.signalingState,
STABLE, "Initial remote signalingState is 'stable'"
);
},
function PC_LOCAL_CHECK_INITIAL_ICE_STATE(test) {
is(
test.pcLocal.iceConnectionState,
ICE_NEW, "Initial local ICE connection state is 'new'"
);
},
function PC_REMOTE_CHECK_INITIAL_ICE_STATE(test) {
is(
test.pcRemote.iceConnectionState,
ICE_NEW, "Initial remote ICE connection state is 'new'"
);
},
function PC_LOCAL_CHECK_INITIAL_CAN_TRICKLE_SYNC(test) {
is(
test.pcLocal._pc.canTrickleIceCandidates, null, "Local trickle status should start out unknown"
);
},
function PC_REMOTE_CHECK_INITIAL_CAN_TRICKLE_SYNC(test) {
is(
test.pcRemote._pc.canTrickleIceCandidates, null, "Remote trickle status should start out unknown"
);
},
];
var commandsGetUserMedia = [ function PC_LOCAL_GUM(test) { return test.pcLocal.getAllUserMediaAndAddStreams(test.pcLocal.constraints);
},
function PC_REMOTE_GUM(test) { return test.pcRemote.getAllUserMediaAndAddStreams(
test.pcRemote.constraints
);
},
];
var commandsPeerConnectionOfferAnswer = [ function PC_LOCAL_SETUP_ICE_HANDLER(test) {
test.pcLocal.setupIceCandidateHandler(test);
},
function PC_REMOTE_SETUP_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test);
},
function PC_LOCAL_CREATE_OFFER(test) { return test.createOffer(test.pcLocal).then(offer => {
is(
test.pcLocal.signalingState,
STABLE, "Local create offer does not change signaling state"
);
});
},
function PC_LOCAL_SET_LOCAL_DESCRIPTION(test) { return test
.setLocalDescription(test.pcLocal, test.originalOffer, HAVE_LOCAL_OFFER)
.then(() => {
is(
test.pcLocal.signalingState,
HAVE_LOCAL_OFFER, "signalingState after local setLocalDescription is 'have-local-offer'"
);
});
},
function PC_LOCAL_SET_REMOTE_DESCRIPTION(test) { return test
.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE)
.then(() => {
is(
test.pcLocal.signalingState,
STABLE, "signalingState after local setRemoteDescription is 'stable'"
);
});
},
function PC_LOCAL_CHECK_MSID(test) { return test.pcLocal.checkLocalMsids();
}, function PC_REMOTE_CHECK_MSID(test) { return test.pcRemote.checkLocalMsids();
},
function PC_LOCAL_CHECK_TRACK_STATS(test) { return checkAllTrackStats(test.pcLocal);
}, function PC_REMOTE_CHECK_TRACK_STATS(test) { return checkAllTrackStats(test.pcRemote);
}, function PC_LOCAL_VERIFY_SDP_AFTER_END_OF_TRICKLE(test) { if (test.pcLocal.endOfTrickleSdp) { /* In case the endOfTrickleSdp promise is resolved already it will win the * race because it gets evaluated first. But if endOfTrickleSdp is still
* pending the rejection will win the race. */ return Promise.race([
test.pcLocal.endOfTrickleSdp,
Promise.reject("No SDP"),
]).then(
sdp =>
sdputils.checkSdpAfterEndOfTrickle(
sdp,
test.testOptions,
test.pcLocal.label
),
() =>
info( "pcLocal: Gathering is not complete yet, skipping post-gathering SDP check"
)
);
}
}, function PC_REMOTE_VERIFY_SDP_AFTER_END_OF_TRICKLE(test) { if (test.pcRemote.endOfTrickleSdp) { /* In case the endOfTrickleSdp promise is resolved already it will win the * race because it gets evaluated first. But if endOfTrickleSdp is still
* pending the rejection will win the race. */ return Promise.race([
test.pcRemote.endOfTrickleSdp,
Promise.reject("No SDP"),
]).then(
sdp =>
sdputils.checkSdpAfterEndOfTrickle(
sdp,
test.testOptions,
test.pcRemote.label
),
() =>
info( "pcRemote: Gathering is not complete yet, skipping post-gathering SDP check"
)
);
}
},
];
function PC_LOCAL_REMOVE_ALL_BUT_H264_FROM_OFFER(test) {
isnot(
test.originalOffer.sdp.search("H264/90000"),
-1, "H.264 should be present in the SDP offer"
);
test.originalOffer.sdp = sdputils.removeCodecs(
test.originalOffer.sdp,
[120, 121, 97]
);
info("Updated H264 only offer: " + JSON.stringify(test.originalOffer));
}
function PC_LOCAL_REMOVE_ALL_BUT_AV1_FROM_OFFER(test) {
isnot(
test.originalOffer.sdp.search("AV1/90000"),
-1, "AV1 should be present in the SDP offer"
); for (const codec of [103, 105, 120, 121, 126, 97]) {
test.originalOffer.sdp = sdputils.removeCodec(
test.originalOffer.sdp,
codec
);
}
info("Updated AV1 only offer: " + JSON.stringify(test.originalOffer));
}
function PC_LOCAL_REMOVE_BUNDLE_FROM_OFFER(test) {
test.originalOffer.sdp = sdputils.removeBundle(test.originalOffer.sdp);
info("Updated no bundle offer: " + JSON.stringify(test.originalOffer));
}
function PC_LOCAL_REMOVE_RTCPMUX_FROM_OFFER(test) {
test.originalOffer.sdp = sdputils.removeRtcpMux(test.originalOffer.sdp);
info("Updated no RTCP-Mux offer: " + JSON.stringify(test.originalOffer));
}
function PC_LOCAL_REMOVE_SSRC_FROM_OFFER(test) {
test.originalOffer.sdp = sdputils.removeSSRCs(test.originalOffer.sdp);
info("Updated no SSRCs offer: " + JSON.stringify(test.originalOffer));
}
function PC_REMOTE_REMOVE_SSRC_FROM_ANSWER(test) {
test.originalAnswer.sdp = sdputils.removeSSRCs(test.originalAnswer.sdp);
info("Updated no SSRCs answer: " + JSON.stringify(test.originalAnswer));
}
var addRenegotiation = (chain, commands, checks) => {
chain.append(commands);
chain.append(commandsPeerConnectionOfferAnswer); if (checks) {
chain.append(checks);
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.