If no device specified, look in /dev/ for video devices and specify them to zmu. Fix use of undefined host var
parent
01ab1c2535
commit
53805079b6
|
@ -27,22 +27,33 @@ if (!canEdit('Monitors')) {
|
|||
function probeV4L() {
|
||||
|
||||
$cameras = array();
|
||||
$monitors = array();
|
||||
foreach ( dbFetchAll("SELECT Id, Name, Device, Channel FROM Monitors WHERE Type = 'Local' ORDER BY Device, Channel" ) as $monitor )
|
||||
$monitors[$monitor['Device'].':'.$monitor['Channel']] = $monitor;
|
||||
$devices = array();
|
||||
$devices_to_probe = array();
|
||||
$preferredStandards = array('PAL', 'NTSC');
|
||||
$preferredFormats = array('BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY');
|
||||
|
||||
if ( !empty($_REQUEST['device']) ) {
|
||||
$devices_to_probe[] = $_REQUEST['device'];
|
||||
} else {
|
||||
$it = new FilesystemIterator('/dev/');
|
||||
foreach ($it as $fileinfo) {
|
||||
if (preg_match('/^video\d+$/', $fileinfo->getFilename())) {
|
||||
$devices_to_probe[] = '/dev/'.$fileinfo->getFilename();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($devices_to_probe as $d) {
|
||||
$command = getZmuCommand(' --query --device');
|
||||
if ( !empty($_REQUEST['device']) )
|
||||
$command .= '='.escapeshellarg($_REQUEST['device']);
|
||||
$command .= '='.escapeshellarg($d);
|
||||
$result = exec(escapeshellcmd($command), $output, $status);
|
||||
if ($status) {
|
||||
ZM\Warning("Errors while probe local cameras using $command, status is '$status' " . implode("\n", $output));
|
||||
}
|
||||
|
||||
$monitors = array();
|
||||
foreach ( dbFetchAll("SELECT Id, Name, Device, Channel FROM Monitors WHERE Type = 'Local' ORDER BY Device, Channel" ) as $monitor )
|
||||
$monitors[$monitor['Device'].':'.$monitor['Channel']] = $monitor;
|
||||
|
||||
$devices = array();
|
||||
$preferredStandards = array('PAL', 'NTSC');
|
||||
$preferredFormats = array('BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY');
|
||||
foreach ( $output as $line ) {
|
||||
if ( !preg_match('/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches) ) {
|
||||
ZM\Error("Can't parse command output '$line'");
|
||||
|
@ -112,6 +123,7 @@ function probeV4L() {
|
|||
$device['inputs'] = $inputs;
|
||||
$devices[] = $device;
|
||||
} # end foreach output line
|
||||
} # end foreach device in /dev
|
||||
return $cameras;
|
||||
} # end function probeV4L
|
||||
|
||||
|
@ -347,7 +359,7 @@ function probeNetwork() {
|
|||
$macBase = $macBases[$macRoot];
|
||||
$camera = call_user_func($macBase['probeFunc'], $ip);
|
||||
$sourceDesc = base64_encode(json_encode($camera['monitor']));
|
||||
$sourceString = $camera['model'].' @ '.$host;
|
||||
$sourceString = $camera['model'].' @ '.$ip;
|
||||
if ( isset($monitors[$ip]) ) {
|
||||
$monitor = $monitors[$ip];
|
||||
$sourceString .= ' ('.$monitor['Name'].')';
|
||||
|
@ -370,7 +382,7 @@ function probeNetwork() {
|
|||
$macBase = $macBases[$macRoot];
|
||||
$camera = call_user_func($macBase['probeFunc'], $ip);
|
||||
$sourceDesc = base64_encode(json_encode($camera['monitor']));
|
||||
$sourceString = $camera['model'].' @ '.$host;
|
||||
$sourceString = $camera['model'].' @ '.$ip;
|
||||
if (isset($monitors[$ip])) {
|
||||
$monitor = $monitors[$ip];
|
||||
$sourceString .= ' ('.$monitor['Name'].')';
|
||||
|
|
Loading…
Reference in New Issue