mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 02:09:22 +02:00
This commit is contained in:
parent
37e90e3dfe
commit
214f5d9fc3
4949 changed files with 1393320 additions and 29 deletions
49
node_modules/mux.js/test/mp4-emsg.test.js
generated
vendored
Normal file
49
node_modules/mux.js/test/mp4-emsg.test.js
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
'use strict';
|
||||
|
||||
var QUnit = require('qunit'),
|
||||
emsg = require('../lib/mp4/emsg'),
|
||||
generateEmsgBoxData = require('./utils/mp4-helpers').generateEmsgBoxData,
|
||||
messageData = new Uint8Array([0x64, 0x61, 0x74, 0x61]); // data;
|
||||
|
||||
QUnit.module('EMSG Parsing');
|
||||
|
||||
QUnit.test('Can parse a v0 emsg box', function(assert) {
|
||||
var boxData = generateEmsgBoxData(0, messageData);
|
||||
var parsedBox = emsg.parseEmsgBox(boxData);
|
||||
|
||||
assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v0 box has expected scheme_id_uri');
|
||||
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v0 box has expected value');
|
||||
assert.equal(parsedBox.timescale, 100, 'v0 box has expected timescale');
|
||||
assert.equal(parsedBox.presentation_time, undefined, 'v0 box has expected presentation_time');
|
||||
assert.equal(parsedBox.presentation_time_delta, 1000, 'v0 box has expected presentation_time_delta');
|
||||
assert.equal(parsedBox.event_duration, 0, 'v0 box has expected event_duration');
|
||||
assert.equal(parsedBox.id, 1, 'v0 box has expected id');
|
||||
assert.deepEqual(parsedBox.message_data, messageData, 'v0 box has expected data');
|
||||
|
||||
});
|
||||
|
||||
QUnit.test('Can parse a v1 emsg box', function(assert) {
|
||||
var boxData = generateEmsgBoxData(1, messageData);
|
||||
var parsedBox = emsg.parseEmsgBox(boxData);
|
||||
|
||||
assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v1 box has expected scheme_id_uri');
|
||||
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v1 box has expected value');
|
||||
assert.equal(parsedBox.timescale, 100, 'v1 box has expected timescale');
|
||||
assert.equal(parsedBox.presentation_time, 10000, 'v1 box has expected presentation_time');
|
||||
assert.equal(parsedBox.presentation_time_delta, undefined, 'v1 box has expected presentation_time_delta');
|
||||
assert.equal(parsedBox.event_duration, 1, 'v1 box has expected event_duration');
|
||||
assert.equal(parsedBox.id, 2, 'v1 box has expected id');
|
||||
assert.deepEqual(parsedBox.message_data, messageData, 'v1 box has expected data');
|
||||
});
|
||||
|
||||
QUnit.test('Will return undefined if the emsg version is invalid', function(assert) {
|
||||
var badBoxData = generateEmsgBoxData(2, messageData);
|
||||
var parsedBox = emsg.parseEmsgBox(badBoxData);
|
||||
assert.equal(parsedBox, undefined, 'parsed box is undefined');
|
||||
});
|
||||
|
||||
QUnit.test('Will return undefined if the emsg data is malformed', function(assert) {
|
||||
var badBoxData = generateEmsgBoxData(3, messageData);
|
||||
var parsedBox = emsg.parseEmsgBox(badBoxData);
|
||||
assert.equal(parsedBox, undefined, 'malformed box is undefined');
|
||||
});
|
32
node_modules/mux.js/test/utils.string.test.js
generated
vendored
Normal file
32
node_modules/mux.js/test/utils.string.test.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
var
|
||||
QUnit = require('qunit'),
|
||||
string = require('../lib/utils/string');
|
||||
|
||||
QUnit.module('String Utils');
|
||||
|
||||
QUnit.test('Converts a uint8 array into a C string from start of array until first null char', function(assert) {
|
||||
var uint8String = new Uint8Array([0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72, 0x2E, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00,
|
||||
0x76, 0x61, 0x6C, 0x75, 0x65, 0x2E, 0x62, 0x61, 0x72, 0x00]); // foo.bar.value\0value.bar\0
|
||||
var firstString = string.uint8ToCString(uint8String);
|
||||
assert.equal(firstString, 'foo.bar.value\0', 'converts uint8 data to a c string');
|
||||
assert.equal(firstString.length, 14, 'string has the correct length');
|
||||
var secondString = string.uint8ToCString(uint8String.subarray(14));
|
||||
assert.equal(secondString, 'value.bar\0', 'converts uint8 data to a c string');
|
||||
assert.equal(secondString.length, 10, 'string has the correct length');
|
||||
});
|
||||
|
||||
QUnit.test('Converts a uint8 array with no null char into a C string', function(assert) {
|
||||
var uint8String = new Uint8Array([0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72]); // foo.bar
|
||||
var firstString = string.uint8ToCString(uint8String);
|
||||
assert.equal(firstString, 'foo.bar\0', 'converts uint8 data to a c string');
|
||||
assert.equal(firstString.length, 8, 'string has the correct length');
|
||||
});
|
||||
|
||||
QUnit.test('Returns a null char from a uint8 array starting with a null char', function(assert) {
|
||||
var uint8String = new Uint8Array([0x00, 0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72]); // \0foo.bar
|
||||
var firstString = string.uint8ToCString(uint8String);
|
||||
assert.equal(firstString, '\0', 'converts uint8 data to a c string');
|
||||
assert.equal(firstString.length, 1, 'string has the correct length');
|
||||
});
|
28
node_modules/mux.js/test/utils.typed-array.test.js
generated
vendored
Normal file
28
node_modules/mux.js/test/utils.typed-array.test.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
QUnit = require('qunit'),
|
||||
typedArrayIndexOf = require('../lib/utils/typed-array').typedArrayIndexOf;
|
||||
|
||||
QUnit.module('typedArrayIndexOf');
|
||||
|
||||
QUnit.test('returns -1 when no typed array', function(assert) {
|
||||
assert.equal(typedArrayIndexOf(null, 5, 0), -1, 'returned -1');
|
||||
});
|
||||
|
||||
QUnit.test('returns -1 when element not found', function(assert) {
|
||||
assert.equal(typedArrayIndexOf(new Uint8Array([2, 3]), 5, 0), -1, 'returned -1');
|
||||
});
|
||||
|
||||
QUnit.test('returns -1 when element not found starting from index', function(assert) {
|
||||
assert.equal(typedArrayIndexOf(new Uint8Array([3, 5, 6, 7]), 5, 2), -1, 'returned -1');
|
||||
});
|
||||
|
||||
QUnit.test('returns index when element found', function(assert) {
|
||||
assert.equal(typedArrayIndexOf(new Uint8Array([2, 3, 5]), 5, 0), 2, 'returned 2');
|
||||
});
|
||||
|
||||
QUnit.test('returns index when element found starting from index', function(assert) {
|
||||
assert.equal(typedArrayIndexOf(new Uint8Array([2, 3, 5]), 5, 2), 2, 'returned 2');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue