summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/media-info/media-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/media-info/media-info.c')
-rw-r--r--gst-libs/gst/media-info/media-info.c221
1 files changed, 104 insertions, 117 deletions
diff --git a/gst-libs/gst/media-info/media-info.c b/gst-libs/gst/media-info/media-info.c
index 902b6cef..4f995359 100644
--- a/gst-libs/gst/media-info/media-info.c
+++ b/gst-libs/gst/media-info/media-info.c
@@ -26,12 +26,11 @@
#include "media-info.h"
#include "media-info-priv.h"
-static void gst_media_info_class_init (GstMediaInfoClass *klass);
-static void gst_media_info_instance_init (GstMediaInfo *info);
+static void gst_media_info_class_init (GstMediaInfoClass * klass);
+static void gst_media_info_instance_init (GstMediaInfo * info);
-static void gst_media_info_get_property (GObject *object, guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_media_info_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static gboolean _media_info_inited = FALSE;
@@ -64,6 +63,7 @@ GQuark
gst_media_info_error_quark (void)
{
static GQuark quark = 0;
+
if (quark == 0)
quark = g_quark_from_static_string ("gst-media-info-error-quark");
return quark;
@@ -86,11 +86,12 @@ GST_DEBUG_CATEGORY (gst_media_info_debug);
void
gst_media_info_init (void)
{
- if (_media_info_inited) return;
+ if (_media_info_inited)
+ return;
/* register our debugging category */
GST_DEBUG_CATEGORY_INIT (gst_media_info_debug, "GST_MEDIA_INFO", 0,
- "GStreamer media-info library");
+ "GStreamer media-info library");
GST_DEBUG ("Initialized media-info library");
_media_info_inited = TRUE;
}
@@ -99,8 +100,8 @@ GType
gst_media_info_get_type (void)
{
static GType gst_media_info_type = 0;
- if (!gst_media_info_type)
- {
+
+ if (!gst_media_info_type) {
static const GTypeInfo gst_media_info_info = {
sizeof (GstMediaInfoClass),
(GBaseInitFunc) NULL,
@@ -113,14 +114,13 @@ gst_media_info_get_type (void)
NULL
};
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
- "GstMediaInfo",
- &gst_media_info_info, 0);
+ "GstMediaInfo", &gst_media_info_info, 0);
}
return gst_media_info_type;
}
static void
-gst_media_info_class_init (GstMediaInfoClass *klass)
+gst_media_info_class_init (GstMediaInfoClass * klass)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
@@ -129,36 +129,36 @@ gst_media_info_class_init (GstMediaInfoClass *klass)
/*
- object_class->finalize = gst_media_info_finalize;
- object_class->dispose = gst_media_info_dispose;
- */
+ object_class->finalize = gst_media_info_finalize;
+ object_class->dispose = gst_media_info_dispose;
+ */
/*
- g_object_class->set_property = gst_media_info_set_property;
- */
+ g_object_class->set_property = gst_media_info_set_property;
+ */
g_object_class->get_property = gst_media_info_get_property;
klass->media_info_signal = NULL;
- 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);
+ 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);
}
static void
-gst_media_info_instance_init (GstMediaInfo *info)
+gst_media_info_instance_init (GstMediaInfo * info)
{
GError **error;
info->priv = g_new0 (GstMediaInfoPriv, 1);
error = &info->priv->error;
- if (!_media_info_inited) { gst_media_info_init (); }
+ if (!_media_info_inited) {
+ gst_media_info_init ();
+ }
gmip_init (info->priv, error);
gmip_reset (info->priv);
@@ -166,13 +166,12 @@ gst_media_info_instance_init (GstMediaInfo *info)
/* get/set */
static void
-gst_media_info_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_media_info_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstMediaInfo *info = GST_MEDIA_INFO (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case PROP_SOURCE:
g_value_set_string (value, info->priv->source_name);
break;
@@ -183,21 +182,17 @@ gst_media_info_get_property (GObject *object, guint prop_id,
}
GstMediaInfo *
-gst_media_info_new (GError **error)
+gst_media_info_new (GError ** error)
{
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
- if (info->priv->error)
- {
- if (error)
- {
+ if (info->priv->error) {
+ if (error) {
*error = info->priv->error;
info->priv->error = NULL;
- }
- else
- {
+ } else {
g_warning ("Error creating GstMediaInfo object.\n%s",
- info->priv->error->message);
+ info->priv->error->message);
g_error_free (info->priv->error);
}
}
@@ -208,7 +203,8 @@ gst_media_info_new (GError **error)
* public methods
*/
gboolean
-gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **error)
+gst_media_info_set_source (GstMediaInfo * info, const char *source,
+ GError ** error)
{
info->priv->source_name = g_strdup (source);
return TRUE;
@@ -221,12 +217,12 @@ gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **erro
* previous one is done ?
*/
void
-gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
- guint16 flags, GError **error)
+gst_media_info_read_with_idler (GstMediaInfo * info, const char *location,
+ guint16 flags, GError ** error)
{
GstMediaInfoPriv *priv = info->priv;
- gmip_reset (info->priv); /* reset all structs */
+ gmip_reset (info->priv); /* reset all structs */
priv->location = g_strdup (location);
priv->flags = flags;
}
@@ -236,12 +232,14 @@ gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
* returns: TRUE if it was able to idle, FALSE if there was an error
*/
gboolean
-gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GError **error)
+gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
+ GError ** error)
{
GstMediaInfoPriv *priv;
/* if it's NULL then we're sure something went wrong higher up) */
- if (info == NULL) return FALSE;
+ if (info == NULL)
+ return FALSE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = info->priv;
@@ -249,15 +247,13 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
g_assert (streamp != NULL);
g_assert (priv);
- switch (priv->state)
- {
+ switch (priv->state) {
case GST_MEDIA_INFO_STATE_NULL:
/* make sure we have a source */
- if (!priv->source_name)
- {
- *error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
- "No source set on media info.");
- return FALSE;
+ if (!priv->source_name) {
+ *error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
+ "No source set on media info.");
+ return FALSE;
}
/* need to find type */
@@ -269,29 +265,27 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
gchar *mime;
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");
- GMI_DEBUG("?");
- return TRUE;
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->type == NULL)
- {
- g_warning ("Couldn't find type\n");
+ if (priv->type == NULL) {
+ g_warning ("Couldn't find type\n");
return FALSE;
}
/* do the state transition */
GST_DEBUG ("doing find_type_post");
gmip_find_type_post (priv);
GST_DEBUG ("finding out mime type");
- mime = g_strdup (gst_structure_get_name (
- gst_caps_get_structure(priv->type, 0)));
+ mime =
+ g_strdup (gst_structure_get_name (gst_caps_get_structure (priv->type,
+ 0)));
GST_DEBUG ("found out mime type: %s", mime);
- if (!gmi_set_mime (info, mime))
- {
- /* FIXME: pop up error */
- GST_DEBUG ("no decoder pipeline found for mime %s", mime);
- return FALSE;
+ if (!gmi_set_mime (info, mime)) {
+ /* FIXME: pop up error */
+ GST_DEBUG ("no decoder pipeline found for mime %s", mime);
+ return FALSE;
}
priv->stream = gmi_stream_new ();
GST_DEBUG ("new stream: %p", priv->stream);
@@ -303,14 +297,12 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAM:
{
GST_LOG ("STATE_STREAM");
- if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->format == NULL)
- {
- g_warning ("Couldn't find format\n");
+ if (priv->format == NULL) {
+ g_warning ("Couldn't find format\n");
return FALSE;
}
/* do state transition; stream -> first track metadata */
@@ -320,26 +312,25 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
gmip_find_track_metadata_pre (priv);
return TRUE;
}
- /* these ones are repeated per track */
+ /* these ones are repeated per track */
case GST_MEDIA_INFO_STATE_METADATA:
{
if ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
- priv->metadata_iters < MAX_METADATA_ITERS)
- {
- GMI_DEBUG("?");
+ priv->metadata_iters < MAX_METADATA_ITERS) {
+ GMI_DEBUG ("?");
priv->metadata_iters++;
- return TRUE;
+ return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
- g_print ("iterated a few times, didn't find metadata\n");
- if (priv->metadata == NULL)
- {
+ g_print ("iterated a few times, didn't find metadata\n");
+ if (priv->metadata == NULL) {
/* this is not a permanent failure */
- GST_DEBUG ("Couldn't find metadata");
+ GST_DEBUG ("Couldn't find metadata");
}
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\n");
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
return gmip_find_track_streaminfo_pre (priv);
@@ -347,53 +338,47 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
case GST_MEDIA_INFO_STATE_STREAMINFO:
{
if ((priv->streaminfo == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->streaminfo == NULL)
- {
+ if (priv->streaminfo == NULL) {
/* this is not a permanent failure */
- GST_DEBUG ("Couldn't find streaminfo");
- }
- else
- GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
- if (!gmip_find_track_streaminfo_post (priv)) return FALSE;
+ GST_DEBUG ("Couldn't find streaminfo");
+ } else
+ GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
+ if (!gmip_find_track_streaminfo_post (priv))
+ return FALSE;
priv->state = GST_MEDIA_INFO_STATE_FORMAT;
return gmip_find_track_format_pre (priv);
}
case GST_MEDIA_INFO_STATE_FORMAT:
{
- if ((priv->format == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->format == NULL)
- {
- g_warning ("Couldn't find format\n");
+ if (priv->format == NULL) {
+ g_warning ("Couldn't find format\n");
return FALSE;
}
GST_DEBUG ("found format of track %ld", priv->current_track_num);
- if (!gmip_find_track_format_post (priv)) return FALSE;
+ if (!gmip_find_track_format_post (priv))
+ return FALSE;
/* save the track info */
priv->stream->tracks = g_list_append (priv->stream->tracks,
- priv->current_track);
+ priv->current_track);
/* 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++;
- if (priv->current_track_num < priv->stream->length_tracks)
- {
- gmi_seek_to_track (info, priv->current_track_num);
- priv->current_track = gmi_track_new ();
- if (!gmip_find_track_metadata_pre (priv))
- {
+ if (priv->current_track_num < priv->stream->length_tracks) {
+ 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;
+ return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
@@ -407,24 +392,26 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GEr
}
case GST_MEDIA_INFO_STATE_DONE:
return TRUE;
- default:
+ default:
g_warning ("don't know what to do\n");
return FALSE;
- }
+ }
}
/* main function
* read all possible info from the file pointed to by location
* use flags to limit the type of information searched for */
GstMediaInfoStream *
-gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags, GError **error)
+gst_media_info_read (GstMediaInfo * info, const char *location, guint16 flags,
+ GError ** error)
{
GstMediaInfoStream *stream = NULL;
gst_media_info_read_with_idler (info, location, flags, error);
- if (*error) return FALSE;
+ if (*error)
+ return FALSE;
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
- /* keep looping */;
+ /* keep looping */ ;
if (*error)
return NULL;