Procházet zdrojové kódy

change pre buffer option to a simple read ahead buffer size option

Gil Pedersen před 13 roky
rodič
revize
fe4d5507d6
2 změnil soubory, kde provedl 3 přidání a 14 odebrání
  1. 3 3
      bin/hlsdump
  2. 0 11
      lib/reader.js

+ 3 - 3
bin/hlsdump

@@ -17,7 +17,7 @@ hlsdump.version('0.0.0')
      }
      return r;
    })
-   .option('-b, --prebuffer-size <bytes>', 'prebuffer <bytes> input data before output (implies -s)')
+   .option('-b, --buffer-size <bytes>', 'try to buffer <bytes> of input data (implies -s)')
    .option('-s, --sync', 'clock sync using stream PCR')
    .option('-k, --keep-connection', 'don\'t give up once connected')
    .option('-f, --full-stream', 'fetch all stream data')
@@ -35,9 +35,9 @@ var reader = require('../lib/reader'),
 var src = process.argv[2];
 if (!src) return hlsdump.help();
 
-if (hlsdump.prebufferSize) hlsdump.sync = true;
+if (hlsdump.bufferSize) hlsdump.sync = true;
 
-var r = reader(src, {prebufferSize:hlsdump.prebufferSize/*, bufferSize:10000*/, keepConnection:hlsdump.keepConnection, fullStream:hlsdump.fullStream});
+var r = reader(src, {highWaterMark:hlsdump.bufferSize, keepConnection:hlsdump.keepConnection, fullStream:hlsdump.fullStream});
 
 var time = 0;
 r.on('segment', function(seqNo, duration, meta) {

+ 0 - 11
lib/reader.js

@@ -97,7 +97,6 @@ function HlsStreamReader(src, options) {
   this.url = src;
   this.baseUrl = src;
 
-  this.prebufferSize = options.prebufferSize || 0;
   this.fullStream = !!options.fullStream;
   this.keepConnection = !!options.keepConnection;
   this.noData = !!options.noData;
@@ -110,16 +109,6 @@ function HlsStreamReader(src, options) {
     stream:null
   }
 
-  if (this.prebufferSize) {
-    var lwm = options.lowWaterMark || 0;
-    var hwm = options.highWaterMark || this.prebufferSize * 2;
-    options.lowWaterMark = Math.max(this.prebufferSize, lwm);
-    options.highWaterMark = Math.max(hwm, lwm);
-    this.once('readable', function() {
-      self._readableState.lowWaterMark = ~~lwm;
-    });
-  }
-
   function updatecheck(updated) {
     if (updated) {
       if (self.readState.currentSeq===-1)