'', // 'rts'=>'' ]; $push_url['rtmp'] = 'rtmp://' . $config['push_domain'] . '/' . $appName . '/' . $streamName; // $push_url['rts'] = 'artc://' . $config['push_domain'] . '/' . $appName . '/' . $streamName; //未开启鉴权Key的情况下 if ($config['push_key']) { $timeStamp = time() + self::$expireTime; $sstring = '/' . $appName . '/' . $streamName . '-' . $timeStamp . '-0-0-' . $config['push_key']; $md5hash = md5($sstring); $args['auth_key'] = $timeStamp . '-0-0-' . $md5hash; } $push_url['rtmp'] .= '?'.http_build_query($args); // $push_url['rts'] .= '?'.http_build_query($args); return $push_url; } /** * 播流域名 * @param $appName * @param $streamName * @param string $templateId 转码模板ID,非空时生成转码流地址 * @return string[] */ public static function playUrl($appName, $streamName, $templateId = '') { $config = \app\common\model\config\System::getConfig('ali_live'); // 转码流在 StreamName 后拼接 _{templateId} $realStreamName = $streamName; if ($templateId !== '') { $realStreamName = $streamName . '_' . $templateId; } //未开启鉴权Key的情况下 if ($config['play_key'] == '') { $rtmp_play_url = 'rtmp://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName; $artc_play_url = 'artc://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName; $flv_play_url = 'https://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '.flv'; $hls_play_url = 'https://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '.m3u8'; } else { $timeStamp = time() + self::$expireTime; $rtmp_sstring = '/' . $appName . '/' . $realStreamName . '-' . $timeStamp . '-0-0-' . $config['play_key']; $rtmp_md5hash = md5($rtmp_sstring); $rtmp_play_url = 'rtmp://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '?auth_key=' . $timeStamp . '-0-0-' . $rtmp_md5hash; $flv_sstring = '/' . $appName . '/' . $realStreamName . '.flv-' . $timeStamp . '-0-0-' . $config['play_key']; $flv_md5hash = md5($flv_sstring); $flv_play_url = 'https://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '.flv?auth_key=' . $timeStamp . '-0-0-' . $flv_md5hash; $hls_sstring = '/' . $appName . '/' . $realStreamName . '.m3u8-' . $timeStamp . '-0-0-' . $config['play_key']; $hls_md5hash = md5($hls_sstring); $hls_play_url = 'https://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '.m3u8?auth_key=' . $timeStamp . '-0-0-' . $hls_md5hash; $artc_sstring = '/' . $appName . '/' . $realStreamName . '-' . $timeStamp . '-0-0-' . $config['play_key']; $artc_md5hash = md5($artc_sstring); $artc_play_url = 'artc://' . $config['play_domain'] . '/' . $appName . '/' . $realStreamName . '?auth_key=' . $timeStamp . '-0-0-' . $artc_md5hash; } return [ 'rtmp'=>$rtmp_play_url, 'artc'=>$artc_play_url, 'flv'=>$flv_play_url, 'hls'=>$hls_play_url ]; } /** * 获取会调地址 * @return string */ public static function getCallbackUrl(){ global $_W; return $_W['siteroot'].'/index.php?i='.$_W['uniacid'].'&route=callback/live/playback'; } }