rename utils to pbutils

Original commit message from CVS:
* configure.ac:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/Makefile.am:
* gst-libs/gst/interfaces/mixer.c:
* gst-libs/gst/pbutils/Makefile.am:
* gst-libs/gst/pbutils/descriptions.c:
(gst_pb_utils_get_source_description),
(gst_pb_utils_get_sink_description),
(gst_pb_utils_get_decoder_description),
(gst_pb_utils_get_encoder_description),
(gst_pb_utils_get_element_description),
(gst_pb_utils_add_codec_description_to_tag_list),
(gst_pb_utils_get_codec_description), (gst_pb_utils_list_all):
* gst-libs/gst/pbutils/descriptions.h:
* gst-libs/gst/pbutils/install-plugins.c:
* gst-libs/gst/pbutils/install-plugins.h:
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_source_message_new),
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new),
(gst_missing_plugin_message_get_description):
* gst-libs/gst/pbutils/missing-plugins.h:
* gst-libs/gst/pbutils/pbutils.c: (gst_pb_utils_init):
* gst-libs/gst/pbutils/pbutils.h:
* gst-libs/gst/utils/Makefile.am:
* gst-libs/gst/utils/base-utils.c:
* gst-libs/gst/utils/base-utils.h:
* gst-libs/gst/utils/descriptions.c:
* gst-libs/gst/utils/descriptions.h:
* gst-libs/gst/utils/install-plugins.c:
* gst-libs/gst/utils/install-plugins.h:
* gst-libs/gst/utils/missing-plugins.c:
* gst-libs/gst/utils/missing-plugins.h:
* gst-plugins-base.spec.in:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c:
* gst/playback/gstdecodebin2.c:
* gst/playback/gstplaybasebin.c: (setup_subtitle),
(gen_source_element):
* gst/playback/gstplaybin.c: (plugin_init):
* tests/check/Makefile.am:
* tests/check/libs/pbutils.c: (GST_START_TEST),
(test_pb_utils_install_plugins_do_callout), (libgstpbutils_suite):
* tests/check/libs/utils.c:
rename utils to pbutils
This commit is contained in:
Thomas Vander Stichele 2007-03-04 23:39:51 +00:00
parent 64d706f402
commit f6bd20e5e3
33 changed files with 212 additions and 3415 deletions

View file

@ -1,3 +1,54 @@
2007-03-05 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/Makefile.am:
* gst-libs/gst/interfaces/mixer.c:
* gst-libs/gst/pbutils/Makefile.am:
* gst-libs/gst/pbutils/descriptions.c:
(gst_pb_utils_get_source_description),
(gst_pb_utils_get_sink_description),
(gst_pb_utils_get_decoder_description),
(gst_pb_utils_get_encoder_description),
(gst_pb_utils_get_element_description),
(gst_pb_utils_add_codec_description_to_tag_list),
(gst_pb_utils_get_codec_description), (gst_pb_utils_list_all):
* gst-libs/gst/pbutils/descriptions.h:
* gst-libs/gst/pbutils/install-plugins.c:
* gst-libs/gst/pbutils/install-plugins.h:
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_source_message_new),
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new),
(gst_missing_plugin_message_get_description):
* gst-libs/gst/pbutils/missing-plugins.h:
* gst-libs/gst/pbutils/pbutils.c: (gst_pb_utils_init):
* gst-libs/gst/pbutils/pbutils.h:
* gst-libs/gst/utils/Makefile.am:
* gst-libs/gst/utils/base-utils.c:
* gst-libs/gst/utils/base-utils.h:
* gst-libs/gst/utils/descriptions.c:
* gst-libs/gst/utils/descriptions.h:
* gst-libs/gst/utils/install-plugins.c:
* gst-libs/gst/utils/install-plugins.h:
* gst-libs/gst/utils/missing-plugins.c:
* gst-libs/gst/utils/missing-plugins.h:
* gst-plugins-base.spec.in:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c:
* gst/playback/gstdecodebin2.c:
* gst/playback/gstplaybasebin.c: (setup_subtitle),
(gen_source_element):
* gst/playback/gstplaybin.c: (plugin_init):
* tests/check/Makefile.am:
* tests/check/libs/pbutils.c: (GST_START_TEST),
(test_pb_utils_install_plugins_do_callout), (libgstpbutils_suite):
* tests/check/libs/utils.c:
rename utils to pbutils
2007-03-02 Jan Schmidt <thaytan@mad.scientist.com> 2007-03-02 Jan Schmidt <thaytan@mad.scientist.com>
* docs/plugins/Makefile.am: * docs/plugins/Makefile.am:

View file

@ -210,7 +210,7 @@ AC_CHECK_HEADERS([sys/socket.h],
HAVE_SYS_SOCKET_H="yes", HAVE_SYS_SOCKET_H="no") HAVE_SYS_SOCKET_H="yes", HAVE_SYS_SOCKET_H="no")
AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "x$HAVE_SYS_SOCKET_H" = "xyes") AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "x$HAVE_SYS_SOCKET_H" = "xyes")
dnl used in gst-libs/gst/utils and associated unit test dnl used in gst-libs/gst/pbutils and associated unit test
AC_CHECK_HEADERS([process.h sys/types.h sys/wait.h sys/stat.h]) AC_CHECK_HEADERS([process.h sys/types.h sys/wait.h sys/stat.h])
dnl ffmpegcolorspace includes _stdint.h dnl ffmpegcolorspace includes _stdint.h
@ -656,7 +656,7 @@ gst-libs/gst/netbuffer/Makefile
gst-libs/gst/riff/Makefile gst-libs/gst/riff/Makefile
gst-libs/gst/rtp/Makefile gst-libs/gst/rtp/Makefile
gst-libs/gst/tag/Makefile gst-libs/gst/tag/Makefile
gst-libs/gst/utils/Makefile gst-libs/gst/pbutils/Makefile
gst-libs/gst/video/Makefile gst-libs/gst/video/Makefile
tools/Makefile tools/Makefile
win32/common/config.h win32/common/config.h

View file

@ -46,10 +46,10 @@
<!ENTITY GstTagVorbis SYSTEM "xml/gsttagvorbis.xml"> <!ENTITY GstTagVorbis SYSTEM "xml/gsttagvorbis.xml">
<!ENTITY GstTagID3 SYSTEM "xml/gsttagid3.xml"> <!ENTITY GstTagID3 SYSTEM "xml/gsttagid3.xml">
<!-- utils --> <!-- utils -->
<!ENTITY GstBaseUtils SYSTEM "xml/gstbaseutils.xml"> <!ENTITY GstPBUtils SYSTEM "xml/gstpbutils.xml">
<!ENTITY GstBaseUtilsDescriptions SYSTEM "xml/gstbaseutilsdescriptions.xml"> <!ENTITY GstPBUtilsDescriptions SYSTEM "xml/gstpbutilsdescriptions.xml">
<!ENTITY GstBaseUtilsMissingPlugins SYSTEM "xml/gstbaseutilsmissingplugins.xml"> <!ENTITY GstPBUtilsMissingPlugins SYSTEM "xml/gstpbutilsmissingplugins.xml">
<!ENTITY GstBaseUtilsInstallPlugins SYSTEM "xml/gstbaseutilsinstallplugins.xml"> <!ENTITY GstPBUtilsInstallPlugins SYSTEM "xml/gstpbutilsinstallplugins.xml">
<!-- video --> <!-- video -->
<!ENTITY GstVideo SYSTEM "xml/gstvideo.xml"> <!ENTITY GstVideo SYSTEM "xml/gstvideo.xml">
<!ENTITY GstVideoFilter SYSTEM "xml/gstvideofilter.xml"> <!ENTITY GstVideoFilter SYSTEM "xml/gstvideofilter.xml">
@ -183,13 +183,13 @@
<para> <para>
This library should be linked to by getting cflags and libs from This library should be linked to by getting cflags and libs from
<filename>gstreamer-plugins-base.pc</filename> and adding <filename>gstreamer-plugins-base.pc</filename> and adding
<filename>-lgstbaseutils-&GST_MAJORMINOR;</filename> to the library <filename>-lgstpbutils-&GST_MAJORMINOR;</filename> to the library
flags. flags.
</para> </para>
&GstBaseUtils; &GstPBUtils;
&GstBaseUtilsDescriptions; &GstPBUtilsDescriptions;
&GstBaseUtilsMissingPlugins; &GstPBUtilsMissingPlugins;
&GstBaseUtilsInstallPlugins; &GstPBUtilsInstallPlugins;
</chapter> </chapter>
<chapter id="gstreamer-video"> <chapter id="gstreamer-video">

View file

@ -917,14 +917,14 @@ gst_tag_to_id3_tag
# base utils # base utils
<SECTION> <SECTION>
<FILE>gstbaseutils</FILE> <FILE>gstpbutils</FILE>
<INCLUDE>gst/utils/base-utils.h</INCLUDE> <INCLUDE>gst/utils/base-utils.h</INCLUDE>
<SUBSECTION> <SUBSECTION>
gst_base_utils_init gst_pb_utils_init
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gstbaseutilsmissingplugins</FILE> <FILE>gstpbutilsmissingplugins</FILE>
<INCLUDE>gst/utils/missing-plugins.h</INCLUDE> <INCLUDE>gst/utils/missing-plugins.h</INCLUDE>
<SUBSECTION> <SUBSECTION>
gst_missing_plugin_message_get_installer_detail gst_missing_plugin_message_get_installer_detail
@ -939,7 +939,7 @@ gst_missing_element_message_new
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gstbaseutilsinstallplugins</FILE> <FILE>gstpbutilsinstallplugins</FILE>
<INCLUDE>gst/utils/install-plugins.h</INCLUDE> <INCLUDE>gst/utils/install-plugins.h</INCLUDE>
<SUBSECTION> <SUBSECTION>
GstInstallPluginsReturn GstInstallPluginsReturn
@ -956,17 +956,17 @@ gst_install_plugins_context_set_xid
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gstbaseutilsdescriptions</FILE> <FILE>gstpbutilsdescriptions</FILE>
<INCLUDE>gst/utils/descriptions.h</INCLUDE> <INCLUDE>gst/utils/descriptions.h</INCLUDE>
<SUBSECTION> <SUBSECTION>
gst_base_utils_get_source_description gst_pb_utils_get_source_description
gst_base_utils_get_sink_description gst_pb_utils_get_sink_description
gst_base_utils_get_decoder_description gst_pb_utils_get_decoder_description
gst_base_utils_get_encoder_description gst_pb_utils_get_encoder_description
gst_base_utils_get_element_description gst_pb_utils_get_element_description
<SUBSECTION> <SUBSECTION>
gst_base_utils_add_codec_description_to_tag_list gst_pb_utils_add_codec_description_to_tag_list
gst_base_utils_get_codec_description gst_pb_utils_get_codec_description
</SECTION> </SECTION>
# video # video

View file

@ -9,9 +9,9 @@ SUBDIRS = \
cdda \ cdda \
floatcast \ floatcast \
netbuffer \ netbuffer \
pbutils \
riff \ riff \
rtp \ rtp \
utils \
video video
noinst_HEADERS = gettext.h gst-i18n-plugin.h noinst_HEADERS = gettext.h gst-i18n-plugin.h

View file

