summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2006-04-12 13:41:45 +0000
committerdeva <deva>2006-04-12 13:41:45 +0000
commit6da7cc9bd16bb16f03bf0695b79cb41f9f23f58f (patch)
treea8f94dd7ff7e10a308d0ce0787a8070a621c4fa6
parentc9a7d3ecf5a5e979c4503dbf1f072898ffd72574 (diff)
*** empty log message ***
-rw-r--r--client/Makefile.am2
-rw-r--r--client/control.cc112
-rw-r--r--client/control.h67
-rw-r--r--client/decoder.cc15
-rw-r--r--client/mainwindow.cc14
-rw-r--r--client/mainwindow.h2
-rw-r--r--client/player.cc32
-rw-r--r--client/player.h4
-rw-r--r--client/videowidget.cc50
-rw-r--r--client/videowidget.h9
10 files changed, 231 insertions, 76 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
index 0767a22..73019c4 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -9,6 +9,7 @@ bin_PROGRAMS = miav_client
miav_client_SOURCES = $(shell ../tools/MocList cc ) \
miav_client.cc \
aboutwindow.cc \
+ control.cc \
cprlisten.cc \
cprquerydialog.cc \
decoder.cc \
@@ -29,6 +30,7 @@ miav_client_SOURCES = $(shell ../tools/MocList cc ) \
EXTRA_DIST = \
aboutwindow.h \
config.h \
+ control.h \
cprlisten.h \
cprquerydialog.h \
decoder.h \
diff --git a/client/control.cc b/client/control.cc
new file mode 100644
index 0000000..143e11c
--- /dev/null
+++ b/client/control.cc
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * control.cc
+ *
+ * Wed Apr 12 11:54:19 CEST 2006
+ * Copyright 2006 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of MIaV.
+ *
+ * MIaV is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MIaV is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MIaV; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "control.h"
+
+Control::Control()
+{
+ // Initialize control state
+ frozen = false;
+ recording = false;
+ cpr = "";
+}
+
+Control::~Control()
+{
+}
+
+void Control::setCpr(QString cpr)
+{
+ mutex.lock();
+ Control::cpr = cpr;
+ mutex.unlock();
+}
+
+void Control::getCpr(QString *cpr)
+{
+ mutex.lock();
+ *cpr = Control::cpr;
+ mutex.unlock();
+}
+
+void Control::freeze()
+{
+ mutex.lock();
+ frozen = true;
+ mutex.unlock();
+}
+
+void Control::unfreeze()
+{
+ mutex.lock();
+ frozen = false;
+ mutex.unlock();
+}
+
+void Control::shoot()
+{
+ mutex.lock();
+ frozen = false;
+ mutex.unlock();
+}
+
+void Control::record()
+{
+ mutex.lock();
+ recording = true;
+ mutex.unlock();
+}
+
+void Control::stop()
+{
+ mutex.lock();
+ recording = false;
+ mutex.unlock();
+}
+
+bool Control::isFrozen()
+{
+ bool isfrozen;
+ mutex.lock();
+ isfrozen = frozen;
+ mutex.unlock();
+ return isfrozen;
+}
+
+bool Control::isRecording()
+{
+ bool isrecording;
+ mutex.lock();
+ isrecording = recording;
+ mutex.unlock();
+ return isrecording;
+}
+
+
+// Global control object
+Control MIaV::control;
+
+
diff --git a/client/control.h b/client/control.h
new file mode 100644
index 0000000..5f28f0a
--- /dev/null
+++ b/client/control.h
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * control.h
+ *
+ * Wed Apr 12 11:54:19 CEST 2006
+ * Copyright 2006 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of MIaV.
+ *
+ * MIaV is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MIaV is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MIaV; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __MIAV_CONTROL_H__
+#define __MIAV_CONTROL_H__
+
+#include <QMutex>
+#include <QString>
+#include <QImage>
+
+/**
+ * Class for the global control object.
+ */
+class Control {
+public:
+ Control();
+ ~Control();
+
+ void setCpr(QString cpr);
+ void getCpr(QString *cpr);
+
+ void freeze();
+ void unfreeze();
+ void shoot();
+
+ void record();
+ void stop();
+
+ bool isFrozen();
+ bool isRecording();
+
+private:
+ bool frozen;
+ bool recording;
+
+ QMutex mutex;
+ QString cpr;
+};
+
+namespace MIaV {
+ extern Control control;
+};
+
+#endif/*__MIAV_CONTROL_H__*/
diff --git a/client/decoder.cc b/client/decoder.cc
index 5c2cce5..ea67d68 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -40,6 +40,8 @@
#include <QEvent>
#include <QApplication>
+#include "control.h"
+
Decoder::Decoder(): semaphore(1)
{
frame = NULL;
@@ -63,10 +65,15 @@ void Decoder::run()
while(running) {
char *tmp = (char*)reader.readFrame();
- mutex.lock();
- if(frame) free(frame);
- frame = tmp;
- mutex.unlock();
+
+ if(MIaV::control.isFrozen() == false) {
+ mutex.lock();
+ if(frame) free(frame);
+ frame = tmp;
+ mutex.unlock();
+ } else {
+ free(tmp);
+ }
}
semaphore.release(); // Unlock the shutdown process
}
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index c3d29ba..239e10f 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -37,6 +37,8 @@
#include <QX11Info>
#include <QMoveEvent>
+#include "control.h"
+
QPushButton *MainWindow::createButton(char* icon)
{
QPixmap pixmap(icon);
@@ -158,20 +160,20 @@ void MainWindow::record_clicked()
void MainWindow::snapshot_clicked()
{
+ MIaV::control.shoot();
history->addHistoryItem(new HistoryWidget(new QPixmap(PIXMAP_LOGO_SMALL)));
}
void MainWindow::freeze_clicked()
{
+ if(MIaV::control.isFrozen()) {
+ MIaV::control.unfreeze();
+ } else {
+ MIaV::control.freeze();
+ }
}
void MainWindow::mute_clicked()
{
}
-// A hack to ensure we draw the video in the right place
-void MainWindow::moveEvent(QMoveEvent *event)
-{
- QMoveEvent evt(video->pos(),video->pos());
- video->moveEvent(&evt);
-}
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 4698a2c..e3a4411 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -61,8 +61,6 @@ public:
QWidget *getVideoWidget() { return video; }
- void moveEvent(QMoveEvent *event);
-
public slots:
void cpr_clicked();
void clear_clicked();
diff --git a/client/player.cc b/client/player.cc
index a8f6152..5ee0ccd 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -54,13 +54,35 @@ void Player::show_frame()
fprintf(stderr, "Frame!%d\n", num++);
frame = decoder->getFrame();
- if(!frame) return;
-
- dvdecoder.decode(frame);
- free(frame);
+ if(frame) {
+ dvdecoder.decode(frame);
+ free(frame);
+ }
render.width = widget->width();
render.height = widget->height();
render.display(WIDTH, HEIGHT);
-
}
+
+//Hmm ... is this how it should work?
+void Player::getScreenShot(QImage *image)
+{
+ double R, G, B;
+ double Y, U, V;
+
+ char *yuv = render.getDisplayData();
+
+ for(int x = 0; x < WIDTH; x++) {
+ for(int y = 0; y < HEIGHT; y++) {
+ Y = yuv[(x + y * WIDTH)];
+ U = yuv[(x + y * WIDTH)];
+ V = yuv[(x + y * WIDTH)];
+
+ R = Y + 1.4075 * (V - 128);
+ G = Y - (0.3455 * (U - 128)) - (0.7169 * (V - 128));
+ B = Y + 1.7790 * (U - 128);
+ // QRgb qRgb((unsigned int)R,(unsigned int)G,(unsigned int)B);
+ image->setPixel(x, y, qRgb((unsigned int)R,(unsigned int)G,(unsigned int)B));
+ }
+ }
+ }
diff --git a/client/player.h b/client/player.h
index 723fc33..84c2674 100644
--- a/client/player.h
+++ b/client/player.h
@@ -37,6 +37,8 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
+#include <QImage>
+
#include "libdv_wrapper.h"
#include "xvaccelrenderer.h"
@@ -48,6 +50,8 @@ public:
Player(QWidget *widget, Decoder *decoder);
~Player();
+ void getScreenShot(QImage *image);
+
public slots:
void show_frame();
diff --git a/client/videowidget.cc b/client/videowidget.cc
index f6fc430..f679a3a 100644
--- a/client/videowidget.cc
+++ b/client/videowidget.cc
@@ -85,53 +85,3 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
}
*/
}
-
-void VideoWidget::moveEvent(QMoveEvent *event)
-{
- mutex.lock();
- myposition = mapToGlobal(event->pos());
- mutex.unlock();
-}
-
-void VideoWidget::resizeEvent(QResizeEvent *event)
-{
- mutex.lock();
- mysize = event->size();
- mutex.unlock();
-}
-
-int VideoWidget::getX()
-{
- int val;
- mutex.lock();
- val = myposition.x();
- mutex.unlock();
- return val;
-}
-
-int VideoWidget::getY()
-{
- int val;
- mutex.lock();
- val = myposition.y();
- mutex.unlock();
- return val;
-}
-
-int VideoWidget::getWidth()
-{
- int val;
- mutex.lock();
- val = mysize.width();//>720?720:mysize.width();
- mutex.unlock();
- return val;
-}
-
-int VideoWidget::getHeight()
-{
- int val;
- mutex.lock();
- val = mysize.height();//>576?576:mysize.height();
- mutex.unlock();
- return val;
-}
diff --git a/client/videowidget.h b/client/videowidget.h
index d5e77bc..5590d9b 100644
--- a/client/videowidget.h
+++ b/client/videowidget.h
@@ -39,18 +39,9 @@ public:
VideoWidget();
~VideoWidget();
- int getX();
- int getY();
- int getWidth();
- int getHeight();
-
void mouseReleaseEvent(QMouseEvent *event);
- void moveEvent(QMoveEvent *event);
- void resizeEvent(QResizeEvent *event);
private:
- QSize mysize;
- QPoint myposition;
QMutex mutex;
};