Skip to content

Commit

Permalink
tag: add some utility functions for language codes and tags
Browse files Browse the repository at this point in the history
Add some utility functions for language tags and ISO-639
codes. These are useful for both GUIs and elements. The
iso-codes package is used for language name translations
if available.

API: gst_tag_get_language_codes()
API: gst_tag_get_language_name()
API: gst_tag_get_language_code()
API: gst_tag_get_language_code_iso_639_1()
API: gst_tag_get_language_code_iso_639_2B()
API: gst_tag_get_language_code_iso_639_2T()
  • Loading branch information
Tim-Philipp Müller committed Dec 12, 2009
1 parent e897373 commit 088c7c0
Show file tree
Hide file tree
Showing 11 changed files with 1,341 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -42,3 +42,5 @@ Makefile.in
Makefile
*.gir
*.typelib

gst-libs/gst/tag/mklangtables
53 changes: 53 additions & 0 deletions configure.ac
Expand Up @@ -348,6 +348,56 @@ if test "x$HAVE_SYS_SOCKET_H" != "xyes"; then
AG_GST_DISABLE_PLUGIN(tcp)
fi

dnl iso-codes is optional, used by libgsttag
AC_ARG_ENABLE(iso-codes,
AC_HELP_STRING([--enable-iso-codes],[use iso-codes if installed]),
[case "${enableval}" in
yes) enable_iso_codes=yes ;;
no) enable_iso_codes=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-iso-codes) ;;
esac
],
[enable_iso_codes=yes]) dnl Default value

AC_MSG_CHECKING([whether to use iso-codes if they are available])
if test "x$enable_iso_codes" = "xyes"; then
AC_MSG_RESULT([yes])
have_iso_codes=no
AC_MSG_CHECKING([whether iso-codes are available on this system])
if $PKG_CONFIG iso-codes; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether iso-codes has iso-639 domain])
if $PKG_CONFIG --variable=domains iso-codes | $GREP -q 639 ; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for iso-codes prefix])
ISO_CODES_PREFIX=`$PKG_CONFIG --variable=prefix iso-codes`
if test -d "$ISO_CODES_PREFIX"; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([ISO_CODES_PREFIX])
AC_MSG_RESULT([$ISO_CODES_PREFIX])
ISO_639_DOMAIN="iso_639"
AC_MSG_CHECKING([ISO_639_DOMAIN])
AC_MSG_RESULT([$ISO_639_DOMAIN])
have_iso_codes=yes
AC_DEFINE([HAVE_ISO_CODES], [1], [make use of iso-codes for ISO-639])
AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX], ["$ISO_CODES_PREFIX"], [prefix])
ISO_CODES_VERSION=`$PKG_CONFIG --modversion iso-codes`
AC_DEFINE_UNQUOTED([ISO_CODES_VERSION], ["$ISO_CODES_VERSION"], [ ])
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
AM_CONDITIONAL(USE_ISO_CODES, test "x$have_iso_codes" = "xyes")
else
AC_MSG_RESULT([no (disabled via --disable-iso-codes)])
AM_CONDITIONAL(USE_ISO_CODES, false)
fi

dnl *** sys plug-ins ***

echo
Expand Down Expand Up @@ -847,6 +897,7 @@ sed \
-e 's/.* HAVE_CPU_I386$/#define HAVE_CPU_I386 1/' \
-e 's/.* HAVE_FGETPOS$/#define HAVE_FGETPOS 1/' \
-e 's/.* HAVE_FSETPOS$/#define HAVE_FSETPOS 1/' \
-e 's/.* HAVE_ISO_CODES$/#undef HAVE_ISO_CODES/' \
-e 's/.* HAVE_LIBXML2$/#define HAVE_LIBXML2 1/' \
-e 's/.* HAVE_PROCESS_H$/#define HAVE_PROCESS_H 1/' \
-e 's/.* HAVE_STDLIB_H$/#define HAVE_STDLIB_H 1/' \
Expand All @@ -856,6 +907,8 @@ sed \
-e 's/.* HAVE_WIN32$/#define HAVE_WIN32 1/' \
-e 's/.* HAVE_WINSOCK2_H$/#define HAVE_WINSOCK2_H 1/' \
-e 's/.* HOST_CPU$/#define HOST_CPU "i686"/' \
-e 's/.* ISO_CODES_PREFIX$/#undef ISO_CODES_PREFIX/' \
-e 's/.* ISO_CODES_VERSION$/#undef ISO_CODES_VERSION/' \
-e 's/.* LIBDIR$/#ifdef _DEBUG\n# define LIBDIR PREFIX "\\\\debug\\\\lib"\n#else\n# define LIBDIR PREFIX "\\\\lib"\n#endif/' \
-e 's/.* LOCALEDIR$/#define LOCALEDIR PREFIX "\\\\share\\\\locale"/' \
-e "s/.* PACKAGE$/#define PACKAGE \"$PACKAGE\"/" \
Expand Down
1 change: 1 addition & 0 deletions docs/libs/gst-plugins-base-libs-docs.sgml
Expand Up @@ -192,6 +192,7 @@
<xi:include href="xml/gsttagvorbis.xml" />
<xi:include href="xml/gsttagid3.xml" />
<xi:include href="xml/gsttagdemux.xml" />
<xi:include href="xml/gsttaglanguagecodes.xml" />
</chapter>

<chapter id="gstreamer-base-utils">
Expand Down
12 changes: 12 additions & 0 deletions docs/libs/gst-plugins-base-libs-sections.txt
Expand Up @@ -1564,6 +1564,18 @@ GstTagDemuxClass
GstTagDemuxResult
</SECTION>

<SECTION>
<FILE>gsttaglanguagecodes</FILE>
<INCLUDE>gst/tag/tag.h</INCLUDE>
<SUBSECTION>
gst_tag_get_language_codes
gst_tag_get_language_name
gst_tag_get_language_code
gst_tag_get_language_code_iso_639_1
gst_tag_get_language_code_iso_639_2B
gst_tag_get_language_code_iso_639_2T
</SECTION>

# base utils

<SECTION>
Expand Down
16 changes: 15 additions & 1 deletion gst-libs/gst/tag/Makefile.am
Expand Up @@ -6,7 +6,7 @@ libgsttaginclude_HEADERS = \

lib_LTLIBRARIES = libgsttag-@GST_MAJORMINOR@.la

libgsttag_@GST_MAJORMINOR@_la_SOURCES = gstvorbistag.c gstid3tag.c tags.c gsttagdemux.c
libgsttag_@GST_MAJORMINOR@_la_SOURCES = gstvorbistag.c gstid3tag.c lang.c tags.c gsttagdemux.c
libgsttag_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgsttag_@GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
libgsttag_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
Expand Down Expand Up @@ -49,3 +49,17 @@ typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)

CLEANFILES = $(BUILT_GIRSOURCES) $(typelibs_DATA)
endif

# little program that reads iso_639.xml and outputs tables for us as fallback
# for when iso-codes are not available (and so we don't have to read the xml
# just to map codes)
if USE_ISO_CODES
ISO_CODE_PROGS = mklangtables
mklangtables_SOURCES = mklangtables.c
mklangtables_CFLAGS = $(GST_CFLAGS)
mklangtables_LDADD = $(GST_LIBS)
else
ISO_CODE_PROGS =
endif

noinst_PROGRAMS = $(ISO_CODE_PROGS)

0 comments on commit 088c7c0

Please sign in to comment.