コード例 #1
0
ファイル: drm.php プロジェクト: h3len/Project
 public function show()
 {
     if ($this->settings['limit_referer']) {
         $drm = false;
         $salt = 'aiudfhakj';
         $referer = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : $this->input['refererurl'];
         $setreferer = explode(',', $this->settings['limit_referer']);
         foreach ($setreferer as $re) {
             if (strpos($referer, $re)) {
                 $drm = true;
                 $salt = '';
                 break;
             }
         }
     } else {
         $drm = true;
         $salt = '';
     }
     $url = $this->input['url'];
     if (!$url) {
         $this->errorOutput(NO_URL);
     }
     $urlinfo = parse_url($url);
     $sign = hg_sign_uri($urlinfo['path'] . $salt, $this->settings['live_expire'], $this->settings['sign_type']);
     $url = $urlinfo['scheme'] . '://' . $urlinfo['host'];
     if ($urlinfo['port']) {
         $url .= ':' . $urlinfo['port'];
     }
     if ($this->settings['encipt_url']) {
         $url = $this->encipt($urlinfo['path'], $sign[0]);
     } else {
         $url .= $urlinfo['path'] . $sign[0];
     }
     if ($this->input['return']) {
         $this->additem(array('url' => $url));
         $this->output();
     } else {
         echo $url;
     }
 }
コード例 #2
0
ファイル: playlist.php プロジェクト: h3len/Project
    private function build_m3u8($ts, $end = '', $preurl = '', $shield_time_zone = array())
    {
        if (!$ts) {
            return '';
        }
        $m3u8_str = '';
        $cur_last_ts = array();
        foreach ($ts as $r) {
            if ($shield_time_zone) {
                $go = false;
                $stime = intval($r['start_time'] / 1000);
                foreach ($shield_time_zone as $zone) {
                    if ($stime >= $zone['start_time'] && $stime <= $zone['end_time']) {
                        $go = true;
                        break;
                    }
                }
                if ($go) {
                    continue;
                }
            }
            $source = $r['source'];
            if ($r['file_start'] || $source == 0 && $cur_last_ts && $source != $cur_last_ts['source']) {
                $m3u8_str .= '#EXT-X-DISCONTINUITY
';
            }
            if (substr($r['path'], 0, 4) != 'http') {
                if ($preurl && substr($r['path'], 0, 1) == '/') {
                    $sign = hg_sign_uri($r['path'], $this->settings['live_expire'], $this->settings['sign_type']);
                    $r['path'] = $preurl . $r['path'] . $sign[0];
                }
            }
            $m3u8_str .= '#EXTINF:' . round($r['duration'] / 1000, 4) . ',
' . $r['path'] . '
';
            $cur_last_ts = $r;
        }
        $m3u8_str = '#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:20
#EXT-X-MEDIA-SEQUENCE:' . $this->mSequence . '
' . $end . '
' . $m3u8_str;
        return $m3u8_str;
    }
コード例 #3
0
ファイル: functions.php プロジェクト: h3len/Project
/**
 * 拼接流地址
 * Enter description here ...
 * @param unknown_type $wowzaip
 * @param unknown_type $app_name
 * @param unknown_type $stream_name
 * @param unknown_type $type
 * @param unknown_type $starttime
 * @param unknown_type $dvr
 * @param unknown_type $protocol
 */
function hg_set_stream_url($wowzaip, $app_name, $stream_name, $type = '', $servertype = '', $starttime = '', $dvr = '', $protocol = 'http://', $psuffix = '/playlist.m3u8')
{
    global $gGlobalConfig;
    $suffix = '';
    if ($type == 'flv') {
        $suffix = '/manifest.f4m';
        $wowzaip = hg_replace_stream_port($wowzaip);
    } else {
        if ($type == 'm3u8') {
            $suffix = $psuffix;
            $wowzaip = hg_replace_stream_port($wowzaip);
        } else {
            if ($type == 'manifest.m3u8') {
                $suffix = '/manifest.m3u8';
                $wowzaip = hg_replace_stream_port($wowzaip);
            } else {
                $protocol = 'rtmp://';
            }
        }
    }
    if ($dvr == 'dvr') {
        $dvr = '?dvr';
    }
    if ($starttime) {
        $starttime = '&starttime=' . $starttime;
    }
    if ($app_name) {
        $app_name = '/' . $app_name;
    }
    if ($servertype == 'nginx') {
        if ($protocol == 'rtmp://') {
            return $url = $protocol . $wowzaip . $app_name . '/' . $stream_name . $suffix . $dvr . $starttime;
        }
        $path = '/' . $stream_name . $suffix . $dvr . $starttime;
        $sign = hg_sign_uri($path, $gGlobalConfig['live_expire'], $gGlobalConfig['sign_type']);
        return $url = $protocol . $wowzaip . $path . $sign[0];
    }
    $path = $app_name . '/' . $stream_name . $suffix . $dvr . $starttime;
    if ($protocol == 'http://') {
        $sign = hg_sign_uri($path, $gGlobalConfig['live_expire'], $gGlobalConfig['sign_type']);
    }
    return $url = $protocol . $wowzaip . $path . $sign[0];
}
コード例 #4
0
ファイル: program.php プロジェクト: h3len/Project
 public function set_m3u8($channel_info)
 {
     $channel_stream = $channel_info['channel_stream'][0];
     if (!$channel_info['is_sys'] && $channel_stream['timeshift_url']) {
         $timeshift_url = $channel_stream['timeshift_url'];
         if (strstr($timeshift_url, 'dvr') && strstr($timeshift_url, '{&#036;starttime}') && strstr($timeshift_url, '{&#036;duration}')) {
             $timeshift_url = str_replace('{&#036;starttime}', $channel_info['starttime'] . '000', $timeshift_url);
             $timeshift_url = str_replace('{&#036;duration}', $channel_info['toff'] . '000', $timeshift_url);
         } else {
             if (strstr($timeshift_url, '{&#036;starttime}') && strstr($timeshift_url, '{&#036;endtime}')) {
                 $timeshift_url = str_replace('{&#036;starttime}', $channel_info['starttime'] . '000', $timeshift_url);
                 $timeshift_url = str_replace('{&#036;endtime}', $channel_info['starttime'] + $channel_info['toff'] . '000', $timeshift_url);
             }
         }
         $m3u8 = $timeshift_url;
     } else {
         if ($channel_stream['live_m3u8']) {
             if ($channel_info['server_type'] == 'nginx') {
                 $m3u8url = parse_url($channel_stream['live_m3u8']);
                 $m3u8url['path'] = str_replace(array('playlist.m3u8', 'live.m3u8'), $channel_info['starttime'] * 1000 . ',' . $channel_info['toff'] * 1000 . '.m3u8', $m3u8url['path']);
                 $sign = hg_sign_uri($m3u8url['path'], $this->settings['live_expire'], $this->settings['sign_type']);
                 $m3u8 = $m3u8url['scheme'] . '://' . $m3u8url['host'] . $m3u8url['path'] . $sign[0];
             } else {
                 $m3u8url = parse_url($channel_stream['live_m3u8']);
                 $m3u8 = $m3u8url['scheme'] . '://' . $m3u8url['host'] . $m3u8url['path'] . '?dvr&starttime=' . $channel_info['starttime'] * 1000 . '&duration=' . $channel_info['toff'] * 1000;
             }
         } else {
             $m3u8 = '';
         }
     }
     return $m3u8;
 }