pbutils/encoding-profile: Streamline cleanup
Cleanup all local variables in one place, and ensure failure cases go through there. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3390>
This commit is contained in:
parent
6582cd514a
commit
7988144048
@ -1826,9 +1826,9 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guint presence = 0;
|
guint presence = 0;
|
||||||
gboolean single_segment = FALSE;
|
gboolean single_segment = FALSE;
|
||||||
gchar *strcaps, *strpresence, **strprops_v, **restriction_format,
|
gchar *strcaps = NULL, *strpresence, **strprops_v =
|
||||||
**preset_v, *preset_name = NULL, *factory_name = NULL,
|
NULL, **restriction_format, **preset_v = NULL, *preset_name =
|
||||||
*variable_framerate = NULL;
|
NULL, *factory_name = NULL, *variable_framerate = NULL;
|
||||||
GstStructure *element_properties = NULL;
|
GstStructure *element_properties = NULL;
|
||||||
GstCaps *restrictioncaps = NULL;
|
GstCaps *restrictioncaps = NULL;
|
||||||
GstEncodingProfile *profile = NULL;
|
GstEncodingProfile *profile = NULL;
|
||||||
@ -1886,7 +1886,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
g_warning ("Wrong format for property: %s, only 1 `=` is expected",
|
g_warning ("Wrong format for property: %s, only 1 `=` is expected",
|
||||||
prop);
|
prop);
|
||||||
g_strfreev (propv);
|
g_strfreev (propv);
|
||||||
return NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!propv[1]) {
|
if (!propv[1]) {
|
||||||
@ -1903,7 +1903,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
g_warning ("Invalid value for property 'single-segment': %s",
|
g_warning ("Invalid value for property 'single-segment': %s",
|
||||||
propv[1]);
|
propv[1]);
|
||||||
g_strfreev (propv);
|
g_strfreev (propv);
|
||||||
return NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
single_segment = g_value_get_boolean (&v);
|
single_segment = g_value_get_boolean (&v);
|
||||||
@ -1911,7 +1911,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
} else {
|
} else {
|
||||||
g_warning ("Unsupported property: %s", propv[0]);
|
g_warning ("Unsupported property: %s", propv[0]);
|
||||||
g_strfreev (propv);
|
g_strfreev (propv);
|
||||||
return NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presence_str) {
|
if (presence_str) {
|
||||||
@ -1920,7 +1920,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
if (endptr == strprops_v[1]) {
|
if (endptr == strprops_v[1]) {
|
||||||
g_warning ("Wrong presence %s", presence_str);
|
g_warning ("Wrong presence %s", presence_str);
|
||||||
g_strfreev (propv);
|
g_strfreev (propv);
|
||||||
return NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_strfreev (propv);
|
g_strfreev (propv);
|
||||||
@ -1932,8 +1932,6 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
strcaps = g_strdup (preset_v[0]);
|
strcaps = g_strdup (preset_v[0]);
|
||||||
} /* Else we have no presence nor preset */
|
} /* Else we have no presence nor preset */
|
||||||
}
|
}
|
||||||
g_strfreev (strprops_v);
|
|
||||||
g_strfreev (preset_v);
|
|
||||||
|
|
||||||
GST_DEBUG ("Creating preset with restrictions: %" GST_PTR_FORMAT
|
GST_DEBUG ("Creating preset with restrictions: %" GST_PTR_FORMAT
|
||||||
", caps: %s, preset %s, presence %d", restrictioncaps, strcaps,
|
", caps: %s, preset %s, presence %d", restrictioncaps, strcaps,
|
||||||
@ -1961,11 +1959,6 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (preset_name);
|
|
||||||
g_free (strcaps);
|
|
||||||
|
|
||||||
if (restrictioncaps)
|
|
||||||
gst_caps_unref (restrictioncaps);
|
|
||||||
|
|
||||||
if (variable_framerate) {
|
if (variable_framerate) {
|
||||||
if (GST_IS_ENCODING_VIDEO_PROFILE (profile)) {
|
if (GST_IS_ENCODING_VIDEO_PROFILE (profile)) {
|
||||||
@ -1986,19 +1979,26 @@ create_encoding_stream_profile (gchar * serialized_profile,
|
|||||||
GST_WARNING
|
GST_WARNING
|
||||||
("Variable framerate specified on a non video encoding profile");
|
("Variable framerate specified on a non video encoding profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (variable_framerate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile == NULL) {
|
if (profile == NULL) {
|
||||||
GST_ERROR ("No way to create a profile for description: %s",
|
GST_ERROR ("No way to create a profile for description: %s",
|
||||||
serialized_profile);
|
serialized_profile);
|
||||||
|
} else if (element_properties) {
|
||||||
return NULL;
|
gst_encoding_profile_set_element_properties (profile,
|
||||||
|
g_steal_pointer (&element_properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
g_free (strcaps);
|
||||||
|
g_free (variable_framerate);
|
||||||
|
g_strfreev (strprops_v);
|
||||||
|
g_strfreev (preset_v);
|
||||||
|
g_free (preset_name);
|
||||||
if (element_properties)
|
if (element_properties)
|
||||||
gst_encoding_profile_set_element_properties (profile, element_properties);
|
gst_structure_free (element_properties);
|
||||||
|
if (restrictioncaps)
|
||||||
|
gst_caps_unref (restrictioncaps);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user