Commit e79f0e80 authored by Thibault Saunier's avatar Thibault Saunier

encodebing: Use the preset_name as the factory name and preset as the name of the preset

The naming is not perfect, but at least we can keep the exact same behaviour as
before.
parent 929edc25
......@@ -261,8 +261,8 @@ gst_encoding_profile_get_format (GstEncodingProfile * profile)
* gst_encoding_profile_get_preset:
* @profile: a #GstEncodingProfile
*
* Returns: the name of the #GstElement that implements #GstPreset to
* be used in the profile.
* Returns: the name of the #GstPreset to be used in the profile.
* This is the name that has been set when saving the preset.
*/
const gchar *
gst_encoding_profile_get_preset (GstEncodingProfile * profile)
......@@ -274,8 +274,7 @@ gst_encoding_profile_get_preset (GstEncodingProfile * profile)
* gst_encoding_profile_get_preset_name:
* @profile: a #GstEncodingProfile
*
* Returns: the name of the #GstPreset to be used in the profile.
* This is the name that has been set when saving the preset.
* Returns: the name of the #GstPreset factory to be used in the profile.
*/
const gchar *
gst_encoding_profile_get_preset_name (GstEncodingProfile * profile)
......@@ -368,6 +367,7 @@ gst_encoding_profile_set_format (GstEncodingProfile * profile, GstCaps * format)
*
* Sets the name of the #GstElement that implements the #GstPreset interface
* to use for the profile.
* This is the name that has been set when saving the preset.
*/
void
gst_encoding_profile_set_preset (GstEncodingProfile * profile,
......@@ -383,8 +383,7 @@ gst_encoding_profile_set_preset (GstEncodingProfile * profile,
* @profile: a #GstEncodingProfile
* @preset_name: The name of the preset to use in this @profile.
*
* Sets the name of the #GstPreset to be used in the profile.
* This is the name that has been set when saving the preset.
* Sets the name of the #GstPreset's factory to be used in the profile.
*/
void
gst_encoding_profile_set_preset_name (GstEncodingProfile * profile,
......
......@@ -825,24 +825,26 @@ _create_element_and_set_preset (GstElementFactory * factory,
" preset name: %s)", GST_OBJECT_NAME (factory), preset, preset_name);
res = gst_element_factory_create (factory, name);
if (preset) {
if (g_strcmp0 (gst_object_get_name (GST_OBJECT (factory)), preset) == 0) {
if (preset_name) {
if (!gst_preset_load_preset (GST_PRESET (res), preset_name)) {
GST_WARNING ("Couldn't set preset [%s] on element [%s]",
preset, GST_OBJECT_NAME (factory));
gst_object_unref (res);
res = NULL;
}
} else {
GST_DEBUG ("Using a preset with no preset name, making use of the"
" proper element without setting any property");
if (preset && GST_IS_PRESET (res)) {
if (preset_name == NULL ||
g_strcmp0 (GST_OBJECT_NAME (factory), preset_name) == 0) {
if (!gst_preset_load_preset (GST_PRESET (res), preset)) {
GST_WARNING ("Couldn't set preset [%s] on element [%s]",
preset, GST_OBJECT_NAME (factory));
gst_object_unref (res);
res = NULL;
}
} else {
gst_object_unref (res);
res = NULL;
GST_DEBUG ("Using a preset with no preset name, making use of the"
" proper element without setting any property");
}
} else if (preset_name && g_strcmp0 (GST_OBJECT_NAME (factory), preset_name)) {
gst_object_unref (res);
res = NULL;
}
/* Else we keep it */
return res;
}
......
......@@ -220,8 +220,8 @@ GST_START_TEST (test_encodebin_preset)
/* Give a name someone should never use outside of that test */
gst_preset_save_preset (oggmuxpreset, "test_encodebin_preset");
gst_encoding_profile_set_preset (prof, "oggmux");
gst_encoding_profile_set_preset_name (prof, "test_encodebin_preset");
gst_encoding_profile_set_preset (prof, "test_encodebin_preset");
gst_encoding_profile_set_preset_name (prof, "oggmux");
g_object_set (ebin, "profile", prof, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment