static void _check_message_level (const gchar * factoryname, GstValidateReportLevel level, const gchar * message_id) { GList *reports; GstElement *element; GstValidateRunner *runner; GstValidateMonitor *monitor; element = gst_element_factory_make (factoryname, NULL); fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE)); runner = gst_validate_runner_new (); monitor = gst_validate_monitor_factory_create (GST_OBJECT (element), runner, NULL); GST_VALIDATE_REPORT (monitor, g_quark_from_string (message_id), "Just some fakery"); reports = gst_validate_runner_get_reports (runner); fail_unless_equals_int (g_list_length (reports), 1); fail_unless_equals_int (((GstValidateReport *) reports->data)->level, level); g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref); gst_object_unref (element); gst_object_unref (monitor); }
static void _test_flow_aggregation (GstFlowReturn flow, GstFlowReturn flow1, GstFlowReturn flow2, GstFlowReturn demux_flow, gboolean should_fail) { GstPad *srcpad; GstValidateReport *report; GstValidatePadMonitor *pmonitor, *pmonitor1, *pmonitor2; GstElement *demuxer = fake_demuxer_new (); GstBin *pipeline = GST_BIN (gst_pipeline_new ("validate-pipeline")); GList *reports; GstValidateRunner *runner; GstValidateMonitor *monitor; fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE)); runner = gst_validate_runner_new (); monitor = gst_validate_monitor_factory_create (GST_OBJECT (pipeline), runner, NULL); gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); gst_bin_add (pipeline, demuxer); fake_demuxer_prepare_pads (pipeline, demuxer, runner); srcpad = gst_pad_new ("srcpad1", GST_PAD_SRC); gst_pad_link (srcpad, demuxer->sinkpads->data); fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE)); gst_check_setup_events_with_stream_id (srcpad, demuxer, NULL, GST_FORMAT_TIME, "the-stream"); pmonitor = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->data)); pmonitor1 = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->next->data)); pmonitor2 = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->next->next->data)); pmonitor->last_flow_return = flow; pmonitor1->last_flow_return = flow1; pmonitor2->last_flow_return = flow2; FAKE_DEMUXER (demuxer)->return_value = demux_flow; fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_new ()), demux_flow); reports = gst_validate_runner_get_reports (runner); if (should_fail) { assert_equals_int (g_list_length (reports), 1); report = reports->data; fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_CRITICAL); fail_unless_equals_int (report->issue->issue_id, WRONG_FLOW_RETURN); } else { assert_equals_int (g_list_length (reports), 0); } g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref); clean_bus (GST_ELEMENT (pipeline)); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); ASSERT_OBJECT_REFCOUNT (pipeline, "ours", 1); check_destroyed (pipeline, demuxer, NULL); check_destroyed (monitor, pmonitor, NULL); }
gboolean ges_validate_activate (GstPipeline * pipeline, const gchar * scenario, gboolean * needs_setting_state) { GstValidateRunner *runner = NULL; GstValidateMonitor *monitor = NULL; ges_validate_register_action_types (); if (scenario) { if (g_strcmp0 (scenario, "none")) { gchar *scenario_name = g_strconcat (scenario, "->gespipeline*", NULL); g_setenv ("GST_VALIDATE_SCENARIO", scenario_name, TRUE); g_free (scenario_name); } } runner = gst_validate_runner_new (); g_signal_connect (runner, "report-added", G_CALLBACK (_validate_report_added_cb), pipeline); monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL); gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); g_object_get (monitor, "handles-states", needs_setting_state, NULL); *needs_setting_state = !*needs_setting_state; g_object_set_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE, monitor); g_object_set_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE, runner); return TRUE; }
static void do_element_new (GstValidateRunner * self, guint64 ts, GstElement * element) { element_created = TRUE; if (gst_validate_runner_should_monitor (self, element)) { /* the reference to the monitor is lost */ gst_validate_monitor_factory_create (GST_OBJECT_CAST (element), self, NULL); } }
static void gst_validate_bin_monitor_wrap_element (GstValidateBinMonitor * monitor, GstElement * element) { GstValidateElementMonitor *element_monitor; GST_DEBUG_OBJECT (monitor, "Wrapping element %s", GST_ELEMENT_NAME (element)); element_monitor = GST_VALIDATE_ELEMENT_MONITOR_CAST (gst_validate_monitor_factory_create (GST_OBJECT_CAST (element), GST_VALIDATE_MONITOR_GET_RUNNER (monitor), GST_VALIDATE_MONITOR_CAST (monitor))); g_return_if_fail (element_monitor != NULL); GST_VALIDATE_MONITOR_LOCK (monitor); monitor->element_monitors = g_list_prepend (monitor->element_monitors, element_monitor); GST_VALIDATE_MONITOR_UNLOCK (monitor); }
static void gst_validate_element_monitor_wrap_pad (GstValidateElementMonitor * monitor, GstPad * pad) { GstValidatePadMonitor *pad_monitor; GstValidateRunner *runner = gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (monitor)); GST_DEBUG_OBJECT (monitor, "Wrapping pad %s:%s", GST_DEBUG_PAD_NAME (pad)); pad_monitor = GST_VALIDATE_PAD_MONITOR (gst_validate_monitor_factory_create (GST_OBJECT (pad), runner, GST_VALIDATE_MONITOR (monitor))); g_return_if_fail (pad_monitor != NULL); GST_VALIDATE_MONITOR_LOCK (monitor); monitor->pad_monitors = g_list_prepend (monitor->pad_monitors, pad_monitor); GST_VALIDATE_MONITOR_UNLOCK (monitor); gst_object_unref (runner); }
static void _check_media_info (GstSegment * segment, BufferDesc * bufs) { GList *reports; GstEvent *segev; GstBuffer *buffer; GstElement *decoder; GstPad *srcpad, *sinkpad; GstValidateReport *report; GstValidateMonitor *monitor; GstValidateRunner *runner; GstMediaDescriptor *mdesc; GError *err = NULL; gint i, num_issues = 0; fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE)); runner = gst_validate_runner_new (); mdesc = (GstMediaDescriptor *) gst_media_descriptor_parser_new_from_xml (runner, media_info, &err); decoder = fake_decoder_new (); monitor = gst_validate_monitor_factory_create (GST_OBJECT (decoder), runner, NULL); gst_validate_monitor_set_media_descriptor (monitor, mdesc); srcpad = gst_pad_new ("src", GST_PAD_SRC); sinkpad = decoder->sinkpads->data; ASSERT_OBJECT_REFCOUNT (sinkpad, "decoder ref", 1); fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE)); fail_unless_equals_int (gst_element_set_state (decoder, GST_STATE_PLAYING), GST_STATE_CHANGE_SUCCESS); assert_equals_string (gst_pad_link_get_name (gst_pad_link (srcpad, sinkpad)), gst_pad_link_get_name (GST_PAD_LINK_OK)); gst_check_setup_events_with_stream_id (srcpad, decoder, gst_caps_from_string ("video/x-fake"), GST_FORMAT_TIME, "the-stream"); if (segment) { segev = gst_event_new_segment (segment); fail_unless (gst_pad_push_event (srcpad, segev)); } for (i = 0; bufs[i].content != NULL; i++) { BufferDesc *buf = &bufs[i]; buffer = _create_buffer (buf); assert_equals_string (gst_flow_get_name (gst_pad_push (srcpad, buffer)), gst_flow_get_name (GST_FLOW_OK)); reports = gst_validate_runner_get_reports (runner); num_issues += buf->num_issues; assert_equals_int (g_list_length (reports), num_issues); if (buf->num_issues) { GList *tmp = g_list_nth (reports, num_issues - buf->num_issues); while (tmp) { report = tmp->data; fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_WARNING); fail_unless_equals_int (report->issue->issue_id, WRONG_BUFFER); tmp = tmp->next; } } } /* clean up */ fail_unless (gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, FALSE)); fail_unless_equals_int (gst_element_set_state (decoder, GST_STATE_NULL), GST_STATE_CHANGE_SUCCESS); gst_object_unref (srcpad); check_destroyed (decoder, sinkpad, NULL); check_destroyed (runner, NULL, NULL); }
gboolean ges_validate_activate (GstPipeline * pipeline, const gchar * scenario, gboolean activate_before_paused) { GstValidateRunner *runner = NULL; GstValidateMonitor *monitor = NULL; const gchar *move_clip_mandatory_fields[] = { "clip-name", "position", NULL }; const gchar *set_child_property_mandatory_fields[] = { "element-name", "property", "value", NULL }; const gchar *serialize_project_mandatory_fields[] = { "uri", NULL }; const gchar *add_asset_mandatory_fields[] = { "id", "type", NULL }; const gchar *remove_asset_mandatory_fields[] = { "id", "type", NULL }; const gchar *add_layer_mandatory_fields[] = { "priority", NULL }; const gchar *remove_layer_mandatory_fields[] = { "priority", NULL }; const gchar *add_clip_mandatory_fields[] = { "name", "layer-priority", "asset-id", "type", NULL }; const gchar *remove_clip_mandatory_fields[] = { "name", NULL }; gst_validate_init (); if (scenario) { if (g_strcmp0 (scenario, "none")) { gchar *scenario_name = g_strconcat (scenario, "->gespipeline*", NULL); g_setenv ("GST_VALIDATE_SCENARIO", scenario_name, TRUE); g_free (scenario_name); } } gst_validate_add_action_type ("edit-clip", _edit_clip, move_clip_mandatory_fields, "Allows to seek into the files", FALSE); gst_validate_add_action_type ("add-asset", _add_asset, add_asset_mandatory_fields, "Allows to add an asset to the current project", FALSE); gst_validate_add_action_type ("remove-asset", _remove_asset, remove_asset_mandatory_fields, "Allows to remove an asset from the current project", FALSE); gst_validate_add_action_type ("add-layer", _add_layer, add_layer_mandatory_fields, "Allows to add a layer to the current timeline", FALSE); gst_validate_add_action_type ("remove-layer", _remove_layer, remove_layer_mandatory_fields, "Allows to remove a layer from the current timeline", FALSE); gst_validate_add_action_type ("add-clip", _add_clip, add_clip_mandatory_fields, "Allows to add a clip to a given layer", FALSE); gst_validate_add_action_type ("remove-clip", _remove_clip, remove_clip_mandatory_fields, "Allows to remove a clip from a given layer", FALSE); gst_validate_add_action_type ("serialize-project", _serialize_project, serialize_project_mandatory_fields, "serializes a project", FALSE); gst_validate_add_action_type ("set-child-property", _set_child_property, set_child_property_mandatory_fields, "Allows to change child property of an object", FALSE); runner = gst_validate_runner_new (); g_signal_connect (runner, "report-added", G_CALLBACK (_validate_report_added_cb), pipeline); monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL); g_object_set (monitor, "stateless", activate_before_paused, NULL); g_object_set_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE, monitor); g_object_set_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE, runner); return TRUE; }