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