gstengine: Add a gstreamer debug console page

New page initially provides a button that triggers a dump of a graph of the main
pipeline.
This commit is contained in:
Jim Broadus 2020-12-31 12:56:32 -08:00 committed by John Maguire
parent c353deba0c
commit 409c6b89d1
8 changed files with 159 additions and 6 deletions

View File

@ -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

View File

@ -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),

View File

@ -40,13 +40,16 @@
#include <vector>
#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");
}

View File

@ -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<GstEnginePipeline> 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,

View File

@ -0,0 +1,35 @@
/* This file is part of Clementine.
Copyright 2020, Jim Broadus <jbroadus@gmail.com>
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 <http://www.gnu.org/licenses/>.
*/
#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<GstEnginePipeline> pipeline = engine_->GetCurrentPipeline();
if (pipeline) {
pipeline->DumpGraph();
}
}

View File

@ -0,0 +1,40 @@
/* This file is part of Clementine.
Copyright 2020, Jim Broadus <jbroadus@gmail.com>
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 <http://www.gnu.org/licenses/>.
*/
#ifndef GSTENGINEDEBUG_H
#define GSTENGINEDEBUG_H
#include <QWidget>
#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

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GstEngineDebug</class>
<widget class="QWidget" name="GstEngineDebug">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="graph_group">
<property name="title">
<string>Pipeline</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="dump_graph_button">
<property name="text">
<string>Dump Pipeline Graph</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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
}