validate: Add/fix various annotations

And fix monitor constructors to correctly check for valid arguments.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3194>
This commit is contained in:
Sebastian Dröge 2022-10-15 11:38:02 +03:00 committed by GStreamer Marge Bot
parent 533ea9bd7c
commit 3827f94574
8 changed files with 60 additions and 64 deletions

View file

@ -194,25 +194,18 @@ gst_validate_bin_monitor_init (GstValidateBinMonitor * bin_monitor)
* @runner: (transfer none): a #GstValidateRunner * @runner: (transfer none): a #GstValidateRunner
* @parent: (nullable): The parent of the new monitor * @parent: (nullable): The parent of the new monitor
* *
* Returns: (transfer full): A #GstValidateBinMonitor or NULL * Returns: (transfer full): A #GstValidateBinMonitor
*/ */
GstValidateBinMonitor * GstValidateBinMonitor *
gst_validate_bin_monitor_new (GstBin * bin, GstValidateRunner * runner, gst_validate_bin_monitor_new (GstBin * bin, GstValidateRunner * runner,
GstValidateMonitor * parent) GstValidateMonitor * parent)
{ {
GstValidateBinMonitor *monitor = g_return_val_if_fail (GST_IS_BIN (bin), NULL);
g_return_val_if_fail (runner != NULL, NULL);
return
g_object_new (GST_TYPE_VALIDATE_BIN_MONITOR, "object", g_object_new (GST_TYPE_VALIDATE_BIN_MONITOR, "object",
bin, "validate-runner", runner, "validate-parent", parent, NULL); bin, "validate-runner", runner, "validate-parent", parent, NULL);
GstObject *target =
gst_validate_monitor_get_target (GST_VALIDATE_MONITOR (monitor));
if (target == NULL) {
g_object_unref (monitor);
return NULL;
}
gst_object_unref (target);
return monitor;
} }
static void static void

View file

@ -155,31 +155,17 @@ gst_validate_element_monitor_init (GstValidateElementMonitor * element_monitor)
* @runner: (transfer none): a #GstValidateRunner * @runner: (transfer none): a #GstValidateRunner
* @parent: (nullable): The parent of the new monitor * @parent: (nullable): The parent of the new monitor
* *
* Returns: (transfer full): A #GstValidateElementMonitor or NULL * Returns: (transfer full): A #GstValidateElementMonitor
*/ */
GstValidateElementMonitor * GstValidateElementMonitor *
gst_validate_element_monitor_new (GstElement * element, gst_validate_element_monitor_new (GstElement * element,
GstValidateRunner * runner, GstValidateMonitor * parent) GstValidateRunner * runner, GstValidateMonitor * parent)
{ {
GstValidateElementMonitor *monitor; g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
GstElement *target; g_return_val_if_fail (runner != NULL, NULL);
g_return_val_if_fail (element != NULL, NULL); return g_object_new (GST_TYPE_VALIDATE_ELEMENT_MONITOR, "object", element,
monitor = g_object_new (GST_TYPE_VALIDATE_ELEMENT_MONITOR, "object", element,
"validate-runner", runner, "validate-parent", parent, NULL); "validate-runner", runner, "validate-parent", parent, NULL);
target =
GST_ELEMENT (gst_validate_monitor_get_target (GST_VALIDATE_MONITOR
(monitor)));
if (!target) {
g_object_unref (monitor);
return NULL;
}
gst_object_unref (target);
return monitor;
} }
static GstElement * static GstElement *

View file

