summaryrefslogtreecommitdiff
path: root/client/decoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/decoder.cc')
-rw-r--r--client/decoder.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index ea67d68..1193710 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -42,15 +42,19 @@
#include "control.h"
-Decoder::Decoder(): semaphore(1)
+#include "libdv_wrapper.h"
+
+Decoder::Decoder(): semaphore(1), screenshotsemaphore(1)
{
frame = NULL;
running = true;
qApp->installEventFilter(this);
+ screenshotsemaphore.acquire(); // Lock the screenshot method
}
Decoder::~Decoder()
-{}
+{
+}
void Decoder::run()
{
@@ -63,9 +67,16 @@ void Decoder::run()
reader.connect();
#endif/* READ_DV_FROM_FILE*/
+ fprintf(stderr, "init done\n");
+
while(running) {
char *tmp = (char*)reader.readFrame();
+ if(MIaV::control.isScreenshot()) {
+ memcpy(screenshotframe, tmp, DVPACKAGE_SIZE);
+ screenshotsemaphore.release();
+ }
+
if(MIaV::control.isFrozen() == false) {
mutex.lock();
if(frame) free(frame);
@@ -93,10 +104,24 @@ char *Decoder::getFrame()
bool Decoder::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::Close) {
- running = false; // Tell the thread to stop.
- semaphore.acquire(); // Wait for the thread to stop.
+ // printf("QUIT from: %p, this: %p, testing: %p\n", o, this, qApp->activeWindow());
+ if(qApp->activeWindow() == (QWidget*)o) { // Ignore close events from non top level widgets
+ running = false; // Tell the thread to stop.
+ semaphore.acquire(); // Wait for the thread to stop.
+ }
}
-
+
// standard event processing
return false;
}
+
+
+void Decoder::snapshot(char *rgb)
+{
+ LibDVWrapper dv;
+ dv.setOutputBuffer(rgb, DV::BGR0);
+
+ MIaV::control.takeScreenshot();
+ screenshotsemaphore.acquire(); // Wait for screenshot
+ dv.decode(screenshotframe);
+}