Wowza Community

Access websocket httpprovider from module within onRTPSessionCreate

I’m trying to test the ability of turning one to many webrtc into a conferencing option. I just read the client should play the available streams as HLS instead of many peer connection subscribe streams,

I need the ability to broadcast to websocket connections when an RTP session is created or destroyed to update the clients when a stream has started for that instance. Instead of polling the available streams from the client side.

I’ve got this, I need to access the specific custom websocket httpprovider with a message of the stream name to subscribe to.

public void onRTPSessionCreate(RTPSession rtpSession)

{

if (rtpSession.isWebRTC())

{

}

}

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) {

}

}

I’m checking with the engineers on this for you.

Using the example class:

HTTPWebRTCExchangeSessionInfoCustom extends HTTPWebRTCExchangeSessionInfo

you can listen for websocket connections that are created, and destroyed. With your sample above @Daniel Rossi, you can look for WebRTCSession, and then send messages about the created/destroyed WebRTC sessions over the websocket connections. Using the websocketsessions, you can send websocket messages about what webrtcsessions are in existence.

https://www.wowza.com/docs/manage-webrtc-sessions-in-wowza-streaming-engine

My proof of concept failed. onRTPSessionCreate(RTPSession rtpSession)

is called on subscribing also not when webrtc is publishing. I need to notify all clients when webrtc starts publishing.

Your solution makes no sense sorry. You cannot get RTP creation events from the httpprovider. I certainly cant see a way only on the module side. Which I then have to broadcast over websocket. The RTP session create begins before the final peer connection “sendOffer” is completed as per the logs. So not sure if it’s ready to subscribe to.