Commit 6a937f1b authored by lm's avatar lm

Merge branch 'videostreaming' of https://github.com/fattonz/qgroundcontrol into dev-mac

parents aa5f67d4 22d043ae
......@@ -86,6 +86,7 @@
<file>images/mapproviders/googleearth.svg</file>
<file>images/contrib/slugs.png</file>
<file>images/style-outdoor.css</file>
<file>images/patterns/lenna.jpg</file>
</qresource>
<qresource prefix="/general">
<file alias="vera.ttf">images/Vera.ttf</file>
......
......@@ -7,15 +7,11 @@ TEMPLATE = app
TARGET = qgcvideo
BASEDIR = .
BUILDDIR = build/qgcvideo
LANGUAGE = C++
CONFIG += release
CONFIG -= debug
OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated
macx:DESTDIR = $$BASEDIR/bin/mac
......@@ -29,11 +25,18 @@ INCLUDEPATH += . \
# Input
HEADERS += \
src/comm/UDPLink.h \
src/comm/LinkInterface.h \
src/comm/LinkManager.h \
src/QGC.h \
src/apps/qgcvideo/QGCVideoMainWindow.h \
src/apps/qgcvideo/QGCVideoApp.h \
src/apps/qgcvideo/QGCVideoWidget.h
SOURCES += \
src/comm/UDPLink.cc \
src/comm/LinkManager.cc \
src/QGC.cc \
src/apps/qgcvideo/main.cc \
src/apps/qgcvideo/QGCVideoMainWindow.cc \
src/apps/qgcvideo/QGCVideoApp.cc \
......
......@@ -44,6 +44,8 @@
#include <QMainWindow>
#include "QGCVideoApp.h"
#include "QGCVideoMainWindow.h"
#include "UDPLink.h"
/**
......@@ -76,7 +78,7 @@ QGCVideoApp::QGCVideoApp(int &argc, char* argv[]) : QApplication(argc, argv)
setFont(fontDatabase.font(fontFamilyName, "Roman", 12));
// Create main window
QMainWindow* window = new QMainWindow();
QMainWindow* window = new QGCVideoMainWindow();
//window->setCentralWidget(new XMLCommProtocolWidget(window));
window->setWindowTitle(applicationName() + " " + applicationVersion());
window->show();
......
......@@ -32,14 +32,67 @@
#include "QGCVideoMainWindow.h"
#include "ui_QGCVideoMainWindow.h"
#include "UDPLink.h"
#include <QDebug>
QGCVideoMainWindow::QGCVideoMainWindow(QWidget *parent) :
QMainWindow(parent),
link(QHostAddress::Any, 5555),
ui(new Ui::QGCVideoMainWindow)
{
ui->setupUi(this);
// Set widgets in video mode
ui->video1Widget->enableVideo(true);
ui->video2Widget->enableVideo(true);
ui->video3Widget->enableVideo(true);
ui->video4Widget->enableVideo(true);
// Connect link to this widget, receive all bytes
connect(&link, SIGNAL(bytesReceived(LinkInterface*,QByteArray)), this, SLOT(receiveBytes(LinkInterface*,QByteArray)));
// Open port
link.connect();
}
QGCVideoMainWindow::~QGCVideoMainWindow()
{
delete ui;
}
void QGCVideoMainWindow::receiveBytes(LinkInterface* link, QByteArray data)
{
// There is no need to differentiate between links
// for this use case here
Q_UNUSED(link);
// Image data is stored in QByteArray
// Output bytes and load Lenna!
QString bytes;
QString ascii;
for (int i=0; i<data.size(); i++) {
unsigned char v = data[i];
bytes.append(QString().sprintf("%02x ", v));
if (data.at(i) > 31 && data.at(i) < 127)
{
ascii.append(data.at(i));
}
else
{
ascii.append(219);
}
}
qDebug() << "Received" << data.size() << "bytes";
qDebug() << bytes;
qDebug() << "ASCII:" << ascii;
// Load image into window
QImage test(":images/patterns/lenna.jpg");
ui->video1Widget->copyImage(test);
ui->video2Widget->copyImage(test);
ui->video3Widget->copyImage(test);
ui->video4Widget->copyImage(test);
}
......@@ -33,6 +33,7 @@
#define QGCVIDEOMAINWINDOW_H
#include <QMainWindow>
#include "UDPLink.h"
namespace Ui {
class QGCVideoMainWindow;
......@@ -46,6 +47,12 @@ public:
explicit QGCVideoMainWindow(QWidget *parent = 0);
~QGCVideoMainWindow();
public slots:
void receiveBytes(LinkInterface* link, QByteArray data);
protected:
UDPLink link;
private:
Ui::QGCVideoMainWindow *ui;
};
......
......@@ -160,7 +160,7 @@ QGCVideoWidget::QGCVideoWidget(QWidget* parent)
// Refresh timer
refreshTimer->setInterval(updateInterval);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintQGCVideoWidget()));
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintHUD()));
// Resize to correct size and fill with image
//glDrawPixels(glImage.width(), glImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, glImage.bits());
......@@ -201,16 +201,12 @@ QSize QGCVideoWidget::sizeHint() const
void QGCVideoWidget::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event)
refreshTimer->start(updateInterval);
}
void QGCVideoWidget::hideEvent(QHideEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event);
refreshTimer->stop();
}
......@@ -220,20 +216,20 @@ void QGCVideoWidget::contextMenuEvent (QContextMenuEvent* event)
QMenu menu(this);
// Update actions
enableHUDAction->setChecked(hudInstrumentsEnabled);
enableVideoAction->setChecked(videoEnabled);
// enableVideoAction->setChecked(videoEnabled);
menu.addAction(enableHUDAction);
//menu.addAction(selectQGCVideoWidgetColorAction);
menu.addAction(enableVideoAction);
menu.addAction(selectOfflineDirectoryAction);
// menu.addAction(enableVideoAction);
// menu.addAction(selectOfflineDirectoryAction);
//menu.addAction(selectVideoChannelAction);
menu.exec(event->globalPos());
}
void QGCVideoWidget::createActions()
{
enableHUDAction = new QAction(tr("Enable QGCVideoWidget"), this);
enableHUDAction->setStatusTip(tr("Show the QGCVideoWidget instruments in this window"));
enableHUDAction = new QAction(tr("Enable HUD"), this);
enableHUDAction->setStatusTip(tr("Show the HUD instruments in this window"));
enableHUDAction->setCheckable(true);
enableHUDAction->setChecked(hudInstrumentsEnabled);
connect(enableHUDAction, SIGNAL(triggered(bool)), this, SLOT(enableHUDInstruments(bool)));
......@@ -242,11 +238,11 @@ void QGCVideoWidget::createActions()
enableVideoAction->setStatusTip(tr("Show the video live feed"));
enableVideoAction->setCheckable(true);
enableVideoAction->setChecked(videoEnabled);
connect(enableVideoAction, SIGNAL(triggered(bool)), this, SLOT(enableVideo(bool)));
// connect(enableVideoAction, SIGNAL(triggered(bool)), this, SLOT(enableVideo(bool)));
selectOfflineDirectoryAction = new QAction(tr("Select image log"), this);
selectOfflineDirectoryAction->setStatusTip(tr("Load previously logged images into simulation / replay"));
connect(selectOfflineDirectoryAction, SIGNAL(triggered()), this, SLOT(selectOfflineDirectory()));
// connect(selectOfflineDirectoryAction, SIGNAL(triggered()), this, SLOT(selectOfflineDirectory()));
}
/**
......
......@@ -30,6 +30,7 @@ public slots:
/** @brief Copy an image from an external buffer */
void copyImage(const QImage& img);
void enableHUDInstruments(bool enabled) { hudInstrumentsEnabled = enabled; }
void enableVideo(bool enabled) { videoEnabled = enabled; }
protected slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment