IceCast与iPhone Header问题 [英] IceCast with iPhone Header issue
问题描述
我正在尝试使用我的iPhone应用程序使用Icecast服务器。我正在为我的icecast服务器创建一个源客户端。目前我使用NSURL级别发送请求以创建服务器的挂载点。但是我认为这还不够。我必须使用任何其他核心库,如CFNetworks或BSD套接字。但我不确定。任何人都可以帮我解决哪个库适合实现iPhone的icecast。
I am trying to use Icecast server with my iPhone app. I am creating a source client for my icecast server. Currently I am using NSURL level for sending request to create a mount point to the server. But as I felt that its not sufficient. I have to use any other core library like CFNetworks or BSD Sockets. But I am not sure. Can any one please help me out that which library is suitable to implement icecast for iPhone.
第二件事就是当我为Icecast实现一个头创建mountpoint请求时。我使用以下链接 -
Icecast 2:协议描述,使用C#进行流式传输
The second thing is that when I am implementing a header for Icecast request to create mountpoint. I using following link - Icecast 2: protocol description, streaming to it using C#
但是我无法发送 SOURCE / mountpoint ICE / 1.0
因为它没有钥匙。
But I am not able to send SOURCE /mountpoint ICE/1.0
because its without key.
我发送它就像 -
NSMutableString *requestString = [NSMutableString stringWithFormat:@"http://192.168.1.99:8000"];
NSLog(@"Request String = %@", requestString);
NSURL *url = [NSURL URLWithString:requestString];
NSMutableURLRequest *requestURL = [NSMutableURLRequest requestWithURL:url];
[requestURL setHTTPMethod:@"GET"];
[requestURL addValue:@"SOURCE /mp3test ICE/1.0" forHTTPHeaderField:@"SOURCE"];
[requestURL addValue:@"audio/mpeg" forHTTPHeaderField: @"Content-Type"];
[requestURL setValue:@"Basic c291cmNlOmhhY2ttZQ==" forHTTPHeaderField:@"Authorization"];
[requestURL setValue:@"This is my server name" forHTTPHeaderField:@"ice-name"];
[requestURL setValue:path forHTTPHeaderField:@"ice-url"];
[requestURL setValue:@"Rock" forHTTPHeaderField:@"ice-genre"];
[requestURL setValue:@"128" forHTTPHeaderField:@"ice-bitrate"];
[requestURL setValue:@"0" forHTTPHeaderField:@"ice-private"];
[requestURL setValue:@"1" forHTTPHeaderField:@"ice-public"];
[requestURL setValue:@"This is my server description" forHTTPHeaderField:@"ice-description"];
[requestURL setValue:@"ice-samplerate=44100;ice-bitrate=128;ice-channels=2" forHTTPHeaderField:@"ice-audio-info"];
NSLog(@"Request URL Value = %@",requestURL);
NSURLResponse *response;
NSError *error;
NSData *responseData = [NSURLConnection sendSynchronousRequest:requestURL returningResponse:&response error:&error];
if(error != nil){
NSLog(@"%@",[error description]);
}
我的回复是和HTML代码 -
My Response is and HTML code -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Icecast Streaming Media Server</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<h2>Icecast2 Status</h2>
<br><div class="roundcont">
<div class="roundtop"><img src="/corner_topleft.jpg" class="corner" style="display: none"></div>
<table border="0" width="100%" id="table1" cellspacing="0" cellpadding="4"><tr><td bgcolor="#656565">
<a class="nav" href="admin/">Administration</a><a class="nav" href="status.xsl">Server Status</a><a class="nav" href="server_version.xsl">Version</a>
</td></tr></table>
<div class="roundbottom"><img src="/corner_bottomleft.jpg" class="corner" style="display: none"></div>
</div>
<br><br>
<div class="poster">Support icecast development at <a class="nav" target="_blank" href="http://www.icecast.org">www.icecast.org</a>
</div>
</body>
</html>
这是一个糟糕的回应。任何人都可以指导我如何发送一个干净整洁的请求并得到回应。我也没有得到如何在创建挂载点后将mp3数据发送到服务器。如何创建一个流并将其发送给icecast。
Its a bad response. Can any one please guide me that how can I send a neat and clean request and get response. I also did not get that how to send mp3 data to server after creating a mountpoint. How to create a stream and send it to icecast.
任何帮助都将受到赞赏。
Any help will be appreciated.
推荐答案
我使用 GET
方法发送请求,这是一种错误的方法。
我使用过 -
I was sending request using GET
method which was a wrong way.
I used -
[requestURL setHTTPMethod:@SOURCE / mountpoint ICE / 1.0];
。
我能够在icecast服务器上创建mount。
I am able to create mount at icecast server.
我还添加了mp3文件数据来播放文件如
I also added mp3 file data to play the file like
//get data from the file url so we can start recording with some file
NSData *audioData = [NSData dataWithContentsOfURL:fileURL];
//add audio to stream and add the stream to request for sending data
NSInputStream *inputStream = [NSInputStream inputStreamWithData:audioData];
[request setHTTPBodyStream:inputStream];
它能够播放歌曲数据。但目前我不知道为什么它只播放一大块数据。我正在研究添加数据块以进行流式传输。
Its able to play the song data. But currently I don't know why its play only a single chunk of data. I am researching to add chunks of data to stream.
这篇关于IceCast与iPhone Header问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!