|
|
@ -708,6 +708,554 @@ QUnit.test('key 500 calls back with error', function(assert) { |
|
|
|
keyReq.respond(500, null, ''); |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test('init segment with key has bytes decrypted', function(assert) { |
|
|
|
const done = assert.async(); |
|
|
|
const postMessage = this.mockDecrypter.postMessage; |
|
|
|
|
|
|
|
this.transmuxer = this.createTransmuxer(); |
|
|
|
|
|
|
|
// mock decrypting the init segment.
|
|
|
|
this.mockDecrypter.postMessage = (message) => { |
|
|
|
message.encrypted.bytes = mp4VideoInit().buffer; |
|
|
|
message.encrypted.byteLength = message.encrypted.bytes.byteLength; |
|
|
|
message.encrypted.byteOffset = 0; |
|
|
|
|
|
|
|
return postMessage.call(this.mockDecrypter, message); |
|
|
|
}; |
|
|
|
let trackInfo; |
|
|
|
const timingInfo = {}; |
|
|
|
let data; |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn(segment, _trackInfo) { |
|
|
|
trackInfo = _trackInfo; |
|
|
|
}, |
|
|
|
timingInfoFn(segment, type, prop, value) { |
|
|
|
timingInfo[type] = timingInfo[type] || {}; |
|
|
|
timingInfo[type][prop] = value; |
|
|
|
}, |
|
|
|
dataFn(segment, _data) { |
|
|
|
data = _data; |
|
|
|
}, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
assert.notOk(error, 'there are no errors'); |
|
|
|
assert.ok(segmentData.map.bytes, 'decrypted bytes in map'); |
|
|
|
assert.ok(segmentData.map.key.bytes, 'key bytes in map'); |
|
|
|
assert.equal( |
|
|
|
segmentData.map.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
|
|
|
|
// verify stats
|
|
|
|
assert.equal(segmentData.stats.bytesReceived, 6198, '6198 bytes'); |
|
|
|
|
|
|
|
assert.ok(data, 'got data'); |
|
|
|
assert.ok(trackInfo, 'got track info'); |
|
|
|
assert.ok(Object.keys(timingInfo).length, 'got timing info'); |
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 3, 'there are three requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests.shift(); |
|
|
|
const mapReq = this.requests.shift(); |
|
|
|
const segmentReq = this.requests.shift(); |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(mapReq.uri, '0-map.mp4', 'the second request is for a map'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the third request is for a segment'); |
|
|
|
|
|
|
|
segmentReq.responseType = 'arraybuffer'; |
|
|
|
segmentReq.respond(200, null, mp4Video().buffer); |
|
|
|
mapReq.responseType = 'arraybuffer'; |
|
|
|
mapReq.respond(200, null, new Uint8Array(8).buffer); |
|
|
|
keyReq.responseType = 'arraybuffer'; |
|
|
|
keyReq.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
// mock decrypting the init segment.
|
|
|
|
this.mockDecrypter.postMessage = (message) => { |
|
|
|
// segment is 9, init is 8
|
|
|
|
if (message.encrypted.byteLength === 8) { |
|
|
|
message.encrypted.bytes = mp4VideoInit().buffer; |
|
|
|
} else { |
|
|
|
message.encrypted.bytes = mp4Video(); |
|
|
|
} |
|
|
|
message.encrypted.byteLength = message.encrypted.bytes.byteLength; |
|
|
|
message.encrypted.byteOffset = 0; |
|
|
|
|
|
|
|
return postMessage.call(this.mockDecrypter, message); |
|
|
|
}; |
|
|
|
let trackInfo; |
|
|
|
const timingInfo = {}; |
|
|
|
let data; |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
}, |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn(segment, _trackInfo) { |
|
|
|
trackInfo = _trackInfo; |
|
|
|
}, |
|
|
|
timingInfoFn(segment, type, prop, value) { |
|
|
|
timingInfo[type] = timingInfo[type] || {}; |
|
|
|
timingInfo[type][prop] = value; |
|
|
|
}, |
|
|
|
dataFn(segment, _data) { |
|
|
|
data = _data; |
|
|
|
}, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
assert.notOk(error, 'there are no errors'); |
|
|
|
assert.ok(segmentData.map.bytes, 'decrypted bytes in map'); |
|
|
|
assert.ok(segmentData.map.key.bytes, 'key bytes in map'); |
|
|
|
assert.equal( |
|
|
|
segmentData.map.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
|
|
|
|
assert.ok(segmentData.bytes, 'decrypted bytes in segment'); |
|
|
|
assert.ok(segmentData.key.bytes, 'key bytes in segment'); |
|
|
|
assert.equal( |
|
|
|
segmentData.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
|
|
|
|
// verify stats
|
|
|
|
assert.equal(segmentData.stats.bytesReceived, 9, '9 bytes'); |
|
|
|
assert.equal(segmentData.key.bytes, segmentData.map.key.bytes, 'keys are the same'); |
|
|
|
|
|
|
|
assert.ok(data, 'got data'); |
|
|
|
assert.ok(trackInfo, 'got track info'); |
|
|
|
assert.ok(Object.keys(timingInfo).length, 'got timing info'); |
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 3, 'there are three requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests.shift(); |
|
|
|
const mapReq = this.requests.shift(); |
|
|
|
const segmentReq = this.requests.shift(); |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(mapReq.uri, '0-map.mp4', 'the second request is for a map'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the third request is for a segment'); |
|
|
|
|
|
|
|
segmentReq.responseType = 'arraybuffer'; |
|
|
|
segmentReq.respond(200, null, new Uint8Array(9).buffer); |
|
|
|
mapReq.responseType = 'arraybuffer'; |
|
|
|
mapReq.respond(200, null, new Uint8Array(8).buffer); |
|
|
|
keyReq.responseType = 'arraybuffer'; |
|
|
|
keyReq.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
// mock decrypting the init segment.
|
|
|
|
this.mockDecrypter.postMessage = (message) => { |
|
|
|
// segment is 9, init is 8
|
|
|
|
if (message.encrypted.byteLength === 8) { |
|
|
|
message.encrypted.bytes = mp4VideoInit().buffer; |
|
|
|
} else { |
|
|
|
message.encrypted.bytes = mp4Video(); |
|
|
|
} |
|
|
|
message.encrypted.byteLength = message.encrypted.bytes.byteLength; |
|
|
|
message.encrypted.byteOffset = 0; |
|
|
|
|
|
|
|
return postMessage.call(this.mockDecrypter, message); |
|
|
|
}; |
|
|
|
let trackInfo; |
|
|
|
const timingInfo = {}; |
|
|
|
let data; |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
}, |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '1-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn(segment, _trackInfo) { |
|
|
|
trackInfo = _trackInfo; |
|
|
|
}, |
|
|
|
timingInfoFn(segment, type, prop, value) { |
|
|
|
timingInfo[type] = timingInfo[type] || {}; |
|
|
|
timingInfo[type][prop] = value; |
|
|
|
}, |
|
|
|
dataFn(segment, _data) { |
|
|
|
data = _data; |
|
|
|
}, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
assert.notOk(error, 'there are no errors'); |
|
|
|
assert.ok(segmentData.map.bytes, 'decrypted bytes in map'); |
|
|
|
assert.ok(segmentData.map.key.bytes, 'key bytes in map'); |
|
|
|
assert.equal( |
|
|
|
segmentData.map.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
|
|
|
|
assert.ok(segmentData.bytes, 'decrypted bytes in segment'); |
|
|
|
assert.ok(segmentData.key.bytes, 'key bytes in segment'); |
|
|
|
assert.equal( |
|
|
|
segmentData.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
assert.notEqual(segmentData.key.bytes, segmentData.map.key.bytes, 'keys are different'); |
|
|
|
|
|
|
|
// verify stats
|
|
|
|
assert.equal(segmentData.stats.bytesReceived, 9, '9 bytes'); |
|
|
|
|
|
|
|
assert.ok(data, 'got data'); |
|
|
|
assert.ok(trackInfo, 'got track info'); |
|
|
|
assert.ok(Object.keys(timingInfo).length, 'got timing info'); |
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 4, 'there are four requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests.shift(); |
|
|
|
const keyReq2 = this.requests.shift(); |
|
|
|
const mapReq = this.requests.shift(); |
|
|
|
const segmentReq = this.requests.shift(); |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(keyReq2.uri, '1-key.php', 'the second request is for a key'); |
|
|
|
assert.equal(mapReq.uri, '0-map.mp4', 'the third request is for a map'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the forth request is for a segment'); |
|
|
|
|
|
|
|
segmentReq.responseType = 'arraybuffer'; |
|
|
|
segmentReq.respond(200, null, new Uint8Array(9).buffer); |
|
|
|
mapReq.responseType = 'arraybuffer'; |
|
|
|
mapReq.respond(200, null, new Uint8Array(8).buffer); |
|
|
|
keyReq.responseType = 'arraybuffer'; |
|
|
|
keyReq.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
keyReq2.responseType = 'arraybuffer'; |
|
|
|
keyReq2.respond(200, null, new Uint32Array([4, 5, 6, 7]).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test('encrypted init segment parse error', function(assert) { |
|
|
|
const done = assert.async(); |
|
|
|
const postMessage = this.mockDecrypter.postMessage; |
|
|
|
|
|
|
|
this.transmuxer = this.createTransmuxer(); |
|
|
|
|
|
|
|
// mock decrypting the init segment.
|
|
|
|
this.mockDecrypter.postMessage = (message) => { |
|
|
|
// segment is 9, init is 8
|
|
|
|
if (message.encrypted.byteLength === 8) { |
|
|
|
// Responding with a webm segment is something we do not
|
|
|
|
// support. so this will be an error.
|
|
|
|
message.encrypted.bytes = webmVideoInit().buffer; |
|
|
|
} else { |
|
|
|
message.encrypted.bytes = mp4Video(); |
|
|
|
} |
|
|
|
message.encrypted.byteLength = message.encrypted.bytes.byteLength; |
|
|
|
message.encrypted.byteOffset = 0; |
|
|
|
|
|
|
|
return postMessage.call(this.mockDecrypter, message); |
|
|
|
}; |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
}, |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '1-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn: this.noop, |
|
|
|
timingInfoFn: this.noop, |
|
|
|
dataFn: this.noop, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
// decrypted webm init segment caused this error.
|
|
|
|
assert.ok(error, 'error for invalid init segment'); |
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 4, 'there are four requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests.shift(); |
|
|
|
const keyReq2 = this.requests.shift(); |
|
|
|
const mapReq = this.requests.shift(); |
|
|
|
const segmentReq = this.requests.shift(); |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(keyReq2.uri, '1-key.php', 'the second request is for a key'); |
|
|
|
assert.equal(mapReq.uri, '0-map.mp4', 'the third request is for a map'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the forth request is for a segment'); |
|
|
|
|
|
|
|
segmentReq.responseType = 'arraybuffer'; |
|
|
|
segmentReq.respond(200, null, new Uint8Array(9).buffer); |
|
|
|
mapReq.responseType = 'arraybuffer'; |
|
|
|
mapReq.respond(200, null, new Uint8Array(8).buffer); |
|
|
|
keyReq.responseType = 'arraybuffer'; |
|
|
|
keyReq.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
keyReq2.responseType = 'arraybuffer'; |
|
|
|
keyReq2.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test('encrypted init segment request failure', function(assert) { |
|
|
|
const done = assert.async(); |
|
|
|
|
|
|
|
this.transmuxer = this.createTransmuxer(); |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
}, |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '1-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn: this.noop, |
|
|
|
timingInfoFn: this.noop, |
|
|
|
dataFn: this.noop, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
assert.ok(error, 'errored'); |
|
|
|
this.requests.forEach(function(request) { |
|
|
|
assert.ok(request.aborted, 'request aborted'); |
|
|
|
}); |
|
|
|
|
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 4, 'there are four requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests[0]; |
|
|
|
const keyReq2 = this.requests[1]; |
|
|
|
const mapReq = this.requests[2]; |
|
|
|
const segmentReq = this.requests[3]; |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(keyReq2.uri, '1-key.php', 'the second request is for a key'); |
|
|
|
assert.equal(mapReq.uri, '0-map.mp4', 'the third request is for a map'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the forth request is for a segment'); |
|
|
|
|
|
|
|
mapReq.responseType = 'arraybuffer'; |
|
|
|
mapReq.respond(500, null, new Uint8Array(8).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
// mock decrypting the init segment.
|
|
|
|
this.mockDecrypter.postMessage = (message) => { |
|
|
|
message.encrypted.bytes = mp4Video(); |
|
|
|
message.encrypted.byteLength = message.encrypted.bytes.byteLength; |
|
|
|
message.encrypted.byteOffset = 0; |
|
|
|
|
|
|
|
return postMessage.call(this.mockDecrypter, message); |
|
|
|
}; |
|
|
|
let trackInfo; |
|
|
|
const timingInfo = {}; |
|
|
|
let data; |
|
|
|
|
|
|
|
mediaSegmentRequest({ |
|
|
|
xhr: this.xhr, |
|
|
|
xhrOptions: this.xhrOptions, |
|
|
|
decryptionWorker: this.mockDecrypter, |
|
|
|
segment: { |
|
|
|
transmuxer: this.transmuxer, |
|
|
|
resolvedUri: '0-test.mp4', |
|
|
|
key: { |
|
|
|
resolvedUri: '0-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
}, |
|
|
|
map: { |
|
|
|
resolvedUri: '0-map.mp4', |
|
|
|
bytes: mp4VideoInit().buffer, |
|
|
|
timescales: { |
|
|
|
1: 30000 |
|
|
|
}, |
|
|
|
tracks: { |
|
|
|
video: { |
|
|
|
id: 1, |
|
|
|
timescale: 30000, |
|
|
|
type: 'video', |
|
|
|
codec: 'avc1.64001e' |
|
|
|
} |
|
|
|
}, |
|
|
|
key: { |
|
|
|
resolvedUri: '1-key.php', |
|
|
|
iv: { |
|
|
|
bytes: new Uint32Array([0, 0, 0, 1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
trackInfoFn(segment, _trackInfo) { |
|
|
|
trackInfo = _trackInfo; |
|
|
|
}, |
|
|
|
timingInfoFn(segment, type, prop, value) { |
|
|
|
timingInfo[type] = timingInfo[type] || {}; |
|
|
|
timingInfo[type][prop] = value; |
|
|
|
}, |
|
|
|
dataFn(segment, _data) { |
|
|
|
data = _data; |
|
|
|
}, |
|
|
|
progressFn: this.noop, |
|
|
|
doneFn: (error, segmentData) => { |
|
|
|
assert.notOk(error, 'there are no errors'); |
|
|
|
assert.ok(segmentData.bytes, 'decrypted bytes in segment'); |
|
|
|
assert.ok(segmentData.key.bytes, 'key bytes in segment'); |
|
|
|
assert.equal( |
|
|
|
segmentData.key.bytes.buffer.byteLength, |
|
|
|
16, |
|
|
|
'key bytes are readable' |
|
|
|
); |
|
|
|
|
|
|
|
// verify stats
|
|
|
|
assert.equal(segmentData.stats.bytesReceived, 9, '9 bytes'); |
|
|
|
|
|
|
|
assert.ok(data, 'got data'); |
|
|
|
assert.ok(trackInfo, 'got track info'); |
|
|
|
assert.ok(Object.keys(timingInfo).length, 'got timing info'); |
|
|
|
done(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
assert.equal(this.requests.length, 2, 'there are two requests'); |
|
|
|
|
|
|
|
const keyReq = this.requests.shift(); |
|
|
|
const segmentReq = this.requests.shift(); |
|
|
|
|
|
|
|
assert.equal(keyReq.uri, '0-key.php', 'the first request is for a key'); |
|
|
|
assert.equal(segmentReq.uri, '0-test.mp4', 'the second request is for a segment'); |
|
|
|
|
|
|
|
segmentReq.responseType = 'arraybuffer'; |
|
|
|
segmentReq.respond(200, null, new Uint8Array(9).buffer); |
|
|
|
keyReq.responseType = 'arraybuffer'; |
|
|
|
keyReq.respond(200, null, new Uint32Array([0, 1, 2, 3]).buffer); |
|
|
|
|
|
|
|
// Allow the decrypter to decrypt
|
|
|
|
this.clock.tick(100); |
|
|
|
}); |
|
|
|
|
|
|
|
QUnit.test( |
|
|
|
'waits for every request to finish before the callback is run', |
|
|
|
function(assert) { |
|
|
|