获取阿里云播放地址
@param string $streamName
@return array
350161
public function getPlayUrls($streamName)
    {
        return [
            'rtmp' => $this->getPlayUrlForRTMP($streamName),
            'flv' => $this->getPlayUrlForFLV($streamName),
            'm3u8' => $this->getPlayUrlForM3U8($streamName)
        ];
    }
1369294
public static function localFilename(StreamInterface $stream)
    {
        self::register();

        $uri = 'spiral://' . spl_object_hash($stream);
        self::$uris[$uri] = $stream;

        return $uri;
    }
1226775
public static function mapFileNameToClassName($fileName)
    {
        $matches = [];
        if (preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches)) {
            $fileName = $matches[1];
        }

        return str_replace(' ', '', ucwords(str_replace('_', ' ', $fileName)));
    }
388260
protected function readStream($filename)
    {
        if (!file_exists($filename)) {
            throw new FileNotFoundException(sprintf('The file "%s" does not exists.', $filename));
        }

        $stream = fopen($filename, 'r');
        if (!$stream) {
            throw new FileNotFoundException(sprintf('The file "%s" can\'t be opened.', $filename));
        }

        return $stream;
    }
831783
public function describeLiveStreamOnlineUserNum($streamName = null, $startTime = null, $endTime = null)
    {
        $params = [
            'Action' => 'DescribeLiveStreamOnlineUserNum',
            'DomainName' => $this->domain,
            'AppName' => $this->appName
        ];
        if (!empty($streamName)) {
            $params['StreamName'] = $streamName;
        }
        if (!empty($startTime) && !empty($endTime)) {
            $params['StartTime'] = gmdate('Y-m-d\TH:i:s\Z', $startTime);
            $params['EndTime'] = gmdate('Y-m-d\TH:i:s\Z', $endTime);
        }
        return $this->createRequest($params);
    }
1176687
private static function readFile(string $fileName): ?array
    {
        //配置文件名
        $fullName = $fileName . '.config.php';

        //逐个配置文件目录查找
        foreach (self::$dirs as $dir) {
            try {
                $content = requireFile($dir . DIRECTORY_SEPARATOR . $fullName);
            } catch (RequireFileException $e) {
                continue;
            }
            if ($content) {
                if (!is_array($content)) {
                    throw new ConfigException('配置文件内容必须是数组', ConfigException::CONTENT_NOT_ARRAY);
                }
                return $content;
            }
        }

        //未找到
        return null;
    }
1024836
public function getStubsNamesInDirectory($directoryName)
    {
        if (!$path = $this->getStubDirPath($directoryName)) {
            return [];
        }

        return array_map(
            function($file) {
                return basename($file, '.stub');
            },
            glob("$path/*.stub")
        );
    }
1118458
public static function getMimeTypeFromFilename($fileName)
    {
        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (array_key_exists($ext, self::$customMimeTypes)) {
            return self::$customMimeTypes[$ext];
        } else if (array_key_exists($ext, self::$mimeTypes)) {
            return self::$mimeTypes[$ext];
        }
        return 'application/octet-stream';
    }
799391
public function readStream($path)
    {
        //获得一个临时文件
        $tmpfname       = FileFunction::getTmpFile();

        file_put_contents($tmpfname, file_get_contents($this->applyPathPrefix($path)) );

        $handle = fopen($tmpfname, 'r');

        //删除临时文件
        FileFunction::deleteTmpFile($tmpfname);

        return ['stream' => $handle];
    }
699929
public function get($filename)
    {
        if (!$stream = $this->readStream($filename)) {
            return false;
        }

        $contents = stream_get_contents($stream);

        fclose($stream);

        return $contents;
    }
766700
public static function checkAndLoad(string $filename): string
    {
        $includePathFilename = \stream_resolve_include_path($filename);

        // As a fallback, PHP looks in the directory of the file executing the stream_resolve_include_path function.
        // We don't want to load the Test.php file here, so skip it if it found that.
        // PHP prioritizes the include_path setting, so if the current directory is in there, it will first look in the
        // current working directory.
        $localFile = __DIR__ . DIRECTORY_SEPARATOR . $filename;

        $isReadable = @\fopen($includePathFilename, 'r') !== false;

        if (!$includePathFilename || !$isReadable || $includePathFilename === $localFile) {
            throw new \Exception(\sprintf('Cannot open file "%s".' . "\n", $filename));
        }

        require_once $includePathFilename;

        return $includePathFilename;
    }
