Securing Streams

QUESTION:

Is there a way I can secure my streams?

Is there a way I can authenticate my streams? 

 

ANSWER:

Yes - you can secure your streams.


How to use parameters to set security on streams:

The Red5 client SDK gives you the option of passing parameters during the server connection event. When using flash scripting with red5, you had the option to include unique information for each new client to identify the session or detect tampering with the server.

With the Red5 Pro client SDK, the client configuration has a setter for connection parameters. They take the form of a semicolon-delimited string.

The parameters are set in the R5Connection class: 


In iOS

http://red5pro.com/docs/static/ios-streaming/interface_r5_connection.html

PublishViewController.m
R5Configuration *config = R5Configuration new;
config.host = domain;
config.contextName = app;
config.port = 8554;
config.protocol = 1;
config.buffer_time = 1;
config.parameters = @"val;val2;"; 


In Android:

R5Configuration configuration = new R5Configuration(R5StreamProtocol.RTSP, “127.0.0.0”, 8554, "live", 1f);
configuration.setParameters("val1;val2;");
R5Stream stream = new R5Stream(new R5Connection(configuration));
StreamCallback client = new StreamCallback();
stream.client = client;


Notes:

  • In the server application adapter, the “appConnect” method receives the parameters along with the session connection.
  • If the connection is not allowed, then the method returns false. The client is then rejected by the server.
  • RTSP clients are prevented from publishing or subscribing to media.

/**

Called when a client connects to the application.

*/
public boolean appConnect(IConnection conn, Object[] params){
log.info("App connect");
//If you have a custom session or state object,
//set an attribute to the connection with it.
conn.setAttribute("statefulObject", new Object());
if(params!=null){
conn.setAttribute("params",params);
for(Object o:params){
log.info("param {}",String.valueOf(o));
}
}


The parameters are parsed from the configuration and given to this method as an array of strings. The method signature shows an object array, but the contents, including numbers will be strings.

However, this treatment of numbers is not unusual in that the same method would be required to parse the number such as:

Integer.valueOf(params0.toString());

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.