pc_forward.html [88:228]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - let button = document.getElementById("tehbutton"); let localvideo1 = document.getElementById("localvideo1"); let localvideo2 = document.getElementById("localvideo2"); let fake = document.getElementById("fake"); fake.checked = true; let oneway = document.getElementById("oneway"); oneway.checked = false; let audio_only = document.getElementById("audio_only"); audio_only.checked = false; let video_disable = document.getElementById("disable_video"); let audio_disable = document.getElementById("disable_audio"); let requireh264 = document.getElementById("requireh264"); requireh264.checked = false; let prefermode0 = document.getElementById("prefermode0"); prefermode0.checked = false; let requireg722 = document.getElementById("requireg722"); requireg722.checked = false; let pc1; let pc2; let pc1_offer; let pc2_answer; let offer_constraints; let answer_constraints; function disable_media(pc, type, array_index) { log("disable_media"); var stream; if (pc == pc1) stream = localvideo1.mozSrcObject; else if (pc == pc2) stream = localvideo2.mozSrcObject; else log("bad pc " + pc); if (stream) { log("track[" + array_index + "] = " + stream.getVideoTracks()[array_index]); if (type == 1) stream.getVideoTracks()[array_index].enabled = !video_disable.checked; else if (type == 0) stream.getAudioTracks()[array_index].enabled = !audio_disable.checked; else log("bad type"); } else log("no stream"); } function failed(code) { log("Failure callback: " + JSON.stringify(code)); } // pc1.createOffer finished, call pc1.setLocal function step1(offer) { log("Offer: " + sdpPrettyPrint(offer.sdp)); pc1_offer = offer; if (requireh264.checked) { // to enforce the usage of H264 we remove the VP8 codec from the offer offer.sdp = removeVP8(offer.sdp); if (prefermode0.checked) { offer.sdp = preferMode0(offer.sdp); } pc1_offer = offer; log("No VP8 Offer: " + sdpPrettyPrint(offer.sdp)); if (!offer.sdp.match(/a=rtpmap:[0-9]+ H264/g)) { log("No H264 found in the offer!!!"); return; } } if (requireg722.checked) { // to enforce the usage of G.722 we remove other codecs from the offer offer.sdp = removeNonG722(offer.sdp); pc1_offer = offer; log("G.722 only Offer: " + sdpPrettyPrint(offer.sdp)); if (!offer.sdp.match(/a=rtpmap:[0-9]+ G722/g)) { log("No G722 found in the offer!!!"); return; } } pc1.setLocalDescription(offer, step2, failed); } // replace CR NL with HTML breaks function sdpPrettyPrint(sdp) { return sdp.replace(/[\r\n]+/g, '
'); } function h264StateChange(cb) { var h264opts = document.getElementById('divH264'); if(cb.checked){ h264opts.style.display = 'block'; } else { h264opts.style.display = 'none'; } } // Also remove mode 0 if it's offered // Note, we don't bother removing the fmtp lines, which makes a good test // for some SDP parsing issues. function removeVP8(sdp) { updated_sdp = sdp.replace("a=rtpmap:120 VP8/90000\r\n",""); updated_sdp = updated_sdp.replace(/m=video ([0-9]+) RTP\/SAVPF ([0-9 ]*) 120/g, "m=video $1 RTP\/SAVPF $2"); updated_sdp = updated_sdp.replace(/m=video ([0-9]+) RTP\/SAVPF 120([0-9 ]*)/g, "m=video $1 RTP\/SAVPF$2"); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack\r\n",""); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack pli\r\n",""); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 ccm fir\r\n",""); return updated_sdp; } // Remove anything that's not G.722 from the m=audio line function removeNonG722(sdp) { updated_sdp = sdp.replace(/m=audio ([0-9]+) RTP\/SAVPF ([0-9 ]*)/g, "m=audio $1 RTP\/SAVPF 9"); return updated_sdp; } function preferMode0(sdp) { updated_sdp = updated_sdp.replace("126 97", "97 126"); return updated_sdp; } // pc1.setLocal finished, call pc2.setRemote function step2() { pc1.onicecandidate = function(obj) { if (obj.candidate) { log("pc1 found ICE candidate: " + JSON.stringify(obj.candidate)); pc2.addIceCandidate(obj.candidate); } else { log("pc1 got end-of-candidates signal"); } } pc2.setRemoteDescription(pc1_offer, step3, failed); }; // pc2.setRemote finished, call pc2.createAnswer function step3() { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pc_test_fps.html [90:230]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - let button = document.getElementById("tehbutton"); let localvideo1 = document.getElementById("localvideo1"); let localvideo2 = document.getElementById("localvideo2"); let fake = document.getElementById("fake"); fake.checked = true; let oneway = document.getElementById("oneway"); oneway.checked = false; let audio_only = document.getElementById("audio_only"); audio_only.checked = false; let video_disable = document.getElementById("disable_video"); let audio_disable = document.getElementById("disable_audio"); let requireh264 = document.getElementById("requireh264"); requireh264.checked = false; let prefermode0 = document.getElementById("prefermode0"); prefermode0.checked = false; let requireg722 = document.getElementById("requireg722"); requireg722.checked = false; let pc1; let pc2; let pc1_offer; let pc2_answer; let offer_constraints; let answer_constraints; function disable_media(pc, type, array_index) { log("disable_media"); var stream; if (pc == pc1) stream = localvideo1.mozSrcObject; else if (pc == pc2) stream = localvideo2.mozSrcObject; else log("bad pc " + pc); if (stream) { log("track[" + array_index + "] = " + stream.getVideoTracks()[array_index]); if (type == 1) stream.getVideoTracks()[array_index].enabled = !video_disable.checked; else if (type == 0) stream.getAudioTracks()[array_index].enabled = !audio_disable.checked; else log("bad type"); } else log("no stream"); } function failed(code) { log("Failure callback: " + JSON.stringify(code)); } // pc1.createOffer finished, call pc1.setLocal function step1(offer) { log("Offer: " + sdpPrettyPrint(offer.sdp)); pc1_offer = offer; if (requireh264.checked) { // to enforce the usage of H264 we remove the VP8 codec from the offer offer.sdp = removeVP8(offer.sdp); if (prefermode0.checked) { offer.sdp = preferMode0(offer.sdp); } pc1_offer = offer; log("No VP8 Offer: " + sdpPrettyPrint(offer.sdp)); if (!offer.sdp.match(/a=rtpmap:[0-9]+ H264/g)) { log("No H264 found in the offer!!!"); return; } } if (requireg722.checked) { // to enforce the usage of G.722 we remove other codecs from the offer offer.sdp = removeNonG722(offer.sdp); pc1_offer = offer; log("G.722 only Offer: " + sdpPrettyPrint(offer.sdp)); if (!offer.sdp.match(/a=rtpmap:[0-9]+ G722/g)) { log("No G722 found in the offer!!!"); return; } } pc1.setLocalDescription(offer, step2, failed); } // replace CR NL with HTML breaks function sdpPrettyPrint(sdp) { return sdp.replace(/[\r\n]+/g, '
'); } function h264StateChange(cb) { var h264opts = document.getElementById('divH264'); if(cb.checked){ h264opts.style.display = 'block'; } else { h264opts.style.display = 'none'; } } // Also remove mode 0 if it's offered // Note, we don't bother removing the fmtp lines, which makes a good test // for some SDP parsing issues. function removeVP8(sdp) { updated_sdp = sdp.replace("a=rtpmap:120 VP8/90000\r\n",""); updated_sdp = updated_sdp.replace(/m=video ([0-9]+) RTP\/SAVPF ([0-9 ]*) 120/g, "m=video $1 RTP\/SAVPF $2"); updated_sdp = updated_sdp.replace(/m=video ([0-9]+) RTP\/SAVPF 120([0-9 ]*)/g, "m=video $1 RTP\/SAVPF$2"); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack\r\n",""); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack pli\r\n",""); updated_sdp = updated_sdp.replace("a=rtcp-fb:120 ccm fir\r\n",""); return updated_sdp; } // Remove anything that's not G.722 from the m=audio line function removeNonG722(sdp) { updated_sdp = sdp.replace(/m=audio ([0-9]+) RTP\/SAVPF ([0-9 ]*)/g, "m=audio $1 RTP\/SAVPF 9"); return updated_sdp; } function preferMode0(sdp) { updated_sdp = updated_sdp.replace("126 97", "97 126"); return updated_sdp; } // pc1.setLocal finished, call pc2.setRemote function step2() { pc1.onicecandidate = function(obj) { if (obj.candidate) { log("pc1 found ICE candidate: " + JSON.stringify(obj.candidate)); pc2.addIceCandidate(obj.candidate); } else { log("pc1 got end-of-candidates signal"); } } pc2.setRemoteDescription(pc1_offer, step3, failed); }; // pc2.setRemote finished, call pc2.createAnswer function step3() { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -