mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-04 14:38:48 +00:00
first pass at making this work again needs quite a lot of cleanups
Original commit message from CVS: first pass at making this work again needs quite a lot of cleanups
This commit is contained in:
parent
fe6bf805dc
commit
a11cf2ec0a
6 changed files with 361 additions and 105 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
||||||
|
2004-03-06 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* gst-libs/gst/media-info/media-info-priv.c: (have_type_callback),
|
||||||
|
(deep_notify_callback), (tag_flag_score), (found_tag_callback),
|
||||||
|
(error_callback), (gmi_reset), (gmi_seek_to_track),
|
||||||
|
(gmi_get_decoder), (gmi_set_mime), (gmip_find_type_pre),
|
||||||
|
(gmip_find_type_post), (gmip_find_stream_post),
|
||||||
|
(gmip_find_track_streaminfo_post):
|
||||||
|
* gst-libs/gst/media-info/media-info-priv.h:
|
||||||
|
* gst-libs/gst/media-info/media-info-test.c: (print_tag),
|
||||||
|
(info_print), (main):
|
||||||
|
* gst-libs/gst/media-info/media-info.c:
|
||||||
|
(gst_media_info_error_create), (gst_media_info_error_element),
|
||||||
|
(gst_media_info_instance_init), (gst_media_info_get_property),
|
||||||
|
(gst_media_info_new), (gst_media_info_set_source),
|
||||||
|
(gst_media_info_read_idler), (gst_media_info_read):
|
||||||
|
* gst-libs/gst/media-info/media-info.h:
|
||||||
|
first pass at making this work again. This seems to work on
|
||||||
|
tagged ogg/vorbis and mp3 files.
|
||||||
|
|
||||||
2004-03-06 Benjamin Otte <otte@gnome.org>
|
2004-03-06 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
* ext/mad/gstid3tag.c: (gst_id3_tag_chain):
|
* ext/mad/gstid3tag.c: (gst_id3_tag_chain):
|
||||||
|
|
|
@ -80,9 +80,36 @@ gmi_track_new (void)
|
||||||
static void
|
static void
|
||||||
have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
|
have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
|
||||||
{
|
{
|
||||||
g_print ("DEBUG: have_type: caps %p\n", type);
|
GstStructure *str;
|
||||||
|
const gchar *mime;
|
||||||
|
|
||||||
priv->type = gst_caps_copy (type);
|
priv->type = gst_caps_copy (type);
|
||||||
/* FIXME: make sure we _free these somewhere */
|
str = gst_caps_get_structure (type, 0);
|
||||||
|
mime = gst_structure_get_name (str);
|
||||||
|
GST_DEBUG ("caps %p, mime %s", type, mime);
|
||||||
|
|
||||||
|
/* FIXME: this code doesn't yet work, test it later */
|
||||||
|
#ifdef DONTWORK
|
||||||
|
if (strcmp (mime, "application/x-id3") == 0)
|
||||||
|
{
|
||||||
|
/* dig a little deeper */
|
||||||
|
GST_DEBUG ("dealing with id3, digging deeper");
|
||||||
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
|
gst_element_unlink (priv->source, priv->typefind);
|
||||||
|
g_assert (priv->decontainer == NULL);
|
||||||
|
priv->decontainer = gst_element_factory_make ("id3tag", "decontainer");
|
||||||
|
gst_bin_add (GST_BIN (priv->pipeline), priv->decontainer);
|
||||||
|
if (priv->decontainer == NULL)
|
||||||
|
/* FIXME: signal error */
|
||||||
|
g_warning ("Couldn't create id3tag");
|
||||||
|
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind, NULL));
|
||||||
|
g_warning ("Couldn't link in id3tag");
|
||||||
|
|
||||||
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
||||||
|
== GST_STATE_FAILURE)
|
||||||
|
g_warning ("Couldn't set to playing");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -94,26 +121,21 @@ deep_notify_callback (GObject *object, GstObject *origin,
|
||||||
/* we only care about pad notifies */
|
/* we only care about pad notifies */
|
||||||
if (!GST_IS_PAD (origin)) return;
|
if (!GST_IS_PAD (origin)) return;
|
||||||
|
|
||||||
|
/*
|
||||||
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
|
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
|
||||||
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
|
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
|
||||||
gst_object_get_name (origin));
|
gst_object_get_name (origin));
|
||||||
|
*/
|
||||||
if (strcmp (pspec->name, "metadata") == 0)
|
|
||||||
{
|
|
||||||
GST_DEBUG ("DEBUG: deep_notify: have metadata !");
|
|
||||||
g_value_init (&value, pspec->value_type);
|
|
||||||
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
|
|
||||||
priv->metadata = g_value_peek_pointer (&value);
|
|
||||||
}
|
|
||||||
else if (strcmp (pspec->name, "caps") == 0)
|
else if (strcmp (pspec->name, "caps") == 0)
|
||||||
{
|
{
|
||||||
/* check if we're getting it from the source we want it from */
|
/* check if we're getting it from fakesink */
|
||||||
if (GST_IS_PAD (origin) && GST_PAD (origin) == priv->decoder_pad)
|
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("DEBUG: deep_notify: have caps on decoder_pad !");
|
GST_DEBUG ("have caps on fakesink pad !");
|
||||||
g_value_init (&value, pspec->value_type);
|
g_value_init (&value, pspec->value_type);
|
||||||
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
|
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
|
||||||
priv->format = g_value_peek_pointer (&value);
|
priv->format = g_value_peek_pointer (&value);
|
||||||
|
GST_DEBUG ("caps: %" GST_PTR_FORMAT, priv->format);
|
||||||
}
|
}
|
||||||
else GST_DEBUG ("ignoring caps on object %s:%s",
|
else GST_DEBUG ("ignoring caps on object %s:%s",
|
||||||
gst_object_get_name (gst_object_get_parent (origin)),
|
gst_object_get_name (gst_object_get_parent (origin)),
|
||||||
|
@ -123,14 +145,57 @@ deep_notify_callback (GObject *object, GstObject *origin,
|
||||||
{
|
{
|
||||||
/* we REALLY ignore offsets, we hate them */
|
/* we REALLY ignore offsets, we hate them */
|
||||||
}
|
}
|
||||||
else if (strcmp (pspec->name, "streaminfo") == 0)
|
//else GST_DEBUG ("ignoring notify of %s", pspec->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
guint meta;
|
||||||
|
guint encoded;
|
||||||
|
} TagFlagScore;
|
||||||
|
|
||||||
|
static void
|
||||||
|
tag_flag_score (const GstTagList *list, const gchar *tag, gpointer user_data)
|
||||||
|
{
|
||||||
|
TagFlagScore *score = (TagFlagScore *) user_data;
|
||||||
|
GstTagFlag flag;
|
||||||
|
|
||||||
|
flag = gst_tag_get_flag (tag);
|
||||||
|
if (flag == GST_TAG_FLAG_META) score->meta++;
|
||||||
|
if (flag == GST_TAG_FLAG_ENCODED) score->encoded++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv)
|
||||||
|
{
|
||||||
|
TagFlagScore score;
|
||||||
|
|
||||||
|
score.meta = 0;
|
||||||
|
score.encoded = 0;
|
||||||
|
g_print ("FOUND TAG : found by element \"%s\".\n",
|
||||||
|
GST_STR_NULL (GST_ELEMENT_NAME (source)));
|
||||||
|
|
||||||
|
/* decide if it's likely to be metadata or streaminfo */
|
||||||
|
/* FIXME: this is a hack, there must be a better way,
|
||||||
|
but as long as elements can report both mixed we need to do this */
|
||||||
|
|
||||||
|
gst_tag_list_foreach (tags, tag_flag_score, &score);
|
||||||
|
|
||||||
|
if (score.meta > score.encoded)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("deep_notify: have streaminfo !");
|
GST_DEBUG ("found tags from decoder, adding them as metadata");
|
||||||
g_value_init (&value, pspec->value_type);
|
priv->metadata = gst_tag_list_copy (tags);
|
||||||
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
|
|
||||||
priv->streaminfo = g_value_peek_pointer (&value);
|
|
||||||
}
|
}
|
||||||
else GST_DEBUG ("ignoring notify of %s", pspec->name);
|
else
|
||||||
|
{
|
||||||
|
GST_DEBUG ("found tags, adding them as streaminfo");
|
||||||
|
priv->streaminfo = gst_tag_list_copy (tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
error_callback (GObject *element, GstElement *source, GError *error, gchar *debug)
|
||||||
|
{
|
||||||
|
g_print ("ERROR: %s\n", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helpers */
|
/* helpers */
|
||||||
|
@ -151,7 +216,7 @@ gmi_reset (GstMediaInfo *info)
|
||||||
if (priv->metadata)
|
if (priv->metadata)
|
||||||
{
|
{
|
||||||
GMI_DEBUG ("unreffing priv->metadata, error before this ?\n");
|
GMI_DEBUG ("unreffing priv->metadata, error before this ?\n");
|
||||||
gst_caps_free (priv->metadata);
|
gst_tag_list_free (priv->metadata);
|
||||||
priv->metadata = NULL;
|
priv->metadata = NULL;
|
||||||
}
|
}
|
||||||
if (priv->stream)
|
if (priv->stream)
|
||||||
|
@ -202,20 +267,22 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
|
||||||
/* clear structs because of the seek */
|
/* clear structs because of the seek */
|
||||||
if (priv->metadata)
|
if (priv->metadata)
|
||||||
{
|
{
|
||||||
gst_caps_free (priv->metadata);
|
gst_tag_list_free (priv->metadata);
|
||||||
priv->metadata = NULL;
|
priv->metadata = NULL;
|
||||||
}
|
}
|
||||||
if (priv->streaminfo)
|
if (priv->streaminfo)
|
||||||
{
|
{
|
||||||
gst_caps_free (priv->streaminfo);
|
gst_tag_list_free (priv->streaminfo);
|
||||||
priv->streaminfo = NULL;
|
priv->streaminfo = NULL;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef REMOVEME
|
||||||
/* create a good decoder for this mime type */
|
/* create a good decoder for this mime type */
|
||||||
/* FIXME: maybe make this more generic with a type, so it can be used
|
/* FIXME: maybe make this more generic with a type, so it can be used
|
||||||
* for taggers and other things as well */
|
* for taggers and other things as well */
|
||||||
|
/* FIXME: deprecated, we work with pipelines now */
|
||||||
GstElement *
|
GstElement *
|
||||||
gmi_get_decoder (GstMediaInfo *info, const char *mime)
|
gmi_get_decoder (GstMediaInfo *info, const char *mime)
|
||||||
{
|
{
|
||||||
|
@ -234,6 +301,7 @@ gmi_get_decoder (GstMediaInfo *info, const char *mime)
|
||||||
else if ((strcmp (mime, "audio/mpeg") == 0) ||
|
else if ((strcmp (mime, "audio/mpeg") == 0) ||
|
||||||
(strcmp (mime, "audio/x-mp3") == 0) ||
|
(strcmp (mime, "audio/x-mp3") == 0) ||
|
||||||
(strcmp (mime, "audio/mp3") == 0) ||
|
(strcmp (mime, "audio/mp3") == 0) ||
|
||||||
|
(strcmp (mime, "application/x-id3") == 0) ||
|
||||||
(strcmp (mime, "audio/x-id3") == 0))
|
(strcmp (mime, "audio/x-id3") == 0))
|
||||||
factory = g_strdup ("mad");
|
factory = g_strdup ("mad");
|
||||||
else if (strcmp (mime, "application/x-flac") == 0)
|
else if (strcmp (mime, "application/x-flac") == 0)
|
||||||
|
@ -303,6 +371,72 @@ gmi_clear_decoder (GstMediaInfo *info)
|
||||||
info->priv->decoder = NULL;
|
info->priv->decoder = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set the mime type on the media info getter */
|
||||||
|
gboolean
|
||||||
|
gmi_set_mime (GstMediaInfo *info, const char *mime)
|
||||||
|
{
|
||||||
|
gchar *desc = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
GstMediaInfoPriv *priv = info->priv;
|
||||||
|
|
||||||
|
/* FIXME: please figure out proper mp3 mimetypes */
|
||||||
|
if ((strcmp (mime, "application/x-ogg") == 0) ||
|
||||||
|
(strcmp (mime, "application/ogg") == 0))
|
||||||
|
desc = g_strdup_printf ("%s name=source ! oggdemux ! vorbisdec name=decoder ! audioconvert ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
|
||||||
|
else if ((strcmp (mime, "audio/mpeg") == 0) ||
|
||||||
|
(strcmp (mime, "audio/x-mp3") == 0) ||
|
||||||
|
(strcmp (mime, "audio/mp3") == 0) ||
|
||||||
|
(strcmp (mime, "application/x-id3") == 0) ||
|
||||||
|
(strcmp (mime, "audio/x-id3") == 0))
|
||||||
|
desc = g_strdup_printf ("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
|
||||||
|
else if (strcmp (mime, "application/x-flac") == 0)
|
||||||
|
desc = g_strdup_printf ("%s name=source ! flac name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
|
||||||
|
else if (strcmp (mime, "audio/x-wav") == 0)
|
||||||
|
desc = g_strdup_printf ("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
|
||||||
|
else if (strcmp (mime, "audio/x-mod") == 0 ||
|
||||||
|
strcmp (mime, "audio/x-s3m") == 0 ||
|
||||||
|
strcmp (mime, "audio/x-xm") == 0 ||
|
||||||
|
strcmp (mime, "audio/x-it") == 0)
|
||||||
|
desc = g_strdup_printf ("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
|
||||||
|
|
||||||
|
GST_DEBUG ("using description %s", desc);
|
||||||
|
priv->pipeline_desc = desc;
|
||||||
|
priv->pipeline = gst_parse_launch (desc, &error);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_warning ("Error parsing pipeline description: %s\n", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* get a bunch of elements from the bin */
|
||||||
|
priv->source = gst_bin_get_by_name (GST_BIN (priv->pipeline), "source");
|
||||||
|
g_assert (GST_IS_ELEMENT (priv->source));
|
||||||
|
g_object_set (G_OBJECT (priv->source), "location", priv->location, NULL);
|
||||||
|
priv->decoder = gst_bin_get_by_name (GST_BIN (priv->pipeline), "decoder");
|
||||||
|
g_assert (GST_IS_ELEMENT (priv->decoder));
|
||||||
|
priv->fakesink = gst_bin_get_by_name (GST_BIN (priv->pipeline), "sink");
|
||||||
|
g_assert (GST_IS_ELEMENT (priv->fakesink));
|
||||||
|
|
||||||
|
/* get the "source " source pad */
|
||||||
|
priv->source_pad = gst_element_get_pad (priv->source, "src");
|
||||||
|
g_assert (GST_IS_PAD (priv->source_pad));
|
||||||
|
/* get the "decoder" source pad */
|
||||||
|
priv->decoder_pad = gst_element_get_pad (priv->decoder, "src");
|
||||||
|
g_assert (GST_IS_PAD (priv->decoder_pad));
|
||||||
|
GST_DEBUG ("decoder pad: %s:%s", gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->decoder_pad))), gst_pad_get_name (priv->decoder_pad));
|
||||||
|
|
||||||
|
/* attach notify handler */
|
||||||
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
|
||||||
|
G_CALLBACK (deep_notify_callback), info->priv);
|
||||||
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag", G_CALLBACK (found_tag_callback), info->priv);
|
||||||
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "error",
|
||||||
|
G_CALLBACK (error_callback), info->priv);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* typefind functions
|
* typefind functions
|
||||||
|
@ -321,6 +455,9 @@ gmip_find_type_pre (GstMediaInfoPriv *priv)
|
||||||
priv->type = NULL;
|
priv->type = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_assert (priv);
|
||||||
|
g_assert (priv->source);
|
||||||
|
|
||||||
GST_DEBUG ("gmip_find_type_pre: start");
|
GST_DEBUG ("gmip_find_type_pre: start");
|
||||||
/* find out type */
|
/* find out type */
|
||||||
/* FIXME: we could move caps for typefind out of struct and
|
/* FIXME: we could move caps for typefind out of struct and
|
||||||
|
@ -338,6 +475,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv)
|
||||||
g_warning ("Couldn't set to play");
|
g_warning ("Couldn't set to play");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
GST_DEBUG ("moving to STATE_TYPEFIND\n");
|
||||||
priv->state = GST_MEDIA_INFO_STATE_TYPEFIND;
|
priv->state = GST_MEDIA_INFO_STATE_TYPEFIND;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +486,16 @@ gmip_find_type_post (GstMediaInfoPriv *priv)
|
||||||
{
|
{
|
||||||
/*clear up typefind */
|
/*clear up typefind */
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
gst_element_unlink (priv->source, priv->typefind);
|
if (priv->decontainer)
|
||||||
|
{
|
||||||
|
gst_element_unlink (priv->source, priv->decontainer);
|
||||||
|
gst_element_unlink (priv->decontainer, priv->typefind);
|
||||||
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->decontainer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gst_element_unlink (priv->source, priv->typefind);
|
||||||
|
}
|
||||||
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
|
||||||
|
|
||||||
if (priv->type == NULL)
|
if (priv->type == NULL)
|
||||||
|
@ -356,6 +503,7 @@ gmip_find_type_post (GstMediaInfoPriv *priv)
|
||||||
g_warning ("iteration ended, type not found !\n");
|
g_warning ("iteration ended, type not found !\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
GST_DEBUG ("moving to STATE_STREAM\n");
|
||||||
priv->state = GST_MEDIA_INFO_STATE_STREAM;
|
priv->state = GST_MEDIA_INFO_STATE_STREAM;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -450,6 +598,7 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
|
||||||
formats++;
|
formats++;
|
||||||
}
|
}
|
||||||
if (stream->length_tracks == 0) stream->length_tracks = 1;
|
if (stream->length_tracks == 0) stream->length_tracks = 1;
|
||||||
|
|
||||||
/* now get number of bytes from the sink pad to get the bitrate */
|
/* now get number of bytes from the sink pad to get the bitrate */
|
||||||
format = GST_FORMAT_BYTES;
|
format = GST_FORMAT_BYTES;
|
||||||
g_assert (GST_IS_PAD (priv->source_pad));
|
g_assert (GST_IS_PAD (priv->source_pad));
|
||||||
|
@ -465,6 +614,7 @@ gmip_find_stream_post (GstMediaInfoPriv *priv)
|
||||||
double bits = bytes * 8;
|
double bits = bytes * 8;
|
||||||
stream->bitrate = (long) (bits / seconds);
|
stream->bitrate = (long) (bits / seconds);
|
||||||
}
|
}
|
||||||
|
GST_DEBUG ("moving to STATE_METADATA\n");
|
||||||
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
|
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +687,7 @@ gmip_find_track_metadata (GstMediaInfoPriv *priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find streaminfo found by decoder and store in priv->streaminfo */
|
/* find streaminfo found by decoder and store in priv->streaminfo */
|
||||||
/* FIXME: this is an exact copy, so reuse this functioin instead */
|
/* FIXME: this is an exact copy, so reuse this function instead */
|
||||||
gboolean
|
gboolean
|
||||||
gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv)
|
gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv)
|
||||||
{
|
{
|
||||||
|
@ -590,8 +740,8 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
|
||||||
value_end -= value_start;
|
value_end -= value_start;
|
||||||
/* FIXME: check units; this is in seconds */
|
/* FIXME: check units; this is in seconds */
|
||||||
|
|
||||||
gst_caps_set_simple (priv->streaminfo,
|
gst_tag_list_add (priv->streaminfo, GST_TAG_MERGE_REPLACE,
|
||||||
"length", G_TYPE_INT, (int) (value_end / 1E6), NULL);
|
GST_TAG_DURATION, (int) (value_end / 1E6), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,26 +63,25 @@ typedef enum
|
||||||
/* private structure */
|
/* private structure */
|
||||||
struct GstMediaInfoPriv
|
struct GstMediaInfoPriv
|
||||||
{
|
{
|
||||||
GstElement *pipeline;
|
|
||||||
|
|
||||||
GstElement *typefind;
|
GstElement *typefind;
|
||||||
|
|
||||||
GstCaps *type;
|
GstCaps *type;
|
||||||
GstPad *decoder_pad; /* pad for querying decoded caps */
|
|
||||||
GstPad *source_pad; /* pad for querying encoded caps */
|
|
||||||
|
|
||||||
GstCaps *format;
|
GstCaps *format;
|
||||||
GstCaps *metadata;
|
GstTagList *metadata;
|
||||||
gint metadata_iters;
|
gint metadata_iters;
|
||||||
GstCaps *streaminfo;
|
GstTagList *streaminfo;
|
||||||
|
|
||||||
GstElement *decoder; /* will be != NULL during collection */
|
GstElement *pipeline; /* will be != NULL during collection */
|
||||||
|
gchar *pipeline_desc; /* will be != NULL during collection */
|
||||||
GstElement *fakesink; /* so we can get caps from the
|
GstElement *fakesink; /* so we can get caps from the
|
||||||
decoder sink pad */
|
decoder sink pad */
|
||||||
gchar *source_element; /* type of element used as source */
|
gchar *source_name; /* type of element used as source */
|
||||||
GstElement *source;
|
GstElement *source;
|
||||||
|
GstPad *source_pad; /* pad for querying encoded caps */
|
||||||
GHashTable *decoders; /* a table of decoder GstElements */
|
GstElement *decoder;
|
||||||
|
GstPad *decoder_pad; /* pad for querying decoded caps */
|
||||||
|
GstElement *decontainer; /* element to typefind in containers */
|
||||||
|
|
||||||
GstMediaInfoState state; /* current state of state machine */
|
GstMediaInfoState state; /* current state of state machine */
|
||||||
gchar *location; /* location set on the info object */
|
gchar *location; /* location set on the info object */
|
||||||
|
@ -92,6 +91,8 @@ struct GstMediaInfoPriv
|
||||||
|
|
||||||
GstMediaInfoStream *stream; /* total stream properties */
|
GstMediaInfoStream *stream; /* total stream properties */
|
||||||
char *cache; /* location of cache */
|
char *cache; /* location of cache */
|
||||||
|
|
||||||
|
GError *error; /* error for creation problems */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* declarations */
|
/* declarations */
|
||||||
|
@ -106,16 +107,15 @@ void gmi_reset (GstMediaInfo *info);
|
||||||
gboolean gmi_seek_to_track (GstMediaInfo *info,
|
gboolean gmi_seek_to_track (GstMediaInfo *info,
|
||||||
long track);
|
long track);
|
||||||
|
|
||||||
GstElement * gmi_get_decoder (GstMediaInfo *info,
|
gboolean gmi_set_mime (GstMediaInfo *info,
|
||||||
const char *mime);
|
const char *mime);
|
||||||
void gmi_set_decoder (GstMediaInfo *info,
|
|
||||||
GstElement *decoder);
|
|
||||||
void gmi_clear_decoder (GstMediaInfo *info);
|
|
||||||
|
|
||||||
void deep_notify_callback (GObject *object,
|
void deep_notify_callback (GObject *object,
|
||||||
GstObject *origin,
|
GstObject *origin,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GstMediaInfoPriv *priv);
|
GstMediaInfoPriv *priv);
|
||||||
|
void found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv);
|
||||||
|
void error_callback (GObject *element, GstElement *source, GError *error, gchar *debug);
|
||||||
|
|
||||||
gboolean gmip_find_type_pre (GstMediaInfoPriv *priv);
|
gboolean gmip_find_type_pre (GstMediaInfoPriv *priv);
|
||||||
gboolean gmip_find_type_post (GstMediaInfoPriv *priv);
|
gboolean gmip_find_type_post (GstMediaInfoPriv *priv);
|
||||||
|
|
|
@ -4,6 +4,33 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "media-info.h"
|
#include "media-info.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
|
||||||
|
{
|
||||||
|
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 {
|
||||||
|
str = g_strdup_value_contents (
|
||||||
|
gst_tag_list_get_value_index (list, tag, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
|
||||||
|
} else {
|
||||||
|
g_print (" : %s\n", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
info_print (GstMediaInfoStream *stream)
|
info_print (GstMediaInfoStream *stream)
|
||||||
{
|
{
|
||||||
|
@ -27,9 +54,12 @@ info_print (GstMediaInfoStream *stream)
|
||||||
g_print ("- track %d\n", i);
|
g_print ("- track %d\n", i);
|
||||||
track = (GstMediaInfoTrack *) p->data;
|
track = (GstMediaInfoTrack *) p->data;
|
||||||
g_print (" - metadata:\n");
|
g_print (" - metadata:\n");
|
||||||
g_print ("%s\n", gst_caps_to_string (track->metadata));
|
if (track->metadata)
|
||||||
|
gst_tag_list_foreach (track->metadata, print_tag, NULL);
|
||||||
|
else
|
||||||
|
g_print (" (none found)\n");
|
||||||
g_print (" - streaminfo:\n");
|
g_print (" - streaminfo:\n");
|
||||||
g_print ("%s\n", gst_caps_to_string (track->streaminfo));
|
gst_tag_list_foreach (track->streaminfo, print_tag, NULL);
|
||||||
g_print (" - format:\n");
|
g_print (" - format:\n");
|
||||||
g_print ("%s\n", gst_caps_to_string (track->format));
|
g_print ("%s\n", gst_caps_to_string (track->format));
|
||||||
p = p->next;
|
p = p->next;
|
||||||
|
@ -41,14 +71,29 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstMediaInfo *info;
|
GstMediaInfo *info;
|
||||||
GstMediaInfoStream *stream = NULL;
|
GstMediaInfoStream *stream = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_assert (argc > 1);
|
g_assert (argc > 1);
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
|
||||||
gst_media_info_init ();
|
gst_media_info_init ();
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
info = gst_media_info_new (&error);
|
||||||
|
if (error != NULL)
|
||||||
|
{
|
||||||
|
g_print ("Error creating media-info object: %s\n", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (G_IS_OBJECT (info));
|
||||||
|
if (!gst_media_info_set_source (info, "gnomevfssrc"))
|
||||||
|
{
|
||||||
|
g_print ("Could not set gnomevfssrc as a source\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
|
|
||||||
g_print ("stream: %p, &stream: %p\n", stream, &stream);
|
g_print ("stream: %p, &stream: %p\n", stream, &stream);
|
||||||
for (i = 1; i < argc; ++i)
|
for (i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* GStreamer
|
/* GStreamer media-info library
|
||||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
* Copyright (C) 2003,2004 Thomas Vander Stichele <thomas@apestaart.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -48,15 +48,16 @@ enum
|
||||||
|
|
||||||
static guint gst_media_info_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_media_info_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
/* GError stuff */
|
|
||||||
/*
|
/*
|
||||||
|
* all GError stuff
|
||||||
|
*/
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MEDIA_INFO_ERROR_FILE
|
MEDIA_INFO_ERROR_FILE
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
/* GError quark stuff */
|
/* GError quark stuff */
|
||||||
/*
|
|
||||||
static GQuark
|
static GQuark
|
||||||
gst_media_info_error_quark (void)
|
gst_media_info_error_quark (void)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +66,53 @@ gst_media_info_error_quark (void)
|
||||||
quark = g_quark_from_static_string ("gst-media-info-error-quark");
|
quark = g_quark_from_static_string ("gst-media-info-error-quark");
|
||||||
return quark;
|
return quark;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
/* General GError creation */
|
||||||
|
static void
|
||||||
|
gst_media_info_error_create (GError **error, const gchar *message)
|
||||||
|
{
|
||||||
|
/* check if caller wanted an error reported */
|
||||||
|
if (error == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GError creation when element is missing */
|
||||||
|
static void
|
||||||
|
gst_media_info_error_element (const gchar *element, GError **error)
|
||||||
|
{
|
||||||
|
gchar *message;
|
||||||
|
|
||||||
|
message = g_strdup_printf ("The %s element could not be found. "
|
||||||
|
"This element is essential for reading. "
|
||||||
|
"Please install the right plug-in and verify "
|
||||||
|
"that it works by running 'gst-inspect %s'",
|
||||||
|
element, element);
|
||||||
|
gst_media_info_error_create (error, message);
|
||||||
|
g_free (message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* used from the instance_init function to report errors */
|
||||||
|
#define GST_MEDIA_INFO_MAKE_OR_ERROR(el, factory, name, error) \
|
||||||
|
G_STMT_START { \
|
||||||
|
el = gst_element_factory_make (factory, name); \
|
||||||
|
if (!GST_IS_ELEMENT (el)) \
|
||||||
|
{ \
|
||||||
|
gst_media_info_error_element (factory, error); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
#define GST_MEDIA_INFO_ERROR_RETURN(error, message) \
|
||||||
|
G_STMT_START { \
|
||||||
|
gst_media_info_error_create (error, message); \
|
||||||
|
return FALSE; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GObject type stuff
|
* GObject type stuff
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +125,8 @@ enum
|
||||||
static GObjectClass *parent_class = NULL;
|
static GObjectClass *parent_class = NULL;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY (gst_media_info_debug);
|
GST_DEBUG_CATEGORY (gst_media_info_debug);
|
||||||
|
|
||||||
|
/* initialize the media-info library */
|
||||||
void
|
void
|
||||||
gst_media_info_init (void)
|
gst_media_info_init (void)
|
||||||
{
|
{
|
||||||
|
@ -145,53 +194,35 @@ gst_media_info_class_init (GstMediaInfoClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_media_info_instance_init (GstMediaInfo *info)
|
gst_media_info_instance_init (GstMediaInfo *info)
|
||||||
{
|
{
|
||||||
GstElement *source;
|
GError **error;
|
||||||
|
|
||||||
info->priv = g_new0 (GstMediaInfoPriv, 1);
|
info->priv = g_new0 (GstMediaInfoPriv, 1);
|
||||||
|
error = &info->priv->error;
|
||||||
|
|
||||||
info->priv->pipeline = gst_pipeline_new ("media-info");
|
info->priv->pipeline = gst_pipeline_new ("media-info");
|
||||||
|
|
||||||
/* create the typefind element and make sure it stays around by reffing */
|
/* create the typefind element and make sure it stays around by reffing */
|
||||||
info->priv->typefind = gst_element_factory_make ("typefind", "typefind");
|
GST_MEDIA_INFO_MAKE_OR_ERROR (info->priv->typefind, "typefind", "typefind", error);
|
||||||
if (!GST_IS_ELEMENT (info->priv->typefind))
|
|
||||||
g_error ("Cannot create typefind element !");
|
|
||||||
gst_object_ref (GST_OBJECT (info->priv->typefind));
|
gst_object_ref (GST_OBJECT (info->priv->typefind));
|
||||||
|
|
||||||
/* create the fakesink element and make sure it stays around by reffing */
|
/* create the fakesink element and make sure it stays around by reffing */
|
||||||
info->priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
|
GST_MEDIA_INFO_MAKE_OR_ERROR (info->priv->fakesink, "fakesink", "fakesink", error);
|
||||||
if (!GST_IS_ELEMENT (info->priv->fakesink))
|
|
||||||
g_error ("Cannot create fakesink element !");
|
|
||||||
gst_object_ref (GST_OBJECT (info->priv->fakesink));
|
gst_object_ref (GST_OBJECT (info->priv->fakesink));
|
||||||
|
|
||||||
|
/* source element for media info reading */
|
||||||
|
info->priv->source = NULL;
|
||||||
|
info->priv->source_name = NULL;
|
||||||
|
|
||||||
/* use gnomevfssrc by default */
|
|
||||||
source = gst_element_factory_make ("gnomevfssrc", "source");
|
|
||||||
if (GST_IS_ELEMENT (source))
|
|
||||||
{
|
|
||||||
info->priv->source = source;
|
|
||||||
info->priv->source_element = g_strdup ("gnomevfssrc");
|
|
||||||
gst_bin_add (GST_BIN (info->priv->pipeline), info->priv->source);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info->priv->source = NULL;
|
|
||||||
info->priv->source_element = NULL;
|
|
||||||
}
|
|
||||||
info->priv->location = NULL;
|
info->priv->location = NULL;
|
||||||
info->priv->decoder = NULL;
|
|
||||||
info->priv->type = NULL;
|
info->priv->type = NULL;
|
||||||
info->priv->format = NULL;
|
info->priv->format = NULL;
|
||||||
info->priv->metadata = NULL;
|
info->priv->metadata = NULL;
|
||||||
|
info->priv->pipeline_desc = NULL;
|
||||||
|
|
||||||
/* clear result pointers */
|
/* clear result pointers */
|
||||||
info->priv->stream = NULL;
|
info->priv->stream = NULL;
|
||||||
|
|
||||||
/* set up decoder hash table */
|
info->priv->error = NULL;
|
||||||
info->priv->decoders = g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
|
|
||||||
/* attach notify handler */
|
|
||||||
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
|
|
||||||
G_CALLBACK (deep_notify_callback), info->priv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get/set */
|
/* get/set */
|
||||||
|
@ -204,7 +235,7 @@ gst_media_info_get_property (GObject *object, guint prop_id,
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_SOURCE:
|
case PROP_SOURCE:
|
||||||
g_value_set_string (value, info->priv->source_element);
|
g_value_set_string (value, info->priv->source_name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -213,12 +244,24 @@ gst_media_info_get_property (GObject *object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
GstMediaInfo *
|
GstMediaInfo *
|
||||||
gst_media_info_new (const gchar *source_element)
|
gst_media_info_new (GError **error)
|
||||||
{
|
{
|
||||||
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
|
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
|
||||||
if (source_element)
|
|
||||||
g_object_set (G_OBJECT (info), "source", source_element);
|
|
||||||
|
|
||||||
|
if (info->priv->error)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
*error = info->priv->error;
|
||||||
|
info->priv->error = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_warning ("Error creating GstMediaInfo object.\n%s",
|
||||||
|
info->priv->error->message);
|
||||||
|
g_error_free (info->priv->error);
|
||||||
|
}
|
||||||
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,16 +280,16 @@ gst_media_info_set_source (GstMediaInfo *info, const char *source)
|
||||||
{
|
{
|
||||||
/* this also unrefs the element */
|
/* this also unrefs the element */
|
||||||
gst_bin_remove (GST_BIN (info->priv->pipeline), info->priv->source);
|
gst_bin_remove (GST_BIN (info->priv->pipeline), info->priv->source);
|
||||||
if (info->priv->source_element)
|
if (info->priv->source_name)
|
||||||
{
|
{
|
||||||
g_free (info->priv->source_element);
|
g_free (info->priv->source_name);
|
||||||
info->priv->source_element = NULL;
|
info->priv->source_name = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_object_set (G_OBJECT (src), "name", "source", NULL);
|
g_object_set (G_OBJECT (src), "name", "source", NULL);
|
||||||
gst_bin_add (GST_BIN (info->priv->pipeline), src);
|
gst_bin_add (GST_BIN (info->priv->pipeline), src);
|
||||||
info->priv->source = src;
|
info->priv->source = src;
|
||||||
info->priv->source_element = g_strdup (source);
|
info->priv->source_name = g_strdup (source);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -275,26 +318,27 @@ gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
|
||||||
gboolean
|
gboolean
|
||||||
gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
|
gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
|
||||||
{
|
{
|
||||||
GstMediaInfoPriv *priv ;
|
GstMediaInfoPriv *priv;
|
||||||
/* if it's NULL then we're sure something went wrong higher up) */
|
/* if it's NULL then we're sure something went wrong higher up) */
|
||||||
if (info == NULL) return FALSE;
|
if (info == NULL) return FALSE;
|
||||||
|
|
||||||
priv = info->priv;
|
priv = info->priv;
|
||||||
|
|
||||||
g_assert (streamp != NULL);
|
g_assert (streamp != NULL);
|
||||||
|
g_assert (priv);
|
||||||
|
|
||||||
switch (priv->state)
|
switch (priv->state)
|
||||||
{
|
{
|
||||||
case GST_MEDIA_INFO_STATE_NULL:
|
case GST_MEDIA_INFO_STATE_NULL:
|
||||||
/* need to find type */
|
/* need to find type */
|
||||||
GST_DEBUG ("idler: NULL, need to find type");
|
GST_DEBUG ("idler: NULL, need to find type, priv %p", priv);
|
||||||
return gmip_find_type_pre (priv);
|
return gmip_find_type_pre (priv);
|
||||||
|
|
||||||
case GST_MEDIA_INFO_STATE_TYPEFIND:
|
case GST_MEDIA_INFO_STATE_TYPEFIND:
|
||||||
{
|
{
|
||||||
gchar *mime;
|
gchar *mime;
|
||||||
GstElement *decoder;
|
|
||||||
|
|
||||||
GST_DEBUG ("STATE_TYPEFIND");
|
GST_LOG ("STATE_TYPEFIND");
|
||||||
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
||||||
{
|
{
|
||||||
GST_DEBUG ("iterating while in STATE_TYPEFIND");
|
GST_DEBUG ("iterating while in STATE_TYPEFIND");
|
||||||
|
@ -313,24 +357,22 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
|
||||||
mime = g_strdup (gst_structure_get_name (
|
mime = g_strdup (gst_structure_get_name (
|
||||||
gst_caps_get_structure(priv->type, 0)));
|
gst_caps_get_structure(priv->type, 0)));
|
||||||
GST_DEBUG ("found out mime type: %s", mime);
|
GST_DEBUG ("found out mime type: %s", mime);
|
||||||
decoder = gmi_get_decoder (info, mime);
|
if (!gmi_set_mime (info, mime))
|
||||||
if (decoder == NULL)
|
|
||||||
{
|
{
|
||||||
/* FIXME: pop up error */
|
/* FIXME: pop up error */
|
||||||
GST_DEBUG ("no decoder found for mime %s", mime);
|
GST_DEBUG ("no decoder pipeline found for mime %s", mime);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
priv->stream = gmi_stream_new ();
|
priv->stream = gmi_stream_new ();
|
||||||
GST_DEBUG ("new stream: %p", priv->stream);
|
GST_DEBUG ("new stream: %p", priv->stream);
|
||||||
priv->stream->mime = mime;
|
priv->stream->mime = mime;
|
||||||
priv->stream->path = priv->location;
|
priv->stream->path = priv->location;
|
||||||
gmi_set_decoder (info, decoder);
|
|
||||||
|
|
||||||
gmip_find_stream_pre (priv);
|
gmip_find_stream_pre (priv);
|
||||||
}
|
}
|
||||||
case GST_MEDIA_INFO_STATE_STREAM:
|
case GST_MEDIA_INFO_STATE_STREAM:
|
||||||
{
|
{
|
||||||
GST_DEBUG ("STATE_STREAM");
|
GST_LOG ("STATE_STREAM");
|
||||||
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
||||||
{
|
{
|
||||||
GMI_DEBUG("?");
|
GMI_DEBUG("?");
|
||||||
|
@ -368,7 +410,7 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
|
||||||
}
|
}
|
||||||
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
|
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
|
||||||
if (!gmip_find_track_metadata_post (priv)) return FALSE;
|
if (!gmip_find_track_metadata_post (priv)) return FALSE;
|
||||||
GST_DEBUG ("METADATA: going to STREAMINFO");
|
GST_DEBUG ("METADATA: going to STREAMINFO\n");
|
||||||
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
|
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
|
||||||
return gmip_find_track_streaminfo_pre (priv);
|
return gmip_find_track_streaminfo_pre (priv);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +472,6 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
|
||||||
*streamp = priv->stream;
|
*streamp = priv->stream;
|
||||||
priv->stream = NULL;
|
priv->stream = NULL;
|
||||||
GST_DEBUG ("TOTALLY DONE, setting pointer *streamp to %p", *streamp);
|
GST_DEBUG ("TOTALLY DONE, setting pointer *streamp to %p", *streamp);
|
||||||
gmi_clear_decoder (info);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case GST_MEDIA_INFO_STATE_DONE:
|
case GST_MEDIA_INFO_STATE_DONE:
|
||||||
|
@ -464,8 +505,8 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags)
|
||||||
gst_caps_get_structure(priv->type, 0)));
|
gst_caps_get_structure(priv->type, 0)));
|
||||||
GST_DEBUG ("mime type: %s", mime);
|
GST_DEBUG ("mime type: %s", mime);
|
||||||
|
|
||||||
/* c) figure out decoder */
|
/* c) figure out decoding pipeline */
|
||||||
decoder = gmi_get_decoder (info, mime);
|
//FIXMEdecoder = gmi_get_pipeline_description (info, mime);
|
||||||
g_print ("DEBUG: using decoder %s\n", gst_element_get_name (decoder));
|
g_print ("DEBUG: using decoder %s\n", gst_element_get_name (decoder));
|
||||||
|
|
||||||
/* if it's NULL, then that's a sign we can't decode it */
|
/* if it's NULL, then that's a sign we can't decode it */
|
||||||
|
@ -481,7 +522,8 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags)
|
||||||
priv->stream->path = priv->location;
|
priv->stream->path = priv->location;
|
||||||
|
|
||||||
/* install this decoder in the pipeline */
|
/* install this decoder in the pipeline */
|
||||||
gmi_set_decoder (info, decoder);
|
|
||||||
|
//FIXME: use new systemgmi_set_decoder (info, decoder);
|
||||||
|
|
||||||
/* collect total stream properties */
|
/* collect total stream properties */
|
||||||
/* d) get all stream properties */
|
/* d) get all stream properties */
|
||||||
|
@ -509,8 +551,6 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags)
|
||||||
priv->current_track = NULL;
|
priv->current_track = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* f) clear decoder */
|
|
||||||
gmi_clear_decoder (info);
|
|
||||||
/* please return it */
|
/* please return it */
|
||||||
stream = priv->stream;
|
stream = priv->stream;
|
||||||
priv->stream = NULL;
|
priv->stream = NULL;
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct _GstMediaInfoClass
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (*media_info_signal) (GstMediaInfo *gst_media_info);
|
void (*media_info_signal) (GstMediaInfo *gst_media_info);
|
||||||
|
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
@ -68,8 +68,8 @@ typedef struct
|
||||||
* or one of a set of sequentially muxed streams */
|
* or one of a set of sequentially muxed streams */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GstCaps *metadata; /* changeable metadata or tags */
|
GstTagList *metadata; /* changeable metadata or tags */
|
||||||
GstCaps *streaminfo; /* codec property stuff */
|
GstTagList *streaminfo; /* codec property stuff */
|
||||||
GstCaps *format; /* properties of the logical stream */
|
GstCaps *format; /* properties of the logical stream */
|
||||||
|
|
||||||
guint64 length_time;
|
guint64 length_time;
|
||||||
|
@ -102,8 +102,9 @@ typedef struct
|
||||||
void gst_media_info_init (void);
|
void gst_media_info_init (void);
|
||||||
GType gst_media_info_get_type (void);
|
GType gst_media_info_get_type (void);
|
||||||
|
|
||||||
GstMediaInfo * gst_media_info_new (const char *source_element);
|
GstMediaInfo * gst_media_info_new (GError **error);
|
||||||
|
|
||||||
|
gboolean gst_media_info_set_source (GstMediaInfo *info, const char *source);
|
||||||
void gst_media_info_read_with_idler (GstMediaInfo *media_info,
|
void gst_media_info_read_with_idler (GstMediaInfo *media_info,
|
||||||
const char *location,
|
const char *location,
|
||||||
guint16 GST_MEDIA_INFO_FLAGS);
|
guint16 GST_MEDIA_INFO_FLAGS);
|
||||||
|
|
Loading…
Reference in a new issue