Example #1
0
function outputlivestream($monitor, $inwidth = 0, $inheight = 0)
{
    $scale = isset($_REQUEST['scale']) ? validInt($_REQUEST['scale']) : reScale(SCALE_BASE, $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE);
    $connkey = $monitor['connKey'];
    // Minor hack
    //$connKey = generateConnKey();
    if (ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT) {
        $streamMode = "mpeg";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale, "bitrate=" . ZM_WEB_VIDEO_BITRATE, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "format=" . ZM_MPEG_LIVE_FORMAT, "buffer=" . $monitor['StreamReplayBuffer']));
    } elseif (canStream()) {
        $streamMode = "jpeg";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "buffer=" . $monitor['StreamReplayBuffer']));
    } else {
        $streamMode = "single";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale));
    }
    $width = !empty($inwidth) ? $inwidth : 150;
    $height = empty($inheight) ? $width * $monitor['Height'] / $monitor['Width'] : $inheight;
    $width = (int) $width;
    $height = (int) $height;
    if ($streamMode === "mpeg") {
        outputVideoStream('liveStream' . $monitor['Id'], $streamSrc, reScale($width, $scale), reScale($height, $scale), ZM_MPEG_LIVE_FORMAT, $monitor['Name']);
    } elseif ($streamMode == "jpeg") {
        if (canStreamNative()) {
            outputImageStream('liveStream' . $monitor['Id'], $streamSrc, reScale($width, $scale), reScale($height, $scale), $monitor['Name']);
        } elseif (canStreamApplet()) {
            outputHelperStream('liveStream' . $monitor['Id'], $streamSrc, reScale($width, $scale), reScale($height, $scale), $monitor['Name']);
        }
    } else {
        outputImageStill('liveStream' . $monitor['Id'], $streamSrc, reScale($width, $scale), reScale($height, $scale), $monitor['Name']);
    }
}
Example #2
0
</a>
      </div>
      <h2><?php 
echo $SLANG['Cycle'];
?>
 - <?php 
echo validHtmlStr($monitor['Name']);
?>
</h2>
    </div>
    <div id="content">
      <div id="imageFeed">
<?php 
if ($streamMode == "mpeg") {
    outputVideoStream("liveStream", $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), ZM_MPEG_LIVE_FORMAT, validHtmlStr($monitor['Name']));
} elseif ($streamMode == "jpeg") {
    if (canStreamNative()) {
        outputImageStream("liveStream", $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), validHtmlStr($monitor['Name']));
    } elseif (canStreamApplet()) {
        outputHelperStream("liveStream", $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), validHtmlStr($monitor['Name']));
    }
} else {
    outputImageStill("liveStream", $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), validHtmlStr($monitor['Name']));
}
?>
      </div>
    </div>
  </div>
</body>
</html>
Example #3
0
function getStreamHTML($monitor, $scale = 100)
{
    //FIXME, the width and height of the image need to be scaled.
    if (ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT) {
        $streamSrc = $monitor->getStreamSrc(array("mode=mpeg", "scale=" . $scale, "bitrate=" . ZM_WEB_VIDEO_BITRATE, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "format=" . ZM_MPEG_LIVE_FORMAT));
        outputVideoStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), ZM_MPEG_LIVE_FORMAT, $monitor->Name());
    } else {
        if (canStream()) {
            $streamSrc = $monitor->getStreamSrc(array('mode=jpeg', 'scale=' . $scale, 'maxfps=' . ZM_WEB_VIDEO_MAXFPS, 'buffer=' . $monitor->StreamReplayBuffer()));
            if (canStreamNative()) {
                outputImageStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
            } elseif (canStreamApplet()) {
                outputHelperStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
            }
        } else {
            $streamSrc = $monitor->getStreamSrc(array('mode=single', "scale=" . $scale));
            outputImageStill("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
            Info("The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.");
        }
    }
}
Example #4
0
" type="video/mp4">
      Your browser does not support the video tag.
      </video>
    </div>
<?php 
} else {
    ?>
    <div id="imageFeed">
<?php 
    if (ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT) {
        $streamSrc = getStreamSrc(array("source=event", "mode=mpeg", "event=" . $eid, "frame=" . $fid, "scale=" . $scale, "rate=" . $rate, "bitrate=" . ZM_WEB_VIDEO_BITRATE, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "format=" . ZM_MPEG_REPLAY_FORMAT, "replay=" . $replayMode));
        outputVideoStream("evtStream", $streamSrc, reScale($event['Width'], $scale), reScale($event['Height'], $scale), ZM_MPEG_LIVE_FORMAT);
    } else {
        $streamSrc = getStreamSrc(array("source=event", "mode=jpeg", "event=" . $eid, "frame=" . $fid, "scale=" . $scale, "rate=" . $rate, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "replay=" . $replayMode));
        if (canStreamNative()) {
            outputImageStream("evtStream", $streamSrc, reScale($event['Width'], $scale), reScale($event['Height'], $scale), validHtmlStr($event['Name']));
        } else {
            outputHelperStream("evtStream", $streamSrc, reScale($event['Width'], $scale), reScale($event['Height'], $scale));
        }
    }
    # end if ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
    ?>
        </div>
        <p id="dvrControls">
          <input type="button" value="&lt;+" id="prevBtn" title="<?php 
    echo translate('Prev');
    ?>
" class="inactive" onclick="streamPrev( true )"/>
          <input type="button" value="&lt;&lt;" id="fastRevBtn" title="<?php 
    echo translate('Rewind');
    ?>
Example #5
0
          <div id="scaleControl"><?php 
echo translate('Scale');
?>
: <?php 
echo buildSelect("scale", $scales, "changeScale( this );");
?>
</div>
        </div>
      </div>
      <div id="imageFeed">
<?php 
if ($streamMode == "mpeg") {
    outputVideoStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), ZM_MPEG_LIVE_FORMAT, $monitor->Name());
} elseif ($streamMode == "jpeg") {
    if (canStreamNative()) {
        outputImageStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
    } elseif (canStreamApplet()) {
        outputHelperStream("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
    }
} else {
    outputImageStill("liveStream", $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), $monitor->Name());
}
?>
      </div>
      <div id="monitorStatus">
<?php 
if (canEdit('Monitors')) {
    ?>
        <div id="enableDisableAlarms"><a id="enableAlarmsLink" href="#" onclick="cmdEnableAlarms(); return( false );" class="hidden"><?php 
    echo translate('EnableAlarms');
    ?>
Example #6
0
             /* 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'])) {
Example #7
0
/** 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;";
    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 
}
Example #8
0
    ?>
', 'watch', <?php 
    echo $monitor->scaleWidth();
    ?>
, <?php 
    echo $monitor->scaleHeight();
    ?>
 );">
<?php 
    if (ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT) {
        $streamSrc = $monitor->getStreamSrc(array("mode=mpeg", "scale=" . $scale, "bitrate=" . ZM_WEB_VIDEO_BITRATE, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "format=" . ZM_MPEG_LIVE_FORMAT));
        outputVideoStream("liveStream" . $monitor->Id(), $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), ZM_MPEG_LIVE_FORMAT);
    } else {
        $streamSrc = $monitor->getStreamSrc(array("mode=jpeg", "scale=" . $scale, "maxfps=" . ZM_WEB_VIDEO_MAXFPS));
        if (canStreamNative()) {
            outputImageStream("liveStream" . $monitor->Id(), $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale), validHtmlStr($monitor->Name()));
        } else {
            outputHelperStream("liveStream" . $monitor->Id(), $streamSrc, reScale($monitor->Width(), $scale), reScale($monitor->Height(), $scale));
        }
    }
    ?>
            </div>
<?php 
    if (!ZM_WEB_COMPACT_MONTAGE) {
        ?>
            <div id="monitorState<?php 
        echo $monitor->index();
        ?>
" class="monitorState idle"><?php 
        echo translate('State');
        ?>
Example #9
0
function displayMonitor($monitor, $bandwidth)
{
    if (!defined(ZM_WEB_DEFAULT_SCALE)) {
        $scale = 40;
    } else {
        $scale = ZM_WEB_DEFAULT_SCALE;
    }
    if (ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT) {
        $streamMode = "mpeg";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale, "bitrate=" . ZM_WEB_VIDEO_BITRATE, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "format=" . ZM_MPEG_LIVE_FORMAT, "buffer=" . $monitor['StreamReplayBuffer']));
    } elseif (canStream()) {
        $streamMode = "jpeg";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale, "maxfps=" . ZM_WEB_VIDEO_MAXFPS, "buffer=" . $monitor['StreamReplayBuffer']));
    } else {
        $streamMode = "single";
        $streamSrc = getStreamSrc(array("mode=" . $streamMode, "monitor=" . $monitor['Id'], "scale=" . $scale));
    }
    $width = $monitor['Width'] * ('.' . $scale) + 20;
    $display_name = strlen($monitor['Name']) > 10 ? substr($monitor['Name'], 0, 10) . '...' : $monitor['Name'];
    ?>
	<li id="monitor_<?php 
    echo $monitor['Id'];
    ?>
" style="width:<?php 
    echo $width;
    ?>
px;">
		<div class="mon_header">
			<div style="float:left;overflow:hidden;width:100px;"><h3 style="display:inline;"><?php 
    echo $display_name;
    ?>
</h3></div>
			<div class="right">
				<div class="spinner"></div>
				<div class="minimize"><img src="skins/modern/graphics/minimize.png" style="width:15px;" alt="minimize" /></div>
				<div class="maximize" url="?view=watch&amp;mid=<?php 
    echo $monitor['Id'];
    ?>
"><img src="skins/modern/graphics/maximize.png" style="width:15px;" alt="maximize" /></div>


			</div>
			<br style="clear:both;" />
		</div>
		<div class="mon">
			<a rel="monitor" href="?view=watch&amp;mid=<?php 
    echo $monitor['Id'];
    ?>
" title="<?php 
    echo $monitor['Name'];
    ?>
">
			<?php 
    //$name = $monitor['Name'] . "_live";
    //outputImageStill( "$name", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
    // output image
    if ($streamMode === "mpeg") {
        outputVideoStream('liveStream' . $monitor['Id'], $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), ZM_MPEG_LIVE_FORMAT, $monitor['Name']);
    } elseif ($streamMode == "jpeg") {
        if (canStreamNative()) {
            outputImageStream('liveStream' . $monitor['Id'], $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), $monitor['Name']);
        } elseif (canStreamApplet()) {
            outputHelperStream('liveStream' . $monitor['Id'], $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), $monitor['Name']);
        }
    } else {
        outputImageStill('liveStream' . $monitor['Id'], $streamSrc, reScale($monitor['Width'], $scale), reScale($monitor['Height'], $scale), $monitor['Name']);
    }
    ?>
			</a>
		</div>
		<div class="monfooter"></div>
</li>
<?php 
}