Roxen.git / server / modules / icecast / icecast.pike

version» Context lines:

Roxen.git/server/modules/icecast/icecast.pike:1:   inherit "module"; - constant cvs_version="$Id: icecast.pike,v 1.2 2001/04/10 05:13:58 per Exp $"; + constant cvs_version="$Id: icecast.pike,v 1.3 2001/04/10 05:23:42 per Exp $";   constant thread_safe=1;      #define BSIZE 8192   #define METAINTERVAL 4192      #include <module.h>   #include <roxen.h>   #include <stat.h>   #include <request_trace.h>   
Roxen.git/server/modules/icecast/icecast.pike:272:    mapping meta = stream->playlist->metadata();    if( !meta )    {    denied++;    return Roxen.http_string_answer( "Too early\n" );    }       connections++;    int use_metadata;    string i, metahd=""; -  string protocol = "ShoutCast"; +  string protocol = "ICY";       werror("%O\n", id->request_headers );    if( id->request_headers[ "icy-metadata" ] )    {   // use_metadata = (int)id->request_headers[ "icy-metadata" ];   // if( use_metadata )   // metahd = "icy-metaint:"+METAINTERVAL+"\r\n";    }       if( id->request_headers[ "x-audiocast-udpport" ] )    {    protocol = "AudioCast"; -  // shoutcast.. +     i = ("HTTP/1.0 200 OK\r\n"    "Server: "+roxen.version()+"\r\n"    "Content-type: audio/mpeg\r\n"    "x-audiocast-name:"+(meta->name||meta->path)+"\r\n"    "x-audiocast-gengre:"+(meta->gengre||"unknown")+"\r\n"    "x-audiocast-url:"+("http://"+id->misc->host+    query_location()+location)+"\r\n"+    "x-audiocast-streamid:1\r\n"+metahd+    "x-audiocast-public:1\r\n"    "x-audiocast-bitrate:"+(stream->bitrate/1000)+"\r\n"    "x-audiocast-description:Served by Roxen\r\n"    "\r\n" );    }    else    { -  // icecast.. +     i = ("ICY 200 OK\r\n"    "Server: "+roxen.version()+"\r\n"    "Content-type: audio/mpeg\r\n"    "icy-notice1:This stream requires a shoutcast compatible player.\r\n"    "icy-notice2:Roxen mod_mp3\r\n"+metahd+    "icy-name:"+(meta->name||meta->path)+"\r\n"    "icy-gengre:"+(meta->gengre||"unknown")+"\r\n"    "icy-url:"+("http://"+id->misc->host+    query_location()+location)+"\r\n"+    "icy-pub:1\r\n"
Roxen.git/server/modules/icecast/icecast.pike:426:    }       static void callback( string frame )    {    buffer += ({ frame });    if( sizeof( buffer ) > 10 )    {    skipped++;    buffer = buffer[1..];    } +  if( !sizeof( buffer ) )    send_more();    }       int headers_done;       static void send_more()    {    if( !strlen(current_block) )    {    headers_done = 1;    if( !sizeof(buffer) )    { - // werror("out of buffer\n"); +     return;    }    current_block = buffer[0];       if( do_meta )    {    if( (strlen( current_block ) + sent_bytes) - last_meta >= METAINTERVAL )    {    last_meta = (strlen( current_block ) + sent_bytes);    current_block += gen_metadata();    }    }       buffer = buffer[1..];    sent++;    } - // werror("writing ... "); +     int n = fd->write( current_block ); - // werror(" %d bytes\n", n, current_block ); +     if( !n || n < 0 )    closed();    if( headers_done )    sent_bytes += n;    current_block = current_block[n..];    }       static void md_callback( mapping metadata )    {    current_md = metadata;