vrplayer: update from neutrinolabs
This commit is contained in:
parent
12381b1c0d
commit
6a5f141769
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "demuxmedia.h"
|
#include "demuxmedia.h"
|
||||||
|
|
||||||
DemuxMedia::DemuxMedia(QObject *parent, QQueue<MediaPacket *> *audioQueue,
|
DemuxMedia::DemuxMedia(QObject *parent, QQueue<MediaPacket *> *audioQueue,
|
||||||
|
@ -4,12 +4,18 @@
|
|||||||
/*
|
/*
|
||||||
* TODO
|
* TODO
|
||||||
* o should we use tick marks in QSlider?
|
* o should we use tick marks in QSlider?
|
||||||
|
* o check for memory leaks
|
||||||
|
* o double click should make it full screen
|
||||||
|
* o when opening files, pause video
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
|
gotMediaOnCmdline = false;
|
||||||
|
moveResizeTimer = NULL;
|
||||||
|
|
||||||
/* connect to remote client */
|
/* connect to remote client */
|
||||||
interface = new OurInterface();
|
interface = new OurInterface();
|
||||||
if (interface->oneTimeInit())
|
if (interface->oneTimeInit())
|
||||||
@ -35,16 +41,42 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
connect(interface, SIGNAL(onMediaDurationInSeconds(int)),
|
connect(interface, SIGNAL(onMediaDurationInSeconds(int)),
|
||||||
this, SLOT(onMediaDurationInSeconds(int)));
|
this, SLOT(onMediaDurationInSeconds(int)));
|
||||||
|
|
||||||
|
/* if media file is specified on cmd line, use it */
|
||||||
|
QStringList args = QApplication::arguments();
|
||||||
|
if (args.count() > 1)
|
||||||
|
{
|
||||||
|
if (QFile::exists(args.at(1)))
|
||||||
|
{
|
||||||
|
interface->setFilename(args.at(1));
|
||||||
|
filename = args.at(1);
|
||||||
|
gotMediaOnCmdline = true;
|
||||||
|
on_actionOpen_Media_File_triggered();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "Invalid media file specified",
|
||||||
|
"\nThe media file\n\n" + args.at(1) +
|
||||||
|
"\n\ndoes not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
|
if (moveResizeTimer)
|
||||||
|
delete moveResizeTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
if (!oneTimeInitSuccess)
|
if (oneTimeInitSuccess)
|
||||||
|
{
|
||||||
|
interface->deInitRemoteClient();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, "Closing application",
|
QMessageBox::warning(this, "Closing application",
|
||||||
"This is not an xrdp session with xrdpvr");
|
"This is not an xrdp session with xrdpvr");
|
||||||
@ -54,22 +86,68 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
void MainWindow::resizeEvent(QResizeEvent *)
|
void MainWindow::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
QRect rect;
|
if (vcrFlag != VCR_PLAY)
|
||||||
|
{
|
||||||
|
QRect rect;
|
||||||
|
|
||||||
getVdoGeometry(&rect);
|
getVdoGeometry(&rect);
|
||||||
interface->sendGeometry(rect);
|
interface->sendGeometry(rect);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface->setVcrOp(VCR_PAUSE);
|
||||||
|
vcrFlag = VCR_PAUSE;
|
||||||
|
|
||||||
|
if (!moveResizeTimer)
|
||||||
|
{
|
||||||
|
moveResizeTimer = new QTimer;
|
||||||
|
connect(moveResizeTimer, SIGNAL(timeout()),
|
||||||
|
this, SLOT(onMoveCompleted()));
|
||||||
|
}
|
||||||
|
lblVideo->setStyleSheet("QLabel { background-color : black; color : blue; }");
|
||||||
|
moveResizeTimer->start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::moveEvent(QMoveEvent *)
|
void MainWindow::moveEvent(QMoveEvent *)
|
||||||
{
|
{
|
||||||
QRect rect;
|
if (vcrFlag != VCR_PLAY)
|
||||||
|
{
|
||||||
|
QRect rect;
|
||||||
|
|
||||||
getVdoGeometry(&rect);
|
getVdoGeometry(&rect);
|
||||||
interface->sendGeometry(rect);
|
interface->sendGeometry(rect);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface->setVcrOp(VCR_PAUSE);
|
||||||
|
vcrFlag = VCR_PAUSE;
|
||||||
|
|
||||||
|
if (!moveResizeTimer)
|
||||||
|
{
|
||||||
|
moveResizeTimer = new QTimer;
|
||||||
|
connect(moveResizeTimer, SIGNAL(timeout()),
|
||||||
|
this, SLOT(onMoveCompleted()));
|
||||||
|
}
|
||||||
|
lblVideo->setStyleSheet("QLabel { background-color : black; color : blue; }");
|
||||||
|
moveResizeTimer->start(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onVolSliderValueChanged(int value)
|
||||||
|
{
|
||||||
|
int volume;
|
||||||
|
|
||||||
|
volume = (value * 0xffff) / 100;
|
||||||
|
if (interface != 0)
|
||||||
|
{
|
||||||
|
interface->setVolume(volume);
|
||||||
|
}
|
||||||
|
qDebug() << "vol = " << volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupUI()
|
void MainWindow::setupUI()
|
||||||
{
|
{
|
||||||
|
this->setWindowTitle("vrplayer");
|
||||||
|
|
||||||
/* setup area to display video */
|
/* setup area to display video */
|
||||||
lblVideo = new QLabel();
|
lblVideo = new QLabel();
|
||||||
lblVideo->setMinimumWidth(320);
|
lblVideo->setMinimumWidth(320);
|
||||||
@ -134,10 +212,26 @@ void MainWindow::setupUI()
|
|||||||
connect(btnRewind, SIGNAL(clicked(bool)),
|
connect(btnRewind, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(onBtnRewindClicked(bool)));
|
this, SLOT(onBtnRewindClicked(bool)));
|
||||||
|
|
||||||
|
/* setup volume control slider */
|
||||||
|
volSlider = new QSlider();
|
||||||
|
volSlider->setOrientation(Qt::Horizontal);
|
||||||
|
volSlider->setMinimumWidth(100);
|
||||||
|
volSlider->setMaximumWidth(100);
|
||||||
|
volSlider->setMinimum(0);
|
||||||
|
volSlider->setMaximum(100);
|
||||||
|
volSlider->setValue(20);
|
||||||
|
volSlider->setTickPosition(QSlider::TicksAbove);
|
||||||
|
volSlider->setTickInterval(10);
|
||||||
|
|
||||||
|
connect(volSlider, SIGNAL(valueChanged(int)),
|
||||||
|
this, SLOT(onVolSliderValueChanged(int)));
|
||||||
|
|
||||||
/* add buttons to bottom panel */
|
/* add buttons to bottom panel */
|
||||||
hboxLayoutBottom = new QHBoxLayout;
|
hboxLayoutBottom = new QHBoxLayout;
|
||||||
hboxLayoutBottom->addWidget(btnPlay);
|
hboxLayoutBottom->addWidget(btnPlay);
|
||||||
hboxLayoutBottom->addWidget(btnStop);
|
hboxLayoutBottom->addWidget(btnStop);
|
||||||
|
hboxLayoutBottom->addWidget(volSlider);
|
||||||
|
|
||||||
//hboxLayoutBottom->addWidget(btnRewind);
|
//hboxLayoutBottom->addWidget(btnRewind);
|
||||||
hboxLayoutBottom->addStretch();
|
hboxLayoutBottom->addStretch();
|
||||||
|
|
||||||
@ -208,9 +302,14 @@ void MainWindow::clearDisplay()
|
|||||||
void MainWindow::on_actionOpen_Media_File_triggered()
|
void MainWindow::on_actionOpen_Media_File_triggered()
|
||||||
{
|
{
|
||||||
if (vcrFlag != 0)
|
if (vcrFlag != 0)
|
||||||
onBtnStopClicked(false);
|
onBtnStopClicked(true);
|
||||||
|
|
||||||
|
/* if media was specified on cmd line, use it just once */
|
||||||
|
if (gotMediaOnCmdline)
|
||||||
|
gotMediaOnCmdline = false;
|
||||||
|
else
|
||||||
|
openMediaFile();
|
||||||
|
|
||||||
openMediaFile();
|
|
||||||
if (filename.length() == 0)
|
if (filename.length() == 0)
|
||||||
{
|
{
|
||||||
/* cancel btn was clicked */
|
/* cancel btn was clicked */
|
||||||
@ -238,7 +337,7 @@ void MainWindow::on_actionOpen_Media_File_triggered()
|
|||||||
remoteClientInited = true;
|
remoteClientInited = true;
|
||||||
interface->playMedia();
|
interface->playMedia();
|
||||||
|
|
||||||
if (vcrFlag != 0)
|
//if (vcrFlag != 0)
|
||||||
{
|
{
|
||||||
interface->setVcrOp(VCR_PLAY);
|
interface->setVcrOp(VCR_PLAY);
|
||||||
btnPlay->setText("Pause");
|
btnPlay->setText("Pause");
|
||||||
@ -404,3 +503,30 @@ void MainWindow::onSliderActionTriggered(int action)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onMoveCompleted()
|
||||||
|
{
|
||||||
|
QRect rect;
|
||||||
|
|
||||||
|
getVdoGeometry(&rect);
|
||||||
|
interface->sendGeometry(rect);
|
||||||
|
|
||||||
|
interface->setVcrOp(VCR_PLAY);
|
||||||
|
vcrFlag = VCR_PLAY;
|
||||||
|
moveResizeTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionAbout_triggered()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
QMessageBox msgBox;
|
||||||
|
|
||||||
|
msgBox.setText("VRPlayer version 1.2");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
msgBox.exec();
|
||||||
|
#else
|
||||||
|
DlgAbout *dlgabt = new DlgAbout(this);
|
||||||
|
dlgabt->exec();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -25,12 +25,15 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "xrdpapi.h"
|
#include "xrdpapi.h"
|
||||||
#include "xrdpvr.h"
|
#include "xrdpvr.h"
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "ourinterface.h"
|
#include "ourinterface.h"
|
||||||
#include "playvideo.h"
|
#include "playvideo.h"
|
||||||
|
#include "dlgabout.h"
|
||||||
|
|
||||||
/* ffmpeg related stuff */
|
/* ffmpeg related stuff */
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -75,6 +78,11 @@ private slots:
|
|||||||
void onMediaDurationInSeconds(int duration);
|
void onMediaDurationInSeconds(int duration);
|
||||||
void onElapsedTime(int secs);
|
void onElapsedTime(int secs);
|
||||||
void onSliderActionTriggered(int value);
|
void onSliderActionTriggered(int value);
|
||||||
|
void onMoveCompleted();
|
||||||
|
|
||||||
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
|
void onVolSliderValueChanged(int value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
@ -96,8 +104,10 @@ private:
|
|||||||
QPushButton *btnStop;
|
QPushButton *btnStop;
|
||||||
QPushButton *btnRewind;
|
QPushButton *btnRewind;
|
||||||
QSlider *slider;
|
QSlider *slider;
|
||||||
|
QSlider *volSlider;
|
||||||
QWidget *window;
|
QWidget *window;
|
||||||
bool acceptSliderMove;
|
bool acceptSliderMove;
|
||||||
|
QTimer *moveResizeTimer;
|
||||||
|
|
||||||
/* private stuff */
|
/* private stuff */
|
||||||
OurInterface *interface;
|
OurInterface *interface;
|
||||||
@ -109,6 +119,7 @@ private:
|
|||||||
int stream_id;
|
int stream_id;
|
||||||
int64_t elapsedTime; /* elapsed time in usecs since play started */
|
int64_t elapsedTime; /* elapsed time in usecs since play started */
|
||||||
int vcrFlag;
|
int vcrFlag;
|
||||||
|
bool gotMediaOnCmdline;
|
||||||
|
|
||||||
/* private methods */
|
/* private methods */
|
||||||
void setupUI();
|
void setupUI();
|
||||||
|
@ -31,7 +31,14 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuHelp">
|
||||||
|
<property name="title">
|
||||||
|
<string>Help</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionAbout"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
|
<addaction name="menuHelp"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
<attribute name="toolBarArea">
|
<attribute name="toolBarArea">
|
||||||
@ -55,6 +62,11 @@
|
|||||||
<string>Exit application</string>
|
<string>Exit application</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionAbout">
|
||||||
|
<property name="text">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -215,3 +215,15 @@ void OurInterface::setVcrOp(int op)
|
|||||||
if (demuxMedia)
|
if (demuxMedia)
|
||||||
demuxMedia->setVcrOp(op);
|
demuxMedia->setVcrOp(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OurInterface::setVolume(int volume)
|
||||||
|
{
|
||||||
|
printf("OurInterface::setVolume\n");
|
||||||
|
if (xrdpvr_set_volume(channel, volume))
|
||||||
|
{
|
||||||
|
emit on_ErrorMsg("I/O Error",
|
||||||
|
"Error sending volume to remote client");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
void playMedia();
|
void playMedia();
|
||||||
PlayVideo *getPlayVideoInstance();
|
PlayVideo *getPlayVideoInstance();
|
||||||
void setVcrOp(int op);
|
void setVcrOp(int op);
|
||||||
|
int setVolume(int volume);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onGeometryChanged(int x, int y, int width, int height);
|
void onGeometryChanged(int x, int y, int width, int height);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "playaudio.h"
|
#include "playaudio.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "playvideo.h"
|
#include "playvideo.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -16,16 +16,19 @@ SOURCES += main.cpp\
|
|||||||
mediapacket.cpp \
|
mediapacket.cpp \
|
||||||
playaudio.cpp \
|
playaudio.cpp \
|
||||||
demuxmedia.cpp \
|
demuxmedia.cpp \
|
||||||
ourinterface.cpp
|
ourinterface.cpp \
|
||||||
|
dlgabout.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
mediapacket.h \
|
mediapacket.h \
|
||||||
playvideo.h \
|
playvideo.h \
|
||||||
playaudio.h \
|
playaudio.h \
|
||||||
demuxmedia.h \
|
demuxmedia.h \
|
||||||
ourinterface.h
|
ourinterface.h \
|
||||||
|
dlgabout.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui \
|
||||||
|
dlgabout.ui
|
||||||
|
|
||||||
# added by LK
|
# added by LK
|
||||||
INCLUDEPATH += ../xrdpvr
|
INCLUDEPATH += ../xrdpvr
|
||||||
|
Loading…
Reference in New Issue
Block a user