<?php
   require_once 'video_streamer_range_basic.php';

   class VideoStreamerRangeRandomChunk extends VideoStreamerRangeBasic {
      private $_chunk_sizes = array();

      public function __construct($video_path, $require_cookie, $min_chunk_size, $max_chunk_size, $step_number) {
         parent::__construct($video_path, $require_cookie, 1024 /* dummy chunk size */);
         // Example: A---B---C---D---E
         //          | 1 | 2 | 3 | 4 |
         // Number of steps: 4
         $step_value = ($max_chunk_size - $min_chunk_size) / $step_number;
         for ($i = 0; $i <= $step_number; $i++) {
            $this->_chunk_sizes[] = intval(round($min_chunk_size + ($step_value * $i)));
         }
      }

      protected function beforeByteSend() {
         $i = random_int(0, count($this->_chunk_sizes) - 1);
         $this->_chunk_size = $this->_chunk_sizes[$i];
      }
   }
?>