Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP source client

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Tue Mar 25, 2008 7:47 pm    Post subject: PHP source client Reply with quote

Hello!

Is it possible to create a icecast client built only in PHP with sockets?
I have an icecast server and I want to programatically add a new mount point for a very user who wants to create a favourite playlist.
I wonder if there's a documentation on how to talk to the icecast server through its listening port.

Thank you.
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Mar 25, 2008 7:58 pm    Post subject: Reply with quote

There are no language restrictions imposed, just use the libshout api to talk to icecast, if you don't want to use the slightly modified HTTP mechansim.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Tue Mar 25, 2008 8:20 pm    Post subject: Reply with quote

i want to develop this php client on windows so i need the win32 libshout extension for php. unfortunately i didn't find a version for windows so i figure that what libshout does can be done using the icy protocol.
it surprises me that there is no description of this protocol whatsoever.
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Mar 25, 2008 8:30 pm    Post subject: Reply with quote

icy was never documented but there are decent references out there. The basic mechanism for talking to icecast is http but using SOURCE as the method.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Tue Mar 25, 2008 8:46 pm    Post subject: Reply with quote

do you mean http request method = SOURCE?
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Mar 25, 2008 10:38 pm    Post subject: Reply with quote

yes, eg SOURCE /stream.ogg HTTP/1.0

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Fri Mar 28, 2008 10:02 pm    Post subject: Reply with quote

hi!

i see from your posts that you are involved with icecast or closer to it. is it possible for you to send me or post here more information about the icy protocol? i believe it's not some war secret or something.

thank you.
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sat Mar 29, 2008 1:59 am    Post subject: Reply with quote

for what there is on icy, look at the docs on
http://forums.radiotoolbox.com/viewforum.php?f=8

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Sat Mar 29, 2008 10:54 pm    Post subject: Reply with quote

hi again,

i've read those docs before but this the code i manage to write as far as i figure it out:

Code:
<?php
   $headers = array(
      "Authorization: Basic c291cmNlOmNoYW5nZW1l",
      "User-Agent: libshout/2.2.2",
      "Content-Type: audio/mpeg",
      "ice-name: My Stream",
      "ice-public: 0",
      "ice-url: http://www.mydomain.com",
      "ice-genre: rock",
      "ice-audio-info: bitrate=128;channels=2;samplerate=44100",
      "ice-description: This is a stream description"
   );

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8000");
   curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_TIMEOUT, 60);
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "SOURCE /live");
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

   $data = curl_exec($ch);
   curl_close($ch);
?>


So i understand this the part that should mount a new folder /live to the icecast server. After i send those headers i really don't know what i should do: just fopen the mp3 file and output it as it is or... that just blows my mind out.
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Mar 30, 2008 1:54 am    Post subject: Reply with quote

I haven't tried that combination but I suspect you want the URL to refer to /live and CUSTOMREQUEST to be "SOURCE". Also make sure you are using CURLOPT_HTTPHEADER correctly.

When properly executed you should find that /live is a mountpoint on the icecast server. There are no files or directories created. After the headers (for which authorization and content-type are important) you have the actual content or mp3 data in your case.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Sun Mar 30, 2008 2:50 pm    Post subject: Reply with quote

hello karl,

thank you for your support until now. i finally manage to get /live mountpoint to work. here is the code:

Code:

$headers = array(
"Authorization: Basic c291cmNlOmNoYW5nZW1l",
"User-Agent: libshout/2.2.2",
"Content-Type: audio/mpeg",
"ice-name: my name",
"ice-public: 1",
"ice-url: http://www.mydomain.com",
"ice-genre: rock",
"ice-audio-info: bitrate=128;channels=2;samplerate=44100",
"ice-description: This is a stream description"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:8000/live");
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "SOURCE");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_exec($ch);
curl_close($ch);


i don't know by now how to actually send data through this mountpoint. i tried:

Code:

curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize('some.mp3');
curl_setopt($ch, CURLOPT_INFILE, fopen('some.mp3, 'rb'));


but this code plays in winamp only the last notes of the song, probably because it uploads itself too fast to the server. i noticed that if i leave the CURLOPT_UPLOAD = 1 and remove CURLOPT_INFILESIZE and CURLOPT_INFILE, the script keeps sending to the icecast server and this seems to receive something, i don't know what, as you may see in the log file below.

Code:

[2008-03-30  17:23:41] DBUG stats/stats.c new node total_bytes_read (0)
[2008-03-30  17:23:41] DBUG stats/stats.c new node total_bytes_sent (0)
[2008-03-30  17:23:45] DBUG stats/stats.c update node total_bytes_read (306708)
[2008-03-30  17:23:45] DBUG stats/stats.c update node total_bytes_sent (0)
[2008-03-30  17:23:50] DBUG stats/stats.c update node total_bytes_read (814524)
[2008-03-30  17:23:50] DBUG stats/stats.c update node total_bytes_sent (0)
[2008-03-30  17:23:55] DBUG stats/stats.c update node total_bytes_read (1315992)
[2008-03-30  17:23:55] DBUG stats/stats.c update node total_bytes_sent (0)
[2008-03-30  17:24:00] DBUG stats/stats.c update node total_bytes_read (1818696)
[2008-03-30  17:24:00] DBUG stats/stats.c update node total_bytes_sent (0)
[2008-03-30  17:24:05] DBUG stats/stats.c update node total_bytes_read (2326800)
[2008-03-30  17:24:05] DBUG stats/stats.c update node total_bytes_sent (0)
[2008-03-30  17:24:10] DBUG stats/stats.c update node total_bytes_read (2827992)


i don't really know how to inject something into this empty stream. i even tried to output the mp3 with:

Code:

curl_exec($ch);
echo file_get_contents('some.mp3', FILE_BINARY);
curl_close($ch);


but i get no sound.

besides, i'd prefer to mount /live to a playlist.m3u or playlist.pls rather than a mp3 because that will play continously and that is what i want.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber