Remove media-info, which is also successed by playbin (see Totem implementation).

Original commit message from CVS:
* configure.ac:
* gst-libs/gst/Makefile.am:
* gst-libs/gst/media-info/.cvsignore:
* gst-libs/gst/media-info/Makefile.am:
* gst-libs/gst/media-info/README:
* gst-libs/gst/media-info/media-info-priv.c:
* gst-libs/gst/media-info/media-info-priv.h:
* gst-libs/gst/media-info/media-info-test.c:
* gst-libs/gst/media-info/media-info.c:
* gst-libs/gst/media-info/media-info.h:
* gst-libs/gst/media-info/media-info.vcproj:
* pkgconfig/Makefile.am:
* pkgconfig/gstreamer-media-info-uninstalled.pc.in:
* pkgconfig/gstreamer-media-info.pc.in:
Remove media-info, which is also successed by playbin (see Totem
implementation).
This commit is contained in:
Ronald S. Bultje 2005-04-25 10:15:12 +00:00
parent 7172a58563
commit 8664d3ff31
15 changed files with 19 additions and 1865 deletions

View file

@ -1,3 +1,22 @@
2005-04-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
* gst-libs/gst/Makefile.am:
* gst-libs/gst/media-info/.cvsignore:
* gst-libs/gst/media-info/Makefile.am:
* gst-libs/gst/media-info/README:
* gst-libs/gst/media-info/media-info-priv.c:
* gst-libs/gst/media-info/media-info-priv.h:
* gst-libs/gst/media-info/media-info-test.c:
* gst-libs/gst/media-info/media-info.c:
* gst-libs/gst/media-info/media-info.h:
* gst-libs/gst/media-info/media-info.vcproj:
* pkgconfig/Makefile.am:
* pkgconfig/gstreamer-media-info-uninstalled.pc.in:
* pkgconfig/gstreamer-media-info.pc.in:
Remove media-info, which is also successed by playbin (see Totem
implementation).
2005-04-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net> 2005-04-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* configure.ac: * configure.ac:

View file

@ -902,7 +902,6 @@ gst-libs/gst/audio/Makefile
gst-libs/gst/colorbalance/Makefile gst-libs/gst/colorbalance/Makefile
gst-libs/gst/floatcast/Makefile gst-libs/gst/floatcast/Makefile
gst-libs/gst/gconf/Makefile gst-libs/gst/gconf/Makefile
gst-libs/gst/media-info/Makefile
gst-libs/gst/mixer/Makefile gst-libs/gst/mixer/Makefile
gst-libs/gst/navigation/Makefile gst-libs/gst/navigation/Makefile
gst-libs/gst/propertyprobe/Makefile gst-libs/gst/propertyprobe/Makefile

View file

@ -9,7 +9,6 @@ SUBDIRS = \
colorbalance \ colorbalance \
floatcast \ floatcast \
$(GCONF_DIR) \ $(GCONF_DIR) \
media-info \
mixer \ mixer \
navigation \ navigation \
propertyprobe \ propertyprobe \
@ -25,7 +24,6 @@ DIST_SUBDIRS = \
colorbalance \ colorbalance \
floatcast \ floatcast \
gconf \ gconf \
media-info \
mixer \ mixer \
navigation \ navigation \
propertyprobe \ propertyprobe \

View file

@ -1 +0,0 @@
media-info-test

View file

@ -1,20 +0,0 @@
lib_LTLIBRARIES = libgstmedia-info-@GST_MAJORMINOR@.la
libgstmedia_info_@GST_MAJORMINOR@_la_SOURCES = media-info.c media-info-priv.c
libgstmedia_info_@GST_MAJORMINOR@_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGIN_CFLAGS)
libgstmedia_info_@GST_MAJORMINOR@_la_LIBADD = \
$(GST_LIBS) $(GST_PLUGIN_LIBS)
libgstmedia_info_@GST_MAJORMINOR@_la_LDFLAGS = \
-version-info @GST_PLUGINS_LIBVERSION@
libincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/media-info
libinclude_HEADERS = media-info.h
noinst_PROGRAMS = media-info-test
noinst_HEADERS = media-info-priv.h
media_info_test_SOURCES = media-info-test.c
media_info_test_CFLAGS = $(GST_CFLAGS)
media_info_test_LDADD = $(GST_LIBS) libgstmedia-info-@GST_MAJORMINOR@.la

View file

@ -1,30 +0,0 @@
* media-info is a library to collect metadata and streaminfo from media
files
* the current implementation is idler-based.
* you create a new media_info object
* you set the string name of a source element to use using g_object_set or
gst_media_info_set_source
* you declare you'll read a given file by using gst_media_info_read_with_idler
* you loop gst_media_info_read_idler (info, &stream) as long as it returns TRUE
and as long as stream is still NULL
* INTERNALS:
- instance_init sets up the media info reader, its elements, and connects
the deep_notify callback
- read_with_idler resets the media info reader object,
and sets location and flags
- read_idler runs through a state machine:
NULL - TYPEFIND - STREAM - METADATA - STREAMINFO - FORMAT
- NULL: just returns find_type_pre, which moves state to TYPEFIND
- TYPEFIND:
- iterates as long as it can until it has priv->type
- find_type_post
- call gmi_set_mime which creates a pipeline to decode stuff
- move to STREAM
- STREAM

View file

@ -1,782 +0,0 @@
/* 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 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#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
gmi_stream_free (GstMediaInfoStream * stream)
{
if (stream->mime)
g_free (stream->mime);
/* 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
have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
GstMediaInfoPriv * priv)
{
GstStructure *str;
const gchar *mime;
priv->type = gst_caps_copy (type);
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
deep_notify_callback (GObject * object, GstObject * origin,
GParamSpec * pspec, GstMediaInfoPriv * priv)
{
GValue value = { 0, };
/* we only care about pad notifies */
if (!GST_IS_PAD (origin))
return;
/*
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) {
/* check if we're getting it from fakesink */
if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink) {
GST_DEBUG ("have caps on fakesink pad !");
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &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",
gst_object_get_name (gst_object_get_parent (origin)),
gst_object_get_name (origin));
} else if (strcmp (pspec->name, "offset") == 0) {
/* we REALLY ignore offsets, we hate them */
}
//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;
GST_DEBUG ("element %s found tag", 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 ("found tags from decoder, adding them as metadata");
priv->metadata = gst_tag_list_copy (tags);
} 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, GstMediaInfoPriv * priv)
{
g_print ("ERROR: %s\n", error->message);
g_error_free (error);
}
/* helpers */
/* 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;
}
/* initialise priv; done the first time */
gboolean
gmip_init (GstMediaInfoPriv * priv, GError ** error)
{
#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 FALSE; \
} \
} 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;
return TRUE;
}
/* called at the beginning of each use cycle */
/* reset info to a state where it can be used to query for media info */
void
gmip_reset (GstMediaInfoPriv * priv)
{
#define STRING_RESET(string) \
G_STMT_START { \
if (string) g_free (string); \
string = NULL; \
} G_STMT_END
STRING_RESET (priv->pipeline_desc);
STRING_RESET (priv->location);
#undef STRING_RESET
#define CAPS_RESET(target) \
G_STMT_START { \
if (target) gst_caps_unref (target); \
target = NULL; \
} G_STMT_END
CAPS_RESET (priv->type);
CAPS_RESET (priv->format);
#undef CAPS_RESET
#define TAGS_RESET(target) \
G_STMT_START { \
if (target) \
gst_tag_list_free (target); \
target = NULL; \
} G_STMT_END
TAGS_RESET (priv->metadata);
TAGS_RESET (priv->streaminfo);
#undef TAGS_RESET
if (priv->stream) {
gmi_stream_free (priv->stream);
priv->stream = NULL;
}
priv->flags = 0;
priv->state = GST_MEDIA_INFO_STATE_NULL;
priv->error = NULL;
}
/* seek to a track and reset metadata and streaminfo structs */
gboolean
gmi_seek_to_track (GstMediaInfo * info, long track)
{
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");
if (track_format == 0)
return FALSE;
GST_DEBUG ("Track format: %d", track_format);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to play");
g_assert (GST_IS_PAD (info->priv->decoder_pad));
event = gst_event_new_seek (track_format |
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, track);
res = gst_pad_send_event (info->priv->decoder_pad, event);
if (!res) {
g_warning ("seek to logical track on pad %s:%s failed",
GST_DEBUG_PAD_NAME (info->priv->decoder_pad));
return FALSE;
}
/* clear structs because of the seek */
if (priv->metadata) {
gst_tag_list_free (priv->metadata);
priv->metadata = NULL;
}
if (priv->streaminfo) {
gst_tag_list_free (priv->streaminfo);
priv->streaminfo = NULL;
}
return TRUE;
}
/* 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 ! 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)
|| (strcmp (mime, "audio/x-flac") == 0))
desc =
g_strdup_printf
("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else if ((strcmp (mime, "audio/wav") == 0)
|| (strcmp (mime, "audio/x-wav") == 0))
desc =
g_strdup_printf
("%s name=source ! 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);
else
return FALSE;
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");
if (!GST_IS_ELEMENT (priv->source))
g_error ("Could not create source element '%s'", priv->source_name);
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;
}
/* clear the decoding pipeline */
void
gmi_clear_decoder (GstMediaInfo * info)
{
if (info->priv->pipeline) {
GST_DEBUG ("Unreffing pipeline");
gst_object_unref (GST_OBJECT (info->priv->pipeline));
}
info->priv->pipeline = NULL;
}
/****
* 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
gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
GST_DEBUG ("gmip_find_type_pre: start");
/* find out type */
/* FIXME: we could move caps for typefind out of struct and
* just use it through this function only */
priv->pipeline = gst_pipeline_new ("pipeline-typefind");
if (!GST_IS_PIPELINE (priv->pipeline)) {
gst_media_info_error_create (error, "Internal GStreamer error.");
return FALSE;
}
gst_bin_add (GST_BIN (priv->pipeline), priv->typefind);
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->source, priv->source_name, "source",
error);
g_object_set (G_OBJECT (priv->source), "location", priv->location, NULL);
gst_bin_add (GST_BIN (priv->pipeline), priv->source);
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",
G_CALLBACK (have_type_callback), priv);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
GST_DEBUG ("moving to STATE_TYPEFIND\n");
priv->state = GST_MEDIA_INFO_STATE_TYPEFIND;
return TRUE;
}
/* finish off typefind */
gboolean
gmip_find_type_post (GstMediaInfoPriv * priv)
{
/*clear up typefind */
gst_element_set_state (priv->pipeline, GST_STATE_READY);
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);
if (priv->type == NULL) {
g_warning ("iteration ended, type not found !\n");
return FALSE;
}
GST_DEBUG ("moving to STATE_STREAM\n");
priv->state = GST_MEDIA_INFO_STATE_STREAM;
return TRUE;
}
/* complete version */
gboolean
gmip_find_type (GstMediaInfoPriv * priv, GError ** error)
{
if (!gmip_find_type_pre (priv, error))
return FALSE;
GST_DEBUG ("gmip_find_type: iterating");
while ((priv->type == NULL)
// && gst_bin_iterate (GST_BIN (priv->pipeline))
)
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
return gmip_find_type_post (priv);
}
/* FIXME: why not have these functions work on priv types ? */
gboolean
gmip_find_stream_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_STREAM;
return TRUE;
}
gboolean
gmip_find_stream_post (GstMediaInfoPriv * priv)
{
GstMediaInfoStream *stream = priv->stream;
const GstFormat *formats;
GstFormat track_format = 0;
GstFormat format;
gint64 value;
gboolean res;
glong bytes = 0;
GST_DEBUG ("gmip_find_stream_post: start");
/* 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);
while (*formats) {
const GstFormatDefinition *definition;
format = *formats;
g_assert (GST_IS_PAD (priv->decoder_pad));
definition = gst_format_get_details (*formats);
GST_DEBUG ("trying to figure out length for format %s", definition->nick);
res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL, &format, &value);
if (res) {
switch (format) {
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);
}
} else
GST_DEBUG ("query didn't return result for %s", definition->nick);
formats++;
}
if (stream->length_tracks == 0)
stream->length_tracks = 1;
/* 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));
res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL, &format, &value);
if (!res)
g_warning ("Failed to query on sink pad !");
bytes = value;
GST_DEBUG ("bitrate calc: bytes gotten: %ld", bytes);
if (bytes) {
double seconds = (double) stream->length_time / GST_SECOND;
double bits = bytes * 8;
stream->bitrate = (long) (bits / seconds);
}
GST_DEBUG ("moving to STATE_METADATA\n");
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
return TRUE;
}
/* get properties of complete physical stream
* and return them in pre-alloced stream struct in priv->stream */
gboolean
gmip_find_stream (GstMediaInfoPriv * priv)
{
GST_DEBUG ("mip_find_stream start");
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 */
//while (gst_bin_iterate (GST_BIN (priv->pipeline)) && priv->format == NULL);
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
g_warning ("Couldn't set to paused");
if (priv->format == NULL) {
GMI_DEBUG ("gmip_find_stream: couldn't get caps !");
return FALSE;
}
return gmip_find_stream_post (priv);
}
/* find metadata encoded in media and store in priv->metadata */
gboolean
gmip_find_track_metadata_pre (GstMediaInfoPriv * priv)
{
/* 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)
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
return TRUE;
}
gboolean
gmip_find_track_metadata_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
return FALSE;
priv->current_track->metadata = priv->metadata;
priv->metadata = NULL;
return TRUE;
}
gboolean
gmip_find_track_metadata (GstMediaInfoPriv * priv)
{
gmip_find_track_metadata_pre (priv);
GST_DEBUG ("gmip_find_metadata: iterating");
while ((priv->metadata == NULL)
//&& gst_bin_iterate (GST_BIN (priv->pipeline))
)
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_metadata_post (priv);
return TRUE;
}
/* find streaminfo found by decoder and store in priv->streaminfo */
/* FIXME: this is an exact copy, so reuse this function instead */
gboolean
gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
return TRUE;
}
gboolean
gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
{
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");
if (track_format == 0) {
g_print ("FIXME: implement getting length of whole track\n");
} else {
/* 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,
&track_format, &value_start);
if (res) {
format = GST_FORMAT_TIME;
track_num = value_start;
GST_DEBUG ("we are currently at %ld", track_num);
res = gst_pad_convert (priv->decoder_pad,
track_format, track_num, &format, &value_start);
res &= gst_pad_convert (priv->decoder_pad,
track_format, track_num + 1, &format, &value_end);
if (res) {
/* 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 */
gst_tag_list_add (priv->streaminfo, GST_TAG_MERGE_REPLACE,
GST_TAG_DURATION, (int) (value_end / 1E6), NULL);
}
}
}
priv->current_track->streaminfo = priv->streaminfo;
priv->streaminfo = NULL;
return TRUE;
}
gboolean
gmip_find_track_streaminfo (GstMediaInfoPriv * priv)
{
gmip_find_track_streaminfo_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_streaminfo: iterating");
while ((priv->streaminfo == NULL)
// && gst_bin_iterate (GST_BIN (priv->pipeline))
)
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_streaminfo_post (priv);
return TRUE;
}
/* find format found by decoder and store in priv->format */
gboolean
gmip_find_track_format_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
== GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
return TRUE;
}
gboolean
gmip_find_track_format_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
== GST_STATE_FAILURE)
return FALSE;
priv->current_track->format = priv->format;
priv->format = NULL;
return TRUE;
}
gboolean
gmip_find_track_format (GstMediaInfoPriv * priv)
{
gmip_find_track_format_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_format: iterating");
while ((priv->format == NULL)
//&& gst_bin_iterate (GST_BIN (priv->pipeline))
)
GMI_DEBUG ("+");
GMI_DEBUG ("\n");
gmip_find_track_format_post (priv);
return TRUE;
}

