static GstEncodingTarget * gst_encoding_target_subload (gchar * path, const gchar * category, gchar * lfilename, GError ** error) { GstEncodingTarget *target = NULL; if (category) { gchar *filename; filename = g_build_filename (path, category, lfilename, NULL); target = gst_encoding_target_load_from_file (filename, error); g_free (filename); } else { GList *tmp, *tries = get_matching_filenames (path, lfilename); /* Try to find a file named %s.gstprofile in any subdirectories */ for (tmp = tries; tmp; tmp = tmp->next) { target = gst_encoding_target_load_from_file ((gchar *) tmp->data, NULL); if (target) break; } g_list_foreach (tries, (GFunc) g_free, NULL); if (tries) g_list_free (tries); } return target; }
static inline GList * sub_get_all_targets (gchar * subdir) { GList *res = NULL; const gchar *filename; GDir *dir; GstEncodingTarget *target; dir = g_dir_open (subdir, 0, NULL); if (G_UNLIKELY (dir == NULL)) return NULL; while ((filename = g_dir_read_name (dir))) { gchar *fullname; /* Only try files ending with .gstprofile */ if (!g_str_has_suffix (filename, GST_ENCODING_TARGET_SUFFIX)) continue; fullname = g_build_filename (subdir, filename, NULL); target = gst_encoding_target_load_from_file (fullname, NULL); if (target) { res = g_list_append (res, target); } else GST_WARNING ("Failed to get a target from %s", fullname); g_free (fullname); } g_dir_close (dir); return res; }
GstEncodingTarget *get_default_encoding_target(void) { if (default_target == NULL) { char *target_file; GError *error = NULL; if (g_file_test(SOURCE_ENCODING_TARGET_FILE, G_FILE_TEST_EXISTS) != FALSE) target_file = SOURCE_ENCODING_TARGET_FILE; else target_file = INSTALLED_ENCODING_TARGET_FILE; default_target = gst_encoding_target_load_from_file(target_file, &error); if (default_target == NULL) { g_warning("Unable to load encoding profiles from %s: %s", target_file, error ? error->message : "no error"); g_clear_error(&error); return NULL; } } return default_target; }
GstEncodingTarget * rb_gst_get_default_encoding_target () { if (default_target == NULL) { char *target_file; GError *error = NULL; target_file = get_encoding_target_file (); default_target = gst_encoding_target_load_from_file (target_file, &error); if (default_target == NULL) { g_warning ("Unable to load encoding profiles from %s: %s", target_file, error ? error->message : "no error"); g_clear_error (&error); g_free (target_file); return NULL; } g_free (target_file); } return default_target; }
static GstEncodingProfile * load_encoding_profile (void) { GstEncodingProfile *prof = NULL; GstEncodingTarget *target = NULL; GError *error = NULL; /* if profile file was given, try to load profile from there */ if (gep_filename && gep_profilename) { target = gst_encoding_target_load_from_file (gep_filename, &error); if (!target) { GST_WARNING ("Could not load target %s from file %s", gep_targetname, gep_filename); if (error) { GST_WARNING ("Error from file loading: %s", error->message); g_error_free (error); error = NULL; } } else { prof = gst_encoding_target_get_profile (target, gep_profilename); if (prof) GST_DEBUG ("Loaded encoding profile %s from %s", gep_profilename, gep_filename); else GST_WARNING ("Could not load specified encoding profile %s from file %s", gep_profilename, gep_filename); } /* if we could not load profile from file then try to find one from system */ } else if (gep_profilename && gep_targetname) { prof = gst_encoding_profile_find (gep_targetname, gep_profilename, NULL); if (prof) GST_DEBUG ("Loaded encoding profile %s from target %s", gep_profilename, gep_targetname); } else GST_DEBUG ("Encoding profile not set, using camerabin2 default encoding profile"); return prof; }