From 69cd8a0ecf4bc2310a541359c04436d351730c92 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Wed, 20 Nov 2024 21:40:32 +0300 Subject: [PATCH 1/4] Add mechanism to get subtrack count --- src/main/js/webrtc_adaptor.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/js/webrtc_adaptor.js b/src/main/js/webrtc_adaptor.js index 0baf34d5..ae7c4489 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: From 076db7ace0b884a1218f9594b4b895cc19586a94 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Tue, 26 Nov 2024 09:58:07 +0300 Subject: [PATCH 2/4] Add unit test --- src/test/js/webrtc_adaptor.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/js/webrtc_adaptor.test.js b/src/test/js/webrtc_adaptor.test.js index f365001e..1ca3f0f6 100644 --- a/src/test/js/webrtc_adaptor.test.js +++ b/src/test/js/webrtc_adaptor.test.js @@ -2026,6 +2026,36 @@ describe("WebRTCAdaptor", function() { }); + it("getSubtracks", async function() { + + let adaptor = new WebRTCAdaptor({ + websocketURL: "ws://example.com", + isPlayMode: true + }); + + let streamId = "roomId"; + let role = "host"; + let offset = 0; + let size = 10; + + let jsCmd = { + command: "getSubtracks", + streamId: streamId, + role: role, + offset: offset, + size: size, + }; + + let webSocketAdaptor = sinon.mock(adaptor.webSocketAdaptor); + + let sendExpectation = webSocketAdaptor.expects("send").once().withArgs(JSON.stringify(jsCmd)); + + adaptor.getSubtracks(streamId, role, offset, size); + + sendExpectation.verify() + + }); + }); From ff785077d49a1517e2c05c3c25e7f52402f5f286 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Tue, 26 Nov 2024 10:00:37 +0300 Subject: [PATCH 3/4] Add unit test for getSubtrackCount --- src/test/js/webrtc_adaptor.test.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/test/js/webrtc_adaptor.test.js b/src/test/js/webrtc_adaptor.test.js index 1ca3f0f6..cdbb43dd 100644 --- a/src/test/js/webrtc_adaptor.test.js +++ b/src/test/js/webrtc_adaptor.test.js @@ -2026,7 +2026,7 @@ describe("WebRTCAdaptor", function() { }); - it("getSubtracks", async function() { + it("getSubtrackCount", async function() { let adaptor = new WebRTCAdaptor({ websocketURL: "ws://example.com", @@ -2035,22 +2035,20 @@ describe("WebRTCAdaptor", function() { let streamId = "roomId"; let role = "host"; - let offset = 0; - let size = 10; + let status = "active"; let jsCmd = { - command: "getSubtracks", + command: "getSubtrackCount", streamId: streamId, role: role, - offset: offset, - size: size, + status: status, }; let webSocketAdaptor = sinon.mock(adaptor.webSocketAdaptor); let sendExpectation = webSocketAdaptor.expects("send").once().withArgs(JSON.stringify(jsCmd)); - adaptor.getSubtracks(streamId, role, offset, size); + adaptor.getSubtrackCount(streamId, role, status); sendExpectation.verify() From 0cc21215887eb2a87eb9ce5aa05a4d06464f1237 Mon Sep 17 00:00:00 2001 From: Mustafa BOLEKEN Date: Tue, 26 Nov 2024 10:03:00 +0300 Subject: [PATCH 4/4] Fix typo --- src/test/js/webrtc_adaptor.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/js/webrtc_adaptor.test.js b/src/test/js/webrtc_adaptor.test.js index cdbb43dd..6c3077fd 100644 --- a/src/test/js/webrtc_adaptor.test.js +++ b/src/test/js/webrtc_adaptor.test.js @@ -2038,7 +2038,7 @@ describe("WebRTCAdaptor", function() { let status = "active"; let jsCmd = { - command: "getSubtrackCount", + command: "getSubtracksCount", streamId: streamId, role: role, status: status,