Streaming
Wowza Streaming Engine SecureToken Sample
요새 준비하는 동영상 스트리밍 서비스를 위해 Wowza를 테스트 해보고 있습니다. 유료 동영상 서비스 중에 고민되는 것들 중 하나가 URL 보안 부분인데 Wowza에서는 SecureToken을 이용한 기능을 제공해주고 있습니다. https://www.wowza.com/forums/content.php?620-How-to-protect-streaming-using-SecureToken-in-Wowza-Streaming-Engine SecureToken 생성 시 많은 삽질을 경험하게 됩니다. 아래 PHP Sample Code를 먼저 참고해주세요~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?php /** * Note. * * 1. 해쉬값을 만들때 wowzatokenCustomParam, wowzatokenendtime, wowzatokenstarttime 순서를 맞춰야 한다. * * 2. 서브폴더를 사용하려면 아래와 같은 형태로 작업해야 한다. * vodtest/_definst_/mp4:2016/11/sample_subdir.mp4 * 어플리케이션명/_definst_/mp4:폴더경로/파일명 * */ header("Content-Type: text/html; charset=UTF-8"); date_default_timezone_set('Asia/Seoul');//set the time zone if server time-zone is not correct $startTime = time(); //$starttime = strtotime('+24 hours'); $endTime = strtotime('+30 seconds'); $prefixParameter = 'wowzatoken'; $sharedSecret = '1acce578vb1na4b8'; $hashString = hash('sha256', 'vodtest/_definst_/mp4:2016/11/sample_subdir.mp4?'.$sharedSecret.'&wowzatokenCustomParam=gameonevod&wowzatokenendtime='.$endTime.'&wowzatokenstarttime='.$startTime, true); # IMPORTANT to set third parameter equals to TRUE $usableHash= strtr(base64_encode($hashString), '+/', '-_'); $params = $prefixParameter.'starttime='.$startTime.'&'.$prefixParameter.'endtime='.$endTime.'&'.$prefixParameter.'CustomParam=gameonevod'.'&'.$prefixParameter.'hash='.$usableHash; echo 'rtmp://192.168.0.210:1935/vodtest/_definst_/mp4:2016/11/sample_subdir.mp4?'.$params; echo '<br/>'; echo '<br/>';Streaming echo 'http://192.168.0.210:1935/vodtest/_definst_/mp4:2016/11/sample_subdir.mp4/playlist.m3u8?'.$params; |