@ -180,7 +180,7 @@ gst_mixer_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
} }
} }
/* /**
* gst_mixer_get_volume: * gst_mixer_get_volume:
* @mixer: the #GstMixer (a #GstElement) that owns the track * @mixer: the #GstMixer (a #GstElement) that owns the track
* @track: the GstMixerTrack to get the volume from. * @track: the GstMixerTrack to get the volume from.

View file

@ -1,8 +1,8 @@
lib_LTLIBRARIES = libgstbaseutils-@GST_MAJORMINOR@.la lib_LTLIBRARIES = libgstpbutils-@GST_MAJORMINOR@.la
libgstbaseutils_@GST_MAJORMINOR@_la_SOURCES = \ libgstpbutils_@GST_MAJORMINOR@_la_SOURCES = \
base-utils.c \ pbutils.c \
base-utils.h \ pbutils.h \
descriptions.c \ descriptions.c \
descriptions.h \ descriptions.h \
install-plugins.c \ install-plugins.c \
@ -10,13 +10,13 @@ libgstbaseutils_@GST_MAJORMINOR@_la_SOURCES = \
missing-plugins.c \ missing-plugins.c \
missing-plugins.h missing-plugins.h
libgstbaseutils_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/utils libgstpbutils_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/utils
libgstbaseutils_@GST_MAJORMINOR@include_HEADERS = \ libgstpbutils_@GST_MAJORMINOR@include_HEADERS = \
base-utils.h \ pbutils.h \
descriptions.h \ descriptions.h \
install-plugins.h \ install-plugins.h \
missing-plugins.h missing-plugins.h
libgstbaseutils_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS) libgstpbutils_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS)
libgstbaseutils_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) libgstpbutils_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstbaseutils_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) libgstpbutils_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)

View file

@ -1,4 +1,4 @@
/* GStreamer base utils library source/sink/codec description support /* GStreamer Plugins Base utils library source/sink/codec description support
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net> * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -18,7 +18,7 @@
*/ */
/** /**
* SECTION:gstbaseutilsdescriptions * SECTION:gstpbutilsdescriptions
* @short_description: Provides human-readable descriptions for caps/codecs * @short_description: Provides human-readable descriptions for caps/codecs
* and encoder, decoder, URI source and URI sink elements * and encoder, decoder, URI source and URI sink elements
* *
@ -29,7 +29,7 @@
* in error dialogs or other messages shown to users. * in error dialogs or other messages shown to users.
* </para> * </para>
* <para> * <para>
* gst_base_utils_add_codec_description_to_tag_list() is a utility function * gst_pb_utils_add_codec_description_to_tag_list() is a utility function
* for demuxer and decoder elements to add audio/video codec tags from a * for demuxer and decoder elements to add audio/video codec tags from a
* given (fixed) #GstCaps. * given (fixed) #GstCaps.
* </para> * </para>
@ -42,7 +42,7 @@
#include "gst/gst-i18n-plugin.h" #include "gst/gst-i18n-plugin.h"
#include "base-utils.h" #include "pbutils.h"
#include <string.h> #include <string.h>
@ -611,7 +611,7 @@ caps_are_rtp_caps (const GstCaps * caps, const gchar * media, gchar ** format)
} }
/** /**
* gst_base_utils_get_source_description: * gst_pb_utils_get_source_description:
* @protocol: the protocol the source element needs to handle, e.g. "http" * @protocol: the protocol the source element needs to handle, e.g. "http"
* *
* Returns a localised string describing a source element handling the protocol * Returns a localised string describing a source element handling the protocol
@ -626,7 +626,7 @@ caps_are_rtp_caps (const GstCaps * caps, const gchar * media, gchar ** format)
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_source_description (const gchar * protocol) gst_pb_utils_get_source_description (const gchar * protocol)
{ {
gchar *proto_uc, *ret; gchar *proto_uc, *ret;
@ -659,7 +659,7 @@ gst_base_utils_get_source_description (const gchar * protocol)
} }
/** /**
* gst_base_utils_get_sink_description: * gst_pb_utils_get_sink_description:
* @protocol: the protocol the sink element needs to handle, e.g. "http" * @protocol: the protocol the sink element needs to handle, e.g. "http"
* *
* Returns a localised string describing a sink element handling the protocol * Returns a localised string describing a sink element handling the protocol
@ -674,7 +674,7 @@ gst_base_utils_get_source_description (const gchar * protocol)
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_sink_description (const gchar * protocol) gst_pb_utils_get_sink_description (const gchar * protocol)
{ {
gchar *proto_uc, *ret; gchar *proto_uc, *ret;
@ -694,7 +694,7 @@ gst_base_utils_get_sink_description (const gchar * protocol)
} }
/** /**
* gst_base_utils_get_decoder_description: * gst_pb_utils_get_decoder_description:
* @caps: the (fixed) #GstCaps for which an decoder description is needed * @caps: the (fixed) #GstCaps for which an decoder description is needed
* *
* Returns a localised string describing an decoder for the format specified * Returns a localised string describing an decoder for the format specified
@ -709,7 +709,7 @@ gst_base_utils_get_sink_description (const gchar * protocol)
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_decoder_description (const GstCaps * caps) gst_pb_utils_get_decoder_description (const GstCaps * caps)
{ {
gchar *str, *ret; gchar *str, *ret;
@ -727,7 +727,7 @@ gst_base_utils_get_decoder_description (const GstCaps * caps)
} else { } else {
const FormatInfo *info; const FormatInfo *info;
str = gst_base_utils_get_codec_description (caps); str = gst_pb_utils_get_codec_description (caps);
info = find_format_info (caps); info = find_format_info (caps);
if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) { if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) {
ret = g_strdup_printf (_("%s demuxer"), str); ret = g_strdup_printf (_("%s demuxer"), str);
@ -742,7 +742,7 @@ gst_base_utils_get_decoder_description (const GstCaps * caps)
} }
/** /**
* gst_base_utils_get_encoder_description: * gst_pb_utils_get_encoder_description:
* @caps: the (fixed) #GstCaps for which an encoder description is needed * @caps: the (fixed) #GstCaps for which an encoder description is needed
* *
* Returns a localised string describing an encoder for the format specified * Returns a localised string describing an encoder for the format specified
@ -757,7 +757,7 @@ gst_base_utils_get_decoder_description (const GstCaps * caps)
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_encoder_description (const GstCaps * caps) gst_pb_utils_get_encoder_description (const GstCaps * caps)
{ {
gchar *str, *ret; gchar *str, *ret;
@ -775,7 +775,7 @@ gst_base_utils_get_encoder_description (const GstCaps * caps)
} else { } else {
const FormatInfo *info; const FormatInfo *info;
str = gst_base_utils_get_codec_description (caps); str = gst_pb_utils_get_codec_description (caps);
info = find_format_info (caps); info = find_format_info (caps);
if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) { if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) {
ret = g_strdup_printf (_("%s muxer"), str); ret = g_strdup_printf (_("%s muxer"), str);
@ -790,7 +790,7 @@ gst_base_utils_get_encoder_description (const GstCaps * caps)
} }
/** /**
* gst_base_utils_get_element_description: * gst_pb_utils_get_element_description:
* @factory_name: the name of the element, e.g. "gnomevfssrc" * @factory_name: the name of the element, e.g. "gnomevfssrc"
* *
* Returns a localised string describing the given element, for use in * Returns a localised string describing the given element, for use in
@ -805,7 +805,7 @@ gst_base_utils_get_encoder_description (const GstCaps * caps)
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_element_description (const gchar * factory_name) gst_pb_utils_get_element_description (const gchar * factory_name)
{ {
gchar *ret; gchar *ret;
@ -819,7 +819,7 @@ gst_base_utils_get_element_description (const gchar * factory_name)
} }
/** /**
* gst_base_utils_add_codec_description_to_tag_list: * gst_pb_utils_add_codec_description_to_tag_list:
* @taglist: a #GstTagList * @taglist: a #GstTagList
* @codec_tag: a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC, * @codec_tag: a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC,
* #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC * #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC
@ -830,7 +830,7 @@ gst_base_utils_get_element_description (const gchar * factory_name)
* Returns: TRUE if a codec tag was added, FALSE otherwise. * Returns: TRUE if a codec tag was added, FALSE otherwise.
*/ */
gboolean gboolean
gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist, gst_pb_utils_add_codec_description_to_tag_list (GstTagList * taglist,
const gchar * codec_tag, const GstCaps * caps) const gchar * codec_tag, const GstCaps * caps)
{ {
const FormatInfo *info; const FormatInfo *info;
@ -856,7 +856,7 @@ gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist,
} }
/** /**
* gst_base_utils_get_codec_description: * gst_pb_utils_get_codec_description:
* @caps: the (fixed) #GstCaps for which an format description is needed * @caps: the (fixed) #GstCaps for which an format description is needed
* *
* Returns a localised (as far as this is possible) string describing the * Returns a localised (as far as this is possible) string describing the
@ -864,13 +864,13 @@ gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist,
* to be seen by the user. Should never return NULL unless @caps is invalid. * to be seen by the user. Should never return NULL unless @caps is invalid.
* *
* Also see the convenience function * Also see the convenience function
* gst_base_utils_add_codec_description_to_tag_list(). * gst_pb_utils_add_codec_description_to_tag_list().
* *
* Returns: a newly-allocated description string, or NULL on error. Free * Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer. * string with g_free() when not needed any longer.
*/ */
gchar * gchar *
gst_base_utils_get_codec_description (const GstCaps * caps) gst_pb_utils_get_codec_description (const GstCaps * caps)
{ {
const FormatInfo *info; const FormatInfo *info;
gchar *str, *comma; gchar *str, *comma;
@ -902,7 +902,7 @@ gst_base_utils_get_codec_description (const GstCaps * caps)
#if 0 #if 0
void void
gst_base_utils_list_all (void) gst_pb_utils_list_all (void)
{ {
gint i; gint i;

View file

@ -17,8 +17,8 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_BASE_UTILS_DESCRIPTIONS_H__ #ifndef __GST_PB_UTILS_DESCRIPTIONS_H__
#define __GST_BASE_UTILS_DESCRIPTIONS_H__ #define __GST_PB_UTILS_DESCRIPTIONS_H__
#include <gst/gsttaglist.h> #include <gst/gsttaglist.h>
#include <gst/gstcaps.h> #include <gst/gstcaps.h>
@ -30,29 +30,29 @@ G_BEGIN_DECLS
* from caps * from caps
*/ */
gboolean gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist, gboolean gst_pb_utils_add_codec_description_to_tag_list (GstTagList * taglist,
const gchar * codec_tag, const gchar * codec_tag,
const GstCaps * caps); const GstCaps * caps);
gchar * gst_base_utils_get_codec_description (const GstCaps * caps); gchar * gst_pb_utils_get_codec_description (const GstCaps * caps);
/* /*
* functions mainly used by the missing plugins message creation functions to * functions mainly used by the missing plugins message creation functions to
* find descriptions of what exactly is missing * find descriptions of what exactly is missing
*/ */
gchar * gst_base_utils_get_source_description (const gchar * protocol); gchar * gst_pb_utils_get_source_description (const gchar * protocol);
gchar * gst_base_utils_get_sink_description (const gchar * protocol); gchar * gst_pb_utils_get_sink_description (const gchar * protocol);
gchar * gst_base_utils_get_decoder_description (const GstCaps * caps); gchar * gst_pb_utils_get_decoder_description (const GstCaps * caps);
gchar * gst_base_utils_get_encoder_description (const GstCaps * caps); gchar * gst_pb_utils_get_encoder_description (const GstCaps * caps);
gchar * gst_base_utils_get_element_description (const gchar * factory_name); gchar * gst_pb_utils_get_element_description (const gchar * factory_name);
G_END_DECLS G_END_DECLS
#endif /* __GST_BASE_UTILS_DESCRIPTIONS_H__ */ #endif /* __GST_PB_UTILS_DESCRIPTIONS_H__ */

View file

@ -19,7 +19,7 @@
*/ */
/** /**
* SECTION:gstbaseutilsinstallplugins * SECTION:gstpbutilsinstallplugins
* @short_description: Missing plugin installation support for applications * @short_description: Missing plugin installation support for applications
* *
* <refsect2> * <refsect2>

View file

@ -18,8 +18,8 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_BASE_UTILS_INSTALL_PLUGINS_H__ #ifndef __GST_PB_UTILS_INSTALL_PLUGINS_H__
#define __GST_BASE_UTILS_INSTALL_PLUGINS_H__ #define __GST_PB_UTILS_INSTALL_PLUGINS_H__
#include <glib.h> #include <glib.h>
@ -133,5 +133,5 @@ gboolean gst_install_plugins_installation_in_progress (void);
G_END_DECLS G_END_DECLS
#endif /* __GST_BASE_UTILS_INSTALL_PLUGINS_H__ */ #endif /* __GST_PB_UTILS_INSTALL_PLUGINS_H__ */

View file

@ -18,7 +18,7 @@
*/ */
/** /**
* SECTION:gstbaseutilsmissingplugins * SECTION:gstpbutilsmissingplugins
* @short_description: Create, recognise and parse missing-plugins messages * @short_description: Create, recognise and parse missing-plugins messages
* *
* <refsect2> * <refsect2>
@ -66,7 +66,7 @@
#include "gst/gst-i18n-plugin.h" #include "gst/gst-i18n-plugin.h"
#include "base-utils.h" #include "pbutils.h"
#include <string.h> #include <string.h>
@ -164,7 +164,7 @@ gst_missing_uri_source_message_new (GstElement * element,
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
g_return_val_if_fail (protocol != NULL, NULL); g_return_val_if_fail (protocol != NULL, NULL);
description = gst_base_utils_get_source_description (protocol); description = gst_pb_utils_get_source_description (protocol);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"urisource", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING, "urisource", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING,
@ -196,7 +196,7 @@ gst_missing_uri_sink_message_new (GstElement * element, const gchar * protocol)
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (protocol != NULL, FALSE); g_return_val_if_fail (protocol != NULL, FALSE);
description = gst_base_utils_get_sink_description (protocol); description = gst_pb_utils_get_sink_description (protocol);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"urisink", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING, "urisink", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING,
@ -229,7 +229,7 @@ gst_missing_element_message_new (GstElement * element,
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (factory_name != NULL, FALSE); g_return_val_if_fail (factory_name != NULL, FALSE);
description = gst_base_utils_get_element_description (factory_name); description = gst_pb_utils_get_element_description (factory_name);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"element", "detail", G_TYPE_STRING, factory_name, "name", G_TYPE_STRING, "element", "detail", G_TYPE_STRING, factory_name, "name", G_TYPE_STRING,
@ -266,7 +266,7 @@ gst_missing_decoder_message_new (GstElement * element,
g_return_val_if_fail (!gst_caps_is_empty (decode_caps), FALSE); g_return_val_if_fail (!gst_caps_is_empty (decode_caps), FALSE);
g_return_val_if_fail (gst_caps_is_fixed (decode_caps), FALSE); g_return_val_if_fail (gst_caps_is_fixed (decode_caps), FALSE);
description = gst_base_utils_get_decoder_description (decode_caps); description = gst_pb_utils_get_decoder_description (decode_caps);
caps = copy_and_clean_caps (decode_caps); caps = copy_and_clean_caps (decode_caps);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
@ -306,7 +306,7 @@ gst_missing_encoder_message_new (GstElement * element,
g_return_val_if_fail (!gst_caps_is_empty (encode_caps), FALSE); g_return_val_if_fail (!gst_caps_is_empty (encode_caps), FALSE);
g_return_val_if_fail (gst_caps_is_fixed (encode_caps), FALSE); g_return_val_if_fail (gst_caps_is_fixed (encode_caps), FALSE);
description = gst_base_utils_get_encoder_description (encode_caps); description = gst_pb_utils_get_encoder_description (encode_caps);
caps = copy_and_clean_caps (encode_caps); caps = copy_and_clean_caps (encode_caps);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
@ -505,11 +505,11 @@ gst_missing_plugin_message_get_description (GstMessage * msg)
if (missing_structure_get_string_detail (msg->structure, &detail)) { if (missing_structure_get_string_detail (msg->structure, &detail)) {
if (missing_type == GST_MISSING_TYPE_URISOURCE) if (missing_type == GST_MISSING_TYPE_URISOURCE)
ret = gst_base_utils_get_source_description (detail); ret = gst_pb_utils_get_source_description (detail);
else if (missing_type == GST_MISSING_TYPE_URISINK) else if (missing_type == GST_MISSING_TYPE_URISINK)
ret = gst_base_utils_get_sink_description (detail); ret = gst_pb_utils_get_sink_description (detail);
else else
ret = gst_base_utils_get_sink_description (detail); ret = gst_pb_utils_get_sink_description (detail);
g_free (detail); g_free (detail);
} }
break; break;
@ -520,9 +520,9 @@ gst_missing_plugin_message_get_description (GstMessage * msg)
if (missing_structure_get_caps_detail (msg->structure, &caps)) { if (missing_structure_get_caps_detail (msg->structure, &caps)) {
if (missing_type == GST_MISSING_TYPE_DECODER) if (missing_type == GST_MISSING_TYPE_DECODER)
ret = gst_base_utils_get_decoder_description (caps); ret = gst_pb_utils_get_decoder_description (caps);
else else
ret = gst_base_utils_get_encoder_description (caps); ret = gst_pb_utils_get_encoder_description (caps);
gst_caps_unref (caps); gst_caps_unref (caps);
} }
break; break;

View file

@ -17,8 +17,8 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_BASE_UTILS_MISSING_PLUGINS_H__ #ifndef __GST_PB_UTILS_MISSING_PLUGINS_H__
#define __GST_BASE_UTILS_MISSING_PLUGINS_H__ #define __GST_PB_UTILS_MISSING_PLUGINS_H__
#include <gst/gstmessage.h> #include <gst/gstmessage.h>
#include <gst/gstcaps.h> #include <gst/gstcaps.h>
@ -56,5 +56,5 @@ gboolean gst_is_missing_plugin_message (GstMessage * msg);
G_END_DECLS G_END_DECLS
#endif /* __GST_BASE_UTILS_MISSING_PLUGINS_H__ */ #endif /* __GST_PB_UTILS_MISSING_PLUGINS_H__ */

View file

@ -18,12 +18,12 @@
*/ */
/** /**
* SECTION:gstbaseutils * SECTION:gstpbutils
* @short_description: General Application and Plugin Utility Library * @short_description: General Application and Plugin Utility Library
* *
* <refsect2> * <refsect2>
* <para> * <para>
* libgstbaseutils is a general utility library for plugins and applications, * libgstpbutils is a general utility library for plugins and applications,
* available since gst-plugins-base 0.10.12. It currently provides the * available since gst-plugins-base 0.10.12. It currently provides the
* following: * following:
* </para> * </para>
@ -58,12 +58,12 @@
* <para> * <para>
* You should obtain the required CFLAGS and LIBS using pkg-config on the * You should obtain the required CFLAGS and LIBS using pkg-config on the
* gstreamer-plugins-base-0.10 module. You will then also need to add * gstreamer-plugins-base-0.10 module. You will then also need to add
* '-lgstbaseutils-0.10' manually to your LIBS line. * '-lgstpbutils-0.10' manually to your LIBS line.
* </para> * </para>
* <title>Library initialisation</title> * <title>Library initialisation</title>
* <para> * <para>
* Before using any of its functions, applications and plugins must call * Before using any of its functions, applications and plugins must call
* gst_base_utils_init() to initialise the library. * gst_pb_utils_init() to initialise the library.
* </para> * </para>
* </refsect2> * </refsect2>
*/ */
@ -72,12 +72,12 @@
# include "config.h" # include "config.h"
#endif #endif
#include "base-utils.h" #include "pbutils.h"
#include "gst/gst-i18n-plugin.h" #include "gst/gst-i18n-plugin.h"
/** /**
* gst_base_utils_init: * gst_pb_utils_init:
* *
* Initialises the base utils support library. This function is not * Initialises the base utils support library. This function is not
* thread-safe. Applications should call it after calling gst_init(), * thread-safe. Applications should call it after calling gst_init(),
@ -89,7 +89,7 @@
* Since: 0.10.12 * Since: 0.10.12
*/ */
void void
gst_base_utils_init (void) gst_pb_utils_init (void)
{ {
static gboolean inited; /* FALSE */ static gboolean inited; /* FALSE */

View file

@ -17,20 +17,20 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __GST_BASE_UTILS_BASE_UTILS_H__ #ifndef __GST_PB_UTILS_BASE_UTILS_H__
#define __GST_BASE_UTILS_BASE_UTILS_H__ #define __GST_PB_UTILS_BASE_UTILS_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/utils/descriptions.h> #include <gst/pbutils/descriptions.h>
#include <gst/utils/missing-plugins.h> #include <gst/pbutils/missing-plugins.h>
#include <gst/utils/install-plugins.h> #include <gst/pbutils/install-plugins.h>
G_BEGIN_DECLS G_BEGIN_DECLS
void gst_base_utils_init (void); void gst_pb_utils_init (void);
G_END_DECLS G_END_DECLS
#endif /* __GST_BASE_UTILS_BASE_UTILS_H__ */ #endif /* __GST_PB_UTILS_BASE_UTILS_H__ */

View file

@ -1,22 +0,0 @@
lib_LTLIBRARIES = libgstbaseutils-@GST_MAJORMINOR@.la
libgstbaseutils_@GST_MAJORMINOR@_la_SOURCES = \
base-utils.c \
base-utils.h \
descriptions.c \
descriptions.h \
install-plugins.c \
install-plugins.h \
missing-plugins.c \
missing-plugins.h
libgstbaseutils_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/utils
libgstbaseutils_@GST_MAJORMINOR@include_HEADERS = \
base-utils.h \
descriptions.h \
install-plugins.h \
missing-plugins.h
libgstbaseutils_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS)
libgstbaseutils_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstbaseutils_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)

View file

@ -1,107 +0,0 @@
/* GStreamer base utils library
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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.
*/
/**
* SECTION:gstbaseutils
* @short_description: General Application and Plugin Utility Library
*
* <refsect2>
* <para>
* libgstbaseutils is a general utility library for plugins and applications,
* available since gst-plugins-base 0.10.12. It currently provides the
* following:
* </para>
* <itemizedlist>
* <listitem>
* <para>
* human-readable description strings of codecs, elements, sources, decoders,
* encoders, or sinks from decoder/encoder caps, element names, or protocol
* names.
* </para>
* </listitem>
* <listitem>
* <para>
* support for applications to initiate installation of missing plugins (if
* this is supported by the distribution or operating system used)
* </para>
* </listitem>
* <listitem>
* <para>
* API for GStreamer elements to create missing-plugin messages in order to
* communicate to the application that a certain type of plugin is missing
* (decoder, encoder, URI protocol source, URI protocol sink, named element)
* </para>
* </listitem>
* <listitem>
* <para>
* API for applications to recognise and handle missing-plugin messages
* </para>
* </listitem>
* </itemizedlist>
* <title>Linking to this library</title>
* <para>
* You should obtain the required CFLAGS and LIBS using pkg-config on the
* gstreamer-plugins-base-0.10 module. You will then also need to add
* '-lgstbaseutils-0.10' manually to your LIBS line.
* </para>
* <title>Library initialisation</title>
* <para>
* Before using any of its functions, applications and plugins must call
* gst_base_utils_init() to initialise the library.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "base-utils.h"
#include "gst/gst-i18n-plugin.h"
/**
* gst_base_utils_init:
*
* Initialises the base utils support library. This function is not
* thread-safe. Applications should call it after calling gst_init(),
* plugins should call it from their plugin_init function.
*
* This function may be called multiple times. It will do nothing if the
* library has already been initialised.
*
* Since: 0.10.12
*/
void
gst_base_utils_init (void)
{
static gboolean inited; /* FALSE */
if (inited) {
GST_LOG ("already initialised");
return;
}
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
inited = TRUE;
}

View file

@ -1,36 +0,0 @@
/* GStreamer base utils library
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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_BASE_UTILS_BASE_UTILS_H__
#define __GST_BASE_UTILS_BASE_UTILS_H__
#include <gst/gst.h>
#include <gst/utils/descriptions.h>
#include <gst/utils/missing-plugins.h>
#include <gst/utils/install-plugins.h>
G_BEGIN_DECLS
void gst_base_utils_init (void);
G_END_DECLS
#endif /* __GST_BASE_UTILS_BASE_UTILS_H__ */

View file

@ -1,922 +0,0 @@
/* GStreamer base utils library source/sink/codec description support
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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.
*/
/**
* SECTION:gstbaseutilsdescriptions
* @short_description: Provides human-readable descriptions for caps/codecs
* and encoder, decoder, URI source and URI sink elements
*
* <refsect2>
* <para>
* The above functions provide human-readable strings for media formats
* and decoder/demuxer/depayloader/encoder/muxer/payloader elements for use
* in error dialogs or other messages shown to users.
* </para>
* <para>
* gst_base_utils_add_codec_description_to_tag_list() is a utility function
* for demuxer and decoder elements to add audio/video codec tags from a
* given (fixed) #GstCaps.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "base-utils.h"
#include <string.h>
typedef enum
{
FLAG_CONTAINER = (1 << 0), /* format is a container format (muxed) */
FLAG_SYSTEMSTREAM = (1 << 1) /* match record only if caps have systemstream=true */
} FormatFlags;
typedef struct
{
const gchar *type;
const gchar *desc;
FormatFlags flags;
} FormatInfo;
static const FormatInfo formats[] = {
/* container formats with static descriptions */
{"application/ogg", "Ogg", FLAG_CONTAINER},
{"application/vnd.rn-realmedia", "Realmedia", FLAG_CONTAINER},
{"video/x-fli", "FLI/FLC/FLX Animation", FLAG_CONTAINER},
{"video/x-flv", "Flash", FLAG_CONTAINER},
{"video/x-matroska", "Matroska", FLAG_CONTAINER},
{"video/x-ms-asf", "Advanced Streaming Format (ASF)", FLAG_CONTAINER},
{"video/x-msvideo", "AVI", FLAG_CONTAINER},
{"video/x-quicktime", "Quicktime", FLAG_CONTAINER},
{"video/quicktime", "Quicktime", FLAG_CONTAINER},
/* audio formats with static descriptions */
{"audio/x-ac3", "AC-3 (ATSC A/52)", 0},
{"audio/ac3", "AC-3 (ATSC A/52)", 0},
{"audio/x-private-ac3", "DVD AC-3 (ATSC A/52)", 0},
{"audio/x-private1-ac3", "DVD AC-3 (ATSC A/52)", 0},
{"audio/x-adpcm", "ADPCM", 0},
{"audio/aiff", "Audio Interchange File Format (AIFF)", 0},
{"audio/x-alaw", "A-Law", 0},
{"audio/amr", "Adaptive Multi Rate (AMR)", 0},
{"audio/AMR", "Adaptive Multi Rate (AMR)", 0},
{"audio/AMR-WB", "Adaptive Multi Rate WideBand (AMR-WB)", 0},
{"audio/iLBC-sh", "Internet Low Bitrate Codec (iLBC)", 0},
{"audio/ms-gsm", "MS GSM", 0},
{"audio/qcelp", "QCELP", 0},
{"audio/x-adpcm", "ADPCM", 0}, /* TODO: different variants */
{"audio/x-aiff", "Audio Interchange File Format (AIFF)", 0},
{"audio/x-alac", N_("Apple Lossless Audio (ALAC)"), 0},
{"audio/x-amr-nb-sh", "Adaptive Multi Rate NarrowBand (AMR-NB)", 0},
{"audio/x-amr-wb-sh", "Adaptive Multi Rate WideBand (AMR-WB)", 0},
{"audio/x-au", "Sun .au", 0},
{"audio/x-cinepak", "Cinepak Audio", 0},
{"audio/x-dpcm", "DPCM", 0},
{"audio/x-dts", "DTS", 0},
{"audio/x-dv", "DV Audio", 0},
{"audio/x-flac", N_("Free Lossless Audio Codec (FLAC)"), 0},
{"audio/x-gsm", "GSM", 0},
{"audio/x-iec958", "S/PDIF IEC958", 0}, /* TODO: check description */
{"audio/x-iLBC", "Internet Low Bitrate Codec (iLBC)", 0},
{"audio/x-ircam", "Berkeley/IRCAM/CARL", 0},
{"audio/x-lpcm", "LPCM", 0},
{"audio/x-private1-lpcm", "DVD LPCM", 0},
{"audio/x-m4a", "MPEG-4 AAC", FLAG_CONTAINER},
{"audio/x-mod", "Module Music Format (MOD)", 0},
{"audio/x-mulaw", "Mu-Law", 0},
{"audio/x-musepack", "Musepack (MPC)", 0},
{"audio/x-nist", "Sphere NIST", 0},
{"audio/x-nsf", "Nintendo NSF", 0},
{"audio/x-paris", "Ensoniq PARIS", 0},
{"audio/x-qdm2", "QDesign Music (QDM) 2", 0},
{"audio/x-ralf-mpeg4-generic", "Real Audio Lossless (RALF)", 0},
{"audio/x-sds", "SDS", 0},
{"audio/x-shorten", "Shorten Lossless", 0},
{"audio/x-sid", "Sid", 0},
{"audio/x-sipro", "Sipro/ACELP.NET Voice", 0},
{"audio/x-spc", "SNES-SPC700 Sound File Data", 0},
{"audio/x-speex", "Speex", 0},
{"audio/x-svx", "Amiga IFF / SVX8 / SV16", 0},
{"audio/x-tta", N_("Lossless True Audio (TTA)"), 0},
{"audio/x-ttafile", N_("Lossless True Audio (TTA)"), 0},
{"audio/x-vnd.sony.atrac3", "Sony ATRAC3", 0},
{"audio/x-vorbis", "Vorbis", 0},
{"audio/x-voc", "SoundBlaster VOC", 0},
{"audio/x-w64", "Sonic Foundry Wave64", 0},
{"audio/x-wav", "WAV", 0},
{"audio/x-wavpack", "Wavpack", 0},
{"audio/x-wavpack-correction", "Wavpack", 0},
{"audio/x-wms", N_("Windows Media Speech"), 0},
{"audio/x-voxware", "Voxware", 0},
/* video formats with static descriptions */
{"video/sp5x", "Sunplus JPEG 5.x", 0},
{"video/vivo", "Vivo", 0},
{"video/x-3ivx", "3ivx", 0},
{"video/x-4xm", "4X Techologies Video", 0},
{"video/x-apple-video", "Apple video", 0},
{"video/x-camtasia", "TechSmith Camtasia", 0},
{"video/x-cdxa", "RIFF/CDXA (VCD)", 0},
{"video/x-cinepak", "Cinepak Video", 0},
{"video/x-cirrus-logic-accupak", "Cirrus Logipak AccuPak", 0},
{"video/x-compressed-yuv", N_("CYUV Lossless"), 0},
{"video/x-dirac", "Dirac", 0},
{"video/x-dvd-subpicture", "DVD subpicture", 0},
{"video/x-ffv", N_("FFMpeg v1"), 0},
{"video/x-flash-screen", "Flash Screen Video", 0},
{"video/x-flash-video", "Flash Video", 0},
{"video/x-h261", "H.261", 0},
{"video/x-huffyuv", "Huffyuv", 0},
{"video/x-intel-h263", "Intel H.263", 0},
{"video/x-jpeg", "Motion JPEG", 0},
/* { "video/x-jpeg-b", "", 0 }, does this actually exist? */
{"video/x-mjpeg", "Motion-JPEG", 0},
{"video/x-mjpeg-b", "Motion-JPEG format B", 0},
{"video/mpegts", "MPEG-2 Transport Stream", FLAG_CONTAINER},
{"video/x-mng", "Multiple Image Network Graphics (MNG)", 0},
{"video/x-mszh", N_("Lossless MSZH"), 0},
{"video/x-msvideocodec", "Microsoft Video 1", 0},
{"video/x-mve", "Interplay MVE", FLAG_CONTAINER},
{"video/x-nut", "NUT", FLAG_CONTAINER},
{"video/x-nuv", "MythTV NuppelVideo (NUV)", FLAG_CONTAINER},
{"video/x-qdrw", "Apple QuickDraw", 0},
{"video/x-raw-gray", N_("Uncompressed Gray Image"), 0},
{"video/x-smc", "Apple SMC", 0},
{"video/x-smoke", "Smoke", 0},
{"video/x-tarkin", "Tarkin", 0},
{"video/x-theora", "Theora", 0},
{"video/x-rle", N_("Run-length encoding"), 0},
{"video/x-ultimotion", "IBM UltiMotion", 0},
{"video/x-vcd", "VideoCD (VCD)", 0},
{"video/x-vmnc", "VMWare NC", 0},
{"video/x-vp3", "On2 VP3", 0},
{"video/x-vp5", "On2 VP5", 0},
{"video/x-vp6", "On2 VP6", 0},
{"video/x-vp6-flash", "On2 VP6/Flash", 0},
{"video/x-vp7", "On2 VP7", 0},
{"video/x-xvid", "XVID MPEG-4", 0},
{"video/x-zlib", "Lossless zlib video", 0},
/* image formats with static descriptions */
{"image/bmp", "BMP", 0},
{"image/x-bmp", "BMP", 0},
{"image/x-MS-bmp", "BMP", 0},
{"image/gif", "GIF", 0},
{"image/jpeg", "JPEG", 0},
{"image/jng", "JPEG Network Graphics (JNG)", 0},
{"image/png", "PNG", 0},
{"image/pbm", "PBM", 0},
{"image/ppm", "PPM", 0},
{"image/svg+xml", "Scalable Vector Graphics (SVG)", 0},
{"image/tiff", "TIFF", 0},
{"image/x-cmu-raster", "CMU Raster Format", 0},
{"image/x-icon", "ICO", 0},
{"image/x-xcf", "XFC", 0},
{"image/x-pixmap", "XPM", 0},
{"image/x-xpixmap", "XPM", 0},
{"image/x-quicktime", "QuickTime Image Format (QTIF)", 0},
{"image/x-sun-raster", "Sun Raster Format (RAS)", 0},
{"image/x-tga", "TGA", 0},
/* subtitle formats with static descriptions */
{"application/x-subtitle-sami", N_("Sami subtitle format"), 0},
{"application/x-subtitle-tmplayer", N_("TMPlayer subtitle format"), 0},
/* add variant field to typefinder? { "application/x-subtitle", N_("subtitle"), 0}, */
/* formats with dynamic descriptions */
{"audio/mpeg", NULL, 0},
{"audio/x-mace", NULL, 0},
{"audio/x-pn-realaudio", NULL, 0},
{"audio/x-raw-int", NULL, 0},
{"audio/x-raw-float", NULL, 0},
{"audio/x-wma", NULL, 0},
{"video/mpeg", NULL, FLAG_CONTAINER | FLAG_SYSTEMSTREAM},
{"video/mpeg", NULL, 0},
{"video/x-asus", NULL, 0},
{"video/x-ati-vcr", NULL, 0},
{"video/x-divx", NULL, 0},
{"video/x-dv", "Digital Video (DV) System Stream",
FLAG_CONTAINER | FLAG_SYSTEMSTREAM},
{"video/x-dv", "Digital Video (DV)", 0},
{"video/x-h263", NULL, 0},
{"video/x-h264", NULL, 0},
{"video/x-indeo", NULL, 0},
{"video/x-msmpeg", NULL, 0},
{"video/x-pn-realvideo", NULL, 0},
#if 0
/* do these exist? are they used anywhere? */
{"video/x-pn-multirate-realvideo", NULL, 0},
{"audio/x-pn-multirate-realaudio", NULL, 0},
{"audio/x-pn-multirate-realaudio-live", NULL, 0},
#endif
{"video/x-truemotion", NULL, 0},
{"video/x-raw-rgb", NULL, 0},
{"video/x-raw-yuv", NULL, 0},
{"video/x-svq", NULL, 0},
{"video/x-wmv", NULL, 0},
{"video/x-xan", NULL, 0}
};
/* returns static descriptions and dynamic ones (such as video/x-raw-yuv),
* or NULL if caps aren't known at all */
static gchar *
format_info_get_desc (const FormatInfo * info, const GstCaps * caps)
{
const GstStructure *s;
g_assert (info != NULL);
if (info->desc != NULL)
return g_strdup (_(info->desc));
s = gst_caps_get_structure (caps, 0);
if (strcmp (info->type, "video/x-raw-yuv") == 0) {
const gchar *ret = NULL;
guint32 fourcc = 0;
gst_structure_get_fourcc (s, "format", &fourcc);
switch (fourcc) {
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
ret = _("Uncompressed planar YUV 4:2:0");
break;
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
ret = _("Uncompressed planar YVU 4:2:0");
break;
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
ret = _("Uncompressed packed YUV 4:2:2");
break;
case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
ret = _("Uncompressed packed YUV 4:1:0");
break;
case GST_MAKE_FOURCC ('Y', 'V', 'U', '9'):
ret = _("Uncompressed packed YVU 4:1:0");
break;
case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
ret = _("Uncompressed packed YUV 4:2:2");
break;
case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
ret = _("Uncompressed packed YUV 4:1:1");
break;
case GST_MAKE_FOURCC ('I', 'Y', 'U', '2'):
ret = _("Uncompressed packed YUV 4:4:4");
break;
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
ret = _("Uncompressed planar YUV 4:2:2");
break;
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
ret = _("Uncompressed planar YUV 4:1:1");
break;
case GST_MAKE_FOURCC ('Y', '8', '0', '0'):
ret = _("Uncompressed black and white Y-plane");
break;
default:
ret = _("Uncompressed YUV");
break;
}
return g_strdup (ret);
} else if (strcmp (info->type, "video/x-raw-rgb") == 0) {
const gchar *rgb_str;
gint depth = 0;
gst_structure_get_int (s, "depth", &depth);
rgb_str = gst_structure_has_field (s, "alpha_mask") ? "RGBA" : "RGB";
if (gst_structure_has_field (s, "paletted_data")) {
return g_strdup_printf (_("Uncompressed palettized %d-bit %s"), depth,
rgb_str);
} else {
return g_strdup_printf ("Uncompressed %d-bit %s", depth, rgb_str);
}
} else if (strcmp (info->type, "video/x-h263") == 0) {
const gchar *variant, *ret;
variant = gst_structure_get_string (s, "variant");
if (variant == NULL)
ret = "H.263";
else if (strcmp (variant, "itu") == 0)
ret = "ITU H.26n"; /* why not ITU H.263? (tpm) */
else if (strcmp (variant, "lead") == 0)
ret = "Lead H.263";
else if (strcmp (variant, "microsoft") == 0)
ret = "Microsoft H.263";
else if (strcmp (variant, "vdolive") == 0)
ret = "VDOLive";
else if (strcmp (variant, "vivo") == 0)
ret = "Vivo H.263";
else if (strcmp (variant, "xirlink") == 0)
ret = "Xirlink H.263";
else {
GST_WARNING ("Unknown H263 variant '%s'", variant);
ret = "H.263";
}
return g_strdup (ret);
} else if (strcmp (info->type, "video/x-h264") == 0) {
const gchar *variant, *ret;
variant = gst_structure_get_string (s, "variant");
if (variant == NULL)
ret = "H.264";
else if (strcmp (variant, "itu") == 0)
ret = "ITU H.264";
else if (strcmp (variant, "videosoft") == 0)
ret = "Videosoft H.264";
else {
GST_WARNING ("Unknown H264 variant '%s'", variant);
ret = "H.264";
}
return g_strdup (ret);
} else if (strcmp (info->type, "video/x-divx") == 0) {
gint ver = 0;
if (!gst_structure_get_int (s, "divxversion", &ver) || ver <= 2) {
GST_WARNING ("Unexpected DivX version in %" GST_PTR_FORMAT, caps);
return g_strdup ("DivX MPEG-4");
}
return g_strdup_printf (_("DivX MPEG-4 Version %d"), ver);
} else if (strcmp (info->type, "video/x-msmpeg") == 0) {
gint ver = 0;
if (!gst_structure_get_int (s, "msmpegversion", &ver) ||
ver < 40 || ver > 49) {
GST_WARNING ("Unexpected msmpegversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Microsoft MPEG-4 4.x");
}
return g_strdup_printf ("Microsoft MPEG-4 4.%d", ver % 10);
} else if (strcmp (info->type, "video/x-truemotion") == 0) {
gint ver = 0;
gst_structure_get_int (s, "trueversion", &ver);
switch (ver) {
case 1:
return g_strdup_printf ("Duck TrueMotion 1");
case 2:
return g_strdup_printf ("TrueMotion 2.0");
default:
GST_WARNING ("Unexpected trueversion in %" GST_PTR_FORMAT, caps);
break;
}
return g_strdup_printf ("TrueMotion");
} else if (strcmp (info->type, "video/x-xan") == 0) {
gint ver = 0;
if (!gst_structure_get_int (s, "wcversion", &ver) || ver < 1) {
GST_WARNING ("Unexpected wcversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Xan Wing Commander");
}
return g_strdup_printf ("Xan Wing Commander %u", ver);
} else if (strcmp (info->type, "video/x-indeo") == 0) {
gint ver = 0;
if (!gst_structure_get_int (s, "indeoversion", &ver) || ver < 2) {
GST_WARNING ("Unexpected indeoversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Intel Indeo");
}
return g_strdup_printf ("Intel Indeo %u", ver);
} else if (strcmp (info->type, "audio/x-wma") == 0) {
gint ver = 0;
gst_structure_get_int (s, "wmaversion", &ver);
switch (ver) {
case 1:
case 2:
case 3:
return g_strdup_printf ("Windows Media Audio %d", ver + 6);
default:
break;
}
GST_WARNING ("Unexpected wmaversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Windows Media Audio");
} else if (strcmp (info->type, "video/x-wmv") == 0) {
gint ver = 0;
gst_structure_get_int (s, "wmvversion", &ver);
switch (ver) {
case 1:
case 2:
case 3:
return g_strdup_printf ("Windows Media Video %d", ver + 6);
default:
break;
}
GST_WARNING ("Unexpected wmvversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Windows Media Video");
} else if (strcmp (info->type, "audio/x-mace") == 0) {
gint ver = 0;
gst_structure_get_int (s, "maceversion", &ver);
if (ver == 3 || ver == 6) {
return g_strdup_printf ("MACE-%d", ver);
} else {
GST_WARNING ("Unexpected maceversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("MACE");
}
} else if (strcmp (info->type, "video/x-svq") == 0) {
gint ver = 0;
gst_structure_get_int (s, "svqversion", &ver);
if (ver == 1 || ver == 3) {
return g_strdup_printf ("Sorensen Video %d", ver);
} else {
GST_WARNING ("Unexpected svqversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Sorensen Video");
}
} else if (strcmp (info->type, "video/x-asus") == 0) {
gint ver = 0;
gst_structure_get_int (s, "asusversion", &ver);
if (ver == 1 || ver == 2) {
return g_strdup_printf ("Asus Video %d", ver);
} else {
GST_WARNING ("Unexpected asusversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("Asus Video");
}
} else if (strcmp (info->type, "video/x-ati-vcr") == 0) {
gint ver = 0;
gst_structure_get_int (s, "vcrversion", &ver);
if (ver == 1 || ver == 2) {
return g_strdup_printf ("ATI VCR %d", ver);
} else {
GST_WARNING ("Unexpected acrversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("ATI VCR");
}
} else if (strcmp (info->type, "audio/mpeg") == 0) {
gint ver = 0, layer = 0;
gst_structure_get_int (s, "mpegversion", &ver);
switch (ver) {
case 1:
gst_structure_get_int (s, "layer", &layer);
switch (layer) {
case 1:
case 2:
case 3:
return g_strdup_printf ("MPEG-1 Layer %d (MP%d)", layer, layer);
default:
break;
}
GST_WARNING ("Unexpected MPEG-1 layer in %" GST_PTR_FORMAT, caps);
return g_strdup ("MPEG-1 Audio");
case 4:
return g_strdup ("MPEG-4 AAC");
default:
break;
}
GST_WARNING ("Unexpected audio mpegversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("MPEG Audio");
} else if (strcmp (info->type, "audio/x-pn-realaudio") == 0) {
gint ver = 0;
gst_structure_get_int (s, "raversion", &ver);
switch (ver) {
case 1:
return g_strdup ("RealAudio 14k4bps");
case 2:
return g_strdup ("RealAudio 28k8bps");
case 8:
return g_strdup ("RealAudio G2 (Cook)");
default:
break;
}
GST_WARNING ("Unexpected raversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("RealAudio");
} else if (strcmp (info->type, "video/x-pn-realvideo") == 0) {
gint ver = 0;
gst_structure_get_int (s, "rmversion", &ver);
switch (ver) {
case 1:
return g_strdup ("RealVideo 1.0");
case 2:
return g_strdup ("RealVideo 2.0");
case 3:
return g_strdup ("RealVideo 3.0");
case 4:
return g_strdup ("RealVideo 4.0");
default:
break;
}
GST_WARNING ("Unexpected rmversion in %" GST_PTR_FORMAT, caps);
return g_strdup ("RealVideo");
} else if (strcmp (info->type, "video/mpeg") == 0) {
gboolean sysstream;
gint ver = 0;
if (!gst_structure_get_boolean (s, "systemstream", &sysstream) ||
!gst_structure_get_int (s, "mpegversion", &ver) || ver < 1 || ver > 4) {
GST_WARNING ("Missing fields in mpeg video caps %" GST_PTR_FORMAT, caps);
} else {
if (sysstream) {
return g_strdup_printf ("MPEG-%d System Stream", ver);
} else {
return g_strdup_printf ("MPEG-%d Video", ver);
}
}
return g_strdup ("MPEG Video");
} else if (strcmp (info->type, "audio/x-raw-int") == 0) {
gint bitdepth = 0;
/* 8-bit pcm might not have depth field (?) */
if (!gst_structure_get_int (s, "depth", &bitdepth))
gst_structure_get_int (s, "width", &bitdepth);
if (bitdepth != 0)
return g_strdup_printf (_("Raw %d-bit PCM audio"), bitdepth);
else
return g_strdup (_("Raw PCM audio"));
} else if (strcmp (info->type, "audio/x-raw-float") == 0) {
gint bitdepth = 0;
gst_structure_get_int (s, "width", &bitdepth);
if (bitdepth != 0)
return g_strdup_printf (_("Raw %d-bit floating-point audio"), bitdepth);
else
return g_strdup (_("Raw floating-point audio"));
}
return NULL;
}
/* returns format info structure, will return NULL for dynamic media types! */
static const FormatInfo *
find_format_info (const GstCaps * caps)
{
const GstStructure *s;
const gchar *media_type;
guint i;
s = gst_caps_get_structure (caps, 0);
media_type = gst_structure_get_name (s);
for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
if (strcmp (media_type, formats[i].type) == 0) {
gboolean is_sys = FALSE;
if ((formats[i].flags & FLAG_SYSTEMSTREAM) == 0)
return &formats[i];
/* this record should only be matched if the systemstream field is set */
if (gst_structure_get_boolean (s, "systemstream", &is_sys) && is_sys)
return &formats[i];
}
}
return NULL;
}
static gboolean
caps_are_rtp_caps (const GstCaps * caps, const gchar * media, gchar ** format)
{
const GstStructure *s;
const gchar *str;
g_assert (media != NULL && format != NULL);
s = gst_caps_get_structure (caps, 0);
if (!gst_structure_has_name (s, "application/x-rtp"))
return FALSE;
if (!gst_structure_has_field_typed (s, "media", G_TYPE_STRING))
return FALSE;
str = gst_structure_get_string (s, "media");
if (str == NULL || !g_str_equal (str, media))
return FALSE;
str = gst_structure_get_string (s, "encoding-name");
if (str == NULL || *str == '\0')
return FALSE;
*format = g_strdup (str);
return TRUE;
}
/**
* gst_base_utils_get_source_description:
* @protocol: the protocol the source element needs to handle, e.g. "http"
*
* Returns a localised string describing a source element handling the protocol
* specified in @protocol, for use in error dialogs or other messages to be
* seen by the user. Should never return NULL unless @protocol is invalid.
*
* This function is mainly for internal use, applications would typically
* use gst_missing_plugin_message_get_description() to get a description of
* a missing feature from a missing-plugin message.
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_source_description (const gchar * protocol)
{
gchar *proto_uc, *ret;
g_return_val_if_fail (protocol != NULL, NULL);
if (strcmp (protocol, "cdda") == 0)
return g_strdup (_("Audio CD source"));
if (strcmp (protocol, "dvd") == 0)
return g_strdup (_("DVD source"));
if (strcmp (protocol, "rtsp") == 0)
return g_strdup (_("Real Time Streaming Protocol (RTSP) source"));
/* TODO: what about mmst, mmsu, mmsh? */
if (strcmp (protocol, "mms") == 0)
return g_strdup (_("Microsoft Media Server (MMS) protocol source"));
/* make protocol uppercase */
proto_uc = g_ascii_strup (protocol, -1);
/* TODO: find out how to add a comment for translators to the source code
* (and tell them to make the first letter uppercase below if they move
* the protocol to the middle or end of the string) */
ret = g_strdup_printf (_("%s protocol source"), proto_uc);
g_free (proto_uc);
return ret;
}
/**
* gst_base_utils_get_sink_description:
* @protocol: the protocol the sink element needs to handle, e.g. "http"
*
* Returns a localised string describing a sink element handling the protocol
* specified in @protocol, for use in error dialogs or other messages to be
* seen by the user. Should never return NULL unless @protocol is invalid.
*
* This function is mainly for internal use, applications would typically
* use gst_missing_plugin_message_get_description() to get a description of
* a missing feature from a missing-plugin message.
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_sink_description (const gchar * protocol)
{
gchar *proto_uc, *ret;
g_return_val_if_fail (protocol != NULL, NULL);
/* make protocol uppercase */
proto_uc = g_ascii_strup (protocol, -1);
/* TODO: find out how to add a comment for translators to the source code
* (and tell them to make the first letter uppercase below if they move
* the protocol to the middle or end of the string) */
ret = g_strdup_printf ("%s protocol sink", proto_uc);
g_free (proto_uc);
return ret;
}
/**
* gst_base_utils_get_decoder_description:
* @caps: the (fixed) #GstCaps for which an decoder description is needed
*
* Returns a localised string describing an decoder for the format specified
* in @caps, for use in error dialogs or other messages to be seen by the user.
* Should never return NULL unless @factory_name or @caps are invalid.
*
* This function is mainly for internal use, applications would typically
* use gst_missing_plugin_message_get_description() to get a description of
* a missing feature from a missing-plugin message.
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_decoder_description (const GstCaps * caps)
{
gchar *str, *ret;
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
/* special-case RTP caps */
if (caps_are_rtp_caps (caps, "video", &str)) {
ret = g_strdup_printf (_("%s video RTP depayloader"), str);
} else if (caps_are_rtp_caps (caps, "audio", &str)) {
ret = g_strdup_printf (_("%s audio RTP depayloader"), str);
} else if (caps_are_rtp_caps (caps, "application", &str)) {
ret = g_strdup_printf (_("%s RTP depayloader"), str);
} else {
const FormatInfo *info;
str = gst_base_utils_get_codec_description (caps);
info = find_format_info (caps);
if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) {
ret = g_strdup_printf (_("%s demuxer"), str);
} else {
ret = g_strdup_printf (_("%s decoder"), str);
}
}
g_free (str);
return ret;
}
/**
* gst_base_utils_get_encoder_description:
* @caps: the (fixed) #GstCaps for which an encoder description is needed
*
* Returns a localised string describing an encoder for the format specified
* in @caps, for use in error dialogs or other messages to be seen by the user.
* Should never return NULL unless @factory_name or @caps are invalid.
*
* This function is mainly for internal use, applications would typically
* use gst_missing_plugin_message_get_description() to get a description of
* a missing feature from a missing-plugin message.
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_encoder_description (const GstCaps * caps)
{
gchar *str, *ret;
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
/* special-case RTP caps */
if (caps_are_rtp_caps (caps, "video", &str)) {
ret = g_strdup_printf (_("%s video RTP payloader"), str);
} else if (caps_are_rtp_caps (caps, "audio", &str)) {
ret = g_strdup_printf (_("%s audio RTP payloader"), str);
} else if (caps_are_rtp_caps (caps, "application", &str)) {
ret = g_strdup_printf (_("%s RTP payloader"), str);
} else {
const FormatInfo *info;
str = gst_base_utils_get_codec_description (caps);
info = find_format_info (caps);
if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) {
ret = g_strdup_printf (_("%s muxer"), str);
} else {
ret = g_strdup_printf (_("%s encoder"), str);
}
}
g_free (str);
return ret;
}
/**
* gst_base_utils_get_element_description:
* @factory_name: the name of the element, e.g. "gnomevfssrc"
*
* Returns a localised string describing the given element, for use in
* error dialogs or other messages to be seen by the user. Should never
* return NULL unless @factory_name is invalid.
*
* This function is mainly for internal use, applications would typically
* use gst_missing_plugin_message_get_description() to get a description of
* a missing feature from a missing-plugin message.
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_element_description (const gchar * factory_name)
{
gchar *ret;
g_return_val_if_fail (factory_name != NULL, NULL);
ret = g_strdup_printf (_("GStreamer element %s"), factory_name);
if (ret && g_str_has_prefix (ret, factory_name))
*ret = g_ascii_toupper (*ret);
return ret;
}
/**
* gst_base_utils_add_codec_description_to_tag_list:
* @taglist: a #GstTagList
* @codec_tag: a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC,
* #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC
* @caps: the (fixed) #GstCaps for which a codec tag should be added.
*
* Adds a codec tag describing the format specified by @caps to @taglist.
*
* Returns: TRUE if a codec tag was added, FALSE otherwise.
*/
gboolean
gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist,
const gchar * codec_tag, const GstCaps * caps)
{
const FormatInfo *info;
gchar *desc;
g_return_val_if_fail (taglist != NULL, FALSE);
g_return_val_if_fail (GST_IS_TAG_LIST (taglist), FALSE);
g_return_val_if_fail (codec_tag != NULL, FALSE);
g_return_val_if_fail (gst_tag_exists (codec_tag), FALSE);
g_return_val_if_fail (gst_tag_get_type (codec_tag) == G_TYPE_STRING, FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
info = find_format_info (caps);
if (info == NULL)
return FALSE;
desc = format_info_get_desc (info, caps);
gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, codec_tag, desc, NULL);
g_free (desc);
return TRUE;
}
/**
* gst_base_utils_get_codec_description:
* @caps: the (fixed) #GstCaps for which an format description is needed
*
* Returns a localised (as far as this is possible) string describing the
* media format specified in @caps, for use in error dialogs or other messages
* to be seen by the user. Should never return NULL unless @caps is invalid.
*
* Also see the convenience function
* gst_base_utils_add_codec_description_to_tag_list().
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_base_utils_get_codec_description (const GstCaps * caps)
{
const FormatInfo *info;
gchar *str, *comma;
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
info = find_format_info (caps);
if (info) {
str = format_info_get_desc (info, caps);
} else {
str = gst_caps_to_string (caps);
/* cut off everything after the media type, if there is anything */
if ((comma = strchr (str, ','))) {
*comma = '\0';
g_strchomp (str);
/* we could do something more elaborate here, like taking into account
* audio/, video/, image/ and application/ prefixes etc. */
}
GST_WARNING ("No description available for media type: %s", str);
}
return str;
}
#if 0
void
gst_base_utils_list_all (void)
{
gint i;
g_print ("static const gchar *caps_strings[] = { ");
for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
if (formats[i].desc != NULL)
g_print (" \"%s\", ", formats[i].type);
}
g_print ("\n#if 0\n");
for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
if (formats[i].desc == NULL)
g_print (" \"%s\", \n", formats[i].type);
}
g_print ("\n#endif\n");
}
#endif

