summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 14:24:34 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 14:24:34 +0200
commit0ff825e0e6fe5fc7238e3964d24779a07cb53518 (patch)
tree7b47a9fe58a09e12ed99fdfacc84fff198ce5ce1 /src
parent29ae5ac36d4ffc520232ff393b2455130ec0227e (diff)
Split miav server and client apart. Port client to Qt4. Replace libraw1994 with libiec61883. Add unit tests for multiplexer and fix some bugs in it.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am58
-rw-r--r--src/aboutwindow.cc16
-rw-r--r--src/aboutwindow.h17
-rw-r--r--src/camera.cc5
-rw-r--r--src/camera.h8
-rw-r--r--src/cprquerydialog.cc95
-rw-r--r--src/cprquerydialog.h57
-rw-r--r--src/daemon.cc75
-rw-r--r--src/daemon.h2
-rw-r--r--src/decoder.cc13
-rw-r--r--src/decoder.h5
-rw-r--r--src/dv1394.cc150
-rw-r--r--src/dv1394.h9
-rw-r--r--src/encoder.cc8
-rw-r--r--src/encoder.h17
-rw-r--r--src/file.cc12
-rw-r--r--src/file.h3
-rw-r--r--src/historywidget.cc9
-rw-r--r--src/historywidget.h8
-rw-r--r--src/img_encoder.cc2
-rw-r--r--src/info.h2
-rw-r--r--src/info_gui.cc16
-rw-r--r--src/info_gui.h22
-rw-r--r--src/iso11172-1.h96
-rw-r--r--src/libfame_wrapper.cc7
-rw-r--r--src/mainwindow.cc159
-rw-r--r--src/mainwindow.h34
-rw-r--r--src/messagebox.cc22
-rw-r--r--src/messagebox.h19
-rw-r--r--src/miav.cc94
-rw-r--r--src/miav_config.cc5
-rw-r--r--src/miav_config.h1
-rw-r--r--src/miavd.cc (renamed from src/miav.h)37
-rw-r--r--src/multiplexer.cc149
-rw-r--r--src/multiplexer.h8
-rw-r--r--src/network.cc1
-rw-r--r--src/player.cc5
-rw-r--r--src/player.h10
-rw-r--r--src/server.cc2
-rw-r--r--src/socket.cc28
-rw-r--r--src/videowidget.cc14
-rw-r--r--src/videowidget.h9
-rw-r--r--src/yuv_draw.cc27
-rw-r--r--src/yuv_draw.h13
44 files changed, 603 insertions, 746 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3ccf9d2..ef5b746 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,16 +1,22 @@
-AM_CXXFLAGS := $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I../include $(QT_CXXFLAGS) \
- -DQT_THREAD_SUPPORT \
- -DPIXMAPS=\"$(datadir)/pixmaps\" \
+SUBDIRS = icons
+DISTDIRS = icons
+
+bin_PROGRAMS = miav miavd
+
+# This is needed for XXXX.moc.o compilation
+AM_CXXFLAGS = $(QT_CFLAGS)
+
+miav_CXXFLAGS = $(SDL_CFLAGS) $(DV_CFLAGS) $(IEC61883_CFLAGS) $(QT_CFLAGS) \
+ -I../include -DPIXMAPS=\"$(datadir)/pixmaps\" \
-DETC=\"$(prefix)/etc/miav\"
-bin_PROGRAMS = miav
+miav_LDADD = $(shell ../tools/MocList o) $(QT_LIBS) $(IEC61883_LIBS) \
+ $(SDL_LIBS) $(DV_LIBS)
-miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \
+miav_SOURCES = \
aboutwindow.cc \
- audio_encoder.cc \
camera.cc \
cprquerydialog.cc \
- daemon.cc \
decoder.cc \
dv1394.cc \
dvfile.cc \
@@ -18,18 +24,39 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \
file.cc \
frame.cc \
historywidget.cc \
+ info.cc \
+ info_gui.cc \
+ mainwindow.cc \
+ messagebox.cc \
+ miav.cc \
+ miav_config.cc \
+ network.cc \
+ player.cc \
+ socket.cc \
+ thread.cc \
+ util.cc \
+ videowidget.cc \
+ yuv_draw.cc
+
+miavd_CXXFLAGS = $(JPEG_CFLAGS) $(FAME_CFLAGS) $(LAME_CFLAGS) $(DV_CFLAGS) \
+ $(PTHREAD_CFLAGS) -I../include -DETC=\"$(prefix)/etc/miav\"
+
+miavd_LDADD = $(JPEG_LIBS) $(FAME_LIBS) $(LAME_LIBS) $(DV_LIBS) $(PTHREAD_LIBS)
+
+miavd_SOURCES = \
+ miavd.cc \
+ audio_encoder.cc \
+ daemon.cc \
+ file.cc \
+ frame.cc \
img_encoder.cc \
info.cc \
info_console.cc \
- info_gui.cc \
info_simple.cc \
jpeg_mem_dest.cc \
libfame_wrapper.cc \
liblame_wrapper.cc \
libmplex_wrapper.cc \
- mainwindow.cc \
- messagebox.cc \
- miav.cc \
miav_daemon.cc \
miav_config.cc \
mov_encoder.cc \
@@ -40,7 +67,6 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \
multiplexer.cc \
mutex.cc \
network.cc \
- player.cc \
server.cc \
server_status.cc \
semaphore.cc \
@@ -49,9 +75,7 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \
threadsafe_queue.cc \
threadsafe_queue_fifo.cc \
threadsafe_queue_priority.cc \
- util.cc \
- videowidget.cc \
- yuv_draw.cc
+ util.cc
EXTRA_DIST = \
aboutwindow.h \
@@ -110,8 +134,6 @@ EXTRA_DIST = \
videowidget.h \
yuv_draw.h
-miav_LDADD := $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList o; fi )
-
miav_MOC = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi )
BUILT_SOURCES = $(miav_MOC)
@@ -119,7 +141,7 @@ BUILT_SOURCES = $(miav_MOC)
CLEANFILES = $(BUILT_SOURCES)
%.moc.cc: %.h
- $(MOC) -o $@ $<
+ moc -o $@ $<
%.h: %.ui
$(UIC) -o $@ $<
diff --git a/src/aboutwindow.cc b/src/aboutwindow.cc
index 8743ed8..2956d40 100644
--- a/src/aboutwindow.cc
+++ b/src/aboutwindow.cc
@@ -24,27 +24,25 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
#include "aboutwindow.h"
-#include <qpainter.h>
-#include <qfont.h>
+#include <QPainter>
+#include <QFont>
#include <config.h>
#define MARGIN 12
AboutWindow::AboutWindow( QWidget* parent, const char* name )
- : QDialog( parent, name )
+ : QDialog( parent )
{
+ setWindowTitle(name);
setModal(true);
pix_about = new QPixmap();
pix_about->load( PIXMAP_ABOUT );
resize(pix_about->width(), pix_about->height());
- setBackgroundColor(QColor(200,200,200));
+ // setBackgroundColor(QColor(200,200,200));
btn_ok = new QPushButton(this);
btn_ok->setText("OK");
@@ -79,7 +77,7 @@ void AboutWindow::paintEvent( QPaintEvent *event )
painter.drawPixmap(0,0, *pix_about);
// Draw title and version
- painter.setBrush( SolidPattern );
+ //painter.setBrush( SolidPattern );
painter.setFont( QFont( "Arial", 18, QFont::Bold ) );
painter.setPen( Qt::black );
painter.drawText(version_x, version_y, "MIAV-Grab v" VERSION);
@@ -88,5 +86,3 @@ void AboutWindow::paintEvent( QPaintEvent *event )
painter.end();
}
-
-#endif /*USE_GUI*/
diff --git a/src/aboutwindow.h b/src/aboutwindow.h
index f87a10e..5640f02 100644
--- a/src/aboutwindow.h
+++ b/src/aboutwindow.h
@@ -23,18 +23,15 @@
* 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 "config.h"
-#ifdef USE_GUI
-
+ */
#ifndef __ABOUTWINDOW_H__
#define __ABOUTWINDOW_H__
-#include <qdialog.h>
-//#include <qlabel.h>
-#include <qpixmap.h>
-//#include <qtextedit.h>
-#include <qpushbutton.h>
+#include <QDialog>
+//#include <QLabel>
+#include <QPixmap>
+//#include <QTextEdit>
+#include <QPushButton>
#define PIXMAP_ABOUT PIXMAPS"/about.png"
/*
@@ -79,5 +76,3 @@ private:
};
#endif /* __ABOUTWINDOW_H__ */
-
-#endif /*USE_GUI*/
diff --git a/src/camera.cc b/src/camera.cc
index 5dbec13..b1e507c 100644
--- a/src/camera.cc
+++ b/src/camera.cc
@@ -24,9 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
#include "camera.h"
Camera::Camera(Info *ginfo)
@@ -178,5 +175,3 @@ void Camera::setMute(bool mute)
decoder->setMute(mute);
player->setMute(mute);
}
-
-#endif/* USE_GUI */
diff --git a/src/camera.h b/src/camera.h
index a0b849a..d89d3c7 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -24,9 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __CAMERA_H__
#define __CAMERA_H__
@@ -50,7 +47,7 @@ using namespace std;
#include "thread.h"
#include "frame.h"
-#include <qwidget.h>
+#include <QWidget>
/**
* This class represents the symbolic representation of the camera and
@@ -103,7 +100,4 @@ private:
pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER;
};
-
#endif/*__CAMERA_H__*/
-
-#endif/* USE_GUI */
diff --git a/src/cprquerydialog.cc b/src/cprquerydialog.cc
index 4506e42..8ea0986 100644
--- a/src/cprquerydialog.cc
+++ b/src/cprquerydialog.cc
@@ -24,13 +24,11 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
+#include "cprquerydialog.h"
-#include <qframe.h>
+#include <QFrame>
#include "messagebox.h"
-#include "cprquerydialog.h"
#include "miav_config.h"
CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
@@ -38,9 +36,10 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
QWidget *parent,
const char *name,
QStatusBar *status)
- : QDialog(parent, name, TRUE)
+ : QDialog(parent)
{
- setCaption(name);
+ setModal(true);
+ setWindowTitle(name);
// Load image
QPixmap pix_backspace;
@@ -58,7 +57,7 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
cpr[0] = '\0';
internalCpr[0] = '\0';
- cprSocket = new QSocket(this);
+ cprSocket = new QTcpSocket(this);
connect(cprSocket, SIGNAL(readyRead()), SLOT(cprSocket_readyRead()));
connect(cprSocket, SIGNAL(connected()), SLOT(cprSocket_connected()));
connect(cprSocket, SIGNAL(error(int)), SLOT(cprSocket_error(int)));
@@ -70,21 +69,21 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
connect(timer, SIGNAL(timeout()), SLOT(cprSocket_timeout()));
// Generate input buttons
- QGridLayout *gl = new QGridLayout(this, 4, 3, 10, 2);
-
- QButton *b1 = createButton(this, "1", 1);
- QButton *b2 = createButton(this, "2", 2);
- QButton *b3 = createButton(this, "3", 3);
- QButton *b4 = createButton(this, "4", 4);
- QButton *b5 = createButton(this, "5", 5);
- QButton *b6 = createButton(this, "6", 6);
- QButton *b7 = createButton(this, "7", 7);
- QButton *b8 = createButton(this, "8", 8);
- QButton *b9 = createButton(this, "9", 9);
- QButton *b0 = createButton(this, "0", 0);
- QButton *bbs = createButton(this, "", 10);
- bbs->setPixmap(pix_backspace);
- QButton *bca = createButton(this, "CA", 11);
+ QGridLayout *gl = new QGridLayout(this);
+
+ QPushButton *b1 = createButton(this, "1", 1);
+ QPushButton *b2 = createButton(this, "2", 2);
+ QPushButton *b3 = createButton(this, "3", 3);
+ QPushButton *b4 = createButton(this, "4", 4);
+ QPushButton *b5 = createButton(this, "5", 5);
+ QPushButton *b6 = createButton(this, "6", 6);
+ QPushButton *b7 = createButton(this, "7", 7);
+ QPushButton *b8 = createButton(this, "8", 8);
+ QPushButton *b9 = createButton(this, "9", 9);
+ QPushButton *b0 = createButton(this, "0", 0);
+ QPushButton *bbs = createButton(this, "", 10);
+ bbs->setIcon(pix_backspace);
+ QPushButton *bca = createButton(this, "CA", 11);
gl->addWidget(b1, 0,0);
gl->addWidget(b2, 0,1);
@@ -129,7 +128,7 @@ QPushButton *CPRQueryDialog::createButton(QWidget *parent, const char *text, int
{
char buf[32];
sprintf(buf, "%d", value);
- QPushButton *q = new QPushButton(this, buf);
+ QPushButton *q = new QPushButton(this);// buf); // TODO
QFont f("Lucida", 48);
q->setFixedSize(150, 100);
@@ -213,7 +212,9 @@ void CPRQueryDialog::remove_all()
*/
void CPRQueryDialog::insert_digit(int value)
{
- char temp[2];
+ printf("insert_digit(%d)\n", value);
+ char temp[3];
+ printf("strlen(cpr) = %d cpr: '%s'\n", strlen(cpr), cpr);
switch(strlen(cpr)) {
case 5: // Automaticaly add a hyphen after the sixth digit
sprintf(temp, "%d-", value);
@@ -333,21 +334,22 @@ void CPRQueryDialog::cprSocket_error(int errnum)
lbl_name->setText(NAME_NOT_AVAILABLE);
+ /* // TODO
// Print error message
switch(errnum) {
- case QSocket::ErrConnectionRefused: // if the connection was refused
+ case QTcpSocket::ErrConnectionRefused: // if the connection was refused
msg.append("ErrConnectionRefused");
break;
- case QSocket::ErrHostNotFound: // if the host was not found
+ case QTcpSocket::ErrHostNotFound: // if the host was not found
msg.append("ErrHostNotFound");
break;
- case QSocket::ErrSocketRead: // if a read from the socket failed
+ case QTcpSocket::ErrSocketRead: // if a read from the socket failed
msg.append("ErrSocketRead");
break;
}
-
- if(statusbar) statusbar->message(msg, 5000);
- MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec();
+ */
+ if(statusbar) statusbar->showMessage(msg, 5000);
+ MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec();
accept();
}
@@ -367,7 +369,7 @@ void CPRQueryDialog::cprSocket_readyRead()
if (!cprSocket->canReadLine()) return;
QString msg = QString("Recieving name from cpr database...");
- if(statusbar) statusbar->message(msg, 5000);
+ if(statusbar) statusbar->showMessage(msg, 5000);
timer->stop();
while(cprSocket->canReadLine()) {
@@ -375,13 +377,13 @@ void CPRQueryDialog::cprSocket_readyRead()
if (s.startsWith("0001")) {
name.append(s.right(s.length()-4));
lastname.append(s.right(s.length()-4));
- name.setLength(name.length()-1);
+ name = name.left(name.length()-1);
if (name.length()) name += QString(", ");
}
if (s.startsWith("0002")) {
name.append(s.right(s.length()-4));
firstname.append(s.right(s.length()-4));
- name.setLength(name.length()-1);
+ name = name.left(name.length()-1);
cprSocket->close();
lbl_name->setText(name);
accept();
@@ -408,11 +410,11 @@ void CPRQueryDialog::cprSocket_readyRead()
void CPRQueryDialog::cprSocket_connected()
{
QString msg = QString("Connected to cpr database, sending cpr number...");
- if(statusbar) statusbar->message(msg, 5000);
+ if(statusbar) statusbar->showMessage(msg, 5000);
timer->stop();
- cprSocket->writeBlock(internalCpr, 10);
- cprSocket->writeBlock("\n", 1);
+ cprSocket->write(internalCpr, 10);
+ cprSocket->write("\n", 1);
}
/**
@@ -426,29 +428,28 @@ void CPRQueryDialog::cprSocket_timeout()
lbl_name->setText(NAME_NOT_AVAILABLE);
-
+ /* // TODO
// Print connection status
switch(cprSocket->state()) {
- case QSocket::Idle: // if there is no connection
+ case QTcpSocket::Idle: // if there is no connection
msg.append("Idle");
break;
- case QSocket::HostLookup: // during a DNS lookup
+ case QTcpSocket::HostLookup: // during a DNS lookup
msg.append("HostLookup");
break;
- case QSocket::Connecting: // during TCP connection establishment
+ case QTcpSocket::Connecting: // during TCP connection establishment
msg.append("Connecting");
break;
- case QSocket::Connected: // when there is an operational connection
+ case QTcpSocket::Connected: // when there is an operational connection
msg.append("Conected");
break;
- case QSocket::Closing: // if the socket is closing down, but is not yet closed.
+ case QTcpSocket::Closing: // if the socket is closing down, but is not yet closed.
msg.append("Closing");
break;
}
-
- if(statusbar) statusbar->message(msg, 5000);
- MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec();
+ */
+
+ if(statusbar) statusbar->showMessage(msg, 5000);
+ MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec();
accept();
}
-
-#endif /* USE_GUI */
diff --git a/src/cprquerydialog.h b/src/cprquerydialog.h
index 2acf1b4..7a84f5e 100644
--- a/src/cprquerydialog.h
+++ b/src/cprquerydialog.h
@@ -24,9 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __MIAV_CPRQUERYDIALOG_H__
#define __MIAV_CPRQUERYDIALOG_H__
@@ -49,40 +46,40 @@
/**
* Includes
*/
-#include <qdialog.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qfont.h>
+#include <QDialog>
+#include <QPushButton>
+#include <QLayout>
+#include <QLabel>
+#include <QFont>
-#include <qwidget.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qdialog.h>
-#include <qlabel.h>
-#include <qpixmap.h>
+#include <QWidget>
+#include <QLayout>
+#include <QPushButton>
+#include <QDialog>
+#include <QLabel>
+#include <QPixmap>
-#include <qsocket.h>
-#include <qtextedit.h>
-#include <qstring.h>
-#include <qwidget.h>
+#include <QTcpSocket>
+#include <QTextEdit>
+#include <QString>
+#include <QWidget>
-#include <qevent.h>
+#include <QEvent>
-#include <qpushbutton.h>
+#include <QPushButton>
-#include <qwidget.h>
-#include <qlayout.h>
-#include <qdialog.h>
+#include <QWidget>
+#include <QLayout>
+#include <QDialog>
#include <string>
using namespace std;
-#include <qdialog.h>
-#include <qlabel.h>
-#include <qsocket.h>
-#include <qtimer.h>
-#include <qstatusbar.h>
+#include <QDialog>
+#include <QLabel>
+#include <QTcpSocket>
+#include <QTimer>
+#include <QStatusBar>
#include "messagebox.h"
@@ -113,7 +110,7 @@ private:
QLabel *lbl_cpr;
QLabel *lbl_name;
- QSocket *cprSocket;
+ QTcpSocket *cprSocket;
char cpr[12];
char internalCpr[11];
@@ -153,6 +150,4 @@ private:
QTimer *timer;
};
-#endif /* USE_GUI */
-
#endif/*__MIAV_CPRQUERYDIALOG_H__*/
diff --git a/src/daemon.cc b/src/daemon.cc
index f5ebe41..84ad8d9 100644
--- a/src/daemon.cc
+++ b/src/daemon.cc
@@ -45,7 +45,7 @@ Daemon::Daemon()
Daemon::~Daemon()
{}
-int Daemon::run(const char *user, const char* group)
+int Daemon::run(const char *user, const char* group, bool foreground)
{
int f;
int fd;
@@ -75,44 +75,45 @@ int Daemon::run(const char *user, const char* group)
if(chdir("/") == -1) fprintf(stderr, "Could not chdir to '/'.\n");
umask(0);
- f = fork();
- switch(f) {
- case -1: // Fork error
- perror("Fork in daemon.cc");
- return 1;
-
- case 0: // Forked child
- // Switch to given group
- if(setgid(gid) != 0) {
- fprintf(stderr, "Failed to change to group \"%s\" (gid: %d), quitting.\n", group, gid);
- perror("");
- fprintf(stderr, "Runnning daemon as current group\n");
- }
-
- // Switch to given user
- if(setuid(uid) != 0) {
- fprintf(stderr, "Failed to change to user \"%s\" (uid: %d), quitting.\n", user, uid);
- perror("");
- fprintf(stderr, "Runnning daemon as current user\n");
+ if(!foreground) {
+ f = fork();
+ switch(f) {
+ case -1: // Fork error
+ perror("Fork in daemon.cc");
+ return 1;
+ case 0: // Forked child
+ break;
+ default: // Parent
+ return 0;
}
-
- // Redirect stdin, stdout and stderr to /dev/null
- fd = open("/dev/null", O_NOCTTY | O_RDWR, 0666);
+ }
- dup2(0, fd);
- dup2(1, fd);
- dup2(2, fd);
+ // Switch to given group
+ if(setgid(gid) != 0) {
+ fprintf(stderr, "Failed to change to group \"%s\" (gid: %d), quitting.\n", group, gid);
+ perror("");
+ fprintf(stderr, "Runnning daemon as current group\n");
+ }
+
+ // Switch to given user
+ if(setuid(uid) != 0) {
+ fprintf(stderr, "Failed to change to user \"%s\" (uid: %d), quitting.\n", user, uid);
+ perror("");
+ fprintf(stderr, "Runnning daemon as current user\n");
+ }
+
+ // Redirect stdin, stdout and stderr to /dev/null
+ fd = open("/dev/null", O_NOCTTY | O_RDWR, 0666);
+
+ dup2(0, fd);
+ dup2(1, fd);
+ dup2(2, fd);
- setsid();
-
- signal (SIGTERM, SIG_IGN);
- signal (SIGINT, SIG_IGN);
- signal (SIGHUP, SIG_IGN);
+ setsid();
- return daemon_main();
-
- default: // Parent
- // exit(0);
- return 0;
- }
+ signal (SIGTERM, SIG_IGN);
+ if(!foreground) signal (SIGINT, SIG_IGN);
+ signal (SIGHUP, SIG_IGN);
+
+ return daemon_main();
}
diff --git a/src/daemon.h b/src/daemon.h
index 1bd663e..63885b1 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -36,7 +36,7 @@ public:
/**
* Use NOBODY_GROUP and NOBODY_USER if no privileges are needed to run.
*/
- int run(const char* user, const char* group);
+ int run(const char* user, const char* group, bool foreground);
private:
virtual int daemon_main() = 0;
diff --git a/src/decoder.cc b/src/decoder.cc
index 0d56aca..ac039f9 100644
--- a/src/decoder.cc
+++ b/src/decoder.cc
@@ -32,12 +32,7 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
-#include "frame_stream.h"
-
-#include "miav_config.h"
+#include "decoder.h"
#include <time.h>
@@ -47,11 +42,13 @@
#include <SDL/SDL.h>
+#include "frame_stream.h"
+#include "miav_config.h"
+
#include "dv.h"
#include "dvfile.h"
#include "dv1394.h"
-#include "decoder.h"
#include "debug.h"
Decoder::Decoder(Info *ginfo,
@@ -282,5 +279,3 @@ void Decoder::setMute(bool m)
{
mute = m;
}
-
-#endif /*USE_GUI*/
diff --git a/src/decoder.h b/src/decoder.h
index 20878c7..7bdeb43 100644
--- a/src/decoder.h
+++ b/src/decoder.h
@@ -31,9 +31,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __RTVIDEOREC_DECODER_H
#define __RTVIDEOREC_DECODER_H
@@ -95,5 +92,3 @@ private:
};
#endif/* __RTVIDEOREC_DECODER_H*/
-
-#endif/*USE_GUI*/
diff --git a/src/dv1394.cc b/src/dv1394.cc
index 270da2e..fe06a4d 100644
--- a/src/dv1394.cc
+++ b/src/dv1394.cc
@@ -24,14 +24,8 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "dv1394.h"
-#ifdef USE_GUI
-
-#include "dv.h"
-
-
#include <stdlib.h>
#include <memory.h>
#include <stdio.h>
@@ -39,76 +33,31 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
+#include <sys/poll.h>
+#include "dv.h"
-
-/**
- * Callback function for the firewire interface.
- */
-static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadlet_t *data )
+static int write_frame(unsigned char *data, int len, int complete,
+ void *callback_data)
{
- static char *framedata = NULL;
-
- // Only process packets with reasonable length.
- if ( length > 16 )
- {
- unsigned char * p = ( unsigned char* ) & data[ 3 ];
- int section_type = p[ 0 ] >> 5; // section type is in bits 5 - 7
- int dif_sequence = p[ 1 ] >> 4; // dif sequence number is in bits 4 - 7
- int dif_block = p[ 2 ];
-
- if ( section_type == 0 && dif_sequence == 0 )
- {
- if ( framedata != NULL )
- {
- raw1394_set_userdata(handle, (void *)framedata);
- framedata = NULL;
- }
- }
-
- if(!framedata)
- {
- framedata = (char *)malloc(DVPACKAGE_SIZE); // dvframe.h
- if(!framedata)
- {
- // We're fucked
- fprintf(stderr, "Framedata allocation error: %s.\n", strerror( errno ) ); fflush(stderr);
- exit(1);
- }
- }
-
- switch ( section_type )
- {
- case 0: // 1 Header block
- // p[3] |= 0x80; // hack to force PAL data
- memcpy( framedata + dif_sequence * 150 * 80, p, 480 );
- break;
-
- case 1: // 2 Subcode blocks
- memcpy( framedata + dif_sequence * 150 * 80 + ( 1 + dif_block ) * 80, p, 480 );
- break;
-
- case 2: // 3 VAUX blocks
- memcpy( framedata + dif_sequence * 150 * 80 + ( 3 + dif_block ) * 80, p, 480 );
- break;
-
- case 3: // 9 Audio blocks interleaved with video
- memcpy( framedata + dif_sequence * 150 * 80 + ( 6 + dif_block * 16 ) * 80, p, 480 );
- break;
-
- case 4: // 135 Video blocks interleaved with audio
- memcpy( framedata + dif_sequence * 150 * 80 + ( 7 + ( dif_block / 15 ) + dif_block ) * 80, p, 480 );
- break;
-
- default: // we can't handle any other data
- break;
- }
- }
- return 0;
+ class dv1394 *dv = (class dv1394*)callback_data;
+
+ if (complete == 0) {
+ fprintf (stderr, "Error: incomplete frame received!\n");
+ return 0;
+ }
+ //return (fwrite (data, len, 1, f) < 1) ? -1 : 0;
+ unsigned char *ptr = (unsigned char *)malloc(len);
+ memcpy(ptr, data, len);
+
+ dv->ptr = ptr;
+
+ return 1;
}
dv1394::dv1394(Info *i, int p, int c)
{
+ printf("dv1394::dv1394()\n");
info = i;
port = p;
channel = c;
@@ -116,60 +65,49 @@ dv1394::dv1394(Info *i, int p, int c)
dv1394::~dv1394()
{
+ printf("dv1394::~dv1394()\n");
+ iec61883_dv_fb_close (frame);
// Close firewire connection.
- if(handle) raw1394_destroy_handle(handle);
+ if(handle) raw1394_destroy_handle (handle);
}
bool dv1394::connect()
{
- int n_ports;
- struct raw1394_portinfo pinf[ 16 ];
+ printf("dv1394::connect()\n");
- // Get handle to firewire channels
- handle = raw1394_new_handle();
- if(!handle) {
- info->error("raw1394 - failed to get handle: %s.", strerror( errno ) );
- return false;
- }
+ handle = raw1394_new_handle_on_port(port);
+ printf(" handle: %p\n", handle);
- // how many adapters are hooked in?
- if((n_ports = raw1394_get_port_info(handle, pinf, 16)) < 0 ) {
- info->error("raw1394 - failed to get port info: %s.", strerror( errno ) );
- raw1394_destroy_handle(handle);
- handle = NULL;
- return false;
- }
+ frame = iec61883_dv_fb_init(handle, write_frame, this);
+ printf(" frame: %p\n", frame);
- // Tell raw1394 which host adapter to use
- if(raw1394_set_port(handle, port) < 0 ) {
- info->error("raw1394 - failed to set port: %s.", strerror( errno ) );
- raw1394_destroy_handle(handle);
- handle = NULL;
+ if(frame && iec61883_dv_fb_start(frame, channel) == 0) {
+ // ok
+ printf("frame ok\n");
+ } else {
+ // fail
+ printf("frame fail\n");
return false;
- }
+ }
- raw1394_set_iso_handler( handle, channel, raw_reader);
- raw1394_set_userdata( handle, ( void* ) NULL);
- raw1394_start_iso_rcv( handle, channel);
-
return true;
}
unsigned char *dv1394::readFrame()
{
- // Firewire port not correctly opened.
- if(!handle) return NULL;
-
- unsigned char *ptr;
- while(1) {
- raw1394_loop_iterate(handle);
- ptr = (unsigned char *)raw1394_get_userdata(handle);
- if(ptr) {
- raw1394_set_userdata(handle, NULL);
- break;
+ struct pollfd pfd;
+ pfd.fd = raw1394_get_fd(handle);
+ pfd.events = POLLIN | POLLPRI;
+ pfd.revents = 0;
+
+ ptr = NULL;
+
+ while(ptr == NULL) {
+ if(poll (&pfd, 1, 50) > 0 && (pfd.revents & POLLIN)) {
+ raw1394_loop_iterate(handle);
}
}
+
return ptr;
}
-#endif/*USE_GUI*/
diff --git a/src/dv1394.h b/src/dv1394.h
index 7cea9d0..f2361c5 100644
--- a/src/dv1394.h
+++ b/src/dv1394.h
@@ -24,14 +24,11 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#ifndef __MIAV_DV1394_H__
#define __MIAV_DV1394_H__
-#ifdef USE_GUI
-
#include "frame_stream.h"
-#include <libraw1394/raw1394.h>
+#include <libiec61883/iec61883.h>
#include "info.h"
@@ -44,12 +41,14 @@ public:
unsigned char *readFrame();
+ unsigned char *ptr;
+
private:
raw1394handle_t handle;
+ iec61883_dv_fb_t frame;
Info *info;
int port;
int channel;
};
#endif/*__MIAV_DV1394_H__*/
-#endif/*USE_GUI*/
diff --git a/src/encoder.cc b/src/encoder.cc
index e7b79bf..a688585 100644
--- a/src/encoder.cc
+++ b/src/encoder.cc
@@ -32,11 +32,9 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
+#include "encoder.h"
#include "util.h"
-#include "encoder.h"
Encoder::Encoder(Info *ginfo,
const char *gip,
@@ -120,7 +118,7 @@ void Encoder::encode()
if(savestate != NO_CHANGE) savestate_sent = true;
h.header_type = DATA_HEADER;
- sprintf(h.header.h_data.cpr, cpr);
+ sprintf(h.header.h_data.cpr, "%s", cpr);
h.header.h_data.freeze = frame->freeze;
h.header.h_data.snapshot = frame->shoot;
h.header.h_data.record = frame->record;
@@ -269,5 +267,3 @@ void Encoder::stop(n_savestate save)
}
*/
}
-
-#endif /*USE_GUI*/
diff --git a/src/encoder.h b/src/encoder.h
index 0fada07..cf87987 100644
--- a/src/encoder.h
+++ b/src/encoder.h
@@ -31,26 +31,21 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __RTVIDEOREC_ENCODER_H
#define __RTVIDEOREC_ENCODER_H
-#include "thread.h"
-
-#include "info.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-//#include <avformat.h>
-#include "miav.h"
#include "util.h"
#include "package.h"
#include "frame.h"
#include "queue.h"
+#include "thread.h"
+#include "info.h"
+#include "socket.h"
+#include "network.h"
// FIXME: One size fits all...
#define VIDEO_BUFFER_SIZE (1024*1024)
@@ -113,6 +108,4 @@ private:
Network *n;
};
-#endif
-
-#endif /*USE_GUI*/
+#endif/*__RTVIDEOREC_ENCODER_H*/
diff --git a/src/file.cc b/src/file.cc
index 9279015..7c4725d 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -41,6 +41,14 @@
#include <netinet/in.h>
#include <stdlib.h>
+File::File(Info *i)
+{
+ info = i;
+ fd = 0;
+ savestate = NO_CHANGE;
+ filename = new char[1];
+ extension = new char[1];
+}
File::File(const char *fn, const char* ext, Info *i)
{
@@ -104,8 +112,8 @@ File::~File()
break;
}
- delete filename;
- delete extension;
+ delete[] filename;
+ delete[] extension;
}
int File::Move(char *destination)
diff --git a/src/file.h b/src/file.h
index 23ccc0c..845130e 100644
--- a/src/file.h
+++ b/src/file.h
@@ -41,10 +41,11 @@
class File {
public:
+ File(Info* info); // Empty constructor for unit tests.
File(const char *filename, const char* ext, Info* info);
~File();
- int Write(void* data, int size);
+ virtual int Write(void* data, int size);
/*
int Write(char* data, int size);
diff --git a/src/historywidget.cc b/src/historywidget.cc
index bdeb880..adb1627 100644
--- a/src/historywidget.cc
+++ b/src/historywidget.cc
@@ -24,8 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
#include "historywidget.h"
#include "miav_config.h"
@@ -47,8 +45,9 @@ void HistoryWidget::set_image(QImage *i)
image = new QImage(*i);
- QImage resized = image->smoothScale(width(), height());
- setPixmap(resized);
+ QImage resized = image->scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ p = QPixmap::fromImage(resized);
+ setPixmap(p);
}
QImage * HistoryWidget::get_image()
@@ -73,5 +72,3 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *event)
fs->set_image(image);
}
}
-
-#endif/*USE_GUI*/
diff --git a/src/historywidget.h b/src/historywidget.h
index d464d59..85c498f 100644
--- a/src/historywidget.h
+++ b/src/historywidget.h
@@ -24,13 +24,11 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
#ifndef __MIAV_HISTORYWIDGET_H__
#define __MIAV_HISTORYWIDGET_H__
-#include <qlabel.h>
-#include <qimage.h>
+#include <QLabel>
+#include <QImage>
class HistoryWidget : public QLabel {
Q_OBJECT
@@ -44,9 +42,9 @@ public:
void mouseReleaseEvent(QMouseEvent *event);
private:
+ QPixmap p;
QImage *image;
QWidget *parent;
};
#endif/*__MIAV_HISTORYWIDGET_H__*/
-#endif/*USE_GUI*/
diff --git a/src/img_encoder.cc b/src/img_encoder.cc
index 9282dc0..1d4a706 100644
--- a/src/img_encoder.cc
+++ b/src/img_encoder.cc
@@ -35,6 +35,8 @@
#include "img_encoder.h"
#include <stdio.h>
+#include "miav_config.h"
+
#include "debug.h"
extern "C" {
diff --git a/src/info.h b/src/info.h
index 6c0f6de..a725e40 100644
--- a/src/info.h
+++ b/src/info.h
@@ -28,8 +28,6 @@
#ifndef __MIAV_INFO_H__
#define __MIAV_INFO_H__
-#include "miav_config.h"
-// Cyclic include :(
class MiavConfig;
#include <time.h>
diff --git a/src/info_gui.cc b/src/info_gui.cc
index cb2e51d..f8072e1 100644
--- a/src/info_gui.cc
+++ b/src/info_gui.cc
@@ -24,9 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
#include "info_gui.h"
#include <stdio.h>
@@ -38,9 +35,11 @@ bool InfoEventHandler::eventFilter( QObject *o, QEvent *e )
{
if ( e->type() == TYPE_SHOW_MESSAGEBOX ) {
// fprintf(stderr, "Custom event!\n"); fflush(stderr);
+ /* // TODO
MessageBox *msgbox = ((ShowMessageEvent*)e)->messagebox();
msgbox->exec();
delete msgbox;
+ */
return TRUE; // eat event
} else {
// standard event processing
@@ -69,7 +68,7 @@ void InfoGui::setParent(QWidget *p)
parent = p;
}
-void InfoGui::showmsg(char *msg, char *title, msg_icon icon)
+void InfoGui::showmsg(const char *msg, const char *title, msg_icon icon)
{
pthread_mutex_lock(&mutex);
// Beginning of safezone
@@ -86,14 +85,16 @@ void InfoGui::showmsg(char *msg, char *title, msg_icon icon)
MessageBox *msgbox = new MessageBox(parent,
title,
- msg,
+ msg,
TYPE_OK,
icon);
+ (void)msgbox;
+ /* // TODO
ShowMessageEvent *event = new ShowMessageEvent( msgbox );
qapp->postEvent(parent, event);
-
+ */
// End of safezone
pthread_mutex_unlock(&mutex);
}
@@ -139,6 +140,3 @@ void InfoGui::info(const char *fmt, ...)
log("Info: %s", buf);
}
-
-
-#endif/*USE_GUI*/
diff --git a/src/info_gui.h b/src/info_gui.h
index 75322a0..58fc67a 100644
--- a/src/info_gui.h
+++ b/src/info_gui.h
@@ -24,30 +24,28 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#ifndef __MIAV_INFO_GUI_H__
#define __MIAV_INFO_GUI_H__
-#ifdef USE_GUI
-
#define TXT_ERROR_TITLE "Der er opstået en fejl!"
#define TXT_WARNING_TITLE "Advarsel"
#define TXT_INFO_TITLE "Information"
-#include "info.h"
-
-#include "miav_config.h"
-
-#include <qwidget.h>
-#include <qapplication.h>
+#include <QWidget>
+#include <QApplication>
#include <pthread.h>
#include <semaphore.h>
+#include "info.h"
+
+#include "miav_config.h"
+
#include "messagebox.h"
#define TYPE_SHOW_MESSAGEBOX 65432
+/* // TODO
class ShowMessageEvent : public QCustomEvent {
public:
ShowMessageEvent( MessageBox* msgbox )
@@ -56,7 +54,7 @@ public:
private:
MessageBox *m;;
};
-
+*/
class InfoEventHandler : public QObject {
protected:
bool eventFilter( QObject *o, QEvent *e );
@@ -75,12 +73,10 @@ public:
void setParent(QWidget *p);
private:
- void showmsg(char *msg, char *title, msg_icon icon);
+ void showmsg(const char *msg, const char *title, msg_icon icon);
QApplication *qapp;
QWidget *parent;
};
#endif/*__MIAV_INFO_GUI_H__*/
-
-#endif/*USE_GUI*/
diff --git a/src/iso11172-1.h b/src/iso11172-1.h
index a011383..09588d1 100644
--- a/src/iso11172-1.h
+++ b/src/iso11172-1.h
@@ -29,11 +29,11 @@
* This file contains symbols used to create an ISO11172-1 compatible multiplexed
* MPEG stream.
*/
-
-#include "config.h"
#ifndef __MIAV_ISO11172_1_H__
#define __MIAV_ISO11172_1_H__
+#include <stdint.h>
+
#define CLOCK_90KHZ 90000
namespace ISO11172_1 {
@@ -43,61 +43,63 @@ namespace ISO11172_1 {
// 64 bits (8 bytes)
typedef union {
struct {
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
- unsigned long long int stuffing_byte:8;
- unsigned long long int packet_length:16;
+ uint64_t marker_bit3:1;
+ uint64_t system_clock_reference3:15;
+ uint64_t marker_bit2:1;
+ uint64_t system_clock_reference2:15;
+ uint64_t marker_bit1:1;
+ uint64_t system_clock_reference1:3;
+ uint64_t padding:4;
+ uint64_t stuffing_byte:8;
+ uint64_t packet_length:16;
} bits;
- unsigned long long int ulli;
+ uint64_t ulli;
} packet_header;
- typedef union {
+#define MASK3 0x7
+#define MASK15 0x7FFF
+#define TIMECODE32_30(x) ((x >> 30) & MASK3 )
+#define TIMECODE29_15(x) ((x >> 15) & MASK15)
+#define TIMECODE14_0(x) ((x >> 0) & MASK15)
+
+ typedef union { // <============ you are here...
struct {
- unsigned long long int marker_bit5:1;
- unsigned long long int mux_rate:22;
- unsigned long long int marker_bit4:1;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
+ uint64_t marker_bit5:1;
+ uint64_t mux_rate:22;
+ uint64_t marker_bit4:1;
+ uint64_t marker_bit3:1;
+ uint64_t system_clock_reference3:15;
+ uint64_t marker_bit2:1;
+ uint64_t system_clock_reference2:15;
+ uint64_t marker_bit1:1;
+ uint64_t system_clock_reference1:3;
+ uint64_t padding:4;
} bits;
- unsigned long long int ulli;
+ uint64_t ulli;
} pack_header;
typedef union {
struct {
- unsigned long long int reserved_byte:8;
- unsigned long long int video_bound:5;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_video_clock_flag:1;
- unsigned long long int system_audio_clock_flag:1;
- unsigned long long int CSPS_flag:1;
- unsigned long long int fixed_flag:1;
- unsigned long long int audio_bound:6;
- unsigned long long int marker_bit2:1;
- unsigned long long int rate_bound:22;
- unsigned long long int marker_bit1:1;
- unsigned long long int header_length:16;
+ uint32_t reserved_byte:8;
+ uint32_t video_bound:5;
+ uint32_t marker_bit:1;
+ uint32_t system_video_clock_flag:1;
+ uint32_t system_audio_clock_flag:1;
+ uint32_t CSPS_flag:1;
+ uint32_t fixed_flag:1;
+ uint32_t audio_bound:6;
} bits;
- unsigned long long int ulli;
+ uint32_t ulli;
} system_header;
typedef union {
struct {
- unsigned long int STD_buffer_size_bound:13;
- unsigned long int STD_buffer_bound_scale:1;
- unsigned long int market_bits:2;
- unsigned long int stream_id:8;
+ uint32_t STD_buffer_size_bound:13;
+ uint32_t STD_buffer_bound_scale:1;
+ uint32_t market_bits:2;
+ uint32_t stream_id:8;
} bits;
- unsigned long int uli;
+ uint32_t uli;
} stream_description;
////////////////////////////////////////////////////
@@ -145,9 +147,17 @@ namespace ISO11172_1 {
}
/**
- * Calculates Rmux according to subclause A.5.4
+ * Calculates Rmux according to subclause A.6.4
* mux stands for multiplexing and R for Rate,
* so Rmux is the rate of the multiplexing.
+ * IMPORTANT: The formula is wrong...
+ * See
+ * https://www.iso.org/obp/ui/#iso:std:iso-iec:11172:-1:ed-1:v1:cor:2:v1:en
+ * for the correct formula:
+ * Rmux = (video_data_rate + audio_data_rate) *
+ * packet_header_size + pack_header_size / packets_per_pack
+ * ( 1 + ---------------------------------------------------------- )
+ * packet_data_size
*/
inline unsigned int Rmux(unsigned int video_data_rate,
unsigned int audio_data_rate,
diff --git a/src/libfame_wrapper.cc b/src/libfame_wrapper.cc
index dc453a8..f2e9adb 100644
--- a/src/libfame_wrapper.cc
+++ b/src/libfame_wrapper.cc
@@ -243,6 +243,13 @@ Frame *LibFAMEWrapper::encode(Frame *dvframe)
output->size += written;
}
+ /*
+ FILE *fp = fopen("/tmp/dims.mpg", "a");
+ size_t sz = fwrite(output->data, output->size, 1, fp);
+ (void)sz;
+ fclose(fp);
+ */
+
// fame_frame_statistics_t stats;
// fame_end_frame(fame_context, &stats);
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 5e64a75..c8c427b 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -24,23 +24,20 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
#include "mainwindow.h"
-#include <qpainter.h>
-#include <qpicture.h>
+#include <QPainter>
+#include <QPicture>
-#include <qpushbutton.h>
-#include <qfont.h>
-#include <qpixmap.h>
-#include <qbitmap.h>
-#include <qimage.h>
-#include <qlayout.h>
-#include <qgroupbox.h>
+#include <QPushButton>
+#include <QFont>
+#include <QPixmap>
+#include <QBitmap>
+#include <QImage>
+#include <QLayout>
+#include <QGroupBox>
-#include <qstatusbar.h>
+#include <QStatusBar>
#include <math.h>
@@ -53,10 +50,10 @@
//"miav-grab.h"
//#define WITH_DV
-MainWindow::MainWindow(QApplication *qApp, QWidget* parent, const char* name )
- : QWidget( parent, name, WStyle_Customize | WStyle_NoBorder )
+MainWindow::MainWindow(QApplication *_qApp, QWidget* parent, const char* name )
+ : QWidget( parent, Qt::FramelessWindowHint )
{
- info = new InfoGui(qApp, this, config);
+ info = new InfoGui(_qApp, this, config);
info->log("Starting MIaV v. %s.", VERSION);
@@ -128,7 +125,7 @@ MainWindow::~MainWindow()
info->log("MIaV is shut down.");
}
-QImage *MainWindow::loadButtonIcon( char *name, int height )
+QImage *MainWindow::loadButtonIcon( const char *name, int height )
{
QImage scaled;
@@ -140,14 +137,14 @@ QImage *MainWindow::loadButtonIcon( char *name, int height )
int h = (int)(height * unit);
int w = (int)((float)img->width() / (float)(img->height() / (float)h));
- scaled = img->smoothScale(w, h);
+ scaled = img->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
delete img;
img = new QImage(scaled);
return img;
}
-QImage *MainWindow::loadImage( char *name )
+QImage *MainWindow::loadImage( const char *name )
{
QImage *img;
@@ -159,6 +156,7 @@ QImage *MainWindow::loadImage( char *name )
void MainWindow::createGui()
{
+ QPixmap p;
// Layout widgets
/* __________________________________________________
@@ -182,20 +180,23 @@ void MainWindow::createGui()
* |_______________________________|__________________|
*/
- QGridLayout *g0 = new QGridLayout(this, 2, 2, 0, -1);
- QGridLayout *g1 = new QGridLayout(4, 4, -1);
+ QGridLayout *g0 = new QGridLayout(this);//, 2, 2, 0, -1);
+ QGridLayout *g1 = new QGridLayout();//4, 4, -1);
g0->addLayout(g1, 0, 0);
QGroupBox *gb = new QGroupBox(this);
+ gb->setLayout(new QVBoxLayout());
+ /* // TODO
// gb->setRows(NUM_HISTORY);
gb->setColumns(1);
// gb->setTitle("fisk");
// QGridLayout *g2 = new QGridLayout(1, NUM_HISTORY, -1);
// QVBoxLayout *g2 = new QVBoxLayout(this);
// g0->addLayout(g2, 0, 1);
-
+
gb->setInsideMargin(HISTORY_LIST_MARGIN);
gb->setInsideSpacing(HISTORY_LIST_SPACING);
+ */
gb->setFlat(true);
g0->addWidget(gb, 0, 1);
@@ -204,7 +205,7 @@ void MainWindow::createGui()
int output_width = resolution_w - // this->width() -
(int)(BUTTON_WIDTH * unit) -
- (gb->insideMargin() * 2) -
+ // (gb->insideMargin() * 2) - // TODO
g1->margin() * 2 -
g0->margin() * 2;
@@ -214,53 +215,56 @@ void MainWindow::createGui()
g0->margin() * 3;
img_recedge = new QLabel(this);
- img_recedge->setBackgroundColor(QColor(160,160,160));
+ //img_recedge->setBackgroundColor(QColor(160,160,160));
img_recedge->setFixedSize(output_width, output_height);
img_live = new VideoWidget(img_recedge, camera);
img_live->setFixedSize(output_width - 20, output_height - 20);
img_live->move(10,10);
- g1->addMultiCellWidget ( img_recedge, 0, 0, 0, 3, Qt::AlignHCenter);
+ //g1->addWidget ( img_recedge, 0, 0, 0, 3, Qt::AlignHCenter);
+ g1->addWidget ( img_recedge, 0, 0, 1, 4, Qt::AlignHCenter);
// QObject::connect( img_live, SIGNAL(clicked()), this, SLOT(live_clicked()) );
// CPR/NAME LABEL + CPR button
lbl_cpr = createLabel("", output_width - (int)(BUTTON_WIDTH * unit), BUTTON_HEIGHT);
- g1->addMultiCellWidget ( lbl_cpr, 1, 1, 0, 2);
+ //g1->addWidget ( lbl_cpr, 1, 1, 0, 2);
+ g1->addWidget ( lbl_cpr, 1, 0, 1, 2);
btn_cpr = createButton("");
btn_cpr->setFocus();
- btn_cpr->setPixmap(*img_cpr);
+ btn_cpr->setIcon(QPixmap(PIXMAP_CPR));
QObject::connect( btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked()) );
// Will also be connected in the MGUI code
g1->addWidget(btn_cpr, 1, 3);
lbl_name = createLabel("", output_width, (int)(BUTTON_HEIGHT * 0.8f));
- g1->addMultiCellWidget ( lbl_name, 2, 2, 0, 3);
+ //g1->addWidget ( lbl_name, 2, 2, 0, 3);
+ g1->addWidget ( lbl_name, 2, 0, 1, 2);
/*
btn_clear = createButton("");
- btn_clear->setPixmap(*img_clear);
+ btn_clear->setIcon(QPixmap(PIXMAP_CLEAR));
QObject::connect( btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked()) );
// Will also be connected in the MGUI code
g1->addWidget(btn_clear, 1, 2);
*/
// Rec + Shot + Freeze buttons
btn_rec = createButton("");
- btn_rec->setPixmap(*img_record);
+ btn_rec->setIcon(QPixmap(PIXMAP_RECORD));
QObject::connect( btn_rec, SIGNAL(clicked()), this, SLOT(rec_clicked()) );
g1->addWidget(btn_rec, 3, 0);
btn_shoot = createButton("");
- btn_shoot->setPixmap(*img_snapshot);
+ btn_shoot->setIcon(QPixmap(PIXMAP_SNAPSHOT));
QObject::connect( btn_shoot, SIGNAL(clicked()), this, SLOT(shoot_clicked()) );
g1->addWidget(btn_shoot, 3, 1);
btn_freeze = createButton("");
- btn_freeze->setPixmap(*img_freeze);
+ btn_freeze->setIcon(QPixmap(PIXMAP_FREEZE));
QObject::connect( btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked()) );
g1->addWidget(btn_freeze, 3, 2);
btn_mute = createButton("");
- btn_mute->setPixmap(*img_unmute);
+ btn_mute->setIcon(QPixmap(PIXMAP_UNMUTE));
QObject::connect( btn_mute, SIGNAL(clicked()), this, SLOT(mute_clicked()) );
g1->addWidget(btn_mute, 3, 3);
@@ -278,62 +282,70 @@ void MainWindow::createGui()
img_history[i] = new HistoryWidget(gb);
img_history[i]->set_image(img_dummy);
img_history[i]->setFixedSize(w, h);
+ img_history[i]->show();
+ gb->layout()->addWidget(img_history[i]);
}
// Clear button
btn_clear = createButton("", gb);
- btn_clear->setPixmap(*img_clear);
+ btn_clear->setIcon(QPixmap(PIXMAP_CLEAR));
QObject::connect( btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked()) );
+ gb->layout()->addWidget(btn_clear);
// Statusbar
status = new QStatusBar(this);
status->setSizeGripEnabled(FALSE);
// status->setFont(QFont( "Sans Serif", (int)(unit * height / 3), QFont::Normal ));
- g0->addMultiCellWidget(status, 4, 4, 0, 1);
+ //g0->addWidget(status, 4, 4, 0, 1);
+ g0->addWidget(status, 4, 0, 1, 2);
lbl_recordtime = createLabel("", BUTTON_WIDTH, 1);
+ /*
lbl_recordtime->setFixedWidth((int)(BUTTON_WIDTH * unit) +
- (gb->insideMargin() * 2) +
+ //(gb->insideMargin() * 2) +
g1->margin() * 2 +
g0->margin() * 2);
- status->addWidget(lbl_recordtime, 0, TRUE);
+ */
+ status->addPermanentWidget(lbl_recordtime);//, 0, TRUE);
// About button
btn_about = new QPushButton("", this);
btn_about->setFixedHeight((int)unit);
- btn_about->setPixmap(*img_logo);
+ btn_about->setIcon(QPixmap(PIXMAP_LOGO_SMALL));
QObject::connect( btn_about, SIGNAL(clicked()), this, SLOT(about_clicked()) );
- status->addWidget(btn_about, 0, TRUE);
+ status->addPermanentWidget(btn_about);//, 0, TRUE);
// Version label
lbl_version = createLabel("MIaV-Grab v" VERSION, BUTTON_WIDTH, 1);
lbl_version->setFixedWidth((int)(BUTTON_WIDTH * unit) +
- (gb->insideMargin() * 2) +
+ //(gb->insideMargin() * 2) +
g1->margin() * 2 +
g0->margin() * 2);
- status->addWidget(lbl_version, 0, TRUE);
+ status->addPermanentWidget(lbl_version);//, 0, TRUE);
- status->message( TXT_READY );
+ status->showMessage( TXT_READY );
}
-QPushButton *MainWindow::createButton(char *caption, int width, int height)
+QPushButton *MainWindow::createButton(const char *caption, int width, int height)
{
return createButton(caption, this);//, width, height);
}
-QPushButton *MainWindow::createButton(char *caption, QWidget *parent, int width, int height)
+QPushButton *MainWindow::createButton(const char *caption, QWidget *parent, int width, int height)
{
QPushButton *btn = new QPushButton(caption, parent);
btn->setFont( QFont( "Sans Serif", (int)(unit * height / 2), QFont::Bold ) );
btn->setFixedHeight((int)(unit * height));
// btn->setFixedWidth((int)(unit * width));
+ btn->setIconSize(QSize(2 * unit * height, unit * height));
+ btn->setContentsMargins(0,0,0,0);
return btn;
}
-QLabel *MainWindow::createLabel(char *caption, int width, int height)
+QLabel *MainWindow::createLabel(const char *caption, int width, int height)
{
QLabel *lbl = new QLabel(caption, this);
lbl->setFont( QFont( "Sans Serif",
@@ -385,16 +397,18 @@ void MainWindow::taskbar_update()
#define SPEED 0.07f
void MainWindow::redraw_edge()
{
+ /* // TODO
rec_edge_counter += SPEED;
float val = fabs(sin(rec_edge_counter));
img_recedge->setBackgroundColor(QColor((int) ((255 - GREY) * val + GREY),
(int) (GREY - (GREY * val)),
(int) (GREY - (GREY * val))));
+ */
}
void MainWindow::message(char *msg)
{
- status->message(msg);
+ status->showMessage(msg);
info->log("Message: %s", msg);
}
@@ -447,8 +461,8 @@ void MainWindow::cpr_clicked()
info->log("Activated CPR chooser.");
// Save CPR and name, from the labels.
- strcpy(oldname, lbl_name->text().ascii());
- strcpy(oldcpr, lbl_cpr->text().ascii());
+ strcpy(oldname, lbl_name->text().toStdString().c_str());
+ strcpy(oldcpr, lbl_cpr->text().toStdString().c_str());
clear();
@@ -462,25 +476,26 @@ void MainWindow::cpr_clicked()
info->log("Cancelled CPR chooser.");
} else {
// Change CPR camera.
- info->log("New CPR %s (old %s).", (char*)lbl_cpr->text().ascii(), oldcpr);
- strcpy(oldname, lbl_name->text().ascii());
- strcpy(oldcpr, lbl_cpr->text().ascii());
+ info->log("New CPR %s (old %s).", (char*)lbl_cpr->text().toStdString().c_str(), oldcpr);
+ strcpy(oldname, lbl_name->text().toStdString().c_str());
+ strcpy(oldcpr, lbl_cpr->text().toStdString().c_str());
clear();
lbl_name->setText(oldname);
lbl_cpr->setText(oldcpr);
- camera->setCpr((char*)lbl_cpr->text().ascii(), (char*)lbl_name->text().ascii());
+ camera->setCpr((char*)lbl_cpr->text().toStdString().c_str(), (char*)lbl_name->text().toStdString().c_str());
}
}
void MainWindow::rec_clicked()
{
+ QPixmap p;
if(!recording) {
info->log("Start recording.");
recording = 1;
// Start flashing the edge
rec_edge_counter = 0.0f;
timer->start(100);
- btn_rec->setPixmap(*img_stop);
+ btn_rec->setIcon(QPixmap(PIXMAP_STOP));
camera->start();
} else {
switch(MessageBox(this,
@@ -493,8 +508,8 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(SAVE);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ //img_recedge->setBackgroundColor(QColor(160,160,160)); // TODO
+ btn_rec->setIcon(QPixmap(PIXMAP_RECORD));
break;
case MSG_NO:
@@ -502,8 +517,8 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(DELETE);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ //img_recedge->setBackgroundColor(QColor(160,160,160));// TODO
+ btn_rec->setIcon(QPixmap(PIXMAP_RECORD));
break;
case MSG_MAYBE:
@@ -511,8 +526,8 @@ void MainWindow::rec_clicked()
recording = 0;
camera->stop(LATER);
timer->stop();
- img_recedge->setBackgroundColor(QColor(160,160,160));
- btn_rec->setPixmap(*img_record);
+ //img_recedge->setBackgroundColor(QColor(160,160,160));// TODO
+ btn_rec->setIcon(QPixmap(PIXMAP_RECORD));
break;
case MSG_CANCEL:
@@ -524,10 +539,11 @@ void MainWindow::rec_clicked()
void MainWindow::shoot_clicked()
{
+ QPixmap p;
// unsigned char pixels[720*576*3];
info->log("Snapshot (%s).", frozen?"frozen":"unfrozen");
- QImage screenshot(720, 576, 32);
+ QImage screenshot(720, 576, QImage::Format_RGB32);
camera->snapshot(screenshot.bits());
@@ -540,36 +556,39 @@ void MainWindow::shoot_clicked()
if(frozen) {
camera->unfreeze();
- btn_freeze->setPixmap(*img_freeze);
- btn_freeze->setOn(false);
+ btn_freeze->setIcon(QPixmap(PIXMAP_FREEZE));
+ btn_freeze->setChecked(false);
frozen = false;
}
}
void MainWindow::freeze_clicked()
{
+ QPixmap p;
if(frozen) {
info->log("Unfreeze.");
camera->unfreeze();
- btn_freeze->setPixmap(*img_freeze);
- btn_freeze->setOn(false);
+ btn_freeze->setIcon(QPixmap(PIXMAP_FREEZE));
+ btn_freeze->setChecked(false);
frozen = false;
} else {
info->log("Freeze.");
camera->freeze();
- btn_freeze->setPixmap(*img_unfreeze);
- btn_freeze->setOn(true);
+ btn_freeze->setIcon(QPixmap(PIXMAP_UNFREEZE));
+ btn_freeze->setChecked(true);
frozen = true;
}
}
void MainWindow::mute_clicked()
{
+ QPixmap p;
muted = !muted;
- if(muted) btn_mute->setPixmap(*img_mute);
- else btn_mute->setPixmap(*img_unmute);
+ if(muted) {
+ btn_mute->setIcon(QPixmap(PIXMAP_MUTE));
+ } else {
+ btn_mute->setIcon(QPixmap(PIXMAP_UNMUTE));
+ }
camera->setMute(muted);
}
-
-#endif /*USE_GUI*/
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 2ac7d82..3d47ffd 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -24,22 +24,20 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __MAINWINDOW_H__
#define __MAINWINDOW_H__
#include <string>
using namespace std;
-#include <qwidget.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qstatusbar.h>
-#include <qtimer.h>
-#include <qpixmap.h>
-#include <qimage.h>
+#include <QWidget>
+#include <QLabel>
+#include <QPushButton>
+#include <QStatusBar>
+#include <QTimer>
+#include <QPixmap>
+#include <QImage>
+#include <QApplication>
#include "videowidget.h"
#include "camera.h"
@@ -100,7 +98,7 @@ class MainWindow : public QWidget
{
Q_OBJECT
public:
- MainWindow(QApplication *qApp, QWidget* parent = 0, const char* name = 0);
+ MainWindow(QApplication *_qApp, QWidget* parent = 0, const char* name = 0);
~MainWindow();
void message(char* msg);
@@ -129,8 +127,8 @@ private:
Info *cam_info;
// Image loading routines.
- QImage *loadButtonIcon( char *name, int height = BUTTON_HEIGHT );
- QImage *loadImage( char *name );
+ QImage *loadButtonIcon( const char *name, int height = BUTTON_HEIGHT );
+ QImage *loadImage( const char *name );
QImage *img_unfreeze;
QImage *img_freeze;
@@ -183,11 +181,9 @@ private:
int video_width;
int video_height;
- QPushButton *createButton(char *caption, int width = BUTTON_WIDTH, int height = BUTTON_HEIGHT);
- QPushButton *createButton(char *caption, QWidget *parent, int width = BUTTON_WIDTH, int height = BUTTON_HEIGHT);
- QLabel *createLabel(char *caption, int width, int height);
+ QPushButton *createButton(const char *caption, int width = BUTTON_WIDTH, int height = BUTTON_HEIGHT);
+ QPushButton *createButton(const char *caption, QWidget *parent, int width = BUTTON_WIDTH, int height = BUTTON_HEIGHT);
+ QLabel *createLabel(const char *caption, int width, int height);
};
-#endif
-
-#endif /*USE_GUI*/
+#endif/*__MAINWINDOW_H__*/
diff --git a/src/messagebox.cc b/src/messagebox.cc
index fd812eb..f9e76da 100644
--- a/src/messagebox.cc
+++ b/src/messagebox.cc
@@ -24,9 +24,8 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
#include "messagebox.h"
+
#include "miav_config.h"
// For button sizes!
@@ -43,14 +42,14 @@ MessageBox::MessageBox(QWidget* parent,
const char* text,
msg_type type,
msg_icon icon)
- : QDialog(parent, name, TRUE)
+ : QDialog(parent) //, name, TRUE)
{
int resolution_w = config->readInt("pixel_width");
//int resolution_h = config->readInt("pixel_height");
unit = ((float)resolution_w / config->readFloat("screensize")) / INCH_IN_CM;
- setCaption(name);
+ setWindowTitle(name);
QFrame *topf = new QFrame(this);
topf->setFrameStyle(QFrame::Box | QFrame::Raised);
topf->setLineWidth(3);
@@ -116,7 +115,7 @@ MessageBox::MessageBox(QWidget* parent,
// lbl_text->setFont(QFont("Arial", 18));
QFrame *f = new QFrame(topf);
- QVBoxLayout *blayout = new QVBoxLayout(topf, 20, 20);
+ QVBoxLayout *blayout = new QVBoxLayout(topf);//, 20, 20);
blayout->addWidget(lbl_icon);
blayout->addWidget(lbl_text);
@@ -127,7 +126,7 @@ MessageBox::MessageBox(QWidget* parent,
case TYPE_OK:
{
QPushButton *bok = createButton(f, TXT_OK );
- QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 1, 20, 20);
glayout->addWidget(bok, 0, 0);
connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
break;
@@ -136,7 +135,7 @@ MessageBox::MessageBox(QWidget* parent,
{
QPushButton *bok = createButton(f, TXT_OK );
QPushButton *bcancel = createButton(f, TXT_CANCEL );
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 2, 20, 20);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(bok, 0, 2);
connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
@@ -147,7 +146,7 @@ MessageBox::MessageBox(QWidget* parent,
{
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 2, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(byes, 0, 1);
connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
@@ -159,7 +158,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bmaybe = createButton(f, TXT_MAYBE );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 3, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(byes, 0, 1);
glayout->addWidget(bmaybe, 0, 2);
@@ -173,7 +172,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 3, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(byes, 0, 2);
@@ -188,7 +187,7 @@ MessageBox::MessageBox(QWidget* parent,
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QPushButton *bno = createButton(f, TXT_NO );
QPushButton *byes = createButton(f, TXT_YES );
- QGridLayout *glayout = new QGridLayout(f, 1, 4, 20, 20);
+ QGridLayout *glayout = new QGridLayout(f);//, 1, 4, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(byes, 0, 2);
@@ -242,4 +241,3 @@ void MessageBox::bmaybe_clicked()
done(MSG_MAYBE);
}
-#endif/*USE_GUI*/
diff --git a/src/messagebox.h b/src/messagebox.h
index 30a8307..c34cf81 100644
--- a/src/messagebox.h
+++ b/src/messagebox.h
@@ -24,19 +24,16 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __MIAV_MESSAGEBOX_H__
#define __MIAV_MESSAGEBOX_H__
-#include <qdialog.h>
-#include <qwidget.h>
-#include <qframe.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qlabel.h>
-#include <qpixmap.h>
+#include <QDialog>
+#include <QWidget>
+#include <QFrame>
+#include <QLayout>
+#include <QPushButton>
+#include <QLabel>
+#include <QPixmap>
typedef enum {
ICON_NONE, // No icon is used
@@ -108,5 +105,3 @@ private:
};
#endif/*__MIAV_MESSAGEBOX_H__*/
-
-#endif /*USE_GUI*/
diff --git a/src/miav.cc b/src/miav.cc
index 24d6fe1..2217809 100644
--- a/src/miav.cc
+++ b/src/miav.cc
@@ -24,42 +24,19 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-
-#ifdef USE_GUI
-#include <qapplication.h>
-#include "mainwindow.h"
-#include "miav.h"
-#endif /* USE_GUI */
-
-#include "miav_daemon.h"
-
-#include "miav_config.h"
-
-#include "info_gui.h"
-#include "info_console.h"
+#include <QApplication>
#include <stdio.h>
#include <string.h>
-typedef enum {
- MODE_UNKNOWN,
- MODE_GRAB,
- MODE_SERVER
-} run_mode;
-
-#ifdef USE_GUI
-QApplication *miav_app;
-#endif/*USE_GUI*/
-
-/**
- * This function starts the MIaV gui.
- */
-int grab(int argc, char *argv[]) {
-#ifdef USE_GUI
+#include "mainwindow.h"
+#include "miav_config.h"
+#include "info_gui.h"
+#include "debug.h"
- QApplication miav_grab( argc, argv );
- miav_app = &miav_grab;
+int main(int argc, char *argv[])
+{
+ QApplication miav_grab(argc, argv);
MiavConfig cfg(ETC"/miav.conf", NULL);
InfoGui info(&miav_grab, NULL, &cfg);
@@ -69,62 +46,7 @@ int grab(int argc, char *argv[]) {
miav_grab.installEventFilter( eventhandler );
MainWindow mainwindow( &miav_grab );
- miav_grab.setMainWidget( &mainwindow );
info.setParent(&mainwindow);
return miav_grab.exec();
-
-#else /* USE_GUI */
-
- fprintf(stderr, "Error: MIaV was not compiled with GUI support...\n");
- return 0;
-
-#endif /* USE_GUI */
-}
-
-
-
-/**
- * This function starts the MIaV server.
- */
-int server(int argc, char *argv[])
-{
- MiavDaemon daemon;
-
- MiavConfig cfg(ETC"/miav.conf", NULL);
-
- string *user = cfg.readString("server_user");
- string *group = cfg.readString("server_group");
-
- return daemon.run(user->c_str(), group->c_str());
-}
-
-#include "debug.h"
-
-int main(int argc, char *argv[])
-{
- run_mode mode = MODE_UNKNOWN;
-
- if(argc >= 2) {
- if(!strcmp(argv[1], "grab")) mode = MODE_GRAB;
- if(!strcmp(argv[1], "server")) mode = MODE_SERVER;
- }
-
- switch(mode) {
- case MODE_GRAB:
- {
- return grab(argc - 2, &argv[2]);
- }
- case MODE_SERVER:
- {
- return server(argc - 2, &argv[2]);
- }
- case MODE_UNKNOWN:
- {
- printf("Usage: %s [mode] [mode options]\n", argv[0]);
- printf("[mode] can be one of the following: grab or server.\n");
- return 1;
- }
- }
- return 0;
}
diff --git a/src/miav_config.cc b/src/miav_config.cc
index 4e4b82b..d20055f 100644
--- a/src/miav_config.cc
+++ b/src/miav_config.cc
@@ -33,6 +33,11 @@
MiavConfig *config;
+MiavConfig::MiavConfig()
+{
+ info = NULL;
+}
+
MiavConfig::MiavConfig(const char *file, Info *i)
{
info = i;
diff --git a/src/miav_config.h b/src/miav_config.h
index ddd1375..e98b729 100644
--- a/src/miav_config.h
+++ b/src/miav_config.h
@@ -64,6 +64,7 @@ typedef struct __cfg {
class MiavConfig {
public:
+ MiavConfig(); // Empty constructor for unit tests.
MiavConfig(const char *file, Info *info = NULL);
~MiavConfig();
diff --git a/src/miav.h b/src/miavd.cc
index ce7842a..1c0d63f 100644
--- a/src/miav.h
+++ b/src/miavd.cc
@@ -1,9 +1,9 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/***************************************************************************
- * miav.h
+ * miavd.cc
*
- * Mon Nov 8 09:59:24 CET 2004
- * Copyright 2004 Bent Bisballe
+ * Sat Aug 21 17:32:24 2004
+ * Copyright 2004 deva
* deva@aasimon.org
****************************************************************************/
@@ -24,19 +24,26 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifndef __LIBMIAV_H__
-#define __LIBMIAV_H__
+#include <config.h>
-#include "util.h"
+#include "miav_daemon.h"
-#include "network.h"
-#include "socket.h"
-#include "queue.h"
+#include "miav_config.h"
-#ifdef USE_GUI
-#include <qapplication.h>
-extern QApplication *miav_app;
-#endif/*USE_GUI*/
+//#include "info_console.h"
+#include "debug.h"
-#endif/*__LIBMIAV_H__*/
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+ MiavDaemon daemon;
+
+ MiavConfig cfg(ETC"/miav.conf", NULL);
+
+ string *user = cfg.readString("server_user");
+ string *group = cfg.readString("server_group");
+
+ return daemon.run(user->c_str(), group->c_str(), true);
+}
diff --git a/src/multiplexer.cc b/src/multiplexer.cc
index de6180f..d4526bc 100644
--- a/src/multiplexer.cc
+++ b/src/multiplexer.cc
@@ -33,13 +33,19 @@
#include "util.h"
-#define SIZEOF(x) (sizeof(x)-1)
+static uint64_t htonll(uint64_t value)
+{
+ int num = 42;
+ if(*(char *)&num == 42) {
+ return ((uint64_t)htonl(value & 0xffffffff) << 32) |
+ (uint64_t)htonl(value >> 32);
+ }
+
+ return value;
+}
+#define ntohll(v) htonll(v)
-#define MASK3 0x7
-#define MASK15 0x7FFF
-#define TIMECODE32_30(x) ((x >> 30) & MASK3 )
-#define TIMECODE29_15(x) ((x >> 15) & MASK15)
-#define TIMECODE14_0(x) ((x >> 0) & MASK15)
+#define SIZEOF(x) (sizeof(x)-1)
// Audio index lists
/*
@@ -114,50 +120,16 @@ int Multiplexer::Write(char* data, int size)
return Write((void*)data, size);
}
-int Multiplexer::Write(unsigned long long int val)
+int Multiplexer::Write(uint64_t val)
{
- int res;
- int written = 0;
- unsigned long int h_u = val & 0xffffffff;
- unsigned long int h_l = (val << 32) & 0xffffffff;
-
- h_u = htonl(h_u);
- h_l = htonl(h_l);
-
- if((res = Write(&h_l, sizeof(h_l))) < 0) {
- return res;
- }
- written += res;
-
- if((res = Write(&h_u, sizeof(h_u))) < 0) {
- return res;
- }
- written += res;
+ val = htonll(val);
- return written;
+ return Write((char*)&val, sizeof(val));
}
-int Multiplexer::Write(long long int val)
+int Multiplexer::Write(int64_t val)
{
- int res;
- int written = 0;
- unsigned long int h_u = val & 0xffffffff;
- unsigned long int h_l = (val << 32) & 0xffffffff;
-
- h_u = htonl(h_u);
- h_l = htonl(h_l);
-
- if((res = Write(&h_l, sizeof(h_l))) < 0) {
- return res;
- }
- written += res;
-
- if((res = Write(&h_u, sizeof(h_u))) < 0) {
- return res;
- }
- written += res;
-
- return written;
+ return Write((uint64_t)val);
}
int Multiplexer::Write(long int val)
@@ -174,6 +146,13 @@ int Multiplexer::Write(unsigned long int val)
return Write((char*)&val, sizeof(val));
}
+int Multiplexer::Write24(uint32_t val)
+{
+ val = htonl(val) >> 8;
+
+ return Write((char*)&val, 3 /*24 bit*/);
+}
+
int Multiplexer::Write(int val)
{
val = htonl(val);
@@ -348,17 +327,21 @@ void Multiplexer::system_header()
// info->info("\t\t[System Header]");
// system_header_start_code (32 bits)
- Write((void*)ISO11172_1::system_header_start_code, SIZEOF(ISO11172_1::system_header_start_code));
+ Write((void*)ISO11172_1::system_header_start_code,
+ SIZEOF(ISO11172_1::system_header_start_code));
- ISO11172_1::system_header header;
+ uint16_t header_length = 8 - 2 + (NUM_TYPES * 3);
+ // (sizeof(header) - sizeof(header.header_length)) +
+ // NUM_TYPES * sizeof(ISO11172_1::stream_description);
+ Write(header_length);
- header.bits.marker_bit1 = header.bits.marker_bit2 =
- header.bits.marker_bit3 = 1;
+ uint32_t rate_bound = (1 << 23) | // Marker bit
+ 3521 << 1 | // FIXME: This value was simply taken from an example!
+ 1; // Marker bit
+ Write24(rate_bound);
- header.bits.header_length = 8 - 2 + (NUM_TYPES * 3);
- // (sizeof(header) - sizeof(header.header_length)) +
- // NUM_TYPES * sizeof(ISO11172_1::stream_description);
- header.bits.rate_bound = 3521; // FIXME: Taken from the example!
+ ISO11172_1::system_header header;
+ header.bits.marker_bit = 1;
header.bits.audio_bound = 1; // Only 1 audio stream
header.bits.fixed_flag = 1; // Fixed bitrate (0 indicates vbr)
header.bits.CSPS_flag = 1; // Standarts compliant? (yes: see lame_set_strict_ISO in liblame_wrapper.cc)
@@ -366,33 +349,34 @@ void Multiplexer::system_header()
header.bits.system_video_clock_flag = 1; // FIXME: What excactly is this??
header.bits.video_bound = 1; // Only 1 video stream
header.bits.reserved_byte = 0xFF; // Must be 0xFF
- Write(header.ulli);
-
+ Write24(header.ulli);
+
ISO11172_1::stream_description audio_stream_description;
audio_stream_description.bits.stream_id = 0xC0;
- audio_stream_description.bits.market_bits = 0x3;
+ audio_stream_description.bits.market_bits = 3;
audio_stream_description.bits.STD_buffer_bound_scale = 0; // Must be 0 for audio streams
audio_stream_description.bits.STD_buffer_size_bound = 32; // Buffer must be 32 * 128 bytes
- Write(audio_stream_description.uli);
+ Write24(audio_stream_description.uli);
ISO11172_1::stream_description video_stream_description;
video_stream_description.bits.stream_id = 0xE3;
video_stream_description.bits.market_bits = 0x3;
video_stream_description.bits.STD_buffer_bound_scale = 1; // Must be 1 for video streams
video_stream_description.bits.STD_buffer_size_bound = 46; // Buffer must be 32 * 1024 bytes
- Write(video_stream_description.uli);
+
+ Write24(video_stream_description.uli);
}
/**
- * Create and write a pack
+ * Write pack header
*/
-bool Multiplexer::pack()
+void Multiplexer::pack_header()
{
- // info->info("\t[Pack");
-
Write((void*)ISO11172_1::pack_start_code, SIZEOF(ISO11172_1::pack_start_code));
ISO11172_1::pack_header header;
+ header.ulli = 0; // Reset all bits
+
// Set marker bits to 1
header.bits.marker_bit1 =
header.bits.marker_bit2 =
@@ -402,6 +386,18 @@ bool Multiplexer::pack()
header.bits.padding = 0x2;
+ header.bits.system_clock_reference1 = TIMECODE32_30(SCR);
+ header.bits.system_clock_reference2 = TIMECODE29_15(SCR);
+ header.bits.system_clock_reference3 = TIMECODE14_0(SCR);
+ /*
+ info->info("timecode All: %lld, 1: %lld, 2: %lld, 3: %lld",
+ SCR,
+ (unsigned long long int)header.system_clock_reference1,
+ (unsigned long long int)header.system_clock_reference2,
+ (unsigned long long int)header.system_clock_reference3
+ );
+ */
+
unsigned int video_data_rate;
unsigned int audio_data_rate;
@@ -412,11 +408,11 @@ bool Multiplexer::pack()
else video_data_rate = 1100000;
unsigned int Rmux = ISO11172_1::Rmux(video_data_rate,
- audio_data_rate,
- 20, // packet_header_size,
- 12, // pack_header_size,
- PACKETS_PER_PACK, // packets_per_pack,
- PACKET_SIZE);// packet_data_size)
+ audio_data_rate,
+ 20, // packet_header_size,
+ 12, // pack_header_size,
+ PACKETS_PER_PACK, // packets_per_pack,
+ PACKET_SIZE);// packet_data_size)
header.bits.mux_rate = Rmux;
//0x1B82;
@@ -429,18 +425,15 @@ bool Multiplexer::pack()
// SCR = 0x40010003LL;
- header.bits.system_clock_reference1 = TIMECODE32_30(SCR);
- header.bits.system_clock_reference2 = TIMECODE29_15(SCR);
- header.bits.system_clock_reference3 = TIMECODE14_0(SCR);
- /*
- info->info("timecode All: %lld, 1: %lld, 2: %lld, 3: %lld",
- SCR,
- (unsigned long long int)header.system_clock_reference1,
- (unsigned long long int)header.system_clock_reference2,
- (unsigned long long int)header.system_clock_reference3
- );
- */
Write(header.ulli);
+}
+
+/**
+ * Create and write a pack
+ */
+bool Multiplexer::pack()
+{
+ pack_header();
if(write_system_header % SYSTEM_HEADER_FREQUENCY == 0) system_header();
// Count this up here, we want a system header in pack 0, 5, ... NOT 4, 9, ...
diff --git a/src/multiplexer.h b/src/multiplexer.h
index 9959009..1d315fd 100644
--- a/src/multiplexer.h
+++ b/src/multiplexer.h
@@ -76,13 +76,14 @@ public:
void multiplex();
-private:
+protected:
int Write(void* data, int size);
int Write(char* data, int size);
- int Write(unsigned long long int val);
- int Write(long long int val);
+ int Write(uint64_t val);
+ int Write(int64_t val);
int Write(long int val);
int Write(unsigned long int val);
+ int Write24(uint32_t val);
int Write(int val);
int Write(unsigned int val);
int Write(short int val);
@@ -93,6 +94,7 @@ private:
double written[NUM_TYPES];
void iso11172_stream();
+ void pack_header();
bool pack();
void system_header();
bool packet();
diff --git a/src/network.cc b/src/network.cc
index 799bc98..50ff810 100644
--- a/src/network.cc
+++ b/src/network.cc
@@ -107,6 +107,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz)
int n = sendmsg(s->ssocket, &msg, 0);
if(n < 0) {
+ perror(" sendmsg(s->ssocket, &msg, 0): ");
info->error("A network error ocurred during sendPackage!");
return -1;
}
diff --git a/src/player.cc b/src/player.cc
index e57211d..9b5d928 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -32,9 +32,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-#ifdef USE_GUI
-
#include "player.h"
// Use libdv
@@ -318,5 +315,3 @@ void Player::setMute(bool m)
{
muted = m;
}
-
-#endif /* USE_GUI */
diff --git a/src/player.h b/src/player.h
index 0f5ca51..641230a 100644
--- a/src/player.h
+++ b/src/player.h
@@ -32,18 +32,15 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __RTVIDEOREC_PLAYER_H
#define __RTVIDEOREC_PLAYER_H
-#include "info.h"
+#include <QWidget>
#include <stdio.h>
#include <stdlib.h>
+
#include <SDL/SDL.h>
-//#include <avformat.h>
#include "util.h"
#include "queue.h"
@@ -51,7 +48,7 @@
#include "thread.h"
#include "frame.h"
-#include <qwidget.h>
+#include "info.h"
#include "yuv_draw.h"
@@ -139,4 +136,3 @@ private:
#endif/*__RTVIDEOREC_PLAYER_H*/
-#endif /* USE_GUI */
diff --git a/src/server.cc b/src/server.cc
index 3655d33..45d8b48 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -25,7 +25,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "server.h"
-#include "miav.h"
#include <stdio.h>
#include <stdlib.h>
@@ -53,6 +52,7 @@
#include "server_status.h"
#include "dv.h"
+#include "network.h"
void newConnection(Socket *socket, Info *info)
{
diff --git a/src/socket.cc b/src/socket.cc
index 2ae88dc..b34bae6 100644
--- a/src/socket.cc
+++ b/src/socket.cc
@@ -24,12 +24,13 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-
#include "socket.h"
#include <errno.h>
+// for gethostbyname
+#include <netdb.h>
+
Socket::Socket(Info *ginfo)
{
info = ginfo;
@@ -54,6 +55,7 @@ Socket::Socket(u_short port, Info *ginfo)
info->error("Socket: socket() failed!");
}
+ memset((char *) &socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET; // Use "internet protocol" IP
socketaddr.sin_port = htons(port); // connect to that port
socketaddr.sin_addr.s_addr = INADDR_ANY;
@@ -115,7 +117,7 @@ Socket Socket::slisten()
}
-int Socket::sconnect(char *ip)
+int Socket::sconnect(char *addr)
{
if(err) {
connected = false;
@@ -123,9 +125,23 @@ int Socket::sconnect(char *ip)
return err;
}
- // FIXME: gethostbyname()
- socketaddr.sin_addr.s_addr = inet_addr(ip);
- //inet_aton (ip, &socketaddr.sin_addr);
+ // Do DNS lookup
+ char *ip;
+ struct in_addr **addr_list;
+ struct hostent *he;
+ he = gethostbyname(addr);
+ if(!he || !he->h_length) {
+ /*
+ throw TCPConnectException(addr, toString(port),
+ std::string("host lookup failed: ") + hstrerror(h_errno));
+ */
+ }
+
+ addr_list = (struct in_addr **)he->h_addr_list;
+ // Get first value. We know for sure that there are at least one.
+ ip = inet_ntoa(*addr_list[0]);
+
+ socketaddr.sin_addr.s_addr = inet_addr(ip);
err = connect(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
if (err) {
diff --git a/src/videowidget.cc b/src/videowidget.cc
index 61b5c8e..3361156 100644
--- a/src/videowidget.cc
+++ b/src/videowidget.cc
@@ -24,15 +24,12 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
-
-#ifdef USE_GUI
-
#include "videowidget.h"
#include "miav_config.h"
-VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p, "")
+VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old)
+ : QWidget(p)
{
camera = c;
parent = p;
@@ -41,7 +38,7 @@ VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p, "")
// A welltested hack to force SDL to draw in the QWidget
QString ids;
- setenv("SDL_WINDOWID", ids.setNum(winId()), 1);
+ setenv("SDL_WINDOWID", ids.setNum(winId()).toStdString().c_str(), 1);
}
VideoWidget::~VideoWidget()
@@ -59,7 +56,8 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
{
if(!parent) { // We are a fullscreen window
QString ids;
- setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()), 1);
+ setenv("SDL_WINDOWID",
+ ids.setNum(oldWindow->winId()).toStdString().c_str(), 1);
camera->resize(oldWindow->width(), oldWindow->height(), false);
destroy();
} else { // We are a nested window
@@ -72,5 +70,3 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
camera->resize(fs->width(), fs->height(), true);
}
}
-
-#endif /* USE_GUI */
diff --git a/src/videowidget.h b/src/videowidget.h
index b9ac9d6..739601e 100644
--- a/src/videowidget.h
+++ b/src/videowidget.h
@@ -24,14 +24,11 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
-
#ifndef __VIDEOWIDGET_H__
#define __VIDEOWIDGET_H__
-#include <qwidget.h>
-#include <qpixmap.h>
+#include <QWidget>
+#include <QPixmap>
#include "camera.h"
@@ -53,5 +50,3 @@ private:
};
#endif /* __VIDEOWIDGET_H__ */
-
-#endif /* USE_GUI */
diff --git a/src/yuv_draw.cc b/src/yuv_draw.cc
index 06aff5c..9d10867 100644
--- a/src/yuv_draw.cc
+++ b/src/yuv_draw.cc
@@ -24,20 +24,15 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
#include "yuv_draw.h"
-// for miav_app
-#include "miav.h"
-
//#include "font.h"
#include <string.h>
#define TEXT_MARGIN 10
#include "mainwindow.h"
-static QImage *loadIcon( char *name, int height )
+static QImage *loadIcon(const char *name, int height )
{
QImage scaled;
QImage *img;
@@ -48,7 +43,7 @@ static QImage *loadIcon( char *name, int height )
int h = height;
int w = (int)((float)img->width() / (float)(img->height() / (float)h));
- scaled = img->smoothScale(w, h);
+ scaled = img->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
delete img;
img = new QImage(scaled);
@@ -106,9 +101,9 @@ void YUVDraw::addPixel(int x, int y, int val)
}
-void YUVDraw::setTopText(char* text)
+void YUVDraw::setTopText(const char* text)
{
- miav_app->lock();
+ // miav_app->lock(); // TODO
top_pixmap->fill();
QPainter painter;
@@ -118,19 +113,19 @@ void YUVDraw::setTopText(char* text)
painter.drawText(64, 15, text);
painter.end();
- QImage image = top_pixmap->convertToImage();
+ QImage image = top_pixmap->toImage();
for(int x = 64; x < 720 - TEXT_MARGIN; x++) {
for(int y = 0; y < 20; y++) {
top_grey[x][y] = qGray(image.pixel(x, y));
}
}
- miav_app->unlock();
+ // miav_app->unlock();// TODO
}
-void YUVDraw::setBottomText(char* text)
+void YUVDraw::setBottomText(const char* text)
{
- miav_app->lock();
+ //miav_app->lock(); // TODO
bottom_pixmap->fill();
QPainter painter;
@@ -140,14 +135,14 @@ void YUVDraw::setBottomText(char* text)
painter.drawText(0, 15, text);
painter.end();
- QImage image = bottom_pixmap->convertToImage();
+ QImage image = bottom_pixmap->toImage();
for(int x = 0; x < 720 - TEXT_MARGIN; x++) {
for(int y = 0; y < 20; y++) {
bottom_grey[x][y] = qGray(image.pixel(x, y));
}
}
- miav_app->unlock();
+ // miav_app->unlock(); // TODO
}
void YUVDraw::draw()
@@ -238,5 +233,3 @@ typedef struct{
Uint32 hw_overlay:1;
} SDL_Overlay;
*/
-
-#endif/*USE_GUI*/
diff --git a/src/yuv_draw.h b/src/yuv_draw.h
index 62f7d02..bf233ae 100644
--- a/src/yuv_draw.h
+++ b/src/yuv_draw.h
@@ -24,16 +24,14 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
-#ifdef USE_GUI
#ifndef __MIAV_YUV_DRAW_H__
#define __MIAV_YUV_DRAW_H__
#include <SDL/SDL.h>
-#include <qpixmap.h>
-#include <qimage.h>
-#include <qpainter.h>
+#include <QPixmap>
+#include <QImage>
+#include <QPainter>
#define ICON_HEIGHT 48
#define ICON_WIDTH 48
@@ -47,8 +45,8 @@ public:
void addPixel(int x, int y, int val);
- void setTopText(char* text);
- void setBottomText(char* text);
+ void setTopText(const char* text);
+ void setBottomText(const char* text);
void mute(bool muted);
void draw();
@@ -67,4 +65,3 @@ private:
};
#endif/*__MIAV_YUV_DRAW_H__*/
-#endif/*USE_GUI*/