Here are some things that I have learned about iTunes and streaming. Or think that I have learned. I place them here to hopefully prevent others from banging their heads against this wall in the future.
In iTunes 8 and 9, and possibly earlier versions, streaming audio works like this:
- The Content-Length header is used to compute the "Time" column based on the MP3 bitrate. The x-audiocast-bitrate header may also be implicated in this but I'm not sure.
If there is no Content-Length, "Time" shows as "Continuous".
If headers contain both "Content-Length" and "Accept-Ranges: bytes" then the "seek" slider in the UI is active, and moving it re-loads the URL using "Range:bytes=N-M". The server must then respond with status 206, a "Content-Range" header, etc.
You can set the title of the stream (as displayed in both the track listing and at the top of the window) by sending either the "x-audiocast-name" or "icy-name" headers. Case-sensitive!
You can accomplish the same thing by sending an ID3v2 TIT2 tag at the front of the MP3 data.
If you send multiple ID3 tags, only the first is used (you can't just send multiple tags to update streaming metadata).
iTunes supports Icecast/Shoutcast-style inline metadata, but does not advertise this. It should be sending "icy-metadata:1" to indicate that it is capable, but it does not. However, if you send icy-metaint:NNNN and encode it properly, it works. This is the only way to update streaming metadata, e.g., to change the title when the song changes. This metadata will be displayed at the top of the window, but does not overwrite the track name.
Now here's where it gets fun. iTunes 10 changed things. As far as I can tell, inside the black box there is now a "mode" that distinguishes between two cases. Let's call these cases "streaming" and "playing a remote file". You might think that those two cases are exactly the same god damned thing, and you're right, but iTunes disagrees.
When iTunes 10 has decided to be in "streaming" mode:
- Regardless of Content-Length, "Time" always shows as "Continuous".
- Titles and metadata can be updated with x-audiocast-name, icy-name and/or inline icy-metaint metadata.
- The "seek" slider is inactive. No byte-range requests will be made, period.
When iTunes 10 has decided to be in "remote file" mode:
- "Time" is displayed properly.
- The "seek" slider is active, and byte-ranges work.
- The x-audiocast-name and icy-name headers are ignored. Sending an ID3v2 TIT2 tag works, though.
- Sending icy-metaint inline metadata will cause audio glitches. It's not interpreting it at all.
Now, how does it decide between these two modes, you might ask? Well I'll tell you:
- Whether the URL ends with the string .mp3.
No, I am not making this up.
So what this means in practice is that there is no way to have a stream that is seekable and also has dynamically-updated metadata. Either you have a single title for the whole thing that never changes, and you can enable seeking; or you can have continuously-updating metadata, but never seek. In iTunes 9, you could have it all; no longer.
So what's changed in iTunes 11?
I haven't tested it personally, because I still depend heavily on a couple of features they've deleted, but from talking to others who are running it, the situation appears to be:
- iTunes 11.0.1 will now send the icy-metadata header when it is in the mood to accept inline metadata. Unlike earlier versions where you had to guess, at least now they're being explicit about it. Not that that helps much, since you still have to guess for older versions of iTunes.
The "seek" bar never works, ever. If the bits came from a URL, then the "Size" field says "Stream" and you can't seek, even if the URL provided a Content-Length and Accept-Ranges. It now won't even tell you how long the stream is, though the information is there.
So, having only recently crippled the functionality of "stream" by dividing it into the "stream" and "remote file" false dichotomy, they appear to have gone farther and nuked the "remote file" capabilities entirely.
Seeking and metadata still work in VLC, for what it's worth, assuming that you can bring yourself to tolerate that program's catastrophically terrible UI.
If you're messing around with this crap at all, then you will probably be interested in my streaming servers: slowcat.c, audiofs.pl and mixtape.pl.
If you work for Apple, please hassle somebody about bug reports 13004973, 13004985 and 10737146.
I think that, were you to break out of the shackles of proprietary software and user-hostile software like Apple's that ships with extremely strict DRM, you would never have such issues. Just consider it.
Desktop Linux as a whole is much better now. Don't know when the last time you tried it was.
Yeah, I could just say to every one of my customers, "Hey, buddy, break out of your shackles." What software is running on my desktop is irrelevant, you ass.
The last time I booted up my Desktop Linux machine, every time I logged in, it would show me a black screen and then spit me back out onto the login page.
After an hour and some google-fu, I fixed the two distinct issues that were apparently causing this, turned the machine off, and rearranged my desk without bothering to check whether I hooked it up correctly or not.
I think that, were you to break out of the shackles of proprietary software and user-hostile software like Apple's that ships with extremely strict DRM, you would never have such issues.
Yes, because if there's one thing linux is famous for, it's the stability, standards-conformance and feature-richness of its audio stack.
Audio stack has nothing to do with moving data over network, duh. And Linux audio stack is very stable. For one month every now and then.
Joking aside, both ALSA and PulseAudio have been very stable in the last three years. The main problem was distros mass-switching to them when they were effectively incomplete.
No, "mass-switching" to an "effectively incomplete" system is not the "main problem". It is only a symptom of a much deeper problem.
what does that have to do with serving audio? that's fantastic and everything, but real people use itunes and presumably jwz's interested in having real people listen to his streams.
My very stable pulseaudio still needs to be randomly killed every other day to get sound to output at all.
That is the most hilarious thing I've heard this month.
If you want to pretend the millennium never ended, or you really liked Windows 3.11, Linux on the desktop is certainly the way to go.
It was better until GNOME 3. Now Windows 7 is better.
What happens if the file is aac encoded, ending .aac?
Didn't care, didn't try.
What is the Content-Type: header advertising for .mp3 (and .aac)? Hard to believe iTunes is sniffing filename directly; it's not IE. But only testing .mp3 isn't conclusive either way.
Test it yourself if you don't believe me. In my tests, the headers were identical. The only variant was the ".mp3" on the URL.
Arr, when I get kicked behind me balls, I use icy-metaint.
You're wrong if you think that "streaming" and "playing a remote file" are the same thing. Remember that "streaming" is only short for "livestreaming": livestreams are unseekable by definition as they're intended to behave like FM radio signals transmitted over the Internet. You can only seek in what you recorded locally, and seeking forward is conceptually impossible. That iTunes before v10 actually offered some form of hybrid support shows how poorly the software was designed. Apparently the software engineers merely fixed what should have never been done anyway. That it tells both concepts apart using the file extension is pretty much the only option they have as there's AFAIK no standard way to distinguish between a file of finite size and a file of infinite size. If you want to update song titles in a recorded file containing multiple songs you need to use an audio format that supports chapter markers.
A file of finite size is one with a Content-Length header.
You are a pinhead.
File a bug report. This shit worked, now it does not.
That trick never works with Apple. But, Radar 13004973, 13004985, 10737146 just for shits and giggles.
The only good UI is the one that you're used to. I think Winamp has a nice gui ffs!