View file

@ -1,58 +0,0 @@
/* GStreamer base utils library source/sink/codec description support
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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_BASE_UTILS_DESCRIPTIONS_H__
#define __GST_BASE_UTILS_DESCRIPTIONS_H__
#include <gst/gsttaglist.h>
#include <gst/gstcaps.h>
G_BEGIN_DECLS
/*
* functions for use by demuxers or decoders to add CODEC tags to tag lists
* from caps
*/
gboolean gst_base_utils_add_codec_description_to_tag_list (GstTagList * taglist,
const gchar * codec_tag,
const GstCaps * caps);
gchar * gst_base_utils_get_codec_description (const GstCaps * caps);
/*
* functions mainly used by the missing plugins message creation functions to
* find descriptions of what exactly is missing
*/
gchar * gst_base_utils_get_source_description (const gchar * protocol);
gchar * gst_base_utils_get_sink_description (const gchar * protocol);
gchar * gst_base_utils_get_decoder_description (const GstCaps * caps);
gchar * gst_base_utils_get_encoder_description (const GstCaps * caps);
gchar * gst_base_utils_get_element_description (const gchar * factory_name);
G_END_DECLS
#endif /* __GST_BASE_UTILS_DESCRIPTIONS_H__ */

View file

@ -1,720 +0,0 @@
/* GStreamer base utils library plugin install support for applications
* Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2006 Ryan Lortie <desrt desrt ca>
*
* 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.
*/
/**
* SECTION:gstbaseutilsinstallplugins
* @short_description: Missing plugin installation support for applications
*
* <refsect2>
* <title>Overview</title>
* <para>
* Using this API, applications can request the installation of missing
* GStreamer plugins. These may be missing decoders/demuxers or encoders/muxers
* for a certain format, sources or sinks for a certain URI protocol
* (e.g. 'http'), or certain elements known by their element factory name
* ('audioresample').
* </para>
* <para>
* Whether plugin installation is supported or not depends on the operating
* system and/or distribution in question. The vendor of the operating system
* needs to make sure the necessary hooks and mechanisms are in place for
* plugin installation to work. See below for more detailed information.
* </para>
* <para>
* From the application perspective, plugin installation is usually triggered
* either
* <itemizedlist>
* <listitem><para>
* when the application itself has found that it wants or needs to install a
* certain element
* </para></listitem>
* <listitem><para>
* when the application has been notified by an element (such as playbin or
* decodebin) that one or more plugins are missing <emphasis>and</emphasis>
* the application has decided that it wants to install one or more of those
* missing plugins
* </para></listitem>
* </itemizedlist>
* </para>
* <title>Detail Strings</title>
* <para>
* The install functions in this section all take one or more 'detail strings'.
* These detail strings contain information about the type of plugin that
* needs to be installed (decoder, encoder, source, sink, or named element),
* and some additional information such GStreamer version used and a
* human-readable description of the component to install for user dialogs.
* </para>
* <para>
* Applications should not concern themselves with the composition of the
* string itself. They should regard the string as if it was a shared secret
* between GStreamer and the plugin installer application.
* </para>
* <para>
* Detail strings can be obtained using the function
* gst_missing_plugin_message_get_installer_detail() on a missing-plugin
* message. Such a message will either have been found by the application on
* a pipeline's #GstBus, or the application will have created it itself using
* gst_missing_element_message_new(), gst_missing_decoder_message_new(),
* gst_missing_encoder_message_new(), gst_missing_uri_sink_message_new(), or
* gst_missing_uri_source_message_new().
* </para>
* <title>Plugin Installation from the Application Perspective</title>
* <para>
* For each GStreamer element/plugin/component that should be installed, the
* application needs one of those 'installer detail' string mentioned in the
* previous section. This string can be obtained, as already mentioned above,
* from a missing-plugin message using the function
* gst_missing_plugin_message_get_installer_detail(). The missing-plugin
* message is either posted by another element and then found on the bus
* by the application, or the application has created it itself as described
* above.
* </para>
* <para>
* The application will then call gst_install_plugins_async(), passing a
* #NULL-terminated array of installer detail strings, and a function that
* should be called when the installation of the plugins has finished
* (successfully or not). Optionally, a #GstInstallPluginsContext created
* with gst_install_plugins_context_new() may be passed as well. This way
* additional optional arguments like the application window's XID can be
* passed to the external installer application.
* </para>
* <para>
* gst_install_plugins_async() will return almost immediately, with the
* return code indicating whether plugin installation was started or not.
* If the necessary hooks for plugin installation are in place and an
* external installer application has in fact been called, the passed in
* function will be called with a result code as soon as the external installer
* has finished. If the result code indicates that new plugins have been
* installed, the application will want to call gst_update_registry() so the
* run-time plugin registry is updated and the new plugins are made available
* to the application.
* <note>
* A Gtk/GLib main loop must be running in order for the result function to
* be called when the external installer has finished. If this is not the case,
* make sure to regularly call
* <programlisting>
* g_main_context_iteration (NULL,FALSE);
* </programlisting>
* from your code.
* </note>
* </para>
* <title>Plugin Installation from the Vendor/Distribution Perspective</title>
* <para>
* <emphasis>1. Installer hook</emphasis>
* </para>
* <para>
* When GStreamer applications initiate plugin installation via
* gst_install_plugins_async() or gst_install_plugins_sync(), a pre-defined
* helper application will be called.
* </para>
* <para>
* The exact path of the helper application to be called is set at compile
* time, usually by the <literal>./configure</literal> script based on the
* install prefix. For a normal package build into the <literal>/usr</literal>
* prefix, this will usually default to
* <filename>/usr/libexec/gst-install-plugins-helper</filename> or
* <filename>/usr/lib/gst-install-plugins-helper</filename>.
* </para>
* <para>
* Vendors/distros who want to support GStreamer plugin installation should
* either provide such a helper script/application or use the
* <literal>./configure</literal> option
* <literal>--with-install-plugins-helper=/path/to/installer</literal> to
* make GStreamer call an installer of their own directly.
* </para>
* <para>
* It is strongly recommended that vendors provide a small helper application
* as interlocutor to the real installer though, even more so if command line
* argument munging is required to transform the command line arguments
* passed by GStreamer to the helper application into arguments that are
* understood by the reeal installer.
* </para>
* <para>
* The helper application path defined at compile time can be overriden at
* runtime by setting the <envar>GST_INSTALL_PLUGINS_HELPER</envar>
* environment variable. This can be useful for testing/debugging purposes.
* </para>
* <para>
* <emphasis>2. Arguments passed to the install helper</emphasis>
* </para>
* <para>
* GStreamer will pass the following arguments to the install helper (this is
* in addition to the path of the executable itself, which is by convention
* argv[0]):
* <itemizedlist>
* <listitem><para>
* none to many optional arguments in the form of
* <literal>--foo-bar=val</literal>. Example:
* <literal>--transient-for=XID</literal> where XID is the X Window ID of
* the main window of the calling application (so the installer can make
* itself transient to that window). Unknown optional arguments should
* be ignored by the installer.
* </para></listitem>
* <listitem><para>
* one 'installer detail string' argument for each plugin to be installed;
* these strings will have a <literal>gstreamer</literal> prefix; the
* exact format of the detail string is explained below
* </para></listitem>
* </itemizedlist>
* </para>
* <para>
* <emphasis>3. Detail string describing the missing plugin</emphasis>
* </para>
* <para>
* The string is in UTF-8 encoding and is made up of several fields, separated
* by '|' characters (but neither the first nor the last character is a '|').
* The fields are:
* <itemizedlist>
* <listitem><para>
* plugin system identifier, ie. "gstreamer"
* </para><para>
* This identifier determines the format of the rest of the detail string.
* Automatic plugin installers should not process detail strings with
* unknown identifiers. This allows other plugin-based libraries to use
* the same mechanism for their automatic plugin installation needs, or
* for the format to be changed should it turn out to be insufficient.
* </para></listitem>
* <listitem><para>
* plugin system version, e.g. "0.10"
* </para><para>
* This is required so that when there is a GStreamer-0.12 or GStreamer-1.0
* at some point in future, the different major versions can still co-exist
* and use the same plugin install mechanism in the same way.
* </para></listitem>
* <listitem><para>
* application identifier, e.g. "totem"
* </para><para>
* This may also be in the form of "pid/12345" if the program name can't
* be obtained for some reason.
* </para></listitem>
* <listitem><para>
* human-readable localised description of the required component,
* e.g. "Vorbis audio decoder"
* </para></listitem>
* <listitem><para>
* identifier string for the required component (see below for details about
* how to map this to the package/plugin that needs installing), e.g.
* <itemizedlist>
* <listitem><para>
* urisource-$(PROTOCOL_REQUIRED), e.g. urisource-http or urisource-mms
* </para></listitem>
* <listitem><para>
* element-$(ELEMENT_REQUIRED), e.g. element-ffmpegcolorspace
* </para></listitem>
* <listitem><para>
* decoder-$(CAPS_REQUIRED), e.g. (do read below for more details!):
* <itemizedlist>
* <listitem><para>decoder-audio/x-vorbis</para></listitem>
* <listitem><para>decoder-application/ogg</para></listitem>
* <listitem><para>decoder-audio/mpeg, mpegversion=(int)4</para></listitem>
* <listitem><para>decoder-video/mpeg, systemstream=(boolean)true, mpegversion=(int)2</para></listitem>
</itemizedlist>
* </para></listitem>
* <listitem><para>
* encoder-$(CAPS_REQUIRED), e.g. encoder-audio/x-vorbis
* </para></listitem>
* </itemizedlist>
* </para></listitem>
* <listitem><para>
* optional further fields not yet specified
* </para></listitem>
* </itemizedlist>
* </para>
* <para>
* An entire ID string might then look like this, for example:
* <literal>
* gstreamer|0.10|totem|Vorbis audio decoder|decoder-audio/x-vorbis
* </literal>
* </para>
* <para>
* Plugin installers parsing this ID string should expect further fields also
* separated by '|' symbols and either ignore them, warn the user, or error
* out when encountering them.
* </para>
* <para>
* Those unfamiliar with the GStreamer 'caps' system should note a few things
* about the caps string used in the above decoder/encoder case:
* <itemizedlist>
* <listitem><para>
* the first part ("video/mpeg") of the caps string is a GStreamer media
* type and <emphasis>not</emphasis> a MIME type. Wherever possible, the
* GStreamer media type will be the same as the corresponding MIME type,
* but often it is not.
* </para></listitem>
* <listitem><para>
* a caps string may or may not have additional comma-separated fields
* of various types (as seen in the examples above)
* </para></listitem>
* <listitem><para>
* the caps string of a 'required' component (as above) will always have
* fields with fixed values, whereas an introspected string (see below)
* may have fields with non-fixed values. Compare for example:
* <itemizedlist>
* <listitem><para>
* <literal>audio/mpeg, mpegversion=(int)4</literal> vs.
* <literal>audio/mpeg, mpegversion=(int){2, 4}</literal>
* </para></listitem>
* <listitem><para>
* <literal>video/mpeg, mpegversion=(int)2</literal> vs.
* <literal>video/mpeg, systemstream=(boolean){ true, false}, mpegversion=(int)[1, 2]</literal>
* </para></listitem>
* </itemizedlist>
* </para></listitem>
* </itemizedlist>
* </para>
* <para>
* <emphasis>4. Exit codes the installer should return</emphasis>
* </para>
* <para>
* The installer should return one of the following exit codes when it exits:
* <itemizedlist>
* <listitem><para>
* 0 if all of the requested plugins could be installed
* (#GST_INSTALL_PLUGINS_SUCCESS)
* </para></listitem>
* <listitem><para>
* 1 if no appropriate installation candidate for any of the requested
* plugins could be found. Only return this if nothing has been installed
* (#GST_INSTALL_PLUGINS_NOT_FOUND)
* </para></listitem>
* <listitem><para>
* 2 if an error occured during the installation. The application will
* assume that the user will already have seen an error message by the
* installer in this case and will usually not show another one
* (#GST_INSTALL_PLUGINS_ERROR)
* </para></listitem>
* <listitem><para>
* 3 if some of the requested plugins could be installed, but not all
* (#GST_INSTALL_PLUGINS_PARTIAL_SUCCESS)
* </para></listitem>
* <listitem><para>
* 4 if the user aborted the installation (#GST_INSTALL_PLUGINS_USER_ABORT)
* </para></listitem>
* </itemizedlist>
* </para>
* <para>
* <emphasis>5. How to map the required detail string to packages</emphasis>
* </para>
* <para>
* It is up to the vendor to find mechanism to map required components from
* the detail string to the actual packages/plugins to install. This could
* be a hardcoded list of mappings, for example, or be part of the packaging
* system metadata.
* </para>
* <para>
* GStreamer plugin files can be introspected for this information. The
* <literal>gst-inspect</literal> utility has a special command line option
* that will output information similar to what is required. For example
* <command>
* $ gst-inspect-0.10 --print-plugin-auto-install-info /path/to/libgstvorbis.so
* </command>
* should output something along the lines of
* <computeroutput>
* decoder-audio/x-vorbis
* element-vorbisdec
* element-vorbisenc
* element-vorbisparse
* element-vorbistag
* encoder-audio/x-vorbis
* </computeroutput>
* Note that in the encoder and decoder case the introspected caps can be more
* complex with additional fields, e.g.
* <literal>audio/mpeg,mpegversion=(int){2,4}</literal>, so they will not
* always exactly match the caps wanted by the application. It is up to the
* installer to deal with this (either by doing proper caps intersection using
* the GStreamer #GstCaps API, or by only taking into account the media type).
* </para>
* <para>
* Another potential source of problems are plugins such as ladspa or
* libvisual where the list of elements depends on the installed
* ladspa/libvisual plugins at the time. This is also up to the distribution
* to handle (but usually not relevant for playback applications).
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "install-plugins.h"
#include <gst/gstinfo.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
/* best effort to make things compile and possibly even work on win32 */
#ifndef WEXITSTATUS
# define WEXITSTATUS(status) ((((guint)(status)) & 0xff00) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(status) ((((guint)(status)) & 0x7f) == 0)
#endif
static gboolean install_in_progress; /* FALSE */
/* private struct */
struct _GstInstallPluginsContext
{
guint xid;
};
/**
* gst_install_plugins_context_set_xid:
* @ctx: a #GstInstallPluginsContext
* @xid: the XWindow ID (XID) of the top-level application
*
* This function is for X11-based applications (such as most Gtk/Qt
* applications on linux/unix) only. You can use it to tell the external
* the XID of your main application window, so the installer can make its
* own window transient to your application windonw during the installation.
*
* If set, the XID will be passed to the installer via a --transient-for=XID
* command line option.
*
* Gtk+/Gnome application should be able to obtain the XID of the top-level
* window like this:
* <programlisting>
* ##include &lt;gtk/gtk.h&gt;
* ##ifdef GDK_WINDOWING_X11
* ##include &lt;gdk/gdkx.h&gt;
* ##endif
* ...
* ##ifdef GDK_WINDOWING_X11
* xid = GDK_WINDOW_XWINDOW (GTK_WIDGET (application_window)-&gt;window);
* ##endif
* ...
* </programlisting>
*
* Since: 0.10.12
*/
void
gst_install_plugins_context_set_xid (GstInstallPluginsContext * ctx, guint xid)
{
g_return_if_fail (ctx != NULL);
ctx->xid = xid;
}
/**
* gst_install_plugins_context_new:
*
* Creates a new #GstInstallPluginsContext.
*
* Returns: a new #GstInstallPluginsContext. Free with
* gst_install_plugins_context_free() when no longer needed
*
* Since: 0.10.12
*/
GstInstallPluginsContext *
gst_install_plugins_context_new (void)
{
return g_new0 (GstInstallPluginsContext, 1);
}
/**
* gst_install_plugins_context_free:
* @ctx: a #GstInstallPluginsContext
*
* Frees a #GstInstallPluginsContext.
*
* Since: 0.10.12
*/
void
gst_install_plugins_context_free (GstInstallPluginsContext * ctx)
{
g_return_if_fail (ctx != NULL);
g_free (ctx);
}
static const gchar *
gst_install_plugins_get_helper (void)
{
const gchar *helper;
helper = g_getenv ("GST_INSTALL_PLUGINS_HELPER");
if (helper == NULL)
helper = GST_INSTALL_PLUGINS_HELPER;
GST_LOG ("Using plugin install helper '%s'", helper);
return helper;
}
static gboolean
gst_install_plugins_spawn_child (gchar ** details,
GstInstallPluginsContext * ctx, GPid * child_pid, gint * exit_status)
{
GPtrArray *arr;
gboolean ret;
GError *err = NULL;
gchar **argv, xid_str[64] = { 0, };
arr = g_ptr_array_new ();
/* argv[0] = helper path */
g_ptr_array_add (arr, (gchar *) gst_install_plugins_get_helper ());
/* add any additional command line args from the context */
if (ctx != NULL && ctx->xid != 0) {
g_snprintf (xid_str, sizeof (xid_str), "--transient-for=%u", ctx->xid);
g_ptr_array_add (arr, xid_str);
}
/* finally, add the detail strings */
while (details != NULL && details[0] != NULL) {
g_ptr_array_add (arr, details[0]);
++details;
}
/* and NULL-terminate */
g_ptr_array_add (arr, NULL);
argv = (gchar **) arr->pdata;
if (child_pid == NULL && exit_status != NULL) {
install_in_progress = TRUE;
ret = g_spawn_sync (NULL, argv, NULL, (GSpawnFlags) 0, NULL, NULL,
NULL, NULL, exit_status, &err);
install_in_progress = FALSE;
} else if (child_pid != NULL && exit_status == NULL) {
install_in_progress = TRUE;
ret = g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL,
NULL, child_pid, &err);
} else {
g_assert_not_reached ();
}
if (!ret) {
GST_ERROR ("Error spawning plugin install helper: %s", err->message);
g_error_free (err);
}
g_ptr_array_free (arr, TRUE);
return ret;
}
static GstInstallPluginsReturn
gst_install_plugins_return_from_status (gint status)
{
GstInstallPluginsReturn ret;
/* did we exit cleanly? */
if (!WIFEXITED (status)) {
ret = GST_INSTALL_PLUGINS_CRASHED;
} else {
ret = (GstInstallPluginsReturn) WEXITSTATUS (status);
/* did the helper return an invalid status code? */
if ((ret < 0 || ret >= GST_INSTALL_PLUGINS_STARTED_OK) &&
ret != GST_INSTALL_PLUGINS_INTERNAL_FAILURE) {
ret = GST_INSTALL_PLUGINS_INVALID;
}
}
GST_LOG ("plugin installer exited with status 0x%04x = %s", status,
gst_install_plugins_return_get_name (ret));
return ret;
}
typedef struct
{
GstInstallPluginsResultFunc func;
gpointer user_data;
} GstInstallPluginsAsyncHelper;
static void
gst_install_plugins_installer_exited (GPid pid, gint status, gpointer data)
{
GstInstallPluginsAsyncHelper *helper;
GstInstallPluginsReturn ret;
install_in_progress = FALSE;
helper = (GstInstallPluginsAsyncHelper *) data;
ret = gst_install_plugins_return_from_status (status);
GST_LOG ("calling plugin install result function %p", helper->func);
helper->func (ret, helper->user_data);
g_free (helper);
}
/**
* gst_install_plugins_async:
* @details: NULL-terminated array of installer string details (see below)
* @ctx: a #GstInstallPluginsContext, or NULL
* @func: the function to call when the installer program returns
* @user_data: the user data to pass to @func when called, or NULL
*
* Requests plugin installation without blocking. Once the plugins have been
* installed or installation has failed, @func will be called with the result
* of the installation and your provided @user_data pointer.
*
* This function requires a running GLib/Gtk main loop. If you are not
* running a GLib/Gtk main loop, make sure to regularly call
* g_main_context_iteration(NULL,FALSE).
*
* The installer strings that make up @detail are typically obtained by
* calling gst_missing_plugin_message_get_installer_detail() on missing-plugin
* messages that have been caught on a pipeline's bus or created by the
* application via the provided API, such as gst_missing_element_message_new().
*
* Returns: result code whether an external installer could be started
*
* Since: 0.10.12
*/
GstInstallPluginsReturn
gst_install_plugins_async (gchar ** details, GstInstallPluginsContext * ctx,
GstInstallPluginsResultFunc func, gpointer user_data)
{
GstInstallPluginsAsyncHelper *helper;
GPid pid;
g_return_val_if_fail (details != NULL, GST_INSTALL_PLUGINS_INTERNAL_FAILURE);
g_return_val_if_fail (func != NULL, GST_INSTALL_PLUGINS_INTERNAL_FAILURE);
if (install_in_progress)
return GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS;
/* if we can't access our helper, don't bother */
if (!g_file_test (gst_install_plugins_get_helper (),
G_FILE_TEST_IS_EXECUTABLE))
return GST_INSTALL_PLUGINS_HELPER_MISSING;
if (!gst_install_plugins_spawn_child (details, ctx, &pid, NULL))
return GST_INSTALL_PLUGINS_INTERNAL_FAILURE;
helper = g_new (GstInstallPluginsAsyncHelper, 1);
helper->func = func;
helper->user_data = user_data;
g_child_watch_add (pid, gst_install_plugins_installer_exited, helper);
return GST_INSTALL_PLUGINS_STARTED_OK;
}
/**
* gst_install_plugins_sync:
* @details: NULL-terminated array of installer string details
* @ctx: a #GstInstallPluginsContext, or NULL
*
* Requests plugin installation and block until the plugins have been
* installed or installation has failed.
*
* This function should almost never be used, it only exists for cases where
* a non-GLib main loop is running and the user wants to run it in a separate
* thread and marshal the result back asynchronously into the main thread
* using the other non-GLib main loop. You should almost always use
* gst_install_plugins_async() instead of this function.
*
* Returns: the result of the installation.
*
* Since: 0.10.12
*/
GstInstallPluginsReturn
gst_install_plugins_sync (gchar ** details, GstInstallPluginsContext * ctx)
{
gint status;
g_return_val_if_fail (details != NULL, GST_INSTALL_PLUGINS_INTERNAL_FAILURE);
if (install_in_progress)
return GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS;
/* if we can't access our helper, don't bother */
if (!g_file_test (gst_install_plugins_get_helper (),
G_FILE_TEST_IS_EXECUTABLE))
return GST_INSTALL_PLUGINS_HELPER_MISSING;
if (!gst_install_plugins_spawn_child (details, ctx, NULL, &status))
return GST_INSTALL_PLUGINS_INTERNAL_FAILURE;
return gst_install_plugins_return_from_status (status);
}
/**
* gst_install_plugins_return_get_name:
* @ret: the return status code
*
* Convenience function to return the descriptive string associated
* with a status code. This function returns English strings and
* should not be used for user messages. It is here only to assist
* in debugging.
*
* Returns: a descriptive string for the status code in @ret
*
* Since: 0.10.12
*/
const gchar *
gst_install_plugins_return_get_name (GstInstallPluginsReturn ret)
{
switch (ret) {
case GST_INSTALL_PLUGINS_SUCCESS:
return "success";
case GST_INSTALL_PLUGINS_NOT_FOUND:
return "not-found";
case GST_INSTALL_PLUGINS_ERROR:
return "install-error";
case GST_INSTALL_PLUGINS_CRASHED:
return "installer-exit-unclean";
case GST_INSTALL_PLUGINS_PARTIAL_SUCCESS:
return "partial-success";
case GST_INSTALL_PLUGINS_USER_ABORT:
return "user-abort";
case GST_INSTALL_PLUGINS_STARTED_OK:
return "started-ok";
case GST_INSTALL_PLUGINS_INTERNAL_FAILURE:
return "internal-failure";
case GST_INSTALL_PLUGINS_HELPER_MISSING:
return "helper-missing";
case GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS:
return "install-in-progress";
case GST_INSTALL_PLUGINS_INVALID:
return "invalid";
default:
break;
}
return "(UNKNOWN)";
}
/**
* gst_install_plugins_installation_in_progress:
*
* Checks whether plugin installation (initiated by this application only)
* is currently in progress.
*
* Returns: TRUE if plugin installation is in progress, otherwise FALSE
*
* Since: 0.10.12
*/
gboolean
gst_install_plugins_installation_in_progress (void)
{
return install_in_progress;
}

