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) { ...@@ -203,7 +203,7 @@ module.exports = function(grunt) {
203 grunt.loadNpmTasks('grunt-open'); 203 grunt.loadNpmTasks('grunt-open');
204 grunt.loadNpmTasks('grunt-concurrent'); 204 grunt.loadNpmTasks('grunt-concurrent');
205 grunt.loadNpmTasks('grunt-contrib-watch'); 205 grunt.loadNpmTasks('grunt-contrib-watch');
206 206
207 207
208 grunt.registerTask('manifests-to-js', 'Wrap the test fixtures and output' + 208 grunt.registerTask('manifests-to-js', 'Wrap the test fixtures and output' +
209 ' so they can be loaded in a browser', 209 ' so they can be loaded in a browser',
...@@ -230,10 +230,10 @@ module.exports = function(grunt) { ...@@ -230,10 +230,10 @@ module.exports = function(grunt) {
230 jsManifests += ',\n'; 230 jsManifests += ',\n';
231 } 231 }
232 232
233 if ((/\.json$/).test(abspath)) { 233 if ((/\.js$/).test(abspath)) {
234 234
235 // append the JSON 235 // append the expected parse
236 jsExpected += ' "' + basename(filename, '.json') + '": ' + 236 jsExpected += ' "' + basename(filename, '.js') + '": ' +
237 grunt.file.read(abspath) + ',\n'; 237 grunt.file.read(abspath) + ',\n';
238 } 238 }
239 }); 239 });
......
...@@ -305,6 +305,10 @@ ...@@ -305,6 +305,10 @@
305 event.attributes = parseAttributes(match[1]); 305 event.attributes = parseAttributes(match[1]);
306 // parse the IV string into a Uint32Array 306 // parse the IV string into a Uint32Array
307 if (event.attributes.IV) { 307 if (event.attributes.IV) {
308 if (event.attributes.IV.substring(0,2) === '0x') {
309 event.attributes.IV = event.attributes.IV.substring(2);
310 }
311
308 event.attributes.IV = event.attributes.IV.match(/.{8}/g); 312 event.attributes.IV = event.attributes.IV.match(/.{8}/g);
309 event.attributes.IV[0] = parseInt(event.attributes.IV[0], 16); 313 event.attributes.IV[0] = parseInt(event.attributes.IV[0], 16);
310 event.attributes.IV[1] = parseInt(event.attributes.IV[1], 16); 314 event.attributes.IV[1] = parseInt(event.attributes.IV[1], 16);
...@@ -438,6 +442,10 @@ ...@@ -438,6 +442,10 @@
438 method: entry.attributes.METHOD || 'AES-128', 442 method: entry.attributes.METHOD || 'AES-128',
439 uri: entry.attributes.URI 443 uri: entry.attributes.URI
440 }; 444 };
445
446 if (entry.attributes.IV !== undefined) {
447 key.iv = entry.attributes.IV;
448 }
441 }, 449 },
442 'media-sequence': function() { 450 'media-sequence': function() {
443 if (!isFinite(entry.number)) { 451 if (!isFinite(entry.number)) {
......
...@@ -704,11 +704,10 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -704,11 +704,10 @@ videojs.Hls.prototype.drainBuffer = function(event) {
704 } else { 704 } else {
705 // if the media sequence is greater than 2^32, the IV will be incorrect 705 // if the media sequence is greater than 2^32, the IV will be incorrect
706 // assuming 10s segments, that would be about 1300 years 706 // assuming 10s segments, that would be about 1300 years
707 var segIv = segment.key.iv || new Uint32Array([0, 0, 0, mediaIndex + playlist.mediaSequence]);
707 bytes = videojs.Hls.decrypt(bytes, 708 bytes = videojs.Hls.decrypt(bytes,
708 segment.key.bytes, 709 segment.key.bytes,
709 new Uint32Array([ 710 segIv);
710 0, 0, 0,
711 mediaIndex + playlist.mediaSequence]));
712 } 711 }
713 } 712 }
714 713
......
...@@ -35,6 +35,15 @@ ...@@ -35,6 +35,15 @@
35 "uri": "http://media.example.com/fileSequence53-A.ts" 35 "uri": "http://media.example.com/fileSequence53-A.ts"
36 }, 36 },
37 { 37 {
38 "duration": 14,
39 "key": {
40 "method": "AES-128",
41 "uri": "https://priv.example.com/key.php?r=54",
42 "iv": new Uint32Array([0, 0, 331, 3063767524])
43 },
44 "uri": "http://media.example.com/fileSequence53-B.ts"
45 },
46 {
38 "duration": 15, 47 "duration": 15,
39 "uri": "http://media.example.com/fileSequence53-B.ts" 48 "uri": "http://media.example.com/fileSequence53-B.ts"
40 } 49 }
......
...@@ -17,6 +17,11 @@ http://media.example.com/fileSequence52-C.ts ...@@ -17,6 +17,11 @@ http://media.example.com/fileSequence52-C.ts
17 #EXTINF:15.0, 17 #EXTINF:15.0,
18 http://media.example.com/fileSequence53-A.ts 18 http://media.example.com/fileSequence53-A.ts
19 19
20 #EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=54",IV=0x00000000000000000000014BB69D61E4
21
22 #EXTINF:14.0,
23 http://media.example.com/fileSequence53-B.ts
24
20 #EXT-X-KEY:METHOD=NONE 25 #EXT-X-KEY:METHOD=NONE
21 26
22 #EXTINF:15.0, 27 #EXTINF:15.0,
......
1 var grunt = require('grunt'),
2 extname = require('path').extname;
3
4 grunt.file.recurse(process.cwd(), function(path) {
5 var json;
6 if (extname(path) === '.json') {
7 json = grunt.file.readJSON(path);
8 if (json.totalDuration) {
9 delete json.totalDuration;
10 grunt.file.write(path, JSON.stringify(json, null, ' '));
11 }
12 }
13 });