View file

@ -1,159 +0,0 @@
/* 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.h: private stuff */
#ifndef __GST_MEDIA_INFO_PRIV_H__
#define __GST_MEDIA_INFO_PRIV_H__
#include <gst/gst.h>
#include <glib/gprintf.h>
G_BEGIN_DECLS
/* debug */
GST_DEBUG_CATEGORY_EXTERN (gst_media_info_debug);
#define GST_CAT_DEFAULT gst_media_info_debug
//#define DEBUG
#ifdef DEBUG
static gboolean _gmi_debug = TRUE;
#else
static gboolean _gmi_debug = FALSE;
#endif
#ifdef G_HAVE_ISO_VARARGS
#define GMI_DEBUG(...) \
{ if (_gmi_debug) { g_print ( __VA_ARGS__ ); }}
#elif defined(G_HAVE_GNUC_VARARGS)
#define GMI_DEBUG(format, args...) \
{ if (_gmi_debug) { g_print ( format , ## args ); }}
#else
static inline void
GMI_DEBUG (const char *format, ...)
{
va_list varargs;
if (_gmi_debug) {
va_start (varargs, format);
g_vprintf ( format, varargs);
va_end (varargs);
}
}
#endif
/* state machine enum; FIXME: can we move this to priv.c ? */
typedef enum
{
GST_MEDIA_INFO_STATE_NULL,
GST_MEDIA_INFO_STATE_TYPEFIND,
GST_MEDIA_INFO_STATE_STREAM,
GST_MEDIA_INFO_STATE_METADATA,
GST_MEDIA_INFO_STATE_STREAMINFO,
GST_MEDIA_INFO_STATE_FORMAT,
GST_MEDIA_INFO_STATE_DONE
} GstMediaInfoState;
/* private structure */
struct GstMediaInfoPriv
{
GstElement *typefind;
GstCaps *type;
GstCaps *format;
GstTagList *metadata;
gint metadata_iters;
GstTagList *streaminfo;
GstElement *pipeline; /* will be != NULL during collection */
gchar *pipeline_desc; /* will be != NULL during collection */
GstElement *fakesink; /* so we can get caps from the
decoder sink pad */
gchar *source_name; /* type of element used as source */
GstElement *source;
GstPad *source_pad; /* pad for querying encoded caps */
GstElement *decoder;
GstPad *decoder_pad; /* pad for querying decoded caps */
GstElement *decontainer; /* element to typefind in containers */
GstMediaInfoState state; /* current state of state machine */
gchar *location; /* location set on the info object */
guint16 flags; /* flags supplied for detection */
GstMediaInfoTrack *current_track; /* track pointer under inspection */
glong current_track_num; /* current track under inspection */
GstMediaInfoStream *stream; /* total stream properties */
char *cache; /* location of cache */
GError *error; /* error for creation problems */
};
/* declarations */
GstMediaInfoStream *
gmi_stream_new (void);
void gmi_stream_free (GstMediaInfoStream *stream);
GstMediaInfoTrack *
gmi_track_new (void);
void gmip_reset (GstMediaInfoPriv *priv);
gboolean gmip_init (GstMediaInfoPriv *priv, GError **error);
void gmi_clear_decoder (GstMediaInfo *info);
gboolean gmi_seek_to_track (GstMediaInfo *info,
long track);
gboolean gmi_set_mime (GstMediaInfo *info,
const char *mime);
void deep_notify_callback (GObject *object,
GstObject *origin,
GParamSpec *pspec,
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, GstMediaInfoPriv *priv);
gboolean gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error);
gboolean gmip_find_type_post (GstMediaInfoPriv *priv);
gboolean gmip_find_type (GstMediaInfoPriv *priv, GError **error);
gboolean gmip_find_stream_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_stream_post (GstMediaInfoPriv *priv);
gboolean gmip_find_stream (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_metadata (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_streaminfo (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format_pre (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format_post (GstMediaInfoPriv *priv);
gboolean gmip_find_track_format (GstMediaInfoPriv *priv);
G_END_DECLS
#endif /* __GST_MEDIA_INFO_PRIV_H__ */

View file

@ -1,120 +0,0 @@
/* media-info test app */
#include <gst/gst.h>
#include <string.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) {
if (!gst_tag_list_get_string_index (list, tag, i, &str))
g_assert_not_reached ();
} 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
info_print (GstMediaInfoStream * stream)
{
int i;
GList *p;
GstMediaInfoTrack *track;
g_print ("- mime type: %s\n", stream->mime);
g_print ("- length: %.3f seconds\n",
(gdouble) stream->length_time / GST_SECOND);
g_print ("- bitrate: %.3f kbps\n", stream->bitrate / 1000.0);
g_print ("- number of tracks: %ld\n", stream->length_tracks);
p = stream->tracks;
if (p == NULL) {
g_print ("- no track information, probably an error\n");
return;
}
for (i = 0; i < stream->length_tracks; ++i) {
g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n");
if (track->metadata)
gst_tag_list_foreach (track->metadata, print_tag, NULL);
else
g_print (" (none found)\n");
g_print (" - streaminfo:\n");
gst_tag_list_foreach (track->streaminfo, print_tag, NULL);
g_print (" - format:\n");
g_print ("%s\n", gst_caps_to_string (track->format));
p = p->next;
}
}
int
main (int argc, char *argv[])
{
GstMediaInfo *info;
GstMediaInfoStream *stream = NULL;
GError *error = NULL;
gint i;
g_assert (argc > 1);
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", &error)) {
g_print ("Could not set gnomevfssrc as a source\n");
g_print ("reason: %s\n", error->message);
g_error_free (error);
return -1;
}
g_print ("stream: %p, &stream: %p\n", stream, &stream);
for (i = 1; i < argc; ++i) {
/*
stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
*/
gst_media_info_read_with_idler (info, argv[i], GST_MEDIA_INFO_ALL, &error);
while (gst_media_info_read_idler (info, &stream, &error) && stream == NULL)
/* keep idling */
g_print ("+");
g_print ("\nFILE: %s\n", argv[i]);
g_print ("stream: %p, &stream: %p\n", stream, &stream);
if (error) {
g_print ("Error reading media info: %s\n", error->message);
g_error_free (error);
}
if (stream)
info_print (stream);
else
g_print ("no media info found.\n");
stream = NULL;
}
return 0;
}

View file

@ -1,433 +0,0 @@
/* GStreamer media-info library
* Copyright (C) 2003,2004 Thomas Vander Stichele <thomas@apestaart.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <string.h>
#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_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean _media_info_inited = FALSE;
/* FIXME: this is a lousy hack that needs to go */
#define MAX_METADATA_ITERS 5
/* GObject-y bits */
/* signal stuff */
enum
{
MEDIA_INFO_SIGNAL,
LAST_SIGNAL
};
static guint gst_media_info_signals[LAST_SIGNAL] = { 0 };
/*
* all GError stuff
*/
enum
{
MEDIA_INFO_ERROR_FILE
};
/* GError quark stuff */
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;
}
/*
* GObject type stuff
*/
enum
{
PROP_SOURCE
};
static GObjectClass *parent_class = NULL;
GST_DEBUG_CATEGORY (gst_media_info_debug);
/* initialize the media-info library */
void
gst_media_info_init (void)
{
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");
GST_DEBUG ("Initialized media-info library");
_media_info_inited = TRUE;
}
GType
gst_media_info_get_type (void)
{
static GType gst_media_info_type = 0;
if (!gst_media_info_type) {
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
};
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
"GstMediaInfo", &gst_media_info_info, 0);
}
return gst_media_info_type;
}
static void
gst_media_info_class_init (GstMediaInfoClass * klass)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_ref (G_TYPE_OBJECT);
//parent_class = g_type_class_peek_parent (klass);
/*
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->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);
}
static void
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 ();
}
gmip_init (info->priv, error);
gmip_reset (info->priv);
}
/* get/set */
static void
gst_media_info_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMediaInfo *info = GST_MEDIA_INFO (object);
switch (prop_id) {
case PROP_SOURCE:
g_value_set_string (value, info->priv->source_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
GstMediaInfo *
gst_media_info_new (GError ** error)
{
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
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;
}
/**
* public methods
*/
gboolean
gst_media_info_set_source (GstMediaInfo * info, const char *source,
GError ** error)
{
info->priv->source_name = g_strdup (source);
return TRUE;
}
/* 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
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 */
priv->location = g_strdup (location);
priv->flags = flags;
}
/* 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
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;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = info->priv;
g_assert (streamp != NULL);
g_assert (priv);
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;
}
/* need to find type */
GST_DEBUG ("idler: NULL, need to find type, priv %p", priv);
return gmip_find_type_pre (priv, error);
case GST_MEDIA_INFO_STATE_TYPEFIND:
{
gchar *mime;
GST_LOG ("STATE_TYPEFIND");
//if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
if ((priv->type == NULL)) {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG ("?");
return TRUE;
}
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)));
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;
}
priv->stream = gmi_stream_new ();
GST_DEBUG ("new stream: %p", priv->stream);
priv->stream->mime = mime;
priv->stream->path = priv->location;
gmip_find_stream_pre (priv);
}
case GST_MEDIA_INFO_STATE_STREAM:
{
GST_LOG ("STATE_STREAM");
//if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
if ((priv->format == NULL)) {
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
}
/* 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;
}
/* 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++;
return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
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 ("found metadata of track %ld", priv->current_track_num);
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);
}
case GST_MEDIA_INFO_STATE_STREAMINFO:
{
if ((priv->streaminfo == NULL)
//&& gst_bin_iterate (GST_BIN (priv->pipeline))
) {
GMI_DEBUG ("?");
return TRUE;
}
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;
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) {
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;
/* save the track info */
priv->stream->tracks = g_list_append (priv->stream->tracks,
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)) {
g_free (priv->current_track);
return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
}
priv->state = GST_MEDIA_INFO_STATE_DONE;
gmi_clear_decoder (info);
GST_DEBUG ("TOTALLY DONE, setting pointer *streamp to %p", *streamp);
*streamp = priv->stream;
priv->stream = NULL;
return TRUE;
}
case GST_MEDIA_INFO_STATE_DONE:
return TRUE;
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)
{
GstMediaInfoStream *stream = NULL;
gst_media_info_read_with_idler (info, location, flags, error);
if (*error)
return FALSE;
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
/* keep looping */ ;
if (*error)
return NULL;
return stream;
}
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
const char *location,
GstCaps *media_info);
*/

