Studiocam ingebouwd

This commit is contained in:
2020-06-12 17:37:44 +02:00
parent 6d2a2b38a2
commit eb71f5a953

View File

@@ -30,7 +30,7 @@ QUERY;
// //
} }
public function addToSchedule(&$schedule, $start, $end, $program) { public function addToSchedule(&$schedule, $start, $end, $program, $scheduleid) {
if($start == $end) { if($start == $end) {
return; return;
} }
@@ -43,7 +43,7 @@ QUERY;
} }
else else
{ {
$schedule[] = ['start' => clone $start, 'end' => clone $end, 'program' => new \Model\Program($program)]; $schedule[] = ['id' => $scheduleid, 'start' => clone $start, 'end' => clone $end, 'program' => new \Model\Program($program)];
} }
} }
@@ -146,7 +146,7 @@ QUERY;
if($activeProgram == null || $priority < $activeProgram->priority) { if($activeProgram == null || $priority < $activeProgram->priority) {
if(($activeProgram != null) && ($item[1] > $start)) { if(($activeProgram != null) && ($item[1] > $start)) {
if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$item[1]->format('d-m-Y H:i')}: {$activeProgram->name} (reason: {$item[2]->name} starts).<br/>"; if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$item[1]->format('d-m-Y H:i')}: {$activeProgram->name} (reason: {$item[2]->name} starts).<br/>";
$this->addToSchedule($schedule, $activeProgramStart, $item[1], $activeProgram); $this->addToSchedule($schedule, $activeProgramStart, $item[1], $activeProgram, $item[2]->scheduleid);
} }
$activeProgramStart = ($item[1] < $start) ? $start : clone $item[1]; $activeProgramStart = ($item[1] < $start) ? $start : clone $item[1];
@@ -168,7 +168,7 @@ QUERY;
// In addition, when the ending program was the active program, we need to schedule it and find the new currently active program // In addition, when the ending program was the active program, we need to schedule it and find the new currently active program
if($activeProgram == $item[2]) { if($activeProgram == $item[2]) {
if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$item[1]->format('d-m-Y H:i')}: {$activeProgram->name} {$activeProgram->suffix} (reason: {$item[2]->name} ends).<br/>"; if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$item[1]->format('d-m-Y H:i')}: {$activeProgram->name} {$activeProgram->suffix} (reason: {$item[2]->name} ends).<br/>";
$this->addToSchedule($schedule, $activeProgramStart, $item[1], $activeProgram); $this->addToSchedule($schedule, $activeProgramStart, $item[1], $activeProgram, $item[2]->scheduleid);
$activeProgram = null; $activeProgram = null;
foreach($active as $newPriority => $newActive) { foreach($active as $newPriority => $newActive) {
@@ -188,7 +188,7 @@ QUERY;
if(($activeProgram != null) && ($activeProgramStart != $end)) { if(($activeProgram != null) && ($activeProgramStart != $end)) {
if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$end->format('d-m-Y H:i')}: {$activeProgram->name} {$activeProgram->suffix} (reason: schedule finished).<br/>"; if($DEBUG) print "{$activeProgramStart->format('d-m-Y H:i')} -- {$end->format('d-m-Y H:i')}: {$activeProgram->name} {$activeProgram->suffix} (reason: schedule finished).<br/>";
$this->addToSchedule($schedule, $activeProgramStart, $end, $activeProgram); $this->addToSchedule($schedule, $activeProgramStart, $end, $activeProgram, $activeProgram->scheduleid);
} }
return ['startdate' => $start, 'enddate' => $end, 'schedule' => $schedule]; return ['startdate' => $start, 'enddate' => $end, 'schedule' => $schedule];
@@ -252,6 +252,23 @@ QUERY;
return new \Model\Track($data[0]); return new \Model\Track($data[0]);
} }
private function isStreamEnabled($schedule_id) {
if(!($stream = env('STUDIO_STREAM'))) {
return true;
}
$enableCameraQuery = app('db')->select("SELECT COUNT(*) AS is_enabled FROM `programs_schedule_webcam` WHERE `programs_schedule` = " . (int)$schedule_id);
if($enableCamera = $enableCameraQuery[0]->is_enabled) {
$isStreamDisabled = 1;
$output = [];
exec("ffprobe -v quiet -show_streams '$stream'", $output, $isStreamDisabled);
if(!$isStreamDisabled) {
return true;
}
}
return false;
}
/** /**
* Programmas nu en straks (24 uur vooruit) * Programmas nu en straks (24 uur vooruit)
*/ */
@@ -272,9 +289,10 @@ QUERY;
$current = $next; $current = $next;
} }
return response()->json(['inProgram' => false, 'current' => $current, 'program' => $program]); return response()->json(['inProgram' => false, 'stream' => false, 'current' => $current, 'program' => $program]);
} else { } else {
return response()->json(['inProgram' => true, 'program' => $program]); $canStream = $this->isStreamEnabled($schema['schedule'][0]['id']);
return response()->json(['inProgram' => true, 'stream' => $canStream, 'program' => $program]);
} }
} }