-1

I want to create website with audio streaming. For this I am using Wowza streaming engine.

I have searched for solution but not getting the right direction. I have intergrate:- *jw player *flow Player *strobe player without security but I want secure streaming, For these I have read the https://streamtoolbox.com/wowza-security-and-stream-protection but not getting the solution.

I have used secureToken mechanism to secure RTMP streams and that I have user jw7.3.6 player.below I have mentioned code.

    <?php

    function base64url_encode($data) {
        return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
    }

    $hash = base64url_encode('Shared Secret');//created from WOWZA streaming engine brower based panel Application -> vod -> playback sercurity ->edit
    ?>
    Simple RTMP example
    <br>
    <div id="player"></div>

    <script>
        jwplayer("player").setup({
            sources: [{
                    file: "rtmp://[my wowza ip]:1935/vod/sample.mp4?wowzatokenhash=<?php echo $hash; ?>"
                }],
            height: 360,
            width: 640
        });
    </script>

but video not played.

For secure streaming in flow player i have used http://flash.flowplayer.org/demos/plugins/streaming/secure-wowza.html#html but it requires to compile the token inside the plugin but I did not find any way for this.

please help.

Thanks

Ankit Badiya
  • 451
  • 1
  • 4
  • 17

1 Answers1

0

You have to prepare your secure token based url in a specific manner to be able to leverage its functionality. For RTMP, you could try something like the following:

<?php
// Configure your parameters
$clientIP = null; // provide client IP optionally
$host = "127.0.0.1"; // your ip 
$url= "rtmp://".$host."/";
$stream = "vod/mp4:sample.mp4"; // your stream
$start = time();
$end = strtotime("+30 minutes");  
$secret = "mySharedSecret";  
$tokenName = "wowzatoken";

Then you can define the request url here:

$hash = "";
if(is_null($clientIP)){
    $hash = hash('sha256', $stream."?".$secret."&{$tokenName}endtime=".$end."&{$tokenName}starttime=".$start, true); // generate the hash string
}
else{
    $hash = hash('sha256', $stream."?".$clientIP."&".$secret."&{$tokenName}endtime=".$end."&{$tokenName}starttime=".$start, true); // generate the hash string
}

$base64Hash = strtr(base64_encode($hash), '+/', '-_'); 

$params = array("{$tokenName}starttime=".$start, "{$tokenName}endtime=".$end, "{$tokenName}hash=".$base64Hash);
if(!is_null($clientIP)){
    $params[] = $clientIP;
}
sort($params);

$playbackURL = $url.$stream."?";    

foreach($params as $entry){
    $playbackURL.= $entry."&";
}
$playbackURL = preg_replace("/(\&)$/","", $playbackURL);

Then embed the playerURL into the player:

<div id="myElement">
</div>

<script type="text/javascript">
   jwplayer("myElement").setup({
       file: "<?php echo $playbackURL; ?>"
});
</script>
Matt
  • 201
  • 1
  • 3