Right direction

This commit is contained in:
Steve Gilvarry 2016-09-01 00:00:10 +10:00
parent 44df4a830d
commit d1bcb14629
9 changed files with 27 additions and 24 deletions

View File

@ -314,7 +314,7 @@ int cURLCamera::PostCapture()
return( 0 ); return( 0 );
} }
int cURLCamera::CaptureAndRecord(Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue) int cURLCamera::CaptureAndRecord(Image &image, bool recording, char* event_directory)
{ {
Error("Capture and Record not implemented for the cURL camera type"); Error("Capture and Record not implemented for the cURL camera type");
// Nothing to do here // Nothing to do here

View File

@ -79,7 +79,7 @@ public:
int PreCapture(); int PreCapture();
int Capture( Image &image ); int Capture( Image &image );
int PostCapture(); int PostCapture();
int CaptureAndRecord( Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue ); int CaptureAndRecord( Image &image, bool recording, char* event_directory );
size_t data_callback(void *buffer, size_t size, size_t nmemb, void *userdata); size_t data_callback(void *buffer, size_t size, size_t nmemb, void *userdata);
size_t header_callback(void *buffer, size_t size, size_t nmemb, void *userdata); size_t header_callback(void *buffer, size_t size, size_t nmemb, void *userdata);

View File

@ -509,7 +509,8 @@ void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){
} }
//Function to handle capture and store //Function to handle capture and store
int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_file, zm_packetqueue* packetqueue ){
int FfmpegCamera::CaptureAndRecord(Image &image, bool recording, char* event_file) {
if (!mCanCapture){ if (!mCanCapture){
return -1; return -1;
} }
@ -581,9 +582,9 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
//Buffer video packets //Buffer video packets
if (!recording) { if (!recording) {
if(packet.flags & AV_PKT_FLAG_KEY) { if(packet.flags & AV_PKT_FLAG_KEY) {
packetqueue->clearQueues(); // packetqueue->clearQueues();
} }
packetqueue->queueVideoPacket(&packet); // packetqueue->queueVideoPacket(&packet);
} }
//Video recording //Video recording
@ -617,13 +618,13 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
} }
wasRecording = true; wasRecording = true;
strcpy(oldDirectory, event_file); strcpy(oldDirectory, event_file);
while (packetqueue->popVideoPacket(&queuedpacket)) { // while (packetqueue->popVideoPacket(&queuedpacket)) {
int ret = videoStore->writeVideoFramePacket(&packet, mFormatContext->streams[mVideoStreamId]); //, &lastKeyframePkt); // int ret = videoStore->writeVideoFramePacket(&packet, mFormatContext->streams[mVideoStreamId]); //, &lastKeyframePkt);
if (ret < 0) {//Less than zero and we skipped a frame // if (ret < 0) {//Less than zero and we skipped a frame
av_free_packet(&packet); // av_free_packet(&packet);
return 0; // return 0;
} // }
} // }
} else if ( ( ! recording ) && wasRecording && videoStore ) { } else if ( ( ! recording ) && wasRecording && videoStore ) {
Info("Deleting videoStore instance"); Info("Deleting videoStore instance");

View File

@ -26,7 +26,6 @@
//#include "zm_utils.h" //#include "zm_utils.h"
#include "zm_ffmpeg.h" #include "zm_ffmpeg.h"
#include "zm_videostore.h" #include "zm_videostore.h"
#include "zm_packetqueue.h"
// //
// Class representing 'ffmpeg' cameras, i.e. those which are // Class representing 'ffmpeg' cameras, i.e. those which are
@ -88,7 +87,7 @@ public:
int PrimeCapture(); int PrimeCapture();
int PreCapture(); int PreCapture();
int Capture( Image &image ); int Capture( Image &image );
int CaptureAndRecord( Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue ); int CaptureAndRecord( Image &image, bool recording, char* event_directory );
int PostCapture(); int PostCapture();
}; };

View File

