2003-09-23 22:49:35 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* media-info-priv.c - handling of internal stuff */
|
|
|
|
|
2003-11-07 12:47:02 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "media-info.h"
|
|
|
|
#include "media-info-priv.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* helper structs bits */
|
|
|
|
GstMediaInfoStream *
|
|
|
|
gmi_stream_new (void)
|
|
|
|
{
|
|
|
|
GstMediaInfoStream *stream;
|
|
|
|
|
|
|
|
stream = (GstMediaInfoStream *) g_malloc (sizeof (GstMediaInfoStream));
|
|
|
|
|
|
|
|
stream->length_tracks = 0;
|
|
|
|
stream->length_time = 0;
|
|
|
|
stream->bitrate = 0;
|
|
|
|
stream->seekable = FALSE;
|
|
|
|
stream->path = NULL;
|
|
|
|
stream->mime = NULL;
|
|
|
|
stream->tracks = NULL;
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
gmi_stream_free (GstMediaInfoStream * stream)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (stream->mime)
|
|
|
|
g_free (stream->mime);
|
2003-09-23 22:49:35 +00:00
|
|
|
/* FIXME: free tracks */
|
|
|
|
g_free (stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
GstMediaInfoTrack *
|
|
|
|
gmi_track_new (void)
|
|
|
|
{
|
|
|
|
GstMediaInfoTrack *track;
|
|
|
|
|
|
|
|
track = g_malloc (sizeof (GstMediaInfoTrack));
|
|
|
|
|
|
|
|
track->metadata = NULL;
|
|
|
|
track->streaminfo = NULL;
|
|
|
|
track->format = NULL;
|
|
|
|
track->length_time = 0;
|
|
|
|
track->con_streams = NULL;
|
|
|
|
|
|
|
|
return track;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* private functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
|
|
|
|
GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
GstStructure *str;
|
|
|
|
const gchar *mime;
|
|
|
|
|
2004-01-22 19:00:27 +00:00
|
|
|
priv->type = gst_caps_copy (type);
|
2004-03-06 20:15:17 +00:00
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
if (strcmp (mime, "application/x-id3") == 0) {
|
2004-03-06 20:15:17 +00:00
|
|
|
/* 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");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind,
|
2004-03-15 19:32:27 +00:00
|
|
|
NULL));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning ("Couldn't link in id3tag");
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-15 19:32:27 +00:00
|
|
|
== GST_STATE_FAILURE)
|
2004-03-06 20:15:17 +00:00
|
|
|
g_warning ("Couldn't set to playing");
|
|
|
|
}
|
|
|
|
#endif
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
deep_notify_callback (GObject * object, GstObject * origin,
|
|
|
|
GParamSpec * pspec, GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
2004-01-22 19:00:27 +00:00
|
|
|
/* we only care about pad notifies */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!GST_IS_PAD (origin))
|
|
|
|
return;
|
2004-01-22 19:00:27 +00:00
|
|
|
|
2004-03-06 20:15:17 +00:00
|
|
|
/*
|
2004-03-14 22:34:33 +00:00
|
|
|
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))),
|
|
|
|
gst_object_get_name (origin));
|
|
|
|
*/
|
|
|
|
else if (strcmp (pspec->name, "caps") == 0) {
|
2004-03-06 20:15:17 +00:00
|
|
|
/* check if we're getting it from fakesink */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink) {
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("have caps on fakesink pad !");
|
2003-09-23 22:49:35 +00:00
|
|
|
g_value_init (&value, pspec->value_type);
|
|
|
|
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
|
|
|
|
priv->format = g_value_peek_pointer (&value);
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("caps: %" GST_PTR_FORMAT, priv->format);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else
|
|
|
|
GST_DEBUG ("ignoring caps on object %s:%s",
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_object_get_name (gst_object_get_parent (origin)),
|
|
|
|
gst_object_get_name (origin));
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (strcmp (pspec->name, "offset") == 0) {
|
2003-09-23 22:49:35 +00:00
|
|
|
/* we REALLY ignore offsets, we hate them */
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
//else GST_DEBUG ("ignoring notify of %s", pspec->name);
|
2004-03-06 20:15:17 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
guint meta;
|
|
|
|
guint encoded;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
|
|
|
TagFlagScore;
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
tag_flag_score (const GstTagList * list, const gchar * tag, gpointer user_data)
|
2004-03-06 20:15:17 +00:00
|
|
|
{
|
|
|
|
TagFlagScore *score = (TagFlagScore *) user_data;
|
|
|
|
GstTagFlag flag;
|
|
|
|
|
|
|
|
flag = gst_tag_get_flag (tag);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flag == GST_TAG_FLAG_META)
|
|
|
|
score->meta++;
|
|
|
|
if (flag == GST_TAG_FLAG_ENCODED)
|
|
|
|
score->encoded++;
|
2004-03-06 20:15:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
found_tag_callback (GObject * pipeline, GstElement * source, GstTagList * tags,
|
|
|
|
GstMediaInfoPriv * priv)
|
2004-03-06 20:15:17 +00:00
|
|
|
{
|
|
|
|
TagFlagScore score;
|
|
|
|
|
|
|
|
score.meta = 0;
|
|
|
|
score.encoded = 0;
|
2004-03-07 20:51:10 +00:00
|
|
|
GST_DEBUG ("element %s found tag", GST_STR_NULL (GST_ELEMENT_NAME (source)));
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (score.meta > score.encoded) {
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("found tags from decoder, adding them as metadata");
|
|
|
|
priv->metadata = gst_tag_list_copy (tags);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("found tags, adding them as streaminfo");
|
|
|
|
priv->streaminfo = gst_tag_list_copy (tags);
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-06 20:15:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
error_callback (GObject * element, GstElement * source, GError * error,
|
|
|
|
gchar * debug, GstMediaInfoPriv * priv)
|
2004-03-06 20:15:17 +00:00
|
|
|
{
|
|
|
|
g_print ("ERROR: %s\n", error->message);
|
2004-03-07 20:51:10 +00:00
|
|
|
g_error_free (error);
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* helpers */
|
|
|
|
|
2004-03-07 20:51:10 +00:00
|
|
|
/* General GError creation */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_error_create (GError ** error, const gchar * message)
|
2004-03-07 20:51:10 +00:00
|
|
|
{
|
|
|
|
/* 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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_error_element (const gchar * element, GError ** error)
|
2004-03-07 20:51:10 +00:00
|
|
|
{
|
|
|
|
gchar *message;
|
|
|
|
|
|
|
|
message = g_strdup_printf ("The %s element could not be found. "
|
2004-03-14 22:34:33 +00:00
|
|
|
"This element is essential for reading. "
|
|
|
|
"Please install the right plug-in and verify "
|
|
|
|
"that it works by running 'gst-inspect %s'", element, element);
|
2004-03-07 20:51:10 +00:00
|
|
|
gst_media_info_error_create (error, message);
|
|
|
|
g_free (message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialise priv; done the first time */
|
2004-03-07 21:05:40 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_init (GstMediaInfoPriv * priv, GError ** error)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-03-07 20:51:10 +00:00
|
|
|
#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); \
|
2004-03-07 21:05:40 +00:00
|
|
|
return FALSE; \
|
2004-03-07 20:51:10 +00:00
|
|
|
} \
|
|
|
|
} G_STMT_END
|
|
|
|
/* create the typefind element and make sure it stays around by reffing */
|
|
|
|
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->typefind, "typefind", "typefind", error);
|
|
|
|
gst_object_ref (GST_OBJECT (priv->typefind));
|
|
|
|
|
|
|
|
/* create the fakesink element and make sure it stays around by reffing */
|
|
|
|
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->fakesink, "fakesink", "fakesink", error);
|
|
|
|
gst_object_ref (GST_OBJECT (priv->fakesink));
|
|
|
|
/* source element for media info reading */
|
|
|
|
priv->source = NULL;
|
|
|
|
priv->source_name = NULL;
|
2004-03-07 21:05:40 +00:00
|
|
|
return TRUE;
|
2004-03-07 20:51:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called at the beginning of each use cycle */
|
|
|
|
/* reset info to a state where it can be used to query for media info */
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_reset (GstMediaInfoPriv * priv)
|
2004-03-07 20:51:10 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
#define STRING_RESET(string) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (string) g_free (string); \
|
|
|
|
string = NULL; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
STRING_RESET (priv->pipeline_desc);
|
|
|
|
STRING_RESET (priv->location);
|
2004-03-07 20:51:10 +00:00
|
|
|
#undef STRING_RESET
|
|
|
|
|
|
|
|
#define CAPS_RESET(target) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (target) gst_caps_free (target); \
|
|
|
|
target = NULL; \
|
|
|
|
} G_STMT_END
|
2004-03-14 22:34:33 +00:00
|
|
|
CAPS_RESET (priv->type);
|
|
|
|
CAPS_RESET (priv->format);
|
2004-03-07 20:51:10 +00:00
|
|
|
#undef CAPS_RESET
|
|
|
|
|
|
|
|
#define TAGS_RESET(target) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (target) \
|
|
|
|
gst_tag_list_free (target); \
|
|
|
|
target = NULL; \
|
|
|
|
} G_STMT_END
|
2004-03-14 22:34:33 +00:00
|
|
|
TAGS_RESET (priv->metadata);
|
|
|
|
TAGS_RESET (priv->streaminfo);
|
2004-03-07 20:51:10 +00:00
|
|
|
#undef TAGS_RESET
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->stream) {
|
2004-03-07 20:51:10 +00:00
|
|
|
gmi_stream_free (priv->stream);
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->stream = NULL;
|
|
|
|
}
|
|
|
|
priv->flags = 0;
|
|
|
|
priv->state = GST_MEDIA_INFO_STATE_NULL;
|
2004-03-07 20:51:10 +00:00
|
|
|
|
|
|
|
priv->error = NULL;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* seek to a track and reset metadata and streaminfo structs */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmi_seek_to_track (GstMediaInfo * info, long track)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstFormat track_format = 0;
|
|
|
|
GstMediaInfoPriv *priv = info->priv;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
/* FIXME: consider more nicks as "track" */
|
|
|
|
track_format = gst_format_get_by_nick ("logical_stream");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (track_format == 0)
|
|
|
|
return FALSE;
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("Track format: %d", track_format);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE)
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
g_assert (GST_IS_PAD (info->priv->decoder_pad));
|
|
|
|
event = gst_event_new_seek (track_format |
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, track);
|
2003-09-23 22:49:35 +00:00
|
|
|
res = gst_pad_send_event (info->priv->decoder_pad, event);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!res) {
|
2003-10-31 20:03:29 +00:00
|
|
|
g_warning ("seek to logical track on pad %s:%s failed",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG_PAD_NAME (info->priv->decoder_pad));
|
2003-09-23 22:49:35 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* clear structs because of the seek */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->metadata) {
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_tag_list_free (priv->metadata);
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->metadata = NULL;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->streaminfo) {
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_tag_list_free (priv->streaminfo);
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->streaminfo = NULL;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-06 20:15:17 +00:00
|
|
|
/* set the mime type on the media info getter */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmi_set_mime (GstMediaInfo * info, const char *mime)
|
2004-03-06 20:15:17 +00:00
|
|
|
{
|
|
|
|
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))
|
2004-03-14 22:34:33 +00:00
|
|
|
desc =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup_printf
|
|
|
|
("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink",
|
|
|
|
priv->source_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
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 =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup_printf
|
|
|
|
("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink",
|
|
|
|
priv->source_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
else if ((strcmp (mime, "application/x-flac") == 0)
|
|
|
|
|| (strcmp (mime, "audio/x-flac") == 0))
|
|
|
|
desc =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup_printf
|
|
|
|
("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink",
|
|
|
|
priv->source_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
else if ((strcmp (mime, "audio/wav") == 0)
|
|
|
|
|| (strcmp (mime, "audio/x-wav") == 0))
|
|
|
|
desc =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup_printf
|
2004-06-25 11:57:25 +00:00
|
|
|
("%s name=source ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink",
|
2004-03-15 19:32:27 +00:00
|
|
|
priv->source_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
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 =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup_printf
|
|
|
|
("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink",
|
|
|
|
priv->source_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("using description %s", desc);
|
|
|
|
priv->pipeline_desc = desc;
|
|
|
|
priv->pipeline = gst_parse_launch (desc, &error);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (error) {
|
2004-03-06 20:15:17 +00:00
|
|
|
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");
|
2004-06-01 08:51:55 +00:00
|
|
|
if (!GST_IS_ELEMENT (priv->source))
|
|
|
|
g_error ("Could not create source element '%s'", priv->source_name);
|
|
|
|
|
2004-03-06 20:15:17 +00:00
|
|
|
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));
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("decoder pad: %s:%s",
|
|
|
|
gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->
|
2004-03-15 19:32:27 +00:00
|
|
|
decoder_pad))), gst_pad_get_name (priv->decoder_pad));
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
/* attach notify handler */
|
|
|
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
|
2004-03-14 22:34:33 +00:00
|
|
|
G_CALLBACK (deep_notify_callback), info->priv);
|
|
|
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag",
|
|
|
|
G_CALLBACK (found_tag_callback), info->priv);
|
2004-03-06 20:15:17 +00:00
|
|
|
g_signal_connect (G_OBJECT (info->priv->pipeline), "error",
|
2004-03-14 22:34:33 +00:00
|
|
|
G_CALLBACK (error_callback), info->priv);
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-07 20:51:10 +00:00
|
|
|
/* clear the decoding pipeline */
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
gmi_clear_decoder (GstMediaInfo * info)
|
2004-03-07 20:51:10 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (info->priv->pipeline) {
|
|
|
|
GST_DEBUG ("Unreffing pipeline");
|
2004-03-07 20:51:10 +00:00
|
|
|
gst_object_unref (GST_OBJECT (info->priv->pipeline));
|
|
|
|
}
|
|
|
|
info->priv->pipeline = NULL;
|
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
/****
|
|
|
|
* typefind functions
|
|
|
|
* find the type of a file and store it in the caps of the info
|
|
|
|
* FIXME: we might better return GstCaps instead of storing them
|
|
|
|
* internally */
|
|
|
|
|
|
|
|
/* prepare for typefind, move from NULL to TYPEFIND */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-03-07 20:51:10 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2004-03-06 20:15:17 +00:00
|
|
|
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("gmip_find_type_pre: start");
|
2003-09-23 22:49:35 +00:00
|
|
|
/* find out type */
|
|
|
|
/* FIXME: we could move caps for typefind out of struct and
|
|
|
|
* just use it through this function only */
|
|
|
|
|
2004-03-07 20:51:10 +00:00
|
|
|
priv->pipeline = gst_pipeline_new ("pipeline-typefind");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!GST_IS_PIPELINE (priv->pipeline)) {
|
2004-03-07 20:51:10 +00:00
|
|
|
gst_media_info_error_create (error, "Internal GStreamer error.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->typefind);
|
2004-03-07 20:51:10 +00:00
|
|
|
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->source, priv->source_name, "source",
|
2004-03-14 22:34:33 +00:00
|
|
|
error);
|
2003-09-23 22:49:35 +00:00
|
|
|
g_object_set (G_OBJECT (priv->source), "location", priv->location, NULL);
|
2004-03-07 20:51:10 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->source);
|
2003-09-23 22:49:35 +00:00
|
|
|
if (!gst_element_link (priv->source, priv->typefind))
|
|
|
|
g_warning ("Couldn't connect source and typefind\n");
|
|
|
|
g_signal_connect (G_OBJECT (priv->typefind), "have-type",
|
2004-03-14 22:34:33 +00:00
|
|
|
G_CALLBACK (have_type_callback), priv);
|
2003-09-23 22:49:35 +00:00
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("moving to STATE_TYPEFIND\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->state = GST_MEDIA_INFO_STATE_TYPEFIND;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* finish off typefind */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_type_post (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
/*clear up typefind */
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->decontainer) {
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_element_unlink (priv->source, priv->decontainer);
|
|
|
|
gst_element_unlink (priv->decontainer, priv->typefind);
|
|
|
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->decontainer);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2004-03-06 20:15:17 +00:00
|
|
|
gst_element_unlink (priv->source, priv->typefind);
|
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->type == NULL) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("iteration ended, type not found !\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("moving to STATE_STREAM\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->state = GST_MEDIA_INFO_STATE_STREAM;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* complete version */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_type (GstMediaInfoPriv * priv, GError ** error)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-03-07 20:51:10 +00:00
|
|
|
if (!gmip_find_type_pre (priv, error))
|
2003-09-23 22:49:35 +00:00
|
|
|
return FALSE;
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("gmip_find_type: iterating");
|
2004-03-14 22:34:33 +00:00
|
|
|
while ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
|
|
|
GMI_DEBUG ("+");
|
|
|
|
GMI_DEBUG ("\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
return gmip_find_type_post (priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: why not have these functions work on priv types ? */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_stream_pre (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
priv->state = GST_MEDIA_INFO_STATE_STREAM;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_stream_post (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
GstMediaInfoStream *stream = priv->stream;
|
|
|
|
const GstFormat *formats;
|
|
|
|
GstFormat track_format = 0;
|
|
|
|
GstFormat format;
|
|
|
|
gint64 value;
|
|
|
|
gboolean res;
|
|
|
|
glong bytes = 0;
|
|
|
|
|
|
|
|
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("gmip_find_stream_post: start");
|
2003-09-23 22:49:35 +00:00
|
|
|
/* find a format that matches the "track" concept */
|
|
|
|
/* FIXME: this is used in vorbis, but we might have to loop when
|
|
|
|
* more codecs have tracks */
|
|
|
|
track_format = gst_format_get_by_nick ("logical_stream");
|
|
|
|
|
|
|
|
/* get supported formats on decoder pad */
|
|
|
|
formats = gst_pad_get_formats (priv->decoder_pad);
|
2004-03-14 22:34:33 +00:00
|
|
|
while (*formats) {
|
2003-09-23 22:49:35 +00:00
|
|
|
const GstFormatDefinition *definition;
|
|
|
|
|
|
|
|
format = *formats;
|
|
|
|
|
|
|
|
g_assert (GST_IS_PAD (priv->decoder_pad));
|
|
|
|
definition = gst_format_get_details (*formats);
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("trying to figure out length for format %s", definition->nick);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL, &format, &value);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (res) {
|
|
|
|
switch (format) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
stream->length_time = value;
|
|
|
|
GST_DEBUG (" total %s: %lld", definition->nick, value);
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* separation is necessary because track_format doesn't resolve to
|
|
|
|
* int */
|
|
|
|
if (format == track_format) {
|
|
|
|
stream->length_tracks = value;
|
|
|
|
GST_DEBUG (" total %s: %lld", definition->nick, value);
|
|
|
|
} else
|
|
|
|
GST_DEBUG ("unhandled format %s", definition->nick);
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
} else
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("query didn't return result for %s", definition->nick);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
formats++;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (stream->length_tracks == 0)
|
|
|
|
stream->length_tracks = 1;
|
2004-03-06 20:15:17 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* now get number of bytes from the sink pad to get the bitrate */
|
|
|
|
format = GST_FORMAT_BYTES;
|
|
|
|
g_assert (GST_IS_PAD (priv->source_pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL, &format, &value);
|
|
|
|
if (!res)
|
|
|
|
g_warning ("Failed to query on sink pad !");
|
2003-09-23 22:49:35 +00:00
|
|
|
bytes = value;
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("bitrate calc: bytes gotten: %ld", bytes);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (bytes) {
|
2003-09-23 22:49:35 +00:00
|
|
|
double seconds = (double) stream->length_time / GST_SECOND;
|
|
|
|
double bits = bytes * 8;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
stream->bitrate = (long) (bits / seconds);
|
|
|
|
}
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("moving to STATE_METADATA\n");
|
2004-03-15 19:32:27 +00:00
|
|
|
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
|
2003-09-23 22:49:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get properties of complete physical stream
|
|
|
|
* and return them in pre-alloced stream struct in priv->stream */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_stream (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("mip_find_stream start");
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
gmip_find_stream_pre (priv);
|
|
|
|
/* iterate until caps are found */
|
|
|
|
/* FIXME: this should be done through the plugin sending some signal
|
|
|
|
* that it is ready for queries */
|
2004-03-14 22:34:33 +00:00
|
|
|
while (gst_bin_iterate (GST_BIN (priv->pipeline)) && priv->format == NULL);
|
2003-09-23 22:49:35 +00:00
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE)
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to paused");
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->format == NULL) {
|
|
|
|
GMI_DEBUG ("gmip_find_stream: couldn't get caps !");
|
2003-09-23 22:49:35 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return gmip_find_stream_post (priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find metadata encoded in media and store in priv->metadata */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_metadata_pre (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
/* FIXME: this is a hack to set max allowed iterations for metadata
|
|
|
|
* querying - we should make gst smarter by itself instead */
|
|
|
|
priv->metadata_iters = 0;
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_metadata_post (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE)
|
2003-09-23 22:49:35 +00:00
|
|
|
return FALSE;
|
|
|
|
priv->current_track->metadata = priv->metadata;
|
|
|
|
priv->metadata = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_metadata (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
gmip_find_track_metadata_pre (priv);
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("gmip_find_metadata: iterating");
|
2004-03-14 22:34:33 +00:00
|
|
|
while ((priv->metadata == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
|
|
|
GMI_DEBUG ("+");
|
|
|
|
GMI_DEBUG ("\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
gmip_find_track_metadata_post (priv);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find streaminfo found by decoder and store in priv->streaminfo */
|
2004-03-06 20:15:17 +00:00
|
|
|
/* FIXME: this is an exact copy, so reuse this function instead */
|
2003-09-23 22:49:35 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
GstFormat format, track_format;
|
|
|
|
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
/* now add total length to this, and maybe even bitrate ? FIXME */
|
|
|
|
track_format = gst_format_get_by_nick ("logical_stream");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (track_format == 0) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_print ("FIXME: implement getting length of whole track\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2003-09-23 22:49:35 +00:00
|
|
|
/* which one are we at ? */
|
|
|
|
long track_num;
|
|
|
|
gint64 value_start, value_end;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
res = gst_pad_query (priv->decoder_pad, GST_QUERY_POSITION,
|
2004-03-15 19:32:27 +00:00
|
|
|
&track_format, &value_start);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (res) {
|
2003-09-23 22:49:35 +00:00
|
|
|
format = GST_FORMAT_TIME;
|
|
|
|
track_num = value_start;
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("we are currently at %ld", track_num);
|
2004-03-14 22:34:33 +00:00
|
|
|
res = gst_pad_convert (priv->decoder_pad,
|
2004-03-15 19:32:27 +00:00
|
|
|
track_format, track_num, &format, &value_start);
|
2003-09-23 22:49:35 +00:00
|
|
|
res &= gst_pad_convert (priv->decoder_pad,
|
2004-03-15 19:32:27 +00:00
|
|
|
track_format, track_num + 1, &format, &value_end);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (res) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* substract to get the length */
|
|
|
|
GST_DEBUG ("start %lld, end %lld", value_start, value_end);
|
|
|
|
value_end -= value_start;
|
|
|
|
/* FIXME: check units; this is in seconds */
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_tag_list_add (priv->streaminfo, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_DURATION, (int) (value_end / 1E6), NULL);
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
priv->current_track->streaminfo = priv->streaminfo;
|
|
|
|
priv->streaminfo = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_streaminfo (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
gmip_find_track_streaminfo_pre (priv);
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("DEBUG: gmip_find_streaminfo: iterating");
|
2003-09-23 22:49:35 +00:00
|
|
|
while ((priv->streaminfo == NULL) &&
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_bin_iterate (GST_BIN (priv->pipeline)))
|
|
|
|
GMI_DEBUG ("+");
|
|
|
|
GMI_DEBUG ("\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
gmip_find_track_streaminfo_post (priv);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find format found by decoder and store in priv->format */
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_format_pre (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE) {
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("Couldn't set to play");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_format_post (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
|
2004-03-14 22:34:33 +00:00
|
|
|
== GST_STATE_FAILURE)
|
2003-09-23 22:49:35 +00:00
|
|
|
return FALSE;
|
|
|
|
priv->current_track->format = priv->format;
|
|
|
|
priv->format = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gmip_find_track_format (GstMediaInfoPriv * priv)
|
2003-09-23 22:49:35 +00:00
|
|
|
{
|
|
|
|
gmip_find_track_format_pre (priv);
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("DEBUG: gmip_find_format: iterating");
|
2004-03-14 22:34:33 +00:00
|
|
|
while ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
|
|
|
|
GMI_DEBUG ("+");
|
|
|
|
GMI_DEBUG ("\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
gmip_find_track_format_post (priv);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|