Have key.iv be undefined if IV not present
Showing
3 changed files
with
11 additions
and
15 deletions
... | @@ -440,9 +440,12 @@ | ... | @@ -440,9 +440,12 @@ |
440 | // setup an encryption key for upcoming segments | 440 | // setup an encryption key for upcoming segments |
441 | key = { | 441 | key = { |
442 | method: entry.attributes.METHOD || 'AES-128', | 442 | method: entry.attributes.METHOD || 'AES-128', |
443 | uri: entry.attributes.URI, | 443 | uri: entry.attributes.URI |
444 | iv: entry.attributes.IV || null | ||
445 | }; | 444 | }; |
445 | |||
446 | if (entry.attributes.IV !== undefined) { | ||
447 | key.iv = entry.attributes.IV | ||
448 | } | ||
446 | }, | 449 | }, |
447 | 'media-sequence': function() { | 450 | 'media-sequence': function() { |
448 | if (!isFinite(entry.number)) { | 451 | if (!isFinite(entry.number)) { | ... | ... |
... | @@ -704,13 +704,10 @@ videojs.Hls.prototype.drainBuffer = function(event) { | ... | @@ -704,13 +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 theIv = segment.key.iv; | 707 | var segIv = segment.key.iv || new Uint32Array([0, 0, 0, mediaIndex + playlist.mediaSequence]); |
708 | if (theIv === null) { | ||
709 | theIv = new Uint32Array([0, 0, 0, mediaIndex + playlist.mediaSequence]); | ||
710 | } | ||
711 | bytes = videojs.Hls.decrypt(bytes, | 708 | bytes = videojs.Hls.decrypt(bytes, |
712 | segment.key.bytes, | 709 | segment.key.bytes, |
713 | theIv); | 710 | segIv); |
714 | } | 711 | } |
715 | } | 712 | } |
716 | 713 | ... | ... |
... | @@ -6,8 +6,7 @@ | ... | @@ -6,8 +6,7 @@ |
6 | "duration": 2.833, | 6 | "duration": 2.833, |
7 | "key": { | 7 | "key": { |
8 | "method": "AES-128", | 8 | "method": "AES-128", |
9 | "uri": "https://priv.example.com/key.php?r=52", | 9 | "uri": "https://priv.example.com/key.php?r=52" |
10 | "iv": null | ||
11 | }, | 10 | }, |
12 | "uri": "http://media.example.com/fileSequence52-A.ts" | 11 | "uri": "http://media.example.com/fileSequence52-A.ts" |
13 | }, | 12 | }, |
... | @@ -15,8 +14,7 @@ | ... | @@ -15,8 +14,7 @@ |
15 | "duration": 15, | 14 | "duration": 15, |
16 | "key": { | 15 | "key": { |
17 | "method": "AES-128", | 16 | "method": "AES-128", |
18 | "uri": "https://priv.example.com/key.php?r=52", | 17 | "uri": "https://priv.example.com/key.php?r=52" |
19 | "iv": null | ||
20 | }, | 18 | }, |
21 | "uri": "http://media.example.com/fileSequence52-B.ts" | 19 | "uri": "http://media.example.com/fileSequence52-B.ts" |
22 | }, | 20 | }, |
... | @@ -24,8 +22,7 @@ | ... | @@ -24,8 +22,7 @@ |
24 | "duration": 13.333, | 22 | "duration": 13.333, |
25 | "key": { | 23 | "key": { |
26 | "method": "AES-128", | 24 | "method": "AES-128", |
27 | "uri": "https://priv.example.com/key.php?r=52", | 25 | "uri": "https://priv.example.com/key.php?r=52" |
28 | "iv": null | ||
29 | }, | 26 | }, |
30 | "uri": "http://media.example.com/fileSequence52-C.ts" | 27 | "uri": "http://media.example.com/fileSequence52-C.ts" |
31 | }, | 28 | }, |
... | @@ -33,8 +30,7 @@ | ... | @@ -33,8 +30,7 @@ |
33 | "duration": 15, | 30 | "duration": 15, |
34 | "key": { | 31 | "key": { |
35 | "method": "AES-128", | 32 | "method": "AES-128", |
36 | "uri": "https://priv.example.com/key.php?r=53", | 33 | "uri": "https://priv.example.com/key.php?r=53" |
37 | "iv": null | ||
38 | }, | 34 | }, |
39 | "uri": "http://media.example.com/fileSequence53-A.ts" | 35 | "uri": "http://media.example.com/fileSequence53-A.ts" |
40 | }, | 36 | }, | ... | ... |
-
Please register or sign in to post a comment