@ -47,7 +47,7 @@ public:
int PreCapture(); int PreCapture();
int Capture( Image &image ); int Capture( Image &image );
int PostCapture(); int PostCapture();
int CaptureAndRecord( Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue ) {return(0);}; int CaptureAndRecord( Image &image, bool recording, char* event_directory ) {return(0);};
}; };
#endif // ZM_FILE_CAMERA_H #endif // ZM_FILE_CAMERA_H

View File

@ -162,7 +162,7 @@ public:
int PreCapture(); int PreCapture();
int Capture( Image &image ); int Capture( Image &image );
int PostCapture(); int PostCapture();
int CaptureAndRecord( Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue ) {return(0);}; int CaptureAndRecord( Image &image, bool recording, char* event_directory ) {return(0);};
static bool GetCurrentSettings( const char *device, char *output, int version, bool verbose ); static bool GetCurrentSettings( const char *device, char *output, int version, bool verbose );
}; };

View File

@ -305,6 +305,7 @@ Monitor::Monitor(
Rgb p_signal_check_colour, Rgb p_signal_check_colour,
bool p_embed_exif, bool p_embed_exif,
Purpose p_purpose, Purpose p_purpose,
zm_packetqueue p_packetqueue,
int p_n_zones, int p_n_zones,
Zone *p_zones[] Zone *p_zones[]
) : id( p_id ), ) : id( p_id ),
@ -2255,6 +2256,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
signal_check_colour, signal_check_colour,
embed_exif, embed_exif,
purpose, purpose,
packetqueue,
0, 0,
0 0
); );
@ -2442,6 +2444,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
RGB_WHITE, RGB_WHITE,
embed_exif, embed_exif,
purpose, purpose,
packetqueue,
0, 0,
0 0
@ -3113,8 +3116,7 @@ int Monitor::Capture()
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()) { if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()) {
captureResult = camera->CaptureAndRecord(*(next_buffer.image), captureResult = camera->CaptureAndRecord(*(next_buffer.image),
video_store_data->recording, video_store_data->recording,
video_store_data->event_file, video_store_data->event_file);
packetqueue);
}else{ }else{
captureResult = camera->Capture(*(next_buffer.image)); captureResult = camera->Capture(*(next_buffer.image));
} }
@ -3128,7 +3130,7 @@ int Monitor::Capture()
//Check if FFMPEG camera //Check if FFMPEG camera
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){ if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){
//Warning("ZMC: Recording: %d", video_store_data->recording); //Warning("ZMC: Recording: %d", video_store_data->recording);
captureResult = camera->CaptureAndRecord(*capture_image, video_store_data->recording, video_store_data->event_file, packetqueue); captureResult = camera->CaptureAndRecord(*capture_image, video_store_data->recording, video_store_data->event_file);
}else{ }else{
/* Capture directly into image buffer, avoiding the need to memcpy() */ /* Capture directly into image buffer, avoiding the need to memcpy() */
captureResult = camera->Capture(*capture_image); captureResult = camera->Capture(*capture_image);

View File

@ -370,6 +370,7 @@ public:
Rgb p_signal_check_colour, Rgb p_signal_check_colour,
bool p_embed_exif, bool p_embed_exif,
Purpose p_purpose, Purpose p_purpose,
zm_packetqueue packetqueue,
int p_n_zones=0, int p_n_zones=0,
Zone *p_zones[]=0 Zone *p_zones[]=0
); );

View File

@ -59,7 +59,7 @@ public:
int PreCapture(); int PreCapture();
int Capture( Image &image ); int Capture( Image &image );
int PostCapture(); int PostCapture();
int CaptureAndRecord( Image &image, bool recording, char* event_directory, zm_packetqueue* packetqueue ) {return(0);}; int CaptureAndRecord( Image &image, bool recording, char* event_directory ) {return(0);};
}; };
#endif // ZM_REMOTE_CAMERA_HTTP_H #endif // ZM_REMOTE_CAMERA_HTTP_H