@ -77,7 +77,7 @@ _get_reporting_level (GstValidateReporter * monitor)
* gst_validate_monitor_get_pipeline: * gst_validate_monitor_get_pipeline:
* @monitor: The monitor to get the pipeline from * @monitor: The monitor to get the pipeline from
* *
* Returns: (transfer full)(nullable): The pipeline in which @monitor * Returns: (transfer full) (nullable): The pipeline in which @monitor
* target is in. * target is in.
*/ */
GstPipeline * GstPipeline *
@ -90,7 +90,7 @@ gst_validate_monitor_get_pipeline (GstValidateMonitor * monitor)
* gst_validate_monitor_get_target: * gst_validate_monitor_get_target:
* @monitor: The monitor to get the target from * @monitor: The monitor to get the target from
* *
* Returns: (transfer full)(nullable): The target object * Returns: (transfer full) (nullable): The target object
*/ */
GstObject * GstObject *
gst_validate_monitor_get_target (GstValidateMonitor * monitor) gst_validate_monitor_get_target (GstValidateMonitor * monitor)
@ -317,7 +317,7 @@ gst_validate_monitor_setup (GstValidateMonitor * monitor)
* gst_validate_monitor_get_element * gst_validate_monitor_get_element
* @monitor: The monitor * @monitor: The monitor
* *
* Returns: (transfer none): The GstElement associated with @monitor * Returns: (transfer none) (nullable): The GstElement associated with @monitor
*/ */
GstElement * GstElement *
gst_validate_monitor_get_element (GstValidateMonitor * monitor) gst_validate_monitor_get_element (GstValidateMonitor * monitor)
@ -331,6 +331,12 @@ gst_validate_monitor_get_element (GstValidateMonitor * monitor)
return element; return element;
} }
/**
* gst_validate_monitor_get_element_name
* @monitor: The monitor
*
* Returns: (transfer full) (nullable): The name of the element associated with @monitor
*/
gchar * gchar *
gst_validate_monitor_get_element_name (GstValidateMonitor * monitor) gst_validate_monitor_get_element_name (GstValidateMonitor * monitor)
{ {

View file

@ -1041,25 +1041,18 @@ gst_validate_pad_monitor_init (GstValidatePadMonitor * pad_monitor)
* @runner: (transfer none): a #GstValidateRunner * @runner: (transfer none): a #GstValidateRunner
* @parent: (nullable): The parent of the new monitor * @parent: (nullable): The parent of the new monitor
* *
* Returns: (transfer full): A #GstValidatePadMonitor or NULL * Returns: (transfer full): A #GstValidatePadMonitor
*/ */
GstValidatePadMonitor * GstValidatePadMonitor *
gst_validate_pad_monitor_new (GstPad * pad, GstValidateRunner * runner, gst_validate_pad_monitor_new (GstPad * pad, GstValidateRunner * runner,
GstValidateElementMonitor * parent) GstValidateElementMonitor * parent)
{ {
GstValidatePadMonitor *monitor = g_object_new (GST_TYPE_VALIDATE_PAD_MONITOR, g_return_val_if_fail (GST_IS_PAD (pad), NULL);
g_return_val_if_fail (runner != NULL, NULL);
return g_object_new (GST_TYPE_VALIDATE_PAD_MONITOR,
"object", pad, "validate-runner", runner, "validate-parent", "object", pad, "validate-runner", runner, "validate-parent",
parent, NULL); parent, NULL);
GstObject *target =
gst_validate_monitor_get_target (GST_VALIDATE_MONITOR (monitor));
if (target == NULL) {
g_object_unref (monitor);
return NULL;
}
gst_object_unref (target);
return monitor;
} }
static GstElement * static GstElement *

View file

@ -826,24 +826,22 @@ done:
* @runner: (transfer none): a #GstValidateRunner * @runner: (transfer none): a #GstValidateRunner
* @parent: (nullable): The parent of the new monitor * @parent: (nullable): The parent of the new monitor
* *
* Returns: (transfer full): A #GstValidatePipelineMonitor or NULL * Returns: (transfer full): A #GstValidatePipelineMonitor
*/ */
GstValidatePipelineMonitor * GstValidatePipelineMonitor *
gst_validate_pipeline_monitor_new (GstPipeline * pipeline, gst_validate_pipeline_monitor_new (GstPipeline * pipeline,
GstValidateRunner * runner, GstValidateMonitor * parent) GstValidateRunner * runner, GstValidateMonitor * parent)
{ {
GstBus *bus; GstBus *bus;
GstValidatePipelineMonitor *monitor = GstValidatePipelineMonitor *monitor;
g_return_val_if_fail (GST_IS_PIPELINE (pipeline), NULL);
g_return_val_if_fail (runner != NULL, NULL);
monitor =
g_object_new (GST_TYPE_VALIDATE_PIPELINE_MONITOR, "object", g_object_new (GST_TYPE_VALIDATE_PIPELINE_MONITOR, "object",
pipeline, "validate-runner", runner, "validate-parent", parent, pipeline, "validate-runner", runner, "validate-parent", parent,
"pipeline", pipeline, NULL); "pipeline", pipeline, NULL);
GstObject *target =
gst_validate_monitor_get_target (GST_VALIDATE_MONITOR (monitor));
if (target == NULL) {
g_object_unref (monitor);
return NULL;
}
gst_validate_pipeline_monitor_create_scenarios (GST_VALIDATE_BIN_MONITOR gst_validate_pipeline_monitor_create_scenarios (GST_VALIDATE_BIN_MONITOR
(monitor)); (monitor));
@ -865,7 +863,6 @@ gst_validate_pipeline_monitor_new (GstPipeline * pipeline,
monitor->is_playbin = TRUE; monitor->is_playbin = TRUE;
else if (g_strcmp0 (G_OBJECT_TYPE_NAME (pipeline), "GstPlayBin3") == 0) else if (g_strcmp0 (G_OBJECT_TYPE_NAME (pipeline), "GstPlayBin3") == 0)
monitor->is_playbin3 = TRUE; monitor->is_playbin3 = TRUE;
gst_object_unref (target);
return monitor; return monitor;
} }

View file

@ -209,14 +209,14 @@ MAKE_GETTER_COPY (gchar *, reporter_name, g_strdup);
/** /**
* gst_validate_report_get_trace: * gst_validate_report_get_trace:
* *
* Returns: (transfer full): report backtrace * Returns: (transfer full) (nullable): report backtrace
* Since: 1.22 * Since: 1.22
*/ */
MAKE_GETTER_COPY (gchar *, trace, g_strdup); MAKE_GETTER_COPY (gchar *, trace, g_strdup);
/** /**
* gst_validate_report_get_dotfile_name: * gst_validate_report_get_dotfile_name:
* *
* Returns: (transfer full): report dot file name * Returns: (transfer full) (nullable): report dot file name
* Since: 1.22 * Since: 1.22
*/ */
MAKE_GETTER_COPY (gchar *, dotfile_name, g_strdup); MAKE_GETTER_COPY (gchar *, dotfile_name, g_strdup);
@ -744,6 +744,12 @@ gst_validate_report_deinit (void)
g_clear_object (&server_connection); g_clear_object (&server_connection);
} }
/**
* gst_validate_issue_from_id:
* @issue_id: The issue id
*
* Returns: (nullable): The issue if found or NULL otherwise
*/
GstValidateIssue * GstValidateIssue *
gst_validate_issue_from_id (GstValidateIssueId issue_id) gst_validate_issue_from_id (GstValidateIssueId issue_id)
{ {

View file

@ -139,7 +139,7 @@ gst_validate_reporter_get_reporting_level (GstValidateReporter * reporter)
* gst_validate_reporter_get_pipeline: * gst_validate_reporter_get_pipeline:
* @reporter: The reporter to get the pipeline from * @reporter: The reporter to get the pipeline from
* *
* Returns: (transfer full)(nullable): The #GstPipeline * Returns: (transfer full) (nullable): The #GstPipeline
*/ */
GstPipeline * GstPipeline *
gst_validate_reporter_get_pipeline (GstValidateReporter * reporter) gst_validate_reporter_get_pipeline (GstValidateReporter * reporter)
@ -153,6 +153,13 @@ gst_validate_reporter_get_pipeline (GstValidateReporter * reporter)
return NULL; return NULL;
} }
/**
* gst_validate_reporter_get_report:
* @reporter: The reporter to get the report from
* @issue_id: The issue id to get the report from
*
* Returns: (transfer none) (nullable): The #GstValidateReport
*/
GstValidateReport * GstValidateReport *
gst_validate_reporter_get_report (GstValidateReporter * reporter, gst_validate_reporter_get_report (GstValidateReporter * reporter,
GstValidateIssueId issue_id) GstValidateIssueId issue_id)
@ -410,9 +417,9 @@ gst_validate_reporter_report_simple (GstValidateReporter * reporter,
/** /**
* gst_validate_reporter_set_name: * gst_validate_reporter_set_name:
* @reporter: The reporter to set the name on * @reporter: The reporter to set the name on
* @name: (transfer full): The name of the reporter * @name: (transfer full) (nullable): The name of the reporter
* *
* Sets @ name on @reporter * Sets @name on @reporter
*/ */
void void
gst_validate_reporter_set_name (GstValidateReporter * reporter, gchar * name) gst_validate_reporter_set_name (GstValidateReporter * reporter, gchar * name)
@ -424,6 +431,14 @@ gst_validate_reporter_set_name (GstValidateReporter * reporter, gchar * name)
priv->name = name; priv->name = name;
} }
/**
* gst_validate_reporter_get_name:
* @reporter: The reporter to get the name from
*
* Gets @name of @reporter
*
* Returns: (transfer none) (nullable): The name of the reporter
*/
const gchar * const gchar *
gst_validate_reporter_get_name (GstValidateReporter * reporter) gst_validate_reporter_get_name (GstValidateReporter * reporter)
{ {
@ -436,7 +451,7 @@ gst_validate_reporter_get_name (GstValidateReporter * reporter)
* gst_validate_reporter_get_runner: * gst_validate_reporter_get_runner:
* @reporter: The reporter to get the runner from * @reporter: The reporter to get the runner from
* *
* Returns: (transfer full)(nullable): The runner * Returns: (transfer full) (nullable): The runner
*/ */
GstValidateRunner * GstValidateRunner *
gst_validate_reporter_get_runner (GstValidateReporter * reporter) gst_validate_reporter_get_runner (GstValidateReporter * reporter)

View file

@ -324,7 +324,7 @@ gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
* gst_validate_scenario_get_pipeline: * gst_validate_scenario_get_pipeline:
* @scenario: The scenario to retrieve a pipeline from * @scenario: The scenario to retrieve a pipeline from
* *
* Returns: (transfer full): The #GstPipeline the scenario is running * Returns: (transfer full) (nullable): The #GstPipeline the scenario is running
* against * against
*/ */
GstElement * GstElement *
@ -5378,7 +5378,7 @@ gst_validate_scenario_from_structs (GstValidateRunner * runner,
* @pipeline: The pipeline to run the scenario on * @pipeline: The pipeline to run the scenario on
* @scenario_name: The name (or path) of the scenario to run * @scenario_name: The name (or path) of the scenario to run
* *
* Returns: (transfer full): A #GstValidateScenario or NULL * Returns: (transfer full) (nullable): A #GstValidateScenario or NULL
*/ */
GstValidateScenario * GstValidateScenario *
gst_validate_scenario_factory_create (GstValidateRunner * gst_validate_scenario_factory_create (GstValidateRunner *
@ -6375,7 +6375,7 @@ gst_validate_action_set_done (GstValidateAction * action)
* *
* Retrieve the scenario from which @action is executed. * Retrieve the scenario from which @action is executed.
* *
* Returns: (transfer full): The scenario from which the action is being executed. * Returns: (transfer full) (nullable): The scenario from which the action is being executed.
*/ */
GstValidateScenario * GstValidateScenario *
gst_validate_action_get_scenario (GstValidateAction * action) gst_validate_action_get_scenario (GstValidateAction * action)