From 409c6b89d1f44dbae30aa28ec03875a5970d47a4 Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Thu, 31 Dec 2020 12:56:32 -0800 Subject: [PATCH] gstengine: Add a gstreamer debug console page New page initially provides a button that triggers a dump of a graph of the main pipeline. --- src/CMakeLists.txt | 4 +++ src/core/player.cpp | 2 +- src/engines/gstengine.cpp | 13 ++++++-- src/engines/gstengine.h | 14 ++++++++- src/engines/gstenginedebug.cpp | 35 ++++++++++++++++++++++ src/engines/gstenginedebug.h | 40 +++++++++++++++++++++++++ src/engines/gstenginedebug.ui | 50 +++++++++++++++++++++++++++++++ src/engines/gstenginepipeline.cpp | 7 +++-- 8 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 src/engines/gstenginedebug.cpp create mode 100644 src/engines/gstenginedebug.h create mode 100644 src/engines/gstenginedebug.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 186a9e60e..04e5e8985 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,7 @@ set(SOURCES engines/devicefinder.cpp engines/enginebase.cpp engines/gstengine.cpp + engines/gstenginedebug.cpp engines/gstenginepipeline.cpp engines/gstelementdeleter.cpp @@ -455,6 +456,7 @@ set(HEADERS engines/enginebase.h engines/gstengine.h + engines/gstenginedebug.h engines/gstenginepipeline.h engines/gstelementdeleter.h @@ -687,6 +689,8 @@ set(UI devices/deviceproperties.ui devices/deviceviewcontainer.ui + engines/gstenginedebug.ui + globalsearch/globalsearchsettingspage.ui globalsearch/globalsearchview.ui globalsearch/searchproviderstatuswidget.ui diff --git a/src/core/player.cpp b/src/core/player.cpp index b4e9a6fb4..1bdfedc7c 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -56,7 +56,7 @@ Player::Player(Application* app, QObject* parent) : PlayerInterface(parent), app_(app), lastfm_(nullptr), - engine_(new GstEngine(app_->task_manager())), + engine_(new GstEngine(app_)), stream_change_type_(Engine::First), last_state_(Engine::Empty), nb_errors_received_(0), diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index d1ae6eab5..f384b3901 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -40,13 +40,16 @@ #include #include "config.h" +#include "core/application.h" #include "core/closure.h" #include "core/logging.h" #include "core/taskmanager.h" #include "core/timeconstants.h" #include "core/utilities.h" #include "devicefinder.h" +#include "gstenginedebug.h" #include "gstenginepipeline.h" +#include "ui/console.h" #ifdef HAVE_MOODBAR #include "gst/moodbar/plugin.h" @@ -94,9 +97,9 @@ const char* GstEngine::kEnterprisePipeline = "audiotestsrc wave=5 ! " "audiocheblimit mode=0 cutoff=120"; -GstEngine::GstEngine(TaskManager* task_manager) +GstEngine::GstEngine(Application* app) : Engine::Base(), - task_manager_(task_manager), + task_manager_(app->task_manager()), buffering_task_id_(-1), latest_buffer_(nullptr), equalizer_enabled_(false), @@ -119,6 +122,8 @@ GstEngine::GstEngine(TaskManager* task_manager) seek_timer_->setSingleShot(true); seek_timer_->setInterval(kSeekDelayNanosec / kNsecPerMsec); connect(seek_timer_, SIGNAL(timeout()), SLOT(SeekNow())); + connect(app, SIGNAL(NewDebugConsole(Console*)), this, + SLOT(NewDebugConsole(Console*))); ReloadSettings(); @@ -979,3 +984,7 @@ GstEngine::OutputDetailsList GstEngine::GetOutputsList() const { return ret; } + +void GstEngine::NewDebugConsole(Console* console) { + console->AddPage(new GstEngineDebug(this), "GstEngine"); +} diff --git a/src/engines/gstengine.h b/src/engines/gstengine.h index cd3cd822b..92146c29c 100644 --- a/src/engines/gstengine.h +++ b/src/engines/gstengine.h @@ -39,7 +39,10 @@ class QTimer; class QTimerEvent; +class Application; +class Console; class DeviceFinder; +class GstEngineDebug; class GstEnginePipeline; class TaskManager; @@ -57,7 +60,7 @@ class GstEngine : public Engine::Base, public BufferConsumer { Q_OBJECT public: - GstEngine(TaskManager* task_manager); + GstEngine(Application* app); ~GstEngine(); struct OutputDetails { @@ -123,10 +126,19 @@ class GstEngine : public Engine::Base, public BufferConsumer { GTlsDatabase* tls_database() const { return tls_database_; } #endif + void NewDebugConsole(Console* console); + protected: void SetVolumeSW(uint percent); void timerEvent(QTimerEvent*); + private: + // Used for debug purposes only. + friend class GstEngineDebug; + std::shared_ptr GetCurrentPipeline() { + return current_pipeline_; + } + private slots: void EndOfStreamReached(int pipeline_id, bool has_next_track); void HandlePipelineError(int pipeline_id, const QString& message, int domain, diff --git a/src/engines/gstenginedebug.cpp b/src/engines/gstenginedebug.cpp new file mode 100644 index 000000000..fece2d1c3 --- /dev/null +++ b/src/engines/gstenginedebug.cpp @@ -0,0 +1,35 @@ +/* This file is part of Clementine. + Copyright 2020, Jim Broadus + + Clementine 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 3 of the License, or + (at your option) any later version. + + Clementine 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 Clementine. If not, see . +*/ + +#include "gstenginedebug.h" + +#include "core/logging.h" +#include "gstengine.h" +#include "gstenginepipeline.h" + +GstEngineDebug::GstEngineDebug(GstEngine* engine, QWidget* parent) + : QWidget(parent), engine_(engine) { + ui_.setupUi(this); + connect(ui_.dump_graph_button, SIGNAL(clicked()), SLOT(DumpGraph())); +} + +void GstEngineDebug::DumpGraph() { + std::shared_ptr pipeline = engine_->GetCurrentPipeline(); + if (pipeline) { + pipeline->DumpGraph(); + } +} diff --git a/src/engines/gstenginedebug.h b/src/engines/gstenginedebug.h new file mode 100644 index 000000000..d6618e1f7 --- /dev/null +++ b/src/engines/gstenginedebug.h @@ -0,0 +1,40 @@ +/* This file is part of Clementine. + Copyright 2020, Jim Broadus + + Clementine 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 3 of the License, or + (at your option) any later version. + + Clementine 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 Clementine. If not, see . +*/ + +#ifndef GSTENGINEDEBUG_H +#define GSTENGINEDEBUG_H + +#include + +#include "ui_gstenginedebug.h" + +class GstEngine; + +class GstEngineDebug : public QWidget { + Q_OBJECT + public: + GstEngineDebug(GstEngine* engine, QWidget* parent = nullptr); + + private slots: + void DumpGraph(); + + private: + Ui::GstEngineDebug ui_; + GstEngine* engine_; +}; + +#endif // GSTENGINEDEBUG_H diff --git a/src/engines/gstenginedebug.ui b/src/engines/gstenginedebug.ui new file mode 100644 index 000000000..c55e6eb28 --- /dev/null +++ b/src/engines/gstenginedebug.ui @@ -0,0 +1,50 @@ + + + GstEngineDebug + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Pipeline + + + + + + Dump Pipeline Graph + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index 9d0621f0c..053d26d90 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -1337,7 +1337,10 @@ void GstEnginePipeline::DumpGraph() { #ifdef GST_DISABLE_GST_DEBUG qLog(Debug) << "Cannot dump graph. gstreamer debug is not enabled."; #else - qLog(Debug) << "Dumping pipeline graph"; - GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline_), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); + if (pipeline_) { + qLog(Debug) << "Dumping pipeline graph"; + GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline_), + GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); + } #endif }