国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

popen打開的stream如何轉(zhuǎn)發(fā)

iz

問題描述

覺得pipe也許可用,但是pipe只對TCPConnection有效,無法轉(zhuǎn)發(fā)stream

為此你搜索到了哪些方案及不適用的原因

于是嘗試使用定時器

stream_set_timeout($stream,0,10);
$timer = Timer::add(0.5,function ($timer) use ($stream,$connection){
    if(feof($stream)) fclose($stream) and Timer::del($timer);
    else $connection->send(fread($stream,1*1024*1024),true);
},[$timer]);

然后意識到,send執(zhí)行后HTTP請求結(jié)束了,于是瀏覽器拿到了皮毛就返回了
找不到合適的方法,請教HTTP數(shù)據(jù)流可能嗎,該如何實現(xiàn)?
(我知道應(yīng)該降級到HTTP/1.0)

984 1 0
1個回答

iz

最后嘗試使用Chunk解決了流媒體的問題

        $stream = popen("ffmpeg -i '$file' -f '$codec' pipe:",'rb');
        stream_set_blocking($stream, false);
        $connection->send(new Response(200, [
            'Transfer-Encoding' => 'chunked',
            'Content-Type'      =>  $ctype
        ], ''));
        $fd = Worker::$globalEvent->onReadable($stream, function () use ($connection,$stream,$fd){
            // $connection->send(fgets($stream),true);
            $connection->send(new Chunk(fgets($stream)));
            if(feof($stream)) pclose($stream) and Worker::$globalEvent->offReadable($fd);
        });

雖然不是使用文檔上的接口,可用就行了

  • 暫無評論
年代過于久遠(yuǎn),無法發(fā)表回答
??