3 * Copyright (C) 2013 Collabora Ltd.
4 * Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>
6 * gst-validate-pad-monitor.c - Validate PadMonitor class
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include "gst-validate-internal.h"
29 #include "gst-validate-pad-monitor.h"
30 #include "gst-validate-element-monitor.h"
31 #include "gst-validate-pipeline-monitor.h"
32 #include "gst-validate-reporter.h"
37 * SECTION:gst-validate-pad-monitor
38 * @short_description: Class that wraps a #GstPad for Validate checks
43 static GstValidateInterceptionReturn
44 gst_validate_pad_monitor_intercept_report (GstValidateReporter * reporter,
45 GstValidateReport * report);
48 G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init)
51 _reporter_iface_init (GstValidateReporterInterface * iface)
53 iface->intercept_report = gst_validate_pad_monitor_intercept_report;
56 #define gst_validate_pad_monitor_parent_class parent_class
57 G_DEFINE_TYPE_WITH_CODE (GstValidatePadMonitor, gst_validate_pad_monitor,
58 GST_TYPE_VALIDATE_MONITOR, _do_init);
60 #define PENDING_FIELDS "pending-fields"
61 #define AUDIO_TIMESTAMP_TOLERANCE (GST_MSECOND * 100)
63 #define PAD_PARENT_IS_DEMUXER(m) \
64 (GST_VALIDATE_MONITOR_GET_PARENT(m) ? \
65 GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DEMUXER ( \
66 GST_VALIDATE_MONITOR_GET_PARENT(m)) : \
69 #define PAD_PARENT_IS_DECODER(m) \
70 (GST_VALIDATE_MONITOR_GET_PARENT(m) ? \
71 GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DECODER ( \
72 GST_VALIDATE_MONITOR_GET_PARENT(m)) : \
75 #define PAD_PARENT_IS_ENCODER(m) \
76 (GST_VALIDATE_MONITOR_GET_PARENT(m) ? \
77 GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_ENCODER ( \
78 GST_VALIDATE_MONITOR_GET_PARENT(m)) : \
83 * Locking the parent should always be done before locking the
84 * pad-monitor to prevent deadlocks in case another monitor from
85 * another pad on the same element starts an operation that also
86 * requires locking itself and some other monitors from internally
90 * An element has a sink and a src pad. Some test starts running at sinkpad
91 * and it locks the parent, and then it locks itself. In case it needs to get
92 * some information from the srcpad, it is able to lock the srcpad and get it
93 * because the srcpad should never lock itself before locking the parent (which
94 * it won't be able as sinkpad already locked it).
96 * As a side one, it is possible that srcpad locks itself without locking the
97 * parent in case it wants to do a check that won't need to use other internally
98 * linked pads (sinkpad). But in this case it might lock and unlock freely without
101 #define GST_VALIDATE_PAD_MONITOR_PARENT_LOCK(m) \
103 if (G_LIKELY (GST_VALIDATE_MONITOR_GET_PARENT (m))) { \
104 GST_VALIDATE_MONITOR_LOCK (GST_VALIDATE_MONITOR_GET_PARENT (m)); \
106 GST_WARNING_OBJECT (m, "No parent found, can't lock"); \
110 #define GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK(m) \
112 if (G_LIKELY (GST_VALIDATE_MONITOR_GET_PARENT (m))) { \
113 GST_VALIDATE_MONITOR_UNLOCK (GST_VALIDATE_MONITOR_GET_PARENT (m)); \
115 GST_WARNING_OBJECT (m, "No parent found, can't unlock"); \
121 GstClockTime timestamp;
123 } SerializedEventData;
126 _get_actual_pad (GstPad * pad)
130 gst_object_ref (pad);
132 /* We don't monitor ghost pads */
133 while (GST_IS_GHOST_PAD (pad)) {
135 pad = gst_ghost_pad_get_target ((GstGhostPad *) pad);
136 gst_object_unref (tmp_pad);
139 while (GST_IS_PROXY_PAD (pad)) {
141 pad = gst_pad_get_peer (pad);
142 gst_object_unref (tmp_pad);
149 _find_master_report_on_pad (GstPad * pad, GstValidateReport * report)
151 GstValidatePadMonitor *pad_monitor;
152 GstValidateReport *prev_report;
153 gboolean result = FALSE;
154 GstPad *tmppad = pad;
156 pad = _get_actual_pad (pad);
158 GST_ERROR_OBJECT (tmppad, "Does not have a target yet");
163 pad_monitor = g_object_get_data ((GObject *) pad, "validate-monitor");
165 /* For some reason this pad isn't monitored */
166 if (pad_monitor == NULL)
169 prev_report = gst_validate_reporter_get_report ((GstValidateReporter *)
170 pad_monitor, report->issue->issue_id);
173 if (prev_report->master_report)
174 result = gst_validate_report_set_master_report (report,
175 prev_report->master_report);
177 result = gst_validate_report_set_master_report (report, prev_report);
181 gst_object_unref (pad);
187 _find_master_report_for_sink_pad (GstValidatePadMonitor * pad_monitor,
188 GstValidateReport * report)
191 gboolean result = FALSE;
193 GST_PAD_CAST (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
196 peerpad = gst_pad_get_peer (pad);
197 gst_object_unref (pad);
199 /* If the peer src pad already has a similar report no need to look
201 if (peerpad && _find_master_report_on_pad (peerpad, report))
205 gst_object_unref (peerpad);
211 _find_master_report_for_src_pad (GstValidatePadMonitor * pad_monitor,
212 GstValidateReport * report)
216 gboolean result = FALSE;
218 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
221 iter = gst_pad_iterate_internal_links (target);
224 GValue value = { 0, };
225 switch (gst_iterator_next (iter, &value)) {
226 case GST_ITERATOR_OK:
228 GstPad *pad = g_value_get_object (&value);
230 if (_find_master_report_on_pad (pad, report)) {
235 g_value_reset (&value);
238 case GST_ITERATOR_RESYNC:
239 gst_iterator_resync (iter);
241 case GST_ITERATOR_ERROR:
242 GST_WARNING_OBJECT (target, "Internal links pad iteration error");
245 case GST_ITERATOR_DONE:
250 gst_object_unref (target);
251 gst_iterator_free (iter);
256 static GstValidateInterceptionReturn
257 _concatenate_issues (GstValidatePadMonitor * pad_monitor,
258 GstValidateReport * report)
261 GST_PAD_CAST (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
264 if (GST_PAD_IS_SINK (pad)
265 && _find_master_report_for_sink_pad (pad_monitor, report)) {
266 gst_object_unref (pad);
267 return GST_VALIDATE_REPORTER_KEEP;
268 } else if (GST_PAD_IS_SRC (pad)
269 && _find_master_report_for_src_pad (pad_monitor, report)) {
270 gst_object_unref (pad);
271 return GST_VALIDATE_REPORTER_KEEP;
274 gst_object_unref (pad);
275 return GST_VALIDATE_REPORTER_REPORT;
278 static GstValidateInterceptionReturn
279 gst_validate_pad_monitor_intercept_report (GstValidateReporter *
280 reporter, GstValidateReport * report)
282 GstValidateReporterInterface *iface_class, *old_iface_class;
283 GstValidatePadMonitor *pad_monitor = GST_VALIDATE_PAD_MONITOR (reporter);
284 GstValidateReportingDetails monitor_reporting_level;
285 GstValidateInterceptionReturn ret;
287 monitor_reporting_level =
288 gst_validate_reporter_get_reporting_level (reporter);
291 G_TYPE_INSTANCE_GET_INTERFACE (reporter, GST_TYPE_VALIDATE_REPORTER,
292 GstValidateReporterInterface);
293 old_iface_class = g_type_interface_peek_parent (iface_class);
295 old_iface_class->intercept_report (reporter, report);
297 switch (monitor_reporting_level) {
298 case GST_VALIDATE_SHOW_NONE:
299 ret = GST_VALIDATE_REPORTER_DROP;
301 case GST_VALIDATE_SHOW_UNKNOWN:
302 ret = _concatenate_issues (pad_monitor, report);
305 ret = GST_VALIDATE_REPORTER_REPORT;
309 gst_validate_report_set_reporting_level (report, monitor_reporting_level);
314 debug_pending_event (GstPad * pad, GPtrArray * array)
319 for (i = 0; i < len; i++) {
320 SerializedEventData *data = g_ptr_array_index (array, i);
321 GST_DEBUG_OBJECT (pad, "event #%d %" GST_TIME_FORMAT " %s %p",
322 i, GST_TIME_ARGS (data->timestamp),
323 GST_EVENT_TYPE_NAME (data->event), data->event);
328 _serialized_event_data_free (SerializedEventData * serialized_event)
330 gst_event_unref (serialized_event->event);
331 g_slice_free (SerializedEventData, serialized_event);
334 static gboolean gst_validate_pad_monitor_do_setup (GstValidateMonitor *
336 static GstElement *gst_validate_pad_monitor_get_element (GstValidateMonitor *
339 gst_validate_pad_monitor_setcaps_pre (GstValidatePadMonitor * pad_monitor,
341 static void gst_validate_pad_monitor_setcaps_post (GstValidatePadMonitor *
342 pad_monitor, GstCaps * caps, gboolean ret);
344 #define PAD_IS_IN_PUSH_MODE(p) ((p)->mode == GST_PAD_MODE_PUSH)
347 _structure_is_raw_video (GstStructure * structure)
349 return gst_structure_has_name (structure, "video/x-raw");
353 _structure_is_raw_audio (GstStructure * structure)
355 return gst_structure_has_name (structure, "audio/x-raw");
359 _get_event_string (GstEvent * event)
361 const GstStructure *st;
363 if ((st = gst_event_get_structure (event)))
364 return gst_structure_to_string (st);
366 return g_strdup_printf ("%s", GST_EVENT_TYPE_NAME (event));
370 _check_field_type (GstValidatePadMonitor * monitor,
371 GstStructure * structure, gboolean mandatory, const gchar * field, ...)
375 gchar *joined_types = NULL;
376 const gchar *rejected_types[5];
377 gint rejected_types_index = 0;
380 if (!gst_structure_has_field (structure, field)) {
382 gchar *str = gst_structure_to_string (structure);
384 GST_VALIDATE_REPORT (monitor, CAPS_IS_MISSING_FIELD,
385 "Field '%s' is missing from structure: %s", field, str);
388 GST_DEBUG_OBJECT (monitor, "Field %s is missing but is not mandatory",
394 memset ((gchar **) rejected_types, 0, sizeof (rejected_types));
395 va_start (var_args, field);
396 while ((type = va_arg (var_args, GType)) != 0) {
397 if (gst_structure_has_field_typed (structure, field, type)) {
401 rejected_types[rejected_types_index++] = g_type_name (type);
405 joined_types = g_strjoinv (" / ", (gchar **) rejected_types);
406 struct_str = gst_structure_to_string (structure);
407 GST_VALIDATE_REPORT (monitor, CAPS_FIELD_HAS_BAD_TYPE,
408 "Field '%s' has wrong type %s in structure '%s'. Expected: %s", field,
409 g_type_name (gst_structure_get_field_type (structure, field)), struct_str,
411 g_free (joined_types);
416 gst_validate_pad_monitor_check_raw_video_caps_complete (GstValidatePadMonitor *
417 monitor, GstStructure * structure)
419 _check_field_type (monitor, structure, TRUE, "width", G_TYPE_INT,
420 GST_TYPE_INT_RANGE, 0);
421 _check_field_type (monitor, structure, TRUE, "height", G_TYPE_INT,
422 GST_TYPE_INT_RANGE, 0);
423 _check_field_type (monitor, structure, TRUE, "framerate", GST_TYPE_FRACTION,
424 GST_TYPE_FRACTION_RANGE, 0);
425 _check_field_type (monitor, structure, FALSE, "pixel-aspect-ratio",
426 GST_TYPE_FRACTION, GST_TYPE_FRACTION_RANGE, 0);
427 _check_field_type (monitor, structure, TRUE, "format", G_TYPE_STRING,
432 gst_validate_pad_monitor_check_raw_audio_caps_complete (GstValidatePadMonitor *
433 monitor, GstStructure * structure)
436 _check_field_type (monitor, structure, TRUE, "format", G_TYPE_STRING,
438 _check_field_type (monitor, structure, TRUE, "layout", G_TYPE_STRING,
440 _check_field_type (monitor, structure, TRUE, "rate", G_TYPE_INT,
441 GST_TYPE_LIST, GST_TYPE_INT_RANGE, 0);
442 _check_field_type (monitor, structure, TRUE, "channels", G_TYPE_INT,
443 GST_TYPE_LIST, GST_TYPE_INT_RANGE, 0);
444 if (gst_structure_get_int (structure, "channels", &channels)) {
446 _check_field_type (monitor, structure, TRUE, "channel-mask",
447 GST_TYPE_BITMASK, GST_TYPE_LIST, 0);
452 gst_validate_pad_monitor_check_caps_complete (GstValidatePadMonitor * monitor,
455 GstStructure *structure;
458 GST_DEBUG_OBJECT (monitor, "Checking caps %" GST_PTR_FORMAT, caps);
460 for (i = 0; i < gst_caps_get_size (caps); i++) {
461 structure = gst_caps_get_structure (caps, i);
463 if (_structure_is_raw_video (structure)) {
464 gst_validate_pad_monitor_check_raw_video_caps_complete (monitor,
467 } else if (_structure_is_raw_audio (structure)) {
468 gst_validate_pad_monitor_check_raw_audio_caps_complete (monitor,
475 gst_validate_pad_monitor_get_othercaps (GstValidatePadMonitor * monitor,
478 GstCaps *caps = gst_caps_new_empty ();
484 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
487 iter = gst_pad_iterate_internal_links (pad);
490 GValue value = { 0, };
491 switch (gst_iterator_next (iter, &value)) {
492 case GST_ITERATOR_OK:
493 otherpad = g_value_get_object (&value);
495 /* TODO What would be the correct caps operation to merge the caps in
496 * case one sink is internally linked to multiple srcs? */
497 peercaps = gst_pad_peer_query_caps (otherpad, filter);
499 caps = gst_caps_merge (caps, peercaps);
501 g_value_reset (&value);
503 case GST_ITERATOR_RESYNC:
504 gst_iterator_resync (iter);
505 gst_caps_unref (caps);
506 caps = gst_caps_new_empty ();
508 case GST_ITERATOR_ERROR:
509 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
512 case GST_ITERATOR_DONE:
517 GST_DEBUG_OBJECT (pad, "Otherpad caps: %" GST_PTR_FORMAT, caps);
519 gst_iterator_free (iter);
520 gst_object_unref (pad);
526 _structure_is_video (GstStructure * structure)
528 const gchar *name = gst_structure_get_name (structure);
530 return g_strstr_len (name, 6, "video/")
531 && strcmp (name, "video/quicktime") != 0;
535 _structure_is_audio (GstStructure * structure)
537 const gchar *name = gst_structure_get_name (structure);
539 return g_strstr_len (name, 6, "audio/") != NULL;
543 gst_validate_pad_monitor_pad_should_proxy_othercaps (GstValidatePadMonitor *
546 GstValidateMonitor *parent = GST_VALIDATE_MONITOR_GET_PARENT (monitor);
551 /* We only know how to handle othercaps checks for codecs so far */
552 return (GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DECODER (parent) ||
553 GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_ENCODER (parent)) &&
554 !GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_CONVERTER (parent);
558 /* Check if the field @f from @s2 (if present) is represented in @s1
559 * Represented here means either equal or @s1's value is in a list/range
563 _structures_field_is_contained (GstStructure * s1, GstStructure * s2,
564 gboolean mandatory, const gchar * f)
569 v2 = gst_structure_get_value (s2, f);
571 return TRUE; /* nothing to compare to */
573 v1 = gst_structure_get_value (s1, f);
577 if (!gst_value_is_fixed (v1))
580 if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL)
583 if (GST_VALUE_HOLDS_LIST (v2)) {
585 for (i = 0; i < gst_value_list_get_size (v2); i++) {
586 const GValue *v2_subvalue = gst_value_list_get_value (v2, i);
587 if (gst_value_compare (v1, v2_subvalue) == GST_VALUE_EQUAL)
592 if (GST_VALUE_HOLDS_ARRAY (v2)) {
594 for (i = 0; i < gst_value_array_get_size (v2); i++) {
595 const GValue *v2_subvalue = gst_value_array_get_value (v2, i);
596 if (gst_value_compare (v1, v2_subvalue) == GST_VALUE_EQUAL)
601 if (GST_VALUE_HOLDS_INT_RANGE (v2)) {
604 min = gst_value_get_int_range_min (v2);
605 max = gst_value_get_int_range_max (v2);
607 if (G_VALUE_HOLDS_INT (v1)) {
608 gint v = g_value_get_int (v1);
610 return v >= min && v <= max;
612 /* TODO compare int ranges with int ranges
613 * or with lists if useful */
617 if (GST_VALUE_HOLDS_FRACTION_RANGE (v2)) {
618 const GValue *min, *max;
620 min = gst_value_get_fraction_range_min (v2);
621 max = gst_value_get_fraction_range_max (v2);
623 if (GST_VALUE_HOLDS_FRACTION (v1)) {
624 gint v_min = gst_value_compare (v1, min);
625 gint v_max = gst_value_compare (v1, max);
627 return (v_min == GST_VALUE_EQUAL || v_min == GST_VALUE_GREATER_THAN) &&
628 (v_max == GST_VALUE_EQUAL || v_max == GST_VALUE_LESS_THAN);
630 /* TODO compare fraction ranges with fraction ranges
631 * or with lists if useful */
639 _check_and_copy_structure_field (GstStructure * from, GstStructure * to,
642 if (gst_structure_has_field (from, name)) {
643 gst_structure_set_value (to, name, gst_structure_get_value (from, name));
648 gst_validate_pad_monitor_copy_caps_fields_into_caps (GstValidatePadMonitor *
649 monitor, GstCaps * from_caps, GstCaps * into_caps)
651 gint i, j, into_size, from_size;
652 GstStructure *structure;
653 GstCaps *res = gst_caps_new_empty ();
655 into_size = gst_caps_get_size (into_caps);
656 from_size = gst_caps_get_size (from_caps);
658 for (i = 0; i < into_size; i++) {
659 GstStructure *s = gst_caps_get_structure (into_caps, i);
661 for (j = 0; j < from_size; j++) {
662 GstStructure *new_structure = gst_structure_copy (s);
664 structure = gst_caps_get_structure (from_caps, j);
665 if (_structure_is_video (structure)) {
666 _check_and_copy_structure_field (structure, new_structure, "width");
667 _check_and_copy_structure_field (structure, new_structure, "height");
668 _check_and_copy_structure_field (structure, new_structure, "framerate");
669 _check_and_copy_structure_field (structure, new_structure,
670 "pixel-aspect-ratio");
671 } else if (_structure_is_audio (s)) {
672 _check_and_copy_structure_field (structure, new_structure, "rate");
673 _check_and_copy_structure_field (structure, new_structure, "channels");
676 gst_caps_append_structure (res, new_structure);
683 gst_validate_pad_monitor_transform_caps (GstValidatePadMonitor * monitor,
691 GstCaps *template_caps;
695 GST_DEBUG_OBJECT (monitor, "Transform caps %" GST_PTR_FORMAT, caps);
700 othercaps = gst_caps_new_empty ();
703 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
705 iter = gst_pad_iterate_internal_links (pad);
708 GValue value = { 0, };
709 switch (gst_iterator_next (iter, &value)) {
710 case GST_ITERATOR_OK:
711 otherpad = g_value_get_object (&value);
712 template_caps = gst_pad_get_pad_template_caps (otherpad);
715 gst_validate_pad_monitor_copy_caps_fields_into_caps (monitor, caps,
717 if (!gst_caps_is_empty (new_caps))
718 gst_caps_append (othercaps, new_caps);
720 gst_caps_unref (new_caps);
722 gst_caps_unref (template_caps);
723 g_value_reset (&value);
725 case GST_ITERATOR_RESYNC:
726 gst_iterator_resync (iter);
727 gst_caps_unref (othercaps);
728 othercaps = gst_caps_new_empty ();
730 case GST_ITERATOR_ERROR:
731 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
734 case GST_ITERATOR_DONE:
739 gst_iterator_free (iter);
741 GST_DEBUG_OBJECT (pad, "Transformed caps: %" GST_PTR_FORMAT, othercaps);
742 gst_object_unref (pad);
748 gst_validate_pad_monitor_check_caps_fields_proxied (GstValidatePadMonitor *
749 monitor, GstCaps * caps, GstCaps * filter)
751 GstStructure *structure;
752 GstStructure *otherstructure;
754 GstCaps *otherfilter;
757 if (!gst_validate_pad_monitor_pad_should_proxy_othercaps (monitor))
760 otherfilter = gst_validate_pad_monitor_transform_caps (monitor, filter);
761 othercaps = gst_validate_pad_monitor_get_othercaps (monitor, otherfilter);
763 gst_caps_unref (otherfilter);
765 for (i = 0; i < gst_caps_get_size (othercaps); i++) {
766 gboolean found = FALSE;
767 gboolean type_match = FALSE;
769 otherstructure = gst_caps_get_structure (othercaps, i);
771 /* look for a proxied version of 'otherstructure' */
772 if (_structure_is_video (otherstructure)) {
773 for (j = 0; j < gst_caps_get_size (caps); j++) {
774 structure = gst_caps_get_structure (caps, j);
775 if (_structure_is_video (structure)) {
777 if (_structures_field_is_contained (structure, otherstructure, TRUE,
779 && _structures_field_is_contained (structure, otherstructure,
781 && _structures_field_is_contained (structure, otherstructure,
783 && _structures_field_is_contained (structure, otherstructure,
784 FALSE, "pixel-aspect-ratio")) {
790 } else if (_structure_is_audio (otherstructure)) {
791 for (j = 0; j < gst_caps_get_size (caps); j++) {
792 structure = gst_caps_get_structure (caps, j);
793 if (_structure_is_audio (structure)) {
795 if (_structures_field_is_contained (structure, otherstructure, TRUE,
797 && _structures_field_is_contained (structure, otherstructure,
806 if (type_match && !found) {
807 gchar *otherstruct_str = gst_structure_to_string (otherstructure),
808 *caps_str = gst_caps_to_string (caps);
810 GST_VALIDATE_REPORT (monitor, GET_CAPS_NOT_PROXYING_FIELDS,
811 "Peer pad structure '%s' has no similar version "
812 "on pad's caps '%s'", otherstruct_str, caps_str);
814 g_free (otherstruct_str);
819 gst_caps_unref (othercaps);
823 gst_validate_pad_monitor_check_late_serialized_events (GstValidatePadMonitor *
824 monitor, GstClockTime ts)
829 if (!GST_CLOCK_TIME_IS_VALID (ts))
833 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
836 GST_DEBUG_OBJECT (pad, "Timestamp to check %" GST_TIME_FORMAT,
839 for (i = 0; i < monitor->serialized_events->len; i++) {
840 SerializedEventData *data =
841 g_ptr_array_index (monitor->serialized_events, i);
843 GST_DEBUG_OBJECT (pad, "Event #%d (%s) ts: %" GST_TIME_FORMAT,
844 i, GST_EVENT_TYPE_NAME (data->event), GST_TIME_ARGS (data->timestamp));
846 if (GST_CLOCK_TIME_IS_VALID (data->timestamp) && data->timestamp < ts) {
847 gchar *event_str = _get_event_string (data->event);
849 GST_VALIDATE_REPORT (monitor, SERIALIZED_EVENT_WASNT_PUSHED_IN_TIME,
850 "Serialized event %s wasn't pushed before expected timestamp %"
851 GST_TIME_FORMAT " on pad %s:%s", event_str,
852 GST_TIME_ARGS (data->timestamp), GST_DEBUG_PAD_NAME (pad));
856 /* events should be ordered by ts */
862 debug_pending_event (pad, monitor->serialized_events);
863 g_ptr_array_remove_range (monitor->serialized_events, 0, i);
866 gst_object_unref (pad);
870 gst_validate_pad_monitor_dispose (GObject * object)
872 GstValidatePadMonitor *monitor = GST_VALIDATE_PAD_MONITOR_CAST (object);
874 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
878 if (monitor->pad_probe_id)
879 gst_pad_remove_probe (pad, monitor->pad_probe_id);
880 gst_object_unref (pad);
883 if (monitor->expected_segment)
884 gst_event_unref (monitor->expected_segment);
886 gst_structure_free (monitor->pending_setcaps_fields);
887 g_ptr_array_unref (monitor->serialized_events);
888 g_list_free_full (monitor->expired_events, (GDestroyNotify) gst_event_unref);
889 g_list_free_full (monitor->all_bufs, (GDestroyNotify) gst_buffer_unref);
890 gst_caps_replace (&monitor->last_caps, NULL);
891 gst_caps_replace (&monitor->last_query_res, NULL);
892 gst_caps_replace (&monitor->last_query_filter, NULL);
894 G_OBJECT_CLASS (parent_class)->dispose (object);
898 gst_validate_pad_monitor_class_init (GstValidatePadMonitorClass * klass)
900 GObjectClass *gobject_class;
901 GstValidateMonitorClass *monitor_klass;
903 gobject_class = G_OBJECT_CLASS (klass);
904 monitor_klass = GST_VALIDATE_MONITOR_CLASS (klass);
906 gobject_class->dispose = gst_validate_pad_monitor_dispose;
908 monitor_klass->setup = gst_validate_pad_monitor_do_setup;
909 monitor_klass->get_element = gst_validate_pad_monitor_get_element;
912 /* Called when a pad is being flushed */
914 gst_validate_pad_monitor_flush (GstValidatePadMonitor * pad_monitor)
916 /* Note: Keep in the same order as in the GstValidatePadMonitor structure */
918 gst_caps_replace (&pad_monitor->last_caps, NULL);
919 pad_monitor->caps_is_audio = pad_monitor->caps_is_video =
920 pad_monitor->caps_is_raw = FALSE;
922 pad_monitor->first_buffer = TRUE;
924 pad_monitor->has_segment = FALSE;
925 pad_monitor->is_eos = FALSE;
927 pad_monitor->pending_buffer_discont = TRUE;
929 gst_event_replace (&pad_monitor->expected_segment, NULL);
930 if (pad_monitor->serialized_events->len)
931 g_ptr_array_remove_range (pad_monitor->serialized_events, 0,
932 pad_monitor->serialized_events->len);
933 g_list_free_full (pad_monitor->expired_events,
934 (GDestroyNotify) gst_event_unref);
935 pad_monitor->expired_events = NULL;
937 gst_segment_init (&pad_monitor->segment, GST_FORMAT_BYTES);
938 pad_monitor->current_timestamp = GST_CLOCK_TIME_NONE;
939 pad_monitor->current_duration = GST_CLOCK_TIME_NONE;
941 pad_monitor->last_flow_return = GST_FLOW_OK;
943 pad_monitor->timestamp_range_start = GST_CLOCK_TIME_NONE;
944 pad_monitor->timestamp_range_end = GST_CLOCK_TIME_NONE;
947 /* Called when the pad monitor is initialized or when
948 * the pad is deactivated */
950 gst_validate_pad_monitor_reset (GstValidatePadMonitor * pad_monitor)
952 gst_validate_pad_monitor_flush (pad_monitor);
954 /* Note : For the entries that haven't been resetted in _flush(), do
955 * it here and keep in the same order as the GstValidatePadMonitor
958 pad_monitor->pending_flush_stop = FALSE;
959 pad_monitor->pending_newsegment_seqnum = GST_SEQNUM_INVALID;
960 pad_monitor->pending_eos_seqnum = GST_SEQNUM_INVALID;
962 pad_monitor->pending_seek_accurate_time = GST_CLOCK_TIME_NONE;
964 if (pad_monitor->pending_setcaps_fields)
965 gst_structure_free (pad_monitor->pending_setcaps_fields);
966 pad_monitor->pending_setcaps_fields =
967 gst_structure_new_empty (PENDING_FIELDS);
969 /* FIXME : Why BYTES and not UNDEFINED ? */
970 gst_segment_init (&pad_monitor->segment, GST_FORMAT_BYTES);
974 gst_validate_pad_monitor_init (GstValidatePadMonitor * pad_monitor)
976 pad_monitor->serialized_events =
977 g_ptr_array_new_with_free_func ((GDestroyNotify)
978 _serialized_event_data_free);
980 gst_validate_pad_monitor_reset (pad_monitor);
984 * gst_validate_pad_monitor_new:
985 * @pad: (transfer none): a #GstPad to run Validate on
987 GstValidatePadMonitor *
988 gst_validate_pad_monitor_new (GstPad * pad, GstValidateRunner * runner,
989 GstValidateElementMonitor * parent)
991 GstValidatePadMonitor *monitor = g_object_new (GST_TYPE_VALIDATE_PAD_MONITOR,
992 "object", pad, "validate-runner", runner, "validate-parent",
995 gst_validate_monitor_get_target (GST_VALIDATE_MONITOR (monitor));
997 if (target == NULL) {
998 g_object_unref (monitor);
1002 gst_object_unref (target);
1007 gst_validate_pad_monitor_get_element (GstValidateMonitor * monitor)
1010 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1012 GstElement *parent = GST_ELEMENT (gst_pad_get_parent (pad));
1014 gst_object_unref (pad);
1020 gst_validate_pad_monitor_event_overrides (GstValidatePadMonitor * pad_monitor,
1025 GST_VALIDATE_MONITOR_OVERRIDES_LOCK (pad_monitor);
1026 for (iter = GST_VALIDATE_MONITOR_OVERRIDES (pad_monitor).head; iter;
1027 iter = g_list_next (iter)) {
1028 GstValidateOverride *override = iter->data;
1030 gst_validate_override_event_handler (override,
1031 GST_VALIDATE_MONITOR_CAST (pad_monitor), event);
1033 GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (pad_monitor);
1037 gst_validate_pad_monitor_buffer_overrides (GstValidatePadMonitor * pad_monitor,
1042 GST_VALIDATE_MONITOR_OVERRIDES_LOCK (pad_monitor);
1043 for (iter = GST_VALIDATE_MONITOR_OVERRIDES (pad_monitor).head; iter;
1044 iter = g_list_next (iter)) {
1045 GstValidateOverride *override = iter->data;
1047 gst_validate_override_buffer_handler (override,
1048 GST_VALIDATE_MONITOR_CAST (pad_monitor), buffer);
1050 GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (pad_monitor);
1054 gst_validate_pad_monitor_buffer_probe_overrides (GstValidatePadMonitor *
1055 pad_monitor, GstBuffer * buffer)
1059 GST_VALIDATE_MONITOR_OVERRIDES_LOCK (pad_monitor);
1060 for (iter = GST_VALIDATE_MONITOR_OVERRIDES (pad_monitor).head; iter;
1061 iter = g_list_next (iter)) {
1062 GstValidateOverride *override = iter->data;
1064 gst_validate_override_buffer_probe_handler (override,
1065 GST_VALIDATE_MONITOR_CAST (pad_monitor), buffer);
1067 GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (pad_monitor);
1071 gst_validate_pad_monitor_query_overrides (GstValidatePadMonitor * pad_monitor,
1076 GST_VALIDATE_MONITOR_OVERRIDES_LOCK (pad_monitor);
1077 for (iter = GST_VALIDATE_MONITOR_OVERRIDES (pad_monitor).head; iter;
1078 iter = g_list_next (iter)) {
1079 GstValidateOverride *override = iter->data;
1081 gst_validate_override_query_handler (override,
1082 GST_VALIDATE_MONITOR_CAST (pad_monitor), query);
1084 GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (pad_monitor);
1088 gst_validate_pad_monitor_setcaps_overrides (GstValidatePadMonitor * pad_monitor,
1093 GST_VALIDATE_MONITOR_OVERRIDES_LOCK (pad_monitor);
1094 for (iter = GST_VALIDATE_MONITOR_OVERRIDES (pad_monitor).head; iter;
1095 iter = g_list_next (iter)) {
1096 GstValidateOverride *override = iter->data;
1098 gst_validate_override_setcaps_handler (override,
1099 GST_VALIDATE_MONITOR_CAST (pad_monitor), caps);
1101 GST_VALIDATE_MONITOR_OVERRIDES_UNLOCK (pad_monitor);
1104 /* FIXME : This is a bit dubious, what's the point of this check ? */
1106 gst_validate_pad_monitor_timestamp_is_in_received_range (GstValidatePadMonitor *
1107 monitor, GstClockTime ts, GstClockTime tolerance)
1110 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1113 GST_DEBUG_OBJECT (pad,
1114 "Checking if timestamp %" GST_TIME_FORMAT " is in range: %"
1115 GST_TIME_FORMAT " - %" GST_TIME_FORMAT " for pad "
1116 "%s:%s with tolerance: %" GST_TIME_FORMAT, GST_TIME_ARGS (ts),
1117 GST_TIME_ARGS (monitor->timestamp_range_start),
1118 GST_TIME_ARGS (monitor->timestamp_range_end), GST_DEBUG_PAD_NAME (pad),
1119 GST_TIME_ARGS (tolerance));
1120 gst_object_unref (pad);
1122 return !GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_start) ||
1123 !GST_CLOCK_TIME_IS_VALID (monitor->timestamp_range_end) ||
1124 ((monitor->timestamp_range_start >= tolerance ?
1125 monitor->timestamp_range_start - tolerance : 0) <= ts
1126 && (ts >= tolerance ? ts - tolerance : 0) <=
1127 monitor->timestamp_range_end);
1130 /* Iterates over internal links (sinkpads) to check that this buffer has
1131 * a timestamp that is in the range of the lastly received buffers */
1133 gst_validate_pad_monitor_check_buffer_timestamp_in_received_range
1134 (GstValidatePadMonitor * monitor, GstBuffer * buffer,
1135 GstClockTime tolerance)
1138 GstClockTime ts_end;
1140 gboolean has_one = FALSE;
1141 gboolean found = FALSE;
1144 GstValidatePadMonitor *othermonitor;
1146 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1149 if (!GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer))
1150 || !GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) {
1151 GST_DEBUG_OBJECT (pad,
1152 "Can't check buffer timestamps range as "
1153 "buffer has no valid timestamp/duration");
1157 ts = GST_BUFFER_TIMESTAMP (buffer);
1158 ts_end = ts + GST_BUFFER_DURATION (buffer);
1160 iter = gst_pad_iterate_internal_links (pad);
1163 GST_WARNING_OBJECT (pad, "No iterator available");
1169 GValue value = { 0, };
1170 switch (gst_iterator_next (iter, &value)) {
1171 case GST_ITERATOR_OK:
1172 otherpad = g_value_get_object (&value);
1173 GST_DEBUG_OBJECT (pad, "Checking pad %s:%s input timestamps",
1174 GST_DEBUG_PAD_NAME (otherpad));
1176 g_object_get_data ((GObject *) otherpad, "validate-monitor");
1177 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1178 if (gst_validate_pad_monitor_timestamp_is_in_received_range
1179 (othermonitor, ts, tolerance)
1181 gst_validate_pad_monitor_timestamp_is_in_received_range
1182 (othermonitor, ts_end, tolerance)) {
1186 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1187 g_value_reset (&value);
1190 case GST_ITERATOR_RESYNC:
1191 gst_iterator_resync (iter);
1195 case GST_ITERATOR_ERROR:
1196 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1199 case GST_ITERATOR_DONE:
1204 gst_iterator_free (iter);
1207 GST_DEBUG_OBJECT (pad, "Skipping timestamp in range check as no "
1208 "internal linked pad was found");
1212 GST_VALIDATE_REPORT (monitor, BUFFER_TIMESTAMP_OUT_OF_RECEIVED_RANGE,
1213 "Timestamp %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT
1214 " is out of range of received input", GST_TIME_ARGS (ts),
1215 GST_TIME_ARGS (ts_end));
1219 gst_object_unref (pad);
1223 gst_validate_pad_monitor_check_discont (GstValidatePadMonitor * pad_monitor,
1226 if (pad_monitor->pending_buffer_discont) {
1227 if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
1228 GST_VALIDATE_REPORT (pad_monitor, BUFFER_MISSING_DISCONT,
1229 "Buffer is missing a DISCONT flag");
1230 pad_monitor->pending_buffer_discont = FALSE;
1235 gst_validate_pad_monitor_check_first_buffer (GstValidatePadMonitor *
1236 pad_monitor, GstBuffer * buffer)
1239 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1242 if (G_UNLIKELY (pad_monitor->first_buffer)) {
1243 pad_monitor->first_buffer = FALSE;
1245 if (!pad_monitor->has_segment && PAD_IS_IN_PUSH_MODE (pad)) {
1246 GST_VALIDATE_REPORT (pad_monitor, BUFFER_BEFORE_SEGMENT,
1247 "Received buffer before Segment event");
1250 GST_DEBUG_OBJECT (pad,
1251 "Checking first buffer (pts:%" GST_TIME_FORMAT " dts:%" GST_TIME_FORMAT
1252 ")", GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
1253 GST_TIME_ARGS (GST_BUFFER_DTS (buffer)));
1257 gst_object_unref (pad);
1261 gst_validate_pad_monitor_check_eos (GstValidatePadMonitor *
1262 pad_monitor, GstBuffer * buffer)
1264 if (G_UNLIKELY (pad_monitor->is_eos)) {
1265 GST_VALIDATE_REPORT (pad_monitor, BUFFER_AFTER_EOS,
1266 "Received buffer %" GST_PTR_FORMAT " after EOS", buffer);
1271 gst_validate_pad_monitor_update_buffer_data (GstValidatePadMonitor *
1272 pad_monitor, GstBuffer * buffer)
1275 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1277 pad_monitor->current_timestamp = GST_BUFFER_TIMESTAMP (buffer);
1278 pad_monitor->current_duration = GST_BUFFER_DURATION (buffer);
1279 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer))) {
1280 if (GST_CLOCK_TIME_IS_VALID (pad_monitor->timestamp_range_start)) {
1281 pad_monitor->timestamp_range_start =
1282 MIN (pad_monitor->timestamp_range_start,
1283 GST_BUFFER_TIMESTAMP (buffer));
1285 pad_monitor->timestamp_range_start = GST_BUFFER_TIMESTAMP (buffer);
1288 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer))) {
1289 GstClockTime endts =
1290 GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer);
1291 if (GST_CLOCK_TIME_IS_VALID (pad_monitor->timestamp_range_end)) {
1292 pad_monitor->timestamp_range_end =
1293 MAX (pad_monitor->timestamp_range_end, endts);
1295 pad_monitor->timestamp_range_end = endts;
1299 GST_DEBUG_OBJECT (pad, "Current stored range: %" GST_TIME_FORMAT
1300 " - %" GST_TIME_FORMAT,
1301 GST_TIME_ARGS (pad_monitor->timestamp_range_start),
1302 GST_TIME_ARGS (pad_monitor->timestamp_range_end));
1304 gst_object_unref (pad);
1307 static GstFlowReturn
1308 _combine_flows (GstFlowReturn ret1, GstFlowReturn ret2)
1312 if (ret1 <= GST_FLOW_NOT_NEGOTIATED)
1314 if (ret2 <= GST_FLOW_NOT_NEGOTIATED)
1316 if (ret1 == GST_FLOW_FLUSHING || ret2 == GST_FLOW_FLUSHING)
1317 return GST_FLOW_FLUSHING;
1318 if (ret1 == GST_FLOW_OK || ret2 == GST_FLOW_OK)
1324 gst_validate_pad_monitor_check_aggregated_return (GstValidatePadMonitor *
1325 monitor, GstObject * parent, GstFlowReturn ret)
1331 GstValidatePadMonitor *othermonitor;
1332 GstFlowReturn aggregated = GST_FLOW_NOT_LINKED;
1333 gboolean found_a_pad = FALSE;
1335 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1338 iter = gst_pad_iterate_internal_links (pad);
1341 GValue value = { 0, };
1342 switch (gst_iterator_next (iter, &value)) {
1343 case GST_ITERATOR_OK:
1344 otherpad = g_value_get_object (&value);
1345 peerpad = gst_pad_get_peer (otherpad);
1348 g_object_get_data ((GObject *) peerpad, "validate-monitor");
1351 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1353 _combine_flows (aggregated, othermonitor->last_flow_return);
1354 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1357 gst_object_unref (peerpad);
1359 g_value_reset (&value);
1361 case GST_ITERATOR_RESYNC:
1362 gst_iterator_resync (iter);
1364 case GST_ITERATOR_ERROR:
1365 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1368 case GST_ITERATOR_DONE:
1373 gst_iterator_free (iter);
1375 /* no peer pad found, nothing to do */
1378 if (aggregated == GST_FLOW_OK || aggregated == GST_FLOW_EOS) {
1379 GstState state, pending;
1381 /* those are acceptable situations */
1382 if (GST_PAD_IS_FLUSHING (pad) && ret == GST_FLOW_FLUSHING) {
1383 /* pad is flushing, always acceptable to return flushing */
1387 gst_element_get_state (GST_ELEMENT (parent), &state, &pending, 0);
1388 if (ret == GST_FLOW_FLUSHING && (state < GST_STATE_PAUSED
1389 || pending < GST_STATE_PAUSED)) {
1390 /* Element is being teared down, accept FLOW_FLUSHING */
1395 if (monitor->is_eos && ret == GST_FLOW_EOS) {
1396 /* this element received eos and returned eos */
1400 if (PAD_PARENT_IS_DEMUXER (monitor) && ret == GST_FLOW_EOS) {
1401 /* a demuxer can return EOS when the samples end */
1406 if (aggregated != ret) {
1407 GST_VALIDATE_REPORT (monitor, WRONG_FLOW_RETURN,
1408 "Wrong combined flow return %s(%d). Expected: %s(%d)",
1409 gst_flow_get_name (ret), ret, gst_flow_get_name (aggregated),
1414 gst_object_unref (pad);
1418 gst_validate_pad_monitor_otherpad_add_pending_serialized_event
1419 (GstValidatePadMonitor * monitor, GstEvent * event, GstClockTime last_ts)
1424 GstValidatePadMonitor *othermonitor;
1428 if (!GST_EVENT_IS_SERIALIZED (event))
1432 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1434 iter = gst_pad_iterate_internal_links (pad);
1436 /* inputselector will return NULL if the sinkpad is not the active one .... */
1437 GST_FIXME_OBJECT (pad, "No iterator");
1438 gst_object_unref (pad);
1444 GValue value = { 0, };
1445 switch (gst_iterator_next (iter, &value)) {
1446 case GST_ITERATOR_OK:
1447 otherpad = g_value_get_object (&value);
1449 g_object_get_data ((GObject *) otherpad, "validate-monitor");
1451 SerializedEventData *data = g_slice_new0 (SerializedEventData);
1452 data->timestamp = last_ts;
1453 data->event = gst_event_ref (event);
1454 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1455 GST_DEBUG_OBJECT (pad, "Storing for pad %s:%s event %p %s",
1456 GST_DEBUG_PAD_NAME (otherpad), event,
1457 GST_EVENT_TYPE_NAME (event));
1458 g_ptr_array_add (othermonitor->serialized_events, data);
1459 debug_pending_event (otherpad, othermonitor->serialized_events);
1460 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1462 g_value_reset (&value);
1464 case GST_ITERATOR_RESYNC:
1465 gst_iterator_resync (iter);
1467 case GST_ITERATOR_ERROR:
1468 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1471 case GST_ITERATOR_DONE:
1476 gst_iterator_free (iter);
1477 gst_object_unref (pad);
1481 gst_validate_pad_monitor_otherpad_add_pending_field (GstValidatePadMonitor *
1482 monitor, GstStructure * structure, const gchar * field)
1487 GstValidatePadMonitor *othermonitor;
1491 v = gst_structure_get_value (structure, field);
1493 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1497 GST_DEBUG_OBJECT (pad, "Not adding pending field %s as it isn't "
1498 "present on structure %" GST_PTR_FORMAT, field, structure);
1499 gst_object_unref (pad);
1503 iter = gst_pad_iterate_internal_links (pad);
1506 GValue value = { 0, };
1507 switch (gst_iterator_next (iter, &value)) {
1508 case GST_ITERATOR_OK:
1509 otherpad = g_value_get_object (&value);
1511 g_object_get_data ((GObject *) otherpad, "validate-monitor");
1513 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1514 g_assert (othermonitor->pending_setcaps_fields != NULL);
1515 gst_structure_set_value (othermonitor->pending_setcaps_fields,
1517 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1519 g_value_reset (&value);
1521 case GST_ITERATOR_RESYNC:
1522 gst_iterator_resync (iter);
1524 case GST_ITERATOR_ERROR:
1525 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1528 case GST_ITERATOR_DONE:
1533 gst_iterator_free (iter);
1534 gst_object_unref (pad);
1538 gst_validate_pad_monitor_otherpad_clear_pending_fields (GstValidatePadMonitor *
1544 GstValidatePadMonitor *othermonitor;
1547 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1550 iter = gst_pad_iterate_internal_links (pad);
1552 gst_object_unref (pad);
1553 GST_DEBUG_OBJECT (monitor, "No internally linked pad");
1560 GValue value = { 0, };
1561 switch (gst_iterator_next (iter, &value)) {
1562 case GST_ITERATOR_OK:
1563 otherpad = g_value_get_object (&value);
1565 g_object_get_data ((GObject *) otherpad, "validate-monitor");
1567 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1568 g_assert (othermonitor->pending_setcaps_fields != NULL);
1569 gst_structure_free (othermonitor->pending_setcaps_fields);
1570 othermonitor->pending_setcaps_fields =
1571 gst_structure_new_empty (PENDING_FIELDS);
1572 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1574 g_value_reset (&value);
1576 case GST_ITERATOR_RESYNC:
1577 gst_iterator_resync (iter);
1579 case GST_ITERATOR_ERROR:
1580 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1583 case GST_ITERATOR_DONE:
1588 gst_object_unref (pad);
1589 gst_iterator_free (iter);
1593 gst_validate_pad_monitor_add_expected_newsegment (GstValidatePadMonitor *
1594 monitor, GstEvent * event)
1599 GstValidatePadMonitor *othermonitor;
1601 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1604 iter = gst_pad_iterate_internal_links (pad);
1606 GST_DEBUG_OBJECT (monitor, "No internally linked pad");
1607 gst_object_unref (pad);
1613 GValue value = { 0, };
1614 switch (gst_iterator_next (iter, &value)) {
1615 case GST_ITERATOR_OK:
1616 otherpad = g_value_get_object (&value);
1620 g_object_get_data ((GObject *) otherpad, "validate-monitor");
1621 GST_VALIDATE_MONITOR_LOCK (othermonitor);
1622 gst_event_replace (&othermonitor->expected_segment, event);
1623 GST_VALIDATE_MONITOR_UNLOCK (othermonitor);
1624 g_value_reset (&value);
1626 case GST_ITERATOR_RESYNC:
1627 gst_iterator_resync (iter);
1629 case GST_ITERATOR_ERROR:
1630 GST_WARNING_OBJECT (pad, "Internal links pad iteration error");
1633 case GST_ITERATOR_DONE:
1638 gst_iterator_free (iter);
1639 gst_object_unref (pad);
1642 /* common checks for both sink and src event functions */
1644 gst_validate_pad_monitor_common_event_check (GstValidatePadMonitor *
1645 pad_monitor, GstEvent * event)
1647 guint32 seqnum = gst_event_get_seqnum (event);
1649 if (seqnum == GST_SEQNUM_INVALID)
1650 GST_VALIDATE_REPORT (pad_monitor, EVENT_INVALID_SEQNUM,
1651 "Event %p (%s) has an invalid SEQNUM", event,
1652 GST_EVENT_TYPE_NAME (event));
1654 switch (GST_EVENT_TYPE (event)) {
1655 case GST_EVENT_FLUSH_START:
1657 if (pad_monitor->pending_flush_start_seqnum != GST_SEQNUM_INVALID) {
1658 if (seqnum == pad_monitor->pending_flush_start_seqnum) {
1659 pad_monitor->pending_flush_start_seqnum = GST_SEQNUM_INVALID;
1661 GST_VALIDATE_REPORT (pad_monitor, FLUSH_START_HAS_WRONG_SEQNUM,
1662 "Got: %u Expected: %u", seqnum,
1663 pad_monitor->pending_flush_start_seqnum);
1667 if (pad_monitor->pending_flush_stop) {
1668 GST_VALIDATE_REPORT (pad_monitor, EVENT_FLUSH_START_UNEXPECTED,
1669 "Received flush-start from when flush-stop was expected");
1671 pad_monitor->pending_flush_stop = TRUE;
1674 case GST_EVENT_FLUSH_STOP:
1676 if (pad_monitor->pending_flush_stop_seqnum != GST_SEQNUM_INVALID) {
1677 if (seqnum == pad_monitor->pending_flush_stop_seqnum) {
1678 pad_monitor->pending_flush_stop_seqnum = GST_SEQNUM_INVALID;
1680 GST_VALIDATE_REPORT (pad_monitor, FLUSH_STOP_HAS_WRONG_SEQNUM,
1681 "Got: %u Expected: %u", seqnum,
1682 pad_monitor->pending_flush_stop_seqnum);
1686 pad_monitor->pending_newsegment_seqnum = seqnum;
1687 pad_monitor->pending_eos_seqnum = seqnum;
1689 if (!pad_monitor->pending_flush_stop) {
1690 gchar *event_str = _get_event_string (event);
1692 GST_VALIDATE_REPORT (pad_monitor, EVENT_FLUSH_STOP_UNEXPECTED,
1693 "Unexpected flush-stop %s", event_str);
1696 pad_monitor->pending_flush_stop = FALSE;
1698 /* Buffers following a FLUSH should have the DISCONT flag set */
1699 pad_monitor->pending_buffer_discont = TRUE;
1701 /* cleanup our data */
1702 gst_validate_pad_monitor_flush (pad_monitor);
1711 mark_pads_eos (GstValidatePadMonitor * pad_monitor)
1713 GstValidatePadMonitor *peer_monitor;
1716 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1718 GstPad *peer = gst_pad_get_peer (pad);
1720 gst_object_unref (pad);
1721 pad_monitor->is_eos = TRUE;
1723 real_peer = _get_actual_pad (peer);
1725 g_object_get_data ((GObject *) real_peer, "validate-monitor");
1727 peer_monitor->is_eos = TRUE;
1728 gst_object_unref (peer);
1729 gst_object_unref (real_peer);
1733 static inline gboolean
1734 _should_check_buffers (GstValidatePadMonitor * pad_monitor,
1735 gboolean force_checks)
1738 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1740 GstValidateMonitor *monitor = GST_VALIDATE_MONITOR (pad_monitor);
1742 if (pad_monitor->first_buffer || force_checks) {
1743 if (pad_monitor->segment.rate != 1.0) {
1744 GST_INFO_OBJECT (pad_monitor, "We do not support buffer checking"
1745 " for trick modes");
1747 pad_monitor->check_buffers = FALSE;
1748 } else if (!PAD_PARENT_IS_DECODER (pad_monitor)) {
1749 GST_DEBUG_OBJECT (pad, "Not on a decoder => no buffer checking");
1751 pad_monitor->check_buffers = FALSE;
1752 } else if (GST_PAD_DIRECTION (pad) != GST_PAD_SINK) {
1753 GST_DEBUG_OBJECT (pad, "Not a sinkpad => no buffer checking");
1755 pad_monitor->check_buffers = FALSE;
1756 } else if (!pad_monitor->caps_is_video) {
1757 GST_DEBUG_OBJECT (pad, "Not working with video => no buffer checking");
1759 pad_monitor->check_buffers = FALSE;
1760 } else if (monitor->media_descriptor == NULL) {
1761 GST_DEBUG_OBJECT (pad, "No media_descriptor set => no buffer checking");
1763 pad_monitor->check_buffers = FALSE;
1765 if (!gst_validate_media_descriptor_detects_frames
1766 (monitor->media_descriptor)) {
1767 GST_DEBUG_OBJECT (pad,
1768 "No frame detection media descriptor => not buffer checking");
1769 pad_monitor->check_buffers = FALSE;
1770 } else if (pad_monitor->all_bufs == NULL &&
1771 !gst_validate_media_descriptor_get_buffers (monitor->media_descriptor,
1772 pad, NULL, &pad_monitor->all_bufs)) {
1774 GST_INFO_OBJECT (monitor,
1775 "The MediaInfo is marked as detecting frame, but getting frames"
1776 " from pad %" GST_PTR_FORMAT " did not work (some format conversion"
1777 " might be happening)", pad);
1779 pad_monitor->check_buffers = FALSE;
1781 if (!pad_monitor->current_buf)
1782 pad_monitor->current_buf = pad_monitor->all_bufs;
1783 pad_monitor->check_buffers = TRUE;
1786 gst_object_unref (pad);
1788 return pad_monitor->check_buffers;
1792 gst_validate_monitor_find_next_buffer (GstValidatePadMonitor * pad_monitor)
1795 gboolean passed_start = FALSE;
1797 if (!_should_check_buffers (pad_monitor, TRUE))
1800 for (tmp = g_list_last (pad_monitor->all_bufs); tmp; tmp = tmp->prev) {
1801 GstBuffer *cbuf = (GstBuffer *) tmp->data;
1803 GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (cbuf)) ? GST_BUFFER_DTS (cbuf)
1804 : GST_BUFFER_PTS (cbuf);
1806 if (!GST_CLOCK_TIME_IS_VALID (ts))
1809 if (ts <= pad_monitor->segment.start)
1810 passed_start = TRUE;
1815 if (!GST_BUFFER_FLAG_IS_SET (cbuf, GST_BUFFER_FLAG_DELTA_UNIT)) {
1821 pad_monitor->current_buf = pad_monitor->all_bufs;
1823 pad_monitor->current_buf = tmp;
1826 /* Checks whether a segment is just an update of another,
1827 * That is to say that only the base and offset field differ and all
1828 * other fields are identical */
1830 is_segment_update (GstSegment * a, const GstSegment * b)
1832 /* Note : We never care about the position field, it is only
1833 * used for internal usage by elements */
1834 if (a->rate == b->rate &&
1835 a->applied_rate == b->applied_rate &&
1836 a->format == b->format && a->time == b->time) {
1837 /* Changes in base/offset are considered updates */
1838 /* Updating the end position of a segment is an update */
1839 /* Updating the duration of a segment is an update */
1840 if (a->rate > 0.0) {
1841 if (a->start == b->start)
1844 if (a->stop == b->stop)
1851 static GstFlowReturn
1852 gst_validate_pad_monitor_downstream_event_check (GstValidatePadMonitor *
1853 pad_monitor, GstObject * parent, GstEvent * event,
1854 GstPadEventFunction handler)
1856 GstFlowReturn ret = GST_FLOW_OK;
1857 const GstSegment *segment;
1858 guint32 seqnum = gst_event_get_seqnum (event);
1860 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
1863 gst_validate_pad_monitor_common_event_check (pad_monitor, event);
1866 switch (GST_EVENT_TYPE (event)) {
1867 case GST_EVENT_STREAM_START:
1868 /* Buffers following a STREAM_START should have the DISCONT flag set */
1869 pad_monitor->pending_buffer_discont = TRUE;
1871 case GST_EVENT_SEGMENT:
1872 /* parse segment data to be used if event is handled */
1873 gst_event_parse_segment (event, &segment);
1875 GST_DEBUG_OBJECT (pad, "Got segment %" GST_SEGMENT_FORMAT, segment);
1877 /* Reset expected flush start/stop values, we have a segment */
1878 pad_monitor->pending_flush_start_seqnum = GST_SEQNUM_INVALID;
1879 pad_monitor->pending_flush_stop_seqnum = GST_SEQNUM_INVALID;
1881 if (pad_monitor->pending_newsegment_seqnum != GST_SEQNUM_INVALID) {
1882 if (pad_monitor->pending_newsegment_seqnum == seqnum) {
1883 pad_monitor->pending_newsegment_seqnum = GST_SEQNUM_INVALID;
1884 if (GST_CLOCK_TIME_IS_VALID (pad_monitor->pending_seek_accurate_time)) {
1885 if (segment->time == pad_monitor->pending_seek_accurate_time) {
1886 pad_monitor->pending_seek_accurate_time = GST_CLOCK_TIME_NONE;
1888 GST_VALIDATE_REPORT (pad_monitor, SEGMENT_HAS_WRONG_START,
1889 "After an accurate seek, got: %" GST_TIME_FORMAT
1890 " Expected: %" GST_TIME_FORMAT, GST_TIME_ARGS (segment->time),
1891 GST_TIME_ARGS (pad_monitor->pending_seek_accurate_time));
1895 GST_VALIDATE_REPORT (pad_monitor, SEGMENT_HAS_WRONG_SEQNUM,
1896 "Got: %u Expected: %u", seqnum, pad_monitor->pending_eos_seqnum);
1900 pad_monitor->pending_eos_seqnum = seqnum;
1902 if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) {
1903 gst_validate_pad_monitor_add_expected_newsegment (pad_monitor, event);
1905 /* check if this segment is the expected one */
1906 if (pad_monitor->expected_segment) {
1907 const GstSegment *exp_segment;
1909 if (pad_monitor->expected_segment != event) {
1910 gst_event_parse_segment (pad_monitor->expected_segment,
1912 if (segment->format == exp_segment->format) {
1913 if ((exp_segment->rate * exp_segment->applied_rate !=
1914 segment->rate * segment->applied_rate))
1915 GST_VALIDATE_REPORT (pad_monitor, EVENT_NEW_SEGMENT_MISMATCH,
1916 "Rate * applied_rate %f != expected %f",
1917 segment->rate * segment->applied_rate,
1918 exp_segment->rate * exp_segment->applied_rate);
1919 if (exp_segment->start != segment->start)
1920 GST_VALIDATE_REPORT (pad_monitor, EVENT_NEW_SEGMENT_MISMATCH,
1921 "Start %" GST_TIME_FORMAT " != expected %" GST_TIME_FORMAT,
1922 GST_TIME_ARGS (segment->start),
1923 GST_TIME_ARGS (exp_segment->start));
1924 if (exp_segment->stop != segment->stop)
1925 GST_VALIDATE_REPORT (pad_monitor, EVENT_NEW_SEGMENT_MISMATCH,
1926 "Stop %" GST_TIME_FORMAT " != expected %" GST_TIME_FORMAT,
1927 GST_TIME_ARGS (segment->stop),
1928 GST_TIME_ARGS (exp_segment->stop));
1929 if (exp_segment->position != segment->position)
1930 GST_VALIDATE_REPORT (pad_monitor, EVENT_NEW_SEGMENT_MISMATCH,
1931 "Position %" GST_TIME_FORMAT " != expected %"
1932 GST_TIME_FORMAT, GST_TIME_ARGS (segment->position),
1933 GST_TIME_ARGS (exp_segment->position));
1936 gst_event_replace (&pad_monitor->expected_segment, NULL);
1940 case GST_EVENT_CAPS:{
1943 gst_event_parse_caps (event, &caps);
1944 gst_validate_pad_monitor_setcaps_pre (pad_monitor, caps);
1948 pad_monitor->is_eos = TRUE;
1949 /* FIXME : This feels and looks wrong ... */
1950 if (pad_monitor->pending_eos_seqnum == GST_SEQNUM_INVALID) {
1951 GST_VALIDATE_REPORT (pad_monitor, EVENT_EOS_WITHOUT_SEGMENT,
1952 "EOS %" GST_PTR_FORMAT " received before a segment was received",
1954 } else if (pad_monitor->pending_eos_seqnum != seqnum) {
1955 GST_VALIDATE_REPORT (pad_monitor, EOS_HAS_WRONG_SEQNUM,
1956 "Got: %u. Expected: %u", seqnum, pad_monitor->pending_eos_seqnum);
1960 * TODO add end of stream checks for
1961 * - events not pushed
1962 * - buffer data not pushed
1963 * - pending events not received
1967 /* both flushes are handled by the common event function */
1968 case GST_EVENT_FLUSH_START:
1969 case GST_EVENT_FLUSH_STOP:
1971 case GST_EVENT_SINK_MESSAGE:
1976 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
1977 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (pad_monitor);
1978 gst_validate_pad_monitor_event_overrides (pad_monitor, event);
1980 gst_event_ref (event);
1981 if (pad_monitor->event_full_func)
1982 ret = pad_monitor->event_full_func (pad, parent, event);
1983 else if (pad_monitor->event_func (pad, parent, event))
1986 ret = GST_FLOW_ERROR;
1988 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (pad_monitor);
1989 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
1992 switch (GST_EVENT_TYPE (event)) {
1993 case GST_EVENT_SEGMENT:
1994 if (ret == GST_FLOW_OK) {
1995 /* If the new segment is not an update of the previous one, then
1996 * the following buffer should have the DISCONT flag set */
1997 if (!is_segment_update (&pad_monitor->segment, segment))
1998 pad_monitor->pending_buffer_discont = TRUE;
1999 if (!pad_monitor->has_segment
2000 && pad_monitor->segment.format != segment->format) {
2001 gst_segment_init (&pad_monitor->segment, segment->format);
2003 gst_segment_copy_into (segment, &pad_monitor->segment);
2004 pad_monitor->has_segment = TRUE;
2005 gst_validate_monitor_find_next_buffer (pad_monitor);
2008 case GST_EVENT_CAPS:{
2011 gst_event_parse_caps (event, &caps);
2012 gst_validate_pad_monitor_setcaps_post (pad_monitor, caps,
2013 ret == GST_FLOW_OK);
2016 case GST_EVENT_FLUSH_START:
2017 case GST_EVENT_FLUSH_STOP:
2020 case GST_EVENT_SINK_MESSAGE:
2026 gst_event_unref (event);
2027 gst_object_unref (pad);
2032 gst_validate_pad_monitor_src_event_check (GstValidatePadMonitor * pad_monitor,
2033 GstObject * parent, GstEvent * event, GstPadEventFunction handler)
2035 gboolean ret = TRUE;
2039 GstSeekFlags seek_flags;
2040 GstSeekType start_type, stop_type;
2041 guint32 seqnum = gst_event_get_seqnum (event);
2043 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
2046 gst_validate_pad_monitor_common_event_check (pad_monitor, event);
2049 switch (GST_EVENT_TYPE (event)) {
2050 case GST_EVENT_SEEK:
2052 gst_event_parse_seek (event, &rate, &format, &seek_flags, &start_type,
2053 &start, &stop_type, &stop);
2054 /* upstream seek - store the seek event seqnum to check
2055 * flushes and newsegments share the same */
2058 /* both flushes are handled by the common event handling function */
2059 case GST_EVENT_FLUSH_START:
2060 case GST_EVENT_FLUSH_STOP:
2061 case GST_EVENT_NAVIGATION:
2062 case GST_EVENT_LATENCY:
2063 case GST_EVENT_STEP:
2070 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2071 /* Safely store pending accurate seek values */
2072 if (GST_EVENT_TYPE (event) == GST_EVENT_SEEK) {
2073 if (seek_flags & GST_SEEK_FLAG_ACCURATE) {
2074 GST_DEBUG_OBJECT (pad,
2075 "Storing expected accurate seek time %" GST_TIME_FORMAT,
2076 GST_TIME_ARGS (start));
2077 pad_monitor->pending_seek_accurate_time = start;
2079 /* TODO we might need to use a list as multiple seeks can be sent
2080 * before the flushes arrive here */
2081 if (seek_flags & GST_SEEK_FLAG_FLUSH) {
2082 pad_monitor->pending_flush_start_seqnum = seqnum;
2083 pad_monitor->pending_flush_stop_seqnum = seqnum;
2087 gst_event_ref (event);
2088 ret = pad_monitor->event_func (pad, parent, event);
2090 if (GST_EVENT_TYPE (event) == GST_EVENT_SEEK) {
2091 /* If the seek was already handled (same current seqnum), reset the
2092 * expected accurate seek value */
2093 if (ret && pad_monitor->has_segment
2094 && seqnum == pad_monitor->pending_eos_seqnum) {
2095 GST_DEBUG_OBJECT (pad,
2096 "Resetting expected accurate seek value, was already handled");
2097 pad_monitor->pending_seek_accurate_time = GST_CLOCK_TIME_NONE;
2099 /* do not expect any of these events anymore */
2100 pad_monitor->pending_flush_start_seqnum = GST_SEQNUM_INVALID;
2101 pad_monitor->pending_flush_stop_seqnum = GST_SEQNUM_INVALID;
2102 pad_monitor->pending_newsegment_seqnum = GST_SEQNUM_INVALID;
2103 pad_monitor->pending_eos_seqnum = GST_SEQNUM_INVALID;
2104 pad_monitor->pending_seek_accurate_time = GST_CLOCK_TIME_NONE;
2107 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2111 switch (GST_EVENT_TYPE (event)) {
2112 case GST_EVENT_FLUSH_START:
2113 case GST_EVENT_FLUSH_STOP:
2115 case GST_EVENT_SEEK:
2116 case GST_EVENT_NAVIGATION:
2117 case GST_EVENT_LATENCY:
2118 case GST_EVENT_STEP:
2124 gst_event_unref (event);
2125 gst_object_unref (pad);
2130 gst_validate_pad_monitor_check_right_buffer (GstValidatePadMonitor *
2131 pad_monitor, GstBuffer * buffer)
2134 GstBuffer *wanted_buf;
2135 GstMapInfo map, wanted_map;
2137 gboolean ret = TRUE;
2141 if (_should_check_buffers (pad_monitor, FALSE) == FALSE)
2145 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
2147 if (pad_monitor->current_buf == NULL) {
2148 GST_INFO_OBJECT (pad, "No current buffer one pad, Why?");
2149 gst_object_unref (pad);
2153 wanted_buf = pad_monitor->current_buf->data;
2155 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (wanted_buf)) &&
2156 GST_CLOCK_TIME_IS_VALID (GST_BUFFER_PTS (buffer)) &&
2157 GST_BUFFER_PTS (wanted_buf) != GST_BUFFER_PTS (buffer)) {
2159 GST_VALIDATE_REPORT (pad_monitor, WRONG_BUFFER,
2160 "buffer %" GST_PTR_FORMAT " PTS %" GST_TIME_FORMAT
2161 " different than expected: %" GST_TIME_FORMAT, buffer,
2162 GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
2163 GST_TIME_ARGS (GST_BUFFER_PTS (wanted_buf)));
2168 if (GST_BUFFER_DTS (wanted_buf) != GST_BUFFER_DTS (buffer)) {
2169 GST_VALIDATE_REPORT (pad_monitor, WRONG_BUFFER,
2170 "buffer %" GST_PTR_FORMAT " DTS %" GST_TIME_FORMAT
2171 " different than expected: %" GST_TIME_FORMAT, buffer,
2172 GST_TIME_ARGS (GST_BUFFER_DTS (buffer)),
2173 GST_TIME_ARGS (GST_BUFFER_DTS (wanted_buf)));
2177 if (GST_BUFFER_DURATION (wanted_buf) != GST_BUFFER_DURATION (buffer)) {
2178 GST_VALIDATE_REPORT (pad_monitor, WRONG_BUFFER,
2179 "buffer %" GST_PTR_FORMAT " DURATION %" GST_TIME_FORMAT
2180 " different than expected: %" GST_TIME_FORMAT, buffer,
2181 GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
2182 GST_TIME_ARGS (GST_BUFFER_DURATION (wanted_buf)));
2186 if (GST_BUFFER_FLAG_IS_SET (wanted_buf, GST_BUFFER_FLAG_DELTA_UNIT) !=
2187 GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
2188 GST_VALIDATE_REPORT (pad_monitor, WRONG_BUFFER,
2189 "buffer %" GST_PTR_FORMAT " Delta unit is set to %s but expected %s",
2190 buffer, GST_BUFFER_FLAG_IS_SET (buffer,
2191 GST_BUFFER_FLAG_DELTA_UNIT) ? "True" : "False",
2192 GST_BUFFER_FLAG_IS_SET (wanted_buf,
2193 GST_BUFFER_FLAG_DELTA_UNIT) ? "True" : "False");
2197 g_assert (gst_buffer_map (wanted_buf, &wanted_map, GST_MAP_READ));
2198 g_assert (gst_buffer_map (buffer, &map, GST_MAP_READ));
2200 checksum = g_compute_checksum_for_data (G_CHECKSUM_MD5,
2201 (const guchar *) map.data, map.size);
2203 if (g_strcmp0 ((gchar *) wanted_map.data, checksum)) {
2204 GST_VALIDATE_REPORT (pad_monitor, WRONG_BUFFER,
2205 "buffer %" GST_PTR_FORMAT " checksum %s different from expected: %s",
2206 buffer, checksum, wanted_map.data);
2210 gst_buffer_unmap (wanted_buf, &wanted_map);
2211 gst_buffer_unmap (buffer, &map);
2213 gst_object_unref (pad);
2215 pad_monitor->current_buf = pad_monitor->current_buf->next;
2221 gst_validate_pad_monitor_check_return (GstValidatePadMonitor * pad_monitor,
2224 GstValidateMonitor *parent = GST_VALIDATE_MONITOR (pad_monitor);
2226 if (ret != GST_FLOW_ERROR)
2229 while (GST_VALIDATE_MONITOR_GET_PARENT (parent))
2230 parent = GST_VALIDATE_MONITOR_GET_PARENT (parent);
2232 if (GST_IS_VALIDATE_PIPELINE_MONITOR (parent)) {
2233 GstValidatePipelineMonitor *m = GST_VALIDATE_PIPELINE_MONITOR (parent);
2235 GST_VALIDATE_MONITOR_LOCK (m);
2236 if (m->got_error == FALSE) {
2237 GST_VALIDATE_REPORT (pad_monitor, FLOW_ERROR_WITHOUT_ERROR_MESSAGE,
2238 "Pad return GST_FLOW_ERROR but no GST_MESSAGE_ERROR was received on"
2241 /* Only report it the first time */
2242 m->got_error = TRUE;
2244 GST_VALIDATE_MONITOR_UNLOCK (m);
2248 static GstFlowReturn
2249 gst_validate_pad_monitor_chain_func (GstPad * pad, GstObject * parent,
2252 GstValidatePadMonitor *pad_monitor =
2253 g_object_get_data ((GObject *) pad, "validate-monitor");
2256 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (pad_monitor);
2257 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2259 gst_validate_pad_monitor_check_discont (pad_monitor, buffer);
2260 gst_validate_pad_monitor_check_right_buffer (pad_monitor, buffer);
2261 gst_validate_pad_monitor_check_first_buffer (pad_monitor, buffer);
2262 gst_validate_pad_monitor_update_buffer_data (pad_monitor, buffer);
2263 gst_validate_pad_monitor_check_eos (pad_monitor, buffer);
2265 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2266 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (pad_monitor);
2268 gst_validate_pad_monitor_buffer_overrides (pad_monitor, buffer);
2270 ret = pad_monitor->chain_func (pad, parent, buffer);
2272 gst_validate_pad_monitor_check_return (pad_monitor, ret);
2274 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (pad_monitor);
2275 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2277 pad_monitor->last_flow_return = ret;
2278 if (ret == GST_FLOW_EOS) {
2279 mark_pads_eos (pad_monitor);
2281 if (PAD_PARENT_IS_DEMUXER (pad_monitor))
2282 gst_validate_pad_monitor_check_aggregated_return (pad_monitor, parent, ret);
2284 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2285 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (pad_monitor);
2291 gst_validate_pad_monitor_event_is_tracked (GstValidatePadMonitor * monitor,
2294 if (!GST_EVENT_IS_SERIALIZED (event)) {
2298 /* we don't track Tag events because they mutate too much and it is hard
2299 * to match a tag event pushed on a source pad with the one that was received
2301 * One idea would be to use seqnum, but it seems that it is undefined whether
2302 * seqnums should be maintained in tag events that are created from others
2303 * up to today. (2013-08-29)
2305 if (GST_EVENT_TYPE (event) == GST_EVENT_TAG)
2311 static GstFlowReturn
2312 gst_validate_pad_monitor_sink_event_full_func (GstPad * pad, GstObject * parent,
2315 GstValidatePadMonitor *pad_monitor =
2316 g_object_get_data ((GObject *) pad, "validate-monitor");
2319 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (pad_monitor);
2320 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2322 if (gst_validate_pad_monitor_event_is_tracked (pad_monitor, event)) {
2323 GstClockTime last_ts = GST_CLOCK_TIME_NONE;
2324 if (GST_CLOCK_TIME_IS_VALID (pad_monitor->current_timestamp)) {
2325 last_ts = pad_monitor->current_timestamp;
2326 if (GST_CLOCK_TIME_IS_VALID (pad_monitor->current_duration)) {
2327 last_ts += pad_monitor->current_duration;
2330 gst_validate_pad_monitor_otherpad_add_pending_serialized_event (pad_monitor,
2335 gst_validate_pad_monitor_downstream_event_check (pad_monitor, parent,
2336 event, pad_monitor->event_func);
2338 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2339 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (pad_monitor);
2344 gst_validate_pad_monitor_sink_event_func (GstPad * pad, GstObject * parent,
2347 if (gst_validate_pad_monitor_sink_event_full_func (pad, parent,
2348 event) == GST_FLOW_OK)
2354 gst_validate_pad_monitor_src_event_func (GstPad * pad, GstObject * parent,
2357 GstValidatePadMonitor *pad_monitor =
2358 g_object_get_data ((GObject *) pad, "validate-monitor");
2361 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2362 ret = gst_validate_pad_monitor_src_event_check (pad_monitor, parent, event,
2363 pad_monitor->event_func);
2364 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2369 gst_validate_pad_monitor_query_func (GstPad * pad, GstObject * parent,
2372 GstValidatePadMonitor *pad_monitor =
2373 g_object_get_data ((GObject *) pad, "validate-monitor");
2376 gst_validate_pad_monitor_query_overrides (pad_monitor, query);
2377 ret = pad_monitor->query_func (pad, parent, query);
2380 switch (GST_QUERY_TYPE (query)) {
2381 case GST_QUERY_ACCEPT_CAPS:
2385 gst_caps_replace (&pad_monitor->last_refused_caps, NULL);
2386 gst_query_parse_accept_caps_result (query, &result);
2388 GstCaps *refused_caps;
2390 gst_query_parse_accept_caps (query, &refused_caps);
2391 pad_monitor->last_refused_caps = gst_caps_copy (refused_caps);
2397 case GST_QUERY_CAPS:{
2401 /* We shouldn't need to lock the parent as this doesn't modify
2402 * other monitors, just does some peer_pad_caps */
2403 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2405 gst_query_parse_caps (query, &filter);
2406 gst_query_parse_caps_result (query, &res);
2408 gst_caps_replace (&pad_monitor->last_query_res, NULL);
2409 gst_caps_replace (&pad_monitor->last_query_filter, NULL);
2410 pad_monitor->last_query_res =
2411 res ? gst_caps_copy (res) : gst_caps_ref (GST_CAPS_NONE);
2412 pad_monitor->last_query_filter =
2413 filter ? gst_caps_copy (filter) : gst_caps_ref (GST_CAPS_NONE);
2415 if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) {
2416 gst_validate_pad_monitor_check_caps_fields_proxied (pad_monitor, res,
2419 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2431 gst_validate_pad_monitor_activatemode_func (GstPad * pad, GstObject * parent,
2432 GstPadMode mode, gboolean active)
2434 GstValidatePadMonitor *pad_monitor =
2435 g_object_get_data ((GObject *) pad, "validate-monitor");
2436 gboolean ret = TRUE;
2438 /* TODO add overrides for activate func */
2439 GST_DEBUG_OBJECT (pad, "active:%d", active);
2441 if (pad_monitor->activatemode_func)
2442 ret = pad_monitor->activatemode_func (pad, parent, mode, active);
2443 if (ret && active == FALSE) {
2444 GST_VALIDATE_MONITOR_LOCK (pad_monitor);
2445 gst_validate_pad_monitor_reset (pad_monitor);
2446 GST_VALIDATE_MONITOR_UNLOCK (pad_monitor);
2452 static GstFlowReturn
2453 gst_validate_pad_get_range_func (GstPad * pad, GstObject * parent,
2454 guint64 offset, guint size, GstBuffer ** buffer)
2456 GstValidatePadMonitor *pad_monitor =
2457 g_object_get_data ((GObject *) pad, "validate-monitor");
2459 ret = pad_monitor->getrange_func (pad, parent, offset, size, buffer);
2464 gst_validate_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer,
2465 gpointer udata, gboolean pull_mode)
2467 GstValidatePadMonitor *monitor = udata;
2469 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (monitor);
2470 GST_VALIDATE_MONITOR_LOCK (monitor);
2473 gst_validate_pad_monitor_check_discont (monitor, buffer);
2474 gst_validate_pad_monitor_check_first_buffer (monitor, buffer);
2475 gst_validate_pad_monitor_update_buffer_data (monitor, buffer);
2476 gst_validate_pad_monitor_check_eos (monitor, buffer);
2478 if (PAD_PARENT_IS_DECODER (monitor) || PAD_PARENT_IS_ENCODER (monitor)) {
2479 GstClockTime tolerance = 0;
2481 if (monitor->caps_is_audio)
2482 tolerance = AUDIO_TIMESTAMP_TOLERANCE;
2484 gst_validate_pad_monitor_check_buffer_timestamp_in_received_range (monitor,
2488 gst_validate_pad_monitor_check_late_serialized_events (monitor,
2489 GST_BUFFER_TIMESTAMP (buffer));
2491 /* a GstValidatePadMonitor parent must be a GstValidateElementMonitor */
2492 if (PAD_PARENT_IS_DECODER (monitor)) {
2494 /* should not push out of segment data */
2495 if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)) &&
2496 GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)) &&
2497 ((!gst_segment_clip (&monitor->segment, monitor->segment.format,
2498 GST_BUFFER_TIMESTAMP (buffer),
2499 GST_BUFFER_TIMESTAMP (buffer) +
2500 GST_BUFFER_DURATION (buffer), NULL, NULL)) ||
2501 /* In the case of raw data, buffers should be strictly contained inside the
2503 (monitor->caps_is_raw &&
2504 GST_BUFFER_PTS (buffer) + GST_BUFFER_DURATION (buffer) <
2505 monitor->segment.start))
2507 /* TODO is this a timestamp issue? */
2508 GST_VALIDATE_REPORT (monitor, BUFFER_IS_OUT_OF_SEGMENT,
2509 "buffer is out of segment and shouldn't be pushed. Timestamp: %"
2510 GST_TIME_FORMAT " - Duration: %" GST_TIME_FORMAT ". Range: %"
2511 GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
2512 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
2513 GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
2514 GST_TIME_ARGS (monitor->segment.start),
2515 GST_TIME_ARGS (monitor->segment.stop));
2519 GST_VALIDATE_MONITOR_UNLOCK (monitor);
2520 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (monitor);
2521 gst_validate_pad_monitor_buffer_probe_overrides (monitor, buffer);
2526 gst_validate_pad_monitor_event_probe (GstPad * pad, GstEvent * event,
2529 GstValidatePadMonitor *monitor = GST_VALIDATE_PAD_MONITOR_CAST (udata);
2531 GST_VALIDATE_PAD_MONITOR_PARENT_LOCK (monitor);
2532 GST_VALIDATE_MONITOR_LOCK (monitor);
2534 GST_DEBUG_OBJECT (pad, "event %p %s", event, GST_EVENT_TYPE_NAME (event));
2536 if (GST_EVENT_IS_SERIALIZED (event)) {
2539 /* Detect if events the element received are being forwarded in the same order
2541 * Several scenarios:
2542 * 1) The element pushes the event as-is
2543 * 2) The element consumes the event and does not forward it
2544 * 3) The element consumes the event and creates another one instead
2545 * 4) The element pushes other serialized event before pushing out the
2548 * For each pad we have two lists to track serialized events:
2549 * 1) We received on input and expect to see (serialized_events)
2550 * 2) We received on input but don't expect to see (expired_events)
2552 * To detect events that are pushed in a different order from the one they were
2553 * received in we check that:
2555 * For each event being outputted:
2556 * If it is in the expired_events list:
2558 * If it is in the serialized_events list:
2559 * If there are other events that were received before:
2560 * Put those events on the expired_events list
2561 * Remove that event and any previous ones from the serialized_events list
2563 * Clear expired events list when flushing or on pad deactivation
2567 if (g_list_find (monitor->expired_events, event)) {
2568 gchar *event_str = _get_event_string (event);
2569 /* If it's the expired events, we've failed */
2570 GST_WARNING_OBJECT (pad, "Did not expect event %p %s", event,
2571 GST_EVENT_TYPE_NAME (event));
2572 GST_VALIDATE_REPORT (monitor, EVENT_SERIALIZED_OUT_OF_ORDER,
2573 "Serialized event was pushed out of order: %s", event_str);
2576 monitor->expired_events = g_list_remove (monitor->expired_events, event);
2577 gst_event_unref (event); /* remove the ref that was on the list */
2578 } else if (monitor->serialized_events->len) {
2579 for (i = 0; i < monitor->serialized_events->len; i++) {
2580 SerializedEventData *next_event =
2581 g_ptr_array_index (monitor->serialized_events, i);
2582 GST_DEBUG_OBJECT (pad, "Checking against stored event #%d: %p %s", i,
2583 next_event->event, GST_EVENT_TYPE_NAME (next_event->event));
2585 if (event == next_event->event
2586 || GST_EVENT_TYPE (event) == GST_EVENT_TYPE (next_event->event)) {
2587 /* We have found our event */
2588 GST_DEBUG_OBJECT (pad, "Found matching event");
2590 while (monitor->serialized_events->len > i
2591 && GST_EVENT_TYPE (event) == GST_EVENT_TYPE (next_event->event)) {
2592 /* Swallow all expected events of the same type */
2593 g_ptr_array_remove_index (monitor->serialized_events, i);
2594 next_event = g_ptr_array_index (monitor->serialized_events, i);
2597 /* Move all previous events to expired events */
2598 if (G_UNLIKELY (i > 0)) {
2599 GST_DEBUG_OBJECT (pad,
2600 "Moving previous expected events to expired list");
2602 next_event = g_ptr_array_index (monitor->serialized_events, 0);
2603 monitor->expired_events =
2604 g_list_append (monitor->expired_events,
2605 gst_event_ref (next_event->event));
2606 g_ptr_array_remove_index (monitor->serialized_events, 0);
2609 debug_pending_event (pad, monitor->serialized_events);
2616 /* This so far is just like an event that is flowing downstream,
2617 * so we do the same checks as a sinkpad event handler */
2618 gst_validate_pad_monitor_downstream_event_check (monitor, NULL, event, NULL);
2619 GST_VALIDATE_MONITOR_UNLOCK (monitor);
2620 GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (monitor);
2623 static GstPadProbeReturn
2624 gst_validate_pad_monitor_pad_probe (GstPad * pad, GstPadProbeInfo * info,
2627 if (info->type & GST_PAD_PROBE_TYPE_BUFFER)
2628 gst_validate_pad_monitor_buffer_probe (pad, info->data, udata,
2629 GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_PULL);
2630 else if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)
2631 gst_validate_pad_monitor_event_probe (pad, info->data, udata);
2633 return GST_PAD_PROBE_OK;
2637 gst_validate_pad_monitor_update_caps_info (GstValidatePadMonitor * pad_monitor,
2640 GstStructure *structure;
2642 g_return_if_fail (gst_caps_is_fixed (caps));
2644 pad_monitor->caps_is_audio = FALSE;
2645 pad_monitor->caps_is_video = FALSE;
2647 structure = gst_caps_get_structure (caps, 0);
2648 if (g_str_has_prefix (gst_structure_get_name (structure), "audio/")) {
2649 pad_monitor->caps_is_audio = TRUE;
2650 } else if (g_str_has_prefix (gst_structure_get_name (structure), "video/")) {
2651 pad_monitor->caps_is_video = TRUE;
2654 if (g_str_has_prefix (gst_structure_get_name (structure), "audio/x-raw") ||
2655 g_str_has_prefix (gst_structure_get_name (structure), "video/x-raw")) {
2656 pad_monitor->caps_is_raw = TRUE;
2658 pad_monitor->caps_is_raw = FALSE;
2663 gst_validate_pad_monitor_setcaps_pre (GstValidatePadMonitor * pad_monitor,
2666 GstStructure *structure;
2668 GST_PAD (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
2671 /* Check if caps are identical to last caps and complain if so
2672 * Only checked for sink pads as src pads might push the same caps
2673 * multiple times during unlinked/autoplugging scenarios */
2674 if (GST_PAD_IS_SINK (pad) && pad_monitor->last_caps
2675 && gst_caps_is_equal (caps, pad_monitor->last_caps)) {
2676 gchar *caps_str = gst_caps_to_string (caps);
2678 GST_VALIDATE_REPORT (pad_monitor, EVENT_CAPS_DUPLICATE, "%s", caps_str);
2683 gst_validate_pad_monitor_check_caps_complete (pad_monitor, caps);
2686 structure = gst_caps_get_structure (caps, 0);
2687 if (gst_structure_n_fields (pad_monitor->pending_setcaps_fields)) {
2690 i < gst_structure_n_fields (pad_monitor->pending_setcaps_fields);
2693 gst_structure_nth_field_name (pad_monitor->pending_setcaps_fields,
2695 const GValue *v = gst_structure_get_value (structure, name);
2696 const GValue *otherv =
2697 gst_structure_get_value (pad_monitor->pending_setcaps_fields, name);
2700 gchar *caps_str = gst_caps_to_string (caps);
2702 GST_VALIDATE_REPORT (pad_monitor, CAPS_EXPECTED_FIELD_NOT_FOUND,
2703 "Field %s is missing from setcaps caps '%s'", name, caps_str);
2705 } else if (gst_value_compare (v, otherv) != GST_VALUE_EQUAL) {
2706 gchar *caps_str = gst_caps_to_string (caps),
2707 *pending_setcaps_fields_str =
2708 gst_structure_to_string (pad_monitor->pending_setcaps_fields);
2711 GST_VALIDATE_REPORT (pad_monitor, CAPS_FIELD_UNEXPECTED_VALUE,
2712 "Field %s from setcaps caps '%s' is different "
2713 "from expected value in caps '%s'", name, caps_str,
2714 pending_setcaps_fields_str);
2716 g_free (pending_setcaps_fields_str);
2722 if (GST_PAD_IS_SINK (pad) &&
2723 gst_validate_pad_monitor_pad_should_proxy_othercaps (pad_monitor)) {
2724 if (_structure_is_video (structure)) {
2725 GST_DEBUG_OBJECT (pad,
2726 "Adding video common pending fields to other pad: %" GST_PTR_FORMAT,
2728 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2729 structure, "width");
2730 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2731 structure, "height");
2732 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2733 structure, "framerate");
2734 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2735 structure, "pixel-aspect-ratio");
2736 } else if (_structure_is_audio (structure)) {
2737 GST_DEBUG_OBJECT (pad,
2738 "Adding audio common pending fields to other pad: %" GST_PTR_FORMAT,
2740 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2742 gst_validate_pad_monitor_otherpad_add_pending_field (pad_monitor,
2743 structure, "channels");
2748 gst_structure_free (pad_monitor->pending_setcaps_fields);
2749 pad_monitor->pending_setcaps_fields =
2750 gst_structure_new_empty (PENDING_FIELDS);
2751 gst_object_unref (pad);
2753 gst_validate_pad_monitor_setcaps_overrides (pad_monitor, caps);
2757 gst_validate_pad_monitor_setcaps_post (GstValidatePadMonitor * pad_monitor,
2758 GstCaps * caps, gboolean ret)
2761 gst_validate_pad_monitor_otherpad_clear_pending_fields (pad_monitor);
2763 if (pad_monitor->last_caps) {
2764 gst_caps_unref (pad_monitor->last_caps);
2766 pad_monitor->last_caps = gst_caps_ref (caps);
2767 gst_validate_pad_monitor_update_caps_info (pad_monitor, caps);
2772 gst_validate_pad_monitor_do_setup (GstValidateMonitor * monitor)
2774 GstValidatePadMonitor *pad_monitor = GST_VALIDATE_PAD_MONITOR_CAST (monitor);
2775 GstPad *pad = (gpointer) gst_validate_monitor_get_target (monitor);
2777 if (!GST_IS_PAD (pad)) {
2778 GST_WARNING_OBJECT (monitor, "Trying to create pad monitor with other "
2780 gst_object_unref (pad);
2784 if (g_object_get_data ((GObject *) pad, "validate-monitor")) {
2785 GST_WARNING_OBJECT (pad_monitor,
2786 "Pad already has a validate-monitor associated");
2787 gst_object_unref (pad);
2791 g_object_set_data ((GObject *) pad, "validate-monitor", pad_monitor);
2793 pad_monitor->event_func = GST_PAD_EVENTFUNC (pad);
2794 pad_monitor->event_full_func = GST_PAD_EVENTFULLFUNC (pad);
2795 pad_monitor->query_func = GST_PAD_QUERYFUNC (pad);
2796 pad_monitor->activatemode_func = GST_PAD_ACTIVATEMODEFUNC (pad);
2797 if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) {
2799 pad_monitor->chain_func = GST_PAD_CHAINFUNC (pad);
2800 if (pad_monitor->chain_func)
2801 gst_pad_set_chain_function (pad, gst_validate_pad_monitor_chain_func);
2803 if (pad_monitor->event_full_func)
2804 gst_pad_set_event_full_function (pad,
2805 gst_validate_pad_monitor_sink_event_full_func);
2807 gst_pad_set_event_function (pad,
2808 gst_validate_pad_monitor_sink_event_func);
2810 pad_monitor->getrange_func = GST_PAD_GETRANGEFUNC (pad);
2811 if (pad_monitor->getrange_func)
2812 gst_pad_set_getrange_function (pad, gst_validate_pad_get_range_func);
2814 gst_pad_set_event_function (pad, gst_validate_pad_monitor_src_event_func);
2816 /* add buffer/event probes */
2817 pad_monitor->pad_probe_id =
2818 gst_pad_add_probe (pad,
2819 GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
2820 GST_PAD_PROBE_TYPE_EVENT_FLUSH,
2821 (GstPadProbeCallback) gst_validate_pad_monitor_pad_probe, pad_monitor,
2824 gst_pad_set_query_function (pad, gst_validate_pad_monitor_query_func);
2825 gst_pad_set_activatemode_function (pad,
2826 gst_validate_pad_monitor_activatemode_func);
2828 gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (monitor),
2829 g_strdup_printf ("%s:%s", GST_DEBUG_PAD_NAME (pad)));
2831 if (G_UNLIKELY (GST_PAD_PARENT (pad) == NULL))
2832 GST_FIXME ("Saw a pad not belonging to any object");
2834 gst_object_unref (pad);