2002-11-11 13:59:16 +00:00
|
|
|
/* media-info test app */
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "media-info.h"
|
|
|
|
|
2004-03-06 20:15:17 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
2004-03-06 20:15:17 +00:00
|
|
|
{
|
|
|
|
gint i, count;
|
|
|
|
|
|
|
|
count = gst_tag_list_get_tag_size (list, tag);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
|
|
|
|
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
|
|
|
|
} else {
|
2004-03-14 22:34:30 +00:00
|
|
|
str =
|
2004-03-15 19:32:25 +00:00
|
|
|
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
|
2004-03-06 20:15:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
|
|
|
|
} else {
|
|
|
|
g_print (" : %s\n", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
info_print (GstMediaInfoStream * stream)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GList *p;
|
|
|
|
GstMediaInfoTrack *track;
|
|
|
|
|
|
|
|
g_print ("- mime type: %s\n", stream->mime);
|
2003-09-23 22:49:35 +00:00
|
|
|
g_print ("- length: %.3f seconds\n",
|
2004-03-14 22:34:30 +00:00
|
|
|
(gdouble) stream->length_time / GST_SECOND);
|
2002-11-11 13:59:16 +00:00
|
|
|
g_print ("- bitrate: %.3f kbps\n", stream->bitrate / 1000.0);
|
|
|
|
g_print ("- number of tracks: %ld\n", stream->length_tracks);
|
|
|
|
p = stream->tracks;
|
2004-03-14 22:34:30 +00:00
|
|
|
if (p == NULL) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_print ("- no track information, probably an error\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
for (i = 0; i < stream->length_tracks; ++i) {
|
2002-11-11 13:59:16 +00:00
|
|
|
g_print ("- track %d\n", i);
|
|
|
|
track = (GstMediaInfoTrack *) p->data;
|
|
|
|
g_print (" - metadata:\n");
|
2004-03-06 20:15:17 +00:00
|
|
|
if (track->metadata)
|
|
|
|
gst_tag_list_foreach (track->metadata, print_tag, NULL);
|
|
|
|
else
|
|
|
|
g_print (" (none found)\n");
|
2002-11-11 13:59:16 +00:00
|
|
|
g_print (" - streaminfo:\n");
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_tag_list_foreach (track->streaminfo, print_tag, NULL);
|
2002-11-11 13:59:16 +00:00
|
|
|
g_print (" - format:\n");
|
2003-12-22 01:47:08 +00:00
|
|
|
g_print ("%s\n", gst_caps_to_string (track->format));
|
2002-11-11 13:59:16 +00:00
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GstMediaInfo *info;
|
2003-09-23 22:49:35 +00:00
|
|
|
GstMediaInfoStream *stream = NULL;
|
2004-03-06 20:15:17 +00:00
|
|
|
GError *error = NULL;
|
2002-11-11 13:59:16 +00:00
|
|
|
gint i;
|
2003-09-23 22:49:35 +00:00
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
g_assert (argc > 1);
|
|
|
|
|
2004-01-20 16:25:11 +00:00
|
|
|
gst_media_info_init ();
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
info = gst_media_info_new (&error);
|
2004-03-14 22:34:30 +00:00
|
|
|
if (error != NULL) {
|
2004-03-06 20:15:17 +00:00
|
|
|
g_print ("Error creating media-info object: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (G_IS_OBJECT (info));
|
2004-03-14 22:34:30 +00:00
|
|
|
if (!gst_media_info_set_source (info, "gnomevfssrc", &error)) {
|
2004-03-06 20:15:17 +00:00
|
|
|
g_print ("Could not set gnomevfssrc as a source\n");
|
2004-03-07 20:51:10 +00:00
|
|
|
g_print ("reason: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
2004-03-06 20:15:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
g_print ("stream: %p, &stream: %p\n", stream, &stream);
|
2004-03-14 22:34:30 +00:00
|
|
|
for (i = 1; i < argc; ++i) {
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
/*
|
2004-03-14 22:34:30 +00:00
|
|
|
stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
|
|
|
|
*/
|
2004-03-07 20:51:10 +00:00
|
|
|
gst_media_info_read_with_idler (info, argv[i], GST_MEDIA_INFO_ALL, &error);
|
|
|
|
while (gst_media_info_read_idler (info, &stream, &error) && stream == NULL)
|
2004-03-14 22:34:30 +00:00
|
|
|
/* keep idling */
|
|
|
|
g_print ("+");
|
2002-11-11 13:59:16 +00:00
|
|
|
g_print ("\nFILE: %s\n", argv[i]);
|
2003-09-23 22:49:35 +00:00
|
|
|
g_print ("stream: %p, &stream: %p\n", stream, &stream);
|
2004-03-14 22:34:30 +00:00
|
|
|
if (error) {
|
2004-03-07 20:51:10 +00:00
|
|
|
g_print ("Error reading media info: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
2002-11-11 13:59:16 +00:00
|
|
|
if (stream)
|
|
|
|
info_print (stream);
|
|
|
|
else
|
|
|
|
g_print ("no media info found.\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
stream = NULL;
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
return 0;
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|