Icecast 2:协议描述,使用 C# 流式传输
我需要编写一个 Icecast 2 客户端,它能够将计算机中的音频(mp3 文件、声卡录音等)传输到服务器。我决定用C#写一个这样的客户端。
两个问题:
1)了解我可能/应该/必须使用的通用准则(最佳实践,也许是技巧)将非常有用,以便在 C# 中无缝处理流式音频(当然是通过网络流式传输)。一些有关通过 TCP/IP 进行流传输的通用技术文档,特别是 ICY,以及有关应用程序整体架构的建议和注释,我们将非常感激。
2) 有关于 Icecast 2 流协议的好的文档吗?我在 Icecast 的官方网站上找不到这些文档。我不想直接从它的源代码中提取协议描述。如果该协议确实简单明了,有人可以在这里提供它的摘要吗?
I need to write an Icecast 2 client that will be able to stream audio from the computer (mp3-files, soundcard recording and so forth) to the server. I decided to write such a client on C#.
Two questions:
1) It will be very useful to know common guidelines (best practices, maybe tricks) I may/should/must use to seamlessly work with streamed audio (streamed over network, of course) in C#. Some general technical documentation about streaming over TCP/IP in common and ICY in particular, advices and notes on the overall architecture of the application will be very appreciated.
2) Is there any good documentation regarding the Icecast 2 streaming protocol? I couldn't find those docs on the official site of Icecast. I don't want to extract the protocol description directly from the source code of it. If the protocol is really simple and neat, could anybody provide a summary of it right here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
据我所知,除了 Icecast 源代码之外,没有任何协议规范。以下是我从数据包嗅探中发现的内容:
音频流
该协议类似于 HTTP。源客户端将连接到服务器,使用挂载点发出请求,并传递一些包含流信息的标头:
如果一切正常,服务器将响应:
源客户端然后继续发送二进制流数据。请注意,似乎有些编码器在开始发送流数据之前甚至不等待服务器响应
200 OK
。只是标题、空行,然后是流数据。元数据
元数据使用带外 HTTP 请求发送。源客户端发送:
服务器响应:
另请注意,音频流和元数据请求都在同一端口上发送。与 SHOUTcast 不同,这是服务器运行的基本端口。
As far as I know, there is no protocol spec anywhere, outside of the Icecast source code. Here's what I've found from packet sniffing:
Audio Stream
The protocol is similar to HTTP. The source client will connect to the server make a request with the mountpoint, and pass some headers with information about the stream:
If all is good, the server responds with:
The source client then proceeds to send the binary stream data. Note that it seems some encoders don't even wait for the server to respond with
200 OK
before they start sending stream data. Just headers, an empty line, and then stream data.Meta Data
Meta data is sent using an out-of-band HTTP request. The source client sends:
The server responds with:
Also note that both the audio stream and meta data requests are sent on the same port. Unlike SHOUTcast, this is the base port that the server is running on.
尽管这个问题已经很老了,但我还是要在这里发表评论。
Icecast 符合 HTTP 标准。侦听器端始终如此(简单明了的 HTTP1.0,RFC 1945),从 2.4.0 开始,对于源客户端也是如此。
要实现源客户端,它是符合 HTTP 1.1 又名 RFC2616 的 PUT 请求。一些选项可以通过 HTTP headers 设置,详细信息请参阅当前的 Icecast 文档。
如果您发送受支持的容器格式之一:Ogg 或 WebM(技术上是 EBML),那么您只需要了解这些即可。明确地说,这至少涵盖 Opus、Vorbis、Theora 和 VP8 编解码器。
请注意,虽然通常工作正常,但技术上不支持其他格式。在这种情况下,Icecast 仅传递流而不进行任何处理。
如果您需要帮助或有其他问题,那么官方邮件列表和 IRC 频道是正确的选择。
I'm going to comment here despite this question being quite old.
Icecast is HTTP compliant. This was always the case for the listener side (plain and simple HTTP1.0, RFC 1945), starting with 2.4.0 it's also true for the source client side.
To implement a source client it's a PUT request in compliance with HTTP 1.1 aka RFC2616. Some options can be set through HTTP headers, for details please refer to the current Icecast documentation.
If you send one of the supported container formats: Ogg or WebM (technically EBML), then this is all you need to know. To make it clear this covers at leastOpus, Vorbis, Theora and VP8 codecs.
Please note that while generally working fine, other formats are technically not supported. Icecast only passes through the stream without any processing in such a case.
If you need help or have further questions, then the official mailing lists and the IRC channel are the right place to go.
很久以前看过 Icecast2:我能找到的最佳参考是 http://forums .radiotoolbox.com/viewtopic.php?t=74 链接(我应该打印出来,我花了很长时间才找出正确的 Google 咒语来再次显示它)。它似乎涵盖了源到服务器和服务器到客户端。
关于它的准确度仍然存在疑问:在其他事情消耗我之前,我已经完成了 Android 实现的大约一半,并且我不太记得我的实现与 VLC/Winamp 之间的通信出了什么问题,但老实说它是我能找到的最接近规格的东西。
Looked at Icecast2 a good long while ago: best reference I could find was at http://forums.radiotoolbox.com/viewtopic.php?t=74 link (I should print that out, took me forever to figure out the proper Google spell to cast to surface that again). It appears to cover source to server and server to client.
Questions remain about just how accurate it is: I got about halfway through an Android implementation before other things consumed me, and I can't quite remember what was wrong with the communication between my implementation of that and VLC/Winamp, but honestly it was the closest thing I could find to a spec.
我知道的最好的描述在这里: https://gist.github.com/ePirat/adc3b8ba00d85b7e3870
@ePirat 是 xpiph/icecast 核心提交者。
The best description I know is here: https://gist.github.com/ePirat/adc3b8ba00d85b7e3870
@ePirat is xpiph/icecast core committer.