I’ve got this so far to broadcast the published RTC session to websocket sessions. But these will go to all connected sessions. Its the only way I can see to notify clients of a webrtc publish started to subscribe to it for two way.
The broadcast I have to do from the module not websocket provider as I cant access it.
List list = this.vhost.getWebSocketSessions();
RTP session create seems to be called before “sendOffer” though so not sure if its ready to subscribe to.
room-presenter1.html:316 Signal Server Receive Message: {streamName: “myStream”, command: “presenterAvailable”, room: “room1”, direction: “play”}command: "presenterAvailable"direction: "play"room: "room1"streamName: "myStream"proto: Object
20:56:12.364 room-presenter1.html:316 Signal Server Receive Message: {status: 200, statusDescription: “OK”, direction: “publish”, command: “sendOffer”, streamInfo: {…}, …}
public void onRTPSessionCreate(RTPSession rtpSession)
{
if (rtpSession.isWebRTC())
{
updatePresenters(rtpSession, “presenterAvailable”);
}
}
private void updatePresenters(RTPSession rtpSession, String command) {
IApplicationInstance appInstance = rtpSession.getAppInstance();
ObjectMapper mapper = new ObjectMapper();
String jsonResult;
Map<String, String> params = new HashMap<>();
params.put(“direction”, “play”);
params.put(“command”, command);
params.put(“room”, appInstance.getName().toString());
params.put(“streamName”, rtpSession.getRTSPStream().getStreamName());
try {
jsonResult = mapper.writeValueAsString(params);
broadcastWebSocketMessage(jsonResult);
} catch (JsonProcessingException e) {
}
}