From 0e4156c09597f7418aa0db60d09fe3b28c8f1dbd Mon Sep 17 00:00:00 2001 From: SteveGilvarry Date: Thu, 23 Oct 2014 19:56:35 +1100 Subject: [PATCH] Add CaptureAndRecord to vlc, still need to make it record --- src/zm_ffmpeg_camera.h | 2 +- src/zm_libvlc_camera.cpp | 14 ++++++++++++++ src/zm_libvlc_camera.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index d64a078a9..f11403403 100755 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -76,7 +76,7 @@ public: int PrimeCapture(); int PreCapture(); int Capture( Image &image ); - int CaptureAndRecord( Image &image, bool recording, char* event_directory ); + int CaptureAndRecord( Image &image, bool recording, char* event_directory ); int PostCapture(); }; diff --git a/src/zm_libvlc_camera.cpp b/src/zm_libvlc_camera.cpp index bfbcaa47d..1f756f6e0 100644 --- a/src/zm_libvlc_camera.cpp +++ b/src/zm_libvlc_camera.cpp @@ -211,6 +211,20 @@ int LibvlcCamera::Capture( Image &image ) return (0); } +// Should not return -1 as cancels capture. Always wait for image if available. +int LibvlcCamera::CaptureAndRecord( Image &image, bool 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); diff --git a/src/zm_libvlc_camera.h b/src/zm_libvlc_camera.h index 96414cb88..38e258c11 100644 --- a/src/zm_libvlc_camera.h +++ b/src/zm_libvlc_camera.h @@ -70,6 +70,7 @@ public: int PrimeCapture(); int PreCapture(); int Capture( Image &image ); + int CaptureAndRecord( Image &image, bool recording, char* event_directory ); int PostCapture(); };