Skip to content

Commit

Permalink
Merge pull request #517 from ant-media/addPaginationMechanism
Browse files Browse the repository at this point in the history
Add mechanism to get subtrack count
  • Loading branch information
mekya authored Nov 29, 2024
2 parents 1561586 + 0cc2121 commit 0698d53
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/js/webrtc_adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions src/test/js/webrtc_adaptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

});



});

0 comments on commit 0698d53

Please sign in to comment.