XML Plugin: Added vframe action, some more defines, condensed vevent parameter requirements
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3177 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
1c7086dc39
commit
41405e1115
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
define ( "XML_PROTOCOL_VERSION", "2");
|
define ( "XML_PROTOCOL_VERSION", "2");
|
||||||
define ( "XML_FEATURE_SET", "1");
|
define ( "XML_FEATURE_SET", "1");
|
||||||
|
define ( "XML_EVENT_FPS", "10");
|
||||||
|
define ( "XML_EVENT_VCODEC", "mpeg4");
|
||||||
|
|
||||||
$rates = array(
|
$rates = array(
|
||||||
"10000" => "100x",
|
"10000" => "100x",
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
function getset($varname, $defval)
|
||||||
|
{
|
||||||
|
if (isset($_GET[$varname])) return $_GET[$varname];
|
||||||
|
return $defval;
|
||||||
|
}
|
||||||
function xml_header()
|
function xml_header()
|
||||||
{
|
{
|
||||||
header ("content-type: text/xml");
|
header ("content-type: text/xml");
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
if (isset($_GET['action'])) {
|
if (isset($_GET['action'])) {
|
||||||
$action = $_GET['action'];
|
$action = $_GET['action'];
|
||||||
if (strcmp($action, "devent") == 0) {
|
if (strcmp($action, "devent") == 0) {
|
||||||
/* ACTION: Delete an Event */
|
/* ACTION: Delete an Event. Parms: <eid> */
|
||||||
if (!canEdit('Events')) {
|
if (!canEdit('Events')) {
|
||||||
error_log("User ".$user['Username']. " doesn't have edit Events perms");
|
error_log("User ".$user['Username']. " doesn't have edit Events perms");
|
||||||
exit;
|
exit;
|
||||||
|
@ -16,8 +16,9 @@ if (isset($_GET['action'])) {
|
||||||
$url = "./index.php?view=request&request=event&id=".$eid."&action=delete";
|
$url = "./index.php?view=request&request=event&id=".$eid."&action=delete";
|
||||||
header("Location: ".$url);
|
header("Location: ".$url);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} else if (strcmp($action, "feed") == 0) {
|
} else if (strcmp($action, "feed") == 0) {
|
||||||
/* ACTION: View a feed */
|
/* ACTION: View a feed. Parms: <monitor><img. width><img. height> [fps|scale] */
|
||||||
if (!canView('Stream')) {
|
if (!canView('Stream')) {
|
||||||
error_log("User ".$user['Username']. " doesn't have view Stream perms");
|
error_log("User ".$user['Username']. " doesn't have view Stream perms");
|
||||||
exit;
|
exit;
|
||||||
|
@ -49,24 +50,50 @@ if (isset($_GET['action'])) {
|
||||||
outputImageStream("liveStream", $streamSrc, $width, $height, "stream");
|
outputImageStream("liveStream", $streamSrc, $width, $height, "stream");
|
||||||
echo "</div></body></html>";
|
echo "</div></body></html>";
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} else if (strcmp($action, "vevent") == 0) {
|
} else if (strcmp($action, "vevent") == 0) {
|
||||||
/* ACTION: View an event */
|
/* ACTION: View an event. Parms: <eid> [fps|vcodec] */
|
||||||
if (!canView('Events')) {
|
if (!canView('Events')) {
|
||||||
error_log("User ".$user['Username']. " doesn't have view Events perms");
|
error_log("User ".$user['Username']. " doesn't have view Events perms");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (!isset($_GET['mid']) || !isset($_GET['eid']) || !isset($_GET['fps'])) {
|
if (!isset($_GET['eid'])) {
|
||||||
error_log("Not all parameters set for Action View-event");
|
error_log("Not all parameters set for Action View-event");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$baseURL = trim(shell_exec('pwd'))."/events/".$_REQUEST['mid']."/".$_REQUEST['eid']."/";
|
/* Grab event from the database */
|
||||||
$relativeURL = "./events/".$_REQUEST['mid']."/".$_REQUEST['eid']."/";
|
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where (E.Id = ".$_GET['eid'].")";
|
||||||
$shellCmd = "ffmpeg -y -r ".$_REQUEST['fps']." -i ".$baseURL."%03d-capture.jpg -vcodec mpeg4 -r 10 ".$baseURL."capture.mov 2> /dev/null";
|
foreach (dbFetchAll($eventsSql) as $event) {
|
||||||
shell_exec("rm -f ".$baseURL."capture.mov");
|
}
|
||||||
|
/* Calculate FPS */
|
||||||
|
$fps = getset('fps',ceil($event['Frames'] / $event['Length']));
|
||||||
|
$vcodec = getset('vcodec', XML_EVENT_VCODEC);
|
||||||
|
$relativeURL = getEventPath($event);
|
||||||
|
$baseURL = ZM_PATH_WEB."/".ZM_DIR_EVENTS."/".getEventPath($event);
|
||||||
|
$shellCmd = "ffmpeg -y -r ".$fps." -i ".$baseURL."/%03d-capture.jpg -vcodec ".$vcodec." -r ".XML_EVENT_FPS." ".$baseURL."/capture.mov 2> /dev/null";
|
||||||
$shellOutput = shell_exec($shellCmd);
|
$shellOutput = shell_exec($shellCmd);
|
||||||
header("Location: ".$relativeURL."capture.mov");
|
$url = "./".ZM_DIR_EVENTS."/".getEventPath($event)."/capture.mov";
|
||||||
|
header("Location: ".$url);
|
||||||
|
exit;
|
||||||
|
|
||||||
|
} else if (strcmp($action, "vframe") == 0) {
|
||||||
|
/* ACTION: View a frame given by an event and frame-id. Parms: <eid><frame> */
|
||||||
|
if (!isset($_GET['eid']) || !isset($_GET['frame'])) {
|
||||||
|
error_log("Not all parameters set for action view-frame");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$eid = $_GET['eid'];
|
||||||
|
$frame = $_GET['frame'];
|
||||||
|
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where (E.Id = ".$_GET['eid'].")";
|
||||||
|
foreach (dbFetchAll($eventsSql) as $event) {
|
||||||
|
}
|
||||||
|
$fname = sprintf("%03d-capture.jpg", $frame);
|
||||||
|
$url = "./".ZM_DIR_EVENTS."/".getEventPath($event)."/".$fname;
|
||||||
|
header("Location: ".$url);
|
||||||
|
exit;
|
||||||
|
|
||||||
} else if (strcmp($action, "state") == 0) {
|
} else if (strcmp($action, "state") == 0) {
|
||||||
/* ACTION: Change the state of the system */
|
/* ACTION: Change the state of the system. Parms: <state> */
|
||||||
if (!canEdit('System')) {
|
if (!canEdit('System')) {
|
||||||
error_log("User ".$user['Username']. " doesn't have edit System perms");
|
error_log("User ".$user['Username']. " doesn't have edit System perms");
|
||||||
exit;
|
exit;
|
||||||
|
@ -78,8 +105,9 @@ if (isset($_GET['action'])) {
|
||||||
$url = "./index.php?view=none&action=state&runState=".$_GET['state'];
|
$url = "./index.php?view=none&action=state&runState=".$_GET['state'];
|
||||||
header("Location: ".$url);
|
header("Location: ".$url);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} else if (strcmp($action, "func") == 0) {
|
} else if (strcmp($action, "func") == 0) {
|
||||||
/* ACTION: Change state of the monitor */
|
/* ACTION: Change state of the monitor. Parms: <mid><func><en> */
|
||||||
if (!canEdit('Monitors')) {
|
if (!canEdit('Monitors')) {
|
||||||
error_log("User ".$user['Username']. " doesn't have monitors Edit perms");
|
error_log("User ".$user['Username']. " doesn't have monitors Edit perms");
|
||||||
exit;
|
exit;
|
||||||
|
|
Loading…
Reference in New Issue