2006-01-18 19:30:36 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 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
|
2012-11-03 20:40:37 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2006-01-18 19:30:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-09-17 09:53:12 +00:00
|
|
|
#include <gst/gst.h>
|
2012-11-11 20:42:42 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2012-09-17 09:53:12 +00:00
|
|
|
|
2021-03-29 10:28:04 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (gst_cdio_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_cdio_debug
|
|
|
|
|
2012-09-17 09:53:12 +00:00
|
|
|
static gboolean plugin_init (GstPlugin * plugin);
|
|
|
|
|
|
|
|
/* cdio headers redefine VERSION etc., so do this here before including them */
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
cdio,
|
|
|
|
"Read audio from audio CDs",
|
2012-11-11 20:42:42 +00:00
|
|
|
plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
2012-09-17 09:53:12 +00:00
|
|
|
|
2006-01-18 19:30:36 +00:00
|
|
|
#include "gstcdio.h"
|
|
|
|
#include "gstcdiocddasrc.h"
|
|
|
|
|
|
|
|
void
|
2012-05-03 22:50:30 +00:00
|
|
|
gst_cdio_add_cdtext_field (GstObject * src, cdtext_t * cdtext, track_t track,
|
2006-01-18 19:30:36 +00:00
|
|
|
cdtext_field_t field, const gchar * gst_tag, GstTagList ** p_tags)
|
|
|
|
{
|
2012-11-11 20:42:42 +00:00
|
|
|
const gchar *vars[] = { "GST_CDTEXT_TAG_ENCODING", "GST_TAG_ENCODING", NULL };
|
2006-01-18 19:30:36 +00:00
|
|
|
const gchar *txt;
|
2012-11-11 20:42:42 +00:00
|
|
|
gchar *txt_utf8;
|
2006-01-18 19:30:36 +00:00
|
|
|
|
2017-12-06 11:01:39 +00:00
|
|
|
#if LIBCDIO_VERSION_NUM > 83 || LIBCDIO_VERSION_NUM < 76
|
2012-05-03 22:50:30 +00:00
|
|
|
txt = cdtext_get_const (cdtext, field, track);
|
|
|
|
#else
|
2006-01-19 00:10:51 +00:00
|
|
|
txt = cdtext_get_const (field, cdtext);
|
2012-05-03 22:50:30 +00:00
|
|
|
#endif
|
2006-01-18 19:30:36 +00:00
|
|
|
if (txt == NULL || *txt == '\0') {
|
|
|
|
GST_DEBUG_OBJECT (src, "empty CD-TEXT field %u (%s)", field, gst_tag);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-11 20:42:42 +00:00
|
|
|
/* The character encoding is not specified, and there is no provision
|
|
|
|
* for indicating in the CD-Text data which encoding is in use.. */
|
|
|
|
txt_utf8 = gst_tag_freeform_string_to_utf8 (txt, -1, vars);
|
|
|
|
|
|
|
|
if (txt_utf8 == NULL) {
|
|
|
|
GST_WARNING_OBJECT (src, "CD-TEXT %s could not be converted to UTF-8, "
|
|
|
|
"try setting the GST_CDTEXT_TAG_ENCODING or GST_TAG_ENCODING "
|
|
|
|
"environment variable", gst_tag);
|
2006-01-18 19:30:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-11 20:42:42 +00:00
|
|
|
/* FIXME: beautify strings (they might be all uppercase for example)? */
|
|
|
|
|
2006-01-18 19:30:36 +00:00
|
|
|
if (*p_tags == NULL)
|
2011-11-12 21:06:29 +00:00
|
|
|
*p_tags = gst_tag_list_new_empty ();
|
2006-01-18 19:30:36 +00:00
|
|
|
|
2012-11-11 20:42:42 +00:00
|
|
|
gst_tag_list_add (*p_tags, GST_TAG_MERGE_REPLACE, gst_tag, txt_utf8, NULL);
|
2006-01-18 19:30:36 +00:00
|
|
|
|
2012-11-11 20:42:42 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "CD-TEXT: %s = %s", gst_tag, txt_utf8);
|
|
|
|
g_free (txt_utf8);
|
2006-01-18 19:30:36 +00:00
|
|
|
}
|
|
|
|
|
2006-11-02 14:43:11 +00:00
|
|
|
GstTagList *
|
2017-12-06 11:01:39 +00:00
|
|
|
#if LIBCDIO_VERSION_NUM > 83 || LIBCDIO_VERSION_NUM < 76
|
2012-05-03 22:50:30 +00:00
|
|
|
gst_cdio_get_cdtext (GstObject * src, cdtext_t * t, track_t track)
|
|
|
|
{
|
|
|
|
GstTagList *tags = NULL;
|
|
|
|
|
|
|
|
#else
|
2006-11-02 14:43:11 +00:00
|
|
|
gst_cdio_get_cdtext (GstObject * src, CdIo * cdio, track_t track)
|
|
|
|
{
|
|
|
|
GstTagList *tags = NULL;
|
|
|
|
cdtext_t *t;
|
|
|
|
|
|
|
|
t = cdio_get_cdtext (cdio, track);
|
|
|
|
if (t == NULL) {
|
|
|
|
GST_DEBUG_OBJECT (src, "no CD-TEXT for track %u", track);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-05-03 22:50:30 +00:00
|
|
|
#endif
|
2006-11-02 14:43:11 +00:00
|
|
|
|
2012-05-03 22:50:30 +00:00
|
|
|
gst_cdio_add_cdtext_field (src, t, track, CDTEXT_FIELD_PERFORMER,
|
|
|
|
GST_TAG_ARTIST, &tags);
|
|
|
|
gst_cdio_add_cdtext_field (src, t, track, CDTEXT_FIELD_TITLE, GST_TAG_TITLE,
|
|
|
|
&tags);
|
2006-11-02 14:43:11 +00:00
|
|
|
|
|
|
|
return tags;
|
|
|
|
}
|
|
|
|
|
2008-06-09 20:02:05 +00:00
|
|
|
void
|
2017-12-06 11:01:39 +00:00
|
|
|
#if LIBCDIO_VERSION_NUM > 83 || LIBCDIO_VERSION_NUM < 76
|
2012-05-03 22:50:30 +00:00
|
|
|
gst_cdio_add_cdtext_album_tags (GstObject * src, cdtext_t * t,
|
|
|
|
GstTagList * tags)
|
|
|
|
{
|
|
|
|
#else
|
2008-06-09 20:02:05 +00:00
|
|
|
gst_cdio_add_cdtext_album_tags (GstObject * src, CdIo * cdio, GstTagList * tags)
|
|
|
|
{
|
|
|
|
cdtext_t *t;
|
|
|
|
|
|
|
|
t = cdio_get_cdtext (cdio, 0);
|
|
|
|
if (t == NULL) {
|
2009-01-02 00:43:53 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "no CD-TEXT for album");
|
2008-06-09 20:02:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-05-03 22:50:30 +00:00
|
|
|
#endif
|
2008-06-09 20:02:05 +00:00
|
|
|
|
2012-05-03 22:50:30 +00:00
|
|
|
gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_PERFORMER,
|
|
|
|
GST_TAG_ALBUM_ARTIST, &tags);
|
|
|
|
gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_TITLE, GST_TAG_ALBUM,
|
|
|
|
&tags);
|
|
|
|
gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_GENRE, GST_TAG_GENRE,
|
|
|
|
&tags);
|
2008-06-09 20:02:05 +00:00
|
|
|
GST_DEBUG ("CD-TEXT album tags: %" GST_PTR_FORMAT, tags);
|
|
|
|
}
|
|
|
|
|
2021-03-29 10:28:04 +00:00
|
|
|
void
|
2006-01-18 19:30:36 +00:00
|
|
|
gst_cdio_log_handler (cdio_log_level_t level, const char *msg)
|
|
|
|
{
|
|
|
|
const gchar *level_str[] = { "DEBUG", "INFO", "WARN", "ERROR", "ASSERT" };
|
|
|
|
const gchar *s;
|
|
|
|
|
|
|
|
s = level_str[CLAMP (level, 1, G_N_ELEMENTS (level_str)) - 1];
|
|
|
|
GST_DEBUG ("CDIO-%s: %s", s, GST_STR_NULL (msg));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
2021-03-29 10:28:04 +00:00
|
|
|
return GST_ELEMENT_REGISTER (cdiocddasrc, plugin);
|
2006-01-18 19:30:36 +00:00
|
|
|
}
|