We often have customers that want to utilize the Flash Media Live Encoder but also, would like to secure their stream.  We have created server-side code that can be added to the main.asc which will check a variable within the Flash Media Live Encoder.

To incorporate the server-side code simply copy the following code or, download the main.asc within this post and upload it to the application directory to which your Live Encoder is connecting.  Your password is set on the first line and is currently set to “securepass1.”  You can update this to whatever you like, as long as it does not have any non-alphanumeric characters or spaces.

var broadcastpass = "securepass1";

application.onPublish = function( p_client, p_stream )
{

    trace( "onPublish "+p_client.agent+",  "+p_stream.publishQueryString );

    //If broadcaster is secure.
if( broadcastpass != null && broadcastpass.length > 0 ){
    var qData = queryToObject(p_stream.publishQueryString);

    trace("password: "+qData.broadcastpass+", accepted pass: "+broadcastpass);
	    if( qData.broadcastpass != broadcastpass ){
	        trace("Wrong Password - destroy Stream "+p_stream.name);
	        Stream.destroy( p_stream );

            return false;
        }
    }

}

//converts query string to an object for us.
function queryToObject( p_str )
{
    //broadcastPass - look for broadcastpass in query.change it all to lower case.
    var a = p_str.toLocaleLowerCase().split("&");

    var len = a.length;
    var o = new Object();
    for( var i=0; i

Once you have added the server-side code, simply reload the application directory using the FMS Admin Console.  You are finished with the Influxis portion.

Now open the Flash Media Live Encoder and add the rtmp connection path to the directory in the “FMS URL” variable. Within the “Stream” variable, add your stream name plus a query string with the password attached. Here is an example:

mystreamname?broadcastpass=securepass1

If the password matches, it will allow the broadcaster to connect and stream. If the password does not match, the broadcaster will be able to connect and stream but the encoded stream will not be broadcasted to the viewer.

Leave a Reply

Current day month ye@r *