Remove the XML skin folder
This commit is contained in:
parent
e6d57da0d4
commit
7c7d7b245c
|
@ -1,155 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* config.php is created by Jai Dhar, FPS-Tech, for use with eyeZm
|
||||
* iPhone application. This is not intended for use with any other applications,
|
||||
* although source-code is provided under GPL.
|
||||
*
|
||||
* For questions, please email jdhar@eyezm.com (http://www.eyezm.com)
|
||||
*
|
||||
*/
|
||||
|
||||
/* Static defines, these shouldn't change */
|
||||
define ( "ZM_EYEZM_PROTOCOL_VERSION", "2");
|
||||
define ( "ZM_EYEZM_FEATURE_SET", "3");
|
||||
|
||||
/* Dynamic defines, check if they are already defined.
|
||||
* To change a particular parameter default value, without using the
|
||||
* Options Console, change the 2nd parameter of the define() block. */
|
||||
|
||||
/* Parm: ZM_EYEZM_EVENT_FPS: Sets the default FPS of the output videos for events */
|
||||
if (!defined("ZM_EYEZM_EVENT_FPS")) define ( "ZM_EYEZM_EVENT_FPS", "10");
|
||||
/* Parm: ZM_EYEZM_EVENT_VCODEC: Default video codec for generating event video. Can be mpeg4 or h264 */
|
||||
if (!defined("ZM_EYEZM_EVENT_VCODEC")) define ( "ZM_EYEZM_EVENT_VCODEC", "mpeg4");
|
||||
/* Parm: ZM_EYEZM_FEED_VCODEC: Default video codec of live feeds. Can be mjpeg or h264 */
|
||||
if (!defined("ZM_EYEZM_FEED_VCODEC")) define ( "ZM_EYEZM_FEED_VCODEC", "mjpeg");
|
||||
/* Parm: ZM_EYEZM_SEG_DURATION: H264 Live-streaming segment duration in seconds.
|
||||
* Increase to improve feed smooth-ness, but will increase feed latency */
|
||||
if (!defined("ZM_EYEZM_SEG_DURATION")) define ( "ZM_EYEZM_SEG_DURATION", "3");
|
||||
/* Parm: ZM_EYEZM_DEBUG: Set to 1 to enable XML Debugging */
|
||||
if (!defined("ZM_EYEZM_DEBUG")) define ( "ZM_EYEZM_DEBUG", "0" );
|
||||
/* Parm: ZM_EYEZM_H264_MAX_DURATION: Maximum duration in seconds allowed for viewing H264 Streams.
|
||||
* This is useful for systems that crash or stall when viewing H264 streams. After the timeout
|
||||
* expires, the H264 stream will be killed if it has not by the user already */
|
||||
if (!defined("ZM_EYEZM_H264_MAX_DURATION")) define ( "ZM_EYEZM_H264_MAX_DURATION", "120" );
|
||||
/* Parm: ZM_EYEZM_DEFAULT_BR: Default bitrate of H264 live-feed (when selected).
|
||||
* This parameter can be changed to anything FFMPEG supports. 64k is a good lower bound, and 392k
|
||||
* a good upper */
|
||||
if (!defined("ZM_EYEZM_H264_DEFAULT_BR")) define ( "ZM_EYEZM_H264_DEFAULT_BR", "96k" );
|
||||
/* Parm: ZM_EYEZM_H264_TIMEOUT: How long to wait for H264 stream to be created. Increase
|
||||
* this value for streams that take a while to create, or for slow systems that time-out frequently */
|
||||
if (!defined("ZM_EYEZM_H264_TIMEOUT")) define ( "ZM_EYEZM_H264_TIMEOUT", "20" );
|
||||
/* Parm: ZM_EYEZM_H264_DEFAULT_EVBR: Default bit-rate when creasing H264 Event videos */
|
||||
if (!defined("ZM_EYEZM_H264_DEFAULT_EVBR")) define ( "ZM_EYEZM_H264_DEFAULT_EVBR", "128k" );
|
||||
/* Logging defines */
|
||||
/* Parm: ZM_EYEZM_LOG_TO_FILE: Set to 1 to log XML Debug output to a separate file, when
|
||||
* ZM_EYEZM_DEBUG is set to 1. If set to 0, XML Logging will be directed to Apache error log */
|
||||
if (!defined("ZM_EYEZM_LOG_TO_FILE")) define ( "ZM_EYEZM_LOG_TO_FILE", "1" );
|
||||
/* Parm: ZM_EYEZM_LOG_FILE: Path to filename when LOG_TO_FILE is enabled */
|
||||
if (!defined("ZM_EYEZM_LOG_FILE")) define ( "ZM_EYEZM_LOG_FILE", "/tmp/zm_xml.log" );
|
||||
/* Parm: How many lines to display when viewing log from eyeZm */
|
||||
if (!defined("ZM_EYEZM_LOG_LINES")) define ( "ZM_EYEZM_LOG_LINES", "50" );
|
||||
|
||||
$rates = array(
|
||||
"10000" => "100x",
|
||||
"5000" => "50x",
|
||||
"2500" => "25x",
|
||||
"1000" => "10x",
|
||||
"400" => "4x",
|
||||
"200" => "2x",
|
||||
"100" => translate('Real'),
|
||||
"50" => "1/2x",
|
||||
"25" => "1/4x",
|
||||
);
|
||||
|
||||
$scales = array(
|
||||
"400" => "4x",
|
||||
"300" => "3x",
|
||||
"200" => "2x",
|
||||
"150" => "1.5x",
|
||||
"100" => translate('Actual'),
|
||||
"75" => "3/4x",
|
||||
"50" => "1/2x",
|
||||
"33" => "1/3x",
|
||||
"25" => "1/4x",
|
||||
);
|
||||
|
||||
$bwArray = array(
|
||||
"high" => translate('High'),
|
||||
"medium" => translate('Medium'),
|
||||
"low" => translate('Low')
|
||||
);
|
||||
|
||||
/* Check if ZM_WEB_L_CAN_STREAM and ZM_WEB_L_STREAM_METHOD are defined */
|
||||
if (!defined("ZM_WEB_L_CAN_STREAM")) {
|
||||
define ("ZM_WEB_L_CAN_STREAM", 1);
|
||||
define ("ZM_WEB_M_CAN_STREAM", 1);
|
||||
define ("ZM_WEB_H_CAN_STREAM", 1);
|
||||
}
|
||||
if (!defined("ZM_WEB_L_STREAM_METHOD")) {
|
||||
define ("ZM_WEB_L_STREAM_METHOD", "jpeg");
|
||||
define ("ZM_WEB_M_STREAM_METHOD", "jpeg");
|
||||
define ("ZM_WEB_H_STREAM_METHOD", "jpeg");
|
||||
}
|
||||
|
||||
switch ( $_COOKIE['zmBandwidth'] )
|
||||
{
|
||||
case "high" :
|
||||
{
|
||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_H_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_H_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_H_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_H_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_H_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_H_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_H_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_H_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_H_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_H_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_H_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_H_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_H_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_H_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_H_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||
break;
|
||||
}
|
||||
case "medium" :
|
||||
{
|
||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_M_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_M_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_M_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_M_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_M_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_M_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_M_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_M_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_M_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_M_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_M_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_M_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_M_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_M_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_M_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||
break;
|
||||
}
|
||||
case "low" :
|
||||
{
|
||||
define( "ZM_WEB_REFRESH_MAIN", ZM_WEB_L_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
|
||||
define( "ZM_WEB_REFRESH_CYCLE", ZM_WEB_L_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
|
||||
define( "ZM_WEB_REFRESH_IMAGE", ZM_WEB_L_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
|
||||
define( "ZM_WEB_REFRESH_STATUS", ZM_WEB_L_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
|
||||
define( "ZM_WEB_REFRESH_EVENTS", ZM_WEB_L_REFRESH_EVENTS ); // How often the event listing is refreshed in the watch window, only for recent events
|
||||
define( "ZM_WEB_CAN_STREAM", ZM_WEB_L_CAN_STREAM ); // Override the automatic detection of browser streaming capability
|
||||
define( "ZM_WEB_STREAM_METHOD", ZM_WEB_L_STREAM_METHOD ); // Which method should be used to send video streams to your browser
|
||||
define( "ZM_WEB_DEFAULT_SCALE", ZM_WEB_L_DEFAULT_SCALE ); // What the default scaling factor applied to 'live' or 'event' views is (%)
|
||||
define( "ZM_WEB_DEFAULT_RATE", ZM_WEB_L_DEFAULT_RATE ); // What the default replay rate factor applied to 'event' views is (%)
|
||||
define( "ZM_WEB_VIDEO_BITRATE", ZM_WEB_L_VIDEO_BITRATE ); // What the bitrate of any streamed video should be
|
||||
define( "ZM_WEB_VIDEO_MAXFPS", ZM_WEB_L_VIDEO_MAXFPS ); // What the maximum frame rate of any streamed video should be
|
||||
define( "ZM_WEB_SCALE_THUMBS", ZM_WEB_L_SCALE_THUMBS ); // Image scaling for thumbnails, bandwidth versus cpu in rescaling
|
||||
define( "ZM_WEB_EVENTS_VIEW", ZM_WEB_L_EVENTS_VIEW ); // What the default view of multiple events should be.
|
||||
define( "ZM_WEB_SHOW_PROGRESS", ZM_WEB_L_SHOW_PROGRESS ); // Whether to show the progress of replay in event view.
|
||||
define( "ZM_WEB_AJAX_TIMEOUT", ZM_WEB_L_AJAX_TIMEOUT ); // Timeout to use for Ajax requests, no timeout used if unset
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,447 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* functions.php is created by Jai Dhar, FPS-Tech, for use with eyeZm
|
||||
* iPhone application. This is not intended for use with any other applications,
|
||||
* although source-code is provided under GPL.
|
||||
*
|
||||
* For questions, please email support@eyezm.com (http://www.eyezm.com)
|
||||
*
|
||||
*/
|
||||
/* These functions are taken from functions.php */
|
||||
function validInteger( $input )
|
||||
{
|
||||
return( preg_replace( '/\D/', '', $input ) );
|
||||
}
|
||||
|
||||
function validString( $input )
|
||||
{
|
||||
return( strip_tags( $input ) );
|
||||
}
|
||||
/* There appears to be some discrepancy btw. 1.24.1/2 and .3 for EventPaths, to escape them here */
|
||||
function getEventPathSafe($event)
|
||||
{
|
||||
if (ZM_USE_DEEP_STORAGE) {
|
||||
$ret = ZM_DIR_EVENTS."/".$event['MonitorId'].'/'.strftime( "%y/%m/%d/%H/%M/%S", strtotime($event['StartTime']) );
|
||||
} else {
|
||||
$ret = ZM_DIR_EVENTS."/".$event['MonitorId']."/".$event['Id'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
function updateClientVer()
|
||||
{
|
||||
$str = $_SERVER['HTTP_USER_AGENT'];
|
||||
/* Check if it starts with eyeZm */
|
||||
if (!strcmp(substr($str, 0, 5),"eyeZm")) {
|
||||
/* Found eyeZm */
|
||||
$ver = substr($str, 6);
|
||||
$verarray = explode(".", $ver);
|
||||
$_SESSION['vermaj']=$verarray[0];
|
||||
$_SESSION['vermin']=$verarray[1];
|
||||
$_SESSION['verbuild']=$verarray[2];
|
||||
}
|
||||
logXml("(".$_SERVER['REMOTE_ADDR'].") GET: ".$_SERVER['REQUEST_URI']." - eyeZm ".getClientVerMaj().".".getClientVerMin());
|
||||
}
|
||||
function getClientVerMaj()
|
||||
{
|
||||
if (isset($_SESSION['vermaj'])) return $_SESSION['vermaj'];
|
||||
return "0";
|
||||
}
|
||||
function getClientVerMin()
|
||||
{
|
||||
if (isset($_SESSION['vermin'])) return $_SESSION['vermin'];
|
||||
return "0";
|
||||
}
|
||||
function requireVer($maj, $min)
|
||||
{
|
||||
if (getClientVerMaj() > $maj) return 1;
|
||||
if ((getClientVerMaj() == $maj) && (getClientVerMin() >= $min)) return 1;
|
||||
return 0;
|
||||
}
|
||||
function logXmlErr($str)
|
||||
{
|
||||
logXml($str, 1);
|
||||
}
|
||||
function logXml($str, $err = 0)
|
||||
{
|
||||
if (!defined("ZM_EYEZM_DEBUG")) {
|
||||
/* Check session variable */
|
||||
if (isset($_SESSION['xml_debug'])) define("ZM_EYEZM_DEBUG", $_SESSION['xml_debug']);
|
||||
else define ("ZM_EYEZM_DEBUG", "0");
|
||||
}
|
||||
if (!defined("ZM_EYEZM_LOG_TO_FILE")) {
|
||||
/* Check session variable */
|
||||
if (isset($_SESSION['xml_log_to_file'])) define("ZM_EYEZM_LOG_TO_FILE", $_SESSION['xml_log_to_file']);
|
||||
else define ("ZM_EYEZM_LOG_TO_FILE", "1");
|
||||
}
|
||||
if (!defined("ZM_EYEZM_LOG_FILE")) {
|
||||
/* Check session variable */
|
||||
if (isset($_SESSION['xml_log_file'])) define("ZM_EYEZM_LOG_FILE", $_SESSION['xml_log_file']);
|
||||
else define ("ZM_EYEZM_LOG_FILE", "/tmp/zm_xml.log");
|
||||
}
|
||||
/* Only log if debug is enabled */
|
||||
if (ZM_EYEZM_DEBUG == 0) return;
|
||||
/* Logging is enabled, set log string */
|
||||
$logstr = "XML_LOG (".($err?"ERROR":"NOTICE")."): ".$str.(ZM_EYEZM_LOG_TO_FILE?"\n":"");
|
||||
if (ZM_EYEZM_LOG_TO_FILE) {
|
||||
error_log("[".date("r")."] ".$logstr, 3, ZM_EYEZM_LOG_FILE);
|
||||
} else {
|
||||
error_log($logstr);
|
||||
}
|
||||
}
|
||||
/* Returns defval if varname is not set, otherwise return varname */
|
||||
function getset($varname, $defval)
|
||||
{
|
||||
if (isset($_GET[$varname])) return $_GET[$varname];
|
||||
return $defval;
|
||||
}
|
||||
function xml_header()
|
||||
{
|
||||
header ("content-type: text/xml");
|
||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
}
|
||||
function xml_tag_val($tag, $val)
|
||||
{
|
||||
echo "<".$tag.">".$val."</".$tag.">";
|
||||
}
|
||||
function xml_tag_sec($tag, $open)
|
||||
{
|
||||
if ($open) $tok = "<";
|
||||
else $tok = "</";
|
||||
echo $tok.$tag.">";
|
||||
}
|
||||
function xhtmlHeaders( $file, $title )
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
border: 0px solid;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
</head>
|
||||
<?php
|
||||
}
|
||||
/** Returns whether necessary components for H264 streaming
|
||||
* are present */
|
||||
function canStream264($sup = 0) {
|
||||
if (!ffmpegSupportsCodec("libx264")) {
|
||||
if (!$sup) logXmlErr("FFMPEG not installed, accessible in path/ZM_PATH_FFMPEG, or doesn't support libx264");
|
||||
return FALSE;
|
||||
}
|
||||
/* Make sure segmenter exists */
|
||||
if (!exeExists(shell_exec("which segmenter"))) {
|
||||
if (!$sup) logXmlErr("HTTP segmenter not installed or not accessible in path");
|
||||
return FALSE;
|
||||
}
|
||||
/* Check for zmstreamer */
|
||||
if (!exeExists(shell_exec("which zmstreamer"))) {
|
||||
if (!$sup) logXmlErr("ZMSTREAMER not installed or not accessible in path");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
/* Returns the path of ffmpeg by using define */
|
||||
function getFfmpegPath()
|
||||
{
|
||||
if (defined("ZM_PATH_FFMPEG")) {
|
||||
return ZM_PATH_FFMPEG;
|
||||
} else {
|
||||
/* Not defined, get it from using 'which' */
|
||||
return shell_exec("which ffmpeg");
|
||||
}
|
||||
}
|
||||
/* Returns whether ffmpeg supports a given codec. Takes into account
|
||||
* whether FFMPEG exists or not */
|
||||
function ffmpegSupportsCodec($codec)
|
||||
{
|
||||
if (!ffmpegExists()) return FALSE;
|
||||
/* FFMPEG exists */
|
||||
if (preg_match("/\b".$codec."\b/", shell_exec(getFfmpegPath()." -codecs 2> /dev/null")) > 0) {
|
||||
/* More than one match */
|
||||
return TRUE;
|
||||
} else {
|
||||
/* Check -formats tag also if we fail -codecs */
|
||||
if (preg_match("/\b".$codec."\b/", shell_exec(getFfmpegPath()." -formats 2> /dev/null")) > 0) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
function exeExists($exepath)
|
||||
{
|
||||
$path = trim($exepath);
|
||||
return (file_exists($path) && is_readable($path) && ($path != ""));
|
||||
}
|
||||
/* Returns whether ffmpeg exists or not */
|
||||
function ffmpegExists()
|
||||
{
|
||||
return exeExists(getFfmpegPath());
|
||||
}
|
||||
/* Returns with PHP-GD exists */
|
||||
function gdExists()
|
||||
{
|
||||
if (extension_loaded('gd') && function_exists('gd_info')) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function getFfmpeg264FoutParms($br, $fout)
|
||||
{
|
||||
$ffparms = "-analyzeduration 0 -acodec copy";
|
||||
$ffparms .= " -vcodec libx264 -b ".$br;
|
||||
$ffparms .= " -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8";
|
||||
$ffparms .= " -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25";
|
||||
$ffparms .= " -sc_threshold 40 -i_qfactor 0.71 -bt 16k";
|
||||
$ffparms .= " -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6";
|
||||
$ffparms .= " -qmin 10 -qmax 51 -qdiff 4 -level 30";
|
||||
$ffparms .= " -g 30 -analyzeduration 0 -async 2 ".$fout." 2> /dev/null";
|
||||
return $ffparms;
|
||||
}
|
||||
/** Return FFMPEG parameters for H264 streaming */
|
||||
function getFfmpeg264Str($width, $height, $br, $fin, $fout)
|
||||
{
|
||||
$ffparms = getFfmpeg264FoutParms($br, $fout);
|
||||
$ffstr = getFfmpegPath()." -t ".ZM_EYEZM_H264_MAX_DURATION." -analyzeduration 0 -i ";
|
||||
$ffstr .= $fin." -f mpegts ".$ffparms;
|
||||
return $ffstr;
|
||||
}
|
||||
/** Returns true when monitor exists */
|
||||
function isMonitor($monitor)
|
||||
{
|
||||
$query = "select Id from Monitors where Id = ?";
|
||||
$res = dbFetchOne($query, NULL, array($monitor));
|
||||
if ($res) return TRUE;
|
||||
logXml("Monitor ID ".$monitor." does not exist");
|
||||
return FALSE;
|
||||
}
|
||||
/** Returns the width and height of a monitor */
|
||||
function getMonitorDims($monitor)
|
||||
{
|
||||
$query = "select Width,Height from Monitors where Id = ?";
|
||||
$res = dbFetchOne($query, NULL, array( $monitor ) );
|
||||
return $res;
|
||||
}
|
||||
/** Returns the temp directory for H264 encoding */
|
||||
function getTempDir()
|
||||
{
|
||||
/* Assume that the directory structure is <base>/skins/xml/views */
|
||||
return dirname(__FILE__)."/../../../temp";
|
||||
}
|
||||
/** Returns the name of the m3u8 playlist based on monitor */
|
||||
function m3u8fname($monitor) {
|
||||
return "stream_".$monitor.".m3u8";
|
||||
}
|
||||
|
||||
/** Erases the M3u8 and TS file names for a given monitor */
|
||||
function eraseH264Files($monitor) {
|
||||
/** NOTE: This command executes an 'rm' command, so $monitor parameter
|
||||
* should be properly validated before executing */
|
||||
/* Remove wdir/.m3u8 and wdir/sample_<mon>*.ts */
|
||||
shell_exec("rm -f ".getTempDir()."/".m3u8fname($monitor)." ".getTempDir()."/sample_".$monitor."*.ts");
|
||||
}
|
||||
function kill264proc($monitor) {
|
||||
/** NOTE: This command executes an 'kill' command, so $monitor parameter
|
||||
* should be properly validated before executing */
|
||||
$pid = trim(shell_exec("pgrep -f -x \"zmstreamer -m ".$monitor."\""));
|
||||
if ($pid == "") {
|
||||
logXml("No PID found for ZMStreamer to kill");
|
||||
} else {
|
||||
shell_exec("kill -9 ".$pid);
|
||||
logXml("Killed process ".$pid." for Monitor ".$monitor);
|
||||
}
|
||||
}
|
||||
/** Return the command-line shell function to setup H264 stream */
|
||||
function stream264fn ($mid, $width, $height, $br) {
|
||||
$cdir = "./temp";
|
||||
$zmstrm = "zmstreamer -m ".$mid." 2> /dev/null";
|
||||
$ffstr = getFfmpeg264Str($width, $height, $br, "-", "-");
|
||||
$seg = "segmenter - ".ZM_EYEZM_SEG_DURATION." ".$cdir."/sample_".$mid." ".$cdir."/".m3u8fname($mid)." ../ 2> /dev/null";
|
||||
$url = $zmstrm . " | ".$ffstr." | " . $seg;
|
||||
return "nohup ".$url." & echo $!";
|
||||
}
|
||||
|
||||
/** Generate the web-page presented to the viewer when using H264 */
|
||||
function h264vidHtml($width, $height, $monitor, $br, $thumbsrc) {
|
||||
function printTermLink() {
|
||||
$str = "H264 Streaming Launching...<br>Tap to re-load if stream fails";
|
||||
$str2 = "document.getElementById(\"loaddiv\").innerHTML = \"".$str."\";";
|
||||
echo $str2;
|
||||
|
||||
}
|
||||
$ajaxUrl = "?view=actions&action=spawn264&&monitor=".$monitor."&br=".$br;
|
||||
/* Call these two directly to bypass server blocking issues */
|
||||
$ajax2Url = "./skins/xml/views/actions.php?action=chk264&monitor=".$monitor;
|
||||
$ajax2Url .= "&timeout=".ZM_EYEZM_H264_TIMEOUT;
|
||||
$ajax3Url = "./skins/xml/views/actions.php?action=kill264&monitor=".$monitor;
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
/* Called when paused or done is pressed */
|
||||
function vidAbort() {
|
||||
document.getElementById('viddiv').style.display = 'none';
|
||||
var pElement = document.getElementsByTagName('video')[0];
|
||||
var ajaxKill = new AjaxConnection("<?php echo $ajax3Url;?>");
|
||||
ajaxKill.connect("cbKilled");
|
||||
pElement.stop();
|
||||
pElement.src="";
|
||||
|
||||
}
|
||||
function reloadStreamImage() {
|
||||
var obj = document.getElementById('liveStream');
|
||||
var src = obj.src;
|
||||
var date = new Date();
|
||||
obj.src = src + '&vrand=' + date.getTime();
|
||||
return false;
|
||||
}
|
||||
/* Callback when spawn264 process is ended */
|
||||
function cbVidLoad()
|
||||
{
|
||||
reloadStreamImage();
|
||||
<?php
|
||||
printTermLink();
|
||||
?>
|
||||
}
|
||||
function vidLoaded() {
|
||||
window.setTimeout("startVid()", 500);
|
||||
}
|
||||
function bindListeners()
|
||||
{
|
||||
var pElement = document.getElementsByTagName('video')[0];
|
||||
/* Bind abort */
|
||||
pElement.addEventListener('abort', vidAbort, false);
|
||||
pElement.addEventListener('done', vidAbort, false);
|
||||
pElement.addEventListener('ended', vidAbort, false);
|
||||
pElement.addEventListener('pause', vidAbort, false);
|
||||
pElement.addEventListener('loadstart', vidLoaded, false);
|
||||
}
|
||||
/* Callback when kill264 process is ended */
|
||||
function cbKilled()
|
||||
{
|
||||
<?php printTermLink(); ?>
|
||||
}
|
||||
/* Called after an interval from cbFileExists() */
|
||||
function loadVid()
|
||||
{
|
||||
var pElement = document.getElementById("vidcontainer");
|
||||
<?php
|
||||
echo "pElement.src=\"./temp/".m3u8fname($monitor)."\"\n";
|
||||
?>
|
||||
pElement.load();
|
||||
}
|
||||
function startVid()
|
||||
{
|
||||
document.getElementById('viddiv').style.display = 'block';
|
||||
var pElement = document.getElementById("vidcontainer");
|
||||
pElement.play();
|
||||
}
|
||||
/* Callback when stream is active and ready to be played */
|
||||
function cbFileExists()
|
||||
{
|
||||
window.setTimeout("loadVid()", 500);
|
||||
}
|
||||
/* On-load triggers two requests immediately: spawn264 and chk264 */
|
||||
window.onload = function() {
|
||||
bindListeners();
|
||||
var ajax1 = new AjaxConnection("<?php echo "$ajaxUrl";?>");
|
||||
var ajax2 = new AjaxConnection("<?php echo "$ajax2Url";?>");
|
||||
ajax1.connect("cbVidLoad");
|
||||
/* Don't initiate file-exists since eyeZm will */
|
||||
/*ajax2.connect("cbFileExists");*/
|
||||
}
|
||||
function AjaxConnection(url) {
|
||||
this.connect = connect;
|
||||
this.url = url;
|
||||
}
|
||||
function connect(return_func) {
|
||||
this.x = new XMLHttpRequest();
|
||||
this.x.open("GET", this.url, true);
|
||||
var self = this;
|
||||
this.x.onreadystatechange = function() {
|
||||
if (self.x.readyState != 4)
|
||||
return;
|
||||
eval(return_func + '()');
|
||||
delete self.x;
|
||||
}
|
||||
this.x.send(null);
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
border: 0px solid;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background-color: black;
|
||||
width: <?php echo $width ?>px;
|
||||
height: <?php echo $height ?>px;
|
||||
}
|
||||
.textcl {
|
||||
text-align: center;
|
||||
font-family: Arial;
|
||||
font-size: larger;
|
||||
width: 100%;
|
||||
<?php echo "padding-top: ".(($height/2)-100)."px;"; ?>
|
||||
<?php echo "padding-bottom: ".(($height/2)-100)."px;"; ?>
|
||||
z-index: 2;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
height: 100%;
|
||||
}
|
||||
.textcl2 {
|
||||
width: auto;
|
||||
height: auto;
|
||||
background-color: black;
|
||||
padding: 5px 5px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.textcl3 {
|
||||
width: auto;
|
||||
height: auto;
|
||||
padding: 2px 2px;
|
||||
margin: auto;
|
||||
color: white;
|
||||
}
|
||||
.imgdiv {
|
||||
position: absolute;
|
||||
padding: 0px;
|
||||
background-color: black;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
margin: 0px;
|
||||
width: <?php echo $width ?>px;
|
||||
height: <?php echo $height ?>px;
|
||||
z-index: 1;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="viddiv" style="display: none;">
|
||||
<?php
|
||||
echo "<video id=\"vidcontainer\" width='".$width."' height='".$height."' />\n";
|
||||
?>
|
||||
</div>
|
||||
<div id="loaddiv2" class="textcl"><div id="loaddiv3" class="textcl2">
|
||||
<div id="loaddiv" class="textcl3">
|
||||
Initializing H264 Stream (<?php echo($br); ?>)...<br>
|
||||
<span style="font-size: small;"><i>This may take a few seconds</i></span>
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
<div class="imgdiv" id="imagediv">
|
||||
<?php outputImageStream("liveStream", $thumbsrc, $width, $height, "stream"); ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
?>
|
|
@ -1,2 +0,0 @@
|
|||
<?php
|
||||
?>
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// ZoneMinder HTML interface file, $Date: 2008-09-26 02:47:20 -0700 (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 ( empty($_COOKIE['zmBandwidth']) )
|
||||
$_COOKIE['zmBandwidth'] = "low";
|
||||
|
||||
foreach ( getSkinIncludes( 'includes/config.php' ) as $includeFile )
|
||||
require_once $includeFile;
|
||||
|
||||
foreach ( getSkinIncludes( 'includes/functions.php' ) as $includeFile )
|
||||
require_once $includeFile;
|
||||
|
||||
if ( empty($view) )
|
||||
$view = 'console';
|
||||
|
||||
if ( !isset($user) && ZM_OPT_USE_AUTH && ZM_AUTH_TYPE == "remote" && !empty( $_SERVER['REMOTE_USER']) )
|
||||
{
|
||||
$view = "postlogin";
|
||||
$action = "login";
|
||||
$_REQUEST['username'] = $_SERVER['REMOTE_USER'];
|
||||
}
|
||||
/* Get version info from client */
|
||||
updateClientVer();
|
||||
/* Store some logging information in session variables
|
||||
* so other processes can access them */
|
||||
if (defined("ZM_EYEZM_LOG_TO_FILE")) $_SESSION['xml_log_to_file'] = ZM_EYEZM_LOG_TO_FILE;
|
||||
if (defined("ZM_EYEZM_LOG_FILE")) $_SESSION['xml_log_file'] = ZM_EYEZM_LOG_FILE;
|
||||
if (defined("ZM_EYEZM_DEBUG")) $_SESSION['xml_debug'] = ZM_EYEZM_DEBUG;
|
||||
|
||||
?>
|
|
@ -1,392 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* actions.php is created by Jai Dhar, FPS-Tech, for use with eyeZm
|
||||
* iPhone application. This is not intended for use with any other applications,
|
||||
* although source-code is provided under GPL.
|
||||
*
|
||||
* For questions, please email jdhar@eyezm.com (http://www.eyezm.com)
|
||||
*
|
||||
*/
|
||||
/* Parse any specific actions here */
|
||||
if (isset($_GET['action'])) {
|
||||
$action = $_GET['action'];
|
||||
if (!strcmp($action, "devent")) {
|
||||
/* ACTION: Delete an Event. Parms: <eid> */
|
||||
if (!canEdit('Events')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have edit Events perms");
|
||||
exit;
|
||||
}
|
||||
if (!isset($_REQUEST['eid'])) {
|
||||
logXmlErr("EID not set for action delete-event");
|
||||
exit;
|
||||
}
|
||||
$eid = validInteger($_REQUEST['eid']);
|
||||
$url = "./index.php?view=request&request=event&id=".$eid."&action=delete";
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "spawn264")) {
|
||||
/* ACTION: Spawn 264 streaming process.
|
||||
* Parms: <monitor>[br|width|height] */
|
||||
if (!canView('Stream')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have view Stream perms");
|
||||
exit;
|
||||
}
|
||||
if (!isset($_GET['monitor'])) {
|
||||
logXmlErr("Not all parameters specified for spawn264");
|
||||
exit;
|
||||
}
|
||||
$monitor = validInteger($_REQUEST['monitor']);
|
||||
if (!isMonitor($monitor)) exit;
|
||||
$dims = getMonitorDims($monitor);
|
||||
$width = validInteger(getset('width', $dims['Width']));
|
||||
$height = validInteger(getset('height', $dims['Height']));
|
||||
$br = validString(getset('br', ZM_EYEZM_H264_DEFAULT_BR));
|
||||
/* Check that we can stream first */
|
||||
if (!canStream264()) {
|
||||
/* canStream264 will print out error */
|
||||
exit;
|
||||
}
|
||||
$streamUrl = stream264fn($monitor, $width, $height, $br);
|
||||
logXml("Using H264 Pipe Function: ".$streamUrl);
|
||||
$pid = shell_exec($streamUrl);
|
||||
logXml("Streaming Process for monitor ".$monitor." ended, cleaning up files");
|
||||
eraseH264Files($monitor);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "kill264")) {
|
||||
/* ACTION: Kill existing H264 stream process and cleanup files.
|
||||
* Parms: <monitor>.
|
||||
* NOTE: This will be called directly by path, so include files
|
||||
* may not be available */
|
||||
session_start();
|
||||
require_once(dirname(__FILE__)."/../includes/functions.php");
|
||||
if (!isset($_GET['monitor'])) {
|
||||
logXmlErr("Not all parameters specified for kill264");
|
||||
exit;
|
||||
}
|
||||
$monitor = validInteger($_GET['monitor']);
|
||||
kill264proc($monitor);
|
||||
logXml("Killed Segmenter process for monitor ".$monitor);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "chk264")) {
|
||||
/* ACTION: Simply stalls while checking for 264 file.
|
||||
* Parms: <monitor><timeout>
|
||||
* NOTE: This will be called directly by path, so include files
|
||||
* may not be available */
|
||||
session_start();
|
||||
require_once(dirname(__FILE__)."/../includes/functions.php");
|
||||
if (!isset($_GET['monitor']) || !isset($_GET['timeout'])) {
|
||||
logXmlErr("Monitor not specified for chk264");
|
||||
exit;
|
||||
}
|
||||
$monitor = validInteger($_GET['monitor']);
|
||||
$path = getTempDir()."/".m3u8fname($monitor);
|
||||
/* Wait for the second sample to become available */
|
||||
$tsfile = getTempDir()."/sample_".$monitor."-2.ts";
|
||||
/* Setup timeout */
|
||||
$startTime = time();
|
||||
$timeout = validInteger($_GET['timeout']);
|
||||
while (!file_exists($path) || !file_exists($tsfile)) {
|
||||
if (time() > $startTime + $timeout) {
|
||||
logXmlErr("Timed out waiting for stream to start, exiting...");
|
||||
kill264proc($monitor);
|
||||
exit;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
logXml("File exists, stream created after ".(time()-$startTime)." sec");
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "feed")) {
|
||||
/* ACTION: View a feed. Parms: <monitor> [height|width|fps|scale|vcodec|br] */
|
||||
if (!canView('Stream')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have view Stream perms");
|
||||
exit;
|
||||
}
|
||||
/* Check that required variables are set */
|
||||
if (!isset($_REQUEST['monitor'])) {
|
||||
logXmlErr("Not all parameters set for action view-feed");
|
||||
exit;
|
||||
}
|
||||
$monitor = validInteger($_REQUEST['monitor']);
|
||||
if (!isMonitor($monitor)) exit;
|
||||
$dims = getMonitorDims($monitor);
|
||||
$width = validInteger(getset('width', $dims['Width']));
|
||||
$height = validInteger(getset('height', $dims['Height']));
|
||||
$fps = validInteger(getset('fps', ZM_WEB_VIDEO_MAXFPS));
|
||||
$scale = validInteger(getset('scale', 100));
|
||||
$vcodec = validString(getset('vcodec', ZM_EYEZM_FEED_VCODEC));
|
||||
/* Select which codec we want */
|
||||
if (!strcmp($vcodec, "h264")) {
|
||||
/* Validate that we can in fact stream H264 */
|
||||
if (!canStream264()) {
|
||||
/* canStream264 will print out error if
|
||||
* there is one */
|
||||
echo "Server cannot stream H264. Check eyeZm log for details";
|
||||
exit;
|
||||
}
|
||||
if (!requireVer("1", "2")) {
|
||||
echo "H264 Streaming requires eyeZm v1.2 or above";
|
||||
logXmlErr("H264 Streaming requires eyeZm v1.2 or above");
|
||||
exit;
|
||||
}
|
||||
$br = validString(getset('br', ZM_EYEZM_H264_DEFAULT_BR));
|
||||
/* H264 processing */
|
||||
noCacheHeaders();
|
||||
/* Kill any existing processes and files */
|
||||
kill264proc($monitor);
|
||||
eraseH264Files($monitor);
|
||||
logXml("Streaming H264 on Monitor ".$monitor.", ".$width."x".$height." @".$br);
|
||||
/* Get thumbnail source */
|
||||
$thumbsrc =
|
||||
getStreamSrc( array(
|
||||
"mode=single",
|
||||
"monitor=".$monitor,
|
||||
"scale=".$scale,
|
||||
"maxfps=".$fps,
|
||||
"buffer=1000"
|
||||
) );
|
||||
logXml("Using thumbnail image from ".$thumbsrc);
|
||||
/* Generate H264 Web-page */
|
||||
echo "<meta name=\"viewport\" content=\"width=".$width."\" />\n";
|
||||
h264vidHtml($width, $height, $monitor, $br, $thumbsrc);
|
||||
} else if (!strcmp($vcodec, "mjpeg")) {
|
||||
/* MJPEG streaming */
|
||||
/* If $fps=0, get a single-shot */
|
||||
if (!$fps) {
|
||||
/* single-shot */
|
||||
$streamSrc =
|
||||
getStreamSrc( array(
|
||||
"mode=single",
|
||||
"monitor=".$monitor,
|
||||
"scale=".$scale,
|
||||
"maxfps=0",
|
||||
"buffer=1000"
|
||||
) );
|
||||
} else {
|
||||
$streamSrc =
|
||||
getStreamSrc( array(
|
||||
"mode=jpeg",
|
||||
"monitor=".$monitor,
|
||||
"scale=".$scale,
|
||||
"maxfps=".$fps,
|
||||
"buffer=1000"
|
||||
) );
|
||||
}
|
||||
noCacheHeaders();
|
||||
xhtmlHeaders( __FILE__, "Stream" );
|
||||
logXml("Streaming MJPEG on Monitor ".$monitor.", ".$width."x".$height." @".$fps."fps");
|
||||
echo "<meta name=\"viewport\" content=\"width=".$width."\" />\n";
|
||||
echo "<body>\n";
|
||||
echo "<div style=\"border: 0px solid; padding: 0px; background-color: black; position: absolute; top: 0px; left; 0px; margin: 0px; width: ".$width."px; height: ".$height."px;\">\n";
|
||||
logXml("Using stream source: ".$streamSrc);
|
||||
outputImageStream("liveStream", $streamSrc, $width, $height, "stream");
|
||||
echo "</div></body></html>";
|
||||
} else {
|
||||
logXmlErr("Unsupported codec ".$vcodec." selected for streaming");
|
||||
echo("Unsupported codec ".$vcodec." selected for streaming");
|
||||
}
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "vevent")) {
|
||||
/* ACTION: View an event. Parms: <eid> [fps|vcodec|br] */
|
||||
if (!canView('Events')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have view Events perms");
|
||||
exit;
|
||||
}
|
||||
if (!isset($_GET['eid'])) {
|
||||
logXmlErr("Not all parameters set for Action View-event");
|
||||
exit;
|
||||
}
|
||||
/* Grab event from the database */
|
||||
$eid = validInteger($_GET['eid']);
|
||||
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where E.Id = ?";
|
||||
$event = dbFetchOne($eventsSql, NULL, array( $eid ) );
|
||||
/* Check if exists */
|
||||
if (!$event) {
|
||||
logxmlErr("Requested event ID ".$eid." does not exist");
|
||||
exit;
|
||||
}
|
||||
/* Calculate FPS */
|
||||
$fps = validInteger(getset('fps',ceil($event['Frames'] / $event['Length'])));
|
||||
$vcodec = validString(getset('vcodec', ZM_EYEZM_EVENT_VCODEC));
|
||||
$baseURL = ZM_PATH_WEB."/".getEventPathSafe($event);
|
||||
/* Here we validate the codec.
|
||||
* Check that FFMPEG exists and supports codecs */
|
||||
if (!strcmp($vcodec, "mpeg4")) {
|
||||
if (!ffmpegSupportsCodec("mpeg4")) {
|
||||
logXmlErr("FFMPEG not installed, accessible in path/ZM_PATH_FFMPEG, or doesn't support mpeg4");
|
||||
exit;
|
||||
}
|
||||
/* Can generate, we are good to go */
|
||||
$fname = "capture.mov";
|
||||
$ffparms = "-vcodec mpeg4 -r ".ZM_EYEZM_EVENT_FPS." ".$baseURL."/".$fname." 2> /dev/null";
|
||||
|
||||
} else if (!strcmp($vcodec, "h264")) {
|
||||
if (!ffmpegSupportsCodec("libx264")) {
|
||||
logXmlErr("FFMPEG not installed, accessible in path/ZM_PATH_FFMPEG, or doesn't support H264");
|
||||
exit;
|
||||
}
|
||||
if (!requireVer("1","2")) {
|
||||
logXmlErr("H264 Event viewing requires eyeZm v1.2 or greater");
|
||||
exit;
|
||||
}
|
||||
/* Good to go */
|
||||
$fname = "capture.mp4";
|
||||
$ffparms = getFfmpeg264FoutParms(
|
||||
validString(getset('br',ZM_EYEZM_H264_DEFAULT_EVBR)),
|
||||
$baseURL."/".$fname);
|
||||
|
||||
} else {
|
||||
logXmlErr("Unknown codec ".$vcodec." selected for event viewing");
|
||||
exit;
|
||||
}
|
||||
logXml("Selected ".$vcodec." for viewing event ".$event['Id']);
|
||||
$fnameOut = $baseURL."/".$fname;
|
||||
$shellCmd = getFfmpegPath()." -y -r ".$fps." -i ".$baseURL."/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg";
|
||||
$shellCmd .= " ".$ffparms;
|
||||
logXml("Encoding event with command: ".$shellCmd);
|
||||
$shellOutput = shell_exec($shellCmd);
|
||||
/* Check that file exists */
|
||||
if (!file_exists(trim($fnameOut))) {
|
||||
logXmlErr("Generate Event ".$event['Id']." file ".$fnameOut." does not exist");
|
||||
exit;
|
||||
}
|
||||
$url = "./".getEventPathSafe($event)."/".$fname;
|
||||
logXml("Loading Event URL ".$url);
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "vframe")) {
|
||||
/* ACTION: View a frame given by an event and frame-id. Parms: <eid> <frame> [alarm | analyze | qty | scale]
|
||||
* If 'alarm' is set, the returned frame will be the <frame>-th alarm frame. If 'analyze' is set,
|
||||
* the returned frame will be the %03d-analyse frame instead of %03d-capture, if ZM_CREATE_ANALYSIS_IMAGES
|
||||
* is set. Otherwise it just returns the captured frame.
|
||||
* If qty is set, it will apply a quality factor from 0-100, and if width is set, it will scale the jpeg accordingly
|
||||
*/
|
||||
if (!isset($_GET['eid']) || !isset($_GET['frame'])) {
|
||||
logXmlErr("Not all parameters set for action view-frame");
|
||||
exit;
|
||||
}
|
||||
$eid = validInteger($_GET['eid']);
|
||||
$frame = validInteger($_GET['frame']);
|
||||
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where E.Id = ?";
|
||||
$event = dbFetchOne($eventsSql, NULL, array( $eid ) );
|
||||
$qty = validInteger(getset('qty', 100));
|
||||
if ($qty > 100) $qty = 100;
|
||||
$scale = validInteger(getset('scale', 100));
|
||||
if (!$event) {
|
||||
logxmlErr("Requested event ID ".$eid." does not exist");
|
||||
exit;
|
||||
}
|
||||
/* Figure out the frame number. If 'alarm' is not set, this is just equal to the <frame> parameter.
|
||||
* If 'alarm' is set, need to query DB and grab the <frame>-th item */
|
||||
if (isset($_GET['alarm'])) {
|
||||
$frameSql = "select * from Frames as F where F.EventId=? and (F.Type = 'Alarm') order by F.FrameId";
|
||||
$i=0;
|
||||
foreach (dbFetchAll($frameSql, NULL, array($eid) ) as $dbframe) {
|
||||
if ($i == $frame) {
|
||||
$frame = $dbframe['FrameId'];
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (isset($_GET['analyze']) && ZM_CREATE_ANALYSIS_IMAGES) {
|
||||
$suffix = "analyse";
|
||||
} else {
|
||||
$suffix = "capture";
|
||||
}
|
||||
/* A frame index of 0 is invalid, so if we see this, just use frame 1 */
|
||||
if (!$frame) $frame = 1;
|
||||
/* Suffix based on 'analyze' */
|
||||
$fname = sprintf("%0".ZM_EVENT_IMAGE_DIGITS."d-%s.jpg", $frame, $suffix);
|
||||
$url = "./".getEventPathSafe($event)."/".$fname;
|
||||
if (!file_exists($url)) {
|
||||
logXmlErr("Invalid frame image requested: ".$url);
|
||||
$url = "./skins/xml/views/notfound.png";
|
||||
}
|
||||
/* Check if the image needs any processing - check for GD if requested */
|
||||
if (($scale != 100) || ($qty < 100)) {
|
||||
if (!gdExists()) {
|
||||
logXmlErr("Lib GD is not loaded, but required for image scaling functions");
|
||||
$url = "./skins/xml/views/notfound.png";
|
||||
} else if (!$img = imagecreatefromjpeg($url)) {
|
||||
logXmlErr("Could not load JPEG from ".$url);
|
||||
$url = "./skins/xml/views/notfound.png";
|
||||
} else {
|
||||
/* GD exists and we read the file ok */
|
||||
header('Content-type: image/jpeg');
|
||||
/* Check if resizing is needed */
|
||||
if ($scale != 100) {
|
||||
list($width_orig, $height_orig) = getimagesize($url);
|
||||
$width_new = $width_orig * ($scale/100);
|
||||
$height_new = $height_orig * ($scale/100);
|
||||
$img_new = imagecreatetruecolor($width_new, $height_new);
|
||||
imagecopyresampled($img_new, $img, 0, 0, 0, 0, $width_new, $height_new, $width_orig, $height_orig);
|
||||
imagejpeg($img_new, NULL, $qty);
|
||||
} else {
|
||||
imagejpeg($img, NULL, $qty);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "state")) {
|
||||
/* ACTION: Change the state of the system. Parms: <state> */
|
||||
if (!canEdit('System')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have edit System perms");
|
||||
exit;
|
||||
}
|
||||
if (!isset($_GET['state'])) {
|
||||
logXmlErr("Server state not specified for action");
|
||||
exit;
|
||||
}
|
||||
$url = "./index.php?view=none&action=state&runState=".validString($_GET['state']);
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "func")) {
|
||||
/* ACTION: Change state of the monitor. Parms: <mid><func><en> */
|
||||
if (!canEdit('Monitors')) {
|
||||
logXmlErr("User ".$user['Username']. " doesn't have monitors Edit perms");
|
||||
exit;
|
||||
}
|
||||
if (!isset($_GET['mid']) || !isset($_GET['func']) || !isset($_GET['en'])) {
|
||||
logXmlErr("Not all parameters specified for action Monitor state");
|
||||
exit;
|
||||
}
|
||||
$mid = validInteger($_GET['mid']);
|
||||
if (!isMonitor($mid)) exit;
|
||||
$url = "./index.php?view=none&action=function&mid=".$mid."&newFunction=".validString($_GET['func'])."&newEnabled=".validString($_GET['en']);
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
|
||||
} else if (!strcmp($action, "vlog")) {
|
||||
/* ACTION: View log file. Must have debug and log to file enabled, and sufficient perms
|
||||
* Parms: [lines] */
|
||||
if (!canEdit('System')) {
|
||||
logXmlErr("Insufficient permissions to view log file");
|
||||
echo "Insufficient permissions to view log file";
|
||||
exit;
|
||||
}
|
||||
if (!ZM_EYEZM_DEBUG || !ZM_EYEZM_LOG_TO_FILE) {
|
||||
echo "eyeZm Debug (EYEZM_DEBUG) or log-to-file (EYEZM_LOG_TO_FILE) not enabled. Please enable first";
|
||||
exit;
|
||||
}
|
||||
if (!file_exists(ZM_EYEZM_LOG_FILE)) {
|
||||
echo "Log file ".ZM_EYEZM_LOG_FILE." doesn't exist";
|
||||
exit;
|
||||
}
|
||||
$lines = validInteger(getset('lines',ZM_EYEZM_LOG_LINES));
|
||||
logXml("Returning last ".$lines." lines of eyeZm Log from ".ZM_EYEZM_LOG_FILE);
|
||||
echo shell_exec("tail -n ".$lines." ".ZM_EYEZM_LOG_FILE);
|
||||
echo "\n\n--- Showing last ".$lines." lines ---\n";
|
||||
echo "--- End of Log ---\n\n";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,259 +0,0 @@
|
|||
<?php
|
||||
//
|
||||
// ZoneMinder web console file, $Date: 2009-02-19 10:05:31 +0000 (Thu, 19 Feb 2009) $, $Revision: 2780 $
|
||||
// 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.
|
||||
//
|
||||
|
||||
/*
|
||||
* console.php is updated by Jai Dhar, FPS-Tech, for use with eyeZm
|
||||
* iPhone application. This is not intended for use with any other applications,
|
||||
* although source-code is provided under GPL.
|
||||
*
|
||||
* For questions, please email support@eyezm.com (http://www.eyezm.com)
|
||||
*
|
||||
*/
|
||||
$eventCounts = array(
|
||||
array(
|
||||
"title" => translate('Events'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
"title" => translate('Hour'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
array( "attr" => "Archived", "op" => "=", "val" => "0" ),
|
||||
array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 hour" ),
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
"title" => translate('Day'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
array( "attr" => "Archived", "op" => "=", "val" => "0" ),
|
||||
array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 day" ),
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
"title" => translate('Week'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
array( "attr" => "Archived", "op" => "=", "val" => "0" ),
|
||||
array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-7 day" ),
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
"title" => translate('Month'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
array( "attr" => "Archived", "op" => "=", "val" => "0" ),
|
||||
array( "cnj" => "and", "attr" => "DateTime", "op" => ">=", "val" => "-1 month" ),
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
"title" => translate('Archived'),
|
||||
"filter" => array(
|
||||
"terms" => array(
|
||||
array( "attr" => "Archived", "op" => "=", "val" => "1" ),
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$running = daemonCheck();
|
||||
$status = $running?translate('Running'):translate('Stopped');
|
||||
|
||||
if ( $group = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array(empty($_COOKIE['zmGroup'])?0:$_COOKIE['zmGroup']) ) )
|
||||
$groupIds = array_flip(split( ',', $group['MonitorIds'] ));
|
||||
|
||||
$maxWidth = 0;
|
||||
$maxHeight = 0;
|
||||
$cycleCount = 0;
|
||||
$minSequence = 0;
|
||||
$maxSequence = 1;
|
||||
$seqIdList = array();
|
||||
$monitors = dbFetchAll( "select * from Monitors order by Sequence asc" );
|
||||
$displayMonitors = array();
|
||||
for ( $i = 0; $i < count($monitors); $i++ )
|
||||
{
|
||||
if ( !visibleMonitor( $monitors[$i]['Id'] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $group && !empty($groupIds) && !array_key_exists( $monitors[$i]['Id'], $groupIds ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$monitors[$i]['Show'] = true;
|
||||
if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) )
|
||||
{
|
||||
$minSequence = $monitors[$i]['Sequence'];
|
||||
}
|
||||
if ( $monitors[$i]['Sequence'] > $maxSequence )
|
||||
{
|
||||
$maxSequence = $monitors[$i]['Sequence'];
|
||||
}
|
||||
if (isset($_GET['nostatus'])) {
|
||||
$monitors[$i]['zmc'] = 1;
|
||||
$monitors[$i]['zma'] = 1;
|
||||
} else {
|
||||
$monitors[$i]['zmc'] = zmcStatus( $monitors[$i] );
|
||||
$monitors[$i]['zma'] = zmaStatus( $monitors[$i] );
|
||||
}
|
||||
$monitors[$i]['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']) );
|
||||
$counts = array();
|
||||
for ( $j = 0; $j < count($eventCounts); $j++ )
|
||||
{
|
||||
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitors[$i]['Id'] ) );
|
||||
parseFilter( $filter );
|
||||
$counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j";
|
||||
$monitors[$i]['eventCounts'][$j]['filter'] = $filter;
|
||||
}
|
||||
$sql = 'SELECT '.join($counts,", ").' from Events as E where MonitorId = ?';
|
||||
$counts = dbFetchOne( $sql, NULL, array( $monitors[$i]['Id'] ) );
|
||||
if ( $monitors[$i]['Function'] != 'None' )
|
||||
{
|
||||
$cycleCount++;
|
||||
$scaleWidth = reScale( $monitors[$i]['Width'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
$scaleHeight = reScale( $monitors[$i]['Height'], $monitors[$i]['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||
if ( $maxWidth < $scaleWidth ) $maxWidth = $scaleWidth;
|
||||
if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight;
|
||||
}
|
||||
$monitors[$i] = array_merge( $monitors[$i], $counts );
|
||||
$seqIdList[] = $monitors[$i]['Id'];
|
||||
$displayMonitors[] = $monitors[$i];
|
||||
}
|
||||
$states = dbFetchAll("select * from States");
|
||||
/* XML Dump Starts here */
|
||||
xml_header();
|
||||
/* Print out the general section */
|
||||
xml_tag_sec("ZM_XML", 1);
|
||||
xml_tag_sec("GENERAL", 1);
|
||||
xml_tag_val("RUNNING", $running);
|
||||
xml_tag_val("PROTOVER", ZM_EYEZM_PROTOCOL_VERSION);
|
||||
xml_tag_val("FEATURESET", ZM_EYEZM_FEATURE_SET);
|
||||
xml_tag_val("VERSION", ZM_VERSION);
|
||||
xml_tag_val("CANSTR264", canStream264(1));
|
||||
xml_tag_val("GD", gdExists());
|
||||
xml_tag_val("FVCODEC", ZM_EYEZM_FEED_VCODEC);
|
||||
xml_tag_val("FVTMT", ZM_EYEZM_H264_TIMEOUT);
|
||||
xml_tag_val("USER", $user['Username']);
|
||||
xml_tag_val("UID", $user['Id']);
|
||||
/* Permissions block */
|
||||
xml_tag_sec("PERMS", 1);
|
||||
xml_tag_val("STREAM", $user['Stream']);
|
||||
xml_tag_val("EVENTS", $user['Events']);
|
||||
xml_tag_val("CONTROL", $user['Control']);
|
||||
xml_tag_val("MONITORS", $user['Monitors']);
|
||||
xml_tag_val("DEVICES", $user['Devices']);
|
||||
xml_tag_val("SYSTEM", $user['System']);
|
||||
xml_tag_sec("PERMS", 0);
|
||||
/* End permissions block */
|
||||
if (canEdit('System')) {
|
||||
if ($running) {
|
||||
xml_tag_val("STATE", "stop");
|
||||
xml_tag_val("STATE", "restart");
|
||||
} else {
|
||||
xml_tag_val("STATE", "start");
|
||||
}
|
||||
foreach ($states as $state) {
|
||||
xml_tag_val("STATE", $state['Name']);
|
||||
}
|
||||
}
|
||||
/* End general section */
|
||||
xml_tag_sec("GENERAL", 0);
|
||||
/* Print out the monitors section */
|
||||
xml_tag_sec("MONITOR_LIST", 1);
|
||||
foreach( $displayMonitors as $monitor )
|
||||
{
|
||||
if (!canView('Monitors')) continue;
|
||||
xml_tag_sec("MONITOR", 1);
|
||||
xml_tag_val("ID", $monitor['Id']);
|
||||
xml_tag_val("NAME", $monitor['Name']);
|
||||
xml_tag_val("FUNCTION", $monitor['Function']);
|
||||
xml_tag_val("NUMEVENTS", $monitor['EventCount0']);
|
||||
xml_tag_val("ENABLED", $monitor['Enabled']);
|
||||
xml_tag_val("ZMC", $monitor['zmc']);
|
||||
xml_tag_val("ZMA", $monitor['zma']);
|
||||
xml_tag_val("STATE", ($monitor['zmc']!=1)?"ERROR":(
|
||||
($monitor['zma']==1)?"OK":"WARN"));
|
||||
xml_tag_val("WIDTH", $monitor['Width']);
|
||||
xml_tag_val("HEIGHT", $monitor['Height']);
|
||||
|
||||
/* Form the data-base query for this monitor */
|
||||
$pageOffset = 0;
|
||||
$offset = 0;
|
||||
if (isset($_GET['numEvents'])) {
|
||||
$numEvents = validInteger($_GET['numEvents']);
|
||||
$eventsSql = "select E.Id,E.MonitorId,M.Name As MonitorName,E.Cause,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived from Monitors as M inner join Events as E on (M.Id = E.MonitorId) and ( E.MonitorId = ? ) order by E.StartTime desc";
|
||||
$eventsSql .= " limit ".$numEvents;
|
||||
/* If there is an pageOff<x> tag for this monitor, then retrieve the offset. Otherwise, don't specify offset */
|
||||
if (isset($_GET['pageOff'.$monitor['Id']])) {
|
||||
/* If pageOffset is greater than we actually have,
|
||||
* we need to adjust it */
|
||||
$pageOffset = validInteger($_GET['pageOff'.$monitor['Id']]);
|
||||
if ($pageOffset >= ceil($monitor['EventCount0']/$numEvents)) {
|
||||
$pageOffset = 0;
|
||||
}
|
||||
$offset = $pageOffset * $numEvents;
|
||||
}
|
||||
$eventsSql .= " offset ".$offset;
|
||||
} else {
|
||||
unset($eventsSql);
|
||||
}
|
||||
xml_tag_val("PAGEOFF", $pageOffset);
|
||||
xml_tag_sec("EVENTS",1);
|
||||
if (canView('Events') && isset($eventsSql)) {
|
||||
foreach ( dbFetchAll( $eventsSql, NULL, array($monitor['Id']) ) as $event )
|
||||
{
|
||||
xml_tag_sec("EVENT",1);
|
||||
xml_tag_val("ID",$event['Id']);
|
||||
xml_tag_val("NAME",$event['Name']);
|
||||
xml_tag_val("TIME", strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime'])));
|
||||
xml_tag_val("DURATION", $event['Length']);
|
||||
xml_tag_val("FRAMES", $event['Frames']);
|
||||
xml_tag_val("FPS", ($event['Length'] > 0)?ceil($event['Frames']/$event['Length']):0);
|
||||
xml_tag_val("TOTSCORE", $event['TotScore']);
|
||||
xml_tag_val("AVGSCORE", $event['AvgScore']);
|
||||
xml_tag_val("MAXSCORE", $event['MaxScore']);
|
||||
/* Grab the max frame-id from Frames table. If AlarmFrames = 0, don't try
|
||||
* to grab any frames, and just signal the max frame index as index 0 */
|
||||
$fridx = 1;
|
||||
$alarmFrames = 1;
|
||||
if ($event['AlarmFrames']) {
|
||||
$framesSql = "SELECT FrameId FROM Frames WHERE (Type = 'Alarm') and (EventId = ?) ORDER BY Score DESC LIMIT 1";
|
||||
$fr = dbFetchOne($framesSql, NULL, array( $event['Id'] ) );
|
||||
$fridx = $fr['FrameId'];
|
||||
$alarmFrames = $event['AlarmFrames'];
|
||||
}
|
||||
xml_tag_val("ALARMFRAMES", $alarmFrames);
|
||||
xml_tag_val("MAXFRAMEID", $fridx);
|
||||
xml_tag_sec("EVENT",0);
|
||||
}
|
||||
}
|
||||
xml_tag_sec("EVENTS",0);
|
||||
xml_tag_sec("MONITOR", 0);
|
||||
}
|
||||
xml_tag_sec("MONITOR_LIST", 0);
|
||||
xml_tag_sec("ZM_XML", 0);
|
||||
?>
|
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB |
Loading…
Reference in New Issue