Passing params to wowza on Web RTC Connection

I´m new on forum, so I don´t know if this thread is the better choice to this doubt.

My company has a chat project, and we created a custom module with onConnect and onDisconnect functions, to do some programming logic on our system, when broadcasters start publish and clients start to see the streaming. This module works well for flash and net Connection.

On netConnection we pass some parameters to wowza, to do our logic. But When I connect on wowza through Web RTC (using javascript as wowza examples), I can´t pass parameters. I tried building the url for signaling with query String params like this:

var postURL = "https://my-wowza-domain.com/webrtc-session.json?my_param=foo&second_param=bar";

I created the functions onRTPSessionCreate and onRTPSessionDestroy on my custom module, these functions are triggered, but I can´t get connection params.

I tried with:

public void onRTPSessionCreate(RTPSession current_session) 
{
	// don´t work - prints null
	getLogger().info(current_session.getQueryStr());
	// don´t work - prints null
	getLogger().info(current_session.getUri());
	// works 
	getLogger().info("onRTPSessionCreate: " + current_session.getSessionId());	
}

Exist a way to pass parameters on connection through Web RTC?

The correct method to catch Web RTC connect and disconnect events in a custom module is onRTPSessionCreate and onRTPSessionDestroy?

I know the wowza has a HTTP provider to work as signaling, but I can´t figure out how change that class to do what I need, which is pass params on Web RTC connection to wowza. Someone has a example to do this?

Thanks for support

1 Like

Any update on this question ?

Hello,

This has not been tested with WebRTC Preview. Have you found a solution for this? If not, I would recommend opening a WebRTC Preview support case for Wowza Engineering to look into this.

Best,

JasonT

Hi Bruno,

I believe the code you’re looking for should look something like this. I’ve added a simple example.

// If a query parameter is added to the stream name it should be shown here
// An example would be
//
// Stream Name: myStream?param1=value1
//
// should output
//
// ModuleListenWebRTCSession.RTPStream.QueryParameter[param1=value]
getLogger().info("ModuleListenWebRTCSession.RTPStream.QueryParameter["+rtpSession.getRTSPStream().getStreamQueryStr()+"]");

Please let me know if this helps resolve the issue.

Regards,

Jason Hilton

Technical Support Engineer

Wowza Media Systems

Hello,

With the new webrtc package and using Wowza Streaming Engine 4.5.0.02 build 19265 you will be able to pass params.

Here’s an example from the readme:

import com.wowza.wms.module.*;

import com.wowza.wms.rtp.model.*;

public class ModuleListenWebRTCSession extends ModuleBase

{

public void onRTPSessionCreate(RTPSession rtpSession)

{

if (rtpSession.isWebRTC())

{

getLogger().info(“ModuleListenWebRTCSession.onRTPSessionCreate[”+rtpSession.getSessionId()+"]");

// Call rejectSession to stop the session immediately

//rtpSession.rejectSession();

}

}

public void onRTPSessionDestroy(RTPSession rtpSession)

{

if (rtpSession.isWebRTC())

{

getLogger().info(“ModuleListenWebRTCSession.onRTPSessionDestroy[”+rtpSession.getSessionId()+"]");

}

}

}

If not already signed up for WebRTC Preview, please request access on the below site:

https://www.wowza.com/products/capabilities/webrtc-streaming-software

Regards,

JasonT

Hello Bruno,

The link should be in your email box and the updater for Wowza Streaming Engine 4.5.0.02 Build 19165 or now 4.5.0.03 will be available at with active Wowza Support:

www.wowza.com

My Account> My Downloads

If you did not get the email with the WebRTC link, please open a support case at:

https://www.wowza.com/support/open-ticket

and we’ll be sure to forward that onto you.

Regards,

JasonT

Hello,

On the Server-side code this is the part that will take in the JSON payload and store it in jsonEntries and I would recommend not editing this part of the code:

Map<String, Object> jsonEntries = commandContext.commandRequest.getJSONEntries();

if (jsonEntries != null)

{

Map<String, Object> userData = (Map<String, Object>)jsonEntries.get(“userData”);

if (userData != null)

{

for(Map.Entry<String, Object> entry : userData.entrySet())

{

WMSLoggerFactory.getLogger(CLASS).info(CLASSNAME+".authenticateRequest: userData["+entry.getKey()+"]: "+entry.getValue());

}

}

}

// Then you can set these:

//Perform authentication here and set

// commandControl.canPlay

// commandControl.canPublish

// commandControl.canQuery

Then in the client-side JS you will need to use JSON formatted data:

var userData = {param1:“Value1”};

or for multiple values:

var userData = {param1:“Value1”,param2:“value2”,and3:{param1:“Value1”,param2:“value2”,and3:“3”}};

This can be used as a key/value pair. The key is the first and value the second so it can be whatever you want.

Regards,

JasonT

Thanks JasonT

I already has signed to webRtc Preview, but how can I get this last release?

Thanks for support

Hello JasonT

I already installed wowza version 4.5.0.03 with WEBRTC support.

New version has a built in HTTP listener with Websocket, which do signaliging logic.

In READ_ME instrunctions which came with package, is asking to validate connection on this websocket, to allow publish or play streams.

This websocket can get query string params, and json params sended by javascript. Until here works well.

But on my custom application module, the function onRTPSessionCreate still with blank params. I need keep properties with streaming, like my own system ID, to do some logic when disconnect for example.

On websocket HTTP listener Class, I can validate and get params, even I can save these params in app instance properties or vhost properties, but I can´t reference my id in my custom module, even in onRTPSessionCreate or onStreamCreate.

public void onStreamCreate(IMediaStream stream) 
{	
	stream.getRTPStream(); // null
	stream.getClientId(); // null
	stream.getClient(); // null
	stream.getHTTPStreamerSession(); // null
	stream.getQueryStr(); // null
}

Some functions described in READ ME works, but does not do what I need, because this webrtc session id does not exist on websocket connection, so How can I reference my custom id? How can I retrieve my custom id saved on websocket connection

public void onRTPSessionCreate(RTPSession session) 
{			
	if (session.isWebRTC()) // this works
	{			
		WebRTCSession webrtc_session = session.getWebRTCSession();	// this works		
		webrtc_session.getSessionId(); // this works but does not exist on signaliging websocket, how can I get my custom ID?	
	}
	
	session.getSessionId()); // this works but does not exist on signaliging websocket, how can I get my custom ID?
	session.getQueryStr()); // don´t work - prints null	
	session.getUri()); // don´t work - prints null
}

