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

fix: Handle audio only audio track change correctly #1100

Merged
merged 23 commits into from
Apr 6, 2021
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
switch to assert true/false
brandonocasey committed Apr 6, 2021
commit a9bfc51e7680954f8d20f5f9d74d5814b5f9bb50
44 changes: 22 additions & 22 deletions test/playlist.test.js
Original file line number Diff line number Diff line change
@@ -1319,42 +1319,42 @@ QUnit.module('Playlist', function() {
});

QUnit.test('playlistMatch', function(assert) {
Copy link
Member

Choose a reason for hiding this comment

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

if playlistMatch returns a boolean, might be better to use assert.true and assert.false. Same for isAudioOnly.

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'll switch to that.

assert.equal(Playlist.playlistMatch(null, null), false, 'null playlists do not match');
assert.equal(Playlist.playlistMatch({}, null), false, 'a playlist without b');
assert.equal(Playlist.playlistMatch(null, {}), false, 'b playlist without a');
assert.false(Playlist.playlistMatch(null, null), 'null playlists do not match');
assert.false(Playlist.playlistMatch({}, null), 'a playlist without b');
assert.false(Playlist.playlistMatch(null, {}), 'b playlist without a');

const a = {id: 'foo', uri: 'foo.m3u8', resolvedUri: 'http://example.com/foo.m3u8'};
const b = {id: 'foo', uri: 'foo.m3u8', resolvedUri: 'http://example.com/foo.m3u8'};

assert.equal(Playlist.playlistMatch(a, a), true, 'object signature match');
assert.true(Playlist.playlistMatch(a, a), 'object signature match');

assert.equal(Playlist.playlistMatch(a, b), true, 'id match');
assert.true(Playlist.playlistMatch(a, b), 'id match');

a.id = 'bar';
assert.equal(Playlist.playlistMatch(a, b), true, 'resolved uri match');
assert.true(Playlist.playlistMatch(a, b), 'resolved uri match');

a.resolvedUri += '?nope';
assert.equal(Playlist.playlistMatch(a, b), true, 'uri match');
assert.true(Playlist.playlistMatch(a, b), 'uri match');

a.uri += '?nope';

assert.equal(Playlist.playlistMatch(a, b), false, 'no match');
assert.false(Playlist.playlistMatch(a, b), 'no match');
});

QUnit.test('isAudioOnly', function(assert) {
assert.equal(Playlist.isAudioOnly({
assert.false(Playlist.isAudioOnly({
playlists: [{attributes: {CODECS: 'mp4a.40.2,avc1.4d400d'}}]
}), false, 'muxed playlist');
}), 'muxed playlist');

assert.equal(Playlist.isAudioOnly({
assert.false(Playlist.isAudioOnly({
playlists: [
{attributes: {CODECS: 'mp4a.40.2,avc1.4d400d'}},
{attributes: {CODECS: 'avc1.4d400d'}},
{attributes: {CODECS: 'mp4a.40.2'}}
]
}), false, 'muxed, audio only, and video only');
}), 'muxed, audio only, and video only');

assert.equal(Playlist.isAudioOnly({
assert.false(Playlist.isAudioOnly({
mediaGroups: {
AUDIO: {
main: {
@@ -1364,37 +1364,37 @@ QUnit.module('Playlist', function() {
}
},
playlists: [{attributes: {CODECS: 'mp4a.40.2,avc1.4d400d'}}]
}), false, 'muxed and alt audio');
}), 'muxed and alt audio');

assert.equal(Playlist.isAudioOnly({
assert.true(Playlist.isAudioOnly({
playlists: [
{attributes: {CODECS: 'mp4a.40.2'}},
{attributes: {CODECS: 'mp4a.40.2'}},
{attributes: {CODECS: 'mp4a.40.2'}}
]
}), true, 'audio only playlists');
}), 'audio only playlists');

assert.equal(Playlist.isAudioOnly({
assert.true(Playlist.isAudioOnly({
mediaGroups: {
AUDIO: {
main: {
en: {id: 'en', uri: 'en'}
}
}
}
}), true, 'only audio groups, uri');
}), 'only audio groups, uri');

assert.equal(Playlist.isAudioOnly({
assert.true(Playlist.isAudioOnly({
mediaGroups: {
AUDIO: {
main: {
en: {id: 'en', playlists: [{uri: 'foo'}]}
}
}
}
}), true, 'only audio groups, playlists');
}), 'only audio groups, playlists');

assert.equal(Playlist.isAudioOnly({
assert.true(Playlist.isAudioOnly({
playlists: [
{id: 'en'}
],
@@ -1405,7 +1405,7 @@ QUnit.module('Playlist', function() {
}
}
}
}), true, 'audio playlists that are also in groups, without codecs');
}), 'audio playlists that are also in groups, without codecs');

});
});