View file

@ -1,137 +0,0 @@
/* GStreamer base utils library plugin install support for applications
* Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2006 Ryan Lortie <desrt desrt ca>
*
* 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_BASE_UTILS_INSTALL_PLUGINS_H__
#define __GST_BASE_UTILS_INSTALL_PLUGINS_H__
#include <glib.h>
G_BEGIN_DECLS
/*
* functions for use by applications to initiate installation of missing plugins
*/
/**
* GstInstallPluginsReturn:
* @GST_INSTALL_PLUGINS_SUCCESS: all of the requested plugins could be
* installed
* @GST_INSTALL_PLUGINS_NOT_FOUND: no appropriate installation candidate for
* any of the requested plugins could be found. Only return this if nothing
* has been installed. Return #GST_INSTALL_PLUGINS_PARTIAL_SUCCESS if
* some (but not all) of the requested plugins could be installed.
* @GST_INSTALL_PLUGINS_ERROR: an error occured during the installation. If
* this happens, the user has already seen an error message and another
* one should not be displayed
* @GST_INSTALL_PLUGINS_CRASHED: the installer had an unclean exit code
* (ie. death by signal)
* @GST_INSTALL_PLUGINS_PARTIAL_SUCCESS: some of the requested plugins could
* be installed, but not all
* @GST_INSTALL_PLUGINS_USER_ABORT: the user has aborted the installation
* @GST_INSTALL_PLUGINS_INVALID: the helper returned an invalid status code
* @GST_INSTALL_PLUGINS_STARTED_OK: returned by gst_install_plugins_async() to
* indicate that everything went fine so far and the provided callback
* will be called with the result of the installation later
* @GST_INSTALL_PLUGINS_INTERNAL_FAILURE: some internal failure has
* occured when trying to start the installer
* @GST_INSTALL_PLUGINS_HELPER_MISSING: the helper script to call the
* actual installer is not installed
* @GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS: a previously-started plugin
* installation is still in progress, try again later
*
* Result codes returned by gst_install_plugins_async() and
* gst_install_plugins_sync(), and also the result code passed to the
* #GstInstallPluginsResultFunc specified with gst_install_plugin_async().
*
* These codes indicate success or failure of starting an external installer
* program and to what extent the requested plugins could be installed.
*
* Since: 0.10.12
*/
typedef enum {
/* Return codes from the installer. Returned by gst_install_plugins_sync(),
* or passed as result code to your #GstInstallPluginsResultFunc */
GST_INSTALL_PLUGINS_SUCCESS = 0,
GST_INSTALL_PLUGINS_NOT_FOUND = 1,
GST_INSTALL_PLUGINS_ERROR = 2,
GST_INSTALL_PLUGINS_PARTIAL_SUCCESS = 3,
GST_INSTALL_PLUGINS_USER_ABORT = 4,
/* Returned by gst_install_plugins_sync(), or passed as result code to your
* #GstInstallPluginsResultFunc */
GST_INSTALL_PLUGINS_CRASHED = 100,
GST_INSTALL_PLUGINS_INVALID,
/* Return codes from starting the external helper, may be returned by both
* gst_install_plugins_sync() and gst_install_plugins_async(), but should
* never be seen by a #GstInstallPluginsResultFunc */
GST_INSTALL_PLUGINS_STARTED_OK = 200,
GST_INSTALL_PLUGINS_INTERNAL_FAILURE,
GST_INSTALL_PLUGINS_HELPER_MISSING,
GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS
} GstInstallPluginsReturn;
/**
* GstInstallPluginsContext:
*
* Opaque context structure for the plugin installation. Use the provided
* API to set details on it.
*
* Since: 0.10.12
*/
typedef struct _GstInstallPluginsContext GstInstallPluginsContext;
GstInstallPluginsContext * gst_install_plugins_context_new (void);
void gst_install_plugins_context_free (GstInstallPluginsContext * ctx);
void gst_install_plugins_context_set_xid (GstInstallPluginsContext * ctx,
guint xid);
/**
* GstInstallPluginsResultFunc:
* @result: whether the installation of the requested plugins succeeded or not
* @user_data: the user data passed to gst_install_plugins_async()
*
* The prototype of the callback function that will be called once the
* external plugin installer program has returned. You only need to provide
* a callback function if you are using the asynchronous interface.
*
* Since: 0.10.12
*/
typedef void (*GstInstallPluginsResultFunc) (GstInstallPluginsReturn result,
gpointer user_data);
GstInstallPluginsReturn gst_install_plugins_async (gchar ** details,
GstInstallPluginsContext * ctx,
GstInstallPluginsResultFunc func,
gpointer user_data);
GstInstallPluginsReturn gst_install_plugins_sync (gchar ** details,
GstInstallPluginsContext * ctx);
const gchar * gst_install_plugins_return_get_name (GstInstallPluginsReturn ret);
gboolean gst_install_plugins_installation_in_progress (void);
G_END_DECLS
#endif /* __GST_BASE_UTILS_INSTALL_PLUGINS_H__ */

