in monitoring-stack-cdk/resources/frontend/connect-rtc.js [8218:8269]
window.RTCPeerConnection.prototype.createOffer = function(offerOptions) {
var pc = this;
if (offerOptions) {
if (typeof offerOptions.offerToReceiveAudio !== 'undefined') {
// support bit values
offerOptions.offerToReceiveAudio = !!offerOptions.offerToReceiveAudio;
}
var audioTransceiver = pc.getTransceivers().find(function(transceiver) {
return transceiver.sender.track &&
transceiver.sender.track.kind === 'audio';
});
if (offerOptions.offerToReceiveAudio === false && audioTransceiver) {
if (audioTransceiver.direction === 'sendrecv') {
if (audioTransceiver.setDirection) {
audioTransceiver.setDirection('sendonly');
} else {
audioTransceiver.direction = 'sendonly';
}
} else if (audioTransceiver.direction === 'recvonly') {
if (audioTransceiver.setDirection) {
audioTransceiver.setDirection('inactive');
} else {
audioTransceiver.direction = 'inactive';
}
}
} else if (offerOptions.offerToReceiveAudio === true &&
!audioTransceiver) {
pc.addTransceiver('audio');
}
if (typeof offerOptions.offerToReceiveVideo !== 'undefined') {
// support bit values
offerOptions.offerToReceiveVideo = !!offerOptions.offerToReceiveVideo;
}
var videoTransceiver = pc.getTransceivers().find(function(transceiver) {
return transceiver.sender.track &&
transceiver.sender.track.kind === 'video';
});
if (offerOptions.offerToReceiveVideo === false && videoTransceiver) {
if (videoTransceiver.direction === 'sendrecv') {
videoTransceiver.setDirection('sendonly');
} else if (videoTransceiver.direction === 'recvonly') {
videoTransceiver.setDirection('inactive');
}
} else if (offerOptions.offerToReceiveVideo === true &&
!videoTransceiver) {
pc.addTransceiver('video');
}
}
return origCreateOffer.apply(pc, arguments);
};