Merge pull request #3226 from Carbenium/log-format
Fix logging format string mismatches
This commit is contained in:
commit
6a1a94cece
|
@ -24,7 +24,8 @@ void AnalysisThread::Start() {
|
||||||
void AnalysisThread::Run() {
|
void AnalysisThread::Run() {
|
||||||
Microseconds analysis_rate = Microseconds(monitor_->GetAnalysisRate());
|
Microseconds analysis_rate = Microseconds(monitor_->GetAnalysisRate());
|
||||||
Seconds analysis_update_delay = Seconds(monitor_->GetAnalysisUpdateDelay());
|
Seconds analysis_update_delay = Seconds(monitor_->GetAnalysisUpdateDelay());
|
||||||
Debug(2, "AnalysisThread::Run() have update delay %d", analysis_update_delay);
|
Debug(2, "AnalysisThread::Run() has an update delay of %" PRId64 "s",
|
||||||
|
static_cast<int64>(analysis_update_delay.count()));
|
||||||
|
|
||||||
monitor_->UpdateAdaptiveSkip();
|
monitor_->UpdateAdaptiveSkip();
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ void cURLCamera::Initialise() {
|
||||||
/* cURL initialization */
|
/* cURL initialization */
|
||||||
CURLcode cRet = (*curl_global_init_f)(CURL_GLOBAL_ALL);
|
CURLcode cRet = (*curl_global_init_f)(CURL_GLOBAL_ALL);
|
||||||
if(cRet != CURLE_OK) {
|
if(cRet != CURLE_OK) {
|
||||||
Error("libcurl initialization failed: ", (*curl_easy_strerror_f)(cRet));
|
Error("libcurl initialization failed: %s", (*curl_easy_strerror_f)(cRet));
|
||||||
dlclose(curl_lib);
|
dlclose(curl_lib);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ void* cURLCamera::thread_func() {
|
||||||
/* Set URL */
|
/* Set URL */
|
||||||
cRet = (*curl_easy_setopt_f)(c, CURLOPT_URL, mPath.c_str());
|
cRet = (*curl_easy_setopt_f)(c, CURLOPT_URL, mPath.c_str());
|
||||||
if(cRet != CURLE_OK) {
|
if(cRet != CURLE_OK) {
|
||||||
Error("Failed setting libcurl URL: %s", *(curl_easy_strerror_f)(cRet));
|
Error("Failed setting libcurl URL: %s", (*curl_easy_strerror_f)(cRet));
|
||||||
tRet = -52;
|
tRet = -52;
|
||||||
return (void*)tRet;
|
return (void*)tRet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,6 @@ typedef std::uint32_t uint32;
|
||||||
typedef std::uint16_t uint16;
|
typedef std::uint16_t uint16;
|
||||||
typedef std::uint8_t uint8;
|
typedef std::uint8_t uint8;
|
||||||
|
|
||||||
#define SZFMTD "%" PRIuPTR
|
|
||||||
|
|
||||||
#ifndef FALLTHROUGH
|
#ifndef FALLTHROUGH
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#define FALLTHROUGH [[clang::fallthrough]]
|
#define FALLTHROUGH [[clang::fallthrough]]
|
||||||
|
|
|
@ -88,12 +88,10 @@ Event::Event(
|
||||||
localtime_r(&now.tv_sec, &tm_info);
|
localtime_r(&now.tv_sec, &tm_info);
|
||||||
strftime(buffer_now, 26, "%Y:%m:%d %H:%M:%S", &tm_info);
|
strftime(buffer_now, 26, "%Y:%m:%d %H:%M:%S", &tm_info);
|
||||||
|
|
||||||
Error(
|
Error("StartDateTime in the future starttime %ld.%06ld >? now %ld.%06ld difference %" PRIi64 "\nstarttime: %s\nnow: %s",
|
||||||
"StartDateTime in the future starttime %ld.%06ld >? now %ld.%06ld difference %d\nstarttime: %s\nnow: %s",
|
|
||||||
start_time.tv_sec, start_time.tv_usec, now.tv_sec, now.tv_usec,
|
start_time.tv_sec, start_time.tv_usec, now.tv_sec, now.tv_usec,
|
||||||
(now.tv_sec-start_time.tv_sec),
|
static_cast<int64>(now.tv_sec - start_time.tv_sec),
|
||||||
buffer, buffer_now
|
buffer, buffer_now);
|
||||||
);
|
|
||||||
start_time = now;
|
start_time = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +239,11 @@ Event::~Event() {
|
||||||
}
|
}
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2);
|
DELTA_TIMEVAL(delta_time, end_time, start_time, DT_PREC_2);
|
||||||
Debug(2, "start_time:%d.%d end_time%d.%d", start_time.tv_sec, start_time.tv_usec, end_time.tv_sec, end_time.tv_usec);
|
Debug(2, "start_time: %" PRIi64 ".% " PRIi64 " end_time: %" PRIi64 ".%" PRIi64,
|
||||||
|
static_cast<int64>(start_time.tv_sec),
|
||||||
|
static_cast<int64>(start_time.tv_usec),
|
||||||
|
static_cast<int64>(end_time.tv_sec),
|
||||||
|
static_cast<int64>(end_time.tv_usec));
|
||||||
|
|
||||||
if (frame_data.size()) WriteDbFrames();
|
if (frame_data.size()) WriteDbFrames();
|
||||||
|
|
||||||
|
@ -360,7 +362,7 @@ void Event::updateNotes(const StringSetMap &newNoteSetMap) {
|
||||||
std::string notes;
|
std::string notes;
|
||||||
createNotes(notes);
|
createNotes(notes);
|
||||||
|
|
||||||
Debug(2, "Updating notes for event %d, '%s'", id, notes.c_str());
|
Debug(2, "Updating notes for event %" PRIu64 ", '%s'", id, notes.c_str());
|
||||||
#if USE_PREPARED_SQL
|
#if USE_PREPARED_SQL
|
||||||
static MYSQL_STMT *stmt = 0;
|
static MYSQL_STMT *stmt = 0;
|
||||||
|
|
||||||
|
@ -447,7 +449,7 @@ void Event::WriteDbFrames() {
|
||||||
"`Blobs`,`MinBlobSize`, `MaxBlobSize`, "
|
"`Blobs`,`MinBlobSize`, `MaxBlobSize`, "
|
||||||
"`MinX`, `MinY`, `MaxX`, `MaxY`,`Score`) VALUES ";
|
"`MinX`, `MinY`, `MaxX`, `MaxY`,`Score`) VALUES ";
|
||||||
|
|
||||||
Debug(1, "Inserting %d frames", frame_data.size());
|
Debug(1, "Inserting %zu frames", frame_data.size());
|
||||||
while (frame_data.size()) {
|
while (frame_data.size()) {
|
||||||
Frame *frame = frame_data.front();
|
Frame *frame = frame_data.front();
|
||||||
frame_data.pop();
|
frame_data.pop();
|
||||||
|
@ -460,7 +462,7 @@ void Event::WriteDbFrames() {
|
||||||
frame->delta.fsec,
|
frame->delta.fsec,
|
||||||
frame->score);
|
frame->score);
|
||||||
if (config.record_event_stats and frame->zone_stats.size()) {
|
if (config.record_event_stats and frame->zone_stats.size()) {
|
||||||
Debug(1, "ZOne stats size for frame %d: %d", frame->frame_id, frame->zone_stats.size());
|
Debug(1, "Zone stats size for frame %d: %zu", frame->frame_id, frame->zone_stats.size());
|
||||||
for (ZoneStats &stats : frame->zone_stats) {
|
for (ZoneStats &stats : frame->zone_stats) {
|
||||||
stats_insert_sql += stringtf("\n(%" PRIu64 ",%d,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%u),",
|
stats_insert_sql += stringtf("\n(%" PRIu64 ",%d,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%u),",
|
||||||
id, frame->frame_id,
|
id, frame->frame_id,
|
||||||
|
@ -574,9 +576,9 @@ void Event::AddFrame(
|
||||||
|
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
DELTA_TIMEVAL(delta_time, timestamp, start_time, DT_PREC_2);
|
DELTA_TIMEVAL(delta_time, timestamp, start_time, DT_PREC_2);
|
||||||
Debug(1, "Frame delta is %d.%d - %d.%d = %d.%d, score %u zone_stats.size %u",
|
Debug(1, "Frame delta is %" PRIi64 ".%" PRIi64 " - %" PRIi64 ".%" PRIi64 " = %lu.%lu, score %u zone_stats.size %zu",
|
||||||
start_time.tv_sec, start_time.tv_usec,
|
static_cast<int64>(start_time.tv_sec), static_cast<int64>(start_time.tv_usec),
|
||||||
timestamp.tv_sec, timestamp.tv_usec,
|
static_cast<int64>(timestamp.tv_sec), static_cast<int64>(timestamp.tv_usec),
|
||||||
delta_time.sec, delta_time.fsec,
|
delta_time.sec, delta_time.fsec,
|
||||||
score,
|
score,
|
||||||
zone_stats.size());
|
zone_stats.size());
|
||||||
|
@ -592,8 +594,8 @@ void Event::AddFrame(
|
||||||
or
|
or
|
||||||
( fps and (frame_data.size() > fps) )
|
( fps and (frame_data.size() > fps) )
|
||||||
) {
|
) {
|
||||||
Debug(1, "Adding %d frames to DB because write_to_db:%d or frames > analysis fps %f or BULK(%d)",
|
Debug(1, "Adding %zu frames to DB because write_to_db:%d or frames > analysis fps %f or BULK(%d)",
|
||||||
frame_data.size(), write_to_db, fps, (frame_type==BULK));
|
frame_data.size(), write_to_db, fps, (frame_type == BULK));
|
||||||
WriteDbFrames();
|
WriteDbFrames();
|
||||||
last_db_frame = frames;
|
last_db_frame = frames;
|
||||||
|
|
||||||
|
@ -611,7 +613,7 @@ void Event::AddFrame(
|
||||||
);
|
);
|
||||||
dbQueue.push(std::move(sql));
|
dbQueue.push(std::move(sql));
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "Not Adding %d frames to DB because write_to_db:%d or frames > analysis fps %f or BULK",
|
Debug(1, "Not Adding %zu frames to DB because write_to_db:%d or frames > analysis fps %f or BULK",
|
||||||
frame_data.size(), write_to_db, fps);
|
frame_data.size(), write_to_db, fps);
|
||||||
} // end if frame_type == BULK
|
} // end if frame_type == BULK
|
||||||
} // end if db_frame
|
} // end if db_frame
|
||||||
|
|
|
@ -71,14 +71,14 @@ bool EventStream::loadInitialEventData(int monitor_id, time_t event_time) {
|
||||||
//Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time );
|
//Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time );
|
||||||
if ( event_data->frames[i].timestamp >= event_time ) {
|
if ( event_data->frames[i].timestamp >= event_time ) {
|
||||||
curr_frame_id = i+1;
|
curr_frame_id = i+1;
|
||||||
Debug(3, "Set curr_stream_time:%.2f, curr_frame_id:%d", curr_stream_time, curr_frame_id);
|
Debug(3, "Set curr_stream_time:%.2f, curr_frame_id:%ld", curr_stream_time, curr_frame_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end foreach frame
|
} // end foreach frame
|
||||||
Debug(3, "Skipping %ld frames", event_data->frame_count);
|
Debug(3, "Skipping %ld frames", event_data->frame_count);
|
||||||
} else {
|
} else {
|
||||||
Warning("Requested an event time less than the start of the event. event_time %.2f < start_time %.2f",
|
Warning("Requested an event time less than the start of the event. event_time %" PRIi64 " < start_time %" PRIi64,
|
||||||
event_time, event_data->start_time);
|
static_cast<int64>(event_time), static_cast<int64>(event_data->start_time));
|
||||||
}
|
}
|
||||||
} // end if have a start time
|
} // end if have a start time
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,7 +92,7 @@ bool EventStream::loadInitialEventData(
|
||||||
|
|
||||||
if ( init_frame_id ) {
|
if ( init_frame_id ) {
|
||||||
if ( init_frame_id >= event_data->frame_count ) {
|
if ( init_frame_id >= event_data->frame_count ) {
|
||||||
Error("Invalid frame id specified. %d > %d", init_frame_id, event_data->frame_count);
|
Error("Invalid frame id specified. %d > %lu", init_frame_id, event_data->frame_count);
|
||||||
curr_stream_time = event_data->start_time;
|
curr_stream_time = event_data->start_time;
|
||||||
curr_frame_id = 1;
|
curr_frame_id = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,7 +119,7 @@ bool EventStream::loadEventData(uint64_t event_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !mysql_num_rows(result) ) {
|
if ( !mysql_num_rows(result) ) {
|
||||||
Fatal("Unable to load event %d, not found in DB", event_id);
|
Fatal("Unable to load event %" PRIu64 ", not found in DB", event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
MYSQL_ROW dbrow = mysql_fetch_row(result);
|
MYSQL_ROW dbrow = mysql_fetch_row(result);
|
||||||
|
@ -334,7 +334,10 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
||||||
curr_frame_id = 1;
|
curr_frame_id = 1;
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "mode is %s, current frame is %ld, frame count is %ld, last frame id is %ld",
|
Debug(1, "mode is %s, current frame is %ld, frame count is %ld, last frame id is %ld",
|
||||||
StreamMode_Strings[(int)mode].c_str(), curr_frame_id, event_data->frame_count );
|
StreamMode_Strings[(int) mode].c_str(),
|
||||||
|
curr_frame_id,
|
||||||
|
event_data->frame_count,
|
||||||
|
event_data->last_frame_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
replay_rate = ZM_RATE_BASE;
|
replay_rate = ZM_RATE_BASE;
|
||||||
|
@ -389,7 +392,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
||||||
step = 1;
|
step = 1;
|
||||||
if ( (unsigned int)curr_frame_id < event_data->last_frame_id )
|
if ( (unsigned int)curr_frame_id < event_data->last_frame_id )
|
||||||
curr_frame_id += 1;
|
curr_frame_id += 1;
|
||||||
Debug(1, "Got SLOWFWD command new frame id %d", curr_frame_id);
|
Debug(1, "Got SLOWFWD command new frame id %ld", curr_frame_id);
|
||||||
break;
|
break;
|
||||||
case CMD_SLOWREV :
|
case CMD_SLOWREV :
|
||||||
paused = true;
|
paused = true;
|
||||||
|
@ -397,7 +400,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
||||||
step = -1;
|
step = -1;
|
||||||
curr_frame_id -= 1;
|
curr_frame_id -= 1;
|
||||||
if ( curr_frame_id < 1 ) curr_frame_id = 1;
|
if ( curr_frame_id < 1 ) curr_frame_id = 1;
|
||||||
Debug(1, "Got SLOWREV command new frame id %d", curr_frame_id);
|
Debug(1, "Got SLOWREV command new frame id %ld", curr_frame_id);
|
||||||
break;
|
break;
|
||||||
case CMD_FASTREV :
|
case CMD_FASTREV :
|
||||||
Debug(1, "Got FAST REV command");
|
Debug(1, "Got FAST REV command");
|
||||||
|
@ -526,7 +529,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_stream_time = event_data->frames[curr_frame_id-1].timestamp;
|
curr_stream_time = event_data->frames[curr_frame_id-1].timestamp;
|
||||||
Debug(1, "Got SEEK command, to %f (new current frame id: %d offset %f)",
|
Debug(1, "Got SEEK command, to %f (new current frame id: %ld offset %f)",
|
||||||
offset, curr_frame_id, event_data->frames[curr_frame_id-1].offset);
|
offset, curr_frame_id, event_data->frames[curr_frame_id-1].offset);
|
||||||
send_frame = true;
|
send_frame = true;
|
||||||
break;
|
break;
|
||||||
|
@ -569,7 +572,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
||||||
DataMsg status_msg;
|
DataMsg status_msg;
|
||||||
status_msg.msg_type = MSG_DATA_EVENT;
|
status_msg.msg_type = MSG_DATA_EVENT;
|
||||||
memcpy(&status_msg.msg_data, &status_data, sizeof(status_data));
|
memcpy(&status_msg.msg_data, &status_data, sizeof(status_data));
|
||||||
Debug(1, "Size of msg %d", sizeof(status_data));
|
Debug(1, "Size of msg %zu", sizeof(status_data));
|
||||||
if ( sendto(sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr)) < 0 ) {
|
if ( sendto(sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr)) < 0 ) {
|
||||||
//if ( errno != EAGAIN )
|
//if ( errno != EAGAIN )
|
||||||
{
|
{
|
||||||
|
@ -604,7 +607,7 @@ bool EventStream::checkEventLoaded() {
|
||||||
event_data->monitor_id, event_data->event_id);
|
event_data->monitor_id, event_data->event_id);
|
||||||
} else {
|
} else {
|
||||||
// No event change required
|
// No event change required
|
||||||
Debug(3, "No event change required, as curr frame %d <=> event frames %d",
|
Debug(3, "No event change required, as curr frame %ld <=> event frames %lu",
|
||||||
curr_frame_id, event_data->frame_count);
|
curr_frame_id, event_data->frame_count);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +641,7 @@ bool EventStream::checkEventLoaded() {
|
||||||
curr_frame_id = event_data->last_frame_id;
|
curr_frame_id = event_data->last_frame_id;
|
||||||
else
|
else
|
||||||
curr_frame_id = 1;
|
curr_frame_id = 1;
|
||||||
Debug(2, "New frame id = %d", curr_frame_id);
|
Debug(2, "New frame id = %ld", curr_frame_id);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Debug(2, "No next event loaded using %s. Pausing", sql.c_str());
|
Debug(2, "No next event loaded using %s. Pausing", sql.c_str());
|
||||||
|
@ -666,13 +669,13 @@ Image * EventStream::getImage( ) {
|
||||||
static char filepath[PATH_MAX];
|
static char filepath[PATH_MAX];
|
||||||
|
|
||||||
snprintf(filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id);
|
snprintf(filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id);
|
||||||
Debug(2, "EventStream::getImage path(%s) from %s frame(%d) ", filepath, event_data->path, curr_frame_id);
|
Debug(2, "EventStream::getImage path(%s) from %s frame(%ld) ", filepath, event_data->path, curr_frame_id);
|
||||||
Image *image = new Image(filepath);
|
Image *image = new Image(filepath);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventStream::sendFrame(int delta_us) {
|
bool EventStream::sendFrame(int delta_us) {
|
||||||
Debug(2, "Sending frame %d", curr_frame_id);
|
Debug(2, "Sending frame %ld", curr_frame_id);
|
||||||
|
|
||||||
static char filepath[PATH_MAX];
|
static char filepath[PATH_MAX];
|
||||||
static struct stat filestat;
|
static struct stat filestat;
|
||||||
|
@ -856,7 +859,7 @@ void EventStream::runStream() {
|
||||||
|
|
||||||
if ( !paused ) {
|
if ( !paused ) {
|
||||||
// Figure out if we should send this frame
|
// Figure out if we should send this frame
|
||||||
Debug(3, "not paused at cur_frame_id (%d-1) mod frame_mod(%d)", curr_frame_id, frame_mod);
|
Debug(3, "not paused at cur_frame_id (%ld-1) mod frame_mod(%d)", curr_frame_id, frame_mod);
|
||||||
// If we are streaming and this frame is due to be sent
|
// If we are streaming and this frame is due to be sent
|
||||||
// frame mod defaults to 1 and if we are going faster than max_fps will get multiplied by 2
|
// frame mod defaults to 1 and if we are going faster than max_fps will get multiplied by 2
|
||||||
// so if it is 2, then we send every other frame, if is it 4 then every fourth frame, etc.
|
// so if it is 2, then we send every other frame, if is it 4 then every fourth frame, etc.
|
||||||
|
@ -964,8 +967,8 @@ void EventStream::runStream() {
|
||||||
// We assume that we are going forward and the next frame is in the future.
|
// We assume that we are going forward and the next frame is in the future.
|
||||||
delta_us = frame_data->offset * 1000000 - (now_usec-start_usec);
|
delta_us = frame_data->offset * 1000000 - (now_usec-start_usec);
|
||||||
// - (now_usec - start_usec);
|
// - (now_usec - start_usec);
|
||||||
Debug(2, "New delta_us now %" PRIu64 " - start %" PRIu64 " = %d offset %" PRId64 " - elapsed = %dusec",
|
Debug(2, "New delta_us now %" PRIu64 " - start %" PRIu64 " = %" PRIu64 " offset %f - elapsed = %dusec",
|
||||||
now_usec, start_usec, now_usec-start_usec, frame_data->offset * 1000000, delta_us);
|
now_usec, start_usec, static_cast<uint64>(now_usec - start_usec), frame_data->offset * 1000000, delta_us);
|
||||||
} else {
|
} else {
|
||||||
Debug(2, "No last frame_offset, no sleep");
|
Debug(2, "No last frame_offset, no sleep");
|
||||||
delta_us = 0;
|
delta_us = 0;
|
||||||
|
@ -1054,12 +1057,12 @@ bool EventStream::send_file(const char *filepath) {
|
||||||
}
|
}
|
||||||
if ( !filestat.st_size ) {
|
if ( !filestat.st_size ) {
|
||||||
fclose(fdj); /* Close the file handle */
|
fclose(fdj); /* Close the file handle */
|
||||||
Info("File size is zero. Unable to send raw frame %u: %s", curr_frame_id);
|
Info("File size is zero. Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size) ) {
|
if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size) ) {
|
||||||
fclose(fdj); /* Close the file handle */
|
fclose(fdj); /* Close the file handle */
|
||||||
Info("Unable to send raw frame %u: %s", curr_frame_id, strerror(errno));
|
Info("Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int rc = zm_sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size);
|
int rc = zm_sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size);
|
||||||
|
@ -1068,12 +1071,12 @@ bool EventStream::send_file(const char *filepath) {
|
||||||
fclose(fdj); /* Close the file handle */
|
fclose(fdj); /* Close the file handle */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Warning("Unable to send raw frame %u: %s rc %d", curr_frame_id, strerror(errno), rc);
|
Warning("Unable to send raw frame %ld: %s rc %d", curr_frame_id, strerror(errno), rc);
|
||||||
#endif
|
#endif
|
||||||
img_buffer_size = fread(img_buffer, 1, sizeof(temp_img_buffer), fdj);
|
img_buffer_size = fread(img_buffer, 1, sizeof(temp_img_buffer), fdj);
|
||||||
fclose(fdj); /* Close the file handle */
|
fclose(fdj); /* Close the file handle */
|
||||||
if ( !img_buffer_size ) {
|
if ( !img_buffer_size ) {
|
||||||
Info("Unable to read raw frame %u: %s", curr_frame_id, strerror(errno));
|
Info("Unable to read raw frame %ld: %s", curr_frame_id, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,13 +1085,13 @@ bool EventStream::send_file(const char *filepath) {
|
||||||
|
|
||||||
bool EventStream::send_buffer(uint8_t* buffer, int size) {
|
bool EventStream::send_buffer(uint8_t* buffer, int size) {
|
||||||
if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", size) ) {
|
if ( 0 > fprintf(stdout, "Content-Length: %d\r\n\r\n", size) ) {
|
||||||
Info("Unable to send raw frame %u: %s", curr_frame_id, strerror(errno));
|
Info("Unable to send raw frame %ld: %s", curr_frame_id, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int rc = fwrite(buffer, size, 1, stdout);
|
int rc = fwrite(buffer, size, 1, stdout);
|
||||||
|
|
||||||
if ( 1 != rc ) {
|
if ( 1 != rc ) {
|
||||||
Error("Unable to send raw frame %u: %s %d", curr_frame_id, strerror(errno), rc);
|
Error("Unable to send raw frame %ld: %s %d", curr_frame_id, strerror(errno), rc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) {
|
||||||
if (static_cast<size_t>(length) > sizeof(logString)-1) length = sizeof(logString)-1;
|
if (static_cast<size_t>(length) > sizeof(logString)-1) length = sizeof(logString)-1;
|
||||||
// ffmpeg logs have a carriage return, so replace it with terminator
|
// ffmpeg logs have a carriage return, so replace it with terminator
|
||||||
logString[length-1] = 0;
|
logString[length-1] = 0;
|
||||||
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
|
log->logPrint(false, __FILE__, __LINE__, log_level, "%s", logString);
|
||||||
} else {
|
} else {
|
||||||
log->logPrint(false, __FILE__, __LINE__, AV_LOG_ERROR, "Can't encode log from av. fmt was %s", fmt);
|
log->logPrint(false, __FILE__, __LINE__, AV_LOG_ERROR, "Can't encode log from av. fmt was %s", fmt);
|
||||||
}
|
}
|
||||||
|
@ -636,8 +636,7 @@ int zm_resample_audio(
|
||||||
av_make_error_string(ret).c_str());
|
av_make_error_string(ret).c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Debug(3,"swr_get_delay %d",
|
Debug(3, "swr_get_delay %" PRIi64, swr_get_delay(resample_ctx, out_frame->sample_rate));
|
||||||
swr_get_delay(resample_ctx, out_frame->sample_rate));
|
|
||||||
#else
|
#else
|
||||||
#if defined(HAVE_LIBAVRESAMPLE)
|
#if defined(HAVE_LIBAVRESAMPLE)
|
||||||
if (!in_frame) {
|
if (!in_frame) {
|
||||||
|
|
|
@ -308,15 +308,13 @@ void zm_dump_codec(const AVCodecContext *codec);
|
||||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||||
void zm_dump_codecpar(const AVCodecParameters *par);
|
void zm_dump_codecpar(const AVCodecParameters *par);
|
||||||
#endif
|
#endif
|
||||||
#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d channels %d" \
|
#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \
|
||||||
" duration %" PRId64 \
|
" layout %" PRIu64 " pts %" PRId64, \
|
||||||
" layout %d pts %" PRId64, \
|
|
||||||
text, \
|
text, \
|
||||||
frame->format, \
|
frame->format, \
|
||||||
av_get_sample_fmt_name((AVSampleFormat)frame->format), \
|
av_get_sample_fmt_name((AVSampleFormat)frame->format), \
|
||||||
frame->sample_rate, \
|
frame->sample_rate, \
|
||||||
frame->nb_samples, \
|
frame->nb_samples, \
|
||||||
0, 0, \
|
|
||||||
frame->channel_layout, \
|
frame->channel_layout, \
|
||||||
frame->pts \
|
frame->pts \
|
||||||
);
|
);
|
||||||
|
|
|
@ -623,7 +623,9 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) {
|
||||||
}
|
}
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
if (now - start_read_time > 10) {
|
if (now - start_read_time > 10) {
|
||||||
Debug(1, "timeout in ffmpeg camera now %d - %d > 10", now, start_read_time);
|
Debug(1, "timeout in ffmpeg camera now %" PRIi64 " - %" PRIi64 " > 10",
|
||||||
|
static_cast<int64>(now),
|
||||||
|
static_cast<int64>(start_read_time));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -647,7 +647,7 @@ void Image::AssignDirect(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int new_buffer_size = p_width * p_height * p_colours;
|
size_t new_buffer_size = p_width * p_height * p_colours;
|
||||||
|
|
||||||
if ( buffer_size < new_buffer_size ) {
|
if ( buffer_size < new_buffer_size ) {
|
||||||
Error("Attempt to directly assign buffer from an undersized buffer of size: %zu, needed %dx%d*%d colours = %zu",
|
Error("Attempt to directly assign buffer from an undersized buffer of size: %zu, needed %dx%d*%d colours = %zu",
|
||||||
|
|
|
@ -227,11 +227,11 @@ int LibvlcCamera::PrimeCapture() {
|
||||||
|
|
||||||
if ( opVect.size() > 0 ) {
|
if ( opVect.size() > 0 ) {
|
||||||
mOptArgV = new char*[opVect.size()];
|
mOptArgV = new char*[opVect.size()];
|
||||||
Debug(2, "Number of Options: %d",opVect.size());
|
Debug(2, "Number of Options: %zu", opVect.size());
|
||||||
for (size_t i=0; i< opVect.size(); i++) {
|
for (size_t i=0; i< opVect.size(); i++) {
|
||||||
opVect[i] = TrimSpaces(opVect[i]);
|
opVect[i] = TrimSpaces(opVect[i]);
|
||||||
mOptArgV[i] = (char *)opVect[i].c_str();
|
mOptArgV[i] = (char *)opVect[i].c_str();
|
||||||
Debug(2, "set option %d to '%s'", i, opVect[i].c_str());
|
Debug(2, "set option %zu to '%s'", i, opVect[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,8 +320,8 @@ void LibvlcCamera::log_callback(void *ptr, int level, const libvlc_log_t *ctx, c
|
||||||
|
|
||||||
if ( log ) {
|
if ( log ) {
|
||||||
char logString[8192];
|
char logString[8192];
|
||||||
vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
|
vsnprintf(logString, sizeof(logString) - 1, fmt, vargs);
|
||||||
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
|
log->logPrint(false, __FILE__, __LINE__, log_level, "%s", logString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_LIBVLC
|
#endif // HAVE_LIBVLC
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void GotFrameBufferUpdateCallback(rfbClient *rfb, int x, int y, int w, in
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* GetPasswordCallback(rfbClient* cl) {
|
static char* GetPasswordCallback(rfbClient* cl) {
|
||||||
Debug(1, "Getcredentials: %s", (*rfbClientGetClientData_f)(cl, &TAG_1));
|
Debug(1, "Getcredentials: %s", static_cast<char *>((*rfbClientGetClientData_f)(cl, &TAG_1)));
|
||||||
return strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1));
|
return strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,9 @@ static rfbCredential* GetCredentialsCallback(rfbClient* cl, int credentialType){
|
||||||
}
|
}
|
||||||
rfbCredential *c = (rfbCredential *)malloc(sizeof(rfbCredential));
|
rfbCredential *c = (rfbCredential *)malloc(sizeof(rfbCredential));
|
||||||
|
|
||||||
Debug(1, "Getcredentials: %s:%s", (*rfbClientGetClientData_f)(cl, &TAG_1), (*rfbClientGetClientData_f)(cl, &TAG_2));
|
Debug(1, "Getcredentials: %s:%s",
|
||||||
|
static_cast<char *>((*rfbClientGetClientData_f)(cl, &TAG_1)),
|
||||||
|
static_cast<char *>((*rfbClientGetClientData_f)(cl, &TAG_2)));
|
||||||
c->userCredential.password = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1));
|
c->userCredential.password = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_1));
|
||||||
c->userCredential.username = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_2));
|
c->userCredential.username = strdup((const char *)(*rfbClientGetClientData_f)(cl, &TAG_2));
|
||||||
return c;
|
return c;
|
||||||
|
|
|
@ -665,7 +665,7 @@ LocalCamera::LocalCamera(
|
||||||
unsigned int pSize = avpicture_get_size(imagePixFormat, width, height);
|
unsigned int pSize = avpicture_get_size(imagePixFormat, width, height);
|
||||||
#endif
|
#endif
|
||||||
if ( pSize != imagesize ) {
|
if ( pSize != imagesize ) {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %u", pSize, imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
imgConversionContext = sws_getContext(
|
imgConversionContext = sws_getContext(
|
||||||
|
|
|
@ -415,7 +415,7 @@ void Logger::closeSyslog() {
|
||||||
(void) closelog();
|
(void) closelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...) {
|
void Logger::logPrint(bool hex, const char *filepath, int line, int level, const char *fstring, ...) {
|
||||||
if (level > mEffectiveLevel) return;
|
if (level > mEffectiveLevel) return;
|
||||||
if (level < PANIC || level > DEBUG9)
|
if (level < PANIC || level > DEBUG9)
|
||||||
Panic("Invalid logger level %d", level);
|
Panic("Invalid logger level %d", level);
|
||||||
|
|
|
@ -173,8 +173,13 @@ private:
|
||||||
void closeSyslog();
|
void closeSyslog();
|
||||||
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 *filepath,
|
||||||
|
int line,
|
||||||
|
int level,
|
||||||
|
const char *fstring,
|
||||||
|
...) __attribute__((format(printf, 6, 7)));
|
||||||
};
|
};
|
||||||
|
|
||||||
void logInit(const char *name, const Logger::Options &options=Logger::Options());
|
void logInit(const char *name, const Logger::Options &options=Logger::Options());
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool Monitor::MonitorLink::connect() {
|
||||||
|
|
||||||
mem_size = sizeof(SharedData) + sizeof(TriggerData);
|
mem_size = sizeof(SharedData) + sizeof(TriggerData);
|
||||||
|
|
||||||
Debug(1, "link.mem.size=%d", mem_size);
|
Debug(1, "link.mem.size=%jd", mem_size);
|
||||||
#if ZM_MEM_MAPPED
|
#if ZM_MEM_MAPPED
|
||||||
map_fd = open(mem_file, O_RDWR, (mode_t)0600);
|
map_fd = open(mem_file, O_RDWR, (mode_t)0600);
|
||||||
if ( map_fd < 0 ) {
|
if ( map_fd < 0 ) {
|
||||||
|
@ -175,14 +175,14 @@ bool Monitor::MonitorLink::connect() {
|
||||||
disconnect();
|
disconnect();
|
||||||
return false;
|
return false;
|
||||||
} else if ( map_stat.st_size < mem_size ) {
|
} else if ( map_stat.st_size < mem_size ) {
|
||||||
Error("Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size);
|
Error("Got unexpected memory map file size %ld, expected %jd", map_stat.st_size, mem_size);
|
||||||
disconnect();
|
disconnect();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
||||||
if ( mem_ptr == MAP_FAILED ) {
|
if ( mem_ptr == MAP_FAILED ) {
|
||||||
Error("Can't map file %s (%d bytes) to memory: %s", mem_file, mem_size, strerror(errno));
|
Error("Can't map file %s (%jd bytes) to memory: %s", mem_file, mem_size, strerror(errno));
|
||||||
disconnect();
|
disconnect();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -632,11 +632,16 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
|
||||||
+ (image_buffer_count * image_size)
|
+ (image_buffer_count * image_size)
|
||||||
+ 64; /* Padding used to permit aligning the images buffer to 64 byte boundary */
|
+ 64; /* Padding used to permit aligning the images buffer to 64 byte boundary */
|
||||||
|
|
||||||
Debug(1, "mem.size(%d) SharedData=%d TriggerData=%d VideoStoreData=%d timestamps=%d images=%dx%d = %" PRId64 " total=%" PRId64,
|
Debug(1,
|
||||||
|
"mem.size(%zu) SharedData=%zu TriggerData=%zu VideoStoreData=%zu timestamps=%zu images=%dx%" PRIi64 " = %" PRId64 " total=%jd",
|
||||||
sizeof(mem_size),
|
sizeof(mem_size),
|
||||||
sizeof(SharedData), sizeof(TriggerData), sizeof(VideoStoreData),
|
sizeof(SharedData),
|
||||||
(image_buffer_count*sizeof(struct timeval)),
|
sizeof(TriggerData),
|
||||||
image_buffer_count, image_size, (image_buffer_count*image_size),
|
sizeof(VideoStoreData),
|
||||||
|
(image_buffer_count * sizeof(struct timeval)),
|
||||||
|
image_buffer_count,
|
||||||
|
image_size,
|
||||||
|
(image_buffer_count * image_size),
|
||||||
mem_size);
|
mem_size);
|
||||||
|
|
||||||
// Should maybe store this for later use
|
// Should maybe store this for later use
|
||||||
|
@ -675,7 +680,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
|
||||||
}
|
}
|
||||||
} // end if purpose
|
} // end if purpose
|
||||||
|
|
||||||
Debug(1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), zones.size());
|
Debug(1, "Loaded monitor %d(%s), %zu zones", id, name.c_str(), zones.size());
|
||||||
} // Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY)
|
} // Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY)
|
||||||
|
|
||||||
void Monitor::LoadCamera() {
|
void Monitor::LoadCamera() {
|
||||||
|
@ -927,18 +932,18 @@ bool Monitor::connect() {
|
||||||
if (purpose == CAPTURE) {
|
if (purpose == CAPTURE) {
|
||||||
// Allocate the size
|
// Allocate the size
|
||||||
if (ftruncate(map_fd, mem_size) < 0) {
|
if (ftruncate(map_fd, mem_size) < 0) {
|
||||||
Error("Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno));
|
Error("Can't extend memory map file %s to %jd bytes: %s", mem_file, mem_size, strerror(errno));
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
map_fd = -1;
|
map_fd = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (map_stat.st_size == 0) {
|
} else if (map_stat.st_size == 0) {
|
||||||
Error("Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size);
|
Error("Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
map_fd = -1;
|
map_fd = -1;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Error("Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size);
|
Error("Got unexpected memory map file size %ld, expected %jd", map_stat.st_size, mem_size);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
map_fd = -1;
|
map_fd = -1;
|
||||||
return false;
|
return false;
|
||||||
|
@ -950,18 +955,18 @@ bool Monitor::connect() {
|
||||||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0);
|
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0);
|
||||||
if (mem_ptr == MAP_FAILED) {
|
if (mem_ptr == MAP_FAILED) {
|
||||||
if (errno == EAGAIN) {
|
if (errno == EAGAIN) {
|
||||||
Debug(1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size);
|
Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file, mem_size);
|
||||||
#endif
|
#endif
|
||||||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
||||||
Debug(1, "Mapped file %s (%d bytes) to unlocked memory", mem_file, mem_size);
|
Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file, mem_size);
|
||||||
#ifdef MAP_LOCKED
|
#ifdef MAP_LOCKED
|
||||||
} else {
|
} else {
|
||||||
Error("Unable to map file %s (%d bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno));
|
Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((mem_ptr == MAP_FAILED) or (mem_ptr == nullptr)) {
|
if ((mem_ptr == MAP_FAILED) or (mem_ptr == nullptr)) {
|
||||||
Error("Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno);
|
Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
map_fd = -1;
|
map_fd = -1;
|
||||||
mem_ptr = nullptr;
|
mem_ptr = nullptr;
|
||||||
|
@ -1723,10 +1728,14 @@ void Monitor::UpdateAnalysisFPS() {
|
||||||
gettimeofday(&now, nullptr);
|
gettimeofday(&now, nullptr);
|
||||||
double now_double = (double)now.tv_sec + (0.000001f * now.tv_usec);
|
double now_double = (double)now.tv_sec + (0.000001f * now.tv_usec);
|
||||||
double elapsed = now_double - last_analysis_fps_time;
|
double elapsed = now_double - last_analysis_fps_time;
|
||||||
Debug(4, "%s: %d - now:%d.%d = %lf, last %lf, diff %lf", name.c_str(), analysis_image_count,
|
Debug(4, "%s: %d - now:%" PRIi64 ".%" PRIi64 " = %lf, last %lf, diff %lf",
|
||||||
now.tv_sec, now.tv_usec, now_double, last_analysis_fps_time,
|
name.c_str(),
|
||||||
elapsed
|
analysis_image_count,
|
||||||
);
|
static_cast<int64>(now.tv_sec),
|
||||||
|
static_cast<int64>(now.tv_usec),
|
||||||
|
now_double,
|
||||||
|
last_analysis_fps_time,
|
||||||
|
elapsed);
|
||||||
|
|
||||||
if ( elapsed > 1.0 ) {
|
if ( elapsed > 1.0 ) {
|
||||||
double new_analysis_fps = double(motion_frame_count - last_motion_frame_count) / elapsed;
|
double new_analysis_fps = double(motion_frame_count - last_motion_frame_count) / elapsed;
|
||||||
|
@ -1970,12 +1979,14 @@ bool Monitor::Analyse() {
|
||||||
|| ! ( timestamp->tv_sec % section_length )
|
|| ! ( timestamp->tv_sec % section_length )
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %d - %d = %d >= %d",
|
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %d",
|
||||||
name.c_str(), image_count, event->Id(),
|
name.c_str(),
|
||||||
timestamp->tv_sec, video_store_data->recording.tv_sec,
|
image_count,
|
||||||
timestamp->tv_sec - video_store_data->recording.tv_sec,
|
event->Id(),
|
||||||
section_length
|
static_cast<int64>(timestamp->tv_sec),
|
||||||
);
|
static_cast<int64>(video_store_data->recording.tv_sec),
|
||||||
|
static_cast<int64>(timestamp->tv_sec - video_store_data->recording.tv_sec),
|
||||||
|
section_length);
|
||||||
closeEvent();
|
closeEvent();
|
||||||
} // end if section_length
|
} // end if section_length
|
||||||
} // end if event
|
} // end if event
|
||||||
|
@ -2062,10 +2073,13 @@ bool Monitor::Analyse() {
|
||||||
closeEvent();
|
closeEvent();
|
||||||
} else if (event) {
|
} else if (event) {
|
||||||
// This is so if we need more than 1 alarm frame before going into alarm, so it is basically if we have enough alarm frames
|
// This is so if we need more than 1 alarm frame before going into alarm, so it is basically if we have enough alarm frames
|
||||||
Debug(3, "pre_alarm_count in event %d, event frames %d, alarm frames %d event length %d >=? %d min",
|
Debug(3,
|
||||||
Event::PreAlarmCount(), event->Frames(), event->AlarmFrames(),
|
"pre_alarm_count in event %d, event frames %d, alarm frames %d event length %" PRIi64 " >=? %d min",
|
||||||
( timestamp->tv_sec - video_store_data->recording.tv_sec ), min_section_length
|
Event::PreAlarmCount(),
|
||||||
);
|
event->Frames(),
|
||||||
|
event->AlarmFrames(),
|
||||||
|
static_cast<int64>(timestamp->tv_sec - video_store_data->recording.tv_sec),
|
||||||
|
min_section_length);
|
||||||
}
|
}
|
||||||
if ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count-1)) {
|
if ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count-1)) {
|
||||||
// lets construct alarm cause. It will contain cause + names of zones alarmed
|
// lets construct alarm cause. It will contain cause + names of zones alarmed
|
||||||
|
@ -2183,9 +2197,15 @@ bool Monitor::Analyse() {
|
||||||
// Back to IDLE
|
// Back to IDLE
|
||||||
shared_data->state = state = ((function != MOCORD) ? IDLE : TAPE);
|
shared_data->state = state = ((function != MOCORD) ? IDLE : TAPE);
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "State %s because image_count(%d)-last_alarm_count(%d) > post_event_count(%d) and timestamp.tv_sec(%d) - recording.tv_src(%d) >= min_section_length(%d)",
|
Debug(1,
|
||||||
State_Strings[state].c_str(), analysis_image_count, last_alarm_count, post_event_count,
|
"State %s because image_count(%d)-last_alarm_count(%d) > post_event_count(%d) and timestamp.tv_sec(%" PRIi64 ") - recording.tv_src(%" PRIi64 ") >= min_section_length(%d)",
|
||||||
timestamp->tv_sec, video_store_data->recording.tv_sec, min_section_length);
|
State_Strings[state].c_str(),
|
||||||
|
analysis_image_count,
|
||||||
|
last_alarm_count,
|
||||||
|
post_event_count,
|
||||||
|
static_cast<int64>(timestamp->tv_sec),
|
||||||
|
static_cast<int64>(video_store_data->recording.tv_sec),
|
||||||
|
min_section_length);
|
||||||
}
|
}
|
||||||
if (Event::PreAlarmCount())
|
if (Event::PreAlarmCount())
|
||||||
Event::EmptyPreAlarmFrames();
|
Event::EmptyPreAlarmFrames();
|
||||||
|
@ -2226,12 +2246,11 @@ bool Monitor::Analyse() {
|
||||||
if ( section_length
|
if ( section_length
|
||||||
&& ( ( timestamp->tv_sec - video_store_data->recording.tv_sec ) >= section_length )
|
&& ( ( timestamp->tv_sec - video_store_data->recording.tv_sec ) >= section_length )
|
||||||
) {
|
) {
|
||||||
Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %d - %d = %d >= %d",
|
Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %d",
|
||||||
name.c_str(), analysis_image_count, event->Id(),
|
name.c_str(), analysis_image_count, event->Id(),
|
||||||
timestamp->tv_sec, video_store_data->recording.tv_sec,
|
static_cast<int64>(timestamp->tv_sec), static_cast<int64>(video_store_data->recording.tv_sec),
|
||||||
timestamp->tv_sec - video_store_data->recording.tv_sec,
|
static_cast<int64>(timestamp->tv_sec - video_store_data->recording.tv_sec),
|
||||||
section_length
|
section_length);
|
||||||
);
|
|
||||||
closeEvent();
|
closeEvent();
|
||||||
event = new Event(this, *timestamp, cause, noteSetMap);
|
event = new Event(this, *timestamp, cause, noteSetMap);
|
||||||
shared_data->last_event_id = event->Id();
|
shared_data->last_event_id = event->Id();
|
||||||
|
@ -2324,9 +2343,9 @@ void Monitor::Reload() {
|
||||||
} // end void Monitor::Reload()
|
} // end void Monitor::Reload()
|
||||||
|
|
||||||
void Monitor::ReloadZones() {
|
void Monitor::ReloadZones() {
|
||||||
Debug(3, "Reloading zones for monitor %s have %u", name.c_str(), zones.size());
|
Debug(3, "Reloading zones for monitor %s have %zu", name.c_str(), zones.size());
|
||||||
zones = Zone::Load(this);
|
zones = Zone::Load(this);
|
||||||
Debug(1, "Reloading zones for monitor %s have %u", name.c_str(), zones.size());
|
Debug(1, "Reloading zones for monitor %s have %zu", name.c_str(), zones.size());
|
||||||
this->AddPrivacyBitmask();
|
this->AddPrivacyBitmask();
|
||||||
//DumpZoneImage();
|
//DumpZoneImage();
|
||||||
} // end void Monitor::ReloadZones()
|
} // end void Monitor::ReloadZones()
|
||||||
|
@ -3144,8 +3163,8 @@ void Monitor::get_ref_image() {
|
||||||
)
|
)
|
||||||
and !zm_terminate) {
|
and !zm_terminate) {
|
||||||
|
|
||||||
Debug(1, "Waiting for capture daemon lastwriteindex(%d) lastwritetime(%d)",
|
Debug(1, "Waiting for capture daemon lastwriteindex(%d) lastwritetime(%" PRIi64 ")",
|
||||||
shared_data->last_write_index, shared_data->last_write_time);
|
shared_data->last_write_index, static_cast<int64>(shared_data->last_write_time));
|
||||||
if ( snap_lock and ! snap_lock->packet_->image ) {
|
if ( snap_lock and ! snap_lock->packet_->image ) {
|
||||||
delete snap_lock;
|
delete snap_lock;
|
||||||
// can't analyse it anyways, incremement
|
// can't analyse it anyways, incremement
|
||||||
|
|
|
@ -439,10 +439,14 @@ public:
|
||||||
|
|
||||||
inline int ShmValid() const {
|
inline int ShmValid() const {
|
||||||
if ( shared_data && shared_data->valid ) {
|
if ( shared_data && shared_data->valid ) {
|
||||||
struct timeval now;
|
timeval now = {};
|
||||||
gettimeofday(&now, nullptr);
|
gettimeofday(&now, nullptr);
|
||||||
Debug(3, "Shared data is valid, checking heartbeat %u - %u = %d < %f",
|
Debug(3, "Shared data is valid, checking heartbeat %" PRIi64 " - %" PRIi64 " = %" PRIi64" < %f",
|
||||||
now.tv_sec, shared_data->zmc_heartbeat_time, (now.tv_sec - shared_data->zmc_heartbeat_time), config.watch_max_delay);
|
static_cast<int64>(now.tv_sec),
|
||||||
|
static_cast<int64>(shared_data->zmc_heartbeat_time),
|
||||||
|
static_cast<int64>(now.tv_sec - shared_data->zmc_heartbeat_time),
|
||||||
|
config.watch_max_delay);
|
||||||
|
|
||||||
if ((now.tv_sec - shared_data->zmc_heartbeat_time) < config.watch_max_delay)
|
if ((now.tv_sec - shared_data->zmc_heartbeat_time) < config.watch_max_delay)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -795,14 +795,17 @@ void MonitorStream::runStream() {
|
||||||
if ( sleep_time > MonitorStream::MAX_SLEEP_USEC ) {
|
if ( sleep_time > MonitorStream::MAX_SLEEP_USEC ) {
|
||||||
// Shouldn't sleep for long because we need to check command queue, etc.
|
// Shouldn't sleep for long because we need to check command queue, etc.
|
||||||
sleep_time = MonitorStream::MAX_SLEEP_USEC;
|
sleep_time = MonitorStream::MAX_SLEEP_USEC;
|
||||||
Debug(3, "Sleeping for MAX_SLEEP_USEC %dus", sleep_time);
|
Debug(3, "Sleeping for MAX_SLEEP_USEC %luus", sleep_time);
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "Sleeping for %dus", sleep_time);
|
Debug(3, "Sleeping for %luus", sleep_time);
|
||||||
}
|
}
|
||||||
usleep(sleep_time);
|
usleep(sleep_time);
|
||||||
if ( ttl ) {
|
if ( ttl ) {
|
||||||
if ( (now.tv_sec - stream_start_time) > ttl ) {
|
if ( (now.tv_sec - stream_start_time) > ttl ) {
|
||||||
Debug(2, "now(%d) - start(%d) > ttl(%d) break", now.tv_sec, stream_start_time, ttl);
|
Debug(2, "now(%" PRIi64 ") - start(%" PRIi64 " ) > ttl(%" PRIi64 ") break",
|
||||||
|
static_cast<int64>(now.tv_sec),
|
||||||
|
static_cast<int64>(stream_start_time),
|
||||||
|
static_cast<int64>(ttl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ void VideoStream::SetupFormat( ) {
|
||||||
ofc = s;
|
ofc = s;
|
||||||
#endif
|
#endif
|
||||||
if ( !ofc ) {
|
if ( !ofc ) {
|
||||||
Fatal("avformat_alloc_..._context failed: %d", ofc);
|
Fatal("avformat_alloc_..._context failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
of = ofc->oformat;
|
of = ofc->oformat;
|
||||||
|
|
|
@ -121,8 +121,14 @@ bool PacketQueue::queuePacket(ZMPacket* add_packet) {
|
||||||
|
|
||||||
pktQueue.pop_front();
|
pktQueue.pop_front();
|
||||||
packet_counts[zm_packet->packet.stream_index] -= 1;
|
packet_counts[zm_packet->packet.stream_index] -= 1;
|
||||||
Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d",
|
Debug(1,
|
||||||
zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], max_video_packet_count, pktQueue.size());
|
"Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu",
|
||||||
|
zm_packet->packet.stream_index,
|
||||||
|
zm_packet->image_index,
|
||||||
|
zm_packet->keyframe,
|
||||||
|
packet_counts[video_stream_id],
|
||||||
|
max_video_packet_count,
|
||||||
|
pktQueue.size());
|
||||||
delete zm_packet;
|
delete zm_packet;
|
||||||
} // end while
|
} // end while
|
||||||
}
|
}
|
||||||
|
@ -216,8 +222,14 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) {
|
||||||
|
|
||||||
pktQueue.pop_front();
|
pktQueue.pop_front();
|
||||||
packet_counts[zm_packet->packet.stream_index] -= 1;
|
packet_counts[zm_packet->packet.stream_index] -= 1;
|
||||||
Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d",
|
Debug(1,
|
||||||
zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], pre_event_video_packet_count, pktQueue.size());
|
"Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu",
|
||||||
|
zm_packet->packet.stream_index,
|
||||||
|
zm_packet->image_index,
|
||||||
|
zm_packet->keyframe,
|
||||||
|
packet_counts[video_stream_id],
|
||||||
|
pre_event_video_packet_count,
|
||||||
|
pktQueue.size());
|
||||||
delete zm_packet;
|
delete zm_packet;
|
||||||
} // end while
|
} // end while
|
||||||
return;
|
return;
|
||||||
|
@ -276,8 +288,14 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug(1, "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%d",
|
Debug(1,
|
||||||
zm_packet->packet.stream_index, zm_packet->image_index, zm_packet->keyframe, packet_counts[video_stream_id], pre_event_video_packet_count, pktQueue.size());
|
"Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu",
|
||||||
|
zm_packet->packet.stream_index,
|
||||||
|
zm_packet->image_index,
|
||||||
|
zm_packet->keyframe,
|
||||||
|
packet_counts[video_stream_id],
|
||||||
|
pre_event_video_packet_count,
|
||||||
|
pktQueue.size());
|
||||||
pktQueue.pop_front();
|
pktQueue.pop_front();
|
||||||
packet_counts[zm_packet->packet.stream_index] -= 1;
|
packet_counts[zm_packet->packet.stream_index] -= 1;
|
||||||
delete zm_packet;
|
delete zm_packet;
|
||||||
|
@ -289,7 +307,7 @@ void PacketQueue::clearPackets(ZMPacket *add_packet) {
|
||||||
} // end voidPacketQueue::clearPackets(ZMPacket* zm_packet)
|
} // end voidPacketQueue::clearPackets(ZMPacket* zm_packet)
|
||||||
|
|
||||||
ZMLockedPacket* PacketQueue::popPacket( ) {
|
ZMLockedPacket* PacketQueue::popPacket( ) {
|
||||||
Debug(4, "pktQueue size %d", pktQueue.size());
|
Debug(4, "pktQueue size %zu", pktQueue.size());
|
||||||
if ( pktQueue.empty() ) {
|
if ( pktQueue.empty() ) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +346,7 @@ ZMLockedPacket* PacketQueue::popPacket( ) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) {
|
unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) {
|
||||||
Debug(3, "Clearing all but %d frames, queue has %d", frames_to_keep, pktQueue.size());
|
Debug(3, "Clearing all but %d frames, queue has %zu", frames_to_keep, pktQueue.size());
|
||||||
|
|
||||||
if ( pktQueue.empty() ) {
|
if ( pktQueue.empty() ) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -372,7 +390,7 @@ unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) {
|
||||||
|
|
||||||
// Else not at beginning, are pointing at packet before the last video packet
|
// Else not at beginning, are pointing at packet before the last video packet
|
||||||
while ( pktQueue.begin() != it ) {
|
while ( pktQueue.begin() != it ) {
|
||||||
Debug(4, "Deleting a packet from the front, count is (%d), queue size is %d",
|
Debug(4, "Deleting a packet from the front, count is (%d), queue size is %zu",
|
||||||
delete_count, pktQueue.size());
|
delete_count, pktQueue.size());
|
||||||
zm_packet = pktQueue.front();
|
zm_packet = pktQueue.front();
|
||||||
for (
|
for (
|
||||||
|
@ -394,7 +412,7 @@ unsigned int PacketQueue::clear(unsigned int frames_to_keep, int stream_id) {
|
||||||
|
|
||||||
delete_count += 1;
|
delete_count += 1;
|
||||||
} // while our iterator is not the first packet
|
} // while our iterator is not the first packet
|
||||||
Debug(3, "Deleted %d packets, %d remaining", delete_count, pktQueue.size());
|
Debug(3, "Deleted %d packets, %zu remaining", delete_count, pktQueue.size());
|
||||||
return delete_count;
|
return delete_count;
|
||||||
} // end unsigned int PacketQueue::clear( unsigned int frames_to_keep, int stream_id )
|
} // end unsigned int PacketQueue::clear( unsigned int frames_to_keep, int stream_id )
|
||||||
|
|
||||||
|
@ -446,7 +464,7 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) {
|
||||||
timersub(t, duration, &keep_from);
|
timersub(t, duration, &keep_from);
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
Debug(3, "Looking for frame before queue keep time with stream id (%d), queue has %d packets",
|
Debug(3, "Looking for frame before queue keep time with stream id (%d), queue has %zu packets",
|
||||||
streamId, pktQueue.size());
|
streamId, pktQueue.size());
|
||||||
for ( ; it != pktQueue.rend(); ++it) {
|
for ( ; it != pktQueue.rend(); ++it) {
|
||||||
ZMPacket *zm_packet = *it;
|
ZMPacket *zm_packet = *it;
|
||||||
|
@ -456,10 +474,10 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) {
|
||||||
and
|
and
|
||||||
timercmp(zm_packet->timestamp, &keep_from, <=)
|
timercmp(zm_packet->timestamp, &keep_from, <=)
|
||||||
) {
|
) {
|
||||||
Debug(3, "Found frame before keep time with stream index %d at %d.%d",
|
Debug(3, "Found frame before keep time with stream index %d at %" PRIi64 ".%" PRIi64,
|
||||||
av_packet->stream_index,
|
av_packet->stream_index,
|
||||||
zm_packet->timestamp->tv_sec,
|
static_cast<int64>(zm_packet->timestamp->tv_sec),
|
||||||
zm_packet->timestamp->tv_usec);
|
static_cast<int64>(zm_packet->timestamp->tv_usec));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,10 +497,10 @@ unsigned int PacketQueue::clear(struct timeval *duration, int streamId) {
|
||||||
and
|
and
|
||||||
(av_packet->stream_index == streamId)
|
(av_packet->stream_index == streamId)
|
||||||
) {
|
) {
|
||||||
Debug(3, "Found keyframe before start with stream index %d at %d.%d",
|
Debug(3, "Found keyframe before start with stream index %d at %" PRIi64 ".%" PRIi64,
|
||||||
av_packet->stream_index,
|
av_packet->stream_index,
|
||||||
zm_packet->timestamp->tv_sec,
|
static_cast<int64>(zm_packet->timestamp->tv_sec),
|
||||||
zm_packet->timestamp->tv_usec );
|
static_cast<int64>(zm_packet->timestamp->tv_usec));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,7 +553,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
Debug(4, "Locking in get_packet using it %p queue end? %d, packet %p",
|
Debug(4, "Locking in get_packet using it %p queue end? %d, packet %p",
|
||||||
*it, (*it == pktQueue.end()), *(*it));
|
std::addressof(*it), (*it == pktQueue.end()), *(*it));
|
||||||
std::unique_lock<std::mutex> lck(mutex);
|
std::unique_lock<std::mutex> lck(mutex);
|
||||||
Debug(4, "Have Lock in get_packet");
|
Debug(4, "Have Lock in get_packet");
|
||||||
|
|
||||||
|
@ -544,7 +562,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) {
|
||||||
while (*it == pktQueue.end()) {
|
while (*it == pktQueue.end()) {
|
||||||
if (deleting or zm_terminate)
|
if (deleting or zm_terminate)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
Debug(2, "waiting. Queue size %d it == end? %d", pktQueue.size(), (*it == pktQueue.end()));
|
Debug(2, "waiting. Queue size %zu it == end? %d", pktQueue.size(), (*it == pktQueue.end()));
|
||||||
condition.wait(lck);
|
condition.wait(lck);
|
||||||
}
|
}
|
||||||
if (deleting or zm_terminate)
|
if (deleting or zm_terminate)
|
||||||
|
@ -556,7 +574,7 @@ ZMLockedPacket *PacketQueue::get_packet(packetqueue_iterator *it) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Debug(4, "get_packet using it %p locking index %d, packet %p",
|
Debug(4, "get_packet using it %p locking index %d, packet %p",
|
||||||
*it, p->image_index, p);
|
std::addressof(*it), p->image_index, p);
|
||||||
// Packets are only deleted by packetqueue, so lock must be held.
|
// Packets are only deleted by packetqueue, so lock must be held.
|
||||||
// We shouldn't have to trylock. Someone else might hold the lock but not for long
|
// We shouldn't have to trylock. Someone else might hold the lock but not for long
|
||||||
|
|
||||||
|
@ -579,14 +597,14 @@ void PacketQueue::unlock(ZMLockedPacket *lp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PacketQueue::increment_it(packetqueue_iterator *it) {
|
bool PacketQueue::increment_it(packetqueue_iterator *it) {
|
||||||
Debug(2, "Incrementing %p, queue size %d, end? %d", it, pktQueue.size(), ((*it) == pktQueue.end()));
|
Debug(2, "Incrementing %p, queue size %zu, end? %d", it, pktQueue.size(), ((*it) == pktQueue.end()));
|
||||||
if ((*it) == pktQueue.end() or deleting) {
|
if ((*it) == pktQueue.end() or deleting) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lck(mutex);
|
std::unique_lock<std::mutex> lck(mutex);
|
||||||
++(*it);
|
++(*it);
|
||||||
if (*it != pktQueue.end()) {
|
if (*it != pktQueue.end()) {
|
||||||
Debug(2, "Incrementing %p, %p still not at end %p, so returning true", it, *it, pktQueue.end());
|
Debug(2, "Incrementing %p, %p still not at end, so returning true", it, std::addressof(*it));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Debug(2, "At end");
|
Debug(2, "At end");
|
||||||
|
@ -595,7 +613,7 @@ bool PacketQueue::increment_it(packetqueue_iterator *it) {
|
||||||
|
|
||||||
// Increment it only considering packets for a given stream
|
// Increment it only considering packets for a given stream
|
||||||
bool PacketQueue::increment_it(packetqueue_iterator *it, int stream_id) {
|
bool PacketQueue::increment_it(packetqueue_iterator *it, int stream_id) {
|
||||||
Debug(2, "Incrementing %p, queue size %d, end? %d", it, pktQueue.size(), (*it == pktQueue.end()));
|
Debug(2, "Incrementing %p, queue size %zu, end? %d", it, pktQueue.size(), (*it == pktQueue.end()));
|
||||||
if ( *it == pktQueue.end() ) {
|
if ( *it == pktQueue.end() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -696,7 +714,7 @@ packetqueue_iterator * PacketQueue::get_video_it(bool wait) {
|
||||||
|
|
||||||
if ( wait ) {
|
if ( wait ) {
|
||||||
while ( ((! pktQueue.size()) or (*it == pktQueue.end())) and !zm_terminate and !deleting ) {
|
while ( ((! pktQueue.size()) or (*it == pktQueue.end())) and !zm_terminate and !deleting ) {
|
||||||
Debug(2, "waiting for packets in queue. Queue size %d it == end? %d", pktQueue.size(), ( *it == pktQueue.end() ) );
|
Debug(2, "waiting for packets in queue. Queue size %zu it == end? %d", pktQueue.size(), (*it == pktQueue.end()));
|
||||||
condition.wait(lck);
|
condition.wait(lck);
|
||||||
*it = pktQueue.begin();
|
*it = pktQueue.begin();
|
||||||
}
|
}
|
||||||
|
@ -749,7 +767,7 @@ bool PacketQueue::is_there_an_iterator_pointing_to_packet(ZMPacket *zm_packet) {
|
||||||
if ( *iterator_it == pktQueue.end() ) {
|
if ( *iterator_it == pktQueue.end() ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Debug(4, "Checking iterator %p == packet ? %d", (*iterator_it), ( *(*iterator_it) == zm_packet ));
|
Debug(4, "Checking iterator %p == packet ? %d", std::addressof(*iterator_it), ( *(*iterator_it) == zm_packet ));
|
||||||
// Have to check each iterator and make sure it doesn't point to the packet we are about to delete
|
// Have to check each iterator and make sure it doesn't point to the packet we are about to delete
|
||||||
if ( *(*iterator_it) == zm_packet ) {
|
if ( *(*iterator_it) == zm_packet ) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -211,7 +211,9 @@ int RemoteCameraHttp::ReadData(Buffer &buffer, unsigned int bytes_expected) {
|
||||||
|
|
||||||
int n_found = select(sd+1, &rfds, nullptr, nullptr, &temp_timeout);
|
int n_found = select(sd+1, &rfds, nullptr, nullptr, &temp_timeout);
|
||||||
if (n_found == 0) {
|
if (n_found == 0) {
|
||||||
Debug(1, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec);
|
Debug(1, "Select timed out timeout was %" PRIi64 " secs %" PRIi64" usecs",
|
||||||
|
static_cast<int64>(temp_timeout.tv_sec),
|
||||||
|
static_cast<int64>(temp_timeout.tv_usec));
|
||||||
int error = 0;
|
int error = 0;
|
||||||
socklen_t len = sizeof(error);
|
socklen_t len = sizeof(error);
|
||||||
int retval = getsockopt(sd, SOL_SOCKET, SO_ERROR, &error, &len);
|
int retval = getsockopt(sd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||||
|
|
|
@ -202,7 +202,7 @@ int RemoteCameraRtsp::PrimeCapture() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (unsigned int)pSize != imagesize ) {
|
if ( (unsigned int)pSize != imagesize ) {
|
||||||
Fatal("Image size mismatch. Required: %d Available: %d", pSize, imagesize);
|
Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -289,15 +289,14 @@ void RtpCtrlThread::Run() {
|
||||||
unsigned char *bufferPtr = buffer;
|
unsigned char *bufferPtr = buffer;
|
||||||
bufferPtr += generateRr( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) );
|
bufferPtr += generateRr( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) );
|
||||||
bufferPtr += generateSdes( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) );
|
bufferPtr += generateSdes( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) );
|
||||||
Debug( 3, "Preventing timeout by sending %zd bytes on sd %d. Time since last receive: %d",
|
Debug(3, "Preventing timeout by sending %zd bytes on sd %d. Time since last receive: %" PRIi64,
|
||||||
bufferPtr-buffer, rtpCtrlServer.getWriteDesc(), ( now-last_receive) );
|
bufferPtr - buffer, rtpCtrlServer.getWriteDesc(), static_cast<int64>(now - last_receive));
|
||||||
if ( (nBytes = rtpCtrlServer.send(buffer, bufferPtr-buffer)) < 0 )
|
if ( (nBytes = rtpCtrlServer.send(buffer, bufferPtr-buffer)) < 0 )
|
||||||
Error("Unable to send: %s", strerror(errno));
|
Error("Unable to send: %s", strerror(errno));
|
||||||
timeout = true;
|
timeout = true;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
//Error( "RTCP timed out" );
|
Debug(1, "RTCP timed out. Time since last receive: %" PRIi64, static_cast<int64>(now - last_receive));
|
||||||
Debug(1, "RTCP timed out. Time since last receive: %d", ( now-last_receive) );
|
|
||||||
continue;
|
continue;
|
||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,10 +165,8 @@ void RtpSource::updateJitter( const RtpDataHeader *header ) {
|
||||||
uint32_t localTimeRtp = mBaseTimeRtp + uint32_t(tvDiffSec(mBaseTimeReal) * mRtpFactor);
|
uint32_t localTimeRtp = mBaseTimeRtp + uint32_t(tvDiffSec(mBaseTimeReal) * mRtpFactor);
|
||||||
uint32_t packetTransit = localTimeRtp - ntohl(header->timestampN);
|
uint32_t packetTransit = localTimeRtp - ntohl(header->timestampN);
|
||||||
|
|
||||||
Debug(5, "Delta rtp = %.6f\n"
|
Debug(5,
|
||||||
"Local RTP time = %x",
|
"Delta rtp = %.6f\n Local RTP time = %x Packet RTP time = %x Packet transit RTP time = %x",
|
||||||
"Packet RTP time = %x",
|
|
||||||
"Packet transit RTP time = %x",
|
|
||||||
tvDiffSec(mBaseTimeReal),
|
tvDiffSec(mBaseTimeReal),
|
||||||
localTimeRtp,
|
localTimeRtp,
|
||||||
ntohl(header->timestampN),
|
ntohl(header->timestampN),
|
||||||
|
@ -239,13 +237,7 @@ void RtpSource::updateRtcpStats() {
|
||||||
mLostFraction = (lostInterval << 8) / expectedInterval;
|
mLostFraction = (lostInterval << 8) / expectedInterval;
|
||||||
|
|
||||||
Debug(5,
|
Debug(5,
|
||||||
"Expected packets = %d\n",
|
"Expected packets = %d\n Lost packets = %d\n Expected interval = %d\n Received interval = %d\n Lost interval = %d\n Lost fraction = %d\n",
|
||||||
"Lost packets = %d\n",
|
|
||||||
"Expected interval = %d\n",
|
|
||||||
"Received interval = %d\n",
|
|
||||||
"Lost interval = %d\n",
|
|
||||||
"Lost fraction = %d\n",
|
|
||||||
|
|
||||||
mExpectedPackets,
|
mExpectedPackets,
|
||||||
mLostPackets,
|
mLostPackets,
|
||||||
expectedInterval,
|
expectedInterval,
|
||||||
|
|
|
@ -173,7 +173,7 @@ RtspThread::RtspThread(
|
||||||
|
|
||||||
mNeedAuth = false;
|
mNeedAuth = false;
|
||||||
StringVector parts = Split(auth, ":");
|
StringVector parts = Split(auth, ":");
|
||||||
Debug(2, "# of auth parts %d", parts.size());
|
Debug(2, "# of auth parts %zu", parts.size());
|
||||||
if ( parts.size() > 1 )
|
if ( parts.size() > 1 )
|
||||||
mAuthenticator = new zm::Authenticator(parts[0], parts[1]);
|
mAuthenticator = new zm::Authenticator(parts[0], parts[1]);
|
||||||
else
|
else
|
||||||
|
@ -372,7 +372,7 @@ void RtspThread::Run() {
|
||||||
mSessDesc = new SessionDescriptor( mUrl, sdp );
|
mSessDesc = new SessionDescriptor( mUrl, sdp );
|
||||||
mFormatContext = mSessDesc->generateFormatContext();
|
mFormatContext = mSessDesc->generateFormatContext();
|
||||||
} catch ( const Exception &e ) {
|
} catch ( const Exception &e ) {
|
||||||
Error(e.getMessage().c_str());
|
Error("%s", e.getMessage().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,8 +589,12 @@ void RtspThread::Run() {
|
||||||
while (!mTerminate) {
|
while (!mTerminate) {
|
||||||
now = time(nullptr);
|
now = time(nullptr);
|
||||||
// Send a keepalive message if the server supports this feature and we are close to the timeout expiration
|
// Send a keepalive message if the server supports this feature and we are close to the timeout expiration
|
||||||
Debug(5, "sendkeepalive %d, timeout %d, now: %d last: %d since: %d",
|
Debug(5, "sendkeepalive %d, timeout %d, now: %" PRIi64 " last: %" PRIi64 " since: %" PRIi64,
|
||||||
sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) );
|
sendKeepalive,
|
||||||
|
timeout,
|
||||||
|
static_cast<int64>(now),
|
||||||
|
static_cast<int64>(lastKeepalive),
|
||||||
|
static_cast<int64>(now - lastKeepalive));
|
||||||
if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) {
|
if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) {
|
||||||
if ( !sendCommand( message ) )
|
if ( !sendCommand( message ) )
|
||||||
return;
|
return;
|
||||||
|
@ -709,7 +713,12 @@ void RtspThread::Run() {
|
||||||
// FIXME: Is this really necessary when using tcp ?
|
// FIXME: Is this really necessary when using tcp ?
|
||||||
now = time(nullptr);
|
now = time(nullptr);
|
||||||
// Send a keepalive message if the server supports this feature and we are close to the timeout expiration
|
// Send a keepalive message if the server supports this feature and we are close to the timeout expiration
|
||||||
Debug(5, "sendkeepalive %d, timeout %d, now: %d last: %d since: %d", sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) );
|
Debug(5, "sendkeepalive %d, timeout %d, now: %" PRIi64 " last: %" PRIi64 " since: %" PRIi64,
|
||||||
|
sendKeepalive,
|
||||||
|
timeout,
|
||||||
|
static_cast<int64>(now),
|
||||||
|
static_cast<int64>(lastKeepalive),
|
||||||
|
static_cast<int64>(now - lastKeepalive));
|
||||||
if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) )
|
if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) )
|
||||||
{
|
{
|
||||||
if ( !sendCommand( message ) )
|
if ( !sendCommand( message ) )
|
||||||
|
|
|
@ -205,7 +205,7 @@ void Authenticator::checkAuthResponse(const std::string &response) {
|
||||||
|
|
||||||
if ( strncasecmp(lines[i].c_str(), authenticate_match, authenticate_match_len) == 0 ) {
|
if ( strncasecmp(lines[i].c_str(), authenticate_match, authenticate_match_len) == 0 ) {
|
||||||
authLine = lines[i];
|
authLine = lines[i];
|
||||||
Debug(2, "Found auth line at %d:", i);
|
Debug(2, "Found auth line at %zu:", i);
|
||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ unsigned char * H26X_ZoneMinderFifoSource::findMarker(
|
||||||
// extract a frame
|
// extract a frame
|
||||||
unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, size_t& size, size_t& outsize) {
|
unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, size_t& size, size_t& outsize) {
|
||||||
unsigned char *outFrame = nullptr;
|
unsigned char *outFrame = nullptr;
|
||||||
Debug(4, "ExtractFrame: %p %d", frame, size);
|
Debug(4, "ExtractFrame: %p %zu", frame, size);
|
||||||
outsize = 0;
|
outsize = 0;
|
||||||
size_t markerLength = 0;
|
size_t markerLength = 0;
|
||||||
size_t endMarkerLength = 0;
|
size_t endMarkerLength = 0;
|
||||||
|
@ -205,7 +205,7 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si
|
||||||
if ( size >= 3 )
|
if ( size >= 3 )
|
||||||
startFrame = this->findMarker(frame, size, markerLength);
|
startFrame = this->findMarker(frame, size, markerLength);
|
||||||
if ( startFrame != nullptr ) {
|
if ( startFrame != nullptr ) {
|
||||||
Debug(4, "startFrame: %p marker Length %d", startFrame, markerLength);
|
Debug(4, "startFrame: %p marker Length %zu", startFrame, markerLength);
|
||||||
m_frameType = startFrame[markerLength];
|
m_frameType = startFrame[markerLength];
|
||||||
|
|
||||||
int remainingSize = size-(startFrame-frame+markerLength);
|
int remainingSize = size-(startFrame-frame+markerLength);
|
||||||
|
@ -213,7 +213,7 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si
|
||||||
if ( remainingSize > 3 ) {
|
if ( remainingSize > 3 ) {
|
||||||
endFrame = this->findMarker(startFrame+markerLength, remainingSize, endMarkerLength);
|
endFrame = this->findMarker(startFrame+markerLength, remainingSize, endMarkerLength);
|
||||||
}
|
}
|
||||||
Debug(4, "endFrame: %p marker Length %d, remaining size %d", endFrame, endMarkerLength, remainingSize);
|
Debug(4, "endFrame: %p marker Length %zu, remaining size %d", endFrame, endMarkerLength, remainingSize);
|
||||||
|
|
||||||
if ( m_keepMarker ) {
|
if ( m_keepMarker ) {
|
||||||
size -= startFrame-frame;
|
size -= startFrame-frame;
|
||||||
|
@ -229,9 +229,9 @@ unsigned char* H26X_ZoneMinderFifoSource::extractFrame(unsigned char* frame, si
|
||||||
outsize = size;
|
outsize = size;
|
||||||
}
|
}
|
||||||
size -= outsize;
|
size -= outsize;
|
||||||
Debug(4, "Have frame type: %d size %d, keepmarker %d", m_frameType, outsize, m_keepMarker);
|
Debug(4, "Have frame type: %d size %zu, keepmarker %d", m_frameType, outsize, m_keepMarker);
|
||||||
} else if ( size >= sizeof(H264shortmarker) ) {
|
} else if ( size >= sizeof(H264shortmarker) ) {
|
||||||
Info("No marker found size %d", size);
|
Info("No marker found size %zu", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outFrame;
|
return outFrame;
|
||||||
|
|
|
@ -78,7 +78,7 @@ void ZoneMinderFifoSource::WriteRun() {
|
||||||
|
|
||||||
if (nal) {
|
if (nal) {
|
||||||
if (1 and (nal->size() > maxNalSize)) {
|
if (1 and (nal->size() > maxNalSize)) {
|
||||||
Debug(1, "SPlitting NAL %d", nal->size());
|
Debug(1, "Splitting NAL %zu", nal->size());
|
||||||
size_t nalRemaining = nal->size();
|
size_t nalRemaining = nal->size();
|
||||||
u_int8_t *nalSrc = nal->buffer();
|
u_int8_t *nalSrc = nal->buffer();
|
||||||
|
|
||||||
|
@ -123,9 +123,9 @@ void ZoneMinderFifoSource::WriteRun() {
|
||||||
nalSrc += fuNalSize;
|
nalSrc += fuNalSize;
|
||||||
nal_count += 1;
|
nal_count += 1;
|
||||||
}
|
}
|
||||||
Debug(1, "Sending %d NALs @ %d and 1 @ %d", nal_count, maxNalSize, fuNal.size());
|
Debug(1, "Sending %d NALs @ %zu and 1 @ %zu", nal_count, maxNalSize, fuNal.size());
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "Pushing nal of size %d at %" PRId64, nal->size(), nal->pts());
|
Debug(3, "Pushing nal of size %zu at %" PRId64, nal->size(), nal->pts());
|
||||||
PushFrame(nal->buffer(), nal->size(), nal->pts());
|
PushFrame(nal->buffer(), nal->size(), nal->pts());
|
||||||
}
|
}
|
||||||
delete nal;
|
delete nal;
|
||||||
|
@ -214,8 +214,8 @@ int ZoneMinderFifoSource::getNextFrame() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (header_start != m_buffer) {
|
if (header_start != m_buffer) {
|
||||||
Debug(4, "ZM Packet didn't start at beginning of buffer %u. %c%c",
|
Debug(4, "ZM Packet didn't start at beginning of buffer %ld. %c%c",
|
||||||
header_start-m_buffer.head(), m_buffer[0], m_buffer[1]);
|
header_start - m_buffer.head(), m_buffer[0], m_buffer[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_into may invalidate packet_start
|
// read_into may invalidate packet_start
|
||||||
|
@ -244,7 +244,10 @@ int ZoneMinderFifoSource::getNextFrame() {
|
||||||
size_t bytes_remaining = data_size;
|
size_t bytes_remaining = data_size;
|
||||||
std::list< std::pair<unsigned char*, size_t> > framesList = this->splitFrames(packet_start, bytes_remaining);
|
std::list< std::pair<unsigned char*, size_t> > framesList = this->splitFrames(packet_start, bytes_remaining);
|
||||||
m_buffer.consume(data_size+header_size);
|
m_buffer.consume(data_size+header_size);
|
||||||
Debug(3, "Got %d frames, consuming %d bytes, remaining %d", framesList.size(), data_size+header_size, bytes_remaining);
|
Debug(3, "Got %zu frames, consuming %d bytes, remaining %zu",
|
||||||
|
framesList.size(),
|
||||||
|
data_size + header_size,
|
||||||
|
bytes_remaining);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lck(mutex_);
|
std::unique_lock<std::mutex> lck(mutex_);
|
||||||
|
|
|
@ -53,12 +53,13 @@ class NAL_Frame {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug() {
|
void debug() {
|
||||||
if ( m_size <= 4 ) {
|
if (m_size <= 4) {
|
||||||
Debug(1, "NAL: %d: %.2x %.2x %.2x %.2x", m_size,
|
Debug(1, "NAL: %zu: %.2x %.2x %.2x %.2x", m_size,
|
||||||
m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3]);
|
m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3]);
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "NAL: %d: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ", m_size,
|
Debug(1, "NAL: %zu: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ", m_size,
|
||||||
m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3],
|
m_buffer[0], m_buffer[1], m_buffer[2], m_buffer[3],
|
||||||
m_buffer[4], m_buffer[5], m_buffer[6], m_buffer[7]
|
m_buffer[4], m_buffer[5], m_buffer[6], m_buffer[7]
|
||||||
);
|
);
|
||||||
|
|
|
@ -104,8 +104,7 @@ RETSIGTYPE zm_die_handler(int signal)
|
||||||
}
|
}
|
||||||
free(messages);
|
free(messages);
|
||||||
|
|
||||||
Info("Backtrace complete, please execute the following command for more information");
|
Info("Backtrace complete, please execute the following command for more information: %s", cmd);
|
||||||
Info(cmd);
|
|
||||||
#endif // ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS )
|
#endif // ( !defined(ZM_NO_CRASHTRACE) && HAVE_DECL_BACKTRACE && HAVE_DECL_BACKTRACE_SYMBOLS )
|
||||||
#endif // (defined(__i386__) || defined(__x86_64__)
|
#endif // (defined(__i386__) || defined(__x86_64__)
|
||||||
exit(signal);
|
exit(signal);
|
||||||
|
|
|
@ -359,7 +359,7 @@ void StreamBase::openComms() {
|
||||||
// Unlink before bind, in case it already exists
|
// Unlink before bind, in case it already exists
|
||||||
unlink(loc_sock_path);
|
unlink(loc_sock_path);
|
||||||
if ( sizeof(loc_addr.sun_path) < length ) {
|
if ( sizeof(loc_addr.sun_path) < length ) {
|
||||||
Error("Not enough space %d in loc_addr.sun_path for socket file %s", sizeof(loc_addr.sun_path), loc_sock_path);
|
Error("Not enough space %zu in loc_addr.sun_path for socket file %s", sizeof(loc_addr.sun_path), loc_sock_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(loc_addr.sun_path, loc_sock_path, sizeof(loc_addr.sun_path));
|
strncpy(loc_addr.sun_path, loc_sock_path, sizeof(loc_addr.sun_path));
|
||||||
|
|
|
@ -124,7 +124,7 @@ int SWScale::Convert(
|
||||||
unsigned int new_width,
|
unsigned int new_width,
|
||||||
unsigned int new_height
|
unsigned int new_height
|
||||||
) {
|
) {
|
||||||
Debug(1, "Convert: in_buffer %p in_buffer_size %d out_buffer %p size %d width %d height %d width %d height %d %d %d",
|
Debug(1, "Convert: in_buffer %p in_buffer_size %zu out_buffer %p size %zu width %d height %d width %d height %d %d %d",
|
||||||
in_buffer, in_buffer_size, out_buffer, out_buffer_size, width, height, new_width, new_height,
|
in_buffer, in_buffer_size, out_buffer, out_buffer_size, width, height, new_width, new_height,
|
||||||
in_pf, out_pf);
|
in_pf, out_pf);
|
||||||
/* Parameter checking */
|
/* Parameter checking */
|
||||||
|
@ -163,12 +163,19 @@ int SWScale::Convert(
|
||||||
/* Check the buffer sizes */
|
/* Check the buffer sizes */
|
||||||
size_t needed_insize = GetBufferSize(in_pf, width, height);
|
size_t needed_insize = GetBufferSize(in_pf, width, height);
|
||||||
if ( needed_insize > in_buffer_size ) {
|
if ( needed_insize > in_buffer_size ) {
|
||||||
Debug(1, "The input buffer size does not match the expected size for the input format. Required: %d for %dx%d %d Available: %d",
|
Debug(1,
|
||||||
needed_insize, width, height, in_pf, in_buffer_size);
|
"The input buffer size does not match the expected size for the input format. Required: %zu for %dx%d %d Available: %zu",
|
||||||
|
needed_insize,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
in_pf,
|
||||||
|
in_buffer_size);
|
||||||
}
|
}
|
||||||
size_t needed_outsize = GetBufferSize(out_pf, new_width, new_height);
|
size_t needed_outsize = GetBufferSize(out_pf, new_width, new_height);
|
||||||
if ( needed_outsize > out_buffer_size ) {
|
if ( needed_outsize > out_buffer_size ) {
|
||||||
Error("The output buffer is undersized for the output format. Required: %d Available: %d", needed_outsize, out_buffer_size);
|
Error("The output buffer is undersized for the output format. Required: %zu Available: %zu",
|
||||||
|
needed_outsize,
|
||||||
|
out_buffer_size);
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ User *zmLoadAuthUser(const char *auth, bool use_remote_addr) {
|
||||||
Warning("No value set for ZM_AUTH_HASH_TTL. Defaulting to 2.");
|
Warning("No value set for ZM_AUTH_HASH_TTL. Defaulting to 2.");
|
||||||
hours = 2;
|
hours = 2;
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "AUTH_HASH_TTL is %d, time is %d", hours, now);
|
Debug(1, "AUTH_HASH_TTL is %d, time is %" PRIi64, hours, static_cast<int64>(now));
|
||||||
}
|
}
|
||||||
char auth_key[512] = "";
|
char auth_key[512] = "";
|
||||||
char auth_md5[32+1] = "";
|
char auth_md5[32+1] = "";
|
||||||
|
|
|
@ -670,9 +670,7 @@ VideoStore::~VideoStore() {
|
||||||
|
|
||||||
bool VideoStore::setup_resampler() {
|
bool VideoStore::setup_resampler() {
|
||||||
#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE)
|
#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE)
|
||||||
Error(
|
Error("%s", "Not built with resample library. Cannot do audio conversion to AAC");
|
||||||
"Not built with resample library. "
|
|
||||||
"Cannot do audio conversion to AAC");
|
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -727,7 +725,7 @@ bool VideoStore::setup_resampler() {
|
||||||
audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
|
audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
|
||||||
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
|
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
|
||||||
if ( !audio_out_ctx->channel_layout ) {
|
if ( !audio_out_ctx->channel_layout ) {
|
||||||
Debug(3, "Correcting channel layout from (%d) to (%d)",
|
Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")",
|
||||||
audio_out_ctx->channel_layout,
|
audio_out_ctx->channel_layout,
|
||||||
av_get_default_channel_layout(audio_out_ctx->channels)
|
av_get_default_channel_layout(audio_out_ctx->channels)
|
||||||
);
|
);
|
||||||
|
@ -800,29 +798,26 @@ bool VideoStore::setup_resampler() {
|
||||||
audio_out_ctx->time_base.num, audio_out_ctx->time_base.den);
|
audio_out_ctx->time_base.num, audio_out_ctx->time_base.den);
|
||||||
|
|
||||||
Debug(1,
|
Debug(1,
|
||||||
"Audio in bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
"Audio in bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)",
|
||||||
"layout(%d) frame_size(%d)",
|
|
||||||
audio_in_ctx->bit_rate, audio_in_ctx->sample_rate,
|
audio_in_ctx->bit_rate, audio_in_ctx->sample_rate,
|
||||||
audio_in_ctx->channels, audio_in_ctx->sample_fmt,
|
audio_in_ctx->channels, audio_in_ctx->sample_fmt,
|
||||||
audio_in_ctx->channel_layout, audio_in_ctx->frame_size);
|
audio_in_ctx->channel_layout, audio_in_ctx->frame_size);
|
||||||
Debug(1,
|
Debug(1,
|
||||||
"Audio out context bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
"Audio out context bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(% " PRIi64 ") frame_size(%d)",
|
||||||
"layout(%d) frame_size(%d)",
|
|
||||||
audio_out_ctx->bit_rate, audio_out_ctx->sample_rate,
|
audio_out_ctx->bit_rate, audio_out_ctx->sample_rate,
|
||||||
audio_out_ctx->channels, audio_out_ctx->sample_fmt,
|
audio_out_ctx->channels, audio_out_ctx->sample_fmt,
|
||||||
audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
|
audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||||
Debug(1,
|
Debug(1,
|
||||||
"Audio out stream bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
"Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)",
|
||||||
"layout(%d) frame_size(%d)",
|
|
||||||
audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate,
|
audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate,
|
||||||
audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format,
|
audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format,
|
||||||
audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size);
|
audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size);
|
||||||
#else
|
#else
|
||||||
Debug(1,
|
Debug(1,
|
||||||
"Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
"Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
||||||
"layout(%d) frame_size(%d)",
|
"layout(%" PRIi64 ") frame_size(%d)",
|
||||||
audio_out_stream->codec->bit_rate, audio_out_stream->codec->sample_rate,
|
audio_out_stream->codec->bit_rate, audio_out_stream->codec->sample_rate,
|
||||||
audio_out_stream->codec->channels, audio_out_stream->codec->sample_fmt,
|
audio_out_stream->codec->channels, audio_out_stream->codec->sample_fmt,
|
||||||
audio_out_stream->codec->channel_layout, audio_out_stream->codec->frame_size);
|
audio_out_stream->codec->channel_layout, audio_out_stream->codec->frame_size);
|
||||||
|
@ -1021,17 +1016,24 @@ int VideoStore::writeVideoFramePacket(ZMPacket *zm_packet) {
|
||||||
int64_t in_pts = zm_packet->timestamp->tv_sec * (uint64_t)1000000 + zm_packet->timestamp->tv_usec;
|
int64_t in_pts = zm_packet->timestamp->tv_sec * (uint64_t)1000000 + zm_packet->timestamp->tv_usec;
|
||||||
if ( !video_first_pts ) {
|
if ( !video_first_pts ) {
|
||||||
video_first_pts = in_pts;
|
video_first_pts = in_pts;
|
||||||
Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%d) usecs(%d)",
|
Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%" PRIi64 ") usecs(%" PRIi64 ")",
|
||||||
video_first_pts, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec);
|
video_first_pts,
|
||||||
|
static_cast<int64>(zm_packet->timestamp->tv_sec),
|
||||||
|
static_cast<int64>(zm_packet->timestamp->tv_usec));
|
||||||
zm_packet->out_frame->pts = 0;
|
zm_packet->out_frame->pts = 0;
|
||||||
} else {
|
} else {
|
||||||
uint64_t useconds = in_pts - video_first_pts;
|
uint64_t useconds = in_pts - video_first_pts;
|
||||||
zm_packet->out_frame->pts = av_rescale_q(useconds, AV_TIME_BASE_Q, video_out_ctx->time_base);
|
zm_packet->out_frame->pts = av_rescale_q(useconds, AV_TIME_BASE_Q, video_out_ctx->time_base);
|
||||||
Debug(2, " Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - secs(%d) usecs(%d) @ %d/%d",
|
Debug(2,
|
||||||
frame_count, zm_packet->out_frame->pts, video_first_pts, useconds, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec,
|
"Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - secs(%" PRIi64 ") usecs(%" PRIi64 ") @ %d/%d",
|
||||||
|
frame_count,
|
||||||
|
zm_packet->out_frame->pts,
|
||||||
|
video_first_pts,
|
||||||
|
useconds,
|
||||||
|
static_cast<int64>(zm_packet->timestamp->tv_sec),
|
||||||
|
static_cast<int64>(zm_packet->timestamp->tv_usec),
|
||||||
video_out_ctx->time_base.num,
|
video_out_ctx->time_base.num,
|
||||||
video_out_ctx->time_base.den
|
video_out_ctx->time_base.den);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
av_init_packet(&opkt);
|
av_init_packet(&opkt);
|
||||||
|
|
26
src/zmc.cpp
26
src/zmc.cpp
|
@ -214,7 +214,7 @@ int main(int argc, char *argv[]) {
|
||||||
Error("No monitors found");
|
Error("No monitors found");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else {
|
} else {
|
||||||
Debug(2, "%d monitors loaded", monitors.size());
|
Debug(2, "%zu monitors loaded", monitors.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info("Starting Capture version %s", ZM_VERSION);
|
Info("Starting Capture version %s", ZM_VERSION);
|
||||||
|
@ -294,20 +294,20 @@ int main(int argc, char *argv[]) {
|
||||||
monitors[i]->CheckAction();
|
monitors[i]->CheckAction();
|
||||||
|
|
||||||
if (monitors[i]->PreCapture() < 0) {
|
if (monitors[i]->PreCapture() < 0) {
|
||||||
Error("Failed to pre-capture monitor %d %d (%d/" SZFMTD ")",
|
Error("Failed to pre-capture monitor %d %s (%zu/%zu)",
|
||||||
monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size());
|
monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size());
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (monitors[i]->Capture() < 0) {
|
if (monitors[i]->Capture() < 0) {
|
||||||
Error("Failed to capture image from monitor %d %s (%d/" SZFMTD ")",
|
Error("Failed to capture image from monitor %d %s (%zu/%zu)",
|
||||||
monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size());
|
monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size());
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (monitors[i]->PostCapture() < 0) {
|
if (monitors[i]->PostCapture() < 0) {
|
||||||
Error("Failed to post-capture monitor %d %s (%d/" SZFMTD ")",
|
Error("Failed to post-capture monitor %d %s (%zu/%zu)",
|
||||||
monitors[i]->Id(), monitors[i]->Name(), i+1, monitors.size());
|
monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size());
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -322,13 +322,15 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// You have to add back in the previous sleep time
|
// You have to add back in the previous sleep time
|
||||||
sleep_time = delay - (delta_time.delta - sleep_time);
|
sleep_time = delay - (delta_time.delta - sleep_time);
|
||||||
Debug(4, "Sleep time is %d from now:%d.%d last:%d.%d delta %d delay: %d",
|
Debug(4,
|
||||||
|
"Sleep time is %d from now: %" PRIi64 ".%" PRIi64" last: %" PRIi64 ".% " PRIi64 " delta %lu delay: %d",
|
||||||
sleep_time,
|
sleep_time,
|
||||||
now.tv_sec, now.tv_usec,
|
static_cast<int64>(now.tv_sec),
|
||||||
last_capture_times[i].tv_sec, last_capture_times[i].tv_usec,
|
static_cast<int64>(now.tv_usec),
|
||||||
|
static_cast<int64>(last_capture_times[i].tv_sec),
|
||||||
|
static_cast<int64>(last_capture_times[i].tv_usec),
|
||||||
delta_time.delta,
|
delta_time.delta,
|
||||||
delay
|
delay);
|
||||||
);
|
|
||||||
|
|
||||||
if (sleep_time > 0) {
|
if (sleep_time > 0) {
|
||||||
Debug(4, "usleeping (%d)", sleep_time);
|
Debug(4, "usleeping (%d)", sleep_time);
|
||||||
|
|
|
@ -734,7 +734,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
exit_zmu(-1);
|
exit_zmu(-1);
|
||||||
}
|
}
|
||||||
Debug(1, "Got %d monitors", mysql_num_rows(result));
|
Debug(1, "Got %" PRIu64 " monitors", static_cast<uint64>(mysql_num_rows(result)));
|
||||||
|
|
||||||
printf("%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate");
|
printf("%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate");
|
||||||
for ( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row(result); i++ ) {
|
for ( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row(result); i++ ) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ TEST_CASE("ZmFont: load font file") {
|
||||||
SECTION("valid file") {
|
SECTION("valid file") {
|
||||||
REQUIRE(font.LoadFontFile("data/fonts/04_valid.zmfnt") == FontLoadError::kOk);
|
REQUIRE(font.LoadFontFile("data/fonts/04_valid.zmfnt") == FontLoadError::kOk);
|
||||||
|
|
||||||
uint8 var_idx = GENERATE(range(static_cast<decltype(kNumFontSizes)>(0), kNumFontSizes));
|
uint8 var_idx = GENERATE(range(static_cast<std::remove_cv<decltype(kNumFontSizes)>::type>(0), kNumFontSizes));
|
||||||
FontVariant variant = font.GetFontVariant(var_idx);
|
FontVariant variant = font.GetFontVariant(var_idx);
|
||||||
REQUIRE(variant.GetCharHeight() == 10 + var_idx);
|
REQUIRE(variant.GetCharHeight() == 10 + var_idx);
|
||||||
REQUIRE(variant.GetCharWidth() == 10 + var_idx);
|
REQUIRE(variant.GetCharWidth() == 10 + var_idx);
|
||||||
|
|
Loading…
Reference in New Issue