mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
playback: Check type when setting "connection-speed" on unknown elements
Clamp the values if needed
This commit is contained in:
parent
ee4ae0041c
commit
445c41963b
2 changed files with 66 additions and 16 deletions
|
@ -1974,13 +1974,43 @@ connect_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad,
|
|||
|
||||
/* Set connection-speed property if needed */
|
||||
if (chain->demuxer == TRUE) {
|
||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
||||
"connection-speed")) {
|
||||
GST_DEBUG_OBJECT (dbin,
|
||||
"setting connection-speed=%d to demuxer element",
|
||||
dbin->connection_speed / 1000);
|
||||
g_object_set (element, "connection-speed",
|
||||
dbin->connection_speed / 1000, NULL);
|
||||
GParamSpec *pspec;
|
||||
|
||||
if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element),
|
||||
"connection-speed"))) {
|
||||
guint64 speed = dbin->connection_speed / 1000;
|
||||
gboolean wrong_type = FALSE;
|
||||
|
||||
if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_UINT) {
|
||||
GParamSpecUInt *pspecuint = G_PARAM_SPEC_UINT (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecuint->minimum, pspecuint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT) {
|
||||
GParamSpecInt *pspecint = G_PARAM_SPEC_INT (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecint->minimum, pspecint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_UINT64) {
|
||||
GParamSpecUInt64 *pspecuint = G_PARAM_SPEC_UINT64 (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecuint->minimum, pspecuint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT64) {
|
||||
GParamSpecInt64 *pspecint = G_PARAM_SPEC_INT (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecint->minimum, pspecint->maximum);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (dbin,
|
||||
"The connection speed property %i of type %s"
|
||||
" is not usefull not setting it", speed,
|
||||
g_type_name (G_PARAM_SPEC_TYPE (pspec)));
|
||||
wrong_type = TRUE;
|
||||
}
|
||||
|
||||
if (wrong_type == FALSE) {
|
||||
GST_DEBUG_OBJECT (dbin, "setting connection-speed=%d to demuxer"
|
||||
" element", speed);
|
||||
|
||||
g_object_set (element, "connection-speed", speed, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1246,17 +1246,37 @@ gen_source_element (GstURIDecodeBin * decoder)
|
|||
|
||||
pspec = g_object_class_find_property (source_class, "connection-speed");
|
||||
if (pspec != NULL) {
|
||||
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_UINT64 ||
|
||||
G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_INT64) {
|
||||
GST_DEBUG_OBJECT (decoder,
|
||||
"setting connection-speed=%" G_GUINT64_FORMAT " on source element %s",
|
||||
decoder->connection_speed / 1000, G_OBJECT_TYPE_NAME (source));
|
||||
guint64 speed = decoder->connection_speed / 1000;
|
||||
gboolean wrong_type = FALSE;
|
||||
|
||||
g_object_set (source, "connection-speed",
|
||||
decoder->connection_speed / 1000, NULL);
|
||||
if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_UINT) {
|
||||
GParamSpecUInt *pspecuint = G_PARAM_SPEC_UINT (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecuint->minimum, pspecuint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT) {
|
||||
GParamSpecInt *pspecint = G_PARAM_SPEC_INT (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecint->minimum, pspecint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_UINT64) {
|
||||
GParamSpecUInt64 *pspecuint = G_PARAM_SPEC_UINT64 (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecuint->minimum, pspecuint->maximum);
|
||||
} else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT64) {
|
||||
GParamSpecInt64 *pspecint = G_PARAM_SPEC_INT64 (pspec);
|
||||
|
||||
speed = CLAMP (speed, pspecint->minimum, pspecint->maximum);
|
||||
} else {
|
||||
g_warning ("connection-speed property of '%s' is not a 64-bit int type",
|
||||
G_OBJECT_TYPE_NAME (source));
|
||||
GST_WARNING_OBJECT (decoder, "The connection speed property %i of type %s"
|
||||
" is not usefull not setting it", speed,
|
||||
g_type_name (G_PARAM_SPEC_TYPE (pspec)));
|
||||
wrong_type = TRUE;
|
||||
}
|
||||
|
||||
if (wrong_type == FALSE) {
|
||||
g_object_set (source, "connection-speed", speed, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (decoder,
|
||||
"setting connection-speed=%d to source element", speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue