summaryrefslogtreecommitdiff
path: root/src/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-20 11:53:40 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-20 11:53:40 +0200
commit808225629721c2f7d5c751edc60e5c6744be7886 (patch)
tree3d97fc3b7319b5f94e688a454de51b32321ebfd7 /src/mainwindow.cc
parent46d4e577bceb12c9463fdf4ef1d9a9a348f13543 (diff)
First (crashing) prototype.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc67
1 files changed, 57 insertions, 10 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 4dcac58..3e31136 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -27,38 +27,85 @@
#include "mainwindow.h"
#include <QLabel>
+#include <QStatusBar>
+
#include <stdio.h>
-MainWindow::MainWindow(QString v4ldev, QString adev)
- : v4l(v4ldev), ah(adev)
+MainWindow::MainWindow(QString v4ldev, QString adev,
+ QHostAddress addr, quint16 port)
+ : v4l(v4ldev), aih(adev), ostreamer(addr, port), istreamer(addr, port)
{
- connect(&v4l, SIGNAL(newImage(QImage)),
- this, SLOT(newImage(QImage)));
+ /* // Self view:
+ connect(&v4l, SIGNAL(newImage(Frame)),
+ this, SLOT(newImage(Frame)));
+ */
+ connect(&istreamer, SIGNAL(newImage(Frame)),
+ this, SLOT(newImage(Frame)));
+
+ connect(&istreamer, SIGNAL(newAudio(Frame)),
+ &aoh, SLOT(newAudio(Frame)));
- connect(&ah, SIGNAL(newAudio(framelist_t)),
+ /*
+ connect(&aih, SIGNAL(newAudio(framelist_t)),
this, SLOT(newAudio(framelist_t)));
+ */
+ connect(&v4l, SIGNAL(newImage(Frame)),
+ &ostreamer, SLOT(newImage(Frame)));
+
+ connect(&aih, SIGNAL(newAudio(framelist_t)),
+ &ostreamer, SLOT(newAudio(framelist_t)));
+
+ connect(&status_timer, SIGNAL(timeout()),
+ this, SLOT(updateStatus()));
+
+ status_timer.start(1000);
setCentralWidget(new QLabel());
+
+ statusBar()->showMessage("Starting...");
}
-void MainWindow::newImage(QImage img)
+void MainWindow::updateStatus()
{
+ size_t ob = ostreamer.getTotal() / 60 / 1024;
+ size_t ib = istreamer.getTotal() / 60 / 1024;
+ QString status =
+ "In: " + QString::number(ib) + "kb/s"
+ + " - " +
+ "Out: " + QString::number(ob) + "kb/s"
+ ;
+ statusBar()->showMessage(status);
+}
+
+void MainWindow::newImage(Frame frame)
+{
+ QImage img;
+ bool res = img.loadFromData((const uchar*)frame.data, frame.size, "JPG");
+ // printf("processImage() => %s\n", res?"true":"false");
if(img.isNull()) {
printf("Invalid image\n");
return;
}
- printf("img->w: %d\n", img.width());
- printf("img->h: %d\n", img.height());
+ // printf("img->w: %d\n", img.width());
+ // printf("img->h: %d\n", img.height())
QLabel *l = (QLabel*)centralWidget();
QPixmap p;
p.convertFromImage(img);
l->setPixmap(p);
- printf("Got one\n");
+
+ // printf("v"); fflush(stdout);
}
void MainWindow::newAudio(framelist_t list)
{
- printf("audio: %d frames\n", list.size());
+ /*
+ framelist_t::iterator i = list.begin();
+ while(i != list.end()) {
+ sp.playSamples(*i);
+ }
+ // printf("audio: %d frames\n", list.size());
+ */
+ // printf("a"); fflush(stdout);
}