HTTPWebRTCExchangeSessionInfo (websocket class):

package com.wowza.wms.webrtc.http;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.util.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.webrtc.model.*;
import com.wowza.wms.websocket.model.*;
public class HTTPWebRTCExchangeSessionInfo extends HTTPProvider2Base
{
    private static final Class<HTTPWebRTCExchangeSessionInfo> CLASS = HTTPWebRTCExchangeSessionInfo.class;
	private static final String CLASSNAME = "HTTPWebRTCExchangeSessionInfo";	
	public static final String MIMETYPE_JSON = "application/json";
	public static final String STRING_ENCODING = "UTF-8";
	
	/*
	* Omit some methods
	*/
	
	protected void authenticateRequest(CommandContext commandContext, CommandControl commandControl)
	{
		// this is the best place to validate the request. You have
		// access to the request URI (reqURI) and the JSON
		// sent by the player. Set the above booleans to block publish, play or query.
		// You can add additional data to the JSON
		// payload if you like as long as you do not disturb the fields
		// needed for operation.
		
		JSONObject json = new JSONObject(commandContext.commandRequest.getJSONStr());				
		JSONObject user_data = new JSONObject(json.get("webrtc_data_sended_by_javascript").toString());					
			
		// my custom validation	
		String my_custom_id = MyValidationMethod(user_data);
		if(my_custom_id != null)
		{
			WMSProperties prop = new WMSProperties();
			prop.setProperty(my_custom_id, user_data); // how can I retrieve this custom data on my custom application module?
			commandContext.vhost.getProperties().setProperty("webrtc_connections", prop); // I can save on vhost properties on application instance properties				
		}
		else
		{
			commandControl.canPublish = false;
		}		
	}	
}

Thanks for support

Hi Jason T

This validation througt websocket works for me. I can get json params as you said. But we have a custom module, where we need some logic.

So the problem is: I can´t pass this params or query string sended in Authenticate Request, together RTPSession or WebRTCSession

I need get these query string or Json params in method onRTPSessionCreate(RTPSession session) and onRTPSessionDestroy(RTPSession session) from my custom module to identify them on my custom module.

On my search, I founded where RTP Session is created. Is on WebRTCCommands.sendOffer(vhost, commandRequest, commandResponse) in HTTPWebRTCExchangeSessionInfo.java. In wowza core programming, probably they are not passing params on connection to rtp session or webrtc session.

This is the problem.

To My custom module works, I need these params in methods mencioned before.

Example: The module already works for

RTMP:

onConnect(IClient client, RequestFunction function, AMFDataList params) // I get params from flash in AMFDataList params and save in client.getProperties().setProperty("params",params)
onDisconnect(IClient client) // I get params stored previously with client.getProperties()

HLS:

onHTTPCupertinoStreamingSessionCreate(HTTPStreamerSessionCupertino httpSession) // Get query String and store in httpsession httpSession.getProperties().setProperty("params", httpSession.getQueryStr());
onHTTPCupertinoStreamingSessionDestroy(HTTPStreamerSessionCupertino httpSession)// Get query String stored previously in httpsession with httpSession.getProperties()

WebRTC:

onRTPSessionCreate(RTPSession rtp_session) // rtp_session.getQueryStr() prints null. Even that Json data passed in autenticate I can´t get here
onRTPSessionDestroy(RTPSession rtp_session) // how identificate previously param if I can´t store params with session?

Thanks

Hi Jason Hilton

Sorry for delay to respond, Was busy in my company.

I tried what you suggest, and works here to get Query String params.

Maybe, my problem is that I was setting query String params in websocket negotiation url.

Now works like I expected.

Thanks for support!

For anybody having similar issues:

  • commandContext.commandRequest.setStreamName(“streamname?param1=xx”) in authenticateRequest will send these parameters to onRTPSessionCreate

  • after creating the SDP (WebRTCCommands.sendOffer), commandResponse.getSessionId() will contain same value as rtpSession.getSessionId() under onRTPSessionCreate

  • inside onRTPSessionCreate you can use: rtpSession.getRTSPStream().getStreamName() and rtpSession.getRTSPStream().getStreamQueryStr() to access the parameters you set with commandContext.commandRequest.setStreamName

Be aware, WebRTC connections seems to bypass StreamAliasProvider (at least in my tests).

I am in a similar situation (have a module that controls authentication, accountability, transcoding, stream redirection and I had quite a hard time integrating with all the functionality in wowza … It would really really help if Wowza would offer some documentation regarding the flow for each connection type).