summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2006-05-20 14:35:59 +0000
committerdeva <deva>2006-05-20 14:35:59 +0000
commitdd8e7832c69a5ef484a2f3b6054a482d29275f85 (patch)
tree6865f4f18d8545a0edecbb3646f69039ccc82727
parent60c43b0a065175a49ae0aa2b10280e893479889b (diff)
*** empty log message ***
-rw-r--r--TASKS1
-rw-r--r--client/control.cc6
-rw-r--r--client/control.h2
-rw-r--r--client/decoder.cc22
-rw-r--r--client/decoder.h6
-rw-r--r--client/mainwindow.cc42
-rw-r--r--client/mainwindow.h10
-rw-r--r--client/miav_client.cc4
-rw-r--r--client/networksender.cc36
-rw-r--r--client/networksender.h19
10 files changed, 112 insertions, 36 deletions
diff --git a/TASKS b/TASKS
new file mode 100644
index 0000000..7578035
--- /dev/null
+++ b/TASKS
@@ -0,0 +1 @@
+tilføj sender kø størelser til statusbar \ No newline at end of file
diff --git a/client/control.cc b/client/control.cc
index b6495d2..d634039 100644
--- a/client/control.cc
+++ b/client/control.cc
@@ -46,11 +46,13 @@ void Control::setCpr(QString cpr)
mutex.unlock();
}
-void Control::getCpr(QString *cpr)
+QString Control::getCpr()
{
+ QString cpr;
mutex.lock();
- *cpr = Control::cpr;
+ cpr = Control::cpr;
mutex.unlock();
+ return cpr;
}
void Control::freeze()
diff --git a/client/control.h b/client/control.h
index f6b4599..cdc8bc4 100644
--- a/client/control.h
+++ b/client/control.h
@@ -39,7 +39,7 @@ public:
~Control();
void setCpr(QString cpr);
- void getCpr(QString *cpr);
+ QString getCpr();
void freeze();
void unfreeze();
diff --git a/client/decoder.cc b/client/decoder.cc
index 5421e16..0ed2032 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -44,9 +44,8 @@
#include "libdv_wrapper.h"
-Decoder::Decoder(NetworkSender *ns): closesem(1)
+Decoder::Decoder()
{
- sender = ns;
running = true;
memset(pframe, 0, sizeof(pframe)); // Init an empty frame
qApp->installEventFilter(this);
@@ -58,7 +57,9 @@ Decoder::~Decoder()
void Decoder::run()
{
- closesem.acquire(); // Lock the shutdown process
+ bool newconnection = true;
+
+ // closesem.acquire(); // Lock the shutdown process
#ifdef READ_DV_FROM_FILE
dvfile reader;
@@ -77,9 +78,20 @@ void Decoder::run()
pmutex.unlock();
}
- free(frame);
+ if(MIaV::control.isRecording()) {
+ if(newconnection) {
+ NetworkSender *sender = new NetworkSender(MIaV::control.getCpr());
+ senders.push_back(sender);
+ sender->start();
+ newconnection = false;
+ }
+ senders.front()->pushFrame(frame, false, false);
+ } else {
+ free(frame);
+ newconnection = true;
+ }
}
- closesem.release(); // Unlock the shutdown process
+ // closesem.release(); // Unlock the shutdown process
}
char *Decoder::pframeAcquire()
diff --git a/client/decoder.h b/client/decoder.h
index a8fb4f9..26d86d7 100644
--- a/client/decoder.h
+++ b/client/decoder.h
@@ -31,6 +31,8 @@
#include <QSemaphore>
#include <QMutex>
+#include <QList>
+
#include "dv.h"
#include "networksender.h"
@@ -38,7 +40,7 @@ class Decoder : public QThread
{
Q_OBJECT
public:
- Decoder(NetworkSender *sender);
+ Decoder();
~Decoder();
char *getFrame();
@@ -62,7 +64,7 @@ private:
QMutex mutex;
- NetworkSender *sender;
+ QList<NetworkSender *> senders;
};
#endif/*__MIAV_DECODER_H__*/
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index 3680afc..da2785b 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -34,15 +34,12 @@
#include "historywidget.h"
-#include <QStatusBar>
-
#include "control.h"
#include "icons.h"
QPushButton *MainWindow::createButton(QPixmap *pixmap)
{
- // QPixmap p = loadIcon(icon);
QPushButton *btn = new QPushButton();
btn->setIconSize(QSize(pixmap->width(), pixmap->height()));
btn->setIcon(*pixmap);
@@ -83,35 +80,58 @@ MainWindow::MainWindow(Decoder *d)
// Create the control buttons
btn_cpr = createButton(Icons::cpr);
- layout->addWidget(btn_cpr, 1,3, 1,1);
+ layout->addWidget(btn_cpr, 1,3, 2,1);
connect(btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked()));
btn_record = createButton(Icons::record);
- layout->addWidget(btn_record, 2,0, 1,1);
+ layout->addWidget(btn_record, 3,0, 1,1);
connect(btn_record, SIGNAL(clicked()), this, SLOT(record_clicked()));
btn_snapshot = createButton(Icons::snapshot);
- layout->addWidget(btn_snapshot, 2,1, 1,1);
+ layout->addWidget(btn_snapshot, 3,1, 1,1);
connect(btn_snapshot, SIGNAL(clicked()), this, SLOT(snapshot_clicked()));
btn_freeze = createButton(Icons::freeze);
- layout->addWidget(btn_freeze, 2,2, 1,1);
+ layout->addWidget(btn_freeze, 3,2, 1,1);
connect(btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked()));
btn_mute = createButton(Icons::mute);
- layout->addWidget(btn_mute, 2,3, 1,1);
+ layout->addWidget(btn_mute, 3,3, 1,1);
connect(btn_mute, SIGNAL(clicked()), this, SLOT(mute_clicked()));
btn_clear = createButton(Icons::clear);
- layout->addWidget(btn_clear, 2,4, 1,1);
+ layout->addWidget(btn_clear, 3,4, 1,1);
connect(btn_clear, SIGNAL(clicked()), this, SLOT(clear_clicked()));
+ // Create the labels
+ lbl_cpr = new QLabel();
+ QFont font = lbl_cpr->font();
+ font.setPointSize(font.pointSize() * 2);
+ font.setBold(true);
+ lbl_cpr->setFont(font);
+ lbl_cpr->setText("CPR");
+ layout->addWidget(lbl_cpr, 1,0, 1,3);
+
+ lbl_name = new QLabel();
+ font = lbl_name->font();
+ font.setPointSize(font.pointSize() * 3);
+ font.setBold(true);
+ lbl_name->setFont(font);
+ lbl_name->setText("Name");
+ layout->addWidget(lbl_name, 2,0, 1,3);
+
+ // Stretch the layout
+ layout->setRowStretch(0, 100);
+ layout->setRowStretch(1, 1);
+ layout->setRowStretch(2, 1);
+ layout->setRowStretch(3, 1);
+
// Create history bar
history = new HistoryFrame();
- layout->addWidget(history, 0,4, 2,1);
+ layout->addWidget(history, 0,4, 3,1);
// Create statusbar
- QStatusBar *statusbar = new QStatusBar(this);
+ statusbar = new QStatusBar(this);
outerlayout->addWidget(statusbar, 1,0, 1,1);
statusbar->showMessage("Ready!");
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 742351d..b94f5c5 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -30,6 +30,9 @@
#include <QWidget>
#include <QPushButton>
+#include <QLabel>
+#include <QStatusBar>
+
#include "historyframe.h"
#include "videowidget.h"
@@ -68,6 +71,13 @@ private:
QPushButton *btn_freeze;
QPushButton *btn_mute;
QPushButton *btn_clear;
+
+ // Labels
+ QLabel *lbl_cpr;
+ QLabel *lbl_name;
+
+ // Statusbar
+ QStatusBar *statusbar;
};
#endif/*__MIAV_MAINWINDOW_H__*/
diff --git a/client/miav_client.cc b/client/miav_client.cc
index 38b8894..f004f83 100644
--- a/client/miav_client.cc
+++ b/client/miav_client.cc
@@ -45,8 +45,7 @@ int main(int argc, char *argv[])
InfoGui info(MIaV::config);
MIaV::initInfo(&info);
- NetworkSender sender;
- Decoder decoder(&sender);
+ Decoder decoder;
MainWindow mainwindow(&decoder);
Player player(mainwindow.getVideoWidget(), &decoder);
@@ -54,7 +53,6 @@ int main(int argc, char *argv[])
decoder.start();
player.start(1000 / fps);
- sender.start();
return app.exec();
}
diff --git a/client/networksender.cc b/client/networksender.cc
index 21c107c..675bdb9 100644
--- a/client/networksender.cc
+++ b/client/networksender.cc
@@ -28,28 +28,46 @@
#include "info.h"
-NetworkSender::NetworkSender()
+NetworkSender::NetworkSender(QString cpr)
{
ip = "192.168.0.10";
port = 6666;
+
+ // Connect
}
NetworkSender::~NetworkSender()
-{}
-
-void NetworkSender::newConnection(char *cpr)
{
+ // Disconnect
}
-void NetworkSender::pushFrame(char* frame, bool freeze, bool snapshot)
+void NetworkSender::pushFrame(char* framedata, bool freeze, bool snapshot)
{
-}
+ Frame *frame = new Frame((unsigned char*)framedata);
+ frame->freeze = freeze;
+ frame->shoot = snapshot;
-void NetworkSender::endConnection()
-{
+ mutex.lock();
+ framelist.push_back(frame);
+ mutex.unlock();
+
+ semaphore.release();
}
void NetworkSender::run()
{
- // MIaV::info->info("The NetworkSender thread is running.");
+ while(running) {
+ semaphore.acquire();
+
+ Frame *frame = NULL;
+ mutex.lock();
+ if(framelist.isEmpty() == false) frame = framelist.takeLast();
+ mutex.unlock();
+
+ if(frame) {
+ // TODO: Send it over the network
+
+ delete frame;
+ }
+ }
}
diff --git a/client/networksender.h b/client/networksender.h
index 89c522a..43bb797 100644
--- a/client/networksender.h
+++ b/client/networksender.h
@@ -28,22 +28,35 @@
#define __MIAV_NETWORKSENDER_H__
#include <QThread>
+#include <QLinkedList>
+#include <QString>
+#include <QMutex>
+#include <QSemaphore>
+
+#include <frame.h>
class NetworkSender : public QThread
{
public:
- NetworkSender();
+ NetworkSender(QString cpr);
~NetworkSender();
- void newConnection(char *cpr);
+ void newConnection(QString cpr);
void pushFrame(char* frame, bool freeze, bool snapshot);
void endConnection();
void run();
private:
- std::string ip;
+ QString ip;
unsigned short port;
+
+ volatile bool running;
+
+ QMutex mutex;
+ QSemaphore semaphore;
+ QLinkedList<Frame*> framelist;
+
};
#endif/*__MIAV_NETWORKSENDER_H__*/