mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
formatter: Use the new GstEncodingProfile:element-properties
property
Cleaning up the code and making everything simpler. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/227>
This commit is contained in:
parent
7282e1e56c
commit
d7764275d8
2 changed files with 22 additions and 67 deletions
|
@ -813,36 +813,9 @@ _create_profile (GESBaseXmlFormatter * self,
|
|||
gst_encoding_profile_set_description (profile, description);
|
||||
gst_encoding_profile_set_preset_name (profile, preset_name);
|
||||
}
|
||||
|
||||
if (preset && preset_properties) {
|
||||
GstElement *element;
|
||||
|
||||
if (!g_strcmp0 (type, "container")) {
|
||||
element = get_element_for_encoding_profile (profile,
|
||||
GST_ELEMENT_FACTORY_TYPE_MUXER);
|
||||
} else {
|
||||
element = get_element_for_encoding_profile (profile,
|
||||
GST_ELEMENT_FACTORY_TYPE_ENCODER);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (!element || !GST_IS_PRESET (element))) {
|
||||
GST_WARNING_OBJECT (element, "Element is not a GstPreset");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* If the preset doesn't exist on the system, create it */
|
||||
if (!gst_preset_load_preset (GST_PRESET (element), preset)) {
|
||||
gst_structure_foreach (preset_properties,
|
||||
(GstStructureForeachFunc) set_property_foreach, element);
|
||||
|
||||
if (!gst_preset_save_preset (GST_PRESET (element), preset)) {
|
||||
GST_WARNING_OBJECT (element, "Could not save preset %s", preset);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (element)
|
||||
gst_object_unref (element);
|
||||
if (preset_properties) {
|
||||
gst_encoding_profile_set_element_properties (profile,
|
||||
gst_structure_copy (preset_properties));
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
|
|
@ -1867,6 +1867,7 @@ _save_stream_profiles (GESXmlFormatter * self, GString * str,
|
|||
{
|
||||
gchar *tmpc;
|
||||
GstCaps *tmpcaps;
|
||||
GstStructure *properties;
|
||||
const gchar *preset, *preset_name, *name, *description;
|
||||
|
||||
append_escaped (str,
|
||||
|
@ -1901,25 +1902,18 @@ _save_stream_profiles (GESXmlFormatter * self, GString * str,
|
|||
|
||||
preset = gst_encoding_profile_get_preset (sprof);
|
||||
if (preset) {
|
||||
GstElement *encoder;
|
||||
|
||||
append_escaped (str, g_markup_printf_escaped ("preset='%s' ", preset),
|
||||
depth);
|
||||
}
|
||||
|
||||
encoder = get_element_for_encoding_profile (sprof,
|
||||
GST_ELEMENT_FACTORY_TYPE_ENCODER);
|
||||
if (encoder) {
|
||||
if (GST_IS_PRESET (encoder) &&
|
||||
gst_preset_load_preset (GST_PRESET (encoder), preset)) {
|
||||
properties = gst_encoding_profile_get_element_properties (sprof);
|
||||
if (properties) {
|
||||
gchar *props_str = gst_structure_to_string (properties);
|
||||
|
||||
gchar *settings =
|
||||
_serialize_properties (G_OBJECT (encoder), NULL, NULL);
|
||||
append_escaped (str, g_markup_printf_escaped ("preset-properties='%s' ",
|
||||
settings), depth);
|
||||
g_free (settings);
|
||||
}
|
||||
gst_object_unref (encoder);
|
||||
}
|
||||
append_escaped (str,
|
||||
g_markup_printf_escaped ("preset-properties='%s' ", props_str), depth);
|
||||
g_free (props_str);
|
||||
gst_structure_free (properties);
|
||||
}
|
||||
|
||||
preset_name = gst_encoding_profile_get_preset_name (sprof);
|
||||
|
@ -1953,6 +1947,7 @@ _save_encoding_profiles (GESXmlFormatter * self, GString * str,
|
|||
GESProject * project, guint depth)
|
||||
{
|
||||
GstCaps *profformat;
|
||||
GstStructure *properties;
|
||||
const gchar *profname, *profdesc, *profpreset, *proftype, *profpresetname;
|
||||
|
||||
const GList *tmp;
|
||||
|
@ -1974,32 +1969,19 @@ _save_encoding_profiles (GESXmlFormatter * self, GString * str,
|
|||
profname, profdesc, proftype), depth);
|
||||
|
||||
if (profpreset) {
|
||||
GstElement *element;
|
||||
|
||||
append_escaped (str, g_markup_printf_escaped ("preset='%s' ",
|
||||
profpreset), depth);
|
||||
}
|
||||
|
||||
if (GST_IS_ENCODING_CONTAINER_PROFILE (prof)) {
|
||||
element = get_element_for_encoding_profile (prof,
|
||||
GST_ELEMENT_FACTORY_TYPE_MUXER);
|
||||
} else {
|
||||
element = get_element_for_encoding_profile (prof,
|
||||
GST_ELEMENT_FACTORY_TYPE_ENCODER);
|
||||
}
|
||||
|
||||
if (element) {
|
||||
if (GST_IS_PRESET (element) &&
|
||||
gst_preset_load_preset (GST_PRESET (element), profpreset)) {
|
||||
gchar *settings =
|
||||
_serialize_properties (G_OBJECT (element), NULL, NULL);
|
||||
append_escaped (str,
|
||||
g_markup_printf_escaped ("preset-properties='%s' ", settings),
|
||||
depth);
|
||||
g_free (settings);
|
||||
}
|
||||
gst_object_unref (element);
|
||||
}
|
||||
properties = gst_encoding_profile_get_element_properties (prof);
|
||||
if (properties) {
|
||||
gchar *props_str = gst_structure_to_string (properties);
|
||||
|
||||
append_escaped (str,
|
||||
g_markup_printf_escaped ("preset-properties='%s' ", props_str),
|
||||
depth);
|
||||
g_free (props_str);
|
||||
gst_structure_free (properties);
|
||||
}
|
||||
|
||||
if (profpresetname)
|
||||
|
|
Loading…
Reference in a new issue