*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <locale.h>
+
#include <stdlib.h>
#include <glib.h>
#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
+/* *INDENT-OFF* */
+static void my_g_string_append_printf (GString * str, int depth, const gchar * format, ...) G_GNUC_PRINTF (3, 4);
+/* *INDENT-ON* */
+
static gboolean async = FALSE;
-static gboolean silent = FALSE;
static gboolean show_toc = FALSE;
static gboolean verbose = FALSE;
va_end (args);
}
-static gchar *
-gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
+static void
+gst_stream_information_to_string (GstDiscovererStreamInfo * info, GString * s,
gint depth)
{
- GstDiscovererAudioInfo *audio_info;
- GString *s;
gchar *tmp;
- const gchar *ctmp;
- int len = 400;
- const GstTagList *tags;
GstCaps *caps;
-
- g_return_val_if_fail (info != NULL, NULL);
-
- s = g_string_sized_new (len);
+ const GstStructure *misc;
my_g_string_append_printf (s, depth, "Codec:\n");
caps = gst_discoverer_stream_info_get_caps (info);
g_free (tmp);
my_g_string_append_printf (s, depth, "Additional info:\n");
- if (gst_discoverer_stream_info_get_misc (info)) {
- tmp = gst_structure_to_string (gst_discoverer_stream_info_get_misc (info));
+ if ((misc = gst_discoverer_stream_info_get_misc (info))) {
+ tmp = gst_structure_to_string (misc);
my_g_string_append_printf (s, depth, " %s\n", tmp);
g_free (tmp);
} else {
my_g_string_append_printf (s, depth, " None\n");
}
+ my_g_string_append_printf (s, depth, "Stream ID: %s\n",
+ gst_discoverer_stream_info_get_stream_id (info));
+}
+
+static gchar *
+gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
+ gint depth)
+{
+ GstDiscovererAudioInfo *audio_info;
+ GString *s;
+ gchar *tmp;
+ const gchar *ctmp;
+ int len = 400;
+ const GstTagList *tags;
+
+ g_return_val_if_fail (info != NULL, NULL);
+
+ s = g_string_sized_new (len);
+
+ gst_stream_information_to_string (info, s, depth);
+
audio_info = (GstDiscovererAudioInfo *) info;
ctmp = gst_discoverer_audio_info_get_language (audio_info);
my_g_string_append_printf (s, depth, "Language: %s\n",
GString *s;
gchar *tmp;
int len = 500;
- const GstStructure *misc;
const GstTagList *tags;
- GstCaps *caps;
g_return_val_if_fail (info != NULL, NULL);
s = g_string_sized_new (len);
- my_g_string_append_printf (s, depth, "Codec:\n");
- caps = gst_discoverer_stream_info_get_caps (info);
- tmp = gst_caps_to_string (caps);
- gst_caps_unref (caps);
- my_g_string_append_printf (s, depth, " %s\n", tmp);
- g_free (tmp);
-
- my_g_string_append_printf (s, depth, "Additional info:\n");
- misc = gst_discoverer_stream_info_get_misc (info);
- if (misc) {
- tmp = gst_structure_to_string (misc);
- my_g_string_append_printf (s, depth, " %s\n", tmp);
- g_free (tmp);
- } else {
- my_g_string_append_printf (s, depth, " None\n");
- }
+ gst_stream_information_to_string (info, s, depth);
video_info = (GstDiscovererVideoInfo *) info;
my_g_string_append_printf (s, depth, "Width: %u\n",
const gchar *ctmp;
int len = 400;
const GstTagList *tags;
- GstCaps *caps;
g_return_val_if_fail (info != NULL, NULL);
s = g_string_sized_new (len);
- my_g_string_append_printf (s, depth, "Codec:\n");
- caps = gst_discoverer_stream_info_get_caps (info);
- tmp = gst_caps_to_string (caps);
- gst_caps_unref (caps);
- my_g_string_append_printf (s, depth, " %s\n", tmp);
- g_free (tmp);
-
- my_g_string_append_printf (s, depth, "Additional info:\n");
- if (gst_discoverer_stream_info_get_misc (info)) {
- tmp = gst_structure_to_string (gst_discoverer_stream_info_get_misc (info));
- my_g_string_append_printf (s, depth, " %s\n", tmp);
- g_free (tmp);
- } else {
- my_g_string_append_printf (s, depth, " None\n");
- }
+ gst_stream_information_to_string (info, s, depth);
subtitle_info = (GstDiscovererSubtitleInfo *) info;
ctmp = gst_discoverer_subtitle_info_get_language (subtitle_info);
}
static void
-print_tag (const gchar * tag_name, const GValue * value, gint tab)
-{
- gchar *ser;
-
- if (G_VALUE_HOLDS_STRING (value))
- ser = g_value_dup_string (value);
- else if (GST_VALUE_HOLDS_SAMPLE (value)) {
- GstSample *smpl = gst_value_get_sample (value);
- GstBuffer *buf = gst_sample_get_buffer (smpl);
- GstCaps *caps = gst_sample_get_caps (smpl);
- gchar *caps_str;
-
- caps_str = caps ? gst_caps_to_string (caps) : g_strdup ("unknown");
- ser =
- g_strdup_printf ("<GstSample [%" G_GSIZE_FORMAT " bytes, type %s]>",
- gst_buffer_get_size (buf), caps_str);
- g_free (caps_str);
- } else
- ser = gst_value_serialize (value);
-
- g_print ("%*s%s: %s\n", tab, " ", gst_tag_get_nick (tag_name), ser);
- g_free (ser);
-}
-
-/* FIXME: this function is almost identical to print_tag() */
-static void
print_tag_foreach (const GstTagList * tags, const gchar * tag,
gpointer user_data)
{
GstTocEntry *entry = (GstTocEntry *) data;
gint depth = GPOINTER_TO_INT (user_data);
guint indent = MIN (GPOINTER_TO_UINT (user_data), MAX_INDENT);
+ GstTagList *tags;
+ GList *subentries;
gint64 start, stop;
- gst_toc_entry_get_start_stop (entry, &start, &stop);
+ gst_toc_entry_get_start_stop_times (entry, &start, &stop);
g_print ("%*s%s: start: %" GST_TIME_FORMAT " stop: %" GST_TIME_FORMAT "\n",
- depth, " ", gst_toc_entry_type_get_nick (entry->type),
+ depth, " ",
+ gst_toc_entry_type_get_nick (gst_toc_entry_get_entry_type (entry)),
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
indent += 2;
/* print tags */
- if (entry->type == GST_TOC_ENTRY_TYPE_CHAPTER)
+ tags = gst_toc_entry_get_tags (entry);
+ if (tags) {
g_print ("%*sTags:\n", 2 * depth, " ");
- gst_tag_list_foreach (entry->tags, print_tag_foreach,
- GUINT_TO_POINTER (indent));
+ gst_tag_list_foreach (tags, print_tag_foreach, GUINT_TO_POINTER (indent));
+ }
/* loop over sub-toc entries */
- g_list_foreach (entry->subentries, print_toc_entry,
- GUINT_TO_POINTER (indent));
+ subentries = gst_toc_entry_get_sub_entries (entry);
+ g_list_foreach (subentries, print_toc_entry, GUINT_TO_POINTER (indent));
}
static void
g_print ("%*sSeekable: %s\n", tab + 1, " ",
(gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
if ((tags = gst_discoverer_info_get_tags (info))) {
- guint num_tags, i;
-
g_print ("%*sTags: \n", tab + 1, " ");
- num_tags = gst_tag_list_n_tags (tags);
- for (i = 0; i < num_tags; ++i) {
- const GValue *val;
- const gchar *tag_name;
- guint num_entries, j;
-
- tag_name = gst_tag_list_nth_tag_name (tags, i);
- num_entries = gst_tag_list_get_tag_size (tags, tag_name);
- for (j = 0; j < num_entries; ++j) {
- val = gst_tag_list_get_value_index (tags, tag_name, j);
- print_tag (tag_name, val, tab + 5);
- }
- }
+ gst_tag_list_foreach (tags, print_tag_foreach, GUINT_TO_POINTER (tab + 2));
}
if (show_toc && (toc = gst_discoverer_info_get_toc (info))) {
+ GList *entries;
+
g_print ("%*sTOC: \n", tab + 1, " ");
- g_list_foreach (toc->entries, print_toc_entry, GUINT_TO_POINTER (tab + 5));
+ entries = gst_toc_get_entries (toc);
+ g_list_foreach (entries, print_toc_entry, GUINT_TO_POINTER (tab + 5));
}
}
{
g_print ("Missing plugins\n");
if (verbose) {
- gchar *tmp =
- gst_structure_to_string (gst_discoverer_info_get_misc (info));
- g_print (" (%s)\n", tmp);
- g_free (tmp);
+ gint i = 0;
+ const gchar **installer_details =
+ gst_discoverer_info_get_missing_elements_installer_details (info);
+
+ while (installer_details[i]) {
+ g_print (" (%s)\n", installer_details[i]);
+
+ i++;
+ }
}
break;
}
GOptionEntry options[] = {
{"async", 'a', 0, G_OPTION_ARG_NONE, &async,
"Run asynchronously", NULL},
- {"silent", 's', 0, G_OPTION_ARG_NONE, &silent,
- "Don't output the information structure", NULL},
{"timeout", 't', 0, G_OPTION_ARG_INT, &timeout,
"Specify timeout (in seconds, default 10)", "T"},
/* {"elem", 'e', 0, G_OPTION_ARG_NONE, &elem_seek, */
};
GOptionContext *ctx;
+ setlocale (LC_ALL, "");
+
ctx =
g_option_context_new
("- discover files synchronously with GstDiscoverer");