柚子快报激活码778899分享:TP5 在线直播 实现

http://yzkb.51969.com/

TP5 在线直播 实现

namespace app\admin\controller;

use think\Db;

/**

* @title 直播

* xpush.xxxx.cn 推流域名

* xlive.xxxx.cn 播流域名

*/

class Live

{

public $appName="xxxx";

/**

* @title 推流

* @域名 xpush.xxxx.cn

* @param string $appName 应用名称 -- 会议名

* @param string $streamName 名称 -- 主题

* @param string $host 域名

* @param string $pushPrivatekey `推流`鉴权key

* @param string $livePrivatekey `播流`鉴权key

* @param int $timestamp 过期时间(时间戳)有效期30分钟

* @param string $rand 随机数(建议使用uuid不能包含-),暂时0

* @param int $uid 暂时0

* @param string $md5hash 验证串

*/

public function pushFlow()

{

$room_name = input('room_name');

$meet_id = input('meet_id');

$appName = $this->appName; //线上会议

$streamName = MD5($room_name);

$pushHost = 'xpush.xxxx.cn';

$timestamp = time() + 60 * 60 * 30;

$rand = 0;

$uid = 0;

//推流

$pushPrivatekey = 'xxxx';

$md5hash = '/'.$appName.'/'.$streamName.'-'.$timestamp.'-'.$rand.'-'.$uid.'-' . $pushPrivatekey;

$md5hash = md5($md5hash);

$pushUrl = 'rtmp://' . $pushHost . '/' . $appName . '/' . $streamName . '?auth_key=' . $timestamp . '-'. $rand . '-' . 0 . '-' . $md5hash;

return json(['code'=>1,'msg'=>'success','data'=>$pushUrl]);

}

文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

若有帮助到您,欢迎捐赠支持,您的支持是对我坚持最好的肯定(_)

柚子快报激活码778899分享:TP5 在线直播 实现

http://yzkb.51969.com/

精彩链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。