validate: scenario: Cleanup the 'switch-track' action implementation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5803>
This commit is contained in:
Thibault Saunier 2023-12-12 10:43:34 -03:00 committed by GStreamer Marge Bot
parent fbf478b3f5
commit 6abc36ad34

View file

@ -1798,7 +1798,7 @@ execute_switch_track_default (GstValidateScenario * scenario,
gboolean relative = FALSE;
const gchar *type, *str_index;
GstElement *input_selector;
GstValidateExecuteActionReturn ret = GST_VALIDATE_EXECUTE_ACTION_ERROR;
GstValidateExecuteActionReturn res = GST_VALIDATE_EXECUTE_ACTION_OK;
DECLARE_AND_GET_PIPELINE (scenario, action);
@ -1807,11 +1807,11 @@ execute_switch_track_default (GstValidateScenario * scenario,
/* First find an input selector that has the right type */
input_selector = find_input_selector_with_type (GST_BIN (pipeline), type);
if (input_selector) {
REPORT_UNLESS (input_selector, done,
"Could not find input selector for type %s", type);
GstState state, next;
GstPad *pad, *cpad, *srcpad;
ret = GST_VALIDATE_EXECUTE_ACTION_OK;
str_index = gst_structure_get_string (action->structure, "index");
if (str_index == NULL) {
@ -1846,7 +1846,7 @@ execute_switch_track_default (GstValidateScenario * scenario,
gst_pad_add_probe (srcpad,
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
(GstPadProbeCallback) _check_select_pad_done, action, NULL);
ret = GST_VALIDATE_EXECUTE_ACTION_ASYNC;
res = GST_VALIDATE_EXECUTE_ACTION_ASYNC;
gst_object_unref (srcpad);
}
@ -1855,14 +1855,11 @@ execute_switch_track_default (GstValidateScenario * scenario,
gst_object_unref (cpad);
gst_object_unref (input_selector);
goto done;
}
/* No selector found -> Failed */
done:
gst_object_unref (pipeline);
return ret;
return res;
}
static GstPadProbeReturn
@ -1925,17 +1922,11 @@ execute_switch_track_pb (GstValidateScenario * scenario,
}
if (relative) { /* We are changing track relatively to current track */
if (n == 0) {
GST_VALIDATE_REPORT_ACTION (scenario, action,
SCENARIO_ACTION_EXECUTION_ERROR,
REPORT_UNLESS (n != 0, done,
"Trying to execute a relative %s for %s track when there"
" is no track of this type available on current stream.",
action->type, type);
res = GST_VALIDATE_EXECUTE_ACTION_ERROR;
goto done;
}
index = (current + index) % n;
}