From 1c35956da6631fb7248939054911a723350b4751 Mon Sep 17 00:00:00 2001 From: salfter Date: Thu, 23 Feb 2012 23:49:19 +0000 Subject: [PATCH] write a flag file if the capture input is dead git-svn-id: https://svn.salfter.gotdns.org/svn/h264dvr/trunk@394 1b90f75b-8b96-4784-87c0-14078182fce6 --- include/recd_capture.h | 5 +++++ lib/recd_capture.cpp | 31 ++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/recd_capture.h b/include/recd_capture.h index ad9aaeb..3475fef 100644 --- a/include/recd_capture.h +++ b/include/recd_capture.h @@ -16,6 +16,8 @@ #include "config.h" #define V_BUFFERS 8 +#define FRAMESIZE_WINDOW 60 +#define DEAD_THRESHOLD 1024 #define reset_vbuf(__vb) do { \ memset((__vb), 0, sizeof(*(__vb))); \ @@ -43,6 +45,9 @@ private: void set_osd(char* fmt, ...); void v4l_prepare(); string szPrevOSDMessage; + int framesizes[FRAMESIZE_WINDOW]; + int framesize_ptr; + string deadfilename; public: void StartCapture(string source, string prefix, string outdir, string caption); Capture(); diff --git a/lib/recd_capture.cpp b/lib/recd_capture.cpp index 30ead24..2186eba 100644 --- a/lib/recd_capture.cpp +++ b/lib/recd_capture.cpp @@ -7,6 +7,7 @@ Capture::Capture() { szPrevOSDMessage=""; + framesize_ptr=0; } @@ -138,6 +139,9 @@ void Capture::StartCapture(string source, string prefix, string outdir, string c DiskWriter dw(outdir, prefix); + deadfilename=outdir+"/dead."+prefix; + unlink(deadfilename.c_str()); + open_video_dev(source.c_str()); v4l_prepare(); @@ -175,14 +179,31 @@ void Capture::StartCapture(string source, string prefix, string outdir, string c got_vop = true; } -// if (vb.flags & V4L2_BUF_FLAG_KEYFRAME) -// cout << vb.bytesused << " keyframe" << endl; -// else -// cout << vb.bytesused << endl; - if (!dw.Write(p_buf[vb.index].data, vb.bytesused, vb.flags & V4L2_BUF_FLAG_KEYFRAME)) err_out((char*)"Unable to write to disk"); + // see if the input is dead + + framesizes[framesize_ptr++]=vb.bytesused; + if (framesize_ptr==FRAMESIZE_WINDOW) + { + struct stat st; + int sum=0; + for (int i=0; i