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

test: cleanup transmuxers in tests #1163

Merged
merged 2 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5839,6 +5839,10 @@ QUnit.test('maxPlaylistRetries defaults to Infinity when no value or null/undefi
assert.equal(playerNull.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when null is provided as the option value');
assert.equal(playerUndefined.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when undefined is provided as the option value');
assert.equal(playerNoValue.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when no value is provided');

playerNoValue.dispose();
playerUndefined.dispose();
playerNull.dispose();
});

QUnit.test('maxPlaylistRetries is set when zero is passed as the option\'s value', function(assert) {
Expand All @@ -5858,6 +5862,8 @@ QUnit.test('maxPlaylistRetries is set when zero is passed as the option\'s value
this.clock.tick(1);

assert.equal(player.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, 0, 'maxPlaylistRetries was set to zero');

player.dispose();
});

QUnit.test('true duration < 16 with experimentalBufferBasedABR', function(assert) {
Expand Down
54 changes: 24 additions & 30 deletions test/media-segment-request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,25 @@ const sharedHooks = {
this.clock.tick(1);
};

this.transmuxers = [];
this.createTransmuxer = () => {
return createTransmuxer_({
const transmuxer = createTransmuxer_({
remux: false,
keepOriginalTimestamps: true
});

this.transmuxers.push(transmuxer);

return transmuxer;
};
},
afterEach(assert) {
this.realDecrypter.terminate();
this.env.restore();

if (this.transmuxer) {
this.transmuxer.terminate();
}
this.transmuxers.forEach(function(transmuxer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

seemed safer to keep track of every transmuxer we create and clean them all up.

transmuxer.terminate();
});
}

};
Expand Down Expand Up @@ -108,10 +113,7 @@ QUnit.module('Media Segment Request - make it to transmuxer', {
});

},
afterEach(assert) {
this.transmuxer = this.options.segment.transmuxer;
sharedHooks.afterEach.call(this, assert);
}
afterEach: sharedHooks.afterEach
});

QUnit.test('ac3 without id3 segments will not make it to the transmuxer', function(assert) {
Expand Down Expand Up @@ -712,8 +714,7 @@ QUnit.test('key 500 calls back with error', function(assert) {
QUnit.test('init segment with key has bytes decrypted', function(assert) {
const done = assert.async();
const postMessage = this.mockDecrypter.postMessage;

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

// mock decrypting the init segment.
this.mockDecrypter.postMessage = (message) => {
Expand All @@ -732,7 +733,7 @@ QUnit.test('init segment with key has bytes decrypted', function(assert) {
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
map: {
resolvedUri: '0-map.mp4',
Expand Down Expand Up @@ -799,8 +800,7 @@ QUnit.test('init segment with key has bytes decrypted', function(assert) {
QUnit.test('segment/init segment share a key and get decrypted', function(assert) {
const done = assert.async();
const postMessage = this.mockDecrypter.postMessage;

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

// mock decrypting the init segment.
this.mockDecrypter.postMessage = (message) => {
Expand All @@ -824,7 +824,7 @@ QUnit.test('segment/init segment share a key and get decrypted', function(assert
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
key: {
resolvedUri: '0-key.php',
Expand Down Expand Up @@ -906,8 +906,7 @@ QUnit.test('segment/init segment share a key and get decrypted', function(assert
QUnit.test('segment/init segment different key and get decrypted', function(assert) {
const done = assert.async();
const postMessage = this.mockDecrypter.postMessage;

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

// mock decrypting the init segment.
this.mockDecrypter.postMessage = (message) => {
Expand All @@ -931,7 +930,7 @@ QUnit.test('segment/init segment different key and get decrypted', function(asse
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
key: {
resolvedUri: '0-key.php',
Expand Down Expand Up @@ -1017,8 +1016,7 @@ QUnit.test('segment/init segment different key and get decrypted', function(asse
QUnit.test('encrypted init segment parse error', function(assert) {
const done = assert.async();
const postMessage = this.mockDecrypter.postMessage;

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

// mock decrypting the init segment.
this.mockDecrypter.postMessage = (message) => {
Expand All @@ -1041,7 +1039,7 @@ QUnit.test('encrypted init segment parse error', function(assert) {
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
key: {
resolvedUri: '0-key.php',
Expand Down Expand Up @@ -1097,15 +1095,14 @@ QUnit.test('encrypted init segment parse error', function(assert) {

QUnit.test('encrypted init segment request failure', function(assert) {
const done = assert.async();

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

mediaSegmentRequest({
xhr: this.xhr,
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
key: {
resolvedUri: '0-key.php',
Expand Down Expand Up @@ -1159,8 +1156,7 @@ QUnit.test('encrypted init segment request failure', function(assert) {
QUnit.test('encrypted init segment with decrypted bytes not re-requested', function(assert) {
const done = assert.async();
const postMessage = this.mockDecrypter.postMessage;

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

// mock decrypting the init segment.
this.mockDecrypter.postMessage = (message) => {
Expand All @@ -1179,7 +1175,7 @@ QUnit.test('encrypted init segment with decrypted bytes not re-requested', funct
xhrOptions: this.xhrOptions,
decryptionWorker: this.mockDecrypter,
segment: {
transmuxer: this.transmuxer,
transmuxer,
resolvedUri: '0-test.mp4',
key: {
resolvedUri: '0-key.php',
Expand Down Expand Up @@ -1261,8 +1257,7 @@ QUnit.test(
'waits for every request to finish before the callback is run',
function(assert) {
const done = assert.async();

this.transmuxer = this.createTransmuxer();
const transmuxer = this.createTransmuxer();

assert.expect(10);
mediaSegmentRequest({
Expand All @@ -1280,7 +1275,7 @@ QUnit.test(
map: {
resolvedUri: '0-init.dat'
},
transmuxer: this.transmuxer
transmuxer
},
progressFn: this.noop,
trackInfoFn: this.noop,
Expand Down Expand Up @@ -1326,7 +1321,6 @@ QUnit.test('non-TS segment will get parsed for captions', function(assert) {
let gotCaption = false;
let gotData = false;
const captions = [{foo: 'bar'}];

const transmuxer = new videojs.EventTarget();

transmuxer.postMessage = (event) => {
Expand Down