mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
debugutils: port to 0.11
This commit is contained in:
parent
260e2e7427
commit
bc0dd274ee
7 changed files with 206 additions and 181 deletions
|
@ -315,7 +315,7 @@ dnl Non ported plugins (non-dependant, then dependant)
|
||||||
dnl Make sure you have a space before and after all plugins
|
dnl Make sure you have a space before and after all plugins
|
||||||
GST_PLUGINS_NONPORTED=" aiff asfmux \
|
GST_PLUGINS_NONPORTED=" aiff asfmux \
|
||||||
camerabin cdxaparse coloreffects \
|
camerabin cdxaparse coloreffects \
|
||||||
dccp debugutils faceoverlay festival \
|
dccp faceoverlay festival \
|
||||||
fieldanalysis freeverb freeze frei0r gaudieffects geometrictransform h264parse \
|
fieldanalysis freeverb freeze frei0r gaudieffects geometrictransform h264parse \
|
||||||
hdvparse hls id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
hdvparse hls id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
||||||
kate liveadder legacyresample librfb mpegtsmux \
|
kate liveadder legacyresample librfb mpegtsmux \
|
||||||
|
|
|
@ -16,8 +16,8 @@ plugin_LTLIBRARIES = libgstdebugutilsbad.la
|
||||||
|
|
||||||
libgstdebugutilsbad_la_SOURCES = \
|
libgstdebugutilsbad_la_SOURCES = \
|
||||||
gstdebugspy.c \
|
gstdebugspy.c \
|
||||||
fpsdisplaysink.c \
|
|
||||||
debugutilsbad.c \
|
debugutilsbad.c \
|
||||||
|
fpsdisplaysink.c \
|
||||||
gstchecksumsink.c \
|
gstchecksumsink.c \
|
||||||
gstchecksumsink.h \
|
gstchecksumsink.h \
|
||||||
gstchopmydata.c \
|
gstchopmydata.c \
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
|
|
||||||
#include "debugutils-marshal.h"
|
#include "debugutils-marshal.h"
|
||||||
#include "fpsdisplaysink.h"
|
#include "fpsdisplaysink.h"
|
||||||
#include <gst/interfaces/xoverlay.h>
|
|
||||||
|
|
||||||
#define DEFAULT_SIGNAL_FPS_MEASUREMENTS FALSE
|
#define DEFAULT_SIGNAL_FPS_MEASUREMENTS FALSE
|
||||||
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 500 /* 500 ms */
|
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 500 /* 500 ms */
|
||||||
|
@ -214,10 +213,11 @@ fps_display_sink_class_init (GstFPSDisplaySinkClass * klass)
|
||||||
"Zeeshan Ali <zeeshan.ali@nokia.com>, Stefan Kost <stefan.kost@nokia.com>");
|
"Zeeshan Ali <zeeshan.ali@nokia.com>, Stefan Kost <stefan.kost@nokia.com>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GstPadProbeReturn
|
||||||
on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
on_video_sink_data_flow (GstPad * pad, GstPadProbeInfo * info,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GstMiniObject *mini_obj = GST_PAD_PROBE_INFO_DATA (info);
|
||||||
GstFPSDisplaySink *self = GST_FPS_DISPLAY_SINK (user_data);
|
GstFPSDisplaySink *self = GST_FPS_DISPLAY_SINK (user_data);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -246,7 +246,7 @@ on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
||||||
GstClockTimeDiff diff;
|
GstClockTimeDiff diff;
|
||||||
GstClockTime ts;
|
GstClockTime ts;
|
||||||
|
|
||||||
gst_event_parse_qos (ev, NULL, &diff, &ts);
|
gst_event_parse_qos (ev, NULL, NULL, &diff, &ts);
|
||||||
if (diff <= 0.0) {
|
if (diff <= 0.0) {
|
||||||
g_atomic_int_inc (&self->frames_rendered);
|
g_atomic_int_inc (&self->frames_rendered);
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,7 +263,7 @@ on_video_sink_data_flow (GstPad * pad, GstMiniObject * mini_obj,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return GST_PAD_PROBE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -278,6 +278,14 @@ update_sub_sync (GstElement * sink, gpointer data)
|
||||||
GST_WARNING ("Internal sink doesn't have sync property");
|
GST_WARNING ("Internal sink doesn't have sync property");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_sub_sync_foreach (const GValue * item, gpointer data)
|
||||||
|
{
|
||||||
|
GstElement *sink = g_value_get_object (item);
|
||||||
|
|
||||||
|
update_sub_sync (sink, data);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
|
fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
|
||||||
{
|
{
|
||||||
|
@ -288,7 +296,8 @@ fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
|
||||||
|
|
||||||
if (GST_IS_BIN (self->video_sink)) {
|
if (GST_IS_BIN (self->video_sink)) {
|
||||||
iterator = gst_bin_iterate_sinks (GST_BIN (self->video_sink));
|
iterator = gst_bin_iterate_sinks (GST_BIN (self->video_sink));
|
||||||
gst_iterator_foreach (iterator, (GFunc) update_sub_sync,
|
gst_iterator_foreach (iterator,
|
||||||
|
(GstIteratorForeachFunction) update_sub_sync_foreach,
|
||||||
(void *) &self->sync);
|
(void *) &self->sync);
|
||||||
gst_iterator_free (iterator);
|
gst_iterator_free (iterator);
|
||||||
} else
|
} else
|
||||||
|
@ -305,7 +314,7 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
|
||||||
|
|
||||||
/* remove pad probe */
|
/* remove pad probe */
|
||||||
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
||||||
gst_pad_remove_data_probe (sink_pad, self->data_probe_id);
|
gst_pad_remove_probe (sink_pad, self->data_probe_id);
|
||||||
gst_object_unref (sink_pad);
|
gst_object_unref (sink_pad);
|
||||||
self->data_probe_id = -1;
|
self->data_probe_id = -1;
|
||||||
|
|
||||||
|
@ -332,8 +341,9 @@ update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
|
||||||
|
|
||||||
/* attach or pad probe */
|
/* attach or pad probe */
|
||||||
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
|
||||||
self->data_probe_id = gst_pad_add_data_probe (sink_pad,
|
self->data_probe_id = gst_pad_add_probe (sink_pad,
|
||||||
G_CALLBACK (on_video_sink_data_flow), (gpointer) self);
|
GST_PAD_PROBE_TYPE_DATA_BOTH, on_video_sink_data_flow,
|
||||||
|
(gpointer) self, NULL);
|
||||||
gst_object_unref (sink_pad);
|
gst_object_unref (sink_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,21 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
|
||||||
/* class initialization */
|
/* class initialization */
|
||||||
|
|
||||||
GST_BOILERPLATE (GstChecksumSink, gst_checksum_sink, GstBaseSink,
|
#define gst_checksum_sink_parent_class parent_class
|
||||||
GST_TYPE_BASE_SINK);
|
G_DEFINE_TYPE (GstChecksumSink, gst_checksum_sink, GST_TYPE_BASE_SINK);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_checksum_sink_base_init (gpointer g_class)
|
gst_checksum_sink_class_init (GstChecksumSinkClass * klass)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->dispose = gst_checksum_sink_dispose;
|
||||||
|
gobject_class->finalize = gst_checksum_sink_finalize;
|
||||||
|
base_sink_class->start = GST_DEBUG_FUNCPTR (gst_checksum_sink_start);
|
||||||
|
base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_checksum_sink_stop);
|
||||||
|
base_sink_class->render = GST_DEBUG_FUNCPTR (gst_checksum_sink_render);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_checksum_sink_src_template));
|
gst_static_pad_template_get (&gst_checksum_sink_src_template));
|
||||||
|
@ -66,21 +74,7 @@ gst_checksum_sink_base_init (gpointer g_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_checksum_sink_class_init (GstChecksumSinkClass * klass)
|
gst_checksum_sink_init (GstChecksumSink * checksumsink)
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
GstBaseSinkClass *base_sink_class = GST_BASE_SINK_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = gst_checksum_sink_dispose;
|
|
||||||
gobject_class->finalize = gst_checksum_sink_finalize;
|
|
||||||
base_sink_class->start = GST_DEBUG_FUNCPTR (gst_checksum_sink_start);
|
|
||||||
base_sink_class->stop = GST_DEBUG_FUNCPTR (gst_checksum_sink_stop);
|
|
||||||
base_sink_class->render = GST_DEBUG_FUNCPTR (gst_checksum_sink_render);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_checksum_sink_init (GstChecksumSink * checksumsink,
|
|
||||||
GstChecksumSinkClass * checksumsink_class)
|
|
||||||
{
|
{
|
||||||
gst_base_sink_set_sync (GST_BASE_SINK (checksumsink), FALSE);
|
gst_base_sink_set_sync (GST_BASE_SINK (checksumsink), FALSE);
|
||||||
}
|
}
|
||||||
|
@ -113,9 +107,11 @@ static GstFlowReturn
|
||||||
gst_checksum_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
gst_checksum_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
gchar *s;
|
gchar *s;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, GST_BUFFER_DATA (buffer),
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
GST_BUFFER_SIZE (buffer));
|
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, map.data, map.size);
|
||||||
|
gst_buffer_unmap (buffer, &map);
|
||||||
g_print ("%" GST_TIME_FORMAT " %s\n",
|
g_print ("%" GST_TIME_FORMAT " %s\n",
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), s);
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), s);
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,12 @@ static void gst_chop_my_data_get_property (GObject * object,
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
gst_chop_my_data_change_state (GstElement * element, GstStateChange transition);
|
gst_chop_my_data_change_state (GstElement * element, GstStateChange transition);
|
||||||
|
|
||||||
static GstFlowReturn gst_chop_my_data_chain (GstPad * pad, GstBuffer * buffer);
|
static GstFlowReturn gst_chop_my_data_chain (GstPad * pad, GstObject * parent,
|
||||||
static gboolean gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event);
|
GstBuffer * buffer);
|
||||||
static gboolean gst_chop_my_data_src_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_chop_my_data_sink_event (GstPad * pad, GstObject * parent,
|
||||||
|
GstEvent * event);
|
||||||
|
static gboolean gst_chop_my_data_src_event (GstPad * pad, GstObject * parent,
|
||||||
|
GstEvent * event);
|
||||||
|
|
||||||
#define DEFAULT_MAX_SIZE 4096
|
#define DEFAULT_MAX_SIZE 4096
|
||||||
#define DEFAULT_MIN_SIZE 1
|
#define DEFAULT_MIN_SIZE 1
|
||||||
|
@ -91,21 +94,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
|
||||||
/* class initialization */
|
/* class initialization */
|
||||||
|
|
||||||
GST_BOILERPLATE (GstChopMyData, gst_chop_my_data, GstElement, GST_TYPE_ELEMENT);
|
#define gst_chop_my_data_parent_class parent_class
|
||||||
|
G_DEFINE_TYPE (GstChopMyData, gst_chop_my_data, GST_TYPE_ELEMENT);
|
||||||
static void
|
|
||||||
gst_chop_my_data_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_chop_my_data_src_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_chop_my_data_sink_template));
|
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class, "FIXME",
|
|
||||||
"Generic", "FIXME", "David Schleef <ds@schleef.org>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_chop_my_data_class_init (GstChopMyDataClass * klass)
|
gst_chop_my_data_class_init (GstChopMyDataClass * klass)
|
||||||
|
@ -130,11 +120,18 @@ gst_chop_my_data_class_init (GstChopMyDataClass * klass)
|
||||||
g_param_spec_int ("step-size", "step-size",
|
g_param_spec_int ("step-size", "step-size",
|
||||||
"Step increment for random buffer sizes", 1, G_MAXINT,
|
"Step increment for random buffer sizes", 1, G_MAXINT,
|
||||||
DEFAULT_MAX_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_MAX_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&gst_chop_my_data_src_template));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&gst_chop_my_data_sink_template));
|
||||||
|
|
||||||
|
gst_element_class_set_details_simple (element_class, "FIXME",
|
||||||
|
"Generic", "FIXME", "David Schleef <ds@schleef.org>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_chop_my_data_init (GstChopMyData * chopmydata,
|
gst_chop_my_data_init (GstChopMyData * chopmydata)
|
||||||
GstChopMyDataClass * chopmydata_class)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
chopmydata->sinkpad =
|
chopmydata->sinkpad =
|
||||||
|
@ -144,16 +141,14 @@ gst_chop_my_data_init (GstChopMyData * chopmydata,
|
||||||
GST_DEBUG_FUNCPTR (gst_chop_my_data_sink_event));
|
GST_DEBUG_FUNCPTR (gst_chop_my_data_sink_event));
|
||||||
gst_pad_set_chain_function (chopmydata->sinkpad,
|
gst_pad_set_chain_function (chopmydata->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_chop_my_data_chain));
|
GST_DEBUG_FUNCPTR (gst_chop_my_data_chain));
|
||||||
gst_pad_set_getcaps_function (chopmydata->sinkpad, gst_pad_proxy_getcaps);
|
GST_PAD_SET_PROXY_CAPS (chopmydata->sinkpad);
|
||||||
gst_pad_set_setcaps_function (chopmydata->sinkpad, gst_pad_proxy_setcaps);
|
|
||||||
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->sinkpad);
|
||||||
|
|
||||||
chopmydata->srcpad =
|
chopmydata->srcpad =
|
||||||
gst_pad_new_from_static_template (&gst_chop_my_data_src_template, "src");
|
gst_pad_new_from_static_template (&gst_chop_my_data_src_template, "src");
|
||||||
gst_pad_set_event_function (chopmydata->srcpad,
|
gst_pad_set_event_function (chopmydata->srcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_chop_my_data_src_event));
|
GST_DEBUG_FUNCPTR (gst_chop_my_data_src_event));
|
||||||
gst_pad_set_getcaps_function (chopmydata->srcpad, gst_pad_proxy_getcaps);
|
GST_PAD_SET_PROXY_CAPS (chopmydata->srcpad);
|
||||||
gst_pad_set_setcaps_function (chopmydata->srcpad, gst_pad_proxy_setcaps);
|
|
||||||
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->srcpad);
|
gst_element_add_pad (GST_ELEMENT (chopmydata), chopmydata->srcpad);
|
||||||
|
|
||||||
chopmydata->step_size = DEFAULT_STEP_SIZE;
|
chopmydata->step_size = DEFAULT_STEP_SIZE;
|
||||||
|
@ -315,29 +310,28 @@ gst_chop_my_data_process (GstChopMyData * chopmydata, gboolean flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_chop_my_data_chain (GstPad * pad, GstBuffer * buffer)
|
gst_chop_my_data_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstChopMyData *chopmydata;
|
GstChopMyData *chopmydata;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (chopmydata, "chain");
|
GST_DEBUG_OBJECT (chopmydata, "chain");
|
||||||
|
|
||||||
gst_adapter_push (chopmydata->adapter, buffer);
|
gst_adapter_push (chopmydata->adapter, buffer);
|
||||||
ret = gst_chop_my_data_process (chopmydata, FALSE);
|
ret = gst_chop_my_data_process (chopmydata, FALSE);
|
||||||
|
|
||||||
gst_object_unref (chopmydata);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
gst_chop_my_data_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
{
|
{
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GstChopMyData *chopmydata;
|
GstChopMyData *chopmydata;
|
||||||
|
|
||||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (chopmydata, "event");
|
GST_DEBUG_OBJECT (chopmydata, "event");
|
||||||
|
|
||||||
|
@ -349,7 +343,7 @@ gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
||||||
gst_adapter_clear (chopmydata->adapter);
|
gst_adapter_clear (chopmydata->adapter);
|
||||||
res = gst_pad_push_event (chopmydata->srcpad, event);
|
res = gst_pad_push_event (chopmydata->srcpad, event);
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_NEWSEGMENT:
|
case GST_EVENT_SEGMENT:
|
||||||
res = gst_pad_push_event (chopmydata->srcpad, event);
|
res = gst_pad_push_event (chopmydata->srcpad, event);
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
|
@ -361,17 +355,16 @@ gst_chop_my_data_sink_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_object_unref (chopmydata);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_chop_my_data_src_event (GstPad * pad, GstEvent * event)
|
gst_chop_my_data_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
{
|
{
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GstChopMyData *chopmydata;
|
GstChopMyData *chopmydata;
|
||||||
|
|
||||||
chopmydata = GST_CHOP_MY_DATA (gst_pad_get_parent (pad));
|
chopmydata = GST_CHOP_MY_DATA (parent);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (chopmydata, "event");
|
GST_DEBUG_OBJECT (chopmydata, "event");
|
||||||
|
|
||||||
|
@ -384,6 +377,5 @@ gst_chop_my_data_src_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_object_unref (chopmydata);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,31 +108,16 @@ static void gst_compare_get_property (GObject * object,
|
||||||
|
|
||||||
static void gst_compare_reset (GstCompare * overlay);
|
static void gst_compare_reset (GstCompare * overlay);
|
||||||
|
|
||||||
static GstCaps *gst_compare_getcaps (GstPad * pad);
|
static gboolean gst_compare_query (GstPad * pad, GstObject * parent,
|
||||||
|
GstQuery * query);
|
||||||
static GstFlowReturn gst_compare_collect_pads (GstCollectPads2 * cpads,
|
static GstFlowReturn gst_compare_collect_pads (GstCollectPads2 * cpads,
|
||||||
GstCompare * comp);
|
GstCompare * comp);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_compare_change_state (GstElement * element,
|
static GstStateChangeReturn gst_compare_change_state (GstElement * element,
|
||||||
GstStateChange transition);
|
GstStateChange transition);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstCompare, gst_compare, GstElement, GST_TYPE_ELEMENT);
|
#define gst_compare_parent_class parent_class
|
||||||
|
G_DEFINE_TYPE (GstCompare, gst_compare, GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_compare_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&check_sink_factory));
|
|
||||||
gst_element_class_set_details_simple (element_class, "Compare buffers",
|
|
||||||
"Filter/Debug", "Compares incoming buffers",
|
|
||||||
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_compare_finalize (GObject * object)
|
gst_compare_finalize (GObject * object)
|
||||||
|
@ -184,10 +169,20 @@ gst_compare_class_init (GstCompareClass * klass)
|
||||||
g_param_spec_boolean ("upper", "Threshold Upper Bound",
|
g_param_spec_boolean ("upper", "Threshold Upper Bound",
|
||||||
"Whether threshold value is upper bound or lower bound for difference measure",
|
"Whether threshold value is upper bound or lower bound for difference measure",
|
||||||
DEFAULT_UPPER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_UPPER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
|
gst_static_pad_template_get (&sink_factory));
|
||||||
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
|
gst_static_pad_template_get (&check_sink_factory));
|
||||||
|
gst_element_class_set_details_simple (gstelement_class, "Compare buffers",
|
||||||
|
"Filter/Debug", "Compares incoming buffers",
|
||||||
|
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
gst_compare_init (GstCompare * comp)
|
||||||
{
|
{
|
||||||
comp->cpads = gst_collect_pads2_new ();
|
comp->cpads = gst_collect_pads2_new ();
|
||||||
gst_collect_pads2_set_function (comp->cpads,
|
gst_collect_pads2_set_function (comp->cpads,
|
||||||
|
@ -195,12 +190,12 @@ gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
||||||
comp);
|
comp);
|
||||||
|
|
||||||
comp->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
|
comp->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
|
||||||
gst_pad_set_getcaps_function (comp->sinkpad, gst_compare_getcaps);
|
GST_PAD_SET_PROXY_CAPS (comp->sinkpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (comp), comp->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (comp), comp->sinkpad);
|
||||||
|
|
||||||
comp->checkpad =
|
comp->checkpad =
|
||||||
gst_pad_new_from_static_template (&check_sink_factory, "check");
|
gst_pad_new_from_static_template (&check_sink_factory, "check");
|
||||||
gst_pad_set_getcaps_function (comp->checkpad, gst_compare_getcaps);
|
gst_pad_set_query_function (comp->checkpad, gst_compare_query);
|
||||||
gst_element_add_pad (GST_ELEMENT (comp), comp->checkpad);
|
gst_element_add_pad (GST_ELEMENT (comp), comp->checkpad);
|
||||||
|
|
||||||
gst_collect_pads2_add_pad_full (comp->cpads, comp->sinkpad,
|
gst_collect_pads2_add_pad_full (comp->cpads, comp->sinkpad,
|
||||||
|
@ -209,7 +204,7 @@ gst_compare_init (GstCompare * comp, GstCompareClass * klass)
|
||||||
sizeof (GstCollectData2), NULL, TRUE);
|
sizeof (GstCollectData2), NULL, TRUE);
|
||||||
|
|
||||||
comp->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
|
comp->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
|
||||||
gst_pad_set_getcaps_function (comp->srcpad, gst_compare_getcaps);
|
gst_pad_set_query_function (comp->srcpad, gst_compare_query);
|
||||||
gst_element_add_pad (GST_ELEMENT (comp), comp->srcpad);
|
gst_element_add_pad (GST_ELEMENT (comp), comp->srcpad);
|
||||||
|
|
||||||
/* init properties */
|
/* init properties */
|
||||||
|
@ -227,29 +222,21 @@ gst_compare_reset (GstCompare * comp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static gboolean
|
||||||
gst_compare_getcaps (GstPad * pad)
|
gst_compare_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstCompare *comp;
|
GstCompare *comp;
|
||||||
GstPad *otherpad;
|
GstPad *otherpad;
|
||||||
GstCaps *result;
|
|
||||||
|
|
||||||
comp = GST_COMPARE (gst_pad_get_parent (pad));
|
|
||||||
if (G_UNLIKELY (comp == NULL))
|
|
||||||
return gst_caps_new_any ();
|
|
||||||
|
|
||||||
|
comp = GST_COMPARE (parent);
|
||||||
otherpad = (pad == comp->srcpad ? comp->sinkpad : comp->srcpad);
|
otherpad = (pad == comp->srcpad ? comp->sinkpad : comp->srcpad);
|
||||||
result = gst_pad_peer_get_caps (otherpad);
|
|
||||||
if (result == NULL)
|
|
||||||
result = gst_caps_new_any ();
|
|
||||||
|
|
||||||
gst_object_unref (comp);
|
return gst_pad_peer_query (otherpad, query);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||||
|
GstBuffer * buf2, GstCaps * caps2)
|
||||||
{
|
{
|
||||||
gint flags = 0;
|
gint flags = 0;
|
||||||
|
|
||||||
|
@ -290,14 +277,16 @@ gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
/* FIXME ?? */
|
||||||
if (comp->meta & GST_BUFFER_COPY_CAPS) {
|
if (comp->meta & GST_BUFFER_COPY_CAPS) {
|
||||||
if (!gst_caps_is_equal (GST_BUFFER_CAPS (buf1), GST_BUFFER_CAPS (buf2))) {
|
if (!gst_caps_is_equal (caps1, caps2)) {
|
||||||
flags |= GST_BUFFER_COPY_CAPS;
|
flags |= GST_BUFFER_COPY_CAPS;
|
||||||
GST_DEBUG_OBJECT (comp,
|
GST_DEBUG_OBJECT (comp,
|
||||||
"caps %" GST_PTR_FORMAT " != caps %" GST_PTR_FORMAT,
|
"caps %" GST_PTR_FORMAT " != caps %" GST_PTR_FORMAT, caps1, caps2);
|
||||||
GST_BUFFER_CAPS (buf1), GST_BUFFER_CAPS (buf2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* signal mismatch by debug and message */
|
/* signal mismatch by debug and message */
|
||||||
if (flags) {
|
if (flags) {
|
||||||
|
@ -313,23 +302,39 @@ gst_compare_meta (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||||
/* when comparing contents, it is already ensured sizes are equal */
|
/* when comparing contents, it is already ensured sizes are equal */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gst_compare_mem (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
gst_compare_mem (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||||
|
GstBuffer * buf2, GstCaps * caps2)
|
||||||
{
|
{
|
||||||
return memcmp (GST_BUFFER_DATA (buf1), GST_BUFFER_DATA (buf2),
|
GstMapInfo map1, map2;
|
||||||
GST_BUFFER_SIZE (buf1)) ? 1 : 0;
|
gint c;
|
||||||
|
|
||||||
|
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||||
|
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||||
|
|
||||||
|
c = memcmp (map1.data, map2.data, map1.size);
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf1, &map1);
|
||||||
|
gst_buffer_unmap (buf2, &map2);
|
||||||
|
|
||||||
|
return c ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||||
|
GstBuffer * buf2, GstCaps * caps2)
|
||||||
{
|
{
|
||||||
gint i, delta = 0;
|
gint i, delta = 0;
|
||||||
gint8 *data1, *data2;
|
gint8 *data1, *data2;
|
||||||
|
GstMapInfo map1, map2;
|
||||||
|
|
||||||
data1 = (gint8 *) GST_BUFFER_DATA (buf1);
|
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||||
data2 = (gint8 *) GST_BUFFER_DATA (buf2);
|
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||||
|
|
||||||
|
data1 = (gint8 *) map1.data;
|
||||||
|
data2 = (gint8 *) map2.data;
|
||||||
|
|
||||||
/* primitive loop */
|
/* primitive loop */
|
||||||
for (i = 0; i < GST_BUFFER_SIZE (buf1); i++) {
|
for (i = 0; i < map1.size; i++) {
|
||||||
gint diff = ABS (*data1 - *data2);
|
gint diff = ABS (*data1 - *data2);
|
||||||
if (diff > 0)
|
if (diff > 0)
|
||||||
GST_LOG_OBJECT (comp, "diff at %d = %d", i, diff);
|
GST_LOG_OBJECT (comp, "diff at %d = %d", i, diff);
|
||||||
|
@ -338,6 +343,9 @@ gst_compare_max (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
||||||
data2++;
|
data2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf1, &map1);
|
||||||
|
gst_buffer_unmap (buf2, &map2);
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,65 +418,66 @@ gst_compare_ssim_component (GstCompare * comp, guint8 * data1, guint8 * data2,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gdouble
|
static gdouble
|
||||||
gst_compare_ssim (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
gst_compare_ssim (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||||
|
GstBuffer * buf2, GstCaps * caps2)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstVideoInfo info1, info2;
|
||||||
GstVideoFormat format, f;
|
GstVideoFrame frame1, frame2;
|
||||||
gint width, height, w, h, i, comps;
|
gint i, comps;
|
||||||
gdouble cssim[4], ssim, c[4] = { 1.0, 0.0, 0.0, 0.0 };
|
gdouble cssim[4], ssim, c[4] = { 1.0, 0.0, 0.0, 0.0 };
|
||||||
guint8 *data1, *data2;
|
|
||||||
|
|
||||||
caps = GST_BUFFER_CAPS (buf1);
|
if (!caps1)
|
||||||
if (!caps)
|
|
||||||
goto invalid_input;
|
goto invalid_input;
|
||||||
|
|
||||||
if (!gst_video_format_parse_caps (caps, &format, &width, &height))
|
if (!gst_video_info_from_caps (&info1, caps1))
|
||||||
goto invalid_input;
|
goto invalid_input;
|
||||||
|
|
||||||
caps = GST_BUFFER_CAPS (buf2);
|
if (!caps2)
|
||||||
if (!caps)
|
|
||||||
goto invalid_input;
|
goto invalid_input;
|
||||||
|
|
||||||
if (!gst_video_format_parse_caps (caps, &f, &w, &h))
|
if (!gst_video_info_from_caps (&info2, caps1))
|
||||||
goto invalid_input;
|
goto invalid_input;
|
||||||
|
|
||||||
if (f != format || w != width || h != height)
|
if (GST_VIDEO_INFO_FORMAT (&info1) != GST_VIDEO_INFO_FORMAT (&info2) ||
|
||||||
|
GST_VIDEO_INFO_WIDTH (&info1) != GST_VIDEO_INFO_WIDTH (&info2) ||
|
||||||
|
GST_VIDEO_INFO_HEIGHT (&info1) != GST_VIDEO_INFO_HEIGHT (&info2))
|
||||||
return comp->threshold + 1;
|
return comp->threshold + 1;
|
||||||
|
|
||||||
comps = gst_video_format_is_gray (format) ? 1 : 3;
|
comps = GST_VIDEO_INFO_N_COMPONENTS (&info1);
|
||||||
if (gst_video_format_has_alpha (format))
|
|
||||||
comps += 1;
|
|
||||||
|
|
||||||
/* note that some are reported both yuv and gray */
|
/* note that some are reported both yuv and gray */
|
||||||
for (i = 0; i < comps; ++i)
|
for (i = 0; i < comps; ++i)
|
||||||
c[i] = 1.0;
|
c[i] = 1.0;
|
||||||
/* increase luma weight if yuv */
|
/* increase luma weight if yuv */
|
||||||
if (gst_video_format_is_yuv (format) && (comps > 1))
|
if (GST_VIDEO_INFO_IS_YUV (&info1) && (comps > 1))
|
||||||
c[0] = comps - 1;
|
c[0] = comps - 1;
|
||||||
for (i = 0; i < comps; ++i)
|
for (i = 0; i < comps; ++i)
|
||||||
c[i] /= (gst_video_format_is_yuv (format) && (comps > 1)) ?
|
c[i] /= (GST_VIDEO_INFO_IS_YUV (&info1) && (comps > 1)) ?
|
||||||
2 * (comps - 1) : comps;
|
2 * (comps - 1) : comps;
|
||||||
|
|
||||||
data1 = GST_BUFFER_DATA (buf1);
|
gst_video_frame_map (&frame1, &info1, buf1, GST_MAP_READ);
|
||||||
data2 = GST_BUFFER_DATA (buf2);
|
gst_video_frame_map (&frame2, &info2, buf2, GST_MAP_READ);
|
||||||
|
|
||||||
for (i = 0; i < comps; i++) {
|
for (i = 0; i < comps; i++) {
|
||||||
gint offset, cw, ch, step, stride;
|
gint cw, ch, step, stride;
|
||||||
|
|
||||||
/* only support most common formats */
|
/* only support most common formats */
|
||||||
if (gst_video_format_get_component_depth (format, i) != 8)
|
if (GST_VIDEO_INFO_COMP_DEPTH (&info1, i) != 8)
|
||||||
goto unsupported_input;
|
goto unsupported_input;
|
||||||
offset = gst_video_format_get_component_offset (format, i, width, height);
|
cw = GST_VIDEO_FRAME_COMP_WIDTH (&frame1, i);
|
||||||
cw = gst_video_format_get_component_width (format, i, width);
|
ch = GST_VIDEO_FRAME_COMP_HEIGHT (&frame1, i);
|
||||||
ch = gst_video_format_get_component_height (format, i, height);
|
step = GST_VIDEO_FRAME_COMP_PSTRIDE (&frame1, i);
|
||||||
step = gst_video_format_get_pixel_stride (format, i);
|
stride = GST_VIDEO_FRAME_COMP_STRIDE (&frame1, i);
|
||||||
stride = gst_video_format_get_row_stride (format, i, width);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (comp, "component %d", i);
|
GST_LOG_OBJECT (comp, "component %d", i);
|
||||||
cssim[i] = gst_compare_ssim_component (comp, data1 + offset, data2 + offset,
|
cssim[i] = gst_compare_ssim_component (comp,
|
||||||
cw, ch, step, stride);
|
GST_VIDEO_FRAME_COMP_DATA (&frame1, i),
|
||||||
|
GST_VIDEO_FRAME_COMP_DATA (&frame2, i), cw, ch, step, stride);
|
||||||
GST_LOG_OBJECT (comp, "ssim[%d] = %f", i, cssim[i]);
|
GST_LOG_OBJECT (comp, "ssim[%d] = %f", i, cssim[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_video_frame_unmap (&frame1);
|
||||||
|
gst_video_frame_unmap (&frame2);
|
||||||
|
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
GST_DEBUG_OBJECT (comp, "ssim[%d] = %f, c[%d] = %f", i, cssim[i], i, c[i]);
|
GST_DEBUG_OBJECT (comp, "ssim[%d] = %f, c[%d] = %f", i, cssim[i], i, c[i]);
|
||||||
|
@ -488,37 +497,46 @@ invalid_input:
|
||||||
unsupported_input:
|
unsupported_input:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (comp, "raw video format not supported %" GST_PTR_FORMAT,
|
GST_ERROR_OBJECT (comp, "raw video format not supported %" GST_PTR_FORMAT,
|
||||||
caps);
|
caps1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_compare_buffers (GstCompare * comp, GstBuffer * buf1, GstBuffer * buf2)
|
gst_compare_buffers (GstCompare * comp, GstBuffer * buf1, GstCaps * caps1,
|
||||||
|
GstBuffer * buf2, GstCaps * caps2)
|
||||||
{
|
{
|
||||||
gdouble delta = 0;
|
gdouble delta = 0;
|
||||||
|
gsize size1, size2;
|
||||||
|
|
||||||
/* first check metadata */
|
/* first check metadata */
|
||||||
gst_compare_meta (comp, buf1, buf2);
|
gst_compare_meta (comp, buf1, caps1, buf2, caps2);
|
||||||
|
|
||||||
|
size1 = gst_buffer_get_size (buf1);
|
||||||
|
size2 = gst_buffer_get_size (buf1);
|
||||||
|
|
||||||
/* check content according to method */
|
/* check content according to method */
|
||||||
/* but at least size should match */
|
/* but at least size should match */
|
||||||
if (GST_BUFFER_SIZE (buf1) != GST_BUFFER_SIZE (buf2)) {
|
if (size1 != size2) {
|
||||||
delta = comp->threshold + 1;
|
delta = comp->threshold + 1;
|
||||||
} else {
|
} else {
|
||||||
GST_MEMDUMP_OBJECT (comp, "buffer 1", GST_BUFFER_DATA (buf1),
|
GstMapInfo map1, map2;
|
||||||
GST_BUFFER_SIZE (buf1));
|
|
||||||
GST_MEMDUMP_OBJECT (comp, "buffer 2", GST_BUFFER_DATA (buf2),
|
gst_buffer_map (buf1, &map1, GST_MAP_READ);
|
||||||
GST_BUFFER_SIZE (buf2));
|
gst_buffer_map (buf2, &map2, GST_MAP_READ);
|
||||||
|
GST_MEMDUMP_OBJECT (comp, "buffer 1", map1.data, map2.size);
|
||||||
|
GST_MEMDUMP_OBJECT (comp, "buffer 2", map2.data, map2.size);
|
||||||
|
gst_buffer_unmap (buf1, &map1);
|
||||||
|
gst_buffer_unmap (buf2, &map2);
|
||||||
switch (comp->method) {
|
switch (comp->method) {
|
||||||
case GST_COMPARE_METHOD_MEM:
|
case GST_COMPARE_METHOD_MEM:
|
||||||
delta = gst_compare_mem (comp, buf1, buf2);
|
delta = gst_compare_mem (comp, buf1, caps1, buf2, caps2);
|
||||||
break;
|
break;
|
||||||
case GST_COMPARE_METHOD_MAX:
|
case GST_COMPARE_METHOD_MAX:
|
||||||
delta = gst_compare_max (comp, buf1, buf2);
|
delta = gst_compare_max (comp, buf1, caps1, buf2, caps2);
|
||||||
break;
|
break;
|
||||||
case GST_COMPARE_METHOD_SSIM:
|
case GST_COMPARE_METHOD_SSIM:
|
||||||
delta = gst_compare_ssim (comp, buf1, buf2);
|
delta = gst_compare_ssim (comp, buf1, caps1, buf2, caps2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
@ -542,18 +560,21 @@ static GstFlowReturn
|
||||||
gst_compare_collect_pads (GstCollectPads2 * cpads, GstCompare * comp)
|
gst_compare_collect_pads (GstCollectPads2 * cpads, GstCompare * comp)
|
||||||
{
|
{
|
||||||
GstBuffer *buf1, *buf2;
|
GstBuffer *buf1, *buf2;
|
||||||
|
GstCaps *caps1, *caps2;
|
||||||
|
|
||||||
buf1 = gst_collect_pads2_pop (comp->cpads,
|
buf1 = gst_collect_pads2_pop (comp->cpads,
|
||||||
gst_pad_get_element_private (comp->sinkpad));
|
gst_pad_get_element_private (comp->sinkpad));
|
||||||
|
caps1 = gst_pad_get_current_caps (comp->sinkpad);
|
||||||
|
|
||||||
buf2 = gst_collect_pads2_pop (comp->cpads,
|
buf2 = gst_collect_pads2_pop (comp->cpads,
|
||||||
gst_pad_get_element_private (comp->checkpad));
|
gst_pad_get_element_private (comp->checkpad));
|
||||||
|
caps2 = gst_pad_get_current_caps (comp->checkpad);
|
||||||
|
|
||||||
if (!buf1 && !buf2) {
|
if (!buf1 && !buf2) {
|
||||||
gst_pad_push_event (comp->srcpad, gst_event_new_eos ());
|
gst_pad_push_event (comp->srcpad, gst_event_new_eos ());
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_EOS;
|
||||||
} else if (buf1 && buf2) {
|
} else if (buf1 && buf2) {
|
||||||
gst_compare_buffers (comp, buf1, buf2);
|
gst_compare_buffers (comp, buf1, caps1, buf2, caps2);
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING_OBJECT (comp, "buffer %p != NULL", buf1 ? buf1 : buf2);
|
GST_WARNING_OBJECT (comp, "buffer %p != NULL", buf1 ? buf1 : buf2);
|
||||||
|
|
||||||
|
@ -570,6 +591,12 @@ gst_compare_collect_pads (GstCollectPads2 * cpads, GstCompare * comp)
|
||||||
if (buf2)
|
if (buf2)
|
||||||
gst_buffer_unref (buf2);
|
gst_buffer_unref (buf2);
|
||||||
|
|
||||||
|
if (caps1)
|
||||||
|
gst_caps_unref (caps1);
|
||||||
|
|
||||||
|
if (caps2)
|
||||||
|
gst_caps_unref (caps2);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_STATIC_CAPS ("ANY")
|
GST_STATIC_CAPS ("ANY")
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstDebugSpy, gst_debug_spy, GstBaseTransform,
|
G_DEFINE_TYPE (GstDebugSpy, gst_debug_spy, GST_TYPE_BASE_TRANSFORM);
|
||||||
GST_TYPE_BASE_TRANSFORM);
|
|
||||||
|
|
||||||
static void gst_debug_spy_set_property (GObject * object, guint prop_id,
|
static void gst_debug_spy_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -107,33 +106,16 @@ static GstFlowReturn gst_debug_spy_transform_ip (GstBaseTransform * transform,
|
||||||
|
|
||||||
/* GObject vmethod implementations */
|
/* GObject vmethod implementations */
|
||||||
|
|
||||||
static void
|
|
||||||
gst_debug_spy_base_init (gpointer gclass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_debug_spy_debug, "debugspy", 0, "debugspy");
|
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class,
|
|
||||||
"DebugSpy",
|
|
||||||
"Filter/Analyzer/Debug",
|
|
||||||
"DebugSpy provides information on buffers with bus messages",
|
|
||||||
"Guillaume Emont <gemont@igalia.com>");
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_factory));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the debugspy's class */
|
/* initialize the debugspy's class */
|
||||||
static void
|
static void
|
||||||
gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
GstBaseTransformClass *base_transform_class;
|
GstBaseTransformClass *base_transform_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
element_class = (GstElementClass *) klass;
|
||||||
base_transform_class = (GstBaseTransformClass *) klass;
|
base_transform_class = (GstBaseTransformClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_debug_spy_set_property;
|
gobject_class->set_property = gst_debug_spy_set_property;
|
||||||
|
@ -151,6 +133,18 @@ gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
||||||
"Checksum algorithm to use", GST_DEBUG_SPY_CHECKSUM_TYPE,
|
"Checksum algorithm to use", GST_DEBUG_SPY_CHECKSUM_TYPE,
|
||||||
G_CHECKSUM_SHA1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_CHECKSUM_SHA1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
gst_element_class_set_details_simple (element_class,
|
||||||
|
"DebugSpy",
|
||||||
|
"Filter/Analyzer/Debug",
|
||||||
|
"DebugSpy provides information on buffers with bus messages",
|
||||||
|
"Guillaume Emont <gemont@igalia.com>");
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_factory));
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_debug_spy_debug, "debugspy", 0, "debugspy");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the new element
|
/* initialize the new element
|
||||||
|
@ -159,7 +153,7 @@ gst_debug_spy_class_init (GstDebugSpyClass * klass)
|
||||||
* initialize instance structure
|
* initialize instance structure
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_debug_spy_init (GstDebugSpy * debugspy, GstDebugSpyClass * gclass)
|
gst_debug_spy_init (GstDebugSpy * debugspy)
|
||||||
{
|
{
|
||||||
debugspy->silent = FALSE;
|
debugspy->silent = FALSE;
|
||||||
debugspy->checksum_type = G_CHECKSUM_SHA1;
|
debugspy->checksum_type = G_CHECKSUM_SHA1;
|
||||||
|
@ -214,20 +208,26 @@ gst_debug_spy_transform_ip (GstBaseTransform * transform, GstBuffer * buf)
|
||||||
gchar *checksum;
|
gchar *checksum;
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstStructure *message_structure;
|
GstStructure *message_structure;
|
||||||
|
GstMapInfo map;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
checksum = g_compute_checksum_for_data (debugspy->checksum_type,
|
checksum = g_compute_checksum_for_data (debugspy->checksum_type,
|
||||||
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
map.data, map.size);
|
||||||
|
|
||||||
|
caps = gst_pad_get_current_caps (GST_BASE_TRANSFORM_SRC_PAD (transform));
|
||||||
message_structure = gst_structure_new ("buffer",
|
message_structure = gst_structure_new ("buffer",
|
||||||
"checksum", G_TYPE_STRING, checksum,
|
"checksum", G_TYPE_STRING, checksum,
|
||||||
"timestamp", GST_TYPE_CLOCK_TIME, GST_BUFFER_TIMESTAMP (buf),
|
"timestamp", GST_TYPE_CLOCK_TIME, GST_BUFFER_TIMESTAMP (buf),
|
||||||
"duration", GST_TYPE_CLOCK_TIME, GST_BUFFER_DURATION (buf),
|
"duration", GST_TYPE_CLOCK_TIME, GST_BUFFER_DURATION (buf),
|
||||||
"offset", G_TYPE_UINT64, GST_BUFFER_OFFSET (buf),
|
"offset", G_TYPE_UINT64, GST_BUFFER_OFFSET (buf),
|
||||||
"offset_end", G_TYPE_UINT64, GST_BUFFER_OFFSET_END (buf),
|
"offset_end", G_TYPE_UINT64, GST_BUFFER_OFFSET_END (buf),
|
||||||
"size", G_TYPE_UINT, GST_BUFFER_SIZE (buf),
|
"size", G_TYPE_UINT, map.size, "caps", GST_TYPE_CAPS, caps, NULL);
|
||||||
"caps", GST_TYPE_CAPS, GST_BUFFER_CAPS (buf), NULL);
|
if (caps)
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
g_free (checksum);
|
g_free (checksum);
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
message =
|
message =
|
||||||
gst_message_new_element (GST_OBJECT (transform), message_structure);
|
gst_message_new_element (GST_OBJECT (transform), message_structure);
|
||||||
|
|
Loading…
Reference in a new issue