From a4074721e9bea9a57b4741b7cb4e15e8963e82d8 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Mon, 2 Oct 2023 17:31:09 +0300 Subject: [PATCH 1/2] Add requestVideoTrackAssignments and getBroadcastObject --- src/main/webapp/js/webrtc_adaptor.js | 128 ++++++++++++++++----------- 1 file changed, 77 insertions(+), 51 deletions(-) diff --git a/src/main/webapp/js/webrtc_adaptor.js b/src/main/webapp/js/webrtc_adaptor.js index 6cd31727..76d1db59 100644 --- a/src/main/webapp/js/webrtc_adaptor.js +++ b/src/main/webapp/js/webrtc_adaptor.js @@ -13,8 +13,8 @@ const Logger = window.log; */ class ReceivingMessage { /** - * - * @param {number} size + * + * @param {number} size */ constructor(size) { this.size = size; @@ -57,8 +57,8 @@ export class WebRTCAdaptor { WebRTCAdaptor.pluginInitMethods.push(pluginInitMethod); } /** - * - * @param {object} initialValues + * + * @param {object} initialValues */ constructor(initialValues) { /** @@ -644,7 +644,7 @@ export class WebRTCAdaptor { } //reconnect play - for (var index in this.playStreamId) + for (var index in this.playStreamId) { var streamId = this.playStreamId[index]; if (this.remotePeerConnection[streamId] != "null" && @@ -773,6 +773,32 @@ export class WebRTCAdaptor { this.webSocketAdaptor.send(JSON.stringify(jsCmd)); } + /** + * Called to get the list of video track assignments. AMS responds with the videoTrackAssignmentList message. + * Parameters: + * @param {string} streamId: unique id for the stream that you want to get info about + */ + requestVideoTrackAssignments(streamId) { + var jsCmd = { + command: "getVideoTrackAssignments", + streamId: streamId, + }; + this.webSocketAdaptor.send(JSON.stringify(jsCmd)); + } + + /** + * Called to get the broadcast object for a specific stream. AMS responds with the broadcastObject callback. + * Parameters: + * @param {string} streamId: unique id for the stream that you want to get info about + */ + getBroadcastObject(streamId) { + var jsCmd = { + command: "getBroadcastObject", + streamId: streamId, + }; + this.webSocketAdaptor.send(JSON.stringify(jsCmd)); + } + /** * Called to update the meta information for a specific stream. * Parameters: @@ -1121,7 +1147,7 @@ export class WebRTCAdaptor { * @param {string} streamId: unique id for the stream */ gotDescription(configuration, streamId) { - + this.remotePeerConnection[streamId] .setLocalDescription(configuration) .then(responose => { @@ -1170,7 +1196,7 @@ export class WebRTCAdaptor { this.initPeerConnection(streamId, dataChannelMode); Logger.debug("setRemoteDescription:" + conf); - + this.remotePeerConnection[streamId].setRemoteDescription(new RTCSessionDescription({ sdp: conf, type: type @@ -1241,7 +1267,7 @@ export class WebRTCAdaptor { var dataChannelMode = "peer"; this.initPeerConnection(streamId, dataChannelMode); - + Logger.debug("takeCandidate:" + candidateSdp) if (this.remoteDescriptionSet[streamId] == true) { @@ -1388,7 +1414,7 @@ export class WebRTCAdaptor { var audioJitterAverageDelay = -1; var videoJitterAverageDelay = -1; var availableOutgoingBitrate = Infinity; - + stats.forEach(value => { //Logger.debug(value); if (value.type == "inbound-rtp" && typeof value.kind != "undefined") { @@ -1782,15 +1808,15 @@ export class WebRTCAdaptor { /** * Called by user * This message is used to send audio level in a conference. - * - * IMPORTANT: AMS v2.7+ can get the audio level from the RTP header and sends audio level to the viewers the same way here. + * + * IMPORTANT: AMS v2.7+ can get the audio level from the RTP header and sends audio level to the viewers the same way here. * Just one difference, AMS sends the audio level in the range of 0 and 127. 0 is max, 127 is ms - - * It means that likely you don't need to send UPDATE_AUDIO_LEVEL anymore + + * It means that likely you don't need to send UPDATE_AUDIO_LEVEL anymore * * @param {string} streamId * @param {*} value : audio lavel - * @returns + * @returns */ updateAudioLevel(streamId, value) { var jsCmd = { @@ -1827,9 +1853,9 @@ export class WebRTCAdaptor { this.mediaManager.turnOffLocalCamera(streamId); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ turnOnLocalCamera(streamId) { return this.mediaManager.turnOnLocalCamera(streamId); @@ -1843,9 +1869,9 @@ export class WebRTCAdaptor { this.mediaManager.unmuteLocalMic(); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ switchDesktopCapture(streamId) { return this.mediaManager.switchDesktopCapture(streamId); @@ -1875,10 +1901,10 @@ export class WebRTCAdaptor { /** * Update audio track of the stream. Updates the audio track on the fly as well. It just replaces the audio track with the first one in the stream - * @param {*} stream - * @param {*} streamId - * @param {*} onEndedCallback - * @returns + * @param {*} stream + * @param {*} streamId + * @param {*} onEndedCallback + * @returns */ updateAudioTrack(stream, streamId, onEndedCallback) { return this.mediaManager.updateAudioTrack(stream, streamId, onEndedCallback); @@ -1897,35 +1923,35 @@ export class WebRTCAdaptor { return this.mediaManager.switchVideoCameraFacingMode(streamId, facingMode); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ switchDesktopCaptureWithCamera(streamId) { return this.mediaManager.switchDesktopCaptureWithCamera(streamId); } /** - * - * @param {string} streamId - * @param {string} deviceId - * @returns + * + * @param {string} streamId + * @param {string} deviceId + * @returns */ switchAudioInputSource(streamId, deviceId) { return this.mediaManager.switchAudioInputSource(streamId, deviceId); } /** - * - * @param {number} volumeLevel + * + * @param {number} volumeLevel */ setVolumeLevel(volumeLevel) { this.mediaManager.setVolumeLevel(volumeLevel); } /** - * - * Using sound meter in order to get audio level may cause audio distortion in Windows browsers - * @param {Function} levelCallback - * @param {number} period - * @returns + * + * Using sound meter in order to get audio level may cause audio distortion in Windows browsers + * @param {Function} levelCallback + * @param {number} period + * @returns */ enableAudioLevelForLocalStream(levelCallback, period) { return this.mediaManager.enableAudioLevelForLocalStream(levelCallback, period); @@ -1935,18 +1961,18 @@ export class WebRTCAdaptor { this.mediaManager.disableAudioLevelForLocalStream(); } /** - * - * @param {object} constraints - * @returns + * + * @param {object} constraints + * @returns */ applyConstraints(constraints) { return this.mediaManager.applyConstraints(constraints) }; - + /** - * - * @param {number} bandwidth - * @param {string} streamId + * + * @param {number} bandwidth + * @param {string} streamId */ changeBandwidth(bandwidth, streamId) { this.mediaManager.changeBandwidth(bandwidth, streamId); @@ -1960,18 +1986,18 @@ export class WebRTCAdaptor { this.mediaManager.disableAudioLevelWhenMuted(); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ getVideoSender(streamId) { return this.mediaManager.getVideoSender(streamId); } /** - * - * @param {object} mediaConstraints, media constraints to be used for opening the stream + * + * @param {object} mediaConstraints, media constraints to be used for opening the stream * @param {string} streamId, id of the stream to replace tracks with - * @returns + * @returns */ openStream(mediaConstraints, streamId) { return this.mediaManager.openStream(mediaConstraints, streamId); From b61fcf972a16cac1b67f324246f7595945f1eae6 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Tue, 3 Oct 2023 19:05:28 +0300 Subject: [PATCH 2/2] Update webrtc_adaptor.js --- src/main/webapp/js/webrtc_adaptor.js | 104 +++++++++++++-------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/main/webapp/js/webrtc_adaptor.js b/src/main/webapp/js/webrtc_adaptor.js index 6cd31727..6c8dcf8c 100644 --- a/src/main/webapp/js/webrtc_adaptor.js +++ b/src/main/webapp/js/webrtc_adaptor.js @@ -13,8 +13,8 @@ const Logger = window.log; */ class ReceivingMessage { /** - * - * @param {number} size + * + * @param {number} size */ constructor(size) { this.size = size; @@ -57,8 +57,8 @@ export class WebRTCAdaptor { WebRTCAdaptor.pluginInitMethods.push(pluginInitMethod); } /** - * - * @param {object} initialValues + * + * @param {object} initialValues */ constructor(initialValues) { /** @@ -644,7 +644,7 @@ export class WebRTCAdaptor { } //reconnect play - for (var index in this.playStreamId) + for (var index in this.playStreamId) { var streamId = this.playStreamId[index]; if (this.remotePeerConnection[streamId] != "null" && @@ -779,7 +779,7 @@ export class WebRTCAdaptor { * @param {string} streamId: unique id for the stream that you want to update MetaData * @param {string} metaData: new free text information for the stream */ - upateStreamMetaData(streamId, metaData) { + updateStreamMetaData(streamId, metaData) { var jsCmd = { command: "updateStreamMetaData", streamId: streamId, @@ -1121,7 +1121,7 @@ export class WebRTCAdaptor { * @param {string} streamId: unique id for the stream */ gotDescription(configuration, streamId) { - + this.remotePeerConnection[streamId] .setLocalDescription(configuration) .then(responose => { @@ -1170,7 +1170,7 @@ export class WebRTCAdaptor { this.initPeerConnection(streamId, dataChannelMode); Logger.debug("setRemoteDescription:" + conf); - + this.remotePeerConnection[streamId].setRemoteDescription(new RTCSessionDescription({ sdp: conf, type: type @@ -1241,7 +1241,7 @@ export class WebRTCAdaptor { var dataChannelMode = "peer"; this.initPeerConnection(streamId, dataChannelMode); - + Logger.debug("takeCandidate:" + candidateSdp) if (this.remoteDescriptionSet[streamId] == true) { @@ -1388,7 +1388,7 @@ export class WebRTCAdaptor { var audioJitterAverageDelay = -1; var videoJitterAverageDelay = -1; var availableOutgoingBitrate = Infinity; - + stats.forEach(value => { //Logger.debug(value); if (value.type == "inbound-rtp" && typeof value.kind != "undefined") { @@ -1782,15 +1782,15 @@ export class WebRTCAdaptor { /** * Called by user * This message is used to send audio level in a conference. - * - * IMPORTANT: AMS v2.7+ can get the audio level from the RTP header and sends audio level to the viewers the same way here. + * + * IMPORTANT: AMS v2.7+ can get the audio level from the RTP header and sends audio level to the viewers the same way here. * Just one difference, AMS sends the audio level in the range of 0 and 127. 0 is max, 127 is ms - - * It means that likely you don't need to send UPDATE_AUDIO_LEVEL anymore + + * It means that likely you don't need to send UPDATE_AUDIO_LEVEL anymore * * @param {string} streamId * @param {*} value : audio lavel - * @returns + * @returns */ updateAudioLevel(streamId, value) { var jsCmd = { @@ -1827,9 +1827,9 @@ export class WebRTCAdaptor { this.mediaManager.turnOffLocalCamera(streamId); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ turnOnLocalCamera(streamId) { return this.mediaManager.turnOnLocalCamera(streamId); @@ -1843,9 +1843,9 @@ export class WebRTCAdaptor { this.mediaManager.unmuteLocalMic(); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ switchDesktopCapture(streamId) { return this.mediaManager.switchDesktopCapture(streamId); @@ -1875,10 +1875,10 @@ export class WebRTCAdaptor { /** * Update audio track of the stream. Updates the audio track on the fly as well. It just replaces the audio track with the first one in the stream - * @param {*} stream - * @param {*} streamId - * @param {*} onEndedCallback - * @returns + * @param {*} stream + * @param {*} streamId + * @param {*} onEndedCallback + * @returns */ updateAudioTrack(stream, streamId, onEndedCallback) { return this.mediaManager.updateAudioTrack(stream, streamId, onEndedCallback); @@ -1897,35 +1897,35 @@ export class WebRTCAdaptor { return this.mediaManager.switchVideoCameraFacingMode(streamId, facingMode); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ switchDesktopCaptureWithCamera(streamId) { return this.mediaManager.switchDesktopCaptureWithCamera(streamId); } /** - * - * @param {string} streamId - * @param {string} deviceId - * @returns + * + * @param {string} streamId + * @param {string} deviceId + * @returns */ switchAudioInputSource(streamId, deviceId) { return this.mediaManager.switchAudioInputSource(streamId, deviceId); } /** - * - * @param {number} volumeLevel + * + * @param {number} volumeLevel */ setVolumeLevel(volumeLevel) { this.mediaManager.setVolumeLevel(volumeLevel); } /** - * - * Using sound meter in order to get audio level may cause audio distortion in Windows browsers - * @param {Function} levelCallback - * @param {number} period - * @returns + * + * Using sound meter in order to get audio level may cause audio distortion in Windows browsers + * @param {Function} levelCallback + * @param {number} period + * @returns */ enableAudioLevelForLocalStream(levelCallback, period) { return this.mediaManager.enableAudioLevelForLocalStream(levelCallback, period); @@ -1935,18 +1935,18 @@ export class WebRTCAdaptor { this.mediaManager.disableAudioLevelForLocalStream(); } /** - * - * @param {object} constraints - * @returns + * + * @param {object} constraints + * @returns */ applyConstraints(constraints) { return this.mediaManager.applyConstraints(constraints) }; - + /** - * - * @param {number} bandwidth - * @param {string} streamId + * + * @param {number} bandwidth + * @param {string} streamId */ changeBandwidth(bandwidth, streamId) { this.mediaManager.changeBandwidth(bandwidth, streamId); @@ -1960,18 +1960,18 @@ export class WebRTCAdaptor { this.mediaManager.disableAudioLevelWhenMuted(); } /** - * - * @param {string} streamId - * @returns + * + * @param {string} streamId + * @returns */ getVideoSender(streamId) { return this.mediaManager.getVideoSender(streamId); } /** - * - * @param {object} mediaConstraints, media constraints to be used for opening the stream + * + * @param {object} mediaConstraints, media constraints to be used for opening the stream * @param {string} streamId, id of the stream to replace tracks with - * @returns + * @returns */ openStream(mediaConstraints, streamId) { return this.mediaManager.openStream(mediaConstraints, streamId);