1309987
public function getNamesWithDifferentExtension(string $fileName)
    {
        if (! file_exists($this->basePath)) {
            return [];
        }

        $extension = pathinfo($fileName, PATHINFO_EXTENSION);

        $baseName = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1);

        $allNames = scandir($this->basePath);

        $namesWithDifferentExtension = array_filter($allNames, function ($existingName) use ($baseName, $extension) {
            $existingExtension = pathinfo($existingName, PATHINFO_EXTENSION);

            $existingBaseName = substr($existingName, 0, strlen($existingName) - strlen($existingExtension) - 1);

            return $existingBaseName === $baseName && $existingExtension !== $extension;
        });

        return array_values($namesWithDifferentExtension);
    }
301482
static function guessMimeType($fileName)
    {
        self::$map = include(__DIR__ . "/mime.types.php");
        $ext = pathinfo($fileName, PATHINFO_EXTENSION);
        return isset(self::$map[$ext]) ? self::$map[$ext] : 'application/octet-stream';
    }
1373655
public static function getFileContentType($filename)
    {
        $path_parts = pathinfo($filename);//返回文件路径的信息
        $ext = strtolower($path_parts["extension"]); //将字符串转化为小写
        // Determine Content Type
        switch ($ext) {
            case "ico":
                $cType = "image/x-icon";
                break;
            case "pdf":
                $cType = "application/pdf";
                break;
            case "exe":
                $cType = "application/octet-stream";
                break;
            case "zip":
                $cType = "application/zip";
                break;
            case "doc":
                $cType = "application/msword";
                break;
            case "xls":
            case "xlsx":
                $cType = "application/vnd.ms-excel";
                break;
            case "ppt":
                $cType = "application/vnd.ms-powerpoint";
                break;
            case "gif":
                $cType = "image/gif";
                break;
            case "png":
                $cType = "image/png";
                break;
            case "jpeg":
            case "jpg":
                $cType = "image/jpg";
                break;
            case "css":
                $cType = "text/css";
                break;
            case "js":
                $cType = "text/x-javascript";
                break;
            case "html":
                $cType = "text/html";
                break;
            case "txt":
            case "xml":
                $cType = "text/xml";
                break;
            default:
                $cType = "application/force-download";
                break;
        }

//        header("Pragma", "public"); // required 指明响应可被任何缓存保存
//        header("Expires", "0");
//        header("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
//        header("Content-Type", $ctype);
        return $cType;
    }
346586
private function getTokensStream()
    {
        $matches = [];
        \preg_match_all(static::PATTERN_VAR, $this->pattern, $matches);
        foreach ($matches[0] ?? [] as $match) {
            $arr = $this->paramStrToArr($match);

            if (\count($arr) > 3) {
                throw new InvalidArgumentException("Invalid url pattern {$this->pattern}");
            }

            $name = $arr[0];
            $pattern = $arr[1] ?? $this->patterns->getDefaultPattern();
            $default = $arr[2] ?? null;

            yield [
                $match,
                $name,
                $pattern,
                $default
            ];
        }
    }
1093684
public function readSFixed64(Stream $stream)
    {
        $bytes = $stream->read(8);

        list(, $lo0, $lo1, $hi0, $hi1) = unpack('v*', $bytes);

        return ($hi1 << 16 | $hi0) << 32 | ($lo1 << 16 | $lo0);
    }
702189
private function parseTemplateName($templateName){
        if(substr($templateName,0,1)=='$')
            //支持加载变量文件名
            $templateName = $this->get(substr($templateName,1));
        $array  =   explode(',',$templateName);
        $parseStr   =   ''; 
        foreach ($array as $templateName){
            if(empty($templateName)) continue;
            if(false === strpos($templateName,$this->config['template_suffix'])) {
                // 解析规则为 模块@主题/控制器/操作
                $templateName   =   T($templateName);
            }
            // 获取模板文件内容
            $parseStr .= file_get_contents($templateName);
        }
        return $parseStr;
    }