Added monitor probe facility
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2829 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
f5d7391e72
commit
62503acd16
|
@ -120,13 +120,14 @@ $SLANG = array(
|
|||
'Auto' => 'Auto',
|
||||
'AutoStopTimeout' => 'Auto Stop Timeout',
|
||||
'AvgBrScore' => 'Avg.<br/>Score',
|
||||
'Available' => 'Available',
|
||||
'Background' => 'Background',
|
||||
'BackgroundFilter' => 'Run filter in background',
|
||||
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
|
||||
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
|
||||
'BadChannel' => 'Channel must be set to an integer of zero or more',
|
||||
'BadDevice' => 'Device must be set to a valid value',
|
||||
'BadFormat' => 'Format must be set to an integer of zero or more',
|
||||
'BadFormat' => 'Format must be set to a valid value',
|
||||
'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 100 or more',
|
||||
'BadFrameSkip' => 'Frame skip count must be an integer of zero or more',
|
||||
'BadHeight' => 'Height must be set to a valid value',
|
||||
|
@ -136,6 +137,7 @@ $SLANG = array(
|
|||
'BadLabelY' => 'Label Y co-ordinate must be set to an integer of zero or more',
|
||||
'BadMaxFPS' => 'Maximum FPS must be a positive integer or floating point value',
|
||||
'BadNameChars' => 'Names may only contain alphanumeric characters plus hyphen and underscore',
|
||||
'BadPalette' => 'Palette must be set to a valid value',
|
||||
'BadPath' => 'Path must be set to a valid value',
|
||||
'BadPort' => 'Port must be set to a valid number',
|
||||
'BadPostEventCount' => 'Post event image count must be an integer of zero or more',
|
||||
|
@ -200,6 +202,7 @@ $SLANG = array(
|
|||
'Cause' => 'Cause',
|
||||
'Layout' => 'Layout',
|
||||
'CheckMethod' => 'Alarm Check Method',
|
||||
'ChooseDetectedCamera' => 'Choose Detected Camera',
|
||||
'ChooseFilter' => 'Choose Filter',
|
||||
'ChoosePreset' => 'Choose Preset',
|
||||
'Close' => 'Close',
|
||||
|
@ -234,6 +237,7 @@ $SLANG = array(
|
|||
'Delete' => 'Delete',
|
||||
'DeleteSavedFilter' => 'Delete saved filter',
|
||||
'Description' => 'Description',
|
||||
'DetectedCameras' => 'Detected Cameras',
|
||||
'DeviceChannel' => 'Device Channel',
|
||||
'DeviceFormat' => 'Device Format',
|
||||
'DeviceNumber' => 'Device Number',
|
||||
|
@ -253,6 +257,7 @@ $SLANG = array(
|
|||
'DonateRemindWeek' => 'Not yet, remind again in 1 week',
|
||||
'DonateYes' => 'Yes, I\'d like to donate now',
|
||||
'Download' => 'Download',
|
||||
'DuplicateMonitorName' => 'Duplicate Monitor Name',
|
||||
'Duration' => 'Duration',
|
||||
'Edit' => 'Edit',
|
||||
'Email' => 'Email',
|
||||
|
@ -432,8 +437,10 @@ $SLANG = array(
|
|||
'Misc' => 'Misc',
|
||||
'MonitorIds' => 'Monitor Ids',
|
||||
'Monitor' => 'Monitor',
|
||||
'MonitorPresetIntro' => 'Select an appropriate preset from the list below.<br/><br/>Please note that this may overwrite any values you already have configured for this monitor.<br/><br/>',
|
||||
'MonitorPresetIntro' => 'Select an appropriate preset from the list below.<br/><br/>Please note that this may overwrite any values you already have configured for the current monitor.<br/><br/>',
|
||||
'MonitorPreset' => 'Monitor Preset',
|
||||
'MonitorProbeIntro' => 'The list below shows detected analog and network cameras and whether they are already being used or available for selection.<br/><br/>Select the desired entry from the list below.<br/><br/>Please note that not all cameras may be detected and that choosing a camera here may overwrite any values you already have configured for the current monitor.<br/><br/>',
|
||||
'MonitorProbe' => 'Monitor Probe',
|
||||
'Monitors' => 'Monitors',
|
||||
'Montage' => 'Montage',
|
||||
'Month' => 'Month',
|
||||
|
@ -453,6 +460,7 @@ $SLANG = array(
|
|||
'NewState' => 'New State',
|
||||
'NewUser' => 'New User',
|
||||
'Next' => 'Next',
|
||||
'NoDetectedCameras' => 'No Detected Cameras',
|
||||
'NoFramesRecorded' => 'There are no frames recorded for this event',
|
||||
'NoGroup' => 'No Group',
|
||||
'NoneAvailable' => 'None available',
|
||||
|
@ -508,6 +516,7 @@ $SLANG = array(
|
|||
'Preset' => 'Preset',
|
||||
'Presets' => 'Presets',
|
||||
'Prev' => 'Prev',
|
||||
'Probe' => 'Probe',
|
||||
'Protocol' => 'Protocol',
|
||||
'Rate' => 'Rate',
|
||||
'Real' => 'Real',
|
||||
|
|
|
@ -62,6 +62,7 @@ var popupSizes = {
|
|||
'logout': { 'width': 240, 'height': 100 },
|
||||
'monitor': { 'width': 380, 'height': 364 },
|
||||
'monitorpreset':{ 'width': 400, 'height': 200 },
|
||||
'monitorprobe': { 'width': 500, 'height': 240 },
|
||||
'monitorselect':{ 'width': 160, 'height': 200 },
|
||||
'montage': { 'width': -1, 'height': -1 },
|
||||
'optionhelp': { 'width': 320, 'height': 330 },
|
||||
|
|
|
@ -35,6 +35,7 @@ dist_web_DATA = \
|
|||
Makefile.am \
|
||||
monitor.php \
|
||||
monitorpreset.php \
|
||||
monitorprobe.php \
|
||||
montage.php \
|
||||
none.php \
|
||||
optionhelp.php \
|
||||
|
|
|
@ -27,6 +27,7 @@ dist_web_DATA = \
|
|||
monitor.js \
|
||||
monitor.js.php \
|
||||
monitorpreset.js \
|
||||
monitorprobe.js \
|
||||
montage.js \
|
||||
montage.js.php \
|
||||
options.js.php \
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
function submitCamera( element )
|
||||
{
|
||||
var form = element.form;
|
||||
form.target = opener.name;
|
||||
form.view.value = 'monitor';
|
||||
form.submit();
|
||||
closeWindow.delay( 250 );
|
||||
}
|
||||
|
||||
function configureButtons( element )
|
||||
{
|
||||
var form = element.form;
|
||||
form.saveBtn.disabled = (form.probe.selectedIndex==0);
|
||||
}
|
|
@ -113,6 +113,11 @@ if ( ZM_OPT_X10 && empty($x10Monitor) )
|
|||
);
|
||||
}
|
||||
|
||||
function fourcc( $a, $b, $c, $d )
|
||||
{
|
||||
return( ord($a) | (ord($b) << 8) | (ord($c) << 16) | (ord($d) << 24) );
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['newMonitor'] ) )
|
||||
{
|
||||
$newMonitor = $_REQUEST['newMonitor'];
|
||||
|
@ -143,6 +148,27 @@ if ( !empty($_REQUEST['preset']) )
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( !empty($_REQUEST['probe']) )
|
||||
{
|
||||
$probe = unserialize( $_REQUEST['probe'] );
|
||||
foreach ( $probe as $name=>$value )
|
||||
{
|
||||
if ( isset($value) )
|
||||
{
|
||||
$newMonitor[$name] = $value;
|
||||
}
|
||||
}
|
||||
if ( $newMonitor['Type'] == 'Local' )
|
||||
{
|
||||
$newMonitor['Palette'] = fourCC( substr($newMonitor['Palette'],0,1), substr($newMonitor['Palette'],1,1), substr($newMonitor['Palette'],2,1), substr($newMonitor['Palette'],3,1) );
|
||||
if ( $newMonitor['Format'] == 'PAL' )
|
||||
$newMonitor['Format'] = 0x000000ff;
|
||||
elseif ( $newMonitor['Format'] == 'NTSC' )
|
||||
$newMonitor['Format'] = 0x0000b000;
|
||||
else
|
||||
$newMonitor['Format'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$sourceTypes = array(
|
||||
'Local' => $SLANG['Local'],
|
||||
|
@ -248,11 +274,6 @@ if ( ZM_V4L2 )
|
|||
for ( $i = 0; $i <= $v4l2MaxChannels; $i++ )
|
||||
$v4l2DeviceChannels["$i"] = $i;
|
||||
|
||||
function fourcc( $a, $b, $c, $d )
|
||||
{
|
||||
return( ord($a) | (ord($b) << 8) | (ord($c) << 16) | (ord($d) << 24) );
|
||||
}
|
||||
|
||||
$v4l2LocalPalettes = array(
|
||||
$SLANG['Undefined'] => '',
|
||||
|
||||
|
@ -344,6 +365,7 @@ if ( canEdit( 'Monitors' ) )
|
|||
{
|
||||
?>
|
||||
<div id="headerButtons">
|
||||
<a href="#" onclick="createPopup( '?view=monitorprobe&mid=<?= $monitor['Id'] ?>', 'zmMonitorProbe<?= $monitor['Id'] ?>', 'monitorprobe' ); return( false );"><?= $SLANG['Probe'] ?></a>
|
||||
<a href="#" onclick="createPopup( '?view=monitorpreset&mid=<?= $monitor['Id'] ?>', 'zmMonitorPreset<?= $monitor['Id'] ?>', 'monitorpreset' ); return( false );"><?= $SLANG['Presets'] ?></a>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -407,7 +429,6 @@ if ( $tab != 'source' || $newMonitor['Type'] != 'Local' )
|
|||
<input type="hidden" name="newMonitor[Device]" value="<?= validHtmlStr($newMonitor['Device']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Channel]" value="<?= validHtmlStr($newMonitor['Channel']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Format]" value="<?= validHtmlStr($newMonitor['Format']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Palette]" value="<?= validHtmlStr($newMonitor['Palette']) ?>"/>
|
||||
<?php
|
||||
}
|
||||
if ( $tab != 'source' || $newMonitor['Type'] != 'Remote' )
|
||||
|
@ -434,6 +455,7 @@ if ( $tab != 'source' || ($newMonitor['Type'] != 'Remote' && $newMonitor['Type']
|
|||
if ( $tab != 'source' )
|
||||
{
|
||||
?>
|
||||
<input type="hidden" name="newMonitor[Palette]" value="<?= validHtmlStr($newMonitor['Palette']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Width]" value="<?= validHtmlStr($newMonitor['Width']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Height]" value="<?= validHtmlStr($newMonitor['Height']) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Orientation]" value="<?= validHtmlStr($newMonitor['Orientation']) ?>"/>
|
||||
|
|
|
@ -0,0 +1,280 @@
|
|||
<?php
|
||||
//
|
||||
// ZoneMinder web monitor probe view file, $Date: 2008-09-26 10:47:20 +0100 (Fri, 26 Sep 2008) $, $Revision: 2632 $
|
||||
// Copyright (C) 2001-2008 Philip Coombes
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
|
||||
if ( !canEdit( 'Monitors' ) )
|
||||
{
|
||||
$view = "error";
|
||||
return;
|
||||
}
|
||||
|
||||
$cameras = array();
|
||||
$cameras[0] = $SLANG['ChooseDetectedCamera'];
|
||||
|
||||
if ( ZM_V4L2 )
|
||||
{
|
||||
// Probe Local Cameras
|
||||
//
|
||||
$command = getZmuCommand( " --query --device" );
|
||||
if ( !empty($_REQUEST['device']) )
|
||||
$command .= "=".escapeshellarg($_REQUEST['device']);
|
||||
|
||||
$result = exec( escapeshellcmd($command), $output, $status );
|
||||
if ( $status )
|
||||
die( "Unable to probe local cameras, status is '$status'" );
|
||||
|
||||
$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( '422P', 'YUYV', 'BGR3' );
|
||||
foreach ( $output as $line )
|
||||
{
|
||||
if ( !preg_match( '/^d:([^|]+).*S:([^|]+).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) )
|
||||
die( "Can't parse command output '$line'" );
|
||||
$standards = split('/',$deviceMatches[2]);
|
||||
$preferredStandard = false;
|
||||
foreach ( $preferredStandards as $standard )
|
||||
{
|
||||
if ( in_array( $standard, $standards ) )
|
||||
{
|
||||
$preferredStandard = $standard;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$formats = split('/',$deviceMatches[3]);
|
||||
$preferredFormat = false;
|
||||
foreach ( $preferredFormats as $format )
|
||||
{
|
||||
if ( in_array( $format, $formats ) )
|
||||
{
|
||||
$preferredFormat = $format;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$device = array( 'device'=>$deviceMatches[1], 'standards'=>$standard, 'preferredStandard'=>$preferredStandard, 'formats'=>$formats, 'preferredFormat'=>$preferredFormat );
|
||||
$inputs = array();
|
||||
for ( $i = 0; $i < $deviceMatches[4]; $i++ )
|
||||
{
|
||||
if ( !preg_match( '/i'.$i.':([^|]+)\|i'.$i.'T:([^|]+)\|/', $deviceMatches[5], $inputMatches ) )
|
||||
die( "Can't parse input '".$deviceMatches[5]."'" );
|
||||
if ( $inputMatches[2] == 'Camera' )
|
||||
{
|
||||
$input = array( 'index'=>$i, 'id'=>$deviceMatches[1].':'.$i, 'name'=>$inputMatches[1], 'free'=>empty($monitors[$deviceMatches[1].':'.$i]) );
|
||||
$inputMonitor = array(
|
||||
'Type' => 'Local',
|
||||
'Device' => $deviceMatches[1],
|
||||
'Channel' => $i,
|
||||
'Format' => $preferredStandard,
|
||||
'Palette' => $preferredFormat,
|
||||
);
|
||||
if ( $preferredStandard == 'NTSC' )
|
||||
{
|
||||
$inputMonitor['Width'] = 320;
|
||||
$inputMonitor['Height'] = 240;
|
||||
}
|
||||
else
|
||||
{
|
||||
$inputMonitor['Width'] = 352;
|
||||
$inputMonitor['Height'] = 288;
|
||||
}
|
||||
$inputDesc = htmlspecialchars(serialize($inputMonitor));
|
||||
$inputString = $deviceMatches[1].', chan '.$i.($input['free']?(" - ".$SLANG['Available']):(" (".$monitors[$input['id']]['Name'].")"));
|
||||
$inputs[] = $input;
|
||||
$cameras[$inputDesc] = $inputString;
|
||||
}
|
||||
}
|
||||
$device['inputs'] = $inputs;
|
||||
$devices[] = $device;
|
||||
}
|
||||
}
|
||||
|
||||
// Probe Network Cameras
|
||||
//
|
||||
function probeAxis( $ip )
|
||||
{
|
||||
$url = 'http://'.$ip.'/axis-cgi/admin/param.cgi?action=list&group=Brand';
|
||||
$camera = array(
|
||||
'model' => "Unknown Axis Camera",
|
||||
'monitor' => array(
|
||||
'Type' => 'Remote',
|
||||
'Protocol' => 'http',
|
||||
'Host' => $ip,
|
||||
'Port' => 80,
|
||||
'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240',
|
||||
'SubPath' => '',
|
||||
'Palette' => 3,
|
||||
'Width' => 320,
|
||||
'Height' => 240,
|
||||
),
|
||||
);
|
||||
if ( $lines = @file( $url ) )
|
||||
{
|
||||
foreach ( $lines as $line )
|
||||
{
|
||||
$line = rtrim( $line );
|
||||
if ( preg_match( '/^(.+)=(.+)$/', $line, $matches ) )
|
||||
{
|
||||
if ( $matches[1] == 'root.Brand.ProdShortName' )
|
||||
{
|
||||
$camera['model'] = $matches[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return( $camera );
|
||||
}
|
||||
|
||||
function probePana( $ip )
|
||||
{
|
||||
$url = 'http://'.$ip.'/Get?Func=Model&Kind=1';
|
||||
$camera = array(
|
||||
'model' => "Unknown Panasonic Camera",
|
||||
'monitor' => array(
|
||||
'Type' => 'Remote',
|
||||
'Protocol' => 'http',
|
||||
'Host' => $ip,
|
||||
'Port' => 80,
|
||||
'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard',
|
||||
'SubPath' => '',
|
||||
'Palette' => 3,
|
||||
'Width' => 320,
|
||||
'Height' => 240,
|
||||
),
|
||||
);
|
||||
return( $camera );
|
||||
}
|
||||
|
||||
function probeActi( $ip )
|
||||
{
|
||||
$url = 'http://'.$ip.'/cgi-bin/system?USER=Admin&PWD=123456&SYSTEM_INFO';
|
||||
$camera = array(
|
||||
'model' => "Unknown Panasonic Camera",
|
||||
'monitor' => array(
|
||||
'Type' => 'Remote',
|
||||
'Protocol' => 'rtsp',
|
||||
'Method' => 'rtpUni',
|
||||
'Host' => 'Admin:123456@'.$ip,
|
||||
'Port' => 7070,
|
||||
'Path' => '',
|
||||
'SubPath' => '/track',
|
||||
'Palette' => 3,
|
||||
'Width' => 320,
|
||||
'Height' => 240,
|
||||
),
|
||||
);
|
||||
if ( $lines = @file( $url ) )
|
||||
{
|
||||
foreach ( $lines as $line )
|
||||
{
|
||||
$line = rtrim( $line );
|
||||
if ( preg_match( '/^(.+?)\s*=\s*(.+)$/', $line, $matches ) )
|
||||
{
|
||||
if ( $matches[1] == 'Production ID' )
|
||||
{
|
||||
$camera['model'] = "ACTi ".substr( $matches[2], 0, strpos( $matches[2], '-' ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return( $camera );
|
||||
}
|
||||
|
||||
$monitors = array();
|
||||
foreach ( dbFetchAll( "select Id, Name, Host from Monitors where Type = 'Remote' or Type = 'Ffmpeg' order by Host" ) as $monitor )
|
||||
if ( preg_match( '/^(.+)@(.+)$/', $monitor['Host'], $matches ) )
|
||||
$monitors[gethostbyname($matches[2])] = $monitor;
|
||||
else
|
||||
$monitors[gethostbyname($monitor['Host'])] = $monitor;
|
||||
|
||||
$macBases = array(
|
||||
'00:40:8c' => array( 'type'=>'Axis', 'probeFunc'=>'probeAxis' ),
|
||||
'00:80:f0' => array( 'type'=>'Panasonic','probeFunc'=>'probePana' ),
|
||||
'00:0f:7c' => array( 'type'=>'ACTi','probeFunc'=>'probeACTi' ),
|
||||
);
|
||||
|
||||
unset($output);
|
||||
$command = "arp -a";
|
||||
$result = exec( escapeshellcmd($command), $output, $status );
|
||||
if ( $status )
|
||||
die( "Unable to probe network cameras, status is '$status'" );
|
||||
foreach ( $output as $line )
|
||||
{
|
||||
if ( !preg_match( '/^(\S+) \(([\d.]+)\) at ([0-9a-f:]+)/', $line, $matches ) )
|
||||
die( "Can't parse command output '$line'" );
|
||||
$host = $matches[1];
|
||||
$ip = $matches[2];
|
||||
if ( !$host || $host == '?' )
|
||||
$host = $ip;
|
||||
$mac = $matches[3];
|
||||
//echo "I:$ip, H:$host, M:$mac<br/>";
|
||||
$macRoot = substr($mac,0,8);
|
||||
if ( isset($macBases[$macRoot]) )
|
||||
{
|
||||
$macBase = $macBases[$macRoot];
|
||||
$camera = call_user_func( $macBase['probeFunc'], $ip );
|
||||
$sourceDesc = htmlspecialchars(serialize($camera['monitor']));
|
||||
$sourceString = $camera['model'].' @ '.$host;
|
||||
if ( isset($monitors[$ip]) )
|
||||
{
|
||||
$monitor = $monitors[$ip];
|
||||
$sourceString .= " (".$monitor['Name'].")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sourceString .= " - ".$SLANG['Available'];
|
||||
}
|
||||
$cameras[$sourceDesc] = $sourceString;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($cameras) <= 0 )
|
||||
$cameras[0] = $SLANG['NoDetectedCameras'];
|
||||
|
||||
$focusWindow = true;
|
||||
|
||||
xhtmlHeaders(__FILE__, $SLANG['MonitorProbe'] );
|
||||
?>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
<h2><?= $SLANG['MonitorProbe'] ?></h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<form name="contentForm" id="contentForm" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
|
||||
<input type="hidden" name="view" value="none"/>
|
||||
<input type="hidden" name="mid" value="<?= validNum($_REQUEST['mid']) ?>"/>
|
||||
<p>
|
||||
<?= $SLANG['MonitorProbeIntro'] ?>
|
||||
</p>
|
||||
<p>
|
||||
<label for="probe"><?= $SLANG['DetectedCameras'] ?></label><?= buildSelect( "probe", $cameras, 'configureButtons( this )' ); ?>
|
||||
</p>
|
||||
<div id="contentButtons">
|
||||
<input type="submit" name="saveBtn" value="<?= $SLANG['Save'] ?>" onclick="submitCamera( this )" disabled="disabled"/><input type="button" value="<?= $SLANG['Cancel'] ?>" onclick="closeWindow()"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue