From df94b9e342f2641eae002779140b0a2c603a55ba Mon Sep 17 00:00:00 2001 From: Raphael Dumusc Date: Tue, 24 Jan 2017 11:26:21 +0100 Subject: [PATCH] DesktopStreamer: new slider to adjust the JPEG quality in advanced settings --- CMakeLists.txt | 2 +- apps/DesktopStreamer/MainWindow.cpp | 13 +++++++++++-- apps/DesktopStreamer/MainWindow.ui | 23 +++++++++++++++++++++++ apps/DesktopStreamer/Stream.cpp | 7 ++++--- apps/DesktopStreamer/Stream.h | 3 ++- doc/Changelog.md | 5 +++++ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07a260b..ba91e70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # Daniel Nachbaur cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -project(Deflect VERSION 0.12.0) +project(Deflect VERSION 0.12.1) set(Deflect_VERSION_ABI 5) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake diff --git a/apps/DesktopStreamer/MainWindow.cpp b/apps/DesktopStreamer/MainWindow.cpp index daeef0a..5b42514 100644 --- a/apps/DesktopStreamer/MainWindow.cpp +++ b/apps/DesktopStreamer/MainWindow.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,11 @@ MainWindow::MainWindow() connect( _remoteControlCheckBox, &QCheckBox::clicked, this, &MainWindow::_onStreamEventsBoxClicked ); + connect( _qualitySlider, &QSlider::valueChanged, []( const int value ) + { + QToolTip::showText( QCursor::pos(), QString::number( value ) + "/100" ); + }); + connect( _actionAdvancedSettings, &QAction::triggered, this, &MainWindow::_showAdvancedSettings ); @@ -242,6 +248,9 @@ void MainWindow::_showAdvancedSettings( const bool visible ) _streamIdLineEdit->setVisible( visible ); _streamIdLabel->setVisible( visible ); + + _qualitySlider->setVisible( visible ); + _qualityLabel->setVisible( visible ); } void MainWindow::_updateStreams() @@ -359,12 +368,12 @@ void MainWindow::_shareDesktopUpdate() for( auto i = _streams.begin(); i != _streams.end(); ) { - const std::string& error = i->second->update(); + const auto error = i->second->update( _qualitySlider->value( )); if( error.empty( )) ++i; else { - _statusbar->showMessage( QString( error.c_str( ))); + _statusbar->showMessage( QString::fromStdString( error )); i = _streams.erase( i ); } } diff --git a/apps/DesktopStreamer/MainWindow.ui b/apps/DesktopStreamer/MainWindow.ui index 296d7c0..8acf208 100644 --- a/apps/DesktopStreamer/MainWindow.ui +++ b/apps/DesktopStreamer/MainWindow.ui @@ -234,6 +234,29 @@ + + + + JPEG quality + + + + + + + 1 + + + 100 + + + 75 + + + Qt::Horizontal + + + diff --git a/apps/DesktopStreamer/Stream.cpp b/apps/DesktopStreamer/Stream.cpp index e559892..4d551b6 100644 --- a/apps/DesktopStreamer/Stream.cpp +++ b/apps/DesktopStreamer/Stream.cpp @@ -120,7 +120,7 @@ bool processEvents( const bool interact ) return true; } -std::string update() +std::string update( const int quality ) { QPixmap pixmap; @@ -169,6 +169,7 @@ std::string update() image.width(), image.height(), deflect::BGRA ); deflectImage.compressionPolicy = deflect::COMPRESSION_ON; + deflectImage.compressionQuality = std::max( 1, std::min( quality, 100 )); if( !_stream.send( deflectImage ) || !_stream.finishFrame( )) return "Streaming failure, connection closed"; @@ -279,9 +280,9 @@ Stream::Stream( const MainWindow& parent, const QPersistentModelIndex window, Stream::~Stream() {} -std::string Stream::update() +std::string Stream::update( const int quality ) { - return _impl->update(); + return _impl->update( quality ); } bool Stream::processEvents( const bool interact ) diff --git a/apps/DesktopStreamer/Stream.h b/apps/DesktopStreamer/Stream.h index c751d75..63d384e 100644 --- a/apps/DesktopStreamer/Stream.h +++ b/apps/DesktopStreamer/Stream.h @@ -57,9 +57,10 @@ class Stream : public deflect::Stream /** * Send an update to the server. + * @param quality the quality setting for compression [1; 100] * @return an empty string on success, the error message otherwise. */ - std::string update(); + std::string update( int quality ); /** * Process all pending events. diff --git a/doc/Changelog.md b/doc/Changelog.md index 8c43a34..ca7f86a 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -3,6 +3,11 @@ Changelog {#Changelog} ## Deflect 0.12 +### 0.12.1 (git master) + +* [145](https://github.com/BlueBrain/Deflect/pull/145): + DesktopStreamer: new slider to adjust the JPEG quality in advanced settings. + ### 0.12.0 (09-12-2016) * [143](https://github.com/BlueBrain/Deflect/pull/143):