我目前正在处理保护来自 Level3 CDN 的 rtmp 流。
文档可以在这里找到: https://rapidshare.com/files/1450549534/Token_Components.html (看来你需要登录才能查看,所以我托管在rapidshare上。原来的网址是: https://mediaportal.level3.com/mediaWeb/help/Content/ServicesDocs-Streaming/StreamingTokenAuth/TokenComponents.htm )
向下滚动到点播流输入/输出示例(对于 MP4 文件)
我正在尝试重现该示例并获得具有相同值的相同 url。我为此写了一个小函数:
function flimmithash($file) {
$streamer = 'pmsales';
$host = 'pmsalesfs.fplive.net';
$start_time = '20080101120000';
$end_time = '20101231235900';
$customer_secret = 'Secret'; // in the documentation there is also secret with a non capital s, i tried both
$resouce_path = "/$streamer/$file"; echo "resouce_path: $resouce_path <br>\n";
$message = "$resouce_path?start_time=$start_time&end_time=$end_time#$customer_secret"; echo "message: $message <br>\n";
$digest = md5($message); echo "digest: $digest <br>\n";
$tokenvalue = "start_time=$start_time&end_time=$end_time&digest=$digest"; echo "tokenvalue: $tokenvalue <br>\n";
$token = base64_encode($tokenvalue); echo "token: $token <br>\n";
$url = "rtmp://$host/$streamer?token=".($token)."/mp4:$file"; echo "url: $url <br>\n";
return $url;
}
echo "url: ".flimmithash('support/lvlt300kbps.mp4')."<br>\n";
我使用与示例中完全相同的值,但无法获得相同的摘要。
我使用了 md5,因为它匹配长度。我还尝试了大写和非大写的 secret。
您可以在此处转到示例脚本:https://rapidshare.com/files/2581196874/Appendix.html (原文:https://mediaportal.level3.com/mediaWeb/help/Content/ServicesDocs-Streaming/StreamingTokenAuth/Appendix-SampleScripts.htm)
但是绝对没有用md5,他们用的是sha1。但是 sha1 比示例中的摘要要长。
当然,我尝试用我的值填充两个版本,但都没有用。
所以我的问题是:任何人都可以重现示例和/或告诉我摘要或更改我的函数以根据示例工作吗?
最佳答案
他们的例子不正确。他们给出的摘要是针对文件 /support/lvlt300kbps.flv
的,并且可以使用小写的 secret
作为共享 secret ,使用 md5 轻松生成该文件名。您可以在他们的文档中看到它与 FLV 示例中给出的摘要相同。
关于php - 从 Level3 CDN 保护 RTMP 流的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6060910/