/** * Check stream control * @param array $media_ids * @return boolean */ public function stream_control($media_ids) { // No check if unlimited bandwidth (= -1) if ($this->time_max < 0) { return true; } // Calculate all media time $next_total = 0; foreach ($media_ids as $media_id) { $media = new $media_id['object_type']($media_id['object_id']); $next_total += $media->time; } $graph = new Graph(); $end_date = time(); $start_date = $end_date - $this->time_days * 86400; $current_total = $graph->get_total_time($this->user_id, $start_date, $end_date); $next_total += $current_total; $max = $this->time_max * 60; debug_event('stream_control_time', 'Next stream time will be ' . $next_total . ' / ' . $max, 3); return $next_total <= $max; }