ogg-streams and tags

Hi,

Stations with ogg-streams are much fewer than with mp3. One of my favorite stations (fm4, austrian[1]) has an unofficial ogg-stream[2] that broadcasts tags for artist and title too but moc doesn't display these. Instead of it shows the stream-title all the time. xmms shows the tags. So i played with the sources for a while and found a simple solution (player.c:358f):

- else if (s && (stream_title = io_get_metadata_title(s))
- && (!curr_tags->title
- || strcmp(stream_title, curr_tags->title))) {
- logit ("New io stream tags");
- tags_clear (curr_tags);
+ else if (s && (stream_title = io_get_metadata_title(s)) /* streamtitle doesn't change */
+ && (!curr_tags->title)) {
+ /* || strcmp(stream_title, curr_tags->title))) { */
+ logit ("New io stream tags, (current title: %s)", curr_tags->title);

I don't know wether this breaks something and i tested it on different stations without negativ results.
Any comments?

ciao, storm

[1] http://fm4.orf.at/
[2] http://listen.fm4.amd.co.at:31337/fm4-mq.ogg

A few weeks ago I had similar 'problems' with ogg streams and my personal solution (that's why I love open source btw. :) ) was adding a new function to moc allowing me to ignore the icecast-meta-information (while breaking some window-size-constraints for other people's setups).

I can remember that I followed the way you present here at first but I abandoned it for some reason I don't remember now....

How does you patch behave when switching from an ogg-stream (no meta) to an mp3-stream (with meta) (and back) ? I could image some nasty latency in the update speed... but maybe I'm just paranoid... :)

I just could not resist testing this :

Really works great and also fixed an other problem I had with title generation (for osd)... :-)
Thank you very much for this. I am gonna use this from now on... ;-)

Oops... I was too optimistic :
While working well for ogg-streams the title change for mp3-streams (e.g. slayradio.org) does not work with this (at least not here)...

yep, i observed that as well. I think the real problem comes from the following: Ogg-streams are divided into logical streams. The last packet of such a logical stream causes the vorbis-decoder to throw the error EV_HOLE. The next(1) packet (start of a new logical stream, as i understand) contains the tags for the currently played song of the station. Until the next(2) packet arrives the curr_tags(holds the tags for the currently played song in moc) will be changed to the new tags. When (2) arrives moc sets curr_tags to the stream-tag (not the song-title or artist). The time between (1) and (2) is short and not enough to see "artist" and "title". Thus moc shows the stream-title all the time (at least for some ogg-streams). Until now i don't have a real solution but i try to find one.

ciao, storm

You are basically right. There are two sources for the title with Internet streams: tags inserted in the shoutcast stream and tags from the stream itself (mp3 tags, ogg comments). Since the soutcast is not an official standarad (AFAIK) it's not clear which to show. From practice I can see some streams insert tags only in shoutcast format, some only in the mp3/ogg stream. The problem is situation when both of them are present. MOC shows the last that arrived. In some cases this is the name of the station, not the current tags.

As I said previously there is no standard here, so I don't have a good solution I would be sure to work in any case. Any propositions?

--
Damian Pietras - MOC developer

How about checking which one is changing ?
As far as I have noticed either the information from shoutcast/icecast or from the decoder is static.
This would however require to monitor the actual change of the stream (to a file or other stream) in addition to monitoring the change of information (or else both could change and nobody knows whats correct).

I think I am motivated enough to go after this as I'm switching quite often between different streams these days - but I need to find some free time next week first :-| ...

This is a good idea. I've made a simple patch that tracks shoutcast title and shows it only when it changes. Please try it on your streams.

<br /> Index: player.c<br /> ===================================================================<br /> --- player.c (revision 1960)<br /> +++ player.c (working copy)<br /> @@ -86,6 +86,7 @@</p> <p> /* Tags of the currentply played file. */<br /> static struct file_tags *curr_tags = NULL;<br /> +static char *last_stream_title = NULL;<br /> static pthread_mutex_t curr_tags_mut = PTHREAD_MUTEX_INITIALIZER;</p> <p> /* Stream associated with the currently playing decoder. */<br /> @@ -372,13 +373,16 @@<br /> show_tags (curr_tags);<br /> }<br /> else if (s &amp;& (stream_title = io_get_metadata_title(s))<br /> - &amp;& (!curr_tags->title<br /> - || strcmp(stream_title, curr_tags->title))) {<br /> + &amp;& (!curr_tags->title || !last_stream_title<br /> + || strcmp(stream_title, last_stream_title))) {<br /> logit ("New io stream tags");<br /> tags_clear (curr_tags);<br /> curr_tags->title = stream_title;<br /> show_tags (curr_tags);<br /> tags_changed = 1;<br /> + if (last_stream_title)<br /> + free (last_stream_title);<br /> + last_stream_title = xstrdup (stream_title);<br /> }<br /> else if (stream_title)<br /> free (stream_title);<br /> @@ -420,6 +424,7 @@</p> <p> LOCK (curr_tags_mut);<br /> curr_tags = tags_new ();<br /> + last_stream_title = NULL;<br /> UNLOCK (curr_tags_mut);</p> <p> if (f->get_stream) {<br /> @@ -573,6 +578,11 @@<br /> if (curr_tags) {<br /> tags_free (curr_tags);<br /> curr_tags = NULL;<br /> +<br /> + if (last_stream_title) {<br /> + free (last_stream_title);<br /> + last_stream_title = NULL;<br /> + }<br /> }<br /> UNLOCK (curr_tags_mut);<br />

--
Damian Pietras - MOC developer

Well, this works but there is still a catch :
When switching to a stream without changing shoutcast information I have to wait until the next song-change to get the information (and this can be quite a long time)...

I think there is no real solution to this, as it would either require the plugins to manage the stream-information by themself - I guess, that is what xmms is doing, but I'm not sure - or the plugins would need to indicate if they want their info to dominate shoutcast.
The latter is rather pointless imho as the real error (on the streamers side) is using shoutcast without proper support for the title information...

I like the idea of having shoutcast information managed not by the plugin so maybe there should be something like a whitelist/blacklist approach based on what shoutcast/the decoder return to determine behaviour... but on the other side I have not yet found any ogg-stream that supplied correct (what I want) shoutcast information...

*edit*
I have now hardwired the player to not use shoutcast information when the ogg-decoder is running...
Not a nice solution but it works for me (tm). I'll post the patch if there is interest.

A decision about displaying shoutcast title or the stream title based on the stream format would be acceptable if I knew it solves the problem. Most streams are probably tested with Winamp or Windows Media Player, if someone knows or can guess their behavior we could do the same thing.

--
Damian Pietras - MOC developer

The patch works better than my solution. Tested on all stations in the playlist atm. Thanks - and thanks for the explanation on sources of tags. Maybe that's a point for the options to switch off shoutcast informations completely, but that's not a must-have.

ciao, storm

btw: moc is a nice program

/np: FM4 (18:38) - Ghostface Killah - Outta Town Shit