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

Adding the ability for CapLevelController to be enabled/disabled dynamically #1986

Merged
merged 9 commits into from Mar 13, 2019

Conversation

darrennolan
Copy link
Contributor

@darrennolan darrennolan commented Nov 4, 2018

This PR will...

Enable hls.js to toggle capping bitrates to media dimensions dynamically.

Why is this Pull Request needed?

Currently, hls.config.capLevelToPlayerSize is only checked when booting a new source. This allows the start and stop of level capping for the video element's size dynamically.

Use case for us is switching two video positions around (main video and PiP) - where the PiP video downloading at full 1080 and competing for bandwidth against the main video is not ideal. When the videos are switched (PiP becomes the main video) - we'll release the cap, and start capping the previous main video.

image

Are there any points in the code the reviewer needs to double check?

I would love some advice on what docblock should read or state. I did try to take some of the formatting from other get/set blocks, but, totally unsure.

Additionally in the main hls constructor where I've capped the capLevelController to the class, not sure if that's the best way to do this, or if I should be looking to the coreComponents array.

Resolves issues:

Ours internally, but no listed issue that I could find. It is a bit of a continuation of #1541

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

^ Let me update the API docs in API.md now.

@darrennolan
Copy link
Contributor Author

darrennolan commented Nov 5, 2018

Feel I might have to allow some more of the normal manifest startup capturing to happen as currently we seem to be getting too small of bitrates.

I assume this is when on manifestParsed we capture levels and things, but only when the config option has been enabled.

^ Scratch the above. Going over the code again, I can see all the things are collected, even if we don't _startCapping(). Which is what I suspected might have been missed. But this PR is still looking okay. I just need to work out on my contentScaleFactor

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

This is working well from my local testing 👍

What are everyone elses thoughts on adding this functionality? The use case is solid IMO

Copy link
Collaborator

@johnBartos johnBartos left a comment

Choose a reason for hiding this comment

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

LGTM overall with a few changes. Needs a test or two! We'll see about squeezing this into the next release - it's very late in the game already.

src/controller/cap-level-controller.js Outdated Show resolved Hide resolved
src/hls.js Outdated Show resolved Hide resolved
src/controller/cap-level-controller.js Outdated Show resolved Hide resolved
@darrennolan
Copy link
Contributor Author

@johnBartos - sounds good to me. I'll get on that shortly, please don't wait for us. We're happy to go in the next release.

@johnBartos johnBartos added this to the 0.11.2 milestone Nov 22, 2018
@johnBartos
Copy link
Collaborator

@darrennolan Thanks, that helps a lot! Happy to schedule for 0.11.2

* capLevelToPlayerSize now calls start and stop capping accordingly from hls class.
* Removed get against cap level as config can be checked for this state.
@darrennolan
Copy link
Contributor Author

Now for some tests....

@darrennolan
Copy link
Contributor Author

darrennolan commented Jan 7, 2019

@johnBartos - How's this?

One thing I wasn't overly happy with myself, was putting the manually created CapLevelController back onto the HLS object, as that's the link needed for the new pub apis.

What do you think?

Edit: Also any further tests you think it needs, let me know.

@johnBartos
Copy link
Collaborator

johnBartos commented Jan 7, 2019 via email

@johnBartos johnBartos added this to In progress in 0.13.0 via automation Jan 7, 2019
Copy link
Collaborator

@johnBartos johnBartos left a comment

Choose a reason for hiding this comment

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

LGTM, just a few nits and additional tests

src/hls.js Outdated Show resolved Hide resolved
tests/unit/controller/cap-level-controller.js Outdated Show resolved Hide resolved
src/controller/cap-level-controller.js Show resolved Hide resolved
src/hls.js Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
0.13.0 automation moved this from In progress to Needs review Jan 7, 2019
@johnBartos
Copy link
Collaborator

One thing I wasn't overly happy with myself, was putting the manually created CapLevelController back onto the HLS object, as that's the link needed for the new pub apis.

I think this is fine, since it's part of the established pattern with the hls instance

* Removed unnecessary !! for setting config on update.
* Reworded capLevelToPlayerSize tests to suit mocha assertions.
* Added test to ensure stop capping called when cap level controller destroyed.
@darrennolan
Copy link
Contributor Author

Should have all those things fixed up @johnBartos
I am curious about missing afterEach and removing spies after they are created, or using sandbox/cleanup. Should I add that in for us?

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

👍

…apping

* Resolving API documentation updates from master.
@darrennolan
Copy link
Contributor Author

Just resolving new merge conflicts, keeping this little fella ready at a moment's notice..... :)
I will be happy to squash (either now or later) as advised to take out some of these semi-redundant commits.

johnBartos
johnBartos previously approved these changes Feb 13, 2019
0.13.0 automation moved this from Needs review to Reviewer approved Feb 13, 2019
@johnBartos
Copy link
Collaborator

@darrennolan Once the conflict is resolved I'll give it a merge 👍

0.13.0 automation moved this from Reviewer approved to Needs review Feb 14, 2019
0.13.0 automation moved this from Needs review to Reviewer approved Feb 14, 2019
@johnBartos johnBartos merged commit 4425770 into video-dev:master Mar 13, 2019
0.13.0 automation moved this from Reviewer approved to Done Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.13.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants