Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
* API function for modules
* getHistory sort by date
* Simple Devices cameras updatePreview call
* thumbnail view debug mode
* XRay filename option
  • Loading branch information
sergejey committed Dec 3, 2017
1 parent 06038f3 commit 79ddaab
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
15 changes: 15 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@
$location['object']=getRoomObjectByLocation($v['ID'],1);
$result['rooms'][]=$location;
}
} elseif (strtolower($request[0]) == 'module') {
$module_name = $request[1];
$module_file = DIR_MODULES.$module_name.'/'.$module_name.'.class.php';
if (file_exists($module_file)) {
include_once($module_file);
$module = new $module_name;
if (method_exists($module,'api')) {
$params = $request;
array_shift($params);
array_shift($params);
$module->api($params);
$db->Disconnect();
exit;
}
}
} elseif (strtolower($request[0]) == 'events' && isset($request[1])) {
array_shift($request);
$event_name=implode('/',$request);
Expand Down
2 changes: 1 addition & 1 deletion lib/objects.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ function getHistory($varname, $start_time, $stop_time = 0) {
}

// Get data
return SQLSelect("SELECT VALUE, ADDED FROM $table_name WHERE VALUE_ID='".$id."' AND ADDED>=('".date('Y-m-d H:i:s', $start_time)."') AND ADDED<=('".date('Y-m-d H:i:s', $stop_time)."')");
return SQLSelect("SELECT VALUE, ADDED FROM $table_name WHERE VALUE_ID='".$id."' AND ADDED>=('".date('Y-m-d H:i:s', $start_time)."') AND ADDED<=('".date('Y-m-d H:i:s', $stop_time)."') ORDER BY ADDED");
}

/**
Expand Down
9 changes: 9 additions & 0 deletions modules/devices/devices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ function renderStructure() {
}
}
subscribeToEvent('devices', 'COMMAND', '', 100);

//update cameras
$objects = getObjectsByClass('SCameras');
$total = count($objects);
for ($i = 0; $i < $total; $i++) {
$ot = $objects[$i]['TITLE'];
callMethod($ot.'.updatePreview');
}

}

function processSubscription($event, &$details) {
Expand Down
26 changes: 16 additions & 10 deletions modules/thumb/thumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@
}

if (preg_match('/^rtsp:/is', $url)) {
if ($live) {
//-rtsp_transport tcp // -rtsp_transport tcp
$stream_options = '-timelimit 15 -y -i "'.$url.'"'.$resize.' -r 10 -f image2 -ss 00:00:01.500 -vframes 1';
if ($_GET['debug']) {
$stream_options = '-v verbose '.$stream_options;
}
$cmd = PATH_TO_FFMPEG.' '.$stream_options.' '.$img;

if ($live && !$_GET['debug']) {
//$cmd=PATH_TO_FFMPEG.' -stimeout 5000000 -rtsp_transport tcp -y -i "'.$url.'" -r 10 -q:v 9 -f mjpeg pipe:1';// /dev/stdout 2>/dev/null
//passthru($cmd);
//exit;
$boundary = "my_mjpeg";
if (!$_GET['debug']) {
header("Cache-Control: no-cache");
header("Cache-Control: private");
header("Pragma: no-cache");
Expand All @@ -73,15 +79,11 @@
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
}

for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush();
ob_implicit_flush(1);
while (true) {
print "Content-type: image/jpeg\n\n";
$cmd = PATH_TO_FFMPEG.' -timelimit 5 -rtsp_transport tcp -y -i "'.$url.'"'.$resize.' -r 10 -f image2 -ss 00:00:01.500 -vframes 1 '.$img;
if ($_GET['debug']) {
echo $cmd;exit;
}
system($cmd);
print LoadFile($img);
print "--$boundary\n";
Expand All @@ -90,11 +92,15 @@

} else {
@unlink($img);
$cmd=PATH_TO_FFMPEG.' -timelimit 5 -v 0 -rtsp_transport tcp -y -i "'.$url.'"'.$resize.' -r 10 -f image2 -ss 00:00:01.500 -vframes 1 '.$img;
$output=array();
$res = exec($cmd.' 2>&1',$output);

if ($_GET['debug']) {
echo $cmd;exit;
echo $cmd;
echo "<hr><pre>".implode("\n",$output)."</pre>";
exit;
}
system($cmd);

}
$dc=1;
} else {
Expand Down
5 changes: 4 additions & 1 deletion modules/xray/xray.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,11 @@ function admin(&$out) {
if (!$file || $file=='xray') {
$file=date('Y-m-d').'.log';
}

$filename=ROOT.'debmes/'.$file;
if (!file_exists($filename)) {
$file = date('Y-m-d').'_'.$file.'.log';
$filename=ROOT.'debmes/'.$file;
}
$data=LoadFile($filename);
$lines=explode("\n", $data);
//$lines=array_reverse($lines);
Expand Down

0 comments on commit 79ddaab

Please sign in to comment.