View file

@ -1,586 +0,0 @@
/* GStreamer base utils library missing plugins support
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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.
*/
/**
* SECTION:gstbaseutilsmissingplugins
* @short_description: Create, recognise and parse missing-plugins messages
*
* <refsect2>
* <para>
* Functions to create, recognise and parse missing-plugins messages for
* applications and elements.
* </para>
* <para>
* Missing-plugin messages are posted on the bus by elements like decodebin
* or playbin if they can't find an appropriate source element or decoder
* element. The application can use these messages for two things:
* <itemizedlist>
* <listitem><para>
* concise error/problem reporting to the user mentioning what exactly
* is missing, see gst_missing_plugin_message_get_description()
* </para></listitem>
* <listitem><para>
* initiate installation of missing plugins, see
* gst_missing_plugin_message_get_installer_detail() and
* gst_install_plugins_async()
* </para></listitem>
* </itemizedlist>
* </para>
* <para>
* Applications may also create missing-plugin messages themselves to install
* required elements that are missing, using the install mechanism mentioned
* above.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* getpid on UNIX */
#endif
#ifdef HAVE_PROCESS_H
# include <process.h> /* getpid on win32 */
#endif
#include "gst/gst-i18n-plugin.h"
#include "base-utils.h"
#include <string.h>
#define GST_DETAIL_STRING_MARKER "gstreamer"
typedef enum
{
GST_MISSING_TYPE_UNKNOWN = 0,
GST_MISSING_TYPE_URISOURCE,
GST_MISSING_TYPE_URISINK,
GST_MISSING_TYPE_ELEMENT,
GST_MISSING_TYPE_DECODER,
GST_MISSING_TYPE_ENCODER
} GstMissingType;
static const struct
{
GstMissingType type;
const gchar type_string[12];
} missing_type_mapping[] = {
{
GST_MISSING_TYPE_URISOURCE, "urisource"}, {
GST_MISSING_TYPE_URISINK, "urisink"}, {
GST_MISSING_TYPE_ELEMENT, "element"}, {
GST_MISSING_TYPE_DECODER, "decoder"}, {
GST_MISSING_TYPE_ENCODER, "encoder"}
};
static GstMissingType
missing_structure_get_type (const GstStructure * s)
{
const gchar *type;
guint i;
type = gst_structure_get_string (s, "type");
g_return_val_if_fail (type != NULL, GST_MISSING_TYPE_UNKNOWN);
for (i = 0; i < G_N_ELEMENTS (missing_type_mapping); ++i) {
if (strcmp (missing_type_mapping[i].type_string, type) == 0)
return missing_type_mapping[i].type;
}
return GST_MISSING_TYPE_UNKNOWN;
}
static GstCaps *
copy_and_clean_caps (const GstCaps * caps)
{
GstStructure *s;
GstCaps *ret;
ret = gst_caps_copy (caps);
/* make caps easier to interpret, remove common fields that are likely
* to be irrelevant for determining the right plugin (ie. mostly fields
* where template caps usually have the standard MIN - MAX range as value) */
s = gst_caps_get_structure (ret, 0);
gst_structure_remove_field (s, "codec_data");
gst_structure_remove_field (s, "palette_data");
gst_structure_remove_field (s, "pixel-aspect-ratio");
gst_structure_remove_field (s, "framerate");
gst_structure_remove_field (s, "leaf_size");
gst_structure_remove_field (s, "packet_size");
/* decoders/encoders almost always handle the usual width/height/channel/rate
* range (and if we don't remove this then the app will have a much harder
* time blacklisting formats it has unsuccessfully tried to install before) */
gst_structure_remove_field (s, "width");
gst_structure_remove_field (s, "height");
gst_structure_remove_field (s, "channels");
gst_structure_remove_field (s, "rate");
return ret;
}
/**
* gst_missing_uri_source_message_new:
* @element: the #GstElement posting the message
* @protocol: the URI protocol the missing source needs to implement,
* e.g. "http" or "mms"
*
* Creates a missing-plugin message for @element to notify the application
* that a source element for a particular URI protocol is missing. This
* function is mainly for use in plugins.
*
* Returns: a new #GstMessage, or NULL on error
*/
GstMessage *
gst_missing_uri_source_message_new (GstElement * element,
const gchar * protocol)
{
GstStructure *s;
gchar *description;
g_return_val_if_fail (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
g_return_val_if_fail (protocol != NULL, NULL);
description = gst_base_utils_get_source_description (protocol);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"urisource", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING,
description, NULL);
g_free (description);
return gst_message_new_element (GST_OBJECT_CAST (element), s);
}
/**
* gst_missing_uri_sink_message_new:
* @element: the #GstElement posting the message
* @protocol: the URI protocol the missing sink needs to implement,
* e.g. "http" or "smb"
*
* Creates a missing-plugin message for @element to notify the application
* that a sink element for a particular URI protocol is missing. This
* function is mainly for use in plugins.
*
* Returns: a new #GstMessage, or NULL on error
*/
GstMessage *
gst_missing_uri_sink_message_new (GstElement * element, const gchar * protocol)
{
GstStructure *s;
gchar *description;
g_return_val_if_fail (element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (protocol != NULL, FALSE);
description = gst_base_utils_get_sink_description (protocol);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"urisink", "detail", G_TYPE_STRING, protocol, "name", G_TYPE_STRING,
description, NULL);
g_free (description);
return gst_message_new_element (GST_OBJECT_CAST (element), s);
}
/**
* gst_missing_element_message_new:
* @element: the #GstElement posting the message
* @factory_name: the name of the missing element (element factory),
* e.g. "videoscale" or "cdparanoiasrc"
*
* Creates a missing-plugin message for @element to notify the application
* that a certain required element is missing. This function is mainly for
* use in plugins.
*
* Returns: a new #GstMessage, or NULL on error
*/
GstMessage *
gst_missing_element_message_new (GstElement * element,
const gchar * factory_name)
{
GstStructure *s;
gchar *description;
g_return_val_if_fail (element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (factory_name != NULL, FALSE);
description = gst_base_utils_get_element_description (factory_name);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"element", "detail", G_TYPE_STRING, factory_name, "name", G_TYPE_STRING,
description, NULL);
g_free (description);
return gst_message_new_element (GST_OBJECT_CAST (element), s);
}
/**
* gst_missing_decoder_message_new:
* @element: the #GstElement posting the message
* @decode_caps: the (fixed) caps for which a decoder element is needed
*
* Creates a missing-plugin message for @element to notify the application
* that a decoder element for a particular set of (fixed) caps is missing.
* This function is mainly for use in plugins.
*
* Returns: a new #GstMessage, or NULL on error
*/
GstMessage *
gst_missing_decoder_message_new (GstElement * element,
const GstCaps * decode_caps)
{
GstStructure *s;
GstCaps *caps;
gchar *description;
g_return_val_if_fail (element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (decode_caps != NULL, FALSE);
g_return_val_if_fail (GST_IS_CAPS (decode_caps), FALSE);
g_return_val_if_fail (!gst_caps_is_any (decode_caps), FALSE);
g_return_val_if_fail (!gst_caps_is_empty (decode_caps), FALSE);
g_return_val_if_fail (gst_caps_is_fixed (decode_caps), FALSE);
description = gst_base_utils_get_decoder_description (decode_caps);
caps = copy_and_clean_caps (decode_caps);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"decoder", "detail", GST_TYPE_CAPS, caps, "name", G_TYPE_STRING,
description, NULL);
gst_caps_unref (caps);
g_free (description);
return gst_message_new_element (GST_OBJECT_CAST (element), s);
}
/**
* gst_missing_encoder_message_new:
* @element: the #GstElement posting the message
* @encode_caps: the (fixed) caps for which an encoder element is needed
*
* Creates a missing-plugin message for @element to notify the application
* that an encoder element for a particular set of (fixed) caps is missing.
* This function is mainly for use in plugins.
*
* Returns: a new #GstMessage, or NULL on error
*/
GstMessage *
gst_missing_encoder_message_new (GstElement * element,
const GstCaps * encode_caps)
{
GstStructure *s;
GstCaps *caps;
gchar *description;
g_return_val_if_fail (element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (encode_caps != NULL, FALSE);
g_return_val_if_fail (GST_IS_CAPS (encode_caps), FALSE);
g_return_val_if_fail (!gst_caps_is_any (encode_caps), FALSE);
g_return_val_if_fail (!gst_caps_is_empty (encode_caps), FALSE);
g_return_val_if_fail (gst_caps_is_fixed (encode_caps), FALSE);
description = gst_base_utils_get_encoder_description (encode_caps);
caps = copy_and_clean_caps (encode_caps);
s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING,
"encoder", "detail", GST_TYPE_CAPS, caps, "name", G_TYPE_STRING,
description, NULL);
gst_caps_unref (caps);
g_free (description);
return gst_message_new_element (GST_OBJECT_CAST (element), s);
}
static gboolean
missing_structure_get_string_detail (const GstStructure * s, gchar ** p_detail)
{
const gchar *detail;
GType detail_type;
*p_detail = NULL;
detail_type = gst_structure_get_field_type (s, "detail");
if (!g_type_is_a (detail_type, G_TYPE_STRING)) {
GST_WARNING ("expected 'detail' field to be of G_TYPE_STRING");
return FALSE;
}
detail = gst_structure_get_string (s, "detail");
if (detail == NULL || *detail == '\0') {
GST_WARNING ("empty 'detail' field");
return FALSE;
}
*p_detail = g_strdup (detail);
return TRUE;
}
static gboolean
missing_structure_get_caps_detail (const GstStructure * s, GstCaps ** p_caps)
{
const GstCaps *caps;
const GValue *val;
GType detail_type;
*p_caps = NULL;
detail_type = gst_structure_get_field_type (s, "detail");
if (!g_type_is_a (detail_type, GST_TYPE_CAPS)) {
GST_WARNING ("expected 'detail' field to be of GST_TYPE_CAPS");
return FALSE;
}
val = gst_structure_get_value (s, "detail");
caps = gst_value_get_caps (val);
if (gst_caps_is_empty (caps) || gst_caps_is_any (caps)) {
GST_WARNING ("EMPTY or ANY caps not allowed");
return FALSE;
}
*p_caps = gst_caps_copy (caps);
return TRUE;
}
/**
* gst_missing_plugin_message_get_installer_detail:
* @msg: a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT
*
* Returns an opaque string containing all the details about the missing
* element to be passed to an external installer or installer library
* such as libgimme-codec.
*
* This function is mainly for applications that use libgimme-codec or
* other libraries that call external plugin installation mechanisms.
*
* Returns: a newly-allocated detail string, or NULL on error. Free string
* with g_free() when not needed any longer.
*/
gchar *
gst_missing_plugin_message_get_installer_detail (GstMessage * msg)
{
GstMissingType missing_type;
const gchar *progname;
const gchar *type;
GString *str = NULL;
gchar *detail = NULL;
gchar *desc;
g_return_val_if_fail (gst_is_missing_plugin_message (msg), NULL);
GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, msg->structure);
missing_type = missing_structure_get_type (msg->structure);
if (missing_type == GST_MISSING_TYPE_UNKNOWN) {
GST_WARNING ("couldn't parse 'type' field");
goto error;
}
type = gst_structure_get_string (msg->structure, "type");
g_assert (type != NULL); /* validity already checked above */
str = g_string_new (GST_DETAIL_STRING_MARKER "|");
g_string_append_printf (str, "%u.%u|", GST_VERSION_MAJOR, GST_VERSION_MINOR);
progname = (const gchar *) g_get_prgname ();
if (progname) {
g_string_append_printf (str, "%s|", progname);
} else {
g_string_append_printf (str, "pid/%lu", (gulong) getpid ());
}
desc = gst_missing_plugin_message_get_description (msg);
if (desc) {
g_strdelimit (desc, "|", '#');
g_string_append_printf (str, "%s|", desc);
g_free (desc);
} else {
g_string_append (str, "|");
}
switch (missing_type) {
case GST_MISSING_TYPE_URISOURCE:
case GST_MISSING_TYPE_URISINK:
case GST_MISSING_TYPE_ELEMENT:
if (!missing_structure_get_string_detail (msg->structure, &detail))
goto error;
break;
case GST_MISSING_TYPE_DECODER:
case GST_MISSING_TYPE_ENCODER:{
GstCaps *caps = NULL;
if (!missing_structure_get_caps_detail (msg->structure, &caps))
goto error;
detail = gst_caps_to_string (caps);
gst_caps_unref (caps);
break;
}
default:
g_assert_not_reached ();
break;
}
g_string_append_printf (str, "%s-%s", type, detail);
g_free (detail);
return g_string_free (str, FALSE);
/* ERRORS */
error:
{
GST_WARNING ("Failed to parse missing-plugin msg: %" GST_PTR_FORMAT, msg);
if (str)
g_string_free (str, TRUE);
return NULL;
}
}
/**
* gst_missing_plugin_message_get_description:
* @msg: a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT
*
* Returns a localised string describing the missing feature, for use in
* error dialogs and the like. Should never return NULL unless @msg is not
* a valid missing-plugin message.
*
* This function is mainly for applications that need a human-readable string
* describing a missing plugin, given a previously collected missing-plugin
* message
*
* Returns: a newly-allocated description string, or NULL on error. Free
* string with g_free() when not needed any longer.
*/
gchar *
gst_missing_plugin_message_get_description (GstMessage * msg)
{
GstMissingType missing_type;
const gchar *desc;
gchar *ret = NULL;
g_return_val_if_fail (gst_is_missing_plugin_message (msg), NULL);
GST_LOG ("Parsing missing-plugin message: %" GST_PTR_FORMAT, msg->structure);
desc = gst_structure_get_string (msg->structure, "name");
if (desc != NULL && *desc != '\0') {
ret = g_strdup (desc);
goto done;
}
/* fallback #1 */
missing_type = missing_structure_get_type (msg->structure);
switch (missing_type) {
case GST_MISSING_TYPE_URISOURCE:
case GST_MISSING_TYPE_URISINK:
case GST_MISSING_TYPE_ELEMENT:{
gchar *detail = NULL;
if (missing_structure_get_string_detail (msg->structure, &detail)) {
if (missing_type == GST_MISSING_TYPE_URISOURCE)
ret = gst_base_utils_get_source_description (detail);
else if (missing_type == GST_MISSING_TYPE_URISINK)
ret = gst_base_utils_get_sink_description (detail);
else
ret = gst_base_utils_get_sink_description (detail);
g_free (detail);
}
break;
}
case GST_MISSING_TYPE_DECODER:
case GST_MISSING_TYPE_ENCODER:{
GstCaps *caps = NULL;
if (missing_structure_get_caps_detail (msg->structure, &caps)) {
if (missing_type == GST_MISSING_TYPE_DECODER)
ret = gst_base_utils_get_decoder_description (caps);
else
ret = gst_base_utils_get_encoder_description (caps);
gst_caps_unref (caps);
}
break;
}
default:
break;
}
if (ret)
goto done;
/* fallback #2 */
switch (missing_type) {
case GST_MISSING_TYPE_URISOURCE:
desc = _("Unknown source element");
break;
case GST_MISSING_TYPE_URISINK:
desc = _("Unknown sink element");
break;
case GST_MISSING_TYPE_ELEMENT:
desc = _("Unknown element");
break;
case GST_MISSING_TYPE_DECODER:
desc = _("Unknown decoder element");
break;
case GST_MISSING_TYPE_ENCODER:
desc = _("Unknown encoder element");
break;
default:
/* we should really never get here, but we better still return
* something if we do */
desc = _("Plugin or element of unknown type");
break;
}
ret = g_strdup (desc);
done:
GST_LOG ("returning '%s'", ret);
return ret;
}
/**
* gst_is_missing_plugin_message:
* @msg: a #GstMessage
*
* Checks whether @msg is a missing plugins message.
*
* Returns: %TRUE if @msg is a missing-plugins message, otherwise %FALSE.
*/
gboolean
gst_is_missing_plugin_message (GstMessage * msg)
{
g_return_val_if_fail (msg != NULL, FALSE);
g_return_val_if_fail (GST_IS_MESSAGE (msg), FALSE);
if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT || msg->structure == NULL)
return FALSE;
return gst_structure_has_name (msg->structure, "missing-plugin");
}

