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