【发布时间】:2017-06-16 20:35:28
【问题描述】:
我想在 android 中为 icecast 服务器开发一个源客户端。我在网上搜索了很多,但我没有找到任何正确的解决方案和任何方法。
如果有人对此有所了解,请在此处回复,我也不明白如何将该元数据发送到 icecast 服务器。
我查看了以下链接:
- Icecast 2: protocol description, streaming to it using C#,
- Broadcast to Icecast / SHOUTcast with Objective-C, C, or C++,
- Developing the client for the icecast server,
@布拉德 感谢您的回复, 我看到了很多问题,你回答的问题越多。 只等你的回复 谢谢 1)我在本地机器上安装了icecast服务器 2)从我的android程序我连接到icecast服务器(tcp连接) 3)代码如下
s = new Socket("10.0.2.2",8000);
Log.d("VS", "Socket Created");
OutputStream out = s.getOutputStream();
Log.d("VS", "Output Stream Established");
output = new PrintWriter(out);
Log.d("VS", "Send Header");
output.println("SOURCE /stream ICE/1.0");
output.println("content-type: audio/mpeg");
output.println("Authorization: Basic c291cmNlOmhhY2ttZQ==");
output.println("ice-name: This is my server name");
output.println("ice-url: http://www.google.com");
output.println("ice-genre: Rock");
output.println("ice-bitrate: 128");
output.println("ice-private: 0");
output.println("ice-public: 1");
output.println("ice-description: This is my server description");
output.println("ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2");
output.println("");
output.flush();
Log.d("VS", "Header sent");
reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
for (String line; (line = reader.readLine()) != null;)
{
if (line.isEmpty()) break;
Log.d("VS", "Responce From Server");
Log.d("VS",line);
}
Log.d("VS", "Sending Password");
output.println("pass:hackme");
output.println("");
output.flush();
for (String aline; (aline = reader.readLine()) != null;)
{
if (aline.isEmpty()) break;
Log.d("VS", "Responce From Server");
Log.d("VS",aline);
}
在 logcat 中: 套接字创建, 输出流建立, 发送标题, 标头已发送, 来自服务器的响应, HTTP/1.0 200 好的, 发送密码, 在“发送密码”消息后没有服务器响应。
在此链接http://droidtools.sourceforge.net/content/icecast-client-android 中显示 libshout、libvorbis for android,这些(库)是在 android 中制作源客户端所必需的吗?
我是 android 开发的新手。如果代码或其他方式有任何问题,请告诉我。 谢谢
【问题讨论】:
-
正如我在您链接到的帖子中提到的,stackoverflow.com/a/9985297/362536,元数据是通过一个简单的 HTTP 请求更新的。你能详细说明你不明白的地方吗?
-
与icecast服务器连接后。您如何将数据发送到 icecast 服务器。请分享您的研究
-
@Williams 要将声音流发送到服务器,您必须将音频编码为 mp3 或 ogg。在我的项目中,代码已完全更改,连接后我将声音编码为 ogg 格式,然后发送编码的实时流到服务器。实际上我使用 NDK 对声音进行编码,据我所知,没有选项可以在 android 中对声音进行编码。
标签: android audio-streaming radio icecast