View file

@ -1,60 +0,0 @@
/* GStreamer base utils library missing plugins support
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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_BASE_UTILS_MISSING_PLUGINS_H__
#define __GST_BASE_UTILS_MISSING_PLUGINS_H__
#include <gst/gstmessage.h>
#include <gst/gstcaps.h>
G_BEGIN_DECLS
/*
* functions to create missing-plugin messages, for use by plugins primarily
*/
GstMessage * gst_missing_uri_source_message_new (GstElement * element,
const gchar * protocol);
GstMessage * gst_missing_uri_sink_message_new (GstElement * element,
const gchar * protocol);
GstMessage * gst_missing_element_message_new (GstElement * element,
const gchar * factory_name);
GstMessage * gst_missing_decoder_message_new (GstElement * element,
const GstCaps * decode_caps);
GstMessage * gst_missing_encoder_message_new (GstElement * element,
const GstCaps * encode_caps);
/*
* functions for use by the application when dealing with missing-plugin messages
*/
gchar * gst_missing_plugin_message_get_installer_detail (GstMessage * msg);
gchar * gst_missing_plugin_message_get_description (GstMessage * msg);
gboolean gst_is_missing_plugin_message (GstMessage * msg);
G_END_DECLS
#endif /* __GST_BASE_UTILS_MISSING_PLUGINS_H__ */

View file

