Great work, very inspired.
I am very new in the web world, but i can understand your great work. big 
fan.
why don't you just use the "new fetch" api as it already support a stream, 
but the "legacy XMLHttpRequest " may need to send  multiple request with 
range making the logic a bit complex.
also, the src "file" may not be a fix-sized video file ,it may be a 
realtime live stream, in this case ,the content-length was unknown, so the 
range request is not possible, right?

I see your entire project, you really have done some great work. appreciate.
在2022年1月8日星期六 UTC+8 00:31:05<Floh> 写道:

> You can read the C and Javascript source code in my sokol_fetch.h header 
> for inspiration, this supports reading large data files piece by piece via 
> HTTP Range requests (via XMLHttpRequest).
>
> https://github.com/floooh/sokol/blob/master/sokol_fetch.h
>
> The interesting stuff is here:
>
>
> https://github.com/floooh/sokol/blob/4ff3ed7d604c3a876146cbf2d89597d81812de22/sokol_fetch.h#L1923-L2064
>
> The fetched data is transferred to the C side by directly copying into the 
> WASM heap here (using a pointer to a pre-allocated buffer from the C side):
>
>
> https://github.com/floooh/sokol/blob/4ff3ed7d604c3a876146cbf2d89597d81812de22/sokol_fetch.h#L1959
>
> It should also be possible to dynamically allocate a memory chunk in the 
> WASM heap on the Javascript side, but I haven't tried that yet. For such 
> things I usually look in the Emscripten SDK's 'src' directory for examples.
>
> An example for sokol_fetch.h which loads data via Range requests is here 
> (this uses https://github.com/phoboslab/pl_mpeg/blob/master/pl_mpeg.h to 
> decode the MPEG stream):
>
> https://floooh.github.io/sokol-html5/plmpeg-sapp.html
>
> Cheers!
> -Floh.
>
> On Friday, 7 January 2022 at 13:07:44 UTC+1 [email protected] wrote:
>
>> Hi,
>> I want to compile ffmpeg to play some H.265 video on the web, i want to 
>> use fetch api(https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) 
>> in js layer to fetch the media data from my server and I can get a 
>> ReadableStream, but how can i get the data chunk from this stream? what's 
>> the best practice, or do i have a  better solution?
>>
>> BTW I've tried the native fetch api ,since the media file may be too big 
>> to load into memory, i must play it piece by piece. but the native fetch 
>> api couldn't implement a "data chunk stream", i have to give it up.
>>
>> Best wishes.
>> Jiaozebo
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/84dfc243-2f25-4fe0-a75b-47e8e35514b8n%40googlegroups.com.

Reply via email to