[gst-debugger] gst-debugger: add bus_messages module
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gst-debugger] gst-debugger: add bus_messages module
- Date: Mon, 31 Aug 2015 19:50:25 +0000 (UTC)
commit 6f1187fd573a55fc4102472b756b70c74fdb3221
Author: Marcin Kolny <marcin kolny gmail com>
Date: Mon Aug 31 21:50:14 2015 +0200
gst-debugger: add bus_messages module
src/gst-debugger/Makefile.am | 2 +
src/gst-debugger/modules/base_main_module.cpp | 22 ++++++
src/gst-debugger/modules/base_main_module.h | 1 +
src/gst-debugger/modules/bus_messages_module.cpp | 75 ++++++++++++++++++++++
src/gst-debugger/modules/bus_messages_module.h | 42 ++++++++++++
src/gst-debugger/modules/pad_data_modules.cpp | 23 -------
src/gst-debugger/modules/pad_data_modules.h | 1 -
src/gst-debugger/ui/gst-debugger.glade | 2 +-
8 files changed, 143 insertions(+), 25 deletions(-)
---
diff --git a/src/gst-debugger/Makefile.am b/src/gst-debugger/Makefile.am
index 1dd5218..2be8d18 100644
--- a/src/gst-debugger/Makefile.am
+++ b/src/gst-debugger/Makefile.am
@@ -45,6 +45,7 @@ gst_debugger_headers = \
models/remote_data_container.h \
modules/base_main_module.h \
modules/log_module.h \
+ modules/bus_messages_module.h \
modules/gst_log_module.h \
modules/gst_properties_module.h \
modules/main_module.h \
@@ -77,6 +78,7 @@ gst_debugger_ GST_API_VERSION@_SOURCES = \
models/gst_pipeline_model.cpp \
modules/main_module.cpp \
modules/log_module.cpp \
+ modules/bus_messages_module.cpp \
modules/base_main_module.cpp \
modules/pad_data_modules.cpp \
modules/gst_log_module.cpp \
diff --git a/src/gst-debugger/modules/base_main_module.cpp b/src/gst-debugger/modules/base_main_module.cpp
index d60b93c..b0f8bf8 100644
--- a/src/gst-debugger/modules/base_main_module.cpp
+++ b/src/gst-debugger/modules/base_main_module.cpp
@@ -39,3 +39,25 @@ void BaseMainModule::append_details_row(const std::string &name, const std::stri
row[detail_columns.name] = name;
row[detail_columns.value] = value;
}
+
+void BaseMainModule::append_details_from_structure(Gst::Structure& structure)
+{
+ if (!structure.gobj())
+ return;
+
+ structure.foreach([structure, this](const Glib::ustring &name, const Glib::ValueBase &value) -> bool {
+ GValue* tmp_val = new GValue;
+ *tmp_val = G_VALUE_INIT;
+ g_value_init(tmp_val, value.gobj()->g_type);
+ g_value_copy(value.gobj(), tmp_val);
+ auto gvalue = GValueBase::build_gvalue(tmp_val);
+ if (gvalue == nullptr)
+ append_details_row(name, std::string("<unsupported type ") +
g_type_name(G_VALUE_TYPE(value.gobj())) + ">");
+ else
+ {
+ append_details_row(name, gvalue->to_string());
+ delete gvalue;
+ }
+ return true;
+ });
+}
diff --git a/src/gst-debugger/modules/base_main_module.h b/src/gst-debugger/modules/base_main_module.h
index 00d466c..0197192 100644
--- a/src/gst-debugger/modules/base_main_module.h
+++ b/src/gst-debugger/modules/base_main_module.h
@@ -24,6 +24,7 @@ protected:
Glib::RefPtr<Gtk::ListStore> details_model;
void append_details_row(const std::string &name, const std::string &value);
+ void append_details_from_structure(Gst::Structure& structure);
public:
BaseMainModule();
diff --git a/src/gst-debugger/modules/bus_messages_module.cpp
b/src/gst-debugger/modules/bus_messages_module.cpp
new file mode 100644
index 0000000..4563c66
--- /dev/null
+++ b/src/gst-debugger/modules/bus_messages_module.cpp
@@ -0,0 +1,75 @@
+/*
+ * bus_messages_module.cpp
+ *
+ * Created on: Aug 31, 2015
+ * Author: loganek
+ */
+
+#include "bus_messages_module.h"
+
+#include "controller/controller.h"
+
+#include "common/deserializer.h"
+#include "common/gstdebugger.pb.h"
+
+static void free_bus_messages(GstreamerQEBM *qebm) { delete qebm; }
+
+BusMessagesModule::BusMessagesModule()
+{
+ create_dispatcher("new-message", sigc::mem_fun(*this, &BusMessagesModule::bus_message_received_),
(GDestroyNotify)free_bus_messages);
+}
+
+void BusMessagesModule::configure_main_list_view(Gtk::TreeView *view)
+{
+ BaseMainModule::configure_main_list_view(view);
+ view->append_column("Messages", columns.header);
+}
+
+void BusMessagesModule::load_details(Gtk::TreeView *view, const Gtk::TreeModel::Path &path)
+{
+ BaseMainModule::load_details(view, path);
+
+ Gtk::TreeModel::iterator iter = model->get_iter(path);
+ if (!iter)
+ {
+ return;
+ }
+
+ Gtk::TreeModel::Row row = *iter;
+ auto message = Glib::wrap((GstMessage*)row[columns.message], true);
+
+ append_details_row("message type", Gst::Enums::get_name(message->get_message_type()));
+ {
+ gchar buffer[20];
+ snprintf(buffer, 20, "%" GST_TIME_FORMAT, GST_TIME_ARGS(message->get_timestamp()));
+ append_details_row("message timestamp", buffer);
+ }
+ append_details_row("message sequence number", std::to_string(message->get_seqnum()));
+ append_details_row("object", "todo"); // todo
+
+ auto structure = message->get_structure();
+ append_details_from_structure(structure);
+}
+
+void BusMessagesModule::set_controller(const std::shared_ptr<Controller> &controller)
+{
+ BaseMainModule::set_controller(controller);
+
+ controller->on_qebm_received.connect([this] (const GstreamerQEBM &qebm, GstreamerInfo_InfoType type) {
+ if (type == GstreamerInfo_InfoType_MESSAGE)
+ {
+ gui_push("new-message", new GstreamerQEBM (qebm));
+ gui_emit("new-message");
+ }
+ });
+}
+
+void BusMessagesModule::bus_message_received_()
+{
+ auto qebm = gui_pop<GstreamerQEBM*>("new-message");
+ Gtk::TreeModel::Row row = *(model->append());
+ GstMessage *message = gst_message_deserialize (qebm->payload().c_str(), qebm->payload().length());
+ row[columns.header] = "Message";
+ row[columns.message] = message;
+ delete qebm;
+}
diff --git a/src/gst-debugger/modules/bus_messages_module.h b/src/gst-debugger/modules/bus_messages_module.h
new file mode 100644
index 0000000..ed7e995
--- /dev/null
+++ b/src/gst-debugger/modules/bus_messages_module.h
@@ -0,0 +1,42 @@
+/*
+ * bus_messages_module.h
+ *
+ * Created on: Aug 31, 2015
+ * Author: loganek
+ */
+
+#ifndef SRC_GST_DEBUGGER_MODULES_BUS_MESSAGES_MODULE_H_
+#define SRC_GST_DEBUGGER_MODULES_BUS_MESSAGES_MODULE_H_
+
+#include "base_main_module.h"
+
+class GstreamerLog;
+
+class BusMessageModelColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+ BusMessageModelColumns() {
+ add(header); add(message);
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> header;
+ Gtk::TreeModelColumn<GstMessage*> message;
+};
+
+class BusMessagesModule : public BaseMainModule
+{
+ void bus_message_received_();
+
+ BusMessageModelColumns columns;
+
+public:
+ BusMessagesModule();
+ virtual ~BusMessagesModule() {}
+
+ void configure_main_list_view(Gtk::TreeView *view) override;
+ void load_details(Gtk::TreeView *view, const Gtk::TreeModel::Path &path) override;
+
+ void set_controller(const std::shared_ptr<Controller> &controller) override;
+};
+
+#endif /* SRC_GST_DEBUGGER_MODULES_BUS_MESSAGES_MODULE_H_ */
diff --git a/src/gst-debugger/modules/pad_data_modules.cpp b/src/gst-debugger/modules/pad_data_modules.cpp
index b43cb19..e1d685e 100644
--- a/src/gst-debugger/modules/pad_data_modules.cpp
+++ b/src/gst-debugger/modules/pad_data_modules.cpp
@@ -72,29 +72,6 @@ void PadDataModule<T>::load_details(Gtk::TreeView *view, const Gtk::TreeModel::P
}
template<typename T>
-void PadDataModule<T>::append_details_from_structure(Gst::Structure& structure)
-{
- if (!structure.gobj())
- return;
-
- structure.foreach([structure, this](const Glib::ustring &name, const Glib::ValueBase &value) -> bool {
- GValue* tmp_val = new GValue;
- *tmp_val = G_VALUE_INIT;
- g_value_init(tmp_val, value.gobj()->g_type);
- g_value_copy(value.gobj(), tmp_val);
- auto gvalue = GValueBase::build_gvalue(tmp_val);
- if (gvalue == nullptr)
- append_details_row(name, std::string("<unsupported type ") +
g_type_name(G_VALUE_TYPE(value.gobj())) + ">");
- else
- {
- append_details_row(name, gvalue->to_string());
- delete gvalue;
- }
- return true;
- });
-}
-
-template<typename T>
PadWatch_WatchType PadDataModule<T>::get_watch_type() const
{
switch (info_type)
diff --git a/src/gst-debugger/modules/pad_data_modules.h b/src/gst-debugger/modules/pad_data_modules.h
index dccd260..011abc3 100644
--- a/src/gst-debugger/modules/pad_data_modules.h
+++ b/src/gst-debugger/modules/pad_data_modules.h
@@ -39,7 +39,6 @@ class PadDataModule : public BaseMainModule
protected:
PadWatch_WatchType get_watch_type() const;
- void append_details_from_structure(Gst::Structure& structure);
virtual void display_details(const Glib::RefPtr<Gst::MiniObject> &obj, const Glib::ustring &pad_path)
= 0;
public:
diff --git a/src/gst-debugger/ui/gst-debugger.glade b/src/gst-debugger/ui/gst-debugger.glade
index 6a50be2..e9e3ec1 100644
--- a/src/gst-debugger/ui/gst-debugger.glade
+++ b/src/gst-debugger/ui/gst-debugger.glade
@@ -212,7 +212,7 @@
<object class="GtkPaned" id="paned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="position">499</property>
+ <property name="position">645</property>
<child>
<object class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]