开发Icecast服务器的客户端 [英] Developing the client for the icecast server

查看:122
本文介绍了开发Icecast服务器的客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Icecast服务器(www.icecast.org)开发客户端.谁能告诉我,他们用于流式传输内容的格式是什么?

I am developing the client for the icecast server (www.icecast.org). Can anybody tell me, what is the format they are using for streaming the content?

我正在看他们的页面,但是根本没有有关流格式的信息.

I was looking on their pages, but there is no information about the stream format at all.

然后,我检查了Wireshark跟踪,由于我了解我在GET请求的200 OK响应中接收到的音频数据的格式,因此它只是一个纯二进制音频数据,不包含任何元数据,因此与 SHOUTcast HTTP实时流(HLS),这是相对简单的方法.

I have then checked the Wireshark trace and due to my understanding the format of the audio data I am receiving within the 200 OK response to the GET request it is just a plain binary audio data without any metadata included, so comparing to the SHOUTcast or HTTP Live Streaming (HLS) it is relative simple approach.

是吗?有经验吗?

Wireshark跟踪代码段:

Wireshark trace snippet:

GET /bonton-128.mp3 HTTP/1.1
Host: icecast3.play.cz
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive


HTTP/1.0 200 OK
Content-Type: audio/mpeg
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:Radio Bonton
icy-genre:Pop / Rock
icy-name:Radio Bonton
icy-pub:0
icy-url:http://www.radiobonton.cz
Server: Icecast 2.3.2
Cache-Control: no-cache

Here are then aac or MPEG data

感谢和问候,

STn

推荐答案

对您而言,Icecast和SHOUTcast是等效的.

For your purposes, Icecast and SHOUTcast are equivalent.

它们都使用HTTP的混混版本.实际上,您可以发出一个简单的HTTP请求并使用标准的HTTP客户端库,并且几乎总是可以正常工作.唯一不同的是SHOUTcast将在响应中返回ICY 200 OK而不是HTTP 200 OK.

They both use a bastardized version of HTTP. In fact, you can make a simple HTTP request and use standard HTTP client libraries, and it will almost always work just fine. The only thing different is that SHOUTcast will return ICY 200 OK instead of HTTP 200 OK in its response.

现在,如上所述,如果您发出请求,您将获得一个可以直接播放的标准音频流.正如您所指出的那样,MP3和AAC几乎全部使用,但是可以使用其他格式.

Now if you make the request, as you have done above, you get a standard audio stream that you can play directly. As you have pointed out, MP3 and AAC are used almost exclusively, but other formats can be used.

如果需要元数据,则必须告诉服务器已准备好接收元数据.您必须在请求中添加此标头:

If you want metadata, you have to tell the server you are prepared to receive it. You have to put this header in your request:

Icy-MetaData:1

执行完此操作后,您将在响应中看到另一个标头,例如icy-metaint:8192,这意味着每8192个字节,您将收到一个元数据块.

Once you do that, you will see another header come back to you in the response, such as icy-metaint:8192, which means that every 8192 bytes, you will receive a chunk of metadata.

我将不做进一步的详细说明,因为已经有充分的记录了.无需重新输入方向盘:

I won't go into further details because this is already well documented. No need to re-type the wheel:

从音频流中提取轨道信息使用PHP

http://www.smackfu.com/stuff/programming/shoutcast.html

但是,如果您确实有任何疑问,请将其发布在StackOverflow上并将其标记为icecast或shoutcast,我们将很乐意为您提供帮助.

However, if you do have questions as you go, please post them on StackOverflow and tag them as icecast or shoutcast, and I will be happy to assist you.

这篇关于开发Icecast服务器的客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