Wowza Community

How to query WebRTC published stream names?

I see an option to select the feature “Query Published Stream Names” on the newest WebRTC configuration panel. Really interesting, but can you show me how to do that?

Thanks for asking @Nguyen Ha as that may be something a lot of others wonder about at well.

The query check box on engine manager allows you to send the queryAll message over the websocket to an application.

Here is an example from this doc: https://www.wowza.com/docs/manage-webrtc-sessions-in-wowza-streaming-engine#get-webrtc-session-information

List<RTPSession> getWebRTCSessions()
List<RTPSession> getWebRTCSessions(String streamName)
int getWebRTCSessionCount()
int getWebRTCSessionCount(String streamName)
Map<String, Integer> getWebRTCSessionCountsByName()

Those methods are an example of what the internal application uses to gather information to return to clients form the queryAll command. There are more that can be found at the link I shared. Hope that helps!

Thanks for your quick answer, @Rose Power-Wowza Community Manager. I’m going to make a test right now

I’ve got a similar requirement but to notify websocket clients when a webrtc publish begins. Not sure if its ready to subscribe within onRTPSessionCreate. I have to notify clients to start subscribing to a new webrtc publish within a particular room.

https://www.wowza.com/community/questions/57679/access-websocket-httpprovider-from-module-within-o.html

The available streams is the “getAvailableStreams” command. Im trying to prevent having to poll this too often and notify clients from the server instead when a webrtc session has started / stopped.

It seems like I sent a wrong format message

@ 11:39:35 AM [SENT]:    {"command":"queryAll","direction":"publish","applicationName":"live"}

@ 11:39:35 AM [RECEIVED]:    {"status":200,"statusDescription":"OK","direction":"unknown","command":"unknown","streamInfo":{"applicationName":"_defapp_/_definst_","streamName":"null","sessionId":"[empty]"}} 

Can you provide an example of the queryAll message?

@Rose Power-Wowza Community Manager Could you provive an example of the queryAll message over the websocket to an application ? I tried to create a JSON message as below and it didn’t work. It seems to be in wrong prototype

{"command":"queryAll","direction":"publish","applicationName":"live"} 

Let me check with the engineers to see if they have an example.

I’m counting on you

So, I checked with an engineer @Nguyen Ha and for the first question, there’s several ways to query wse on what streams are currently published:

  1. the built-in HTTPProviders, particularly connectioncounts would have the name of the incoming streams
  2. the rest api endpoint: curl -X GET --header 'Accept:application/json; charset=utf-8' ``[http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_](http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_)
  3. java api: https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info

A webRTC stream is just like any other incoming stream; if you are specifically looking for webrtc streams only, I believe you can customize a java api so that you can query a stream object and check if it is a webRTC stream.

That’s what I provided to you the first time in this thread, the java methods calls to query only webRTC streams. Something else with webRTC that’s specific to it, is that we do respond to queries from the browser, which is I think what you are asking.

that’s what the following application property corresponds to:

            <EnableQuery>false</EnableQuery>

Make sure that property in the app is enabled, then the JS script that had this call had this:

    function sendPlayGetAvailableStreams()
    {
        console.log("sendPlayGetAvailableStreams: "+JSON.stringify(streamInfo));
        wsConnection.send('{"direction":"play", "command":"getAvailableStreams", "streamInfo":'+JSON.stringify(streamInfo)+', "userData":'+JSON.stringify(userData)+'}');
    }

When this is invoked, the app only logs the available streams though; if you are looking to receive that information from the server to the browser client, you still have to extend a module in order for Streaming Engine to send that info back to the browser.

We just don’t have an example to show you how to do that-it’s custom work on your end. Sorry about that, that’s all I have for you, but hope it helped a little bit.

The functionality is there though in Engine. We try to be very clear that our webrtc option has a lot of features that will need to be configured yourself as we don’t offer a webrtc SDK or out of the box sample code for all scenarios. You can try and post in Hire A Consultant if you’d like for any custom work you may need. I hope you get what you need for your use case though.

Thank you @Rose Power-Wowza Community Manager, I appreciate your supporting.