This commit is contained in:
Isaac Connor 2017-10-25 13:25:44 -07:00
parent 0fbb473dd4
commit 3be40bcc99
7 changed files with 20 additions and 45 deletions

View File

@ -116,7 +116,7 @@ int cURLCamera::PreCapture() {
return( 0 ); return( 0 );
} }
int cURLCamera::Capture( Image &image ) { ZMPacket * cURLCamera::Capture( Image &image ) {
bool frameComplete = false; bool frameComplete = false;
/* MODE_STREAM specific variables */ /* MODE_STREAM specific variables */
@ -144,7 +144,7 @@ int cURLCamera::Capture( Image &image ) {
nRet = pthread_cond_wait(&data_available_cond,&shareddata_mutex); nRet = pthread_cond_wait(&data_available_cond,&shareddata_mutex);
if(nRet != 0) { if(nRet != 0) {
Error("Failed waiting for available data condition variable: %s",strerror(nRet)); Error("Failed waiting for available data condition variable: %s",strerror(nRet));
return -20; return NULL;
} }
} }
@ -257,7 +257,7 @@ int cURLCamera::Capture( Image &image ) {
nRet = pthread_cond_wait(&data_available_cond,&shareddata_mutex); nRet = pthread_cond_wait(&data_available_cond,&shareddata_mutex);
if(nRet != 0) { if(nRet != 0) {
Error("Failed waiting for available data condition variable: %s",strerror(nRet)); Error("Failed waiting for available data condition variable: %s",strerror(nRet));
return -18; return NULL;
} }
need_more_data = false; need_more_data = false;
} }
@ -281,7 +281,7 @@ int cURLCamera::Capture( Image &image ) {
nRet = pthread_cond_wait(&request_complete_cond,&shareddata_mutex); nRet = pthread_cond_wait(&request_complete_cond,&shareddata_mutex);
if(nRet != 0) { if(nRet != 0) {
Error("Failed waiting for request complete condition variable: %s",strerror(nRet)); Error("Failed waiting for request complete condition variable: %s",strerror(nRet));
return -19; return NULL;
} }
} }
} else { } else {
@ -295,9 +295,10 @@ int cURLCamera::Capture( Image &image ) {
unlock(); unlock();
if(!frameComplete) if(!frameComplete)
return -1; return NULL;
return 0; ZMPacket * packet = new ZMPacket( &image );
return packet;
} }
int cURLCamera::PostCapture() { int cURLCamera::PostCapture() {
@ -305,12 +306,6 @@ int cURLCamera::PostCapture() {
return( 0 ); return( 0 );
} }
int cURLCamera::CaptureAndRecord( Image &image, struct timeval recording, char* event_directory ) {
Error("Capture and Record not implemented for the cURL camera type");
// Nothing to do here
return( 0 );
}
size_t cURLCamera::data_callback(void *buffer, size_t size, size_t nmemb, void *userdata) { size_t cURLCamera::data_callback(void *buffer, size_t size, size_t nmemb, void *userdata) {
lock(); lock();

View File

@ -76,9 +76,8 @@ public:
int PrimeCapture(); int PrimeCapture();
int PreCapture(); int PreCapture();
int Capture( Image &image ); ZMPacket * Capture( Image &image );
int PostCapture(); int PostCapture();
int CaptureAndRecord( Image &image, struct timeval 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

@ -140,6 +140,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
if ( symlink( time_path, id_file ) < 0 ) if ( symlink( time_path, id_file ) < 0 )
Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)); Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
} else { } else {
// Shallow Storage
snprintf( path, sizeof(path), "%s/%d/%d", storage->Path(), monitor->Id(), id ); snprintf( path, sizeof(path), "%s/%d/%d", storage->Path(), monitor->Id(), id );
errno = 0; errno = 0;
@ -200,8 +201,8 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
} else { } else {
/* No video object */ /* No video object */
videowriter = NULL; videowriter = NULL;
}
#endif #endif
}
} // Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent ) } // Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent )

View File

@ -116,9 +116,9 @@ AVFrame *FFmpeg_Input::get_frame( int stream_id ) {
if ( (stream_id < 0 ) || ( packet.stream_index == stream_id ) ) { if ( (stream_id < 0 ) || ( packet.stream_index == stream_id ) ) {
Debug(1,"Packet is for our stream (%d)", packet.stream_index ); Debug(1,"Packet is for our stream (%d)", packet.stream_index );
AVCodecContext *context = streams[packet.stream_index].context;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
AVCodecContext *context = streams[packet.stream_index].context;
ret = avcodec_send_packet( context, &packet ); ret = avcodec_send_packet( context, &packet );
if ( ret < 0 ) { if ( ret < 0 ) {
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE ); av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );

View File

@ -192,14 +192,12 @@ int LibvlcCamera::PrimeCapture()
return(0); return(0);
} }
int LibvlcCamera::PreCapture() int LibvlcCamera::PreCapture() {
{
return(0); return(0);
} }
// Should not return -1 as cancels capture. Always wait for image if available. // Should not return -1 as cancels capture. Always wait for image if available.
int LibvlcCamera::Capture( Image &image ) ZMPacket * LibvlcCamera::Capture( Image &image ) {
{
while(!mLibvlcData.newImage.getValueImmediate()) while(!mLibvlcData.newImage.getValueImmediate())
mLibvlcData.newImage.getUpdatedValue(1); mLibvlcData.newImage.getUpdatedValue(1);
@ -208,25 +206,10 @@ int LibvlcCamera::Capture( Image &image )
mLibvlcData.newImage.setValueImmediate(false); mLibvlcData.newImage.setValueImmediate(false);
mLibvlcData.mutex.unlock(); mLibvlcData.mutex.unlock();
return (0); return new ZMPacket( &image );
} }
// Should not return -1 as cancels capture. Always wait for image if available. int LibvlcCamera::PostCapture() {
int LibvlcCamera::CaptureAndRecord(Image &image, timeval recording, char* event_directory)
{
while(!mLibvlcData.newImage.getValueImmediate())
mLibvlcData.newImage.getUpdatedValue(1);
mLibvlcData.mutex.lock();
image.Assign(width, height, colours, subpixelorder, mLibvlcData.buffer, width * height * mBpp);
mLibvlcData.newImage.setValueImmediate(false);
mLibvlcData.mutex.unlock();
return (0);
}
int LibvlcCamera::PostCapture()
{
return(0); return(0);
} }

View File

@ -31,8 +31,7 @@
#endif #endif
// Used by libvlc callbacks // Used by libvlc callbacks
struct LibvlcPrivateData struct LibvlcPrivateData {
{
uint8_t* buffer; uint8_t* buffer;
uint8_t* prevBuffer; uint8_t* prevBuffer;
time_t prevTime; time_t prevTime;
@ -41,8 +40,7 @@ struct LibvlcPrivateData
ThreadData<bool> newImage; ThreadData<bool> newImage;
}; };
class LibvlcCamera : public Camera class LibvlcCamera : public Camera {
{
protected: protected:
std::string mPath; std::string mPath;
std::string mMethod; std::string mMethod;
@ -69,8 +67,7 @@ public:
int PrimeCapture(); int PrimeCapture();
int PreCapture(); int PreCapture();
int Capture( Image &image ); ZMPacket *Capture( Image &image );
int CaptureAndRecord( Image &image, timeval recording, char* event_directory );
int PostCapture(); int PostCapture();
}; };

View File

@ -108,7 +108,7 @@ int ZMPacket::decode( AVCodecContext *ctx ) {
# else # else
int frameComplete = 0; int frameComplete = 0;
ret = zm_avcodec_decode_video( ctx, frame, &frameComplete, &packet ); int ret = zm_avcodec_decode_video( ctx, frame, &frameComplete, &packet );
if ( ret < 0 ) { if ( ret < 0 ) {
Error( "Unable to decode frame at frame %s", av_make_error_string( ret ) ); Error( "Unable to decode frame at frame %s", av_make_error_string( ret ) );
av_frame_free( &frame ); av_frame_free( &frame );