From 41405e1115c681dbf7de3f4eee7955320a85d3d2 Mon Sep 17 00:00:00 2001 From: jaidhar Date: Fri, 5 Nov 2010 23:41:09 +0000 Subject: [PATCH] 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 --- web/skins/xml/includes/config.php | 2 ++ web/skins/xml/includes/functions.php | 6 +++- web/skins/xml/views/actions.php | 50 ++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/web/skins/xml/includes/config.php b/web/skins/xml/includes/config.php index 79d40e273..6c9c9c2c5 100644 --- a/web/skins/xml/includes/config.php +++ b/web/skins/xml/includes/config.php @@ -20,6 +20,8 @@ define ( "XML_PROTOCOL_VERSION", "2"); define ( "XML_FEATURE_SET", "1"); +define ( "XML_EVENT_FPS", "10"); +define ( "XML_EVENT_VCODEC", "mpeg4"); $rates = array( "10000" => "100x", diff --git a/web/skins/xml/includes/functions.php b/web/skins/xml/includes/functions.php index f6a8e34a8..82207eda5 100644 --- a/web/skins/xml/includes/functions.php +++ b/web/skins/xml/includes/functions.php @@ -1,5 +1,9 @@ */ if (!canEdit('Events')) { error_log("User ".$user['Username']. " doesn't have edit Events perms"); exit; @@ -16,8 +16,9 @@ if (isset($_GET['action'])) { $url = "./index.php?view=request&request=event&id=".$eid."&action=delete"; header("Location: ".$url); exit; + } else if (strcmp($action, "feed") == 0) { - /* ACTION: View a feed */ + /* ACTION: View a feed. Parms: [fps|scale] */ if (!canView('Stream')) { error_log("User ".$user['Username']. " doesn't have view Stream perms"); exit; @@ -49,24 +50,50 @@ if (isset($_GET['action'])) { outputImageStream("liveStream", $streamSrc, $width, $height, "stream"); echo ""; exit; + } else if (strcmp($action, "vevent") == 0) { - /* ACTION: View an event */ + /* ACTION: View an event. Parms: [fps|vcodec] */ if (!canView('Events')) { error_log("User ".$user['Username']. " doesn't have view Events perms"); 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"); exit; } - $baseURL = trim(shell_exec('pwd'))."/events/".$_REQUEST['mid']."/".$_REQUEST['eid']."/"; - $relativeURL = "./events/".$_REQUEST['mid']."/".$_REQUEST['eid']."/"; - $shellCmd = "ffmpeg -y -r ".$_REQUEST['fps']." -i ".$baseURL."%03d-capture.jpg -vcodec mpeg4 -r 10 ".$baseURL."capture.mov 2> /dev/null"; - shell_exec("rm -f ".$baseURL."capture.mov"); + /* Grab event from the database */ + $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) { + } + /* 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); - 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: */ + 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) { - /* ACTION: Change the state of the system */ + /* ACTION: Change the state of the system. Parms: */ if (!canEdit('System')) { error_log("User ".$user['Username']. " doesn't have edit System perms"); exit; @@ -78,8 +105,9 @@ if (isset($_GET['action'])) { $url = "./index.php?view=none&action=state&runState=".$_GET['state']; header("Location: ".$url); exit; + } else if (strcmp($action, "func") == 0) { - /* ACTION: Change state of the monitor */ + /* ACTION: Change state of the monitor. Parms: */ if (!canEdit('Monitors')) { error_log("User ".$user['Username']. " doesn't have monitors Edit perms"); exit;