使用 Objective-C、C 或 C++ 广播到 Icecast/SHOUTcast [英] Broadcast to Icecast / SHOUTcast with Objective-C, C, or C++

查看:20
本文介绍了使用 Objective-C、C 或 C++ 广播到 Icecast/SHOUTcast的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将音频数据提供给 SHOUTcast 或 Icecast 服务器,而不使用他们自己的广播公司,因为我将在包括移动在内的各种平台上使用它.

I want to provide audio data into SHOUTcast or Icecast servers without using their own broadcaster, since i will be using this on various platforms including mobile.

我需要协议描述、开源项目或示例,以便能够使用 Objective-C、C 或 C++ 将音频数据(来自麦克风或文件)发送到 SHOUTcast 和 Icecast 服务器.

I need protocol descriptions, open source projects, or samples to be able to send audio data (from mic or file) using Objective-C, C or C++ to SHOUTcast and Icecast servers.

在哪里可以找到构建合适的 SHOUTcast/Icecast 源客户端所需的信息?

Where can I find the information needed to build a proper SHOUTcast/Icecast source client?

推荐答案

评论:是时候为移动设备制作 SHOUTcast 源客户端了.我已经需要这个一段时间了,但没有时间构建它,所以向你致敬.请在某个时候制作一个 Android 版本.

您应该做的第一件事是下载 Wireshark.

The first thing you should do is download Wireshark.

开始数据包捕获,启动一个 SHOUTcast 服务器,然后启动一个源客户端,并将其连接到服务器.为这个协议的可怕的简单性做好准备.

Start the packet capture, fire up a SHOUTcast server, then fire up a source client, and connect it to the server. Be prepared for the horrifying simplicity of this protocol.

  1. 源客户端通过 TCP 连接到 SHOUTcast.使用从基本端口向上的端口.例如,如果您的基本端口是 8000,那么您的侦听器连接到 8000,而您将连接到 8001.
  2. 一旦连接,SHOUTcast 服务器就不会说什么.只需发送广播密码,后跟一个新的CrLf(或 ).
  3. 如果密码错误,它会说invalid password 或类似的东西.如果它是正确的,你会得到这样的东西:

  1. Source client connects to SHOUTcast with TCP. Use the port one up from the base port. For instance, if your base port is 8000, your listeners connect on 8000 and you will connect on 8001.
  2. Once connected, the SHOUTcast server won't say anything. Just send the broadcast password, followed by a new CrLf (or ).
  3. If the password is wrong, it will say invalid password or something like that. If it is correct, you're going to get something like this:

OK2

icy-caps:11

注意每一行后面都有CrLf,这两个header发送后,还有一对CrLf.

Note that each line has CrLf after it, and after these two headers are sent, there are a pair of CrLf.

现在,由源客户端发送一堆标头:icy-nameicy-genreicy-pubicy-bricy-urlicy-ircicy-icqicy-aim, content-type.像这样发送它们:

Now, it is up to the source client to send a bunch of headers: icy-name, icy-genre, icy-pub, icy-br, icy-url, icy-irc, icy-icq, icy-aim, content-type. Send them like this:

icy-name:My Awesome Station

每一行后面应该跟CrLf,在你发送完所有的header后,发送一对CrLf.

Each line should be followed by CrLf, and after you're done sending all of the headers, send a pair of CrLf.

完成这一切后,开始发送您的流数据!无需从任何特定位置开始,只需发送数据即可.由接收端的客户端来同步到帧.SHOUTcast 服务器对流经它的流量完全是哑巴".如果需要,您可以连接 Telnet 客户端并发送一堆文本.

Once this is all done, start sending your stream data! No need to start in any particular spot, just send data. It is up to the clients on the receiving end to sync to the frame. The SHOUTcast server is completely "dumb" to the traffic flowing through it. You can connect with a Telnet client and send a bunch of text if you wanted to.

更新元数据

因此,您可能想知道如何发送下一曲目的信息,而不是发送信息.有趣的是,这完全超出了您发送音频数据的连接的带外.

Updating Metadata

So, you're probably wondering how you send information for the next track and what not. The funny thing is, this is completely out-of-band from the connection where you send audio data.

您所要做的就是向端口库(在我们的示例中为 8000)发出 Web 请求:

All you have to do is make a web request to the port base (8000 in our example):

http://yourserver:8000/admin.cgi?pass=yourpassword&mode=updinfo&song=your%20song&url=some_url_goes_here_but_hardly_any_clients_use_it

如果难以阅读,这些是参数:

In case that is difficult to read, these are the parameters:

  • 通过
  • 模式
  • 歌曲
  • 网址

您会注意到,这些相同的参数和其他参数都可以在 SHOUTcast 管理面板中找到.

You'll note that these same parameters, and others, can all be found in the SHOUTcast admin panel.

这篇关于使用 Objective-C、C 或 C++ 广播到 Icecast/SHOUTcast的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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