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.
This commit is contained in:
Thibault Saunier 2012-12-15 14:43:40 -03:00
parent 929edc2572
commit e79f0e801e
3 changed files with 23 additions and 22 deletions

View file

@ -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,

View file

@ -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;
}

View file

@ -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);