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.
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#
But I am not able to send SOURCE /mountpoint ICE/1.0
because its without key.
I am sending it like -
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]);
}
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>
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.
I was sending request using
GET
method which was a wrong way. I used -[requestURL setHTTPMethod:@"SOURCE /mountpoint ICE/1.0"];
.I am able to create mount at icecast server.
I also added mp3 file data to play the file like
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.