Dash-Industry-Forum / dash.js

A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.
http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html
Other
5.09k stars 1.67k forks source link

Remove XHR API and only use the Fetch API #4254

Open dsilhavy opened 1 year ago

dsilhavy commented 1 year ago

Description

We are currently using two APIs to download manifests, segments, and subtitle files. The XHR API is used for non low-latency streaming and to fetch the manifest and external subtitle files. We only use the Fetch API for low latency streaming with chunked transfer encoding.

As the Fetch API is supported in all major browsers for some time now we should consider removing XHR completely. If older platforms like SmartTVs or Set Top Boxes do not support the Fetch API we can add the option to include a polyfill.

sapna2504 commented 1 week ago

Hi dsilhavy, When will this be available? In the latest version, v4.7.4, XMLHttpRequest is still used. Any suggestion on how we can only use fetch API?

dsilhavy commented 1 week ago

This has not a high priority at the moment. For non-low latency streaming we still use XHR, there is no configuration flag at this point. If you run a CMAF low latency stream we will use the Fetch API.

Happy to review a pull request that removes XHR completely, but as stated above we have more urgent items to address at this point.

sapna2504 commented 1 week ago

Thanks for the response. Just a follow-up question. If I use CMAF for non low latency stream, even then you will use Fetch API. If I am not wrong CMAF is just a format and DASH.js code does not decide to use Fetch API based on video format.

bbert commented 1 week ago

"If I use CMAF for non low latency stream, even then you will use Fetch API." No.

dash.js decides to use fetch API for media segments if it detects the stream is a low latency stream (based on presence of availabilityTimeComplete attribute ), since fetch API is mandatory in this case to enable appending CMAF fragments as soon as they are produced and downloaded, without waiting for the segments to be fully downloaded.

For all others requests (non low latency segments, init segments, mpd etc) dash.js keeps using the XHR API.