Skip to content

Commit

Permalink
Merge pull request #521 from ant-media/passUserPublishIdInPlayRequest
Browse files Browse the repository at this point in the history
Pass user publish id in play request
  • Loading branch information
mekya authored Dec 8, 2024
2 parents 0698d53 + 1d187d0 commit dcc3e0b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/js/webrtc_adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ export class WebRTCAdaptor {
subscriberCode: typeof subscriberCode !== undefined && subscriberId != null ? subscriberCode : "",
viewerInfo: typeof metaData !== undefined && metaData != null ? metaData : "",
role: (typeof role !== undefined && role != null) ? role : "",
userPublishId: typeof this.publishStreamId !== undefined && this.publishStreamId != null ? this.publishStreamId : "",
}

this.webSocketAdaptor.send(JSON.stringify(jsCmd));
Expand Down
41 changes: 41 additions & 0 deletions src/test/js/webrtc_adaptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2055,5 +2055,46 @@ describe("WebRTCAdaptor", function() {
});


it("Play with parameters", async function() {
let publishStreamId = "publish1"
let streamId = "stream1";
let token = "yourToken";
let roomId = "yourRoomId";
let enableTracks = true;
let subscriberId = "yourSubscriberId";
let subscriberCode = "yourSubscriberCode";
let metaData = "yourMetaData";
let role = "subscriber";

var adaptor = new WebRTCAdaptor({
websocketURL: "ws://example.com",
isPlayMode: true,
publishStreamId: publishStreamId
});

var peerConnection = new RTCPeerConnection();
var initPeerConnection = sinon.replace(adaptor, "initPeerConnection", sinon.fake.returns(peerConnection));
var webSocketAdaptor = sinon.mock(adaptor.webSocketAdaptor);

adaptor.play(streamId, token, roomId, enableTracks, subscriberId, subscriberCode, metaData, role);

let jsCmd = {
command: "play",
streamId: streamId,
token: token,
room: roomId,
trackList: enableTracks,
subscriberId: subscriberId,
subscriberCode: subscriberCode,
viewerInfo: metaData,
role: role,
userPublishId: publishStreamId
};

webSocketAdaptor.expects("send").once().withArgs(JSON.stringify(jsCmd));
expect(initPeerConnection.calledWithExactly(streamId, "play")).to.be.true;
});



});

0 comments on commit dcc3e0b

Please sign in to comment.