[gst-debugger/refactor-v1.0] refactor: restore buffer dialog
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gst-debugger/refactor-v1.0] refactor: restore buffer dialog
- Date: Sat, 3 Oct 2015 23:46:27 +0000 (UTC)
commit 370599498424d34dd6c32b2eac2b0f8e7fbf96ce
Author: Marcin Kolny <marcin kolny gmail com>
Date: Sun Oct 4 00:28:06 2015 +0200
refactor: restore buffer dialog
src/debugserver/gstdebugserverbuffer.c | 37 ++++++++++++++--------
src/gst-debugger/Makefile.am | 2 +
src/gst-debugger/dialogs/buffer_data_dialog.cpp | 10 +++---
src/gst-debugger/dialogs/buffer_data_dialog.h | 4 +-
src/gst-debugger/modules/buffer_module.cpp | 24 ++++++++++++++-
src/gst-debugger/modules/buffer_module.h | 7 ++++
src/gst-debugger/ui_utils.cpp | 15 +++------
src/gst-debugger/ui_utils.h | 2 +-
8 files changed, 68 insertions(+), 33 deletions(-)
---
diff --git a/src/debugserver/gstdebugserverbuffer.c b/src/debugserver/gstdebugserverbuffer.c
index 458ef78..868fea1 100644
--- a/src/debugserver/gstdebugserverbuffer.c
+++ b/src/debugserver/gstdebugserverbuffer.c
@@ -61,22 +61,11 @@ static gint buffer_watch_compare (gconstpointer a, gconstpointer b)
}
}
-static gboolean gst_debugserver_buffer_ok (GstDebugger__GStreamerData* original, gpointer new_ptr)
-{
- GSList *list = new_ptr;
- BufferWatch watch;
-
- watch.pad = NULL;
- watch.pad_path = original->buffer_info->pad;
-
- return g_slist_find_custom (list, &watch, buffer_watch_compare) != NULL;
-}
-
GstDebugserverBuffer * gst_debugserver_buffer_new (void)
{
GstDebugserverBuffer *buf = (GstDebugserverBuffer*)g_malloc (sizeof(GstDebugserverBuffer));
- gst_debugserver_watcher_init (&buf->watcher, gst_debugserver_buffer_ok, (GDestroyNotify)
buffer_watch_list_free, buffer_watch_compare);
+ gst_debugserver_watcher_init (&buf->watcher, NULL, (GDestroyNotify) buffer_watch_list_free,
buffer_watch_compare);
return buf;
}
@@ -121,9 +110,14 @@ gboolean gst_debugserver_buffer_set_watch (GstDebugserverBuffer * buf, gboolean
void gst_debugserver_buffer_send_buffer (GstDebugserverBuffer * buffer,
GstDebugserverTcp * tcp_server, GstPad * pad, GstBuffer * gst_buffer)
{
+ GHashTableIter iter;
+ gpointer client, value;
GstDebugger__GStreamerData gst_data = GST_DEBUGGER__GSTREAMER_DATA__INIT;
GstDebugger__BufferInfo buffer_info = GST_DEBUGGER__BUFFER_INFO__INIT;
gchar *pad_path = gst_utils_get_object_path (GST_OBJECT_CAST (pad));
+ GSList *list = NULL;
+ BufferWatch watch = { FALSE, pad, pad_path };
+ gchar *buff_data = NULL;
buffer_info.dts = GST_BUFFER_DTS (gst_buffer);
buffer_info.pts = GST_BUFFER_PTS (gst_buffer);
@@ -132,13 +126,28 @@ void gst_debugserver_buffer_send_buffer (GstDebugserverBuffer * buffer,
buffer_info.offset = GST_BUFFER_OFFSET_END (gst_buffer);
buffer_info.pad = pad_path;
buffer_info.size = gst_buffer_get_size (gst_buffer);
- buffer_info.has_data = FALSE; // todo
+
+ buff_data = (gchar*) g_malloc (sizeof (gchar) * buffer_info.size);
+ gst_buffer_extract (gst_buffer, 0, buff_data, buffer_info.size);
+
+ buffer_info.data.data = buff_data;
+ buffer_info.data.len = buffer_info.size;
gst_data.info_type_case = GST_DEBUGGER__GSTREAMER_DATA__INFO_TYPE_BUFFER_INFO;
gst_data.buffer_info = &buffer_info;
- gst_debugserver_watcher_send_data (&buffer->watcher, tcp_server, &gst_data);
+ g_mutex_lock (&buffer->watcher.mutex);
+ g_hash_table_iter_init (&iter, buffer->watcher.clients);
+ while (g_hash_table_iter_next (&iter, &client, &value)) {
+ list = g_slist_find_custom ((GSList*) value, &watch, buffer_watch_compare);
+ if (list != NULL) {
+ buffer_info.has_data = ((BufferWatch*)list->data)->send_data;
+ gst_debugserver_tcp_send_packet (tcp_server, (TcpClient*) client, &gst_data);
+ }
+ }
+ g_mutex_unlock (&buffer->watcher.mutex);
+ g_free (buff_data);
g_free (pad_path);
}
diff --git a/src/gst-debugger/Makefile.am b/src/gst-debugger/Makefile.am
index 92bc8df..99af2a7 100644
--- a/src/gst-debugger/Makefile.am
+++ b/src/gst-debugger/Makefile.am
@@ -63,6 +63,8 @@ gst_debugger_ GST_API_VERSION@_SOURCES = \
modules/qe_control_module.h \
dialogs/enums_dialog.cpp \
dialogs/enums_dialog.h \
+ dialogs/buffer_data_dialog.cpp \
+ dialogs/buffer_data_dialog.h \
dialogs/factories_dialog.cpp \
dialogs/factories_dialog.h \
modules/gst_properties_module.cpp \
diff --git a/src/gst-debugger/dialogs/buffer_data_dialog.cpp b/src/gst-debugger/dialogs/buffer_data_dialog.cpp
index af317bc..db934bf 100644
--- a/src/gst-debugger/dialogs/buffer_data_dialog.cpp
+++ b/src/gst-debugger/dialogs/buffer_data_dialog.cpp
@@ -41,7 +41,7 @@ BufferDataDialog::BufferDataDialog(BaseObjectType* cobject, const Glib::RefPtr<G
builder->get_widget("setColumnsInRowButton", set_columns_in_row_button);
set_columns_in_row_button->signal_clicked().connect([this] {
cols_in_row = std::max(1, std::atoi(columns_in_row_entry->get_text().c_str()));
- set_buffer(buf);
+ set_data(buf);
});
}
@@ -49,13 +49,13 @@ void BufferDataDialog::change_format(int i)
{
if (format_buttons[i]->get_active())
{
- set_buffer(buf);
+ set_data(buf);
}
}
-void BufferDataDialog::set_buffer(const Glib::RefPtr<Gst::Buffer> &buffer)
+void BufferDataDialog::set_data(const std::string &data)
{
- buf = buffer;
- text_buffer->set_text(buffer_data_to_string(get_selected_format(), buf, buf->get_size(),
cols_in_row));
+ buf = data;
+ text_buffer->set_text(buffer_data_to_string(get_selected_format(), data, data.length(), cols_in_row));
}
diff --git a/src/gst-debugger/dialogs/buffer_data_dialog.h b/src/gst-debugger/dialogs/buffer_data_dialog.h
index 10f9681..a5c4e25 100644
--- a/src/gst-debugger/dialogs/buffer_data_dialog.h
+++ b/src/gst-debugger/dialogs/buffer_data_dialog.h
@@ -23,7 +23,7 @@ class BufferDataDialog : public Gtk::Dialog
Gtk::Entry *columns_in_row_entry;
Gtk::Button *set_columns_in_row_button;
- Glib::RefPtr<Gst::Buffer> buf;
+ std::string buf;
Glib::RefPtr<Gtk::TextBuffer> text_buffer;
int cols_in_row = 16;
@@ -35,7 +35,7 @@ public:
void change_format(int i);
- void set_buffer(const Glib::RefPtr<Gst::Buffer> &buffer);
+ void set_data(const std::string &data);
};
#endif /* SRC_GST_DEBUGGER_DIALOGS_BUFFER_DATA_DIALOG_H_ */
diff --git a/src/gst-debugger/modules/buffer_module.cpp b/src/gst-debugger/modules/buffer_module.cpp
index 3fef793..d9b2622 100644
--- a/src/gst-debugger/modules/buffer_module.cpp
+++ b/src/gst-debugger/modules/buffer_module.cpp
@@ -7,12 +7,16 @@
#include "buffer_module.h"
+#include "ui_utils.h"
+
+#include "dialogs/buffer_data_dialog.h"
#include "controller/controller.h"
BufferModule::BufferModule()
: BaseMainModule(GstDebugger::GStreamerData::kBufferInfo, "buffers")
{
+ data_dialog = load_dialog<BufferDataDialog>("bufferDataDialog");
}
void BufferModule::load_details(gpointer data)
@@ -29,7 +33,25 @@ void BufferModule::load_details(gpointer data)
if (buffer_info->has_data())
{
- append_details_row("Data", "data"); // todo
+ buffer = buffer_info->data();
+ append_details_row("Data", buffer_data_to_string(StringDataFormat::HEX, buffer, 1024, 16));
+ }
+}
+
+
+void BufferModule::details_activated(const Gtk::TreeModel::Path &path)
+{
+ Gtk::TreeModel::iterator iter = details_model->get_iter(path);
+ if (!iter)
+ {
+ return;
+ }
+
+ Gtk::TreeModel::Row row = *iter;
+ if (row[detail_columns.name] == "Data")
+ {
+ data_dialog->set_data(buffer);
+ data_dialog->show();
}
}
diff --git a/src/gst-debugger/modules/buffer_module.h b/src/gst-debugger/modules/buffer_module.h
index 9dbd01e..afe2069 100644
--- a/src/gst-debugger/modules/buffer_module.h
+++ b/src/gst-debugger/modules/buffer_module.h
@@ -11,11 +11,18 @@
#include "control_module.h"
#include "base_main_module.h"
+class BufferDataDialog;
+
class BufferModule : public BaseMainModule
{
+ BufferDataDialog *data_dialog;
+ std::string buffer;
+
void data_received(const Gtk::TreeModel::Row& row, GstDebugger::GStreamerData *data) override;
void load_details(gpointer data) override;
+ void details_activated(const Gtk::TreeModel::Path &path) override;
+
public:
BufferModule();
virtual ~BufferModule() {}
diff --git a/src/gst-debugger/ui_utils.cpp b/src/gst-debugger/ui_utils.cpp
index 02f3579..6398a74 100644
--- a/src/gst-debugger/ui_utils.cpp
+++ b/src/gst-debugger/ui_utils.cpp
@@ -113,11 +113,10 @@ std::string flags_value_to_string(guint value)
return buff;
}
-std::string buffer_data_to_string(StringDataFormat format, const Glib::RefPtr<Gst::Buffer> &buffer, gsize
max_size, int columns_in_row)
+std::string buffer_data_to_string(StringDataFormat format, const std::string &buffer, gsize max_size, int
columns_in_row)
{
std::ostringstream ss;
- gsize display_size = std::min(max_size, buffer->get_size());
- Glib::RefPtr<Gst::MapInfo> map_info(new Gst::MapInfo());
+ gsize display_size = std::min(max_size, buffer.length());
ss << ((format == StringDataFormat::HEX) ?
std::hex : format == StringDataFormat::OCT ? std::oct : std::dec)
@@ -125,29 +124,25 @@ std::string buffer_data_to_string(StringDataFormat format, const Glib::RefPtr<Gs
int width = format == StringDataFormat::HEX ? 2 : format == StringDataFormat::BINARY ? 8 : 3;
- buffer->map(map_info, Gst::MAP_READ);
-
for (std::size_t i = 0; i < display_size; i++)
{
if (i != 0 && i % columns_in_row == 0)
ss << std::endl;
if (format == StringDataFormat::BINARY)
{
- ss << std::setw(width) << std::bitset<8>(map_info->get_data()[i]) << " ";
+ ss << std::setw(width) << std::bitset<8>(buffer[i]) << " ";
}
else
{
- ss << std::setw(width) << static_cast<int>(map_info->get_data()[i]) << " ";
+ ss << std::setw(width) << static_cast<int>((unsigned char)buffer[i]) << " ";
}
}
- if (display_size < buffer->get_size())
+ if (display_size < buffer.length())
{
ss << std::endl << "more...";
}
- buffer->unmap(map_info);
-
return ss.str();
}
diff --git a/src/gst-debugger/ui_utils.h b/src/gst-debugger/ui_utils.h
index e763a43..53b7987 100644
--- a/src/gst-debugger/ui_utils.h
+++ b/src/gst-debugger/ui_utils.h
@@ -40,7 +40,7 @@ Glib::RefPtr<Gst::PadTemplate> protocol_template_to_gst_template(const GstDebugg
std::string flags_value_to_string(guint value);
-std::string buffer_data_to_string(StringDataFormat format, const Glib::RefPtr<Gst::Buffer> &buffer, gsize
max_size, int columns_in_row);
+std::string buffer_data_to_string(StringDataFormat format, const std::string &buffer, gsize max_size, int
columns_in_row);
Glib::RefPtr<Gtk::Builder> get_dialog_ui_def();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]