View file

@ -1,140 +0,0 @@
/* 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.
*/
#ifndef __GST_MEDIA_INFO_H__
#define __GST_MEDIA_INFO_H__
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct GstMediaInfoPriv GstMediaInfoPriv;
typedef struct _GstMediaInfo GstMediaInfo;
typedef struct _GstMediaInfoClass GstMediaInfoClass;
struct _GstMediaInfo
{
GObject parent;
GstMediaInfoPriv *priv;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstMediaInfoClass
{
GObjectClass parent_class;
/* signals */
void (*media_info_signal) (GstMediaInfo *gst_media_info);
void (*error_signal) (GstMediaInfo *gst_media_info, GError *error, const gchar *debug);
gpointer _gst_reserved[GST_PADDING];
};
/* structure for "physical" stream,
* which can contain multiple sequential ones */
typedef struct
{
gboolean seekable;
gchar *mime;
gchar *path;
GstCaps *caps; /* properties of the complete bitstream */
guint64 length_time;
glong length_tracks;
glong bitrate;
GList *tracks;
} GstMediaInfoStream;
/* structure for "logical" stream or track,
* or one of a set of sequentially muxed streams */
typedef struct
{
GstTagList *metadata; /* changeable metadata or tags */
GstTagList *streaminfo; /* codec property stuff */
GstCaps *format; /* properties of the logical stream */
guint64 length_time;
GList *con_streams; /* list of concurrent streams in this
sequential stream */
} GstMediaInfoTrack;
typedef struct
{
GstCaps *caps; /* properties of the muxed concurrent stream */
} GstMediaInfoConcurrent;
#define GST_MEDIA_INFO_ERROR gst_media_info_error_quark ()
#define GST_MEDIA_INFO_TYPE (gst_media_info_get_type ())
#define GST_MEDIA_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_MEDIA_INFO_TYPE, GstMediaInfo))
#define GST_MEDIA_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_MEDIA_INFO_TYPE, GstMediaInfoClass))
#define IS_GST_MEDIA_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_MEDIA_INFO_TYPE))
#define IS_GST_MEDIA_INFO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_MEDIA_INFO_TYPE))
#define GST_MEDIA_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_MEDIA_INFO_TYPE, GstMediaInfoClass))
#define GST_MEDIA_INFO_STREAM 1 << 1
#define GST_MEDIA_INFO_MIME 1 << 2
#define GST_MEDIA_INFO_METADATA 1 << 3
#define GST_MEDIA_INFO_STREAMINFO 1 << 4
#define GST_MEDIA_INFO_FORMAT 1 << 5
#define GST_MEDIA_INFO_ALL ((1 << 6) - 1)
GQuark gst_media_info_error_quark (void);
void gst_media_info_init (void);
GType gst_media_info_get_type (void);
GstMediaInfo * gst_media_info_new (GError **error);
gboolean gst_media_info_set_source (GstMediaInfo *info,
const char *source,
GError **error);
void gst_media_info_read_with_idler (GstMediaInfo *media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
gboolean gst_media_info_read_idler (GstMediaInfo *media_info,
GstMediaInfoStream **streamp,
GError **error);
GstMediaInfoStream *
gst_media_info_read (GstMediaInfo *media_info,
const char *location,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
gboolean gst_media_info_read_many (GstMediaInfo *media_info,
GList *locations,
guint16 GST_MEDIA_INFO_FLAGS,
GError **error);
GstCaps * gst_media_info_get_next (GstMediaInfo *media_info,
GError **error);
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
const char *location,
GstCaps *media_info);
*/
G_END_DECLS
#endif /* __GST_MEDIA_INFO_H__ */

View file

@ -1,150 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="media-info"
ProjectGUID="{979C216F-0ACF-4956-AE00-055A42D67896}"
RootNamespace="media-info"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../../win32/Debug"
IntermediateDirectory="../../../win32/Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../../gstreamer/win32;../../../../gstreamer;../../../../gstreamer/libs;../../../../glib;../../../../glib/glib;../../../../glib/gmodule;&quot;../../../gst-libs&quot;;../../../../popt/include;../../../../libxml2/include/libxml2"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_H;_USE_MATH_DEFINES"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
OutputFile="$(OutDir)/gstmedia-info.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="../../../../gstreamer/win32/Debug;../../../../glib/glib;../../../../glib/gmodule;../../../../glib/gthread;../../../../glib/gobject;../../../../gettext/lib;../../../../libiconv/lib"
ModuleDefinitionFile=""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/media-info.pdb"
SubSystem="2"
OptimizeReferences="2"
ImportLibrary="$(OutDir)/gstmedia-info.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../../win32/Release"
IntermediateDirectory="../../../win32/Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../gstreamer/win32;../../../../gstreamer;../../../../gstreamer/libs;../../../../glib;../../../../glib/glib;../../../../glib/gmodule;&quot;../../../gst-libs&quot;;../../../../popt/include;../../../../libxml2/include/libxml2"
PreprocessorDefinitions="WIN32;NDEBUG;GST_DISABLE_GST_DEBUG;_WINDOWS;_USRDLL;HAVE_CONFIG_H;_USE_MATH_DEFINES"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
OutputFile="$(OutDir)/gstmedia-info.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="../../../../gstreamer/win32/Release;../../../../glib/glib;../../../../glib/gmodule;../../../../glib/gthread;../../../../glib/gobject;../../../../gettext/lib;../../../../libiconv/lib"
ModuleDefinitionFile=""
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/gstmedia-info.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\media-info-priv.c">
</File>
<File
RelativePath=".\media-info.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\media-info-priv.h">
</File>
<File
RelativePath=".\media-info.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -11,13 +11,11 @@ pcverfiles = \
$(GCONF_PC) \ $(GCONF_PC) \
gstreamer-interfaces-@GST_MAJORMINOR@.pc \ gstreamer-interfaces-@GST_MAJORMINOR@.pc \
gstreamer-libs-@GST_MAJORMINOR@.pc \ gstreamer-libs-@GST_MAJORMINOR@.pc \
gstreamer-media-info-@GST_MAJORMINOR@.pc \
gstreamer-plugins-@GST_MAJORMINOR@.pc gstreamer-plugins-@GST_MAJORMINOR@.pc
pcverfiles_uninstalled = \ pcverfiles_uninstalled = \
$(GCONF_PC_UNINSTALLED) \ $(GCONF_PC_UNINSTALLED) \
gstreamer-interfaces-@GST_MAJORMINOR@-uninstalled.pc \ gstreamer-interfaces-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-libs-@GST_MAJORMINOR@-uninstalled.pc \ gstreamer-libs-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-media-info-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-plugins-@GST_MAJORMINOR@-uninstalled.pc gstreamer-plugins-@GST_MAJORMINOR@-uninstalled.pc
pcverfiles_gconf = $(GCONF_PC) $(GCONF_PC_UNINSTALLED) pcverfiles_gconf = $(GCONF_PC) $(GCONF_PC_UNINSTALLED)
@ -37,7 +35,6 @@ pcinfiles = \
gstreamer-gconf.pc.in gstreamer-gconf-uninstalled.pc.in \ gstreamer-gconf.pc.in gstreamer-gconf-uninstalled.pc.in \
gstreamer-interfaces.pc.in gstreamer-interfaces-uninstalled.pc.in \ gstreamer-interfaces.pc.in gstreamer-interfaces-uninstalled.pc.in \
gstreamer-libs.pc.in gstreamer-libs-uninstalled.pc.in \ gstreamer-libs.pc.in gstreamer-libs-uninstalled.pc.in \
gstreamer-media-info.pc.in gstreamer-media-info-uninstalled.pc.in \
gstreamer-plugins.pc.in gstreamer-plugins-uninstalled.pc.in gstreamer-plugins.pc.in gstreamer-plugins-uninstalled.pc.in
DISTCLEANFILES = $(pcinfiles:.in=) DISTCLEANFILES = $(pcinfiles:.in=)

View file

@ -1,12 +0,0 @@
prefix=
exec_prefix=
libdir=${pcfiledir}/../gst-libs/gst/media-info
includedir=${pcfiledir}/../gst-libs
Name: GStreamer Media Info Library, uninstalled
Description: Streaming-media framework, media info libraries, not installed
Requires: gstreamer-@GST_MAJORMINOR@
Version: @VERSION@
Libs: ${libdir}/libgstmedia-info-@GST_MAJORMINOR@.la
Cflags: -I${includedir}

View file

@ -1,12 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/gstreamer-@GST_MAJORMINOR@
Name: GStreamer Media Info Library
Description: Streaming-media framework, media info libraries
Requires: gstreamer-@GST_MAJORMINOR@
Version: @VERSION@
Libs: -L${libdir} -lgstmedia-info-@GST_MAJORMINOR@
Cflags: -I${includedir}