encoding-profile: Handle escaped '\:' in caps describing profiles
Otherwise it won't be possible to specify some profiles such as video/x-h264,profile=(string)high-4:4:4 With this patch, we can do video/x-h264,profile=(string)high-4\:4\:4
This commit is contained in:
parent
762733c3d8
commit
59eacaa966
@ -1691,21 +1691,31 @@ static GstEncodingProfile *
|
|||||||
parse_encoding_profile (const gchar * value)
|
parse_encoding_profile (const gchar * value)
|
||||||
{
|
{
|
||||||
gchar *factory_name;
|
gchar *factory_name;
|
||||||
GstEncodingProfile *res;
|
GstEncodingProfile *res = NULL;
|
||||||
gchar **strcaps_v = g_strsplit (value, ":", 0);
|
gchar *caps_str = NULL;
|
||||||
|
gchar **strcaps_v =
|
||||||
|
g_regex_split_simple ("(?<!\\\\)(?:\\\\\\\\)*:", value, 0, 0);
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
/* The regex returns NULL if no ":" found, handle that case. */
|
||||||
|
if (strcaps_v == NULL)
|
||||||
|
strcaps_v = g_strsplit (value, ":", 0);
|
||||||
|
|
||||||
if (strcaps_v[0] && *strcaps_v[0]) {
|
if (strcaps_v[0] && *strcaps_v[0]) {
|
||||||
GstCaps *caps = get_profile_format_from_possible_factory_name (strcaps_v[0],
|
GstCaps *caps;
|
||||||
|
|
||||||
|
caps_str = g_strcompress (strcaps_v[0]);
|
||||||
|
caps = get_profile_format_from_possible_factory_name (caps_str,
|
||||||
&factory_name, NULL);
|
&factory_name, NULL);
|
||||||
|
|
||||||
if (!caps)
|
if (!caps)
|
||||||
caps = gst_caps_from_string (strcaps_v[0]);
|
caps = gst_caps_from_string (caps_str);
|
||||||
|
|
||||||
if (caps == NULL) {
|
if (caps == NULL) {
|
||||||
GST_ERROR ("Could not parse caps %s", strcaps_v[0]);
|
GST_ERROR ("Could not parse caps %s", caps_str);
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
|
g_clear_pointer (&caps_str, g_free);
|
||||||
|
|
||||||
res =
|
res =
|
||||||
GST_ENCODING_PROFILE (gst_encoding_container_profile_new
|
GST_ENCODING_PROFILE (gst_encoding_container_profile_new
|
||||||
@ -1721,25 +1731,37 @@ parse_encoding_profile (const gchar * value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; strcaps_v[i] && *strcaps_v[i]; i++) {
|
for (i = 1; strcaps_v[i] && *strcaps_v[i]; i++) {
|
||||||
GstEncodingProfile *profile = create_encoding_stream_profile (strcaps_v[i]);
|
GstEncodingProfile *profile;
|
||||||
|
caps_str = g_strcompress (strcaps_v[i]);
|
||||||
|
profile = create_encoding_stream_profile (caps_str);
|
||||||
|
|
||||||
if (!profile)
|
if (!profile) {
|
||||||
return NULL;
|
GST_ERROR ("Could not create profile for caps: %s", caps_str);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
if (!gst_encoding_container_profile_add_profile
|
if (!gst_encoding_container_profile_add_profile
|
||||||
(GST_ENCODING_CONTAINER_PROFILE (res), profile)) {
|
(GST_ENCODING_CONTAINER_PROFILE (res), profile)) {
|
||||||
GST_ERROR ("Can not create a preset for caps: %s", strcaps_v[i]);
|
GST_ERROR ("Can not add profile for caps: %s", caps_str);
|
||||||
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = profile;
|
res = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_pointer (&caps_str, g_free);
|
||||||
}
|
}
|
||||||
g_strfreev (strcaps_v);
|
g_strfreev (strcaps_v);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
error:
|
||||||
|
g_free (caps_str);
|
||||||
|
g_strfreev (strcaps_v);
|
||||||
|
g_clear_object (&res);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstEncodingProfile *
|
static GstEncodingProfile *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user