Laravel阿里云直播功能的实现及地址生成

Laravel阿里云直播功能的实现及地址生成


2024年3月1日发(作者:)

2.配置CNAME解析 3. 关联推流和播流

$play_key = ''; $push_url = $this->push_url($push_domain,$push_key,$expireTime,$appName,$streamName); $data['tui'] = $push_url; $play_url = $this->play_url($play_domain,$play_key,$expireTime,$appName,$streamName); $data['bo']=$play_url; dd($data);

}

function push_url($push_domain,$push_key,$expireTime,$appName,$streamName){ //未开启鉴权Key的情况下 if($push_key==''){ $push_url = 'rtmp://'.$push_domain.'/'.$appName.'/'.$streamName; echo $push_url; return; } $timeStamp = time() + $expireTime; $sstring = '/'.$appName.'/'.$streamName.'-'.$timeStamp.'-0-0-'.$push_key; $md5hash = md5($sstring); $push_url = 'rtmp://'.$push_domain.'/'.$appName.'/'.$streamName.'?auth_key='.$timeStamp.'-0-0-'.$md5hash; return $push_url; }

function play_url($play_domain,$play_key,$expireTime,$appName,$streamName){ //未开启鉴权Key的情况下 if($play_key==''){ $rtmp_play_url = 'rtmp://'.$play_domain.'/'.$appName.'/'.$streamName; $flv_play_url = ''.$play_domain.'/'.$appName.'/'.$streamName.'.flv'; $hls_play_url = ''.$play_domain.'/'.$appName.'/'.$streamName.'.m3u8'; }else{ $timeStamp = time() + $expireTime;

$rtmp_sstring = '/'.$appName.'/'.$streamName.'-'.$timeStamp.'-0-0-'.$play_key; $rtmp_md5hash = md5($rtmp_sstring); $rtmp_play_url = 'rtmp://'.$play_domain.'/'.$appName.'/'.$streamName.'?auth_key='.$timeStamp.'-0-0-'.$rtmp_md5hash;

$flv_sstring = '/'.$appName.'/'.$streamName.'.flv-'.$timeStamp.'-0-0-'.$play_key; $flv_md5hash = md5($flv_sstring); $flv_play_url = ''.$play_domain.'/'.$appName.'/'.$streamName.'.flv?auth_key='.$timeStamp.'-0-0-'.$flv_md5hash;

$hls_sstring = '/'.$appName.'/'.$streamName.'.m3u8-'.$timeStamp.'-0-0-'.$play_key; $hls_md5hash = md5($hls_sstring); $hls_play_url = ''.$play_domain.'/'.$appName.'/'.$streamName.'.m3u8?auth_key='.$timeStamp.'-0-0-'.$hls_md5hash; } $data = [ 'rtmp'=>$rtmp_play_url, 'flv'=>$flv_play_url, 'hls'=>$hls_play_url, ]; return $data; }


发布者:admin,转转请注明出处:http://www.yc00.com/news/1709285097a1616479.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信