Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Stream's DownloadingQueue into fetchers' SegmentQueue
While working on CMCD (#1461), I saw an opportunity for doing a refactoring that I initially postponed: moving what was called the `DownloadingQueue` from the `RepresentationStream` to the `fetchers` code. The modules involved -------------------- The `DownloadingQueue` is a class allowing to put the current list of wanted segments for a given media type (audio, video, text) into a FIFO queue so they can be requested from the most urgent (usually the one coming right next in the corresponding media buffer) to the least urgent (usually the ones consecutive to that segment, in chronological order) - through a simple interface. The `DownloadingQueue` does both the queueing (the list of wanted segments is given to it as input) and the requesting (by relying on an instanciated `SegmentFetcher` - defined in the `fetchers` code) as well as some optimizations such as requesting the initialization segment at the same time than the initially-wanted media segment when possible. Previously, that `DownloadingQueue` was part of the `RepresentationStream` (in the `src/core/stream/representation` directory). The `RepresentationStream` is documented as the module whose role is to find the right segments to load, to orchestrate their requests and then to push them into the right `SegmentSink` (`src/core/segment_sinks`). In terms of responsibility and readability of the code it can make sense to put the `DownloadingQueue` in the `RepresentationStream`, but I always felt that it would be more at its place in the `fetchers` code for segments instead (in `src/core/fetchers/segment). The `fetchers` code for segments's role is to actually perform the segment requests, and do so in a transport-agnostic way (the transport-specific part being defined in `src/transports` which is directly used by the `fetchers` code). What I did here --------------- Basically, I moved the `DownloadingQueue` file into the `src/core/fetchers/segment` directory and renamed it `SegmentQueue` as it made more sense to me to remove the `Downloading` part from the name now that it is implied from its new location, and add the `Segment` part, which is sort of a convention in the `fetchers` to separate manifest-related code to segment-related code. I then made the `SegmentQueue` one of the main modules to be used by code external to the `fetchers` (here principally the `RepresentationStream`) instead of the `PrioritizedSegmentFetcher` like before. I also tried to simplify the whole `fetchers` API for segments so it can be straightforward to use from other modules without having to understand logic specific to that part. What's the relation with CMCD ----------------------------- As written at the start, this was done in relation with my work on CMCD, because that scheme can optionally provide to the CDN hints about what segment it is going to load next (with the previous segment's request). Previously, this would have meant an akward supplementary parameter somewhere asking for information on the next wanted segment for what's in the end very specific. By instead updating the `fetchers` (which is the module directly exploiting CMCD) so its API is already aware of the current queue of wanted segments (and not just the most urgent one like before), implementing "next segment hints" can be done without having to involve any other module.
- Loading branch information