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]);
    }若有帮助到您,欢迎捐赠支持,您的支持是对我坚持最好的肯定(_)
你要保守你心,胜过保守一切。
作者:刘俊涛的博客










