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

Remove settings methods from MediaPlayer #2954

Merged

Conversation

epiclabsDASH
Copy link
Contributor

Second phase of changes related with new configuration mechanism for dash.js. We are removing all configuration methods from MediaPlayer, reducing its size and number of methods, and making simpler adding new setting properties (less chained functions).

In this second phase I am removing deprecated methods from MediaPlayer, fixing unit tests, control bar and updating sample source code, included the Dash.js reference player. Typings have also been updated. dash.js package size reduced by 7Kb.

Pending work:

  • Further review of unit tests. Unit tests of settings should be in its own spec.js file. Currently unit tests of settings are placed within MediaPlayer unit tests.
  • Check if makes sense moving text configuration methods to settings (setTextDefaultLanguage, enableForcedTextStreaming).
  • Check if makes sense moving TrackSwitchMode and SelectionModeForInitialTrack methods to settings.
  • Documentation. Create a wiki page explaining how to consume the new settings api.

@epiclabsDASH epiclabsDASH added this to the v3.0 milestone Mar 14, 2019
@epiclabsDASH epiclabsDASH requested a review from nicosang March 14, 2019 11:31
@nicosang
Copy link
Contributor

I'm reviewing your PR @epiclabsDASH. First, according to me, the main problem is that config type is not checked now. I think maybe an update of mixin function can be done to test if the default type of a specific config parameter is the same than the new value....do you agree?

@@ -566,7 +566,11 @@ var ControlBar = function (dashjsMediaPlayer, displayUTCTimeCodes) {
return idx;

} else if (menuType === "bitrate") {
return player.getAutoSwitchQualityFor(mediaType) ? 0 : player.getQualityFor(mediaType);
var cfg = player.getSettings();
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to get autoswitch settings now, @jeoliva ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not? this method is to retrieve the current configured InitialBitrate.

if (player.getAutoSwitchQualityFor(self.mediaType)) {
player.setAutoSwitchQualityFor(self.mediaType, false);
var cfg = player.getSettings();
if (cfg && cfg.streaming && cfg.streaming.abr && cfg.streaming.abr.initialBitrate && cfg.streaming.abr.autoSwitchBitrate[self.mediaType]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same style of question, why do you check initialBitrate @epiclabsDASH ? Maybe, I missed something....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. It was a copy&paste issue.

@@ -16,7 +16,7 @@

function init() {
player = dashjs.MediaPlayer().create();
player.getDebug().setLogToBrowserConsole(false);
player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_NONE }});
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe the function setLogToBrowserConsole can also be removed in Debug.js....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, agree with you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setLogTimestampVisible and setCalleeNameVisible should be also part of the configuration but will take care of them with reviewing new config parameters to be added (texttrack, trackswitchmode, etc)

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 will take care of all these changes in the third PR. It requires to move some unit tests that are already done in Debug module to the unit tests focused on Settings module. In the mean time I am going to ensure no one call these methods but from Debug unit tests.

@@ -115,23 +113,16 @@ function MediaPlayerModel() {
}
}

function getStableBufferTime() {
Copy link
Contributor

Choose a reason for hiding this comment

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

it means that stableBufferTime will be the same if low latency is enabled or fast switch...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right.

@@ -169,10 +169,6 @@ class MediaPlayerModelMock {
}
}

getStableBufferTime() {
Copy link
Contributor

Choose a reason for hiding this comment

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

some attributes can be removed from MediaPlayerModelMock like retryAttempts, stableBufferTime, etc....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was already cleaned up. I left retryAttempts methods because they add some extra logic that that depends on low latency mode (same for stableBufferTime).

@@ -260,297 +259,6 @@ describe('MediaPlayer', function () {
expect(player.setAutoPlay.bind(player, 12)).to.throw(Constants.BAD_ARGUMENT_ERROR);
});

it('should not set setMaxAllowedBitrateFor value if it\'s not a number type or NaN or if type is not Video or Audio', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

a lot of this unit tests have to be saved to be sure that settings type is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. That's part of the pending work I mentioned and that will be included in a third PR.

}
settings.update(s);
Copy link
Contributor

Choose a reason for hiding this comment

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

By removing those lines, datas will not be saved between different streaming.....no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem I see with using settings to persist an initialBitrate that is not really the one set by the user but a "calculated one" (ex: coming from DOMStorage) is just that. When playing a second stream, even when local storage is disabled, AbrController will set as initial bitrate the one that was set for the first played stream which for most of cases is the value coming from DOMStorage.

If user set initialBitrate through settings, with this approach it will be saved across consecutive playbacks.

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