Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
25210b7ecf
|
@ -270,7 +270,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
Debug( 1, "Got SCALE command, to %d", scale );
|
||||
break;
|
||||
}
|
||||
case CMD_QUIT :
|
||||
case CMD_QUIT :
|
||||
{
|
||||
Info ("User initiated exit - CMD_QUIT");
|
||||
break;
|
||||
|
@ -316,7 +316,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
//status_data.enabled = monitor->shared_data->active;
|
||||
status_data.enabled = monitor->trigger_data->trigger_state!=Monitor::TRIGGER_OFF;
|
||||
status_data.forced = monitor->trigger_data->trigger_state==Monitor::TRIGGER_ON;
|
||||
Debug( 2, "L:%d, D:%d, P:%d, R:%d, d:%.3f, Z:%d, E:%d F:%d",
|
||||
Debug( 2, "Buffer Level:%d, Delayed:%d, Paused:%d, Rate:%d, delay:%.3f, Zoom:%d, Enabled:%d Forced:%d",
|
||||
status_data.buffer_level,
|
||||
status_data.delayed,
|
||||
status_data.paused,
|
||||
|
@ -338,11 +338,15 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
//exit( -1 );
|
||||
}
|
||||
}
|
||||
Debug(2, "NUmber of bytes sent: (%d)", nbytes );
|
||||
|
||||
// quit after sending a status, if this was a quit request
|
||||
if ((MsgCommand)msg->msg_data[0]==CMD_QUIT)
|
||||
exit(0);
|
||||
if ( (MsgCommand)msg->msg_data[0]==CMD_QUIT ) {
|
||||
Debug(2,"Quitting");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Debug(2,"Updating framrate");
|
||||
updateFrameRate( monitor->GetFPS() );
|
||||
} // end void MonitorStream::processCommand( const CmdMsg *msg )
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
$start_time = time();
|
||||
|
||||
define( "MSG_TIMEOUT", ZM_WEB_AJAX_TIMEOUT );
|
||||
define( "MSG_DATA_SIZE", 4+256 );
|
||||
|
||||
|
@ -11,40 +13,49 @@ if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
|||
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );
|
||||
}
|
||||
$locSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.sock';
|
||||
if ( file_exists( $locSockFile ) ) {
|
||||
Warning("sock file $locSockFile already exists?! Is someone else talking to zms?");
|
||||
} else {
|
||||
Logger::Debug("socket file does not exist, we should be good to connect.");
|
||||
}
|
||||
if ( !@socket_bind( $socket, $locSockFile ) ) {
|
||||
ajaxError( "socket_bind( $locSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
||||
} else {
|
||||
Logger::Debug("Bound to $locSockFile");
|
||||
}
|
||||
|
||||
switch ( $_REQUEST['command'] ) {
|
||||
case CMD_VARPLAY :
|
||||
Logger::Debug( "Varplaying to ".$_REQUEST['rate'] );
|
||||
$msg = pack( "lcn", MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||
Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||
break;
|
||||
case CMD_ZOOMIN :
|
||||
Logger::Debug( "Zooming to ".$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( "lcnn", MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
Logger::Debug( 'Zooming to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
break;
|
||||
case CMD_PAN :
|
||||
Logger::Debug( "Panning to ".$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( "lcnn", MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
Logger::Debug( 'Panning to '.$_REQUEST['x'].",".$_REQUEST['y'] );
|
||||
$msg = pack( 'lcnn', MSG_CMD, $_REQUEST['command'], $_REQUEST['x'], $_REQUEST['y'] );
|
||||
break;
|
||||
case CMD_SCALE :
|
||||
Logger::Debug( "Scaling to ".$_REQUEST['scale'] );
|
||||
$msg = pack( "lcn", MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
||||
Logger::Debug( 'Scaling to '.$_REQUEST['scale'] );
|
||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['scale'] );
|
||||
break;
|
||||
case CMD_SEEK :
|
||||
Logger::Debug( "Seeking to ".$_REQUEST['offset'] );
|
||||
$msg = pack( "lcN", MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
||||
Logger::Debug( 'Seeking to '.$_REQUEST['offset'] );
|
||||
$msg = pack( 'lcN', MSG_CMD, $_REQUEST['command'], $_REQUEST['offset'] );
|
||||
break;
|
||||
default :
|
||||
$msg = pack( "lc", MSG_CMD, $_REQUEST['command'] );
|
||||
$msg = pack( 'lc', MSG_CMD, $_REQUEST['command'] );
|
||||
break;
|
||||
}
|
||||
|
||||
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'s.sock';
|
||||
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock';
|
||||
$max_socket_tries = 10;
|
||||
// FIXME This should not exceed web_ajax_timeout
|
||||
while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
|
||||
usleep(2000000);
|
||||
Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
|
||||
usleep(200000);
|
||||
}
|
||||
|
||||
if ( !file_exists($remSockFile) ) {
|
||||
|
@ -58,17 +69,26 @@ if ( !file_exists($remSockFile) ) {
|
|||
$rSockets = array( $socket );
|
||||
$wSockets = NULL;
|
||||
$eSockets = NULL;
|
||||
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval(MSG_TIMEOUT/1000), (MSG_TIMEOUT%1000)*1000 );
|
||||
|
||||
$timeout = MSG_TIMEOUT - ( time() - $start_time );
|
||||
Logger::Debug("TImeout is: $timeout " );
|
||||
|
||||
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
||||
|
||||
if ( $numSockets === false ) {
|
||||
Error("socket_select failed: " . socket_strerror(socket_last_error()) );
|
||||
ajaxError( "socket_select failed: ".socket_strerror(socket_last_error()) );
|
||||
} else if ( $numSockets < 0 ) {
|
||||
Error( "Socket closed $remSockFile" );
|
||||
ajaxError( "Socket closed $remSockFile" );
|
||||
} else if ( $numSockets == 0 ) {
|
||||
Error( "Timed out waiting for msg $remSockFile" );
|
||||
ajaxError( "Timed out waiting for msg $remSockFile" );
|
||||
} else if ( $numSockets > 0 ) {
|
||||
if ( count($rSockets) != 1 )
|
||||
ajaxError( "Bogus return from select, ".count($rSockets)." sockets available" );
|
||||
if ( count($rSockets) != 1 ) {
|
||||
Error( "Bogus return from select, ".count($rSockets).' sockets available' );
|
||||
ajaxError( "Bogus return from select, ".count($rSockets).' sockets available' );
|
||||
}
|
||||
}
|
||||
|
||||
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
|
||||
|
@ -79,7 +99,7 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
|
|||
}
|
||||
case 0 :
|
||||
{
|
||||
ajaxError( "No data to read from socket" );
|
||||
ajaxError( 'No data to read from socket' );
|
||||
break;
|
||||
}
|
||||
default :
|
||||
|
@ -90,7 +110,7 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
|
|||
}
|
||||
}
|
||||
|
||||
$data = unpack( "ltype", $msg );
|
||||
$data = unpack( 'ltype', $msg );
|
||||
switch ( $data['type'] ) {
|
||||
case MSG_DATA_WATCH :
|
||||
{
|
||||
|
@ -99,7 +119,7 @@ switch ( $data['type'] ) {
|
|||
$data['rate'] /= RATE_BASE;
|
||||
$data['delay'] = round( $data['delay'], 2 );
|
||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
|
||||
session_start();
|
||||
$time = time();
|
||||
// Regenerate auth hash after half the lifetime of the hash
|
||||
|
@ -117,7 +137,7 @@ switch ( $data['type'] ) {
|
|||
//$data['progress'] = sprintf( "%.2f", $data['progress'] );
|
||||
$data['rate'] /= RATE_BASE;
|
||||
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) {
|
||||
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
|
||||
session_start();
|
||||
$time = time();
|
||||
// Regenerate auth hash after half the lifetime of the hash
|
||||
|
|
|
@ -109,7 +109,7 @@ function Monitor( monitorData ) {
|
|||
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
||||
};
|
||||
|
||||
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
|
||||
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: 1000+AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
|
||||
|
||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue