mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
* Back out conversions to ISO8859-1.
* Add 'charset=UTF-8' to the metadata update query arguments. The current release of Icecast will ignore it, and the next one will know how to handle it (karl@ is still working on it at this point, but previous diffs worked as advertised.) * If no metadata format string is available and we have both an artist and a title, use the artist/title way of updating instead of the generic "song" interface. git-svn-id: https://svn.xiph.org/trunk/ezstream@13658 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
de17e12fb8
commit
df482694c0
@ -470,7 +470,8 @@ int
|
|||||||
setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
||||||
{
|
{
|
||||||
shout_metadata_t *shout_mdata = NULL;
|
shout_metadata_t *shout_mdata = NULL;
|
||||||
char *songInfo, *encSongInfo;
|
char *songInfo;
|
||||||
|
const char *artist, *title;
|
||||||
int ret = SHOUTERR_SUCCESS;
|
int ret = SHOUTERR_SUCCESS;
|
||||||
|
|
||||||
if (shout == NULL) {
|
if (shout == NULL) {
|
||||||
@ -488,37 +489,63 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((songInfo = getMetadataString(pezConfig->metadataFormat, mdata)) == NULL) {
|
artist = metadata_get_artist(mdata);
|
||||||
if (strlen(metadata_get_artist(mdata)) == 0 &&
|
title = metadata_get_title(mdata);
|
||||||
strlen(metadata_get_title(mdata)) == 0)
|
|
||||||
songInfo = xstrdup(metadata_get_string(mdata));
|
|
||||||
else
|
|
||||||
songInfo = metadata_assemble_string(mdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(pezConfig->format, VORBIS_FORMAT) == 0 ||
|
/*
|
||||||
strcmp(pezConfig->format, THEORA_FORMAT) == 0)
|
* We can do this, because we know how libshout works. This adds
|
||||||
encSongInfo = xstrdup(songInfo);
|
* "charset=UTF-8" to the HTTP metadata update request and has the
|
||||||
else
|
* desired effect of letting newer-than-2.3.1 versions of Icecast know
|
||||||
encSongInfo = UTF8toISO8859_1(songInfo, ICONV_TRANSLIT);
|
* which encoding we're using.
|
||||||
|
*/
|
||||||
if (shout_metadata_add(shout_mdata, "song", (encSongInfo != NULL) ? encSongInfo : "")
|
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
||||||
!= SHOUTERR_SUCCESS) {
|
|
||||||
/* Assume SHOUTERR_MALLOC */
|
/* Assume SHOUTERR_MALLOC */
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((songInfo = getMetadataString(pezConfig->metadataFormat, mdata)) == NULL) {
|
||||||
|
if (artist[0] == '\0' && title[0] == '\0')
|
||||||
|
songInfo = xstrdup(metadata_get_string(mdata));
|
||||||
|
else
|
||||||
|
songInfo = metadata_assemble_string(mdata);
|
||||||
|
if (artist[0] != '\0' && title[0] != '\0') {
|
||||||
|
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
||||||
|
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||||
|
strerror(ENOMEM));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
||||||
|
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||||
|
strerror(ENOMEM));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
|
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||||
|
strerror(ENOMEM));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
|
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||||
|
strerror(ENOMEM));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
||||||
printf("%s: shout_set_metadata(): %s\n",
|
printf("%s: shout_set_metadata(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
__progname, shout_get_error(shout));
|
||||||
|
|
||||||
shout_metadata_free(shout_mdata);
|
shout_metadata_free(shout_mdata);
|
||||||
if (ret == SHOUTERR_SUCCESS &&
|
|
||||||
mdata_copy != NULL && *mdata_copy == NULL)
|
if (ret == SHOUTERR_SUCCESS) {
|
||||||
|
if (mdata_copy != NULL && *mdata_copy == NULL)
|
||||||
*mdata_copy = xstrdup(songInfo);
|
*mdata_copy = xstrdup(songInfo);
|
||||||
|
}
|
||||||
|
|
||||||
xfree(songInfo);
|
xfree(songInfo);
|
||||||
xfree(encSongInfo);
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/util.c
13
src/util.c
@ -236,7 +236,7 @@ CHARtoUTF8(const char *in_str, int mode)
|
|||||||
setlocale(LC_CTYPE, "C");
|
setlocale(LC_CTYPE, "C");
|
||||||
# else
|
# else
|
||||||
codeset = (char *)"";
|
codeset = (char *)"";
|
||||||
# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
|
# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */
|
||||||
#else
|
#else
|
||||||
char codeset[24];
|
char codeset[24];
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ UTF8toCHAR(const char *in_str, int mode)
|
|||||||
setlocale(LC_CTYPE, "C");
|
setlocale(LC_CTYPE, "C");
|
||||||
# else
|
# else
|
||||||
codeset = (char *)"";
|
codeset = (char *)"";
|
||||||
# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE */
|
# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */
|
||||||
#else
|
#else
|
||||||
char codeset[24];
|
char codeset[24];
|
||||||
|
|
||||||
@ -274,15 +274,6 @@ UTF8toCHAR(const char *in_str, int mode)
|
|||||||
return (iconvert(in_str, "UTF-8", codeset, mode));
|
return (iconvert(in_str, "UTF-8", codeset, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
UTF8toISO8859_1(const char *in_str, int mode)
|
|
||||||
{
|
|
||||||
if (in_str == NULL || strlen(in_str) == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
return (iconvert(in_str, "UTF-8", "ISO-8859-1", mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
iconvert(const char *in_str, const char *from, const char *to, int mode)
|
iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,5 @@ int strrcasecmp(const char *, const char *);
|
|||||||
shout_t * stream_setup(const char *, const int, const char *);
|
shout_t * stream_setup(const char *, const int, const char *);
|
||||||
char * CHARtoUTF8(const char *, int);
|
char * CHARtoUTF8(const char *, int);
|
||||||
char * UTF8toCHAR(const char *, int);
|
char * UTF8toCHAR(const char *, int);
|
||||||
char * UTF8toISO8859_1(const char *, int);
|
|
||||||
|
|
||||||
#endif /* __UTIL_H__ */
|
#endif /* __UTIL_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user