Skip to content

Commit

Permalink
Fixed if the first video device is unusable (or blacklisted)
Browse files Browse the repository at this point in the history
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
  • Loading branch information
yarda committed Mar 17, 2020
1 parent 811090b commit 71f98ae
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,34 @@
</div>

<div id="cameras">
<a href="./?camera=<?php echo $camera . ($fullscreen ? "" : "&fullscreen") ?>">
<img data-src="camera.php?id=<?php echo $camera ?>&amp;full" id="mainCamera" class="camera">
</a>
<?php
if (!$fullscreen) {
foreach (array_diff(glob($video_dev_pref."*"), $video_dev_blacklist) as $filename) {
if (!exec("v4l-info ".escapeshellarg($filename)." 2>&1 1>/dev/null")) {
$cameras[substr($filename, strlen($video_dev_pref), 100)] = TRUE;
}
}
if (!array_key_exists(strval($camera), $cameras)) {
$first_cam = array_key_first($cameras);
if ($first_cam != NULL) {
$camera = intval($first_cam);
}
}
}
?>
<a href="./?camera=<?php echo $camera . ($fullscreen ? "" : "&fullscreen") ?>">
<img data-src="camera.php?id=<?php echo $camera ?>&amp;full" id="mainCamera" class="camera">
</a>
<?php
unset($cameras[$camera]);
?>
?>
<div class="othercameras">
<?php foreach($cameras as $c => $_) { ?>
<a href="./?camera=<?php echo $c ?>">
<img data-src="camera.php?id=<?php echo $c ?>" class="camera">
</a>
<?php } ?>
</div>
<?php } ?>
</div>

<script>
Expand Down

0 comments on commit 71f98ae

Please sign in to comment.