pc_forward.html [138:228]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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_callbacks.html [155:245]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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() {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -