diff --git a/src/main/js/webrtc_adaptor.js b/src/main/js/webrtc_adaptor.js index dcd97ef2..eebd4198 100644 --- a/src/main/js/webrtc_adaptor.js +++ b/src/main/js/webrtc_adaptor.js @@ -878,6 +878,22 @@ export class WebRTCAdaptor { this.webSocketAdaptor.send(JSON.stringify(jsCmd)); } + /** + * Called to get the subtrack count for a specific maintrack. AMS responds with the subtrackCount callback. + * @param {string} streamId : main track id + * @param {string} role : filter the subtracks with the role + * @param {string} status : filter the subtracks with the status + */ + getSubtrackCount(streamId, role, status) { + let jsCmd = { + command: "getSubtracksCount", + streamId: streamId, + role: role, + status: status, + }; + this.webSocketAdaptor.send(JSON.stringify(jsCmd)); + } + /** * Called to enable/disable data flow from the AMS for a specific track under a main track. * Parameters: diff --git a/src/test/js/webrtc_adaptor.test.js b/src/test/js/webrtc_adaptor.test.js index f365001e..6c3077fd 100644 --- a/src/test/js/webrtc_adaptor.test.js +++ b/src/test/js/webrtc_adaptor.test.js @@ -2026,6 +2026,34 @@ describe("WebRTCAdaptor", function() { }); + it("getSubtrackCount", async function() { + + let adaptor = new WebRTCAdaptor({ + websocketURL: "ws://example.com", + isPlayMode: true + }); + + let streamId = "roomId"; + let role = "host"; + let status = "active"; + + let jsCmd = { + command: "getSubtracksCount", + streamId: streamId, + role: role, + status: status, + }; + + let webSocketAdaptor = sinon.mock(adaptor.webSocketAdaptor); + + let sendExpectation = webSocketAdaptor.expects("send").once().withArgs(JSON.stringify(jsCmd)); + + adaptor.getSubtrackCount(streamId, role, status); + + sendExpectation.verify() + + }); + });