MrBuddyCasino / ESP32_MP3_Decoder

A internet radio and bluetooth speaker project for the Espressif ESP32
776 stars 182 forks source link

another mp3 stream #15

Closed zajaklis closed 6 years ago

zajaklis commented 7 years ago

i was trying to play http://lr1mp1.latvijasradio.lv:8012 but it seems it requires "Icy-MetaData:1" header in GET. Stream plays ok in vlc and another players. Codec: MPEG Audio layer 1/2 (mpga) Sample rate: 44100 Hz Bitrate: 128 kb/s content type is not returned as audio/mpeg type so there must be another way to catch stream

MrBuddyCasino commented 7 years ago

I don't think mp2 is supported. Headers are currently mandatory, maybe we could add a default to assume mp3, or parse the first few bytes? Pull requests welcome.

MrBuddyCasino commented 7 years ago

Well whaddaya know, someone made a pull request to add MP2 support. I just merged it.

spockbear commented 7 years ago

playlist.c:19:17: fatal error: ini.h: No such file or directory What is the problem ???

zajaklis commented 7 years ago

spockbear, have you read readme? git submodule init && git submodule update

MrBuddyCasino commented 7 years ago

@zajaklis does the new version solve your issue?

zajaklis commented 7 years ago

patch for mpeg 1 and 2 did not resolved issue as my provided radio link seems to be mp3 format: just checked:

http://lr1mp1.latvijasradio.lv:8012 or http://lr1mp1.latvijasradio.lv:8012/listen.pls (does not work) Audio: MP3 44100Hz stereo 96kbps [A: mp3, 44100 Hz, stereo, 96 kb/s]

http://skonto.ls.lv:8002/mp3 (plays ok) Audio: MP3 44100Hz stereo 128kbps [A: mp3, 44100 Hz, stereo, 128 kb/s]

format for both seems to be same as reported by Media Player Classic more info for captured audio from http://lr1mp1.latvijasradio.lv:8012:

ICY 200 OK
icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
icy-notice2:SHOUTcast Distributed Network Audio Server/win32 v1.9.8<BR>
icy-name:Radio 1
icy-genre:classical
icy-url:http://lr1.latvijasradio.lv
content-type:audio/mpeg
icy-pub:0
icy-br:128
MrBuddyCasino commented 7 years ago

Ok I thought it might because you said codec was MPEG Audio layer 1/2 (mpga). I'll investigate.

zajaklis commented 7 years ago

well, MPEG Audio layer 1/2 (mpga) was reported by VLC for both of my mentioned streams (even for the one which works ok) so i tried another player just to make sure its reports mp3 stream.

MrBuddyCasino commented 7 years ago

Sorry, can't find the reason why it doesn't work. This is cURL:

curl -v --http1.0 http://lr1mp1.latvijasradio.lv:8012/
*   Trying 159.148.56.131...
* TCP_NODELAY set
* Connected to lr1mp1.latvijasradio.lv (159.148.56.131) port 8012 (#0)
> GET / HTTP/1.0
> Host: lr1mp1.latvijasradio.lv:8012
> User-Agent: curl/7.51.0
> Accept: */*
>
ICY 200 OK
icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
icy-notice2:SHOUTcast Distributed Network Audio Server/win32 v1.9.8<BR>
icy-name:Radio 1
icy-genre:classical
icy-url:http://lr1.latvijasradio.lv
content-type:audio/mpeg
icy-pub:0
icy-br:128

This is the ESP:

I (3873) http_client: requesting GET / HTTP/1.0
Host: lr1mp1.latvijasradio.lv:8012
User-Agent: curl/7.51.0
Accept: */*

cURL works, ESP doesn't. No idea why. You can try and contact the server operator to have a look at requests with user-agents of "ESP32" and see whats going on in the logs.

zajaklis commented 7 years ago

got it working, http_parser.c expects HTTP/1.0 200 OK in http response header but some web stream services sends ICY 200 OK so idea was to add ICY response support to http parser:

, s_res_I , s_res_IC to line 286

i have included modified http_parser.c, please take necessary lines from it(useless debug lines present) MrBuddyCasino, code is not so beautiful, as i just did a quick dirty test code. http_parser.zip

someone could test it out on icecast radio streams.

MrBuddyCasino commented 7 years ago

ICY 200 OK. Dear lord, why. Thanks.

shaurya0406 commented 6 years ago

I am having the same problem: playlist.c:19:17: fatal error: ini.h: No such file or directory I have tried git submodule init && git submodule update but to no avail. please help thanks in avance Regards

MrBuddyCasino commented 6 years ago

@shaurya0406 what does your issue have do to with zajaklis?

shaurya0406 commented 6 years ago

same issue as spockbear

any help??

MrBuddyCasino commented 6 years ago

Does this work?

git clone https://github.com/MrBuddyCasino/ESP32_MP3_Decoder.git
cd ESP32_MP3_Decoder/
git submodule init && git submodule update
make -j4 flash
shaurya0406 commented 6 years ago

YES it worked!!! THANK YOU VERY MUCH Regards