mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
validate: scenario: Cleanup the 'switch-track' action implementation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5803>
This commit is contained in:
parent
fbf478b3f5
commit
6abc36ad34
1 changed files with 49 additions and 58 deletions
|
@ -1798,7 +1798,7 @@ execute_switch_track_default (GstValidateScenario * scenario,
|
||||||
gboolean relative = FALSE;
|
gboolean relative = FALSE;
|
||||||
const gchar *type, *str_index;
|
const gchar *type, *str_index;
|
||||||
GstElement *input_selector;
|
GstElement *input_selector;
|
||||||
GstValidateExecuteActionReturn ret = GST_VALIDATE_EXECUTE_ACTION_ERROR;
|
GstValidateExecuteActionReturn res = GST_VALIDATE_EXECUTE_ACTION_OK;
|
||||||
|
|
||||||
DECLARE_AND_GET_PIPELINE (scenario, action);
|
DECLARE_AND_GET_PIPELINE (scenario, action);
|
||||||
|
|
||||||
|
@ -1807,62 +1807,59 @@ execute_switch_track_default (GstValidateScenario * scenario,
|
||||||
|
|
||||||
/* First find an input selector that has the right type */
|
/* First find an input selector that has the right type */
|
||||||
input_selector = find_input_selector_with_type (GST_BIN (pipeline), type);
|
input_selector = find_input_selector_with_type (GST_BIN (pipeline), type);
|
||||||
if (input_selector) {
|
REPORT_UNLESS (input_selector, done,
|
||||||
GstState state, next;
|
"Could not find input selector for type %s", type);
|
||||||
GstPad *pad, *cpad, *srcpad;
|
GstState state, next;
|
||||||
|
GstPad *pad, *cpad, *srcpad;
|
||||||
|
|
||||||
ret = GST_VALIDATE_EXECUTE_ACTION_OK;
|
str_index = gst_structure_get_string (action->structure, "index");
|
||||||
str_index = gst_structure_get_string (action->structure, "index");
|
|
||||||
|
|
||||||
if (str_index == NULL) {
|
if (str_index == NULL) {
|
||||||
if (!gst_structure_get_uint (action->structure, "index", &index)) {
|
if (!gst_structure_get_uint (action->structure, "index", &index)) {
|
||||||
GST_WARNING ("No index given, defaulting to +1");
|
GST_WARNING ("No index given, defaulting to +1");
|
||||||
index = 1;
|
index = 1;
|
||||||
relative = TRUE;
|
relative = TRUE;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
relative = strchr ("+-", str_index[0]) != NULL;
|
|
||||||
index = g_ascii_strtoll (str_index, NULL, 10);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (relative) { /* We are changing track relatively to current track */
|
relative = strchr ("+-", str_index[0]) != NULL;
|
||||||
int npads;
|
index = g_ascii_strtoll (str_index, NULL, 10);
|
||||||
|
|
||||||
g_object_get (input_selector, "active-pad", &pad, "n-pads", &npads, NULL);
|
|
||||||
if (pad) {
|
|
||||||
int current_index = find_sink_pad_index (input_selector, pad);
|
|
||||||
|
|
||||||
index = (current_index + index) % npads;
|
|
||||||
gst_object_unref (pad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pad = find_nth_sink_pad (input_selector, index);
|
|
||||||
g_object_get (input_selector, "active-pad", &cpad, NULL);
|
|
||||||
if (gst_element_get_state (pipeline, &state, &next, 0) &&
|
|
||||||
state == GST_STATE_PLAYING && next == GST_STATE_VOID_PENDING) {
|
|
||||||
srcpad = gst_element_get_static_pad (input_selector, "src");
|
|
||||||
|
|
||||||
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;
|
|
||||||
gst_object_unref (srcpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set (input_selector, "active-pad", pad, NULL);
|
|
||||||
gst_object_unref (pad);
|
|
||||||
gst_object_unref (cpad);
|
|
||||||
gst_object_unref (input_selector);
|
|
||||||
|
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (relative) { /* We are changing track relatively to current track */
|
||||||
|
int npads;
|
||||||
|
|
||||||
|
g_object_get (input_selector, "active-pad", &pad, "n-pads", &npads, NULL);
|
||||||
|
if (pad) {
|
||||||
|
int current_index = find_sink_pad_index (input_selector, pad);
|
||||||
|
|
||||||
|
index = (current_index + index) % npads;
|
||||||
|
gst_object_unref (pad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pad = find_nth_sink_pad (input_selector, index);
|
||||||
|
g_object_get (input_selector, "active-pad", &cpad, NULL);
|
||||||
|
if (gst_element_get_state (pipeline, &state, &next, 0) &&
|
||||||
|
state == GST_STATE_PLAYING && next == GST_STATE_VOID_PENDING) {
|
||||||
|
srcpad = gst_element_get_static_pad (input_selector, "src");
|
||||||
|
|
||||||
|
gst_pad_add_probe (srcpad,
|
||||||
|
GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST,
|
||||||
|
(GstPadProbeCallback) _check_select_pad_done, action, NULL);
|
||||||
|
res = GST_VALIDATE_EXECUTE_ACTION_ASYNC;
|
||||||
|
gst_object_unref (srcpad);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_set (input_selector, "active-pad", pad, NULL);
|
||||||
|
gst_object_unref (pad);
|
||||||
|
gst_object_unref (cpad);
|
||||||
|
gst_object_unref (input_selector);
|
||||||
|
|
||||||
/* No selector found -> Failed */
|
/* No selector found -> Failed */
|
||||||
done:
|
done:
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
return ret;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadProbeReturn
|
static GstPadProbeReturn
|
||||||
|
@ -1925,16 +1922,10 @@ execute_switch_track_pb (GstValidateScenario * scenario,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relative) { /* We are changing track relatively to current track */
|
if (relative) { /* We are changing track relatively to current track */
|
||||||
if (n == 0) {
|
REPORT_UNLESS (n != 0, done,
|
||||||
GST_VALIDATE_REPORT_ACTION (scenario, action,
|
"Trying to execute a relative %s for %s track when there"
|
||||||
SCENARIO_ACTION_EXECUTION_ERROR,
|
" is no track of this type available on current stream.",
|
||||||
"Trying to execute a relative %s for %s track when there"
|
action->type, type);
|
||||||
" 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;
|
index = (current + index) % n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue