info: add buffer list support to GST_PTR_FORMAT

This commit is contained in:
Tim-Philipp Müller 2016-01-08 19:25:24 +00:00
parent 6b71877692
commit 4febebb962
2 changed files with 46 additions and 0 deletions

View file

@ -607,6 +607,31 @@ gst_info_describe_buffer (GstBuffer * buffer)
GST_BUFFER_FLAGS (buffer));
}
static inline gchar *
gst_info_describe_buffer_list (GstBufferList * list)
{
GstClockTime pts = GST_CLOCK_TIME_NONE;
GstClockTime dts = GST_CLOCK_TIME_NONE;
gsize total_size = 0;
guint n, i;
n = gst_buffer_list_length (list);
for (i = 0; i < n; ++i) {
GstBuffer *buf = gst_buffer_list_get (list, i);
if (i == 0) {
pts = GST_BUFFER_PTS (buf);
dts = GST_BUFFER_DTS (buf);
}
total_size += gst_buffer_get_size (buf);
}
return g_strdup_printf ("bufferlist: %p, %u buffers, pts %" GST_TIME_FORMAT
", dts %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT, list, n,
GST_TIME_ARGS (pts), GST_TIME_ARGS (dts), total_size);
}
static inline gchar *
gst_info_describe_event (GstEvent * event)
{
@ -693,6 +718,9 @@ gst_debug_print_object (gpointer ptr)
if (GST_IS_BUFFER (ptr)) {
return gst_info_describe_buffer (GST_BUFFER_CAST (ptr));
}
if (GST_IS_BUFFER_LIST (ptr)) {
return gst_info_describe_buffer_list (GST_BUFFER_LIST_CAST (ptr));
}
#ifdef USE_POISONING
if (*(guint32 *) ptr == 0xffffffff) {
return g_strdup_printf ("<poisoned@%p>", ptr);

View file

@ -89,6 +89,24 @@ GST_START_TEST (info_ptr_format_printf_extension)
gst_message_unref (msg);
}
/* buffer and buffer list */
{
GstBufferList *list;
GstBuffer *buf;
buf = gst_buffer_new_allocate (NULL, 42, NULL);
GST_BUFFER_PTS (buf) = 5 * GST_SECOND;
GST_BUFFER_DURATION (buf) = GST_SECOND;
GST_LOG ("BUFFER: %" GST_PTR_FORMAT, buf);
list = gst_buffer_list_new ();
gst_buffer_list_add (list, buf);
buf = gst_buffer_new_allocate (NULL, 58, NULL);
gst_buffer_list_add (list, buf);
GST_LOG ("BUFFERLIST: %" GST_PTR_FORMAT, list);
gst_buffer_list_unref (list);
}
#if 0
/* TODO: GObject */
{