Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas
This commit is contained in:
commit
c466f50255
|
@ -310,10 +310,6 @@ int FfmpegCamera::PostCapture() {
|
|||
|
||||
int FfmpegCamera::OpenFfmpeg() {
|
||||
|
||||
Debug(2, "OpenFfmpeg called.");
|
||||
uint32_t last_event_id = monitor->GetLastEventId() ;
|
||||
uint32_t video_writer_event_id = monitor->GetVideoWriterEventId();
|
||||
Debug(2, "last_event(%d), our current (%d)", last_event_id, video_writer_event_id);
|
||||
|
||||
int ret;
|
||||
|
||||
|
@ -347,24 +343,26 @@ int FfmpegCamera::OpenFfmpeg() {
|
|||
Warning("Could not set rtsp_transport method '%s'\n", method.c_str());
|
||||
}
|
||||
|
||||
Debug ( 1, "Calling avformat_open_input for %s", mPath.c_str() );
|
||||
Debug(1, "Calling avformat_open_input for %s", mPath.c_str());
|
||||
|
||||
mFormatContext = avformat_alloc_context( );
|
||||
//mFormatContext = avformat_alloc_context( );
|
||||
// Speed up find_stream_info
|
||||
//FIXME can speed up initial analysis but need sensible parameters...
|
||||
//mFormatContext->probesize = 32;
|
||||
//mFormatContext->max_analyze_duration = 32;
|
||||
|
||||
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) != 0 )
|
||||
if ( avformat_open_input(&mFormatContext, mPath.c_str(), NULL, &opts) != 0 )
|
||||
#endif
|
||||
{
|
||||
Error("Unable to open input %s due to: %s", mPath.c_str(), strerror(errno));
|
||||
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
|
||||
av_close_input_file( mFormatContext );
|
||||
av_close_input_file(mFormatContext);
|
||||
#else
|
||||
avformat_close_input( &mFormatContext );
|
||||
#endif
|
||||
if ( mFormatContext ) {
|
||||
avformat_close_input(&mFormatContext);
|
||||
mFormatContext = NULL;
|
||||
}
|
||||
#endif
|
||||
av_dict_free(&opts);
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -108,10 +108,10 @@ private:
|
|||
bool mFlush;
|
||||
|
||||
private:
|
||||
static void usrHandler( int sig );
|
||||
static void usrHandler(int sig);
|
||||
|
||||
public:
|
||||
friend void logInit( const char *name, const Options &options );
|
||||
friend void logInit(const char *name, const Options &options);
|
||||
friend void logTerm();
|
||||
|
||||
static Logger *fetch() {
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
Options options;
|
||||
smInstance->initialise( "undef", options );
|
||||
}
|
||||
return( smInstance );
|
||||
return smInstance;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -128,16 +128,16 @@ private:
|
|||
~Logger();
|
||||
|
||||
public:
|
||||
void initialise( const std::string &id, const Options &options );
|
||||
void initialise(const std::string &id, const Options &options);
|
||||
void terminate();
|
||||
|
||||
private:
|
||||
int limit( int level ) {
|
||||
int limit(int level) {
|
||||
if ( level > DEBUG9 )
|
||||
return( DEBUG9 );
|
||||
return DEBUG9;
|
||||
if ( level < NOLOG )
|
||||
return( NOLOG );
|
||||
return( level );
|
||||
return NOLOG;
|
||||
return level;
|
||||
}
|
||||
|
||||
bool boolEnv(const std::string &name, bool defaultValue=false);
|
||||
|
@ -157,19 +157,19 @@ public:
|
|||
Level level() const {
|
||||
return mLevel;
|
||||
}
|
||||
Level level( Level=NOOPT );
|
||||
Level level(Level=NOOPT);
|
||||
|
||||
bool debugOn() {
|
||||
return( mEffectiveLevel >= DEBUG1 );
|
||||
return mEffectiveLevel >= DEBUG1;
|
||||
}
|
||||
|
||||
Level terminalLevel( Level=NOOPT );
|
||||
Level databaseLevel( Level=NOOPT );
|
||||
Level fileLevel( Level=NOOPT );
|
||||
Level syslogLevel( Level=NOOPT );
|
||||
Level terminalLevel(Level=NOOPT);
|
||||
Level databaseLevel(Level=NOOPT);
|
||||
Level fileLevel(Level=NOOPT);
|
||||
Level syslogLevel(Level=NOOPT);
|
||||
|
||||
private:
|
||||
void logFile( const std::string &logFile );
|
||||
void logFile(const std::string &logFile);
|
||||
void openFile();
|
||||
void closeFile();
|
||||
void openSyslog();
|
||||
|
@ -177,22 +177,19 @@ private:
|
|||
void closeDatabase();
|
||||
|
||||
public:
|
||||
void logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... );
|
||||
void logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...);
|
||||
};
|
||||
|
||||
void logInit( const char *name, const Logger::Options &options=Logger::Options() );
|
||||
void logInit(const char *name, const Logger::Options &options=Logger::Options());
|
||||
void logTerm();
|
||||
inline const std::string &logId() {
|
||||
return( Logger::fetch()->id() );
|
||||
return Logger::fetch()->id();
|
||||
}
|
||||
inline Logger::Level logLevel() {
|
||||
return( Logger::fetch()->level() );
|
||||
}
|
||||
inline void logCapLevel( Logger::Level level ) {
|
||||
Logger::fetch()->level( level );
|
||||
return Logger::fetch()->level();
|
||||
}
|
||||
inline Logger::Level logDebugging() {
|
||||
return( Logger::fetch()->debugOn() );
|
||||
return Logger::fetch()->debugOn();
|
||||
}
|
||||
|
||||
#define logPrintf(logLevel,params...) {\
|
||||
|
|
|
@ -2436,7 +2436,7 @@ Debug(4, "Return from Capture (%d)", captureResult);
|
|||
|
||||
image_count++;
|
||||
|
||||
if ( image_count && fps_report_interval && !(image_count%fps_report_interval) ) {
|
||||
if ( image_count && fps_report_interval && ( (!(image_count%fps_report_interval)) || image_count < 5 ) ) {
|
||||
time_t now = image_buffer[index].timestamp->tv_sec;
|
||||
// If we are too fast, we get div by zero. This seems to happen in the case of audio packets.
|
||||
if ( now != last_fps_time ) {
|
||||
|
|
|
@ -78,19 +78,16 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
// Check for incoming command
|
||||
switch( (MsgCommand)msg->msg_data[0] ) {
|
||||
case CMD_PAUSE :
|
||||
{
|
||||
Debug( 1, "Got PAUSE command" );
|
||||
Debug(1, "Got PAUSE command");
|
||||
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
// Set delayed flag
|
||||
delayed = true;
|
||||
last_frame_sent = TV_2_FLOAT( now );
|
||||
last_frame_sent = TV_2_FLOAT(now);
|
||||
break;
|
||||
}
|
||||
case CMD_PLAY :
|
||||
{
|
||||
Debug( 1, "Got PLAY command" );
|
||||
Debug(1, "Got PLAY command");
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
|
@ -99,10 +96,8 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
}
|
||||
replay_rate = ZM_RATE_BASE;
|
||||
break;
|
||||
}
|
||||
case CMD_VARPLAY :
|
||||
{
|
||||
Debug( 1, "Got VARPLAY command" );
|
||||
Debug(1, "Got VARPLAY command");
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
|
@ -111,20 +106,16 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
}
|
||||
replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768;
|
||||
break;
|
||||
}
|
||||
case CMD_STOP :
|
||||
{
|
||||
Debug( 1, "Got STOP command" );
|
||||
Debug(1, "Got STOP command");
|
||||
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
// Clear delayed_play flag
|
||||
delayed = false;
|
||||
break;
|
||||
}
|
||||
case CMD_FASTFWD :
|
||||
{
|
||||
Debug( 1, "Got FAST FWD command" );
|
||||
Debug(1, "Got FAST FWD command");
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
|
@ -132,8 +123,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
delayed = true;
|
||||
}
|
||||
// Set play rate
|
||||
switch ( replay_rate )
|
||||
{
|
||||
switch ( replay_rate ) {
|
||||
case 2 * ZM_RATE_BASE :
|
||||
replay_rate = 5 * ZM_RATE_BASE;
|
||||
break;
|
||||
|
@ -152,9 +142,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_SLOWFWD :
|
||||
{
|
||||
Debug( 1, "Got SLOW FWD command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
|
@ -165,9 +153,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
// Set step
|
||||
step = 1;
|
||||
break;
|
||||
}
|
||||
case CMD_SLOWREV :
|
||||
{
|
||||
Debug( 1, "Got SLOW REV command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
|
@ -178,9 +164,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
// Set step
|
||||
step = -1;
|
||||
break;
|
||||
}
|
||||
case CMD_FASTREV :
|
||||
{
|
||||
Debug( 1, "Got FAST REV command" );
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
|
@ -208,9 +192,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_ZOOMIN :
|
||||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, "Got ZOOM IN command, to %d,%d", x, y );
|
||||
|
@ -233,9 +215,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_ZOOMOUT :
|
||||
{
|
||||
Debug( 1, "Got ZOOM OUT command" );
|
||||
switch ( zoom ) {
|
||||
case 500:
|
||||
|
@ -256,36 +236,25 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_PAN :
|
||||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, "Got PAN command, to %d,%d", x, y );
|
||||
break;
|
||||
}
|
||||
case CMD_SCALE :
|
||||
{
|
||||
scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
Debug( 1, "Got SCALE command, to %d", scale );
|
||||
break;
|
||||
}
|
||||
case CMD_QUIT :
|
||||
{
|
||||
Info ("User initiated exit - CMD_QUIT");
|
||||
break;
|
||||
}
|
||||
case CMD_QUERY :
|
||||
{
|
||||
Debug( 1, "Got QUERY command, sending STATUS" );
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
Error( "Got unexpected command %d", msg->msg_data[0] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // end switch command
|
||||
|
||||
struct {
|
||||
int id;
|
||||
|
@ -331,7 +300,7 @@ void MonitorStream::processCommand( const CmdMsg *msg ) {
|
|||
status_msg.msg_type = MSG_DATA_WATCH;
|
||||
memcpy( &status_msg.msg_data, &status_data, sizeof(status_data) );
|
||||
int nbytes = 0;
|
||||
if ( (nbytes = sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) )) < 0 ) {
|
||||
if ( (nbytes = sendto(sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr))) < 0 ) {
|
||||
//if ( errno != EAGAIN )
|
||||
{
|
||||
Error( "Can't sendto on sd %d: %s", sd, strerror(errno) );
|
||||
|
@ -346,7 +315,7 @@ Debug(2, "NUmber of bytes sent to (%s): (%d)", rem_addr.sun_path, nbytes );
|
|||
exit(0);
|
||||
}
|
||||
|
||||
Debug(2,"Updating framrate");
|
||||
Debug(2,"Updating framerate");
|
||||
updateFrameRate( monitor->GetFPS() );
|
||||
} // end void MonitorStream::processCommand( const CmdMsg *msg )
|
||||
|
||||
|
|
|
@ -239,8 +239,8 @@ int main(int argc, char *argv[]) {
|
|||
time_t now = (time_t)time(NULL);
|
||||
monitors[i]->setStartupTime(now);
|
||||
|
||||
snprintf( sql, sizeof(sql), "REPLACE INTO Monitor_Status (MonitorId, Status) VALUES ('%d','Running')", monitors[i]->Id() );
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
snprintf(sql, sizeof(sql), "REPLACE INTO Monitor_Status (MonitorId, Status) VALUES ('%d','Running')", monitors[i]->Id());
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,12 @@ if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
|
|||
ajaxError( "Unexpected received message type '$type'" );
|
||||
}
|
||||
|
||||
$key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.lock', 'Z');
|
||||
# The file that we point ftok to has to exist, and only exist if zms is running, so we are pointing it at the .sock
|
||||
$key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock', 'Z');
|
||||
$semaphore = sem_get($key,1);
|
||||
if ( sem_acquire($semaphore,1) !== false ) {
|
||||
if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
||||
ajaxError( 'socket_create() failed: '.socket_strerror(socket_last_error()) );
|
||||
if ( !($socket = @socket_create(AF_UNIX, SOCK_DGRAM, 0)) ) {
|
||||
ajaxError('socket_create() failed: '.socket_strerror(socket_last_error()));
|
||||
}
|
||||
|
||||
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c3976f1478c681b0bbc132ec3a3e82c3984eeed5
|
||||
Subproject commit 1351dde6b4c75b215099ae8bcf5a21d6c6e10298
|
Loading…
Reference in New Issue