diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-04 19:39:38 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-04 19:39:38 +0000 |
commit | b227e26b829bd2670c91f670ce71d16c89e1fe58 (patch) | |
tree | 0b5ba5f2a1177bb48341022f8713604c44209516 | |
parent | f9fa26c1990e7fb7fc7f4a8f3c19175d2b5eb9c4 (diff) | |
download | vdr-plugin-live-b227e26b829bd2670c91f670ce71d16c89e1fe58.tar.gz vdr-plugin-live-b227e26b829bd2670c91f670ce71d16c89e1fe58.tar.bz2 |
- added intervals for min/max grabs
-rw-r--r-- | grab.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,21 +1,31 @@ #include <cstdlib> #include <vdr/device.h> +#include <vdr/tools.h> #include "grab.h" namespace vdrlive { using namespace std; +const unsigned int GrabMinIntervalMs = 500; +const unsigned int GrabPauseIntervalMs = GrabMinIntervalMs * 10; + class GrabImageTask: public StickyTask { public: explicit GrabImageTask( int quality = 80, int width = 320, int height = 240 ) - : m_quality( quality ) + : m_firstTime( 0 ) + , m_lastTime( 0 ) + , m_quality( quality ) , m_width( width ) , m_height( height ) {} + void Activate() { m_firstTime = 0; } + private: + uint64_t m_firstTime; + uint64_t m_lastTime; int m_quality; int m_width; int m_height; @@ -25,6 +35,14 @@ private: void GrabImageTask::Action() { + uint64_t now = cTimeMs::Now(); + + if ( m_firstTime == 0 ) + m_firstTime = now; + + if ( now - m_lastTime < GrabMinIntervalMs || now - m_firstTime > GrabPauseIntervalMs ) + return; + cDevice* device = cDevice::PrimaryDevice(); if ( device == 0 ) { SetError( tr("Couldn't aquire primary device") ); @@ -39,6 +57,7 @@ void GrabImageTask::Action() } LiveGrabImageManager().PutImage( reinterpret_cast< char* >( image ), size ); + m_lastTime = now; } GrabImageManager::GrabImageManager() @@ -51,6 +70,7 @@ GrabImageManager::GrabImageManager() GrabImageInfo GrabImageManager::GetImage() const { cMutexLock lock( &LiveTaskManager() ); + m_task->Activate(); return make_pair( m_image, m_size ); } |