-
Notifications
You must be signed in to change notification settings - Fork 791
Blacklist audio only playlists on probe if already playing video #1257
Blacklist audio only playlists on probe if already playing video #1257
Conversation
test/segment-loader.test.js
Outdated
assert.equal(errors.length, 0, 'no errors'); | ||
}); | ||
|
||
QUnit.test('does not error when going from audio only to avoid and video', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be audio and video
Looks good to me |
test/segment-loader.test.js
Outdated
assert.equal(errors.length, 0, 'no errors'); | ||
}); | ||
|
||
QUnit.test('does not error when going from audio only to audio and video', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we support this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I switch from audio only to audio/video rendition it gives me error as VIDEOJS: ERROR: DOMException: Failed to set the 'duration' property on 'MediaSource': The 'updating' attribute is true on one or more of this MediaSource's SourceBuffers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we support it, but I put the test in since we don't want to throw the error there for now (until we re-consider). I can remove the test case if we want, until we are sure about behavior.
Seems from @shahlabs ' testing we may want to consider an error anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well according to the MSE spec, going from audio only to audio + video will be dependent on browser
For example, a user agent may throw a QuotaExceededError exception if the media element has reached the HAVE_METADATA readyState. This can occur if the user agent's media engine does not support adding more tracks during playback.
https://w3c.github.io/media-source/#dom-mediasource-addsourcebuffer
So if we want to support this, we should make sure which browsers support it, and handle the error in browsers that dont. I think its preferable to just not allow switching between audio only and video+audio and vice versa.
Might be worth seeing what happens when going from video only to audio+video as well, though I'm not sure if that is something anyone is trying to do in their manifests.
src/segment-loader.js
Outdated
// don't support switching from audio and video to audio only. If the codecs were in | ||
// the master manifest, then the renditions incompatible with the first rendition | ||
// would already be blacklisted. | ||
if (this.isUsingVideo_ && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WRT the other discussion on going from audio only to video+audio
If we decide that we want to support that, this will NOT trigger an error in the event that you start audio only, switch to video+audio, and then try to switch back to audio only since this.isUsingVideo_
will be set to false
from the initial audio only timing source
src/segment-loader.js
Outdated
|
||
if (!startingMedia.containsAudio && startingMedia.containsVideo && | ||
newSegmentMedia.containsAudio && !newSegmentMedia.containsVideo) { | ||
return 'Only audio found in segment when we expected video only.' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit misleading saying we expected "video only" as we can go from starting with video only to video + audio (sort of, if starting was video only because there was a separate audio segment loader and not because there was just only video stream)
src/segment-loader.js
Outdated
return 'Neither audio nor video found in segment.'; | ||
} | ||
|
||
if (startingMedia.containsAudio && startingMedia.containsVideo && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could simplify this and still give informative messages
if (startingMedia.containsVideo && !newSegmentMedia.containsVideo) {
return 'Only audio found in segment when we expected video.' +
' We can\'t switch to audio only from a stream that had video' +
' To get rid of this message, please add codec information to the manifest.';
}
if (!startingMedia.containsVideo && newSegmentMedia.containsVideo) {
return 'Video found in segment when we expected only audio.' +
' We can\'t switch to a Video stream from a stream that had only audio' +
' To get rid of this message, please add codec information to the manifest.';
}
test/segment-loader.test.js
Outdated
' manifest.', | ||
'error when muxed to audio only'); | ||
|
||
startingMedia = { containsAudio: true, containsVideo: true }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test that has startingMedia = { containsAudio: true, containsVideo: false };
and newSegmentMedia = { containsAudio: false, containsVideo: false };
just to confirm it also returns 'Neither audio nor video found in segment.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you forgot to updated containsVideo
here, this test is exactly the same as the one on line 55. Also would be nice to move the two tests for 'Neither audio nor video found in segment.'
next to each other just for reading through, but not necessary
@@ -603,5 +675,92 @@ QUnit.module('SegmentLoader', function(hooks) { | |||
assert.ok(!playlistUpdated.segments[0].end, | |||
'no end info for first segment of new playlist'); | |||
}); | |||
|
|||
QUnit.test('errors when trying to switch from audio and video to audio only', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe another test like this but switching from audio only to video and audio
@@ -20,6 +23,75 @@ const ogAddSegmentMetadataCue_ = SegmentLoader.prototype.addSegmentMetadataCue_; | |||
|
|||
SegmentLoader.prototype.addSegmentMetadataCue_ = function() {}; | |||
|
|||
QUnit.module('SegmentLoader Isolated Functions'); | |||
|
|||
QUnit.test('illegalMediaSwitch detects illegal media switches', function(assert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to adda test that passes type === 'audio'
since the audio segment loader will also be calling this function
src/segment-loader.js
Outdated
|
||
this.syncController_.probeSegmentInfo(segmentInfo); | ||
let illegalMediaSwitchError = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
src/segment-loader.js
Outdated
// Although these checks should most likely cover non 'main' types, for now it narrows | ||
// the scope of our checks. | ||
if (loaderType !== 'main' || !startingMedia || !newSegmentMedia) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you make use of the return value, it might be a good idea to explicitly return null
or false
Description
When a master playlist doesn't contain codec info, we have to wait until we probe to know if a rendition is audio only. Because we can't switch from audio and video to audio only, blacklist that playlist if we're already playing video.
Requirements Checklist