rough in record_audio, and do lots of whitespace cleanups

This commit is contained in:
Isaac Connor 2016-03-31 12:54:56 -04:00
parent 2a3ed0c32c
commit c26dbb9028
20 changed files with 3809 additions and 3791 deletions

0
src/zm_camera.h Executable file → Normal file
View File

View File

@ -30,8 +30,8 @@ const char* content_type_match = "Content-Type:";
size_t content_length_match_len;
size_t content_type_match_len;
cURLCamera::cURLCamera( int p_id, const std::string &p_path, const std::string &p_user, const std::string &p_pass, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
Camera( p_id, CURL_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
cURLCamera::cURLCamera( int p_id, const std::string &p_path, const std::string &p_user, const std::string &p_pass, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
Camera( p_id, CURL_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
mPath( p_path ), mUser( p_user ), mPass ( p_pass ), bTerminate( false ), bReset( false ), mode ( MODE_UNSET )
{
@ -313,6 +313,7 @@ int cURLCamera::PostCapture()
int cURLCamera::CaptureAndRecord( Image &image, bool recording, char* event_directory )
{
Error("Capture and Record not implemented for the cURL camera type");
// Nothing to do here
return( 0 );
}

View File

@ -65,7 +65,7 @@ protected:
pthread_cond_t request_complete_cond;
public:
cURLCamera( int p_id, const std::string &path, const std::string &username, const std::string &password, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
cURLCamera( int p_id, const std::string &path, const std::string &username, const std::string &password, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~cURLCamera();
const std::string &Path() const { return( mPath ); }

0
src/zm_event.cpp Executable file → Normal file
View File

0
src/zm_event.h Executable file → Normal file
View File

4
src/zm_ffmpeg_camera.cpp Executable file → Normal file
View File

@ -36,8 +36,8 @@ extern "C"{
#include <pthread.h>
#endif
FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
mPath( p_path ),
mMethod( p_method ),
mOptions( p_options )

2
src/zm_ffmpeg_camera.h Executable file → Normal file
View File

@ -73,7 +73,7 @@ protected:
int64_t startTime;
public:
FfmpegCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
FfmpegCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~FfmpegCamera();
const std::string &Path() const { return( mPath ); }

View File

@ -61,8 +61,8 @@ void LibvlcUnlockBuffer(void* opaque, void* picture, void *const *planes)
}
}
LibvlcCamera::LibvlcCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
Camera( p_id, LIBVLC_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
LibvlcCamera::LibvlcCamera( int p_id, const std::string &p_path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
Camera( p_id, LIBVLC_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
mPath( p_path ),
mMethod( p_method ),
mOptions( p_options )

View File

@ -57,7 +57,7 @@ protected:
libvlc_media_player_t *mLibvlcMediaPlayer;
public:
LibvlcCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
LibvlcCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~LibvlcCamera();
const std::string &Path() const { return( mPath ); }

View File

@ -286,13 +286,32 @@ AVFrame **LocalCamera::capturePictures = 0;
LocalCamera *LocalCamera::last_camera = NULL;
LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, bool p_v4l_multi_buffer, unsigned int p_v4l_captures_per_frame, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, unsigned int p_extras) :
LocalCamera::LocalCamera(
int p_id,
const std::string &p_device,
int p_channel,
int p_standard,
bool p_v4l_multi_buffer,
unsigned int p_v4l_captures_per_frame,
const std::string &p_method,
int p_width,
int p_height,
int p_colours,
int p_palette,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio,
unsigned int p_extras) :
Camera( p_id, LOCAL_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
device( p_device ),
channel( p_channel ),
standard( p_standard ),
palette( p_palette ),
channel_index( 0 ),
record_audio( p_record_audio ),
extras ( p_extras )
{
// If we are the first, or only, input on this device then

View File

@ -116,7 +116,25 @@ protected:
static LocalCamera *last_camera;
public:
LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, bool v4lmultibuffer, unsigned int v4lcapturesperframe, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, unsigned int p_extras = 0);
LocalCamera(
int p_id,
const std::string &device,
int p_channel,
int p_format,
bool v4lmultibuffer,
unsigned int v4lcapturesperframe,
const std::string &p_method,
int p_width,
int p_height,
int p_colours,
int p_palette,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio,
unsigned int p_extras = 0);
~LocalCamera();
void Initialise();

282
src/zm_monitor.cpp Executable file → Normal file
View File

@ -75,8 +75,7 @@ std::vector<std::string> split(const std::string &s, char delim) {
Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id )
{
Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id ) {
strncpy( name, p_name, sizeof(name) );
#if ZM_MEM_MAPPED
@ -95,15 +94,12 @@ Monitor::MonitorLink::MonitorLink( int p_id, const char *p_name ) : id( p_id )
connected = false;
}
Monitor::MonitorLink::~MonitorLink()
{
Monitor::MonitorLink::~MonitorLink() {
disconnect();
}
bool Monitor::MonitorLink::connect()
{
if ( !last_connect_time || (time( 0 ) - last_connect_time) > 60 )
{
bool Monitor::MonitorLink::connect() {
if ( !last_connect_time || (time( 0 ) - last_connect_time) > 60 ) {
last_connect_time = time( 0 );
mem_size = sizeof(SharedData) + sizeof(TriggerData);
@ -111,8 +107,7 @@ bool Monitor::MonitorLink::connect()
Debug( 1, "link.mem.size=%d", mem_size );
#if ZM_MEM_MAPPED
map_fd = open( mem_file, O_RDWR, (mode_t)0600 );
if ( map_fd < 0 )
{
if ( map_fd < 0 ) {
Debug( 3, "Can't open linked memory map file %s: %s", mem_file, strerror(errno) );
disconnect();
return( false );
@ -125,44 +120,37 @@ bool Monitor::MonitorLink::connect()
}
struct stat map_stat;
if ( fstat( map_fd, &map_stat ) < 0 )
{
if ( fstat( map_fd, &map_stat ) < 0 ) {
Error( "Can't stat linked memory map file %s: %s", mem_file, strerror(errno) );
disconnect();
return( false );
}
if ( map_stat.st_size == 0 )
{
if ( map_stat.st_size == 0 ) {
Error( "Linked memory map file %s is empty: %s", mem_file, strerror(errno) );
disconnect();
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 );
disconnect();
return( false );
}
mem_ptr = (unsigned char *)mmap( NULL, 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) );
disconnect();
return( false );
}
#else // ZM_MEM_MAPPED
shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, 0700 );
if ( shm_id < 0 )
{
if ( shm_id < 0 ) {
Debug( 3, "Can't shmget link memory: %s", strerror(errno) );
connected = false;
return( false );
}
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
if ( mem_ptr < 0 )
{
if ( mem_ptr < 0 ) {
Debug( 3, "Can't shmat link memory: %s", strerror(errno) );
connected = false;
return( false );
@ -172,8 +160,7 @@ bool Monitor::MonitorLink::connect()
shared_data = (SharedData *)mem_ptr;
trigger_data = (TriggerData *)((char *)shared_data + sizeof(SharedData));
if ( !shared_data->valid )
{
if ( !shared_data->valid ) {
Debug( 3, "Linked memory not initialised by capture daemon" );
disconnect();
return( false );
@ -188,15 +175,12 @@ bool Monitor::MonitorLink::connect()
return( false );
}
bool Monitor::MonitorLink::disconnect()
{
if ( connected )
{
bool Monitor::MonitorLink::disconnect() {
if ( connected ) {
connected = false;
#if ZM_MEM_MAPPED
if ( mem_ptr > 0 )
{
if ( mem_ptr > 0 ) {
msync( mem_ptr, mem_size, MS_ASYNC );
munmap( mem_ptr, mem_size );
}
@ -206,25 +190,21 @@ bool Monitor::MonitorLink::disconnect()
map_fd = -1;
#else // ZM_MEM_MAPPED
struct shmid_ds shm_data;
if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 )
{
if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) {
Debug( 3, "Can't shmctl: %s", strerror(errno) );
return( false );
}
shm_id = 0;
if ( shm_data.shm_nattch <= 1 )
{
if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 )
{
if ( shm_data.shm_nattch <= 1 ) {
if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 ) {
Debug( 3, "Can't shmctl: %s", strerror(errno) );
return( false );
}
}
if ( shmdt( mem_ptr ) < 0 )
{
if ( shmdt( mem_ptr ) < 0 ) {
Debug( 3, "Can't shmdt: %s", strerror(errno) );
return( false );
}
@ -236,19 +216,15 @@ bool Monitor::MonitorLink::disconnect()
return( true );
}
bool Monitor::MonitorLink::isAlarmed()
{
if ( !connected )
{
bool Monitor::MonitorLink::isAlarmed() {
if ( !connected ) {
return( false );
}
return( shared_data->state == ALARM );
}
bool Monitor::MonitorLink::inAlarm()
{
if ( !connected )
{
bool Monitor::MonitorLink::inAlarm() {
if ( !connected ) {
return( false );
}
return( shared_data->state == ALARM || shared_data->state == ALERT );
@ -256,12 +232,9 @@ bool Monitor::MonitorLink::inAlarm()
bool Monitor::MonitorLink::hasAlarmed()
{
if ( shared_data->state == ALARM )
{
if ( shared_data->state == ALARM ) {
return( true );
}
else if( shared_data->last_event != (unsigned int)last_event )
{
} else if ( shared_data->last_event != (unsigned int)last_event ) {
last_event = shared_data->last_event;
}
return( false );
@ -280,6 +253,7 @@ Monitor::Monitor(
int p_savejpegs,
int p_videowriter,
std::string p_encoderparams,
bool p_record_audio,
const char *p_event_prefix,
const char *p_label_format,
const Coord &p_label_coord,
@ -317,6 +291,7 @@ Monitor::Monitor(
savejpegspref( p_savejpegs ),
videowriterpref( p_videowriter ),
encoderparams( p_encoderparams ),
record_audio( p_record_audio ),
label_coord( p_label_coord ),
label_size( p_label_size ),
image_buffer_count( p_image_buffer_count ),
@ -450,16 +425,15 @@ Monitor::Monitor(
shared_data->alarm_y = -1;
}
if ( ( ! mem_ptr ) || ! shared_data->valid )
{
if ( purpose != QUERY )
{
if ( ( ! mem_ptr ) || ! shared_data->valid ) {
if ( purpose != QUERY ) {
Error( "Shared data not initialised by capture daemon for monitor %s", name );
exit( -1 );
}
}
// Will this not happen every time a monitor is instantiated? Seems like all the calls to the Monitor constructor pass a zero for n_zones, then load zones after..
// In my storage areas branch, I took this out.. and didn't notice any problems.
if ( !n_zones ) {
Debug( 1, "Monitor %s has no zones, adding one.", name );
n_zones = 1;
@ -475,8 +449,7 @@ Monitor::Monitor(
Debug( 1, "Monitor %s LBF = '%s', LBX = %d, LBY = %d, LBS = %d", name, label_format, label_coord.X(), label_coord.Y(), label_size );
Debug( 1, "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d, ARBP = %d, FM = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion );
if ( purpose == ANALYSIS )
{
if ( purpose == ANALYSIS ) {
static char path[PATH_MAX];
strncpy( path, config.dir_events, sizeof(path) );
@ -484,8 +457,7 @@ Monitor::Monitor(
struct stat statbuf;
errno = 0;
stat( path, &statbuf );
if ( errno == ENOENT || errno == ENOTDIR )
{
if ( errno == ENOENT || errno == ENOTDIR ) {
if ( mkdir( path, 0755 ) )
{
Error( "Can't make %s: %s", path, strerror(errno));
@ -496,10 +468,8 @@ Monitor::Monitor(
errno = 0;
stat( path, &statbuf );
if ( errno == ENOENT || errno == ENOTDIR )
{
if ( mkdir( path, 0755 ) )
{
if ( errno == ENOENT || errno == ENOTDIR ) {
if ( mkdir( path, 0755 ) ) {
Error( "Can't make %s: %s", path, strerror(errno));
}
char temp_path[PATH_MAX];
@ -513,8 +483,7 @@ Monitor::Monitor(
}
while( shared_data->last_write_index == (unsigned int)image_buffer_count
&& shared_data->last_write_time == 0)
{
&& shared_data->last_write_time == 0) {
Warning( "Waiting for capture daemon" );
sleep( 1 );
}
@ -573,8 +542,7 @@ bool Monitor::connect() {
exit( -1 );
}
mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
if ( mem_ptr < 0 )
{
if ( mem_ptr < 0 ) {
Error( "Can't shmat: %s", strerror(errno));
exit( -1 );
}
@ -591,29 +559,25 @@ bool Monitor::connect() {
shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16)));
}
image_buffer = new Snapshot[image_buffer_count];
for ( int i = 0; i < image_buffer_count; i++ )
{
for ( int i = 0; i < image_buffer_count; i++ ) {
image_buffer[i].timestamp = &(shared_timestamps[i]);
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
}
if ( (deinterlacing & 0xff) == 4)
{
if ( (deinterlacing & 0xff) == 4) {
/* Four field motion adaptive deinterlacing in use */
/* Allocate a buffer for the next image */
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
next_buffer.timestamp = new struct timeval;
}
if ( ( purpose == ANALYSIS ) && analysis_fps )
{
if ( ( purpose == ANALYSIS ) && analysis_fps ) {
// Size of pre event buffer must be greater than pre_event_count
// if alarm_frame_count > 1, because in this case the buffer contains
// alarmed images that must be discarded when event is created
pre_event_buffer_count = pre_event_count + alarm_frame_count - 1;
pre_event_buffer = new Snapshot[pre_event_buffer_count];
for ( int i = 0; i < pre_event_buffer_count; i++ )
{
for ( int i = 0; i < pre_event_buffer_count; i++ ) {
pre_event_buffer[i].timestamp = new struct timeval;
pre_event_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
}
@ -1892,6 +1856,7 @@ void Monitor::Reload()
closeEvent();
static char sql[ZM_SQL_MED_BUFSIZ];
// This seems to have fallen out of date.
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = '%d'", id );
if ( mysql_query( &dbconn, sql ) )
@ -2084,7 +2049,7 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors )
#if ZM_HAS_V4L
int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose purpose )
{
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'";
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Function != 'None' and Type = 'Local'";
if ( device[0] ) {
sql += " AND Device='";
sql += device;
@ -2148,6 +2113,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
int savejpegs = atoi(dbrow[col]); col++;
int videowriter = atoi(dbrow[col]); col++;
std::string encoderparams = dbrow[col]; col++;
bool record_audio = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
@ -2209,6 +2175,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
hue,
colour,
purpose==CAPTURE,
record_audio,
extras
);
@ -2225,6 +2192,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
savejpegs,
videowriter,
encoderparams,
record_audio,
event_prefix,
label_format,
Coord( label_x, label_y ),
@ -2272,7 +2240,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const char *port, const char *path, Monitor **&monitors, Purpose purpose )
{
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'";
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Remote'";
if ( staticConfig.SERVER_ID ) {
sql += stringtf( " AND ServerId=%d", staticConfig.SERVER_ID );
}
@ -2318,6 +2286,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
int savejpegs = atoi(dbrow[col]); col++;
int videowriter = atoi(dbrow[col]); col++;
std::string encoderparams = dbrow[col]; col++;
bool record_audio = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
@ -2354,8 +2323,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
Camera *camera = 0;
if ( protocol == "http" )
{
if ( protocol == "http" ) {
camera = new RemoteCameraHttp(
id,
method,
@ -2369,12 +2337,12 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
}
#if HAVE_LIBAVFORMAT
else if ( protocol == "rtsp" )
{
else if ( protocol == "rtsp" ) {
camera = new RemoteCameraRtsp(
id,
method,
@ -2389,12 +2357,12 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
}
#endif // HAVE_LIBAVFORMAT
else
{
else {
Fatal( "Unexpected remote camera protocol '%s'", protocol.c_str() );
}
@ -2411,6 +2379,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
savejpegs,
videowriter,
encoderparams,
record_audio,
event_prefix.c_str(),
label_format.c_str(),
Coord( label_x, label_y ),
@ -2437,7 +2406,6 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
purpose,
0,
0
);
Zone **zones = 0;
int n_zones = Zone::Load( monitors[i], zones );
@ -2456,9 +2424,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
return( n_monitors );
}
int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose )
{
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'";
int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose purpose ) {
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'File'";
if ( file[0] ) {
sql += " AND Path='";
sql += file;
@ -2501,6 +2468,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
int savejpegs = atoi(dbrow[col]); col++;
int videowriter = atoi(dbrow[col]); col++;
std::string encoderparams = dbrow[col]; col++;
bool record_audio = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
@ -2546,7 +2514,8 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
monitors[i] = new Monitor(
@ -2562,6 +2531,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
savejpegs,
videowriter,
encoderparams,
record_audio,
event_prefix,
label_format,
Coord( label_x, label_y ),
@ -2609,7 +2579,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
#if HAVE_LIBAVFORMAT
int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose purpose )
{
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'";
std::string sql = "select Id, Name, ServerId, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif from Monitors where Function != 'None' and Type = 'Ffmpeg'";
if ( file[0] ) {
sql += " AND Path = '";
sql += file;
@ -2629,8 +2599,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
Debug( 1, "Got %d monitors", n_monitors );
delete[] monitors;
monitors = new Monitor *[n_monitors];
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
{
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) {
int col = 0;
int id = atoi(dbrow[col]); col++;
@ -2654,6 +2623,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
int savejpegs = atoi(dbrow[col]); col++;
int videowriter = atoi(dbrow[col]); col++;
std::string encoderparams = dbrow[col]; col++;
bool record_audio = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
@ -2701,7 +2671,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
monitors[i] = new Monitor(
@ -2717,6 +2688,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
savejpegs,
videowriter,
encoderparams,
record_audio,
event_prefix,
label_format,
Coord( label_x, label_y ),
@ -2762,9 +2734,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
}
#endif // HAVE_LIBAVFORMAT
Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose )
{
std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id );
Monitor *Monitor::Load( unsigned int p_id, bool load_zones, Purpose purpose ) {
std::string sql = stringtf( "select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, SaveJPEGs, VideoWriter, EncoderParameters, RecordAudio, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = %d", p_id );
MYSQL_ROW dbrow = zmDbFetchOne( sql.c_str() );
if ( ! dbrow ) {
@ -2824,6 +2795,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
int savejpegs = atoi(dbrow[col]); col++;
int videowriter = atoi(dbrow[col]); col++;
std::string encoderparams = dbrow[col]; col++;
bool record_audio = (*dbrow[col] != '0'); col++;
int brightness = atoi(dbrow[col]); col++;
int contrast = atoi(dbrow[col]); col++;
@ -2869,8 +2841,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
int extras = (deinterlacing>>24)&0xff;
Camera *camera = 0;
if ( type == "Local" )
{
if ( type == "Local" ) {
#if ZM_HAS_V4L
camera = new LocalCamera(
id,
@ -2889,16 +2860,14 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
hue,
colour,
purpose==CAPTURE,
record_audio,
extras
);
#else // ZM_HAS_V4L
Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id );
#endif // ZM_HAS_V4L
}
else if ( type == "Remote" )
{
if ( protocol == "http" )
{
} else if ( type == "Remote" ) {
if ( protocol == "http" ) {
camera = new RemoteCameraHttp(
id,
method.c_str(),
@ -2912,11 +2881,10 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
}
else if ( protocol == "rtsp" )
{
} else if ( protocol == "rtsp" ) {
#if HAVE_LIBAVFORMAT
camera = new RemoteCameraRtsp(
id,
@ -2932,19 +2900,16 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
#endif // HAVE_LIBAVFORMAT
}
else
{
} else {
Fatal( "Unexpected remote camera protocol '%s' for monitor %d", protocol.c_str(), id );
}
}
else if ( type == "File" )
{
} else if ( type == "File" ) {
camera = new FileCamera(
id,
path.c_str(),
@ -2955,11 +2920,10 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
}
else if ( type == "Ffmpeg" )
{
} else if ( type == "Ffmpeg" ) {
#if HAVE_LIBAVFORMAT
camera = new FfmpegCamera(
id,
@ -2973,14 +2937,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
#else // HAVE_LIBAVFORMAT
Fatal( "You must have ffmpeg libraries installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBAVFORMAT
}
else if (type == "Libvlc")
{
} else if (type == "Libvlc") {
#if HAVE_LIBVLC
camera = new LibvlcCamera(
id,
@ -2994,14 +2957,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
#else // HAVE_LIBVLC
Fatal( "You must have vlc libraries installed to use vlc cameras for monitor %d", id );
#endif // HAVE_LIBVLC
}
else if ( type == "cURL" )
{
} else if ( type == "cURL" ) {
#if HAVE_LIBCURL
camera = new cURLCamera(
id,
@ -3015,14 +2977,13 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
contrast,
hue,
colour,
purpose==CAPTURE
purpose==CAPTURE,
record_audio
);
#else // HAVE_LIBCURL
Fatal( "You must have libcurl installed to use ffmpeg cameras for monitor %d", id );
#endif // HAVE_LIBCURL
}
else
{
} else {
Fatal( "Bogus monitor type '%s' for monitor %d", type.c_str(), id );
}
monitor = new Monitor(
@ -3038,6 +2999,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
savejpegs,
videowriter,
encoderparams,
record_audio,
event_prefix.c_str(),
label_format.c_str(),
Coord( label_x, label_y ),
@ -3068,8 +3030,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
);
int n_zones = 0;
if ( load_zones )
{
if ( load_zones ) {
Zone **zones = 0;
n_zones = Zone::Load( monitor, zones );
monitor->AddZones( n_zones, zones );
@ -3123,8 +3084,7 @@ int Monitor::Capture()
captureResult = 0;
}
if ( captureResult != 0 )
{
if ( captureResult != 0 ) {
// Unable to capture image for temporary reason
// Fake a signal loss image
Rgb signalcolor;
@ -3135,8 +3095,7 @@ int Monitor::Capture()
captureResult = 1;
}
if ( captureResult == 1 )
{
if ( captureResult == 1 ) {
/* Deinterlacing */
if ( (deinterlacing & 0xff) == 1 ) {
@ -3152,48 +3111,41 @@ int Monitor::Capture()
}
if ( orientation != ROTATE_0 )
{
switch ( orientation )
{
case ROTATE_0 :
{
if ( orientation != ROTATE_0 ) {
switch ( orientation ) {
case ROTATE_0 : {
// No action required
break;
}
case ROTATE_90 :
case ROTATE_180 :
case ROTATE_270 :
{
case ROTATE_270 : {
capture_image->Rotate( (orientation-1)*90 );
break;
}
case FLIP_HORI :
case FLIP_VERT :
{
case FLIP_VERT : {
capture_image->Flip( orientation==FLIP_HORI );
break;
}
}
}
} // end if captureResults == 1
}
// if true? let's get rid of this.
if ( true ) {
if ( capture_image->Size() > camera->ImageSize() )
{
if ( capture_image->Size() > camera->ImageSize() ) {
Error( "Captured image %d does not match expected size %d check width, height and colour depth",capture_image->Size(),camera->ImageSize() );
return( -1 );
}
if ( ((unsigned int)index == shared_data->last_read_index) && (function > MONITOR) )
{
if ( ((unsigned int)index == shared_data->last_read_index) && (function > MONITOR) ) {
Warning( "Buffer overrun at index %d, image %d, slow down capture, speed up analysis or increase ring buffer size", index, image_count );
time_t now = time(0);
double approxFps = double(image_buffer_count)/double(now-image_buffer[index].timestamp->tv_sec);
time_t last_read_delta = now - shared_data->last_read_time;
if ( last_read_delta > (image_buffer_count/approxFps) )
{
if ( last_read_delta > (image_buffer_count/approxFps) ) {
Warning( "Last image read from shared memory %ld seconds ago, zma may have gone away", last_read_delta )
shared_data->last_read_index = image_buffer_count;
}
@ -3203,8 +3155,7 @@ int Monitor::Capture()
capture_image->MaskPrivacy( privacy_bitmask );
gettimeofday( image_buffer[index].timestamp, NULL );
if ( config.timestamp_on_capture )
{
if ( config.timestamp_on_capture ) {
TimestampImage( capture_image, image_buffer[index].timestamp );
}
shared_data->signal = CheckSignal(capture_image);
@ -3213,8 +3164,7 @@ int Monitor::Capture()
image_count++;
if ( image_count && fps_report_interval && !(image_count%fps_report_interval) )
{
if ( image_count && fps_report_interval && !(image_count%fps_report_interval) ) {
time_t now = image_buffer[index].timestamp->tv_sec;
fps = double(fps_report_interval)/(now-last_fps_time);
//Info( "%d -> %d -> %d", fps_report_interval, now, last_fps_time );
@ -3223,16 +3173,14 @@ int Monitor::Capture()
last_fps_time = now;
}
if ( shared_data->action & GET_SETTINGS )
{
if ( shared_data->action & GET_SETTINGS ) {
shared_data->brightness = camera->Brightness();
shared_data->hue = camera->Hue();
shared_data->colour = camera->Colour();
shared_data->contrast = camera->Contrast();
shared_data->action &= ~GET_SETTINGS;
}
if ( shared_data->action & SET_SETTINGS )
{
if ( shared_data->action & SET_SETTINGS ) {
camera->Brightness( shared_data->brightness );
camera->Hue( shared_data->hue );
camera->Colour( shared_data->colour );
@ -3292,10 +3240,8 @@ void Monitor::TimestampImage( Image *ts_image, const struct timeval *ts_time ) c
bool Monitor::closeEvent()
{
video_store_data->recording = false;
if ( event )
{
if ( function == RECORD || function == MOCORD )
{
if ( event ) {
if ( function == RECORD || function == MOCORD ) {
gettimeofday( &(event->EndTime()), NULL );
}
delete event;
@ -3747,7 +3693,7 @@ bool Monitor::DumpSettings( char *output, bool verbose )
zones[i]->DumpSettings( output+strlen(output), verbose );
}
return( true );
}
} // bool Monitor::DumpSettings( char *output, bool verbose )
bool MonitorStream::checkSwapPath( const char *path, bool create_path )
{

View File

@ -21,8 +21,23 @@
#include "zm_utils.h"
RemoteCamera::RemoteCamera( int p_id, const std::string &p_protocol, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
Camera( p_id, REMOTE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ),
RemoteCamera::RemoteCamera(
int p_id,
const std::string &p_protocol,
const std::string &p_host,
const std::string &p_port,
const std::string &p_path,
int p_width,
int p_height,
int p_colours,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio
) :
Camera( p_id, REMOTE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
protocol( p_protocol ),
host( p_host ),
port( p_port ),

View File

@ -55,7 +55,22 @@ protected:
struct addrinfo *hp;
public:
RemoteCamera( int p_id, const std::string &p_proto, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
RemoteCamera(
int p_id,
const std::string &p_proto,
const std::string &p_host,
const std::string &p_port,
const std::string &p_path,
int p_width,
int p_height,
int p_colours,
int p_brightness,
int p_contrast,
int p_hue,
int p_colour,
bool p_capture,
bool p_record_audio
);
virtual ~RemoteCamera();
const std::string &Protocol() const { return( protocol ); }

View File

@ -31,8 +31,8 @@
#include <sys/filio.h> // FIONREAD and friends
#endif
RemoteCameraHttp::RemoteCameraHttp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
RemoteCamera( p_id, "http", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture )
RemoteCameraHttp::RemoteCameraHttp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
RemoteCamera( p_id, "http", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio )
{
sd = -1;

View File

@ -45,7 +45,7 @@ protected:
enum { SIMPLE, REGEXP } method;
public:
RemoteCameraHttp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
RemoteCameraHttp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~RemoteCameraHttp();
void Initialise();

View File

@ -28,8 +28,8 @@
#include <sys/types.h>
#include <sys/socket.h>
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) :
RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ),
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
rtsp_describe( p_rtsp_describe ),
rtspThread( 0 )
@ -505,12 +505,16 @@ int RemoteCameraRtsp::CaptureAndRecord( Image &image, bool recording, char* even
} else if ( packet.stream_index == mAudioStreamId ) {
Debug( 4, "Got audio packet" );
if ( videoStore && recording ) {
if ( recordAudio ) {
if ( record_audio ) {
Debug( 4, "Storing Audio packet" );
//Write the packet to our video store
int ret = videoStore->writeAudioFramePacket(&packet, mFormatContext->streams[packet.stream_index]); //FIXME no relevance of last key frame
if ( ret < 0 ) { //Less than zero and we skipped a frame
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( &packet );
#else
av_free_packet( &packet );
#endif
return 0;
}
} else {

View File

@ -73,7 +73,7 @@ protected:
#endif
public:
RemoteCameraRtsp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture );
RemoteCameraRtsp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~RemoteCameraRtsp();
void Initialise();

0
src/zm_videostore.cpp Executable file → Normal file
View File

0
src/zm_videostore.h Executable file → Normal file
View File