Skip to content
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

refactor: Add a better distinction between master and child dash loaders #992

Merged
merged 4 commits into from
Nov 19, 2020

Conversation

brandonocasey
Copy link
Contributor

Description

I am working on refactoring the parsing logic in dash-playlist-loader. This is difficult because the logic is almost impossible to follow in the current state of the code. I tried a grand over-arching refactor and ultimately wasn't happy with it. Instead I am going to opt for smaller changes to get us towards what we want.

Steps

  1. (this pull request) Add a property (isMaster_) to identify if the dash-playlist-loader is master. When masterPlaylistLoader is not passed into the constructor we know that the master playlist loader will be this one. We also shadow this.masterPlaylistLoader to this for master so that operations that update master always happen on this.masterPlaylistLoader. This simplifies a lot of the code and makes it much easier to understand.
  2. refactor parseMasterXml so that it keeps track of xml that has already been parsed, and does not parse again. Also make filterChangedSidxMappings use this logic rather than parsing on it's own.
  3. (might be part of 2) refactor any requesting/parsing logic that we can into a central place so that we are not calling the same functions everywhere.

@brandonocasey brandonocasey force-pushed the refactor/distinctive-master branch from 1cdbf5f to 1ece93f Compare November 10, 2020 20:23
@gkatsev gkatsev added this to the 2.4 milestone Nov 17, 2020
Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question, really

Comment on lines -280 to +285
if (typeof srcUrlOrPlaylist === 'string') {
if (this.isMaster_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we verify that srcUrlOrPlaylist is a string or is it basically guaranteed to be one if we're a master manifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For master it will always be a string, for others it can be a playlist or string. So yes it would seem so.

@@ -528,7 +518,7 @@ export default class DashPlaylistLoader extends EventTarget {

// request the specified URL
this.request = this.vhs_.xhr({
uri: this.srcUrl,
uri: this.masterPlaylistLoader_.srcUrl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we return early above for non master loaders, would it be clearer to use just this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want it to be like this because:

  1. The distinction will help us migrate master playlist loader code into a new file after these refactors.
  2. It's much easier to know that you are accessing the correct object if you always access it the same way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks!

this.srcUrl = srcUrlOrPlaylist;
// TODO: reset sidxMapping between period changes
// once multi-period is refactored
this.sidxMapping_ = {};
return;
this.masterPlaylistLoader_.sidxMapping_ = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the conditional above for master loaders, would it be clearer to use just this?

test/dash-playlist-loader.test.js Outdated Show resolved Hide resolved
Comment on lines +626 to +629
masterXml: this.masterPlaylistLoader_.masterXml_,
srcUrl: this.masterPlaylistLoader_.srcUrl,
clientOffset: this.masterPlaylistLoader_.clientOffset_,
sidxMapping: this.masterPlaylistLoader_.sidxMapping_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question re: above

@brandonocasey brandonocasey merged commit 56592bc into main Nov 19, 2020
evanfarina pushed a commit to evanfarina/http-streaming that referenced this pull request Nov 26, 2020
@brandonocasey brandonocasey deleted the refactor/distinctive-master branch December 10, 2020 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants