2010-11-04 15:07:40 +08:00
|
|
|
<?php
|
2010-11-11 06:20:29 +08:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2011-02-20 04:25:22 +08:00
|
|
|
* For questions, please email support@eyezm.com (http://www.eyezm.com)
|
2010-11-11 06:20:29 +08:00
|
|
|
*
|
|
|
|
*/
|
2011-02-20 04:25:22 +08:00
|
|
|
/* These functions are taken from functions.php */
|
|
|
|
function validInteger( $input )
|
|
|
|
{
|
|
|
|
return( preg_replace( '/\D/', '', $input ) );
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
function validString( $input )
|
|
|
|
{
|
|
|
|
return( strip_tags( $input ) );
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
/* There appears to be some discrepancy btw. 1.24.1/2 and .3 for EventPaths, to escape them here */
|
2010-11-07 12:05:16 +08:00
|
|
|
function getEventPathSafe($event)
|
|
|
|
{
|
2010-11-15 10:48:12 +08:00
|
|
|
if (ZM_USE_DEEP_STORAGE) {
|
2010-11-19 03:08:48 +08:00
|
|
|
$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'];
|
2010-11-15 02:33:55 +08:00
|
|
|
}
|
2010-11-07 12:05:16 +08:00
|
|
|
return $ret;
|
|
|
|
}
|
2010-11-12 12:26:31 +08:00
|
|
|
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];
|
|
|
|
}
|
2010-11-19 03:09:33 +08:00
|
|
|
logXml("(".$_SERVER['REMOTE_ADDR'].") GET: ".$_SERVER['REQUEST_URI']." - eyeZm ".getClientVerMaj().".".getClientVerMin());
|
2010-11-12 12:26:31 +08:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2010-11-19 03:07:37 +08:00
|
|
|
function logXmlErr($str)
|
|
|
|
{
|
2010-11-19 03:09:18 +08:00
|
|
|
logXml($str, 1);
|
2010-11-19 03:07:37 +08:00
|
|
|
}
|
2010-11-19 03:09:18 +08:00
|
|
|
function logXml($str, $err = 0)
|
2010-11-11 13:25:43 +08:00
|
|
|
{
|
2011-02-20 04:25:54 +08:00
|
|
|
if (!defined("ZM_EYEZM_DEBUG")) {
|
2010-11-19 03:09:18 +08:00
|
|
|
/* Check session variable */
|
2011-02-20 04:25:54 +08:00
|
|
|
if (isset($_SESSION['xml_debug'])) define("ZM_EYEZM_DEBUG", $_SESSION['xml_debug']);
|
|
|
|
else define ("ZM_EYEZM_DEBUG", "0");
|
2010-11-19 03:09:18 +08:00
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
if (!defined("ZM_EYEZM_LOG_TO_FILE")) {
|
2010-11-19 03:09:18 +08:00
|
|
|
/* Check session variable */
|
2011-02-20 04:25:54 +08:00
|
|
|
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");
|
2010-11-19 03:09:18 +08:00
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
if (!defined("ZM_EYEZM_LOG_FILE")) {
|
2010-11-19 03:09:18 +08:00
|
|
|
/* Check session variable */
|
2011-02-20 04:25:54 +08:00
|
|
|
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");
|
2010-11-19 03:09:18 +08:00
|
|
|
}
|
|
|
|
/* Only log if debug is enabled */
|
2011-02-20 04:25:54 +08:00
|
|
|
if (ZM_EYEZM_DEBUG == 0) return;
|
2010-11-19 03:09:18 +08:00
|
|
|
/* Logging is enabled, set log string */
|
2011-02-20 04:25:54 +08:00
|
|
|
$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);
|
2010-11-19 03:09:18 +08:00
|
|
|
} else {
|
|
|
|
error_log($logstr);
|
|
|
|
}
|
2010-11-11 13:25:43 +08:00
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Returns defval if varname is not set, otherwise return varname */
|
2010-11-06 07:41:09 +08:00
|
|
|
function getset($varname, $defval)
|
|
|
|
{
|
|
|
|
if (isset($_GET[$varname])) return $_GET[$varname];
|
|
|
|
return $defval;
|
|
|
|
}
|
2010-11-04 15:07:40 +08:00
|
|
|
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.">";
|
|
|
|
}
|
2010-11-05 03:25:34 +08:00
|
|
|
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>
|
2010-11-06 00:48:57 +08:00
|
|
|
<script type="text/javascript">
|
2010-11-11 06:20:29 +08:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<?php
|
|
|
|
}
|
2010-11-19 03:07:37 +08:00
|
|
|
/** Returns whether necessary components for H264 streaming
|
|
|
|
* are present */
|
2010-11-19 03:09:51 +08:00
|
|
|
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;
|
|
|
|
}
|
2010-11-19 03:07:37 +08:00
|
|
|
/* Make sure segmenter exists */
|
2010-11-19 03:09:51 +08:00
|
|
|
if (!exeExists(shell_exec("which segmenter"))) {
|
|
|
|
if (!$sup) logXmlErr("HTTP segmenter not installed or not accessible in path");
|
|
|
|
return FALSE;
|
2010-11-19 03:07:37 +08:00
|
|
|
}
|
|
|
|
/* Check for zmstreamer */
|
2010-11-19 03:09:51 +08:00
|
|
|
if (!exeExists(shell_exec("which zmstreamer"))) {
|
|
|
|
if (!$sup) logXmlErr("ZMSTREAMER not installed or not accessible in path");
|
|
|
|
return FALSE;
|
2010-11-19 03:07:37 +08:00
|
|
|
}
|
2010-11-19 03:09:51 +08:00
|
|
|
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");
|
2010-11-19 03:07:37 +08:00
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-19 03:09:51 +08:00
|
|
|
/* 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 {
|
2011-02-20 04:25:22 +08:00
|
|
|
/* Check -formats tag also if we fail -codecs */
|
2011-06-09 06:37:19 +08:00
|
|
|
if (preg_match("/\b".$codec."\b/", shell_exec(getFfmpegPath()." -formats 2> /dev/null")) > 0) return TRUE;
|
2010-11-19 03:09:51 +08:00
|
|
|
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());
|
|
|
|
}
|
2011-04-19 08:09:20 +08:00
|
|
|
/* Returns with PHP-GD exists */
|
|
|
|
function gdExists()
|
|
|
|
{
|
|
|
|
if (extension_loaded('gd') && function_exists('gd_info')) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-19 03:09:51 +08:00
|
|
|
|
2010-11-19 03:07:37 +08:00
|
|
|
function getFfmpeg264FoutParms($br, $fout)
|
2010-11-13 07:04:09 +08:00
|
|
|
{
|
2011-04-19 08:09:50 +08:00
|
|
|
$ffparms = "-analyzeduration 0 -acodec copy";
|
2010-11-13 07:04:09 +08:00
|
|
|
$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";
|
2010-11-19 03:07:52 +08:00
|
|
|
$ffparms .= " -sc_threshold 40 -i_qfactor 0.71 -bt 16k";
|
|
|
|
$ffparms .= " -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6";
|
2010-11-13 07:04:09 +08:00
|
|
|
$ffparms .= " -qmin 10 -qmax 51 -qdiff 4 -level 30";
|
2010-11-19 03:09:18 +08:00
|
|
|
$ffparms .= " -g 30 -analyzeduration 0 -async 2 ".$fout." 2> /dev/null";
|
2010-11-19 03:07:37 +08:00
|
|
|
return $ffparms;
|
|
|
|
}
|
|
|
|
/** Return FFMPEG parameters for H264 streaming */
|
|
|
|
function getFfmpeg264Str($width, $height, $br, $fin, $fout)
|
|
|
|
{
|
|
|
|
$ffparms = getFfmpeg264FoutParms($br, $fout);
|
2011-02-20 04:25:54 +08:00
|
|
|
$ffstr = getFfmpegPath()." -t ".ZM_EYEZM_H264_MAX_DURATION." -analyzeduration 0 -i ";
|
2010-11-19 03:07:37 +08:00
|
|
|
$ffstr .= $fin." -f mpegts ".$ffparms;
|
2010-11-13 07:04:09 +08:00
|
|
|
return $ffstr;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
/** Returns true when monitor exists */
|
|
|
|
function isMonitor($monitor)
|
|
|
|
{
|
2014-07-07 22:06:50 +08:00
|
|
|
$query = "select Id from Monitors where Id = ?";
|
|
|
|
$res = dbFetchOne($query, NULL, array($monitor));
|
2011-02-20 04:25:22 +08:00
|
|
|
if ($res) return TRUE;
|
|
|
|
logXml("Monitor ID ".$monitor." does not exist");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-13 07:04:09 +08:00
|
|
|
/** Returns the width and height of a monitor */
|
|
|
|
function getMonitorDims($monitor)
|
|
|
|
{
|
2014-07-07 22:06:50 +08:00
|
|
|
$query = "select Width,Height from Monitors where Id = ?";
|
|
|
|
$res = dbFetchOne($query, NULL, array( $monitor ) );
|
2010-11-13 07:04:09 +08:00
|
|
|
return $res;
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
/** 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) {
|
2011-02-20 04:25:22 +08:00
|
|
|
/** NOTE: This command executes an 'rm' command, so $monitor parameter
|
|
|
|
* should be properly validated before executing */
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Remove wdir/.m3u8 and wdir/sample_<mon>*.ts */
|
|
|
|
shell_exec("rm -f ".getTempDir()."/".m3u8fname($monitor)." ".getTempDir()."/sample_".$monitor."*.ts");
|
|
|
|
}
|
|
|
|
function kill264proc($monitor) {
|
2011-02-20 04:25:22 +08:00
|
|
|
/** NOTE: This command executes an 'kill' command, so $monitor parameter
|
|
|
|
* should be properly validated before executing */
|
2010-11-11 06:20:29 +08:00
|
|
|
$pid = trim(shell_exec("pgrep -f -x \"zmstreamer -m ".$monitor."\""));
|
|
|
|
if ($pid == "") {
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("No PID found for ZMStreamer to kill");
|
2010-11-11 06:20:29 +08:00
|
|
|
} else {
|
|
|
|
shell_exec("kill -9 ".$pid);
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("Killed process ".$pid." for Monitor ".$monitor);
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/** Return the command-line shell function to setup H264 stream */
|
|
|
|
function stream264fn ($mid, $width, $height, $br) {
|
|
|
|
$cdir = "./temp";
|
2010-11-19 03:09:18 +08:00
|
|
|
$zmstrm = "zmstreamer -m ".$mid." 2> /dev/null";
|
2010-11-13 07:04:09 +08:00
|
|
|
$ffstr = getFfmpeg264Str($width, $height, $br, "-", "-");
|
2011-02-20 04:25:54 +08:00
|
|
|
$seg = "segmenter - ".ZM_EYEZM_SEG_DURATION." ".$cdir."/sample_".$mid." ".$cdir."/".m3u8fname($mid)." ../ 2> /dev/null";
|
2010-11-13 07:04:09 +08:00
|
|
|
$url = $zmstrm . " | ".$ffstr." | " . $seg;
|
2010-11-11 06:20:29 +08:00
|
|
|
return "nohup ".$url." & echo $!";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Generate the web-page presented to the viewer when using H264 */
|
2010-11-19 03:07:37 +08:00
|
|
|
function h264vidHtml($width, $height, $monitor, $br, $thumbsrc) {
|
2010-11-15 10:48:12 +08:00
|
|
|
function printTermLink() {
|
2011-04-19 08:10:17 +08:00
|
|
|
$str = "H264 Streaming Launching...<br>Tap to re-load if stream fails";
|
2010-11-15 10:48:12 +08:00
|
|
|
$str2 = "document.getElementById(\"loaddiv\").innerHTML = \"".$str."\";";
|
|
|
|
echo $str2;
|
2010-11-19 03:07:37 +08:00
|
|
|
|
2010-11-15 10:48:12 +08:00
|
|
|
}
|
2010-11-13 07:04:09 +08:00
|
|
|
$ajaxUrl = "?view=actions&action=spawn264&&monitor=".$monitor."&br=".$br;
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Call these two directly to bypass server blocking issues */
|
|
|
|
$ajax2Url = "./skins/xml/views/actions.php?action=chk264&monitor=".$monitor;
|
2011-02-20 04:25:54 +08:00
|
|
|
$ajax2Url .= "&timeout=".ZM_EYEZM_H264_TIMEOUT;
|
2010-11-11 06:20:29 +08:00
|
|
|
$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() {
|
2010-11-15 10:48:12 +08:00
|
|
|
document.getElementById('viddiv').style.display = 'none';
|
2010-11-11 06:20:29 +08:00
|
|
|
var pElement = document.getElementsByTagName('video')[0];
|
|
|
|
var ajaxKill = new AjaxConnection("<?php echo $ajax3Url;?>");
|
|
|
|
ajaxKill.connect("cbKilled");
|
|
|
|
pElement.stop();
|
2010-11-11 13:25:43 +08:00
|
|
|
pElement.src="";
|
2010-11-11 06:20:29 +08:00
|
|
|
|
|
|
|
}
|
2010-11-19 03:07:37 +08:00
|
|
|
function reloadStreamImage() {
|
|
|
|
var obj = document.getElementById('liveStream');
|
|
|
|
var src = obj.src;
|
|
|
|
var date = new Date();
|
|
|
|
obj.src = src + '&vrand=' + date.getTime();
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Callback when spawn264 process is ended */
|
|
|
|
function cbVidLoad()
|
|
|
|
{
|
2010-11-19 03:07:37 +08:00
|
|
|
reloadStreamImage();
|
|
|
|
<?php
|
|
|
|
printTermLink();
|
|
|
|
?>
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-13 07:04:09 +08:00
|
|
|
function vidLoaded() {
|
|
|
|
window.setTimeout("startVid()", 500);
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
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);
|
2010-11-13 07:04:09 +08:00
|
|
|
pElement.addEventListener('loadstart', vidLoaded, false);
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
|
|
|
/* Callback when kill264 process is ended */
|
|
|
|
function cbKilled()
|
|
|
|
{
|
2010-11-15 10:48:12 +08:00
|
|
|
<?php printTermLink(); ?>
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-15 10:48:12 +08:00
|
|
|
/* Called after an interval from cbFileExists() */
|
2010-11-13 07:04:09 +08:00
|
|
|
function loadVid()
|
2010-11-11 06:20:29 +08:00
|
|
|
{
|
|
|
|
var pElement = document.getElementById("vidcontainer");
|
2010-11-11 13:25:43 +08:00
|
|
|
<?php
|
|
|
|
echo "pElement.src=\"./temp/".m3u8fname($monitor)."\"\n";
|
|
|
|
?>
|
2010-11-11 06:20:29 +08:00
|
|
|
pElement.load();
|
|
|
|
}
|
2010-11-13 07:04:09 +08:00
|
|
|
function startVid()
|
|
|
|
{
|
2010-11-15 10:48:12 +08:00
|
|
|
document.getElementById('viddiv').style.display = 'block';
|
2010-11-13 07:04:09 +08:00
|
|
|
var pElement = document.getElementById("vidcontainer");
|
|
|
|
pElement.play();
|
|
|
|
}
|
|
|
|
/* Callback when stream is active and ready to be played */
|
|
|
|
function cbFileExists()
|
|
|
|
{
|
|
|
|
window.setTimeout("loadVid()", 500);
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
/* 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");
|
2010-11-16 05:35:29 +08:00
|
|
|
/* Don't initiate file-exists since eyeZm will */
|
|
|
|
/*ajax2.connect("cbFileExists");*/
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
|
|
|
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;
|
2010-11-06 00:48:57 +08:00
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
this.x.send(null);
|
2010-11-06 00:48:57 +08:00
|
|
|
}
|
|
|
|
</script>
|
2010-11-11 06:20:29 +08:00
|
|
|
<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%;
|
2010-11-19 03:07:52 +08:00
|
|
|
<?php echo "padding-top: ".(($height/2)-100)."px;"; ?>
|
|
|
|
<?php echo "padding-bottom: ".(($height/2)-100)."px;"; ?>
|
2010-11-19 03:07:37 +08:00
|
|
|
z-index: 2;
|
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
|
|
|
left: 0px;
|
|
|
|
height: 100%;
|
2010-11-19 03:07:52 +08:00
|
|
|
}
|
|
|
|
.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;
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-19 03:07:37 +08:00
|
|
|
.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;
|
2010-11-19 03:07:52 +08:00
|
|
|
opacity: 0.7;
|
2010-11-19 03:07:37 +08:00
|
|
|
}
|
|
|
|
|
2010-11-11 06:20:29 +08:00
|
|
|
</style>
|
2010-11-05 03:25:34 +08:00
|
|
|
</head>
|
2010-11-11 06:20:29 +08:00
|
|
|
<body>
|
|
|
|
<div id="viddiv" style="display: none;">
|
|
|
|
<?php
|
2010-11-11 13:25:43 +08:00
|
|
|
echo "<video id=\"vidcontainer\" width='".$width."' height='".$height."' />\n";
|
2010-11-11 06:20:29 +08:00
|
|
|
?>
|
|
|
|
</div>
|
2010-11-19 03:07:52 +08:00
|
|
|
<div id="loaddiv2" class="textcl"><div id="loaddiv3" class="textcl2">
|
|
|
|
<div id="loaddiv" class="textcl3">
|
2010-11-16 05:35:29 +08:00
|
|
|
Initializing H264 Stream (<?php echo($br); ?>)...<br>
|
|
|
|
<span style="font-size: small;"><i>This may take a few seconds</i></span>
|
2010-11-11 06:20:29 +08:00
|
|
|
</div>
|
2010-11-19 03:07:52 +08:00
|
|
|
</div></div>
|
|
|
|
|
2010-11-19 03:07:37 +08:00
|
|
|
<div class="imgdiv" id="imagediv">
|
|
|
|
<?php outputImageStream("liveStream", $thumbsrc, $width, $height, "stream"); ?>
|
|
|
|
</div>
|
2010-11-11 06:20:29 +08:00
|
|
|
</body>
|
|
|
|
</html>
|
2010-11-05 03:25:34 +08:00
|
|
|
<?php
|
|
|
|
}
|
2010-11-04 15:07:40 +08:00
|
|
|
?>
|