2004-03-06 20:15:17 +00:00
|
|
|
/* GStreamer media-info library
|
|
|
|
* Copyright (C) 2003,2004 Thomas Vander Stichele <thomas@apestaart.org>
|
2002-11-11 13:59:16 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-11-07 12:47:02 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "media-info.h"
|
2003-09-23 22:49:35 +00:00
|
|
|
#include "media-info-priv.h"
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_media_info_class_init (GstMediaInfoClass * klass);
|
|
|
|
static void gst_media_info_instance_init (GstMediaInfo * info);
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_media_info_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2002-11-11 13:59:16 +00:00
|
|
|
|
|
|
|
|
2004-03-07 20:51:10 +00:00
|
|
|
static gboolean _media_info_inited = FALSE;
|
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* FIXME: this is a lousy hack that needs to go */
|
|
|
|
#define MAX_METADATA_ITERS 5
|
2002-11-11 13:59:16 +00:00
|
|
|
|
|
|
|
/* GObject-y bits */
|
|
|
|
|
|
|
|
/* signal stuff */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MEDIA_INFO_SIGNAL,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint gst_media_info_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
/*
|
2004-03-06 20:15:17 +00:00
|
|
|
* all GError stuff
|
|
|
|
*/
|
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MEDIA_INFO_ERROR_FILE
|
|
|
|
};
|
2004-03-06 20:15:17 +00:00
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
/* GError quark stuff */
|
2004-03-07 20:51:10 +00:00
|
|
|
GQuark
|
2002-11-11 13:59:16 +00:00
|
|
|
gst_media_info_error_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
if (quark == 0)
|
|
|
|
quark = g_quark_from_static_string ("gst-media-info-error-quark");
|
|
|
|
return quark;
|
|
|
|
}
|
2004-03-06 20:15:17 +00:00
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
/*
|
2003-09-23 22:49:35 +00:00
|
|
|
* GObject type stuff
|
2002-11-11 13:59:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_SOURCE
|
|
|
|
};
|
|
|
|
|
|
|
|
static GObjectClass *parent_class = NULL;
|
|
|
|
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG_CATEGORY (gst_media_info_debug);
|
2004-03-06 20:15:17 +00:00
|
|
|
|
|
|
|
/* initialize the media-info library */
|
2004-01-20 16:25:11 +00:00
|
|
|
void
|
|
|
|
gst_media_info_init (void)
|
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (_media_info_inited)
|
|
|
|
return;
|
2004-03-07 20:51:10 +00:00
|
|
|
|
2004-01-20 16:25:11 +00:00
|
|
|
/* register our debugging category */
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_media_info_debug, "GST_MEDIA_INFO", 0,
|
2004-03-14 22:34:33 +00:00
|
|
|
"GStreamer media-info library");
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("Initialized media-info library");
|
2004-03-07 20:51:10 +00:00
|
|
|
_media_info_inited = TRUE;
|
2004-01-20 16:25:11 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
GType
|
|
|
|
gst_media_info_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_media_info_type = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (!gst_media_info_type) {
|
2002-11-11 13:59:16 +00:00
|
|
|
static const GTypeInfo gst_media_info_info = {
|
|
|
|
sizeof (GstMediaInfoClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gst_media_info_class_init,
|
|
|
|
NULL, NULL,
|
|
|
|
sizeof (GstMediaInfo),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_media_info_instance_init,
|
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
|
2004-03-15 19:32:27 +00:00
|
|
|
"GstMediaInfo", &gst_media_info_info, 0);
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
|
|
|
return gst_media_info_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_class_init (GstMediaInfoClass * klass)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
|
|
|
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
|
2003-09-23 22:49:35 +00:00
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
parent_class = g_type_class_ref (G_TYPE_OBJECT);
|
|
|
|
//parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-03-14 22:34:33 +00:00
|
|
|
object_class->finalize = gst_media_info_finalize;
|
|
|
|
object_class->dispose = gst_media_info_dispose;
|
|
|
|
*/
|
2002-11-11 13:59:16 +00:00
|
|
|
|
|
|
|
/*
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class->set_property = gst_media_info_set_property;
|
|
|
|
*/
|
2002-11-11 13:59:16 +00:00
|
|
|
g_object_class->get_property = gst_media_info_get_property;
|
|
|
|
|
|
|
|
klass->media_info_signal = NULL;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_signals[MEDIA_INFO_SIGNAL] =
|
|
|
|
g_signal_new ("media-info",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
|
|
|
|
NULL, NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_instance_init (GstMediaInfo * info)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
GError **error;
|
2002-11-11 13:59:16 +00:00
|
|
|
|
|
|
|
info->priv = g_new0 (GstMediaInfoPriv, 1);
|
2004-03-06 20:15:17 +00:00
|
|
|
error = &info->priv->error;
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!_media_info_inited) {
|
|
|
|
gst_media_info_init ();
|
|
|
|
}
|
2004-01-22 19:00:27 +00:00
|
|
|
|
2004-03-07 21:02:25 +00:00
|
|
|
gmip_init (info->priv, error);
|
2004-03-07 20:51:10 +00:00
|
|
|
gmip_reset (info->priv);
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get/set */
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
|
|
|
GstMediaInfo *info = GST_MEDIA_INFO (object);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (prop_id) {
|
2002-11-11 13:59:16 +00:00
|
|
|
case PROP_SOURCE:
|
2004-03-06 20:15:17 +00:00
|
|
|
g_value_set_string (value, info->priv->source_name);
|
2002-11-11 13:59:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-26 14:51:33 +00:00
|
|
|
GstMediaInfo *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_new (GError ** error)
|
2002-11-26 14:51:33 +00:00
|
|
|
{
|
|
|
|
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (info->priv->error) {
|
|
|
|
if (error) {
|
2004-03-06 20:15:17 +00:00
|
|
|
*error = info->priv->error;
|
|
|
|
info->priv->error = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2004-03-06 20:15:17 +00:00
|
|
|
g_warning ("Error creating GstMediaInfo object.\n%s",
|
2004-03-15 19:32:27 +00:00
|
|
|
info->priv->error->message);
|
2004-03-06 20:15:17 +00:00
|
|
|
g_error_free (info->priv->error);
|
|
|
|
}
|
|
|
|
}
|
2002-11-26 14:51:33 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2002-11-11 13:59:16 +00:00
|
|
|
/**
|
2003-09-23 22:49:35 +00:00
|
|
|
* public methods
|
2002-11-11 13:59:16 +00:00
|
|
|
*/
|
2003-09-23 22:49:35 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_set_source (GstMediaInfo * info, const char *source,
|
|
|
|
GError ** error)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
info->priv->source_name = g_strdup (source);
|
2002-11-11 13:59:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* idler-based implementation
|
|
|
|
* set up read on a given location
|
|
|
|
* FIXME: maybe we should check if the info is cleared when calling this
|
|
|
|
* function ? What happens if it gets called again on same info before
|
|
|
|
* previous one is done ?
|
|
|
|
*/
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_read_with_idler (GstMediaInfo * info, const char *location,
|
|
|
|
guint16 flags, GError ** error)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
|
|
|
GstMediaInfoPriv *priv = info->priv;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
gmip_reset (info->priv); /* reset all structs */
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->location = g_strdup (location);
|
|
|
|
priv->flags = flags;
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
|
|
|
|
/* an idler which does the work of actually collecting all data
|
|
|
|
* this must be called repeatedly, until streamp is set to a non-NULL value
|
|
|
|
* returns: TRUE if it was able to idle, FALSE if there was an error
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
|
|
|
|
GError ** error)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
GstMediaInfoPriv *priv;
|
2004-03-07 20:51:10 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* if it's NULL then we're sure something went wrong higher up) */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (info == NULL)
|
|
|
|
return FALSE;
|
2004-03-07 20:51:10 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
priv = info->priv;
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
g_assert (streamp != NULL);
|
2004-03-06 20:15:17 +00:00
|
|
|
g_assert (priv);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (priv->state) {
|
2003-09-23 22:49:35 +00:00
|
|
|
case GST_MEDIA_INFO_STATE_NULL:
|
2004-03-07 20:51:10 +00:00
|
|
|
/* make sure we have a source */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!priv->source_name) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
|
|
|
|
"No source set on media info.");
|
|
|
|
return FALSE;
|
2004-03-07 20:51:10 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* need to find type */
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("idler: NULL, need to find type, priv %p", priv);
|
2004-03-07 20:51:10 +00:00
|
|
|
return gmip_find_type_pre (priv, error);
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
case GST_MEDIA_INFO_STATE_TYPEFIND:
|
|
|
|
{
|
|
|
|
gchar *mime;
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_LOG ("STATE_TYPEFIND");
|
2004-03-14 22:34:33 +00:00
|
|
|
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG ("iterating while in STATE_TYPEFIND");
|
|
|
|
GMI_DEBUG ("?");
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->type == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("Couldn't find type\n");
|
|
|
|
return FALSE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
/* do the state transition */
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("doing find_type_post");
|
2003-09-23 22:49:35 +00:00
|
|
|
gmip_find_type_post (priv);
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("finding out mime type");
|
2004-03-14 22:34:33 +00:00
|
|
|
mime =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_strdup (gst_structure_get_name (gst_caps_get_structure (priv->type,
|
|
|
|
0)));
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("found out mime type: %s", mime);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gmi_set_mime (info, mime)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* FIXME: pop up error */
|
|
|
|
GST_DEBUG ("no decoder pipeline found for mime %s", mime);
|
|
|
|
return FALSE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
priv->stream = gmi_stream_new ();
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("new stream: %p", priv->stream);
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->stream->mime = mime;
|
|
|
|
priv->stream->path = priv->location;
|
2002-11-11 13:59:16 +00:00
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
gmip_find_stream_pre (priv);
|
|
|
|
}
|
|
|
|
case GST_MEDIA_INFO_STATE_STREAM:
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_LOG ("STATE_STREAM");
|
2004-03-14 22:34:33 +00:00
|
|
|
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GMI_DEBUG ("?");
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->format == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("Couldn't find format\n");
|
|
|
|
return FALSE;
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
/* do state transition; stream -> first track metadata */
|
|
|
|
priv->current_track_num = 0;
|
|
|
|
gmip_find_stream_post (priv);
|
|
|
|
priv->current_track = gmi_track_new ();
|
|
|
|
gmip_find_track_metadata_pre (priv);
|
|
|
|
return TRUE;
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
/* these ones are repeated per track */
|
2003-09-23 22:49:35 +00:00
|
|
|
case GST_MEDIA_INFO_STATE_METADATA:
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2003-09-23 22:49:35 +00:00
|
|
|
if ((priv->metadata == NULL) &&
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
|
|
|
|
priv->metadata_iters < MAX_METADATA_ITERS) {
|
|
|
|
GMI_DEBUG ("?");
|
|
|
|
priv->metadata_iters++;
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
if (priv->metadata_iters == MAX_METADATA_ITERS)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_print ("iterated a few times, didn't find metadata\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->metadata == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* this is not a permanent failure */
|
|
|
|
GST_DEBUG ("Couldn't find metadata");
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gmip_find_track_metadata_post (priv))
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2004-03-06 20:15:17 +00:00
|
|
|
GST_DEBUG ("METADATA: going to STREAMINFO\n");
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
|
|
|
|
return gmip_find_track_streaminfo_pre (priv);
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
case GST_MEDIA_INFO_STATE_STREAMINFO:
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
2003-09-23 22:49:35 +00:00
|
|
|
if ((priv->streaminfo == NULL) &&
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bin_iterate (GST_BIN (priv->pipeline))) {
|
|
|
|
GMI_DEBUG ("?");
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->streaminfo == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* this is not a permanent failure */
|
|
|
|
GST_DEBUG ("Couldn't find streaminfo");
|
2004-03-14 22:34:33 +00:00
|
|
|
} else
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gmip_find_track_streaminfo_post (priv))
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2003-09-23 22:49:35 +00:00
|
|
|
priv->state = GST_MEDIA_INFO_STATE_FORMAT;
|
|
|
|
return gmip_find_track_format_pre (priv);
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
2003-09-23 22:49:35 +00:00
|
|
|
case GST_MEDIA_INFO_STATE_FORMAT:
|
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GMI_DEBUG ("?");
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->format == NULL) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_warning ("Couldn't find format\n");
|
|
|
|
return FALSE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
2004-01-20 16:25:11 +00:00
|
|
|
GST_DEBUG ("found format of track %ld", priv->current_track_num);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gmip_find_track_format_post (priv))
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2003-09-23 22:49:35 +00:00
|
|
|
/* save the track info */
|
|
|
|
priv->stream->tracks = g_list_append (priv->stream->tracks,
|
2004-03-15 19:32:27 +00:00
|
|
|
priv->current_track);
|
2003-09-23 22:49:35 +00:00
|
|
|
/* these alloc'd data types have been handed off */
|
|
|
|
priv->current_track = NULL;
|
|
|
|
priv->location = NULL;
|
|
|
|
/* now see if we need to seek to a next track or not */
|
|
|
|
priv->current_track_num++;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (priv->current_track_num < priv->stream->length_tracks) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gmi_seek_to_track (info, priv->current_track_num);
|
|
|
|
priv->current_track = gmi_track_new ();
|
|
|
|
if (!gmip_find_track_metadata_pre (priv)) {
|
|
|
|
g_free (priv->current_track);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
priv->state = GST_MEDIA_INFO_STATE_METADATA;
|
|
|
|
return TRUE;
|
2003-09-23 22:49:35 +00:00
|
|
|
}
|
|
|
|
priv->state = GST_MEDIA_INFO_STATE_DONE;
|
2004-03-07 20:51:10 +00:00
|
|
|
gmi_clear_decoder (info);
|
|
|
|
GST_DEBUG ("TOTALLY DONE, setting pointer *streamp to %p", *streamp);
|
2003-09-23 22:49:35 +00:00
|
|
|
*streamp = priv->stream;
|
|
|
|
priv->stream = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case GST_MEDIA_INFO_STATE_DONE:
|
|
|
|
return TRUE;
|
2004-03-14 22:34:33 +00:00
|
|
|
default:
|
2003-09-23 22:49:35 +00:00
|
|
|
g_warning ("don't know what to do\n");
|
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-11-11 13:59:16 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 22:49:35 +00:00
|
|
|
/* main function
|
|
|
|
* read all possible info from the file pointed to by location
|
|
|
|
* use flags to limit the type of information searched for */
|
2002-11-11 13:59:16 +00:00
|
|
|
GstMediaInfoStream *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_media_info_read (GstMediaInfo * info, const char *location, guint16 flags,
|
|
|
|
GError ** error)
|
2002-11-11 13:59:16 +00:00
|
|
|
{
|
|
|
|
GstMediaInfoStream *stream = NULL;
|
|
|
|
|
2004-03-08 22:16:04 +00:00
|
|
|
gst_media_info_read_with_idler (info, location, flags, error);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (*error)
|
|
|
|
return FALSE;
|
2004-03-08 22:16:04 +00:00
|
|
|
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
|
2004-03-14 22:34:33 +00:00
|
|
|
/* keep looping */ ;
|
2004-03-08 22:16:04 +00:00
|
|
|
if (*error)
|
2002-11-11 13:59:16 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: reset ?
|
|
|
|
gboolean gst_media_info_write (GstMediaInfo *media_info,
|
|
|
|
const char *location,
|
|
|
|
GstCaps *media_info);
|
|
|
|
*/
|