owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.09k stars 237 forks source link

Serve radio streams to iTunes #410

Open pztrn opened 7 years ago

pztrn commented 7 years ago

As title says, it have problems. To be more specific - latest iTunes on 10.12.6 shows nothing in playlist, but it is added to database.

This problem appears on 24.2 from Debian 9 and on 25.0 which was manually compiled. Tested with two types of playlists - with one stream and two streams, both AAC 128k and MP3 320k. Debug output:

[DEBUG]       db: Added playlist Digitally Imported - Hardstyle (path /disk1/Stas/Music/Digitally Imported - Hardstyle.pls) with id 9
[ INFO]     scan: Added playlist as id 9
[DEBUG]     scan: Playlist contains URL entry: 'http://prem2.di.fm:80/hardstyle?heregoeskey'
[DEBUG]       db: Running query 'SELECT f.id, f.db_timestamp FROM files f WHERE f.path = 'http://prem2.di.fm:80/hardstyle?heregoeskey';'
[DEBUG]   ffmpeg: Opening 'http://prem2.di.fm:80/hardstyle?heregoeskey' for reading
[DEBUG]   ffmpeg: Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[DEBUG]   ffmpeg: request: GET /hardstyle?heregoeskey HTTP/1.1
User-Agent: Lavf/57.71.100
Accept: */*
Range: bytes=0-
Connection: close
Host: prem2.di.fm:80
Icy-MetaData: 1

[DEBUG]   ffmpeg: Probing aac score:51 increased to 75 due to MIME type
[DEBUG]   ffmpeg: Format aac probed with size=2048 and score=75
[DEBUG]   ffmpeg: Before avformat_find_stream_info() pos: 0 bytes read:2400 seeks:0 nb_streams:1
[DEBUG]   ffmpeg: All info found
[ WARN]   ffmpeg: Estimating duration from bitrate, this may be inaccurate
[DEBUG]   ffmpeg: After avformat_find_stream_info() pos: 19423 bytes read:20271 seeks:0 frames:50
[DEBUG]     scan: File has 1 streams
[DEBUG]     scan: Duration 98246650 ms, bitrate 122 kbps
[DEBUG]     scan: Found ICY metadata, name is 'Hardstyle - Digitally Imported Premium'
[DEBUG]     scan: Found ICY metadata, genre is 'Hardstyle Hard Bass Nu-Hardstyle'
[DEBUG]     scan: samplerate 44100, bps 32
[DEBUG]     scan: AAC
[DEBUG]     scan: Picked up 0 tags from file metadata
[DEBUG]     scan: Picked up 0 tags with generic md_map, 0 tags total
[DEBUG]   ffmpeg: Statistics: 20271 bytes read, 0 seeks
[ WARN]     scan: ffmpeg/libav could not extract any metadata
[DEBUG]       db: Running query 'UPDATE files SET path = 'http://prem2.di.fm:80/hardstyle?heregoeskey', fname = 'hardstyle?heregoeskey', title = TRIM('Hardstyle - Digitally Imported Premium'), artist = TRIM('Hardstyle - Digitally Imported Premium'), album = TRIM('Unknown album'), genre = TRIM('Hardstyle Hard Bass Nu-Hardstyle'), comment = TRIM(NULL), type = 'm4a', composer = TRIM(NULL), orchestra = TRIM(NULL), conductor = TRIM(NULL), grouping = TRIM(NULL), url = NULL, bitrate = 122, samplerate = 44100, song_length = 98246650, file_size = 0, year = 0, track = 0, total_tracks = 0, disc = 0, total_discs = 0, bpm = 0, compilation = 0, artwork = 7, rating = 0, seek = 0, data_kind = 1, item_kind = 2, description = 'AAC audio file', time_modified = 1502000652, db_timestamp = 1502000710, disabled = 0, sample_count = 0, codectype = 'mp4a', idx = 0, has_video = 0, bits_per_sample = 32, album_artist = TRIM('Hardstyle - Digitally Imported Premium'), media_kind = 1, tv_series_name = TRIM(NULL), tv_episode_num_str = TRIM(NULL), tv_network_name = TRIM(NULL), tv_episode_sort = 0, tv_season_num = 0, songartistid = daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), ''), songalbumid = daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), LOWER(TRIM('Unknown album'))), title_sort = TRIM('Hardstyle - Digitally Imported Premium'), artist_sort = TRIM('Hardstyle - Digitally Imported Premium'), album_sort = TRIM('Unknown album'), composer_sort = TRIM(NULL), album_artist_sort = TRIM('Hardstyle - Digitally Imported Premium'), virtual_path = TRIM('/http:/Hardstyle - Digitally Imported Premium'), directory_id = 3, date_released = 0 WHERE id = 4741;'
[DEBUG]       db: Running query 'INSERT INTO playlistitems (playlistid, filepath) VALUES (9, 'http://prem2.di.fm:80/hardstyle?heregoeskey');'
[DEBUG]     scan: Playlist contains URL entry: 'http://prem1.di.fm:80/hardstyle?heregoeskey'
[DEBUG]       db: Running query 'SELECT f.id, f.db_timestamp FROM files f WHERE f.path = 'http://prem1.di.fm:80/hardstyle?heregoeskey';'
[DEBUG]       db: No results
[DEBUG]   ffmpeg: Opening 'http://prem1.di.fm:80/hardstyle?heregoeskey' for reading
[DEBUG]   ffmpeg: Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[DEBUG]   ffmpeg: request: GET /hardstyle?heregoeskey HTTP/1.1
User-Agent: Lavf/57.71.100
Accept: */*
Range: bytes=0-
Connection: close
Host: prem1.di.fm:80
Icy-MetaData: 1

[DEBUG]   ffmpeg: Probing aac score:51 increased to 75 due to MIME type
[DEBUG]   ffmpeg: Format aac probed with size=2048 and score=75
[DEBUG]   ffmpeg: Before avformat_find_stream_info() pos: 0 bytes read:2896 seeks:0 nb_streams:1
[DEBUG]   ffmpeg: All info found
[DEBUG]   ffmpeg: After avformat_find_stream_info() pos: 19380 bytes read:20228 seeks:0 frames:50
[DEBUG]     scan: File has 1 streams
[DEBUG]     scan: Duration 0 ms, bitrate 118 kbps
[DEBUG]     scan: Found ICY metadata, name is 'Hardstyle - Digitally Imported Premium'
[DEBUG]     scan: Found ICY metadata, genre is 'Hardstyle Hard Bass Nu-Hardstyle'
[DEBUG]     scan: samplerate 44100, bps 32
[DEBUG]     scan: AAC
[DEBUG]     scan: Picked up 0 tags from file metadata
[DEBUG]     scan: Picked up 0 tags with generic md_map, 0 tags total
[DEBUG]   ffmpeg: Statistics: 20228 bytes read, 0 seeks
[ WARN]     scan: ffmpeg/libav could not extract any metadata
[DEBUG]       db: Running query 'INSERT INTO files (id, path, fname, title, artist, album, genre, comment, type, composer, orchestra, conductor, grouping, url, bitrate, samplerate, song_length, file_size, year, track, total_tracks, disc, total_discs, bpm, compilation, artwork, rating, play_count, seek, data_kind, item_kind, description, time_added, time_modified, time_played, db_timestamp, disabled, sample_count, codectype, idx, has_video, contentrating, bits_per_sample, album_artist, media_kind, tv_series_name, tv_episode_num_str, tv_network_name, tv_episode_sort, tv_season_num,  songartistid, songalbumid,  title_sort, artist_sort, album_sort, composer_sort, album_artist_sort, virtual_path, directory_id, date_released)  VALUES (NULL, 'http://prem1.di.fm:80/hardstyle?heregoeskey', 'hardstyle?heregoeskey', TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Unknown album'), TRIM('Hardstyle Hard Bass Nu-Hardstyle'), TRIM(NULL), 'm4a', TRIM(NULL), TRIM(NULL), TRIM(NULL), TRIM(NULL), NULL, 118, 44100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 1, 2, 'AAC audio file', 1502000711, 1502000652, 0, 1502000711, 0, 0, 'mp4a', 0, 0, 0, 32, TRIM('Hardstyle - Digitally Imported Premium'), 1, TRIM(NULL), TRIM(NULL), TRIM(NULL), 0, 0, daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), ''), daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), LOWER(TRIM('Unknown album'))),  TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Unknown album'), TRIM(NULL), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('/http:/Hardstyle - Digitally Imported Premium'), 3, 0);'
[DEBUG]       db: Running query 'INSERT INTO playlistitems (playlistid, filepath) VALUES (9, 'http://prem1.di.fm:80/hardstyle?heregoeskey');'
[DEBUG]     scan: Playlist contains URL entry: 'http://prem4.di.fm:80/hardstyle?heregoeskey'
[DEBUG]       db: Running query 'SELECT f.id, f.db_timestamp FROM files f WHERE f.path = 'http://prem4.di.fm:80/hardstyle?heregoeskey';'
[DEBUG]       db: No results
[DEBUG]   ffmpeg: Opening 'http://prem4.di.fm:80/hardstyle?heregoeskey' for reading
[DEBUG]   ffmpeg: Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[DEBUG]   ffmpeg: request: GET /hardstyle?heregoeskey HTTP/1.1
User-Agent: Lavf/57.71.100
Accept: */*
Range: bytes=0-
Connection: close
Host: prem4.di.fm:80
Icy-MetaData: 1

[DEBUG]   ffmpeg: Probing aac score:51 increased to 75 due to MIME type
[DEBUG]   ffmpeg: Format aac probed with size=2048 and score=75
[DEBUG]   ffmpeg: Before avformat_find_stream_info() pos: 0 bytes read:2896 seeks:0 nb_streams:1
[DEBUG]   ffmpeg: All info found
[DEBUG]   ffmpeg: After avformat_find_stream_info() pos: 19342 bytes read:19437 seeks:0 frames:50
[DEBUG]     scan: File has 1 streams
[DEBUG]     scan: Duration 0 ms, bitrate 128 kbps
[DEBUG]     scan: Found ICY metadata, name is 'Hardstyle - Digitally Imported Premium'
[DEBUG]     scan: Found ICY metadata, genre is 'Hardstyle Hard Bass Nu-Hardstyle'
[DEBUG]     scan: samplerate 44100, bps 32
[DEBUG]     scan: AAC
[DEBUG]     scan: Picked up 0 tags from file metadata
[DEBUG]     scan: Picked up 0 tags with generic md_map, 0 tags total
[DEBUG]   ffmpeg: Statistics: 19437 bytes read, 0 seeks
[ WARN]     scan: ffmpeg/libav could not extract any metadata
[DEBUG]       db: Running query 'INSERT INTO files (id, path, fname, title, artist, album, genre, comment, type, composer, orchestra, conductor, grouping, url, bitrate, samplerate, song_length, file_size, year, track, total_tracks, disc, total_discs, bpm, compilation, artwork, rating, play_count, seek, data_kind, item_kind, description, time_added, time_modified, time_played, db_timestamp, disabled, sample_count, codectype, idx, has_video, contentrating, bits_per_sample, album_artist, media_kind, tv_series_name, tv_episode_num_str, tv_network_name, tv_episode_sort, tv_season_num,  songartistid, songalbumid,  title_sort, artist_sort, album_sort, composer_sort, album_artist_sort, virtual_path, directory_id, date_released)  VALUES (NULL, 'http://prem4.di.fm:80/hardstyle?heregoeskey', 'hardstyle?heregoeskey', TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Unknown album'), TRIM('Hardstyle Hard Bass Nu-Hardstyle'), TRIM(NULL), 'm4a', TRIM(NULL), TRIM(NULL), TRIM(NULL), TRIM(NULL), NULL, 128, 44100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 1, 2, 'AAC audio file', 1502000712, 1502000652, 0, 1502000712, 0, 0, 'mp4a', 0, 0, 0, 32, TRIM('Hardstyle - Digitally Imported Premium'), 1, TRIM(NULL), TRIM(NULL), TRIM(NULL), 0, 0, daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), ''), daap_songalbumid(LOWER(TRIM('Hardstyle - Digitally Imported Premium')), LOWER(TRIM('Unknown album'))),  TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('Unknown album'), TRIM(NULL), TRIM('Hardstyle - Digitally Imported Premium'), TRIM('/http:/Hardstyle - Digitally Imported Premium'), 3, 0);'
[DEBUG]       db: Running query 'INSERT INTO playlistitems (playlistid, filepath) VALUES (9, 'http://prem4.di.fm:80/hardstyle?heregoeskey');'
[ INFO]     scan: Done processing playlist
pztrn commented 7 years ago

Confirming on Rhythmbox on Debian 9 - same behaviour.

ejurgensen commented 7 years ago

Yes, forked-daapd is not able to stream radio stations to iTunes, and that is why it is not shown in the playlist. The documentation could be more clear on that, I admit.

I will consider adding this ability, but the reason it has not been a priority because I would think for most people it is easier to just add the radio station directly to iTunes?

pztrn commented 7 years ago

Yes and no - I will be happy to listen radio in iTunes and, if neccessary, switch to, for example, HTPC on Linux (which also accesses audio via DAAP).

And, moreover, maybe it's iTunes "feature" - only first item from radio playlist will be used, others are ignored :(

I'm already using forked-daap for music streaming and hoping I'll be also able to stream radio with it :)

ejurgensen commented 7 years ago

You can of course have forked-daapd stream radio with Remote or an mpd client (so not daap), but perhaps you already knew that.

If you could elaborate a bit on the setup you are going for then please do.

pztrn commented 7 years ago

Yes, already know that.

My setup is: listen to radio with iTunes from DAAP playlist (as well as other players that supports DAAP). Is that forked-daap limitation, or iTunes (and other players) will not allow that in any case? They're (iTunes and Rhythmbox for example) showing empty playlist for radio URLs.

ejurgensen commented 7 years ago

The empty playlist is a result of this. Since you built yourself, you can modify it and just let the function return, in which case the playlists should no longer be empty.

However, I don't think playback of the stream in iTunes will work. With daap, forked-daapd serves the file to the client, and since this is not a file it will likely fail (not sure exactly how...).

EDIT Here is the correct link: https://github.com/ejurgensen/forked-daapd/blob/master/src/httpd_daap.c#L531

thekevinbrown commented 6 years ago

I'll elaborate on my setup and why this would be incredibly useful for me.

I've got 5 airplay speakers set up throughout the house. Historically I've been using iTunes to listen to DI.fm and broadcast the single stream to all the speakers in the house. I was hoping to do the same with forked-daapd as I'm now on Linux instead of Windows for the main audio server machine.

I'd love to be able to fully replace iTunes with forked-daapd if possible.

ejurgensen commented 6 years ago

@thekevinbrown this issue is about radio stations not being served to iTunes (so OP would still be using iTunes). I think what you are looking for should already be supported.

I will rename the issue to make it more clear what it is about.

thekevinbrown commented 6 years ago

@ejurgensen I'll lodge a different issue in that case.