Bladeren bron

Fix recording without decryption

Gil Pedersen 10 jaren geleden
bovenliggende
commit
e37018d7b1
2 gewijzigde bestanden met toevoegingen van 4 en 4 verwijderingen
  1. 2 2
      lib/recorder.js
  2. 2 2
      lib/segment-decrypt.js

+ 2 - 2
lib/recorder.js

@@ -195,11 +195,11 @@ HlsStreamRecorder.prototype.process = function(segmentInfo, done) {
   }
 
   // save the stream segment
-  SegmentDecrypt.decrypt(segmentInfo.stream, segmentInfo.details.key, this.decrypt, function (err, stream) {
+  SegmentDecrypt.decrypt(segmentInfo.stream, segmentInfo.details.key, this.decrypt, function (err, stream, decrypted) {
     if (err) {
       console.error('decrypt failed', err.stack);
       stream = segmentInfo.stream;
-    } else {
+    } else if (decrypted) {
       segment.key = null;
     }
 

+ 2 - 2
lib/segment-decrypt.js

@@ -82,7 +82,7 @@ internals.fetchKey = function (keyUri, options, next) {
 exports.decrypt = function (stream, keyAttrs, options, next) {
   var method = keyAttrs && keyAttrs.enumeratedString('method');
   if (!options || !method || method === 'NONE') {
-    return next(null, stream);
+    return next(null, stream, false);
   }
 
   if (method !== 'AES-128' || !keyAttrs.quotedString('uri') || !keyAttrs.hexadecimalInteger('iv')) {
@@ -108,6 +108,6 @@ exports.decrypt = function (stream, keyAttrs, options, next) {
       decrypt.emit('error', err);
     });
 
-    return next(null, stream.pipe(decrypt));
+    return next(null, stream.pipe(decrypt), true);
   });
 };