From f1ea625b9b796064ac6423ac7214b79c14014e97 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 02:52:23 +0000 Subject: [PATCH 1/4] Minor fixes in argument parser and help of playuverTools --- lib/PlaYUVerCmdParser.cpp | 25 +++++++++++++++---------- lib/PlaYUVerCmdParser.h | 1 + lib/ProgramOptions.cpp | 5 +++++ lib/ProgramOptions.h | 2 ++ tools/CommandLineHandle.cpp | 15 +++------------ 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index 65bda94..6dbd779 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -62,10 +62,10 @@ Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] ) // m_cParserOptions.setDefaults(); const std::list& argv_unhandled = scanArgv( m_cParserOptions, argc, ( const Char** )argv ); - for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) - { - fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); - } +// for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) +// { +// fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); +// } if( checkListingOpts() ) { @@ -90,12 +90,6 @@ Bool PlaYUVerCmdParser::checkListingOpts() { Bool bRet = false; - if( m_cParserOptions["help"]->count() ) - { - doHelp( std::cout, m_cParserOptions ); - bRet |= true; - } - if( m_cParserOptions["version"]->count() ) { std::cout << "PlaYUVer version " @@ -112,6 +106,17 @@ Bool PlaYUVerCmdParser::checkListingOpts() } bRet |= true; } + + if( Opts()["quality_metrics"]->count() ) + { + printf( "PlaYUVer supported quality metrics: \n" ); + for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + { + printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); + } + bRet |= true; + } + return bRet; } diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h index e602b6e..22a08f4 100644 --- a/lib/PlaYUVerCmdParser.h +++ b/lib/PlaYUVerCmdParser.h @@ -41,6 +41,7 @@ private: Options m_cParserOptions; Bool checkListingOpts(); + Void listModules(); }; } // NAMESPACE diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 5421e9a..3aaf893 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -51,6 +51,11 @@ using namespace std; namespace plaYUVer { +Options::Options( const std::string& name ) +{ + opt_name = name; +} + Options::~Options() { for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) diff --git a/lib/ProgramOptions.h b/lib/ProgramOptions.h index 0007cc1..af69593 100644 --- a/lib/ProgramOptions.h +++ b/lib/ProgramOptions.h @@ -227,6 +227,7 @@ private: class OptionSpecific; struct Options { + Options( const std::string& name = "" ); ~Options(); OptionSpecific addOptions(); @@ -261,6 +262,7 @@ struct Options NamesMap opt_long_map; NamesMap opt_short_map; + std::string opt_name; }; /* Class with templated overloaded operator(), for use by Options::addOptions() */ diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index f6b2b70..abcfbcc 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -86,19 +86,10 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) m_uiLogLevel = RESULT; } - if( Opts()["quality_metrics"]->count() ) + if( Opts()["help"]->count() ) { - printf( "PlaYUVer supported quality metrics: \n" ); - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) - { - printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); - } - iRet = 1; - } - - if( Opts()["module_list"]->count() || Opts()["module_list_full"]->count() ) - { - listModules(); + printf( "Usage: %s modules/quality [options] -input=input_file [--output=output_file]\n", argv[0] ); + doHelp( std::cout, Opts() ); iRet = 1; } From e9fcf28365b715872c1a164797712d79736966a8 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 02:56:38 +0000 Subject: [PATCH 2/4] Rename file --- app/CMakeLists.txt | 2 +- app/{plaYUVerApp.cpp => PlaYUVerApp.cpp} | 4 ++-- app/{plaYUVerApp.h => PlaYUVerApp.h} | 2 +- app/PlaYUVerAppAdaptor.cpp | 2 +- app/PlaYUVerSubWindowHandle.cpp | 2 +- app/main.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename app/{plaYUVerApp.cpp => PlaYUVerApp.cpp} (99%) rename app/{plaYUVerApp.h => PlaYUVerApp.h} (99%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 53c9f25..0c5c485 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -45,7 +45,7 @@ ENDIF() set(plaYUVer_App_SRCS # Main main.cpp - plaYUVerApp.cpp + PlaYUVerApp.cpp PlaYUVerSubWindowHandle.cpp PlaYUVerMdiSubWindow.cpp SubWindowHandle.cpp diff --git a/app/plaYUVerApp.cpp b/app/PlaYUVerApp.cpp similarity index 99% rename from app/plaYUVerApp.cpp rename to app/PlaYUVerApp.cpp index 4119ced..7b8147d 100644 --- a/app/plaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -18,12 +18,12 @@ */ /** - * \file plaYUVerApp.cpp + * \file PlaYUVerApp.cpp * \brief Main definition of the plaYUVerApp app */ #include -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif diff --git a/app/plaYUVerApp.h b/app/PlaYUVerApp.h similarity index 99% rename from app/plaYUVerApp.h rename to app/PlaYUVerApp.h index 13fb5e2..995f904 100644 --- a/app/plaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -18,7 +18,7 @@ */ /** - * \file plaYUVerApp.h + * \file PlaYUVerApp.h * \ingroup PlaYUVerApp * \brief Main definition of the plaYUVerApp app * diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/PlaYUVerAppAdaptor.cpp index 9314035..fb40288 100644 --- a/app/PlaYUVerAppAdaptor.cpp +++ b/app/PlaYUVerAppAdaptor.cpp @@ -24,7 +24,7 @@ #include #include "PlaYUVerAppAdaptor.h" -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" namespace plaYUVer { diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 1958d3d..172e8af 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -22,7 +22,7 @@ * \brief Handle multiple sub-windows */ -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #include "PlaYUVerSubWindowHandle.h" #include "PlaYUVerMdiSubWindow.h" #include "SubWindowHandle.h" diff --git a/app/main.cpp b/app/main.cpp index 3e04ea1..f3d35e2 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -25,7 +25,7 @@ #include "config.h" #include "PlaYUVerAppDefs.h" #include -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #include "SubWindowHandle.h" #ifdef USE_QTDBUS #include "PlaYUVerAppAdaptor.h" From 57e69e63075944a8df4b5595168abb31ea6abbca Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 03:28:30 +0000 Subject: [PATCH 3/4] Add command line args to playuver --- app/PlaYUVerApp.cpp | 48 ++++++++++++++++++++++++++++++------- app/PlaYUVerApp.h | 5 ++-- app/main.cpp | 44 ++++++++++++++++++---------------- lib/PlaYUVerCmdParser.cpp | 9 +++++-- lib/PlaYUVerCmdParser.h | 12 ++++++++-- tools/CommandLineHandle.cpp | 3 ++- 6 files changed, 84 insertions(+), 37 deletions(-) diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 7b8147d..40276f4 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -27,11 +27,11 @@ #ifdef USE_FERVOR #include "fvupdater.h" #endif +#include "lib/PlaYUVerCmdParser.h" #include "PlaYUVerSubWindowHandle.h" #include "VideoHandle.h" #include "QualityHandle.h" #include "ModulesHandle.h" - #include "DialogSubWindowSelector.h" #define SYNCHRONISED_ZOON 1 @@ -83,17 +83,47 @@ plaYUVerApp::plaYUVerApp() m_pcCurrentVideoSubWindow = NULL; } -Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) +Bool plaYUVerApp::parseArgs( Int argc, Char *argv[] ) { - if( argc >= 2 ) + Bool bRet = false; + m_pcCmdParser = new PlaYUVerCmdParser(); + m_pcCmdParser->config( argc, argv ); + + std::vector m_apcInputs; + std::string strResolution( "" ); + std::string strPelFmt( "" ); + + m_pcCmdParser->Opts().addOptions()/**/ + ( "input,i", m_apcInputs, "input file" ) /**/ + ( "size,s", strResolution, "size (WxH)" ) /**/ + ( "pel_fmt", strPelFmt, "pixel format" ); + + if( !m_pcCmdParser->parse() ) { - for( Int i = 1; i < argc; i++ ) - { - loadFile( argv[i] ); - } - m_pcWindowHandle->tileSubWindows(); - zoomToFitAll(); + bRet |= true; } + + if( m_pcCmdParser->Opts()["help"]->count() ) + { + printf( "Usage: %s [options] input_file[s]\n", argv[0] ); + doHelp( std::cout, m_pcCmdParser->Opts() ); + bRet |= true; + } + if( m_pcCmdParser->Opts()["input"]->count() ) + { + for( UInt i = 1; i < m_apcInputs.size(); i++ ) + { + loadFile( QString::fromStdString( m_apcInputs[i] ) ); + } + } + std::list& argv_unhandled = m_pcCmdParser->getNoArgs(); + for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) + { + loadFile( QString::fromStdString( *it ) ); + } + m_pcWindowHandle->tileSubWindows(); + zoomToFitAll(); + return bRet; } Void plaYUVerApp::about() diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index 995f904..c980297 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -55,6 +55,7 @@ namespace plaYUVer { +class PlaYUVerCmdParser; class PlaYUVerStream; class PlaYUVerSubWindowHandle; class VideoHandle; @@ -68,7 +69,7 @@ Q_OBJECT public: plaYUVerApp(); - Void parseArgs( Int argc, Char *argv[] ); + Bool parseArgs( Int argc, Char *argv[] ); Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); protected: @@ -113,7 +114,7 @@ private Q_SLOTS: private: PlaYUVerAppAdaptor* m_pDBusAdaptor; - + PlaYUVerCmdParser* m_pcCmdParser; /** * Save the current subwindow for every category */ diff --git a/app/main.cpp b/app/main.cpp index f3d35e2..abc4855 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -93,33 +93,32 @@ int main( int argc, char *argv[] ) QStringList tokens; // open given files... - foreach(const QString & file, filenameList) + foreach(const QString & file, filenameList){ + QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME, + QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile")); + + QList dbusargs; + dbusargs.append( file ); + m.setArguments(dbusargs); + + QDBusMessage res = QDBusConnection::sessionBus().call(m); + if (res.type() == QDBusMessage::ReplyMessage) { - QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME, - QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile")); - - QList dbusargs; - dbusargs.append( file ); - m.setArguments(dbusargs); - - QDBusMessage res = QDBusConnection::sessionBus().call(m); - if (res.type() == QDBusMessage::ReplyMessage) + if (res.arguments().count() == 1) { - if (res.arguments().count() == 1) + QVariant v = res.arguments()[0]; + if (v.isValid()) { - QVariant v = res.arguments()[0]; - if (v.isValid()) + QString s = v.toString(); + if ((!s.isEmpty()) && (s != QStringLiteral("ERROR"))) { - QString s = v.toString(); - if ((!s.isEmpty()) && (s != QStringLiteral("ERROR"))) - { - tokens << s; - } + tokens << s; } } } } - // this will wait until exiting is emitted by the used instance, if wanted... + } + // this will wait until exiting is emitted by the used instance, if wanted... return needToBlock ? application.exec() : 0; } } @@ -131,10 +130,13 @@ int main( int argc, char *argv[] ) #endif plaYUVerApp mainwindow; mainwindow.show(); - mainwindow.parseArgs( argc, argv ); + if( mainwindow.parseArgs( argc, argv ) ) + { + return 0; + } #ifdef USE_FERVOR - FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml"); + FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml"); FvUpdater::sharedUpdater()->SetDependencies("ALL"); #endif diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index 6dbd779..f8ec2cc 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -55,12 +55,17 @@ Options& PlaYUVerCmdParser::Opts() return m_cParserOptions; } -Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] ) +std::list& PlaYUVerCmdParser::getNoArgs() +{ + return m_aUnhandledArgs; +} + +Bool PlaYUVerCmdParser::parse() { try { // m_cParserOptions.setDefaults(); - const std::list& argv_unhandled = scanArgv( m_cParserOptions, argc, ( const Char** )argv ); + m_aUnhandledArgs = scanArgv( m_cParserOptions, m_iArgc, ( const Char** )m_ppArgv ); // for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) // { diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h index 22a08f4..8468c0c 100644 --- a/lib/PlaYUVerCmdParser.h +++ b/lib/PlaYUVerCmdParser.h @@ -25,7 +25,6 @@ #include "PlaYUVerDefs.h" #include "ProgramOptions.h" - namespace plaYUVer { @@ -35,10 +34,19 @@ public: PlaYUVerCmdParser(); ~PlaYUVerCmdParser(); - Bool parse( Int argc, Char *argv[] ); + Void config( Int argc, Char *argv[] ) + { + m_iArgc = argc; + m_ppArgv = argv; + } + Bool parse(); + std::list& getNoArgs(); Options& Opts(); private: + Int m_iArgc; + Char** m_ppArgv; Options m_cParserOptions; + std::list m_aUnhandledArgs; Bool checkListingOpts(); Void listModules(); diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index abcfbcc..ba07d58 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -76,7 +76,8 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) ( "quality", m_strQualityMetric, "select a quality metric" ) /**/ ( "module", m_strModule, "select a module (use internal name)" ); - if( !parse( argc, argv ) ) + config( argc, argv ); + if( !parse() ) { iRet = 1; } From 86c4fdc0c7e7a801ffe494f77e1dc84475d51282 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 03:37:56 +0000 Subject: [PATCH 4/4] Set version 0.6.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 535f465..a04c1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET( PROJECT_NAME "playuver" ) PROJECT( ${PROJECT_NAME} ) SET( PLAYUVER_VERSION_MAJOR "0" ) SET( PLAYUVER_VERSION_MINOR "6" ) -SET( PLAYUVER_VERSION_PATCH "0" ) +SET( PLAYUVER_VERSION_PATCH "1" ) SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}")