06e1e28c by David LaPalomento

Merge branch 'rajkosto-master'

Closes #216.
2 parents 906d9cba 2bc4731f
Showing 44 changed files with 28 additions and 20 deletions
......@@ -203,7 +203,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('manifests-to-js', 'Wrap the test fixtures and output' +
' so they can be loaded in a browser',
......@@ -230,10 +230,10 @@ module.exports = function(grunt) {
jsManifests += ',\n';
}
if ((/\.json$/).test(abspath)) {
if ((/\.js$/).test(abspath)) {
// append the JSON
jsExpected += ' "' + basename(filename, '.json') + '": ' +
// append the expected parse
jsExpected += ' "' + basename(filename, '.js') + '": ' +
grunt.file.read(abspath) + ',\n';
}
});
......
......@@ -305,6 +305,10 @@
event.attributes = parseAttributes(match[1]);
// parse the IV string into a Uint32Array
if (event.attributes.IV) {
if (event.attributes.IV.substring(0,2) === '0x') {
event.attributes.IV = event.attributes.IV.substring(2);
}
event.attributes.IV = event.attributes.IV.match(/.{8}/g);
event.attributes.IV[0] = parseInt(event.attributes.IV[0], 16);
event.attributes.IV[1] = parseInt(event.attributes.IV[1], 16);
......@@ -438,6 +442,10 @@
method: entry.attributes.METHOD || 'AES-128',
uri: entry.attributes.URI
};
if (entry.attributes.IV !== undefined) {
key.iv = entry.attributes.IV;
}
},
'media-sequence': function() {
if (!isFinite(entry.number)) {
......
......@@ -704,11 +704,10 @@ videojs.Hls.prototype.drainBuffer = function(event) {
} else {
// if the media sequence is greater than 2^32, the IV will be incorrect
// assuming 10s segments, that would be about 1300 years
var segIv = segment.key.iv || new Uint32Array([0, 0, 0, mediaIndex + playlist.mediaSequence]);
bytes = videojs.Hls.decrypt(bytes,
segment.key.bytes,
new Uint32Array([
0, 0, 0,
mediaIndex + playlist.mediaSequence]));
segIv);
}
}
......
......@@ -35,6 +35,15 @@
"uri": "http://media.example.com/fileSequence53-A.ts"
},
{
"duration": 14,
"key": {
"method": "AES-128",
"uri": "https://priv.example.com/key.php?r=54",
"iv": new Uint32Array([0, 0, 331, 3063767524])
},
"uri": "http://media.example.com/fileSequence53-B.ts"
},
{
"duration": 15,
"uri": "http://media.example.com/fileSequence53-B.ts"
}
......
......@@ -17,6 +17,11 @@ http://media.example.com/fileSequence52-C.ts
#EXTINF:15.0,
http://media.example.com/fileSequence53-A.ts
#EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=54",IV=0x00000000000000000000014BB69D61E4
#EXTINF:14.0,
http://media.example.com/fileSequence53-B.ts
#EXT-X-KEY:METHOD=NONE
#EXTINF:15.0,
......
var grunt = require('grunt'),
extname = require('path').extname;
grunt.file.recurse(process.cwd(), function(path) {
var json;
if (extname(path) === '.json') {
json = grunt.file.readJSON(path);
if (json.totalDuration) {
delete json.totalDuration;
grunt.file.write(path, JSON.stringify(json, null, ' '));
}
}
});