-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support parallel prefetch of mpeg-dash segments #2809
Conversation
This diff adds the ability to download segments listed in a mpeg-dash manifest in parallel. Before this diff, the segments would be downloaded serially. This despite knowing the list of segments to be downloaded apriori. This diff changes that allows shaka-player to prefetch segment downloads. The exact level of parallelism, or the exact number of segments to be prefetched is controlled via a configuration "prefetchLimit". When set to zero, it defaults back to older behaviour. When set to a positive number shaka-player would prefetch only those many segments in parallel and then wait until some of the ongoing downloads finish before issuing more prefetch requests. There are some strange observations w.r.t. behaviour with range requests, pre-flight OPTIONS request and chrome. In many cases every segment request is preceeding by a OPTIONS request. With browser's cache disabled this often leads to multiple identical OPTIONS request. When cache is enabled, that causes an undesirable behaviour with chrome. Chrome's cache has a writer lock and it blocks any subsequent request that has the same URL as the one being currently downloaded. This for range requests often defeats the purpose of the diff as it leads to serialization of all range requests for the same segment (same URL). Thankfully, firefox does not see this issue. Tests: o Ran this version of shaka-player on my local setup and saw segments getting prefetched in parallel. o By changing the prefetchLimit, checked that the number of segments downloads being in flight mimicked the configuration. o Tested the same on chrome as well as firefox.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Let us know if you change your mind. We're always happy to discuss enhancements! |
Hi @sabyasachiroy Thanks ! |
closes #4658. This solution is inspired by abandoned PR #2809, which implements segment prefetching ahead of current play head. ![image](https://user-images.githubusercontent.com/3315733/205465795-75c605d2-c2e3-4d03-90f5-46a72a7189d2.png)
This diff adds the ability to prefetch and download segments listed in a
mpeg-dash manifest in parallel. Before this diff, the segments would be
downloaded serially.
The exact level of parallelism, or the exact number of segments to be
prefetched is controlled via a configuration "prefetchLimit". When set to
zero, it defaults back to older behaviour. When set to a positive number,
shaka-player would prefetch only that many segments in parallel and
then wait until some of the ongoing downloads finish before issuing more
prefetch requests.
There are some strange observations w.r.t. behaviour with range requests,
pre-flight OPTIONS request and chrome. In many cases every segment
request is preceded by a OPTIONS request. With browser's cache disabled this
often leads to multiple identical OPTIONS request. When cache is enabled,
that causes an undesirable behaviour with chrome. Chrome's cache has a
writer lock and it blocks any subsequent request that has the same URL
as the one being currently downloaded. This, for range requests, often
defeats the purpose of the diff as it leads to serialisation of all range
requests for the same segment (same URL). Thankfully, firefox does not see
this issue.
Tests:
o Ran this version of shaka-player on my local setup and saw
segments getting prefetched in parallel.
o By changing the prefetchLimit, checked that the number of
segments downloads being in flight mimicked the configuration.
o Tested the same on chrome as well as firefox.