@ -68,18 +68,17 @@ rm -rf $RPM_BUILD_ROOT
# helper programs # helper programs
%{_bindir}/gst-visualise-%{majorminor} %{_bindir}/gst-visualise-%{majorminor}
%{_mandir}/man1/gst-visualise-%{majorminor}* %{_mandir}/man1/gst-visualise-%{majorminor}*
%{_libdir}/libgstbaseutils-0.10.so.0
%{_libdir}/libgstbaseutils-0.10.so.0.8.0
# libraries # libraries
%{_libdir}/libgstinterfaces-%{majorminor}.so.*
%{_libdir}/libgstaudio-%{majorminor}.so.* %{_libdir}/libgstaudio-%{majorminor}.so.*
%{_libdir}/libgstcdda-%{majorminor}.so*
%{_libdir}/libgstinterfaces-%{majorminor}.so.*
%{_libdir}/libgstnetbuffer-%{majorminor}.so*
%{_libdir}/libgstpbutils-%{majorminor}.so*
%{_libdir}/libgstriff-%{majorminor}.so.* %{_libdir}/libgstriff-%{majorminor}.so.*
%{_libdir}/libgstrtp-%{majorminor}.so*
%{_libdir}/libgsttag-%{majorminor}.so.* %{_libdir}/libgsttag-%{majorminor}.so.*
%{_libdir}/libgstvideo-%{majorminor}.so.* %{_libdir}/libgstvideo-%{majorminor}.so.*
%{_libdir}/libgstrtp-%{majorminor}.so*
%{_libdir}/libgstnetbuffer-%{majorminor}.so*
%{_libdir}/libgstcdda-%{majorminor}.so*
# base plugins without external dependencies # base plugins without external dependencies
%{_libdir}/gstreamer-%{majorminor}/libgstadder.so %{_libdir}/gstreamer-%{majorminor}/libgstadder.so
@ -170,7 +169,6 @@ GStreamer Plugins Base library development and header files.
%{_includedir}/gstreamer-%{majorminor}/gst/utils/descriptions.h %{_includedir}/gstreamer-%{majorminor}/gst/utils/descriptions.h
%{_includedir}/gstreamer-%{majorminor}/gst/utils/missing-plugins.h %{_includedir}/gstreamer-%{majorminor}/gst/utils/missing-plugins.h
%{_includedir}/gstreamer-%{majorminor}/gst/utils/install-plugins.h %{_includedir}/gstreamer-%{majorminor}/gst/utils/install-plugins.h
%{_libdir}/libgstbaseutils-0.10.so
%{_libdir}/libgstaudio-%{majorminor}.so %{_libdir}/libgstaudio-%{majorminor}.so
%{_libdir}/libgstriff-%{majorminor}.so %{_libdir}/libgstriff-%{majorminor}.so
%{_libdir}/libgsttag-%{majorminor}.so %{_libdir}/libgsttag-%{majorminor}.so
@ -178,6 +176,7 @@ GStreamer Plugins Base library development and header files.
%{_libdir}/libgstrtp-%{majorminor}.so %{_libdir}/libgstrtp-%{majorminor}.so
%{_libdir}/libgstinterfaces-%{majorminor}.so %{_libdir}/libgstinterfaces-%{majorminor}.so
%{_libdir}/libgstnetbuffer-%{majorminor}.so %{_libdir}/libgstnetbuffer-%{majorminor}.so
%{_libdir}/libgstpbutils-%{majorminor}.so
%{_libdir}/libgstcdda-%{majorminor}.so %{_libdir}/libgstcdda-%{majorminor}.so
# pkg-config files # pkg-config files

View file

@ -19,7 +19,7 @@ nodist_libgstplaybin_la_SOURCES = $(built_sources)
libgstplaybin_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) libgstplaybin_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstplaybin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstplaybin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstplaybin_la_LIBADD = \ libgstplaybin_la_LIBADD = \
$(top_builddir)/gst-libs/gst/utils/libgstbaseutils-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/pbutils/libgstpbutils-@GST_MAJORMINOR@.la \
$(GST_LIBS) $(GST_LIBS)
libgstdecodebin_la_SOURCES = gstdecodebin.c libgstdecodebin_la_SOURCES = gstdecodebin.c
@ -27,7 +27,7 @@ nodist_libgstdecodebin_la_SOURCES = $(built_sources)
libgstdecodebin_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) libgstdecodebin_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstdecodebin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstdecodebin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstdecodebin_la_LIBADD = \ libgstdecodebin_la_LIBADD = \
$(top_builddir)/gst-libs/gst/utils/libgstbaseutils-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/pbutils/libgstpbutils-@GST_MAJORMINOR@.la \
$(GST_LIBS) $(GST_LIBS)
libgstdecodebin2_la_SOURCES = gstdecodebin2.c libgstdecodebin2_la_SOURCES = gstdecodebin2.c
@ -35,7 +35,7 @@ nodist_libgstdecodebin2_la_SOURCES = $(built_sources)
libgstdecodebin2_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) libgstdecodebin2_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstdecodebin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstdecodebin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstdecodebin2_la_LIBADD = \ libgstdecodebin2_la_LIBADD = \
$(top_builddir)/gst-libs/gst/utils/libgstbaseutils-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/pbutils/libgstpbutils-@GST_MAJORMINOR@.la \
$(GST_LIBS) $(GST_LIBS)
noinst_HEADERS = \ noinst_HEADERS = \

View file

@ -23,7 +23,7 @@
#include <string.h> #include <string.h>
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/utils/base-utils.h> #include <gst/pbutils/pbutils.h>
#include "gstplay-marshal.h" #include "gstplay-marshal.h"

View file

@ -38,7 +38,7 @@
#include <string.h> #include <string.h>
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/utils/base-utils.h> #include <gst/pbutils/pbutils.h>
#include "gstplay-marshal.h" #include "gstplay-marshal.h"

View file

@ -27,7 +27,7 @@
#include "gststreamselector.h" #include "gststreamselector.h"
#include "gstplay-marshal.h" #include "gstplay-marshal.h"
#include <gst/utils/base-utils.h> #include <gst/pbutils/pbutils.h>
GST_DEBUG_CATEGORY_STATIC (gst_play_base_bin_debug); GST_DEBUG_CATEGORY_STATIC (gst_play_base_bin_debug);
#define GST_CAT_DEFAULT gst_play_base_bin_debug #define GST_CAT_DEFAULT gst_play_base_bin_debug
@ -1449,7 +1449,7 @@ unknown_uri:
gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin), gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin),
prot)); prot));
desc = gst_base_utils_get_source_description (prot); desc = gst_pb_utils_get_source_description (prot);
GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN, GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN,
(_("A %s plugin is required to play this stream, but not installed."), (_("A %s plugin is required to play this stream, but not installed."),
desc), ("No URI handler to handle sub_uri: %s", sub_uri)); desc), ("No URI handler to handle sub_uri: %s", sub_uri));
@ -1575,7 +1575,7 @@ no_source:
gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin), gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin),
prot)); prot));
desc = gst_base_utils_get_source_description (prot); desc = gst_pb_utils_get_source_description (prot);
GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN, GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN,
(_("A %s plugin is required to play this stream, but not installed."), (_("A %s plugin is required to play this stream, but not installed."),
desc), ("No URI handler for %s", prot)); desc), ("No URI handler for %s", prot));

View file

@ -246,7 +246,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/gst-i18n-plugin.h> #include <gst/gst-i18n-plugin.h>
#include <gst/utils/base-utils.h> #include <gst/pbutils/pbutils.h>
#include "gstplaybasebin.h" #include "gstplaybasebin.h"
@ -1932,7 +1932,7 @@ plugin_init (GstPlugin * plugin)
{ {
GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin"); GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin");
gst_base_utils_init (); gst_pb_utils_init ();
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,

View file

@ -82,9 +82,9 @@ check_PROGRAMS = \
libs/audio \ libs/audio \
libs/cddabasesrc \ libs/cddabasesrc \
libs/netbuffer \ libs/netbuffer \
libs/pbutils \
libs/tag \ libs/tag \
libs/video \ libs/video \
libs/utils \
pipelines/simple-launch-lines pipelines/simple-launch-lines
# TORTURE_TO_FIX = \ # TORTURE_TO_FIX = \
@ -144,11 +144,11 @@ libs_tag_CFLAGS = \
libs_tag_LDADD = \ libs_tag_LDADD = \
$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la $(LDADD) $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la $(LDADD)
libs_utils_CFLAGS = \ libs_pbutils_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \
$(AM_CFLAGS) $(AM_CFLAGS)
libs_utils_LDADD = \ libs_pbutils_LDADD = \
$(top_builddir)/gst-libs/gst/utils/libgstbaseutils-@GST_MAJORMINOR@.la $(LDADD) $(top_builddir)/gst-libs/gst/pbutils/libgstpbutils-@GST_MAJORMINOR@.la $(LDADD)
elements_alsa_CFLAGS = \ elements_alsa_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) \

View file

