summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-21 10:57:35 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-21 10:57:35 +0200
commitdc0e0e379ba1a9474f5e760c26c076fd1f13ac57 (patch)
tree247802a66ab868d08d31055248a58a16a9d2d458
parentb3cf6b4c1d1477f1cac83f9dc6165781171c2a9e (diff)
Add peer name to video widget.
-rw-r--r--src/Makefile.am12
-rw-r--r--src/mainwindow.cc38
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/videowidget.cc65
-rw-r--r--src/videowidget.h48
5 files changed, 129 insertions, 38 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 224dab9..5dcf5cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,11 +26,12 @@ simplertp_SOURCES = \
audiooutputhandler.cc \
soundplayer.cc \
outputstreamer.cc \
- inputstreamer.cc
+ inputstreamer.cc \
+ videowidget.cc
-simplertp-genkey_LDADD =
-simplertp-genkey_CXXFLAGS =
-simplertp-genkey_SOURCES = \
+simplertp_genkey_LDADD =
+simplertp_genkey_CXXFLAGS =
+simplertp_genkey_SOURCES = \
simplertp-genkey.cc
EXTRA_DIST = \
@@ -46,7 +47,8 @@ EXTRA_DIST = \
audiooutputhandler.h \
soundplayer.h \
outputstreamer.h \
- inputstreamer.h
+ inputstreamer.h \
+ videowidget.h
simplertp_MOC = $(shell ../tools/MocList cc )
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index d7faf2d..81ea65c 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -41,18 +41,18 @@ MainWindow::MainWindow(QString v4ldev, QString adev,
*/
setCentralWidget(new QLabel);
- memset(video, 0 ,sizeof(video));
-
int idx = 0;
QList<InputStreamer*>::iterator i = islist.begin();
while(i != islist.end()) {
- connect(*i, SIGNAL(newImage(int,Frame)),
- this, SLOT(newImage(int,Frame)));
+ VideoWidget *vw = new VideoWidget(idx, *i);
+ videowidgets.push_back(vw);
+
connect(*i, SIGNAL(newAudio(int,Frame)),
&aoh, SLOT(newAudio(int,Frame)));
- video[idx] = new QLabel(NULL);
- video[idx]->resize(640,480);
- video[idx]->show();
+
+ connect(*i, SIGNAL(newImage(int,Frame)),
+ vw, SLOT(newImage(int,Frame)));
+
i++; idx++;
}
@@ -103,27 +103,3 @@ void MainWindow::updateStatus()
;
statusBar()->showMessage(status);
}
-
-void MainWindow::newImage(int peer, Frame frame)
-{
- if(peer >= 10 || video[peer] == NULL) return;
- 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())
-
- QLabel *l = video[peer];
- QPixmap p;
- p.convertFromImage(img);
- l->setPixmap(p);
-
- free(frame.data);
-
- // printf("v"); fflush(stdout);
-}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 72ba092..d8329bb 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -38,6 +38,7 @@
#include "audiooutputhandler.h"
#include "outputstreamer.h"
#include "inputstreamer.h"
+#include "videowidget.h"
class MainWindow : public QMainWindow {
Q_OBJECT
@@ -47,7 +48,6 @@ public:
QList<InputStreamer*> &islist);
public slots:
- void newImage(int peer, Frame frame);
void updateStatus();
private:
@@ -59,7 +59,7 @@ private:
QTimer status_timer;
- QLabel* video[10];
+ QVector<VideoWidget *> videowidgets;
};
#endif/*__SIMPLERTP_MAINWINDOW_H__*/
diff --git a/src/videowidget.cc b/src/videowidget.cc
new file mode 100644
index 0000000..a556e56
--- /dev/null
+++ b/src/videowidget.cc
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * videowidget.cc
+ *
+ * Sun Sep 21 10:42:42 CEST 2014
+ * Copyright 2014 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of SimpleRTP.
+ *
+ * SimpleRTP 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.
+ *
+ * SimpleRTP 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 SimpleRTP; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "videowidget.h"
+
+#include <QPainter>
+
+VideoWidget::VideoWidget(int peer, InputStreamer *is)
+{
+ this->is = is;
+ this->peer = peer;
+ resize(640, 480);
+ show();
+}
+
+void VideoWidget::newImage(int peer, Frame frame)
+{
+ if(peer != this->peer) return;
+
+ 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;
+ }
+
+ {
+ size_t font_size = 14;
+ size_t border = 4;
+ QPainter p(&img);
+ p.setPen(Qt::white);
+ p.setFont(QFont("Arial Bold", font_size));
+ p.drawText(border, font_size + border, is->getName());
+ }
+
+ QPixmap p;
+ p.convertFromImage(img);
+ setPixmap(p);
+
+ free(frame.data);
+}
diff --git a/src/videowidget.h b/src/videowidget.h
new file mode 100644
index 0000000..ebcaeff
--- /dev/null
+++ b/src/videowidget.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * videowidget.h
+ *
+ * Sun Sep 21 10:42:41 CEST 2014
+ * Copyright 2014 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of SimpleRTP.
+ *
+ * SimpleRTP 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.
+ *
+ * SimpleRTP 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 SimpleRTP; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __SIMPLERTP_VIDEOWIDGET_H__
+#define __SIMPLERTP_VIDEOWIDGET_H__
+
+#include <QLabel>
+
+#include "inputstreamer.h"
+#include "frame.h"
+
+class VideoWidget : public QLabel {
+Q_OBJECT
+public:
+ VideoWidget(int peer, InputStreamer *is);
+
+public slots:
+ void newImage(int peer, Frame frame);
+
+private:
+ int peer;
+ InputStreamer *is;
+};
+
+#endif/*__SIMPLERTP_VIDEOWIDGET_H__*/