ext/shout2/gstshout2.*: Properly handle tags in shout2send. Fixes #399825.

Original commit message from CVS:
Patch by: charles <charlesg3 at gmail dot com>
* ext/shout2/gstshout2.c: (gst_shout2send_init),
(set_shout_metadata), (gst_shout2send_event):
* ext/shout2/gstshout2.h:
Properly handle tags in shout2send. Fixes #399825.
This commit is contained in:
charles 2007-01-26 12:21:41 +00:00 committed by Wim Taymans
parent 0ccf6d4991
commit 8d70a788fa
3 changed files with 46 additions and 21 deletions

View file

@ -1,3 +1,12 @@
2007-01-26 Wim Taymans <wim@fluendo.com>
Patch by: charles <charlesg3 at gmail dot com>
* ext/shout2/gstshout2.c: (gst_shout2send_init),
(set_shout_metadata), (gst_shout2send_event):
* ext/shout2/gstshout2.h:
Properly handle tags in shout2send. Fixes #399825.
2007-01-25 Wim Taymans <wim@fluendo.com> 2007-01-25 Wim Taymans <wim@fluendo.com>
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_media_to_caps), * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_media_to_caps),

View file

@ -256,14 +256,21 @@ gst_shout2send_init (GstShout2send * shout2send)
shout2send->audio_format = SHOUT_FORMAT_VORBIS; shout2send->audio_format = SHOUT_FORMAT_VORBIS;
shout2send->connected = FALSE; shout2send->connected = FALSE;
shout2send->songmetadata = NULL; shout2send->songmetadata = NULL;
shout2send->songartist = NULL;
shout2send->songtitle = NULL;
} }
static void static void
set_shout_metadata (const GstTagList * list, const gchar * tag, set_shout_metadata (const GstTagList * list, const gchar * tag,
gpointer user_data) gpointer user_data)
{ {
char **shout_metadata = (char **) user_data; GstShout2send *shout2send = (GstShout2send *) user_data;
gchar *value, *temp; char **shout_metadata = &(shout2send->songmetadata);
char **song_artist = &(shout2send->songartist);
char **song_title = &(shout2send->songtitle);
gchar *value;
GST_DEBUG ("tag: %s being added", tag); GST_DEBUG ("tag: %s being added", tag);
if (strcmp (tag, GST_TAG_ARTIST) == 0) { if (strcmp (tag, GST_TAG_ARTIST) == 0) {
@ -272,15 +279,11 @@ set_shout_metadata (const GstTagList * list, const gchar * tag,
GST_DEBUG ("Error reading \"%s\" tag value", tag); GST_DEBUG ("Error reading \"%s\" tag value", tag);
return; return;
} }
/* shout_metadata should be NULL if title is after artist in list */
if (*shout_metadata == NULL) {
*shout_metadata = g_strdup (value);
} else {
temp = g_strdup_printf ("%s - %s", value, *shout_metadata);
g_free (*shout_metadata);
*shout_metadata = temp;
}
if (*song_artist != NULL)
g_free (*song_artist);
*song_artist = g_strdup (value);
} }
} else if (strcmp (tag, GST_TAG_TITLE) == 0) { } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (gst_tag_get_type (tag) == G_TYPE_STRING) {
@ -288,16 +291,28 @@ set_shout_metadata (const GstTagList * list, const gchar * tag,
GST_DEBUG ("Error reading \"%s\" tag value", tag); GST_DEBUG ("Error reading \"%s\" tag value", tag);
return; return;
} }
/* shout_metadata should be NULL if title is before artist in list */
if (*shout_metadata == NULL) { if (*song_title != NULL)
*shout_metadata = g_strdup (value); g_free (*song_title);
} else {
temp = g_strdup_printf ("%s - %s", *shout_metadata, value); *song_title = g_strdup (value);
g_free (*shout_metadata);
*shout_metadata = temp;
}
} }
} }
if (*shout_metadata != NULL)
g_free (*shout_metadata);
if (*song_title && *song_artist) {
*shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
} else if (*song_title && *song_artist == NULL) {
*shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
} else if (*song_title == NULL && *song_artist) {
*shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
} else {
*shout_metadata = g_strdup_printf ("Unknown - Unknown");
}
GST_LOG ("shout metadata is now: %s", *shout_metadata); GST_LOG ("shout metadata is now: %s", *shout_metadata);
} }
@ -355,8 +370,8 @@ gst_shout2send_event (GstBaseSink * sink, GstEvent * event)
list, list,
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send))); gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (shout2send)));
/* lets get the artist and song tags */ /* lets get the artist and song tags */
gst_tag_list_foreach ((GstTagList *) shout2send->tags, gst_tag_list_foreach ((GstTagList *) list,
set_shout_metadata, &shout2send->songmetadata); set_shout_metadata, shout2send);
if (shout2send->songmetadata && shout2send->connected) { if (shout2send->songmetadata && shout2send->connected) {
shout_metadata_t *pmetadata; shout_metadata_t *pmetadata;

View file

@ -54,7 +54,8 @@ struct _GstShout2send {
gchar *url; gchar *url;
gboolean connected; gboolean connected;
gchar *songmetadata; gchar *songmetadata;
gchar *songartist;
gchar *songtitle;
guint16 audio_format; guint16 audio_format;
GstTagList* tags; GstTagList* tags;