@ -1,4 +1,4 @@
/* GStreamer unit tests for libgstbaseutils /* GStreamer unit tests for libgstpbutils
* *
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net> * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* *
@ -23,7 +23,7 @@
#endif #endif
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/utils/base-utils.h> #include <gst/pbutils/pbutils.h>
#include <stdio.h> #include <stdio.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
@ -58,7 +58,7 @@ missing_msg_check_getters (GstMessage * msg)
g_free (str); g_free (str);
} }
GST_START_TEST (test_base_utils_post_missing_messages) GST_START_TEST (test_pb_utils_post_missing_messages)
{ {
GstElement *pipeline; GstElement *pipeline;
GstStructure *s; GstStructure *s;
@ -66,14 +66,13 @@ GST_START_TEST (test_base_utils_post_missing_messages)
GstCaps *caps; GstCaps *caps;
GstBus *bus; GstBus *bus;
gst_base_utils_init (); gst_pb_utils_init ();
pipeline = gst_pipeline_new ("pipeline"); pipeline = gst_pipeline_new ("pipeline");
bus = gst_element_get_bus (pipeline); bus = gst_element_get_bus (pipeline);
/* first, test common assertion failure cases */ /* first, test common assertion failure cases */
ASSERT_CRITICAL (msg = gst_missing_uri_source_message_new (NULL, "http"); ASSERT_CRITICAL (msg = gst_missing_uri_source_message_new (NULL, "http"););
);
ASSERT_CRITICAL (gst_missing_uri_source_message_new (pipeline, NULL)); ASSERT_CRITICAL (gst_missing_uri_source_message_new (pipeline, NULL));
ASSERT_CRITICAL (gst_missing_uri_sink_message_new (NULL, "http")); ASSERT_CRITICAL (gst_missing_uri_sink_message_new (NULL, "http"));
@ -234,13 +233,13 @@ GST_START_TEST (test_base_utils_post_missing_messages)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_base_utils_init) GST_START_TEST (test_pb_utils_init)
{ {
/* should be fine to call multiple times */ /* should be fine to call multiple times */
gst_base_utils_init (); gst_pb_utils_init ();
gst_base_utils_init (); gst_pb_utils_init ();
gst_base_utils_init (); gst_pb_utils_init ();
gst_base_utils_init (); gst_pb_utils_init ();
} }
GST_END_TEST; GST_END_TEST;
@ -385,11 +384,11 @@ static const gchar *caps_strings[] = {
"video/x-tpm" "video/x-tpm"
}; };
GST_START_TEST (test_base_utils_get_codec_description) GST_START_TEST (test_pb_utils_get_codec_description)
{ {
gint i; gint i;
gst_base_utils_init (); gst_pb_utils_init ();
for (i = 0; i < G_N_ELEMENTS (caps_strings); ++i) { for (i = 0; i < G_N_ELEMENTS (caps_strings); ++i) {
GstCaps *caps; GstCaps *caps;
@ -399,15 +398,15 @@ GST_START_TEST (test_base_utils_get_codec_description)
fail_unless (caps != NULL, "could not create caps from string '%s'", fail_unless (caps != NULL, "could not create caps from string '%s'",
caps_strings[i]); caps_strings[i]);
GST_LOG ("Caps %s:", caps_strings[i]); GST_LOG ("Caps %s:", caps_strings[i]);
desc = gst_base_utils_get_codec_description (caps); desc = gst_pb_utils_get_codec_description (caps);
fail_unless (desc != NULL); fail_unless (desc != NULL);
GST_LOG (" - codec : %s", desc); GST_LOG (" - codec : %s", desc);
g_free (desc); g_free (desc);
desc = gst_base_utils_get_decoder_description (caps); desc = gst_pb_utils_get_decoder_description (caps);
fail_unless (desc != NULL); fail_unless (desc != NULL);
GST_LOG (" - decoder : %s", desc); GST_LOG (" - decoder : %s", desc);
g_free (desc); g_free (desc);
desc = gst_base_utils_get_encoder_description (caps); desc = gst_pb_utils_get_encoder_description (caps);
fail_unless (desc != NULL); fail_unless (desc != NULL);
GST_LOG (" - encoder : %s", desc); GST_LOG (" - encoder : %s", desc);
g_free (desc); g_free (desc);
@ -418,29 +417,29 @@ GST_START_TEST (test_base_utils_get_codec_description)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_base_utils_taglist_add_codec_info) GST_START_TEST (test_pb_utils_taglist_add_codec_info)
{ {
GstTagList *list; GstTagList *list;
GstCaps *caps; GstCaps *caps;
gst_base_utils_init (); gst_pb_utils_init ();
list = gst_tag_list_new (); list = gst_tag_list_new ();
caps = gst_caps_new_simple ("video/x-theora", NULL); caps = gst_caps_new_simple ("video/x-theora", NULL);
ASSERT_CRITICAL (fail_if ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (NULL, (gst_pb_utils_add_codec_description_to_tag_list (NULL,
GST_TAG_VIDEO_CODEC, caps))); GST_TAG_VIDEO_CODEC, caps)));
ASSERT_CRITICAL (fail_if ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, NULL, caps))); (gst_pb_utils_add_codec_description_to_tag_list (list, NULL, caps)));
ASSERT_CRITICAL (fail_if ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, "asdfa", caps))); (gst_pb_utils_add_codec_description_to_tag_list (list, "asdfa", caps)));
ASSERT_CRITICAL (fail_if ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, (gst_pb_utils_add_codec_description_to_tag_list (list,
GST_TAG_IMAGE, caps))); GST_TAG_IMAGE, caps)));
ASSERT_CRITICAL (fail_if ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, (gst_pb_utils_add_codec_description_to_tag_list (list,
GST_TAG_VIDEO_CODEC, NULL))); GST_TAG_VIDEO_CODEC, NULL)));
/* FIXME: do something here */ /* FIXME: do something here */
fail_unless (gst_base_utils_add_codec_description_to_tag_list (list, fail_unless (gst_pb_utils_add_codec_description_to_tag_list (list,
GST_TAG_VIDEO_CODEC, caps)); GST_TAG_VIDEO_CODEC, caps));
fail_if (gst_tag_list_is_empty (list)); fail_if (gst_tag_list_is_empty (list));
gst_tag_list_free (list); gst_tag_list_free (list);
@ -476,7 +475,7 @@ result_cb (GstInstallPluginsReturn result, gpointer user_data)
/* make sure our script gets called with the right parameters */ /* make sure our script gets called with the right parameters */
static void static void
test_base_utils_install_plugins_do_callout (gchar ** details, test_pb_utils_install_plugins_do_callout (gchar ** details,
GstInstallPluginsContext * ctx, const gchar * script, GstInstallPluginsContext * ctx, const gchar * script,
GstInstallPluginsReturn expected_result) GstInstallPluginsReturn expected_result)
{ {
@ -533,7 +532,7 @@ done:
#endif /* G_OS_UNIX */ #endif /* G_OS_UNIX */
} }
GST_START_TEST (test_base_utils_install_plugins) GST_START_TEST (test_pb_utils_install_plugins)
{ {
GstInstallPluginsContext *ctx; GstInstallPluginsContext *ctx;
GstInstallPluginsReturn ret; GstInstallPluginsReturn ret;
@ -541,11 +540,14 @@ GST_START_TEST (test_base_utils_install_plugins)
ctx = gst_install_plugins_context_new (); ctx = gst_install_plugins_context_new ();
ASSERT_CRITICAL (ret = gst_install_plugins_sync (NULL, ctx);); ASSERT_CRITICAL (ret = gst_install_plugins_sync (NULL, ctx);
);
ASSERT_CRITICAL (ret = ASSERT_CRITICAL (ret =
gst_install_plugins_async (NULL, ctx, result_cb, (gpointer) & marker);); gst_install_plugins_async (NULL, ctx, result_cb, (gpointer) & marker);
);
ASSERT_CRITICAL (ret = ASSERT_CRITICAL (ret =
gst_install_plugins_async (details, ctx, NULL, (gpointer) & marker);); gst_install_plugins_async (details, ctx, NULL, (gpointer) & marker);
);
/* make sure the functions return the right error code if the helper does /* make sure the functions return the right error code if the helper does
* not exist */ * not exist */
@ -561,12 +563,12 @@ GST_START_TEST (test_base_utils_install_plugins)
fail_unless_equals_int (marker, -333); fail_unless_equals_int (marker, -333);
/* now make sure our scripts are actually called as expected (if possible) */ /* now make sure our scripts are actually called as expected (if possible) */
test_base_utils_install_plugins_do_callout (details, NULL, SCRIPT_NO_XID, test_pb_utils_install_plugins_do_callout (details, NULL, SCRIPT_NO_XID,
GST_INSTALL_PLUGINS_NOT_FOUND); GST_INSTALL_PLUGINS_NOT_FOUND);
/* and again with context */ /* and again with context */
gst_install_plugins_context_set_xid (ctx, 42); gst_install_plugins_context_set_xid (ctx, 42);
test_base_utils_install_plugins_do_callout (details, ctx, SCRIPT_WITH_XID, test_pb_utils_install_plugins_do_callout (details, ctx, SCRIPT_WITH_XID,
GST_INSTALL_PLUGINS_SUCCESS); GST_INSTALL_PLUGINS_SUCCESS);
/* and free the context now that we don't need it any longer */ /* and free the context now that we don't need it any longer */
@ -590,18 +592,18 @@ GST_START_TEST (test_base_utils_install_plugins)
GST_END_TEST; GST_END_TEST;
static Suite * static Suite *
libgstbaseutils_suite (void) libgstpbutils_suite (void)
{ {
Suite *s = suite_create ("base utils library"); Suite *s = suite_create ("pbutils library");
TCase *tc_chain = tcase_create ("general"); TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_base_utils_init); tcase_add_test (tc_chain, test_pb_utils_init);
tcase_add_test (tc_chain, test_base_utils_post_missing_messages); tcase_add_test (tc_chain, test_pb_utils_post_missing_messages);
tcase_add_test (tc_chain, test_base_utils_taglist_add_codec_info); tcase_add_test (tc_chain, test_pb_utils_taglist_add_codec_info);
tcase_add_test (tc_chain, test_base_utils_get_codec_description); tcase_add_test (tc_chain, test_pb_utils_get_codec_description);
tcase_add_test (tc_chain, test_base_utils_install_plugins); tcase_add_test (tc_chain, test_pb_utils_install_plugins);
return s; return s;
} }
GST_CHECK_MAIN (libgstbaseutils); GST_CHECK_MAIN (libgstpbutils);

View file

@ -1,607 +0,0 @@
/* GStreamer unit tests for libgstbaseutils
*
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* 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/check/gstcheck.h>
#include <gst/utils/base-utils.h>
#include <stdio.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> /* for chmod() and getpid () */
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> /* for chmod() */
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for unlink() */
#endif
static void
missing_msg_check_getters (GstMessage * msg)
{
gchar *str;
str = gst_missing_plugin_message_get_installer_detail (msg);
fail_unless (str != NULL);
fail_unless (*str != '\0');
fail_unless (g_str_has_prefix (str, "gstreamer|"));
g_free (str);
str = gst_missing_plugin_message_get_description (msg);
fail_unless (str != NULL);
fail_unless (*str != '\0');
g_free (str);
}
GST_START_TEST (test_base_utils_post_missing_messages)
{
GstElement *pipeline;
GstStructure *s;
GstMessage *msg;
GstCaps *caps;
GstBus *bus;
gst_base_utils_init ();
pipeline = gst_pipeline_new ("pipeline");
bus = gst_element_get_bus (pipeline);
/* first, test common assertion failure cases */
ASSERT_CRITICAL (msg = gst_missing_uri_source_message_new (NULL, "http");
);
ASSERT_CRITICAL (gst_missing_uri_source_message_new (pipeline, NULL));
ASSERT_CRITICAL (gst_missing_uri_sink_message_new (NULL, "http"));
ASSERT_CRITICAL (gst_missing_uri_sink_message_new (pipeline, NULL));
ASSERT_CRITICAL (gst_missing_element_message_new (NULL, "rgbfyltr"));
ASSERT_CRITICAL (gst_missing_element_message_new (pipeline, NULL));
caps = gst_caps_new_simple ("audio/x-dontexist", NULL);
ASSERT_CRITICAL (gst_missing_decoder_message_new (NULL, caps));
ASSERT_CRITICAL (gst_missing_decoder_message_new (pipeline, NULL));
ASSERT_CRITICAL (gst_missing_encoder_message_new (NULL, caps));
ASSERT_CRITICAL (gst_missing_encoder_message_new (pipeline, NULL));
gst_caps_unref (caps);
/* URI source (with existing protocol) */
msg = gst_missing_uri_source_message_new (pipeline, "http");
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "http");
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* URI sink (with existing protocol) */
msg = gst_missing_uri_sink_message_new (pipeline, "smb");
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisink");
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "smb");
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* URI source (with bogus protocol) */
msg = gst_missing_uri_source_message_new (pipeline, "chchck");
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "chchck");
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* URI sink (with bogus protocol) */
msg = gst_missing_uri_sink_message_new (pipeline, "chchck");
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisink");
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "chchck");
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* element */
msg = gst_missing_element_message_new (pipeline, "foobar");
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "element");
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "foobar");
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* create bogus caps that don't exist */
caps = gst_caps_new_simple ("do/x-not", "exist", G_TYPE_BOOLEAN, FALSE, NULL);
/* decoder (with unknown caps) */
msg = gst_missing_decoder_message_new (pipeline, caps);
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "decoder");
fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* encoder (with unknown caps) */
msg = gst_missing_encoder_message_new (pipeline, caps);
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "encoder");
fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
missing_msg_check_getters (msg);
gst_message_unref (msg);
gst_caps_unref (caps);
/* create caps that exist */
caps = gst_caps_new_simple ("video/x-matroska", NULL);
/* decoder (with known caps) */
msg = gst_missing_decoder_message_new (pipeline, caps);
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "decoder");
fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING));
fail_unless (gst_structure_get_string (s, "name") != NULL);
missing_msg_check_getters (msg);
gst_message_unref (msg);
/* encoder (with known caps) */
msg = gst_missing_encoder_message_new (pipeline, caps);
fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "encoder");
fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING));
fail_unless (gst_structure_get_string (s, "name") != NULL);
missing_msg_check_getters (msg);
gst_message_unref (msg);
gst_caps_unref (caps);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
gst_object_unref (bus);
}
GST_END_TEST;
GST_START_TEST (test_base_utils_init)
{
/* should be fine to call multiple times */
gst_base_utils_init ();
gst_base_utils_init ();
gst_base_utils_init ();
gst_base_utils_init ();
}
GST_END_TEST;
static const gchar *caps_strings[] = {
/* formats with static descriptions */
"application/ogg", "application/vnd.rn-realmedia", "video/x-fli",
"video/x-flv", "video/x-matroska", "video/x-ms-asf", "video/x-msvideo",
"video/x-quicktime", "video/quicktime", "audio/x-ac3", "audio/ac3",
"audio/x-private-ac3", "audio/x-private1-ac3", "audio/x-adpcm",
"audio/aiff", "audio/x-alaw", "audio/amr", "audio/AMR", "audio/AMR-WB",
"audio/iLBC-sh", "audio/ms-gsm", "audio/qcelp", "audio/x-adpcm",
"audio/x-aiff", "audio/x-alac", "audio/x-amr-nb-sh", "audio/x-amr-wb-sh",
"audio/x-au", "audio/x-cinepak", "audio/x-dpcm", "audio/x-dts",
"audio/x-dv", "audio/x-flac", "audio/x-gsm", "audio/x-iec958",
"audio/x-iLBC", "audio/x-ircam", "audio/x-lpcm", "audio/x-private1-lpcm",
"audio/x-m4a", "audio/x-mod", "audio/x-mulaw", "audio/x-musepack",
"audio/x-nist", "audio/x-nsf", "audio/x-paris", "audio/x-qdm2",
"audio/x-ralf-mpeg4-generic", "audio/x-sds", "audio/x-shorten",
"audio/x-sid", "audio/x-sipro", "audio/x-spc", "audio/x-speex",
"audio/x-svx", "audio/x-tta", "audio/x-ttafile",
"audio/x-vnd.sony.atrac3", "audio/x-vorbis", "audio/x-voc", "audio/x-w64",
"audio/x-wav", "audio/x-wavpack", "audio/x-wavpack-correction",
"audio/x-wms", "audio/x-voxware", "video/sp5x", "video/vivo",
"video/x-3ivx", "video/x-4xm", "video/x-apple-video", "video/x-camtasia",
"video/x-cdxa", "video/x-cinepak", "video/x-cirrus-logic-accupak",
"video/x-compressed-yuv", "video/x-dirac", "video/x-dvd-subpicture",
"video/x-ffv", "video/x-flash-screen", "video/x-flash-video",
"video/x-h261", "video/x-huffyuv", "video/x-intel-h263", "video/x-jpeg",
"video/x-mjpeg", "video/x-mjpeg-b", "video/mpegts", "video/x-mng",
"video/x-mszh", "video/x-msvideocodec", "video/x-mve", "video/x-nut",
"video/x-nuv", "video/x-qdrw", "video/x-raw-gray", "video/x-smc",
"video/x-smoke", "video/x-tarkin", "video/x-theora", "video/x-rle",
"video/x-ultimotion", "video/x-vcd", "video/x-vmnc", "video/x-vp3",
"video/x-vp5", "video/x-vp6", "video/x-vp6-flash", "video/x-vp7",
"video/x-xvid", "video/x-zlib", "image/bmp", "image/x-bmp",
"image/x-MS-bmp", "image/gif", "image/jpeg", "image/jng", "image/png",
"image/pbm", "image/ppm", "image/svg+xml", "image/tiff",
"image/x-cmu-raster", "image/x-icon", "image/x-xcf", "image/x-pixmap",
"image/x-xpixmap", "image/x-quicktime", "image/x-sun-raster",
"image/x-tga", "video/x-dv", "video/x-dv",
/* some RTP formats */
"application/x-rtp, media=(string)video, encoding-name=(string)TimVCodec",
"application/x-rtp, media=(string)audio, encoding-name=(string)TimACodec",
"application/x-rtp, media=(string)application, encoding-name=(string)TimMux",
"application/x-rtp, media=(string)woohoo, encoding-name=(string)TPM",
/* incomplete RTP formats */
"application/x-rtp, media=(string)woohoo",
"application/x-rtp, encoding-name=(string)TPM",
"application/x-rtp, media=(string)woohoo",
/* formats with dynamic descriptions */
"audio/mpeg, mpegversion=(int)4",
"audio/mpeg, mpegversion=(int)1, layer=(int)1",
"audio/mpeg, mpegversion=(int)1, layer=(int)2",
"audio/mpeg, mpegversion=(int)1, layer=(int)3",
"audio/mpeg, mpegversion=(int)1, layer=(int)99",
"audio/mpeg, mpegversion=(int)99",
"video/mpeg, mpegversion=(int)2, systemstream=(boolean)TRUE",
"video/mpeg, systemstream=(boolean)FALSE",
"video/mpeg, mpegversion=(int)2",
"video/mpeg, mpegversion=(int)1, systemstream=(boolean)FALSE",
"video/mpeg, mpegversion=(int)2, systemstream=(boolean)FALSE",
"video/mpeg, mpegversion=(int)4, systemstream=(boolean)FALSE",
"video/mpeg, mpegversion=(int)99, systemstream=(boolean)TRUE",
"video/mpeg, mpegversion=(int)99, systemstream=(boolean)FALSE",
"video/mpeg",
"video/x-indeo, indeoversion=(int)3",
"video/x-indeo, indeoversion=(int)5",
"video/x-indeo",
"video/x-wmv, wmvversion=(int)1",
"video/x-wmv, wmvversion=(int)2",
"video/x-wmv, wmvversion=(int)3",
"video/x-wmv, wmvversion=(int)99",
"video/x-wmv",
"audio/x-wma, wmaversion=(int)1",
"audio/x-wma, wmaversion=(int)2",
"audio/x-wma, wmaversion=(int)3",
"audio/x-wma, wmaversion=(int)99",
"audio/x-wma",
"video/x-divx, divxversion=(int)3",
"video/x-divx, divxversion=(int)4",
"video/x-divx, divxversion=(int)5",
"video/x-divx, divxversion=(int)99",
"video/x-divx",
"video/x-svq, svqversion=(int)1",
"video/x-svq, svqversion=(int)3",
"video/x-svq, svqversion=(int)99",
"video/x-svq",
"video/x-h264, variant=(string)itu",
"video/x-h264, variant=(string)videosoft",
"video/x-h264, variant=(string)foobar",
"video/x-h264",
"video/x-h263, variant=(string)itu",
"video/x-h263, variant=(string)lead",
"video/x-h263, variant=(string)microsoft",
"video/x-h263, variant=(string)vdolive",
"video/x-h263, variant=(string)vivo",
"video/x-h263, variant=(string)xirlink",
"video/x-h263, variant=(string)foobar",
"video/x-h263",
"video/x-msmpeg, msmpegversion=(int)41",
"video/x-msmpeg, msmpegversion=(int)42",
"video/x-msmpeg, msmpegversion=(int)43",
"video/x-msmpeg, msmpegversion=(int)99",
"video/x-msmpeg",
"video/x-pn-realvideo, rmversion=(int)1",
"video/x-pn-realvideo, rmversion=(int)2",
"video/x-pn-realvideo, rmversion=(int)3",
"video/x-pn-realvideo, rmversion=(int)4",
"video/x-pn-realvideo, rmversion=(int)99",
"video/x-pn-realvideo",
"audio/x-pn-realaudio, raversion=(int)1",
"audio/x-pn-realaudio, raversion=(int)2",
"audio/x-pn-realaudio, raversion=(int)99",
"audio/x-pn-realaudio",
"audio/x-mace, maceversion=(int)3",
"audio/x-mace, maceversion=(int)6",
"audio/x-mace, maceversion=(int)99",
"audio/x-mace",
"video/x-truemotion, trueversion=(int)1",
"video/x-truemotion, trueversion=(int)2",
"video/x-truemotion, trueversion=(int)99",
"video/x-truemotion",
"video/x-asus, asusversion=(int)1",
"video/x-asus, asusversion=(int)2",
"video/x-asus, asusversion=(int)99",
"video/x-asus",
"video/x-xan, wcversion=(int)1",
"video/x-xan, wcversion=(int)99",
"video/x-xan",
"video/x-ati-vcr, vcrversion=(int)1",
"video/x-ati-vcr, vcrversion=(int)2",
"video/x-ati-vcr, vcrversion=(int)99",
"video/x-ati-vcr",
/* raw audio */
"audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2",
"audio/x-raw-float, rate=(int)22050, channels=(int)2, endianness=(int)1234, width=(int)32",
/* raw video */
"video/x-raw-rgb, bpp=(int)16, endianness=(int)1234, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, width=(int)320, height=(int)240, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1",
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1",
/* and a made-up format */
"video/x-tpm"
};
GST_START_TEST (test_base_utils_get_codec_description)
{
gint i;
gst_base_utils_init ();
for (i = 0; i < G_N_ELEMENTS (caps_strings); ++i) {
GstCaps *caps;
gchar *desc;
caps = gst_caps_from_string (caps_strings[i]);
fail_unless (caps != NULL, "could not create caps from string '%s'",
caps_strings[i]);
GST_LOG ("Caps %s:", caps_strings[i]);
desc = gst_base_utils_get_codec_description (caps);
fail_unless (desc != NULL);
GST_LOG (" - codec : %s", desc);
g_free (desc);
desc = gst_base_utils_get_decoder_description (caps);
fail_unless (desc != NULL);
GST_LOG (" - decoder : %s", desc);
g_free (desc);
desc = gst_base_utils_get_encoder_description (caps);
fail_unless (desc != NULL);
GST_LOG (" - encoder : %s", desc);
g_free (desc);
gst_caps_unref (caps);
}
}
GST_END_TEST;
GST_START_TEST (test_base_utils_taglist_add_codec_info)
{
GstTagList *list;
GstCaps *caps;
gst_base_utils_init ();
list = gst_tag_list_new ();
caps = gst_caps_new_simple ("video/x-theora", NULL);
ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (NULL,
GST_TAG_VIDEO_CODEC, caps)));
ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, NULL, caps)));
ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list, "asdfa", caps)));
ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list,
GST_TAG_IMAGE, caps)));
ASSERT_CRITICAL (fail_if
(gst_base_utils_add_codec_description_to_tag_list (list,
GST_TAG_VIDEO_CODEC, NULL)));
/* FIXME: do something here */
fail_unless (gst_base_utils_add_codec_description_to_tag_list (list,
GST_TAG_VIDEO_CODEC, caps));
fail_if (gst_tag_list_is_empty (list));
gst_tag_list_free (list);
gst_caps_unref (caps);
}
GST_END_TEST;
static gint marker;
static void
result_cb (GstInstallPluginsReturn result, gpointer user_data)
{
GST_LOG ("result = %u, user_data = %p", result, user_data);
fail_unless (user_data == (gpointer) & marker);
marker = result;
}
#define SCRIPT_NO_XID \
"#!/bin/sh\n" \
"if test x$1 != xdetail1; then exit 21; fi;\n" \
"if test x$2 != xdetail2; then exit 22; fi;\n" \
"exit 1\n"
#define SCRIPT_WITH_XID \
"#!/bin/sh\n" \
"if test x$1 != 'x--transient-for=42'; then exit 21; fi;\n" \
"if test x$2 != xdetail1; then exit 22; fi;\n" \
"if test x$3 != xdetail2; then exit 23; fi;\n" \
"exit 0\n"
/* make sure our script gets called with the right parameters */
static void
test_base_utils_install_plugins_do_callout (gchar ** details,
GstInstallPluginsContext * ctx, const gchar * script,
GstInstallPluginsReturn expected_result)
{
#ifdef G_OS_UNIX
GstInstallPluginsReturn ret;
GError *err = NULL;
gchar *path;
path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu",
g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody",
(gulong) getpid ());
if (!g_file_set_contents (path, script, -1, &err)) {
GST_DEBUG ("Failed to write test script to %s: %s", path, err->message);
g_error_free (err);
goto done;
}
if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
GST_DEBUG ("Could not set mode u+rwx on '%s'", path);
goto done;
}
GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path);
g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1);
/* test sync callout */
ret = gst_install_plugins_sync (details, ctx);
fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING ||
ret == expected_result,
"gst_install_plugins_sync() failed with unexpected ret %d, which is "
"neither HELPER_MISSING nor %d", ret, expected_result);
/* test async callout */
marker = -333;
ret = gst_install_plugins_async (details, ctx, result_cb,
(gpointer) & marker);
fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING ||
ret == GST_INSTALL_PLUGINS_STARTED_OK,
"gst_install_plugins_async() failed with unexpected ret %d", ret);
if (ret == GST_INSTALL_PLUGINS_STARTED_OK) {
while (marker == -333) {
g_usleep (500);
g_main_context_iteration (NULL, FALSE);
}
/* and check that the callback was called with the expected code */
fail_unless_equals_int (marker, expected_result);
}
done:
unlink (path);
g_free (path);
#endif /* G_OS_UNIX */
}
GST_START_TEST (test_base_utils_install_plugins)
{
GstInstallPluginsContext *ctx;
GstInstallPluginsReturn ret;
gchar *details[] = { "detail1", "detail2", NULL };
ctx = gst_install_plugins_context_new ();
ASSERT_CRITICAL (ret = gst_install_plugins_sync (NULL, ctx););
ASSERT_CRITICAL (ret =
gst_install_plugins_async (NULL, ctx, result_cb, (gpointer) & marker););
ASSERT_CRITICAL (ret =
gst_install_plugins_async (details, ctx, NULL, (gpointer) & marker););
/* make sure the functions return the right error code if the helper does
* not exist */
g_setenv ("GST_INSTALL_PLUGINS_HELPER", "/does/not/ex/is.t", 1);
ret = gst_install_plugins_sync (details, NULL);
fail_unless_equals_int (ret, GST_INSTALL_PLUGINS_HELPER_MISSING);
marker = -333;
ret =
gst_install_plugins_async (details, NULL, result_cb, (gpointer) & marker);
fail_unless_equals_int (ret, GST_INSTALL_PLUGINS_HELPER_MISSING);
/* and check that the callback wasn't called */
fail_unless_equals_int (marker, -333);
/* now make sure our scripts are actually called as expected (if possible) */
test_base_utils_install_plugins_do_callout (details, NULL, SCRIPT_NO_XID,
GST_INSTALL_PLUGINS_NOT_FOUND);
/* and again with context */
gst_install_plugins_context_set_xid (ctx, 42);
test_base_utils_install_plugins_do_callout (details, ctx, SCRIPT_WITH_XID,
GST_INSTALL_PLUGINS_SUCCESS);
/* and free the context now that we don't need it any longer */
gst_install_plugins_context_free (ctx);
/* completely silly test to check gst_install_plugins_return_get_name()
* is somewhat well-behaved */
{
gint i;
for (i = -99; i < 16738; ++i) {
const gchar *s;
s = gst_install_plugins_return_get_name ((GstInstallPluginsReturn) i);
fail_unless (s != NULL);
/* GST_LOG ("%5d = %s", i, s); */
}
}
}
GST_END_TEST;
static Suite *
libgstbaseutils_suite (void)
{
Suite *s = suite_create ("base utils library");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_base_utils_init);
tcase_add_test (tc_chain, test_base_utils_post_missing_messages);
tcase_add_test (tc_chain, test_base_utils_taglist_add_codec_info);
tcase_add_test (tc_chain, test_base_utils_get_codec_description);
tcase_add_test (tc_chain, test_base_utils_install_plugins);
return s;
}
GST_CHECK_MAIN (libgstbaseutils);