static GstEncodingTarget * parse_keyfile (GKeyFile * in, gchar * targetname, gchar * categoryname, gchar * description) { GstEncodingTarget *res = NULL; GstEncodingProfile *prof; gchar **groups; gsize i, nbgroups; res = gst_encoding_target_new (targetname, categoryname, description, NULL); /* Figure out the various profiles */ groups = g_key_file_get_groups (in, &nbgroups); for (i = 0; i < nbgroups; i++) { if (!g_ascii_strncasecmp (groups[i], "profile-", 8)) { prof = parse_encoding_profile (in, NULL, groups[i], nbgroups, groups); if (prof) gst_encoding_target_add_profile (res, prof); } } g_strfreev (groups); g_free (targetname); g_free (categoryname); g_free (description); return res; }
static gboolean gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s) { GstEncodingProfile *profile; profile = combo_search (s); if (!profile) profile = parse_encoding_profile (s); if (profile) { g_value_take_object (value, (GObject *) profile); return TRUE; } return FALSE; }
/** * parse_encoding_profile: * @in: a #GKeyFile * @parentprofilename: the parent profile name (including 'profile-' or 'streamprofile-' header) * @profilename: the profile name group to parse * @nbgroups: the number of top-level groups * @groups: the top-level groups */ static GstEncodingProfile * parse_encoding_profile (GKeyFile * in, gchar * parentprofilename, gchar * profilename, gsize nbgroups, gchar ** groups) { GstEncodingProfile *sprof = NULL; gchar **parent; gchar *proftype, *format, *preset, *restriction, *pname, *description, *locale; GstCaps *formatcaps = NULL; GstCaps *restrictioncaps = NULL; gboolean variableframerate; gint pass, presence; gsize i, nbencprofiles; GST_DEBUG ("parentprofilename : %s , profilename : %s", parentprofilename, profilename); if (parentprofilename) { gboolean found = FALSE; parent = g_key_file_get_string_list (in, profilename, "parent", &nbencprofiles, NULL); if (!parent || !nbencprofiles) { return NULL; } /* Check if this streamprofile is used in <profilename> */ for (i = 0; i < nbencprofiles; i++) { if (!g_strcmp0 (parent[i], parentprofilename)) { found = TRUE; break; } } g_strfreev (parent); if (!found) { GST_DEBUG ("Stream profile '%s' isn't used in profile '%s'", profilename, parentprofilename); return NULL; } } pname = g_key_file_get_value (in, profilename, "name", NULL); locale = get_locale (); /* will try to fall back to untranslated string if no translation found */ description = g_key_file_get_locale_string (in, profilename, "description", locale, NULL); g_free (locale); /* Note: a missing description is normal for non-container profiles */ if (description == NULL) { GST_LOG ("Missing 'description' field for streamprofile %s", profilename); } /* Parse the remaining fields */ proftype = g_key_file_get_value (in, profilename, "type", NULL); if (!proftype) { GST_WARNING ("Missing 'type' field for streamprofile %s", profilename); return NULL; } format = g_key_file_get_value (in, profilename, "format", NULL); if (format) { formatcaps = gst_caps_from_string (format); g_free (format); } preset = g_key_file_get_value (in, profilename, "preset", NULL); restriction = g_key_file_get_value (in, profilename, "restriction", NULL); if (restriction) { restrictioncaps = gst_caps_from_string (restriction); g_free (restriction); } presence = g_key_file_get_integer (in, profilename, "presence", NULL); pass = g_key_file_get_integer (in, profilename, "pass", NULL); variableframerate = g_key_file_get_boolean (in, profilename, "variableframerate", NULL); /* Build the streamprofile ! */ if (!g_strcmp0 (proftype, "container")) { GstEncodingProfile *pprof; sprof = (GstEncodingProfile *) gst_encoding_container_profile_new (pname, description, formatcaps, preset); /* Now look for the stream profiles */ for (i = 0; i < nbgroups; i++) { if (!g_ascii_strncasecmp (groups[i], "streamprofile-", 13)) { pprof = parse_encoding_profile (in, pname, groups[i], nbgroups, groups); if (pprof) { gst_encoding_container_profile_add_profile ( (GstEncodingContainerProfile *) sprof, pprof); } } } } else if (!g_strcmp0 (proftype, "video")) { sprof = (GstEncodingProfile *) gst_encoding_video_profile_new (formatcaps, preset, restrictioncaps, presence); gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile *) sprof, variableframerate); gst_encoding_video_profile_set_pass ((GstEncodingVideoProfile *) sprof, pass); gst_encoding_profile_set_name (sprof, pname); gst_encoding_profile_set_description (sprof, description); } else if (!g_strcmp0 (proftype, "audio")) { sprof = (GstEncodingProfile *) gst_encoding_audio_profile_new (formatcaps, preset, restrictioncaps, presence); gst_encoding_profile_set_name (sprof, pname); gst_encoding_profile_set_description (sprof, description); } else GST_ERROR ("Unknown profile format '%s'", proftype); if (restrictioncaps) gst_caps_unref (restrictioncaps); if (formatcaps) gst_caps_unref (formatcaps); g_free (pname); g_free (description); g_free (preset); g_free (proftype); return sprof; }