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

version» Context lines:

Roxen.git/server/modules/icecast/icecast.pike:1:   // This is a roxen module. Copyright © 2001 - 2004, Roxen IS.      inherit "module"; - constant cvs_version="$Id: icecast.pike,v 1.11 2008/06/24 11:04:35 jonasw Exp $"; + constant cvs_version="$Id: icecast.pike,v 1.12 2008/08/15 12:33:54 mast 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:61:    void call_callbacks( mixed ... args )    {    foreach( callbacks, function f )    if( mixed e = catch( f(@args) ) )    {    werror(describe_backtrace( e ) );    remove_callback( f );    }    }    -  static int last_hrtime, base_time; +  protected int last_hrtime, base_time;       int realtime()    {    if(!last_hrtime)    {    last_hrtime = gethrtime();    base_time = 0;    }    else    {
Roxen.git/server/modules/icecast/icecast.pike:119:    }    call_out( feeder_thread, 0.02 );    }       void start()    {    feeder_thread( ); // not actually a thread right now.    }       // Low level code. -  static string buffer; -  static int bpos; +  protected string buffer; +  protected int bpos;    -  static string|int getbytes( int n, int|void s ) +  protected string|int getbytes( int n, int|void s )    {    if( !fd )    fd = playlist->next_file();    if( !fd )    return s?0:-1;       if( !buffer || !strlen(buffer) )    {    bpos = 0;    buffer = fd->read( BSIZE );
Roxen.git/server/modules/icecast/icecast.pike:172:    {    bpos = 0;    buffer = fd->read( BSIZE );    if( !buffer || !strlen( buffer ) )    return -1;    }    }    return res;    }    -  static int rate_of(int r) +  protected int rate_of(int r)    {    switch(r)    {    case 0: return 44100;    case 1: return 48000;    case 2: return 32000;    default:return 44100;    }    }    -  static array(array(int)) bitrates = +  protected array(array(int)) bitrates =    ({    ({0,32,64,96,128,160,192,224,256,288,320,352,384,416,448}),    ({0,32,48,56,64,80,96,112,128,160,192,224,256,320,384}),    ({0,32,40,48,56,64,80,96,112,128,160,192,224,256,320}),    });    -  static string get_frame() +  protected string get_frame()    {    string data;    /* Find header */    int trate = 0;    int patt = 0;    int by, p=0, sw=0;    while( (by = getbytes( 1 )) > 0 )    {    patt <<= 8;    patt |= by;
Roxen.git/server/modules/icecast/icecast.pike:456:    current_md->name || current_md->path,    current_md->url || location->url );    }    while( strlen(s) & 15 )    s+= "\0";    s[ 0 ]=strlen(s)/16;    werror("%O\n", s );    return s;    }    -  static void callback( string frame ) +  protected void callback( string frame )    {    buffer += ({ frame });    if( sizeof( buffer ) > 100 )    {    skipped++;    buffer = buffer[1..];    }    if( sizeof( buffer ) == 1 )    {    remove_call_out( send_more );    call_out( send_more, 0.01 );    }    }       int headers_done;    -  static void send_more() +  protected void send_more()    {    if( !strlen(current_block) )    {    headers_done = 1;    if( !sizeof(buffer) )    return;    current_block = buffer[0];       if( do_meta )    {
Roxen.git/server/modules/icecast/icecast.pike:508:    if( n > 0 )    {    if( headers_done )    sent_bytes += n;    current_block = current_block[n..];    }    else if( n < 0 )    closed();    }    -  static void md_callback( mapping metadata ) +  protected void md_callback( mapping metadata )    {    current_md = metadata;    }    -  static void closed( ) +  protected void closed( )    {    fd->set_blocking( );    fd = 0;    stream->remove_callback( callback );    stream->playlist->remove_md_callback( md_callback );    _ccb( this_object() );    werror("Closed from client side\n");   // destruct( this_object() );    }    -  static void create( Stdio.File _fd, string buffer, +  protected void create( Stdio.File _fd, string buffer,    string prot, int _meta, MPEGStream _stream,    Location _loc, function _closed )    {    location = _loc;    protocol = prot;    fd = _fd;    do_meta = _meta;    stream = _stream;    _ccb = _closed;    current_block = buffer;