Commit 8664d3ff authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

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).
parent 7172a585
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>
 
* configure.ac:
......
......@@ -902,7 +902,6 @@ gst-libs/gst/audio/Makefile
gst-libs/gst/colorbalance/Makefile
gst-libs/gst/floatcast/Makefile
gst-libs/gst/gconf/Makefile
gst-libs/gst/media-info/Makefile
gst-libs/gst/mixer/Makefile
gst-libs/gst/navigation/Makefile
gst-libs/gst/propertyprobe/Makefile
......
......@@ -9,7 +9,6 @@ SUBDIRS = \
colorbalance \
floatcast \
$(GCONF_DIR) \
media-info \
mixer \
navigation \
propertyprobe \
......@@ -25,7 +24,6 @@ DIST_SUBDIRS = \
colorbalance \
floatcast \
gconf \
media-info \
mixer \
navigation \
propertyprobe \
......
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
* 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
This diff is collapsed.
/* 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__ */
/* 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;
}
/* 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;