Changeset 375abfbdd16fa92a9a23f94a87d1b6ce0ca48c25

Show
Ignore:
Timestamp:
26/08/05 19:01:48 (3 years ago)
Author:
Derk-Jan Hartman <hartman@videolan.org>
git-committer:
Derk-Jan Hartman <hartman@videolan.org> 1125075708 +0000
git-parent:

[7c896d67cfe224d0d0fa21b52d02e167be0f9607]

git-author:
Derk-Jan Hartman <hartman@videolan.org> 1125075708 +0000
Message:

* added --sout-shout-name to set a stream name
* added --sout-shout-description to set a channel description
* added --sout-shout-mp3 to allow you to upload mp3 streams instead of ogg. (BEWARE, no autodetection)
* fixed the free of a string
* some general coding style cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access_output/shout.c

    r88e95e3 r375abfb  
    11/***************************************************************************** 
    2  * shout.c 
     2 * shout.c: This module forwards vorbis streams to an icecast server 
    33 ***************************************************************************** 
    44 * Copyright (C) 2005 VideoLAN 
     
    2626 * 
    2727 * o this only works for ogg streams, and there's no checking about that yet. 
    28  * o i have lots of problems with audio, but i think they are not caused 
    29  *   by this patch 
    3028 * o there's a memleak somewhere, quite huge. i'm unsure if its somewhere 
    3129 *   in libshout, in vlc or even in this patch... 
     
    5654 
    5755#define SOUT_CFG_PREFIX "sout-shout-" 
     56 
     57#define NAME_TEXT N_("Stream-name") 
     58#define NAME_LONGTEXT N_("The name this stream/channel will get on the icecast server." ) 
     59 
     60#define DESCRIPTION_TEXT N_("Stream-description") 
     61#define DESCRIPTION_LONGTEXT N_("A description of the stream content. (Information about " \ 
     62                         "your channel)." ) 
     63 
     64#define MP3_TEXT N_("Stream MP3") 
     65#define MP3_LONGTEXT N_("Normally you have to feed the shoutcast module with Ogg streams. " \ 
     66                         "This option allows you to feed MP3 streams instead, so you can " \ 
     67                         "forward MP3 streams to the icecast server." ) 
    5868 
    5969vlc_module_begin(); 
     
    6474    set_subcategory( SUBCAT_SOUT_ACO ); 
    6575    add_shortcut( "shout" ); 
     76    add_string( SOUT_CFG_PREFIX "name", "VLC media player - Live stream", NULL, 
     77                NAME_TEXT, NAME_LONGTEXT, VLC_FALSE ); 
     78    add_string( SOUT_CFG_PREFIX "description", "Live stream from VLC media player. " \ 
     79                "http://www.videolan.org/vlc", NULL, 
     80                DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, VLC_FALSE ); 
     81    add_bool(   SOUT_CFG_PREFIX "mp3", VLC_FALSE, NULL, 
     82                MP3_TEXT, MP3_LONGTEXT, VLC_TRUE ); 
    6683    set_callbacks( Open, Close ); 
    6784vlc_module_end(); 
     85 
     86/***************************************************************************** 
     87 * Exported prototypes 
     88 *****************************************************************************/ 
     89static const char *ppsz_sout_options[] = { 
     90    "name", "description", "mp3", NULL 
     91}; 
    6892 
    6993 
     
    89113    shout_t *p_shout; 
    90114    long i_ret; 
    91  
    92     char *psz_user, *psz_pass, *psz_host, *psz_mount; 
    93115    unsigned int i_port; 
    94  
    95     char *parser = strdup( p_access->psz_name ); 
    96     char *tmp_port; 
     116    vlc_value_t val; 
     117 
     118    char *psz_accessname = NULL; 
     119    char *psz_parser = NULL; 
     120    char *psz_user = NULL; 
     121    char *psz_pass = NULL; 
     122    char *psz_host = NULL; 
     123    char *psz_mount = NULL; 
     124    char *psz_name = NULL; 
     125    char *psz_description = NULL; 
     126    char *tmp_port = NULL; 
     127   
     128    sout_CfgParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg ); 
     129 
     130    psz_accessname = psz_parser = strdup( p_access->psz_name ); 
    97131 
    98132    if( !p_access->psz_name ) 
     
    104138 
    105139    /* Parse connection data user:pwd@host:port/mountpoint */ 
    106     psz_user = parser; 
    107     while( parser[0] && parser[0] != ':' ) parser++; 
    108     if( parser[0] ) { parser[0] = 0; parser++; } 
    109     psz_pass = parser; 
    110     while( parser[0] && parser[0] != '@' ) parser++; 
    111     if( parser[0] ) { parser[0] = 0; parser++; } 
    112     psz_host = parser; 
    113     while( parser[0] && parser[0] != ':' ) parser++; 
    114     if( parser[0] ) { parser[0] = 0; parser++; } 
    115     tmp_port = parser; 
    116     while( parser[0] && parser[0] != '/' ) parser++; 
    117     if( parser[0] ) { parser[0] = 0; parser++; } 
    118     psz_mount = parser; 
     140    psz_user = psz_parser; 
     141    while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++; 
     142    if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; } 
     143    psz_pass = psz_parser; 
     144    while( psz_parser[0] && psz_parser[0] != '@' ) psz_parser++; 
     145    if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; } 
     146    psz_host = psz_parser; 
     147    while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++; 
     148    if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; } 
     149    tmp_port = psz_parser; 
     150    while( psz_parser[0] && psz_parser[0] != '/' ) psz_parser++; 
     151    if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; } 
     152    psz_mount = psz_parser; 
    119153 
    120154    i_port = atoi( tmp_port ); 
     
    124158    { 
    125159        msg_Err( p_access, "out of memory" ); 
    126         free( parser ); 
     160        free( psz_accessname ); 
    127161        return VLC_ENOMEM; 
    128162    } 
     163 
     164    var_Get( p_access, SOUT_CFG_PREFIX "name", &val ); 
     165    if( *val.psz_string ) 
     166        psz_name = val.psz_string; 
     167    else 
     168        free( val.psz_string ); 
     169 
     170    var_Get( p_access, SOUT_CFG_PREFIX "description", &val ); 
     171    if( *val.psz_string ) 
     172        psz_description = val.psz_string; 
     173    else 
     174        free( val.psz_string ); 
    129175 
    130176    p_shout = p_sys->p_shout = shout_new(); 
     
    137183         || shout_set_mount( p_shout, psz_mount ) != SHOUTERR_SUCCESS 
    138184         || shout_set_user( p_shout, psz_user ) != SHOUTERR_SUCCESS 
    139          || shout_set_format( p_shout, SHOUT_FORMAT_OGG ) != SHOUTERR_SUCCESS 
    140   //       || shout_set_nonblocking( p_shout, 1 ) != SHOUTERR_SUCCESS 
     185         || shout_set_agent( p_shout, "VLC media player " VERSION ) != SHOUTERR_SUCCESS 
     186         || shout_set_name( p_shout, psz_name ) != SHOUTERR_SUCCESS 
     187         || shout_set_description( p_shout, psz_description ) != SHOUTERR_SUCCESS  
     188//       || shout_set_nonblocking( p_shout, 1 ) != SHOUTERR_SUCCESS 
    141189      ) 
    142190    { 
    143         msg_Err( p_access, "failed to initialize shout streaming to %s:%i%s", 
     191        msg_Err( p_access, "failed to initialize shout streaming to %s:%i/%s", 
    144192                 psz_host, i_port, psz_mount ); 
    145193        free( p_access->p_sys ); 
    146         free( parser ); 
     194        free( psz_accessname ); 
     195        return VLC_EGENERIC; 
     196    } 
     197 
     198    if( psz_name ) free( psz_name ); 
     199    if( psz_description ) free( psz_description ); 
     200 
     201    var_Get( p_access, SOUT_CFG_PREFIX "mp3", &val ); 
     202    if( val.b_bool == VLC_TRUE ) 
     203        i_ret = shout_set_format( p_shout, SHOUT_FORMAT_MP3 ); 
     204    else 
     205        i_ret = shout_set_format( p_shout, SHOUT_FORMAT_OGG ); 
     206 
     207    if( i_ret != SHOUTERR_SUCCESS ) 
     208    { 
     209        msg_Err( p_access, "failed to set the shoutcast streaming format" ); 
     210        free( p_access->p_sys ); 
     211        free( psz_accessname ); 
    147212        return VLC_EGENERIC; 
    148213    } 
     
    164229    if( i_ret != SHOUTERR_CONNECTED ) 
    165230    { 
    166         msg_Err( p_access, "failed to open shout stream to %s:%i%s: %s", 
     231        msg_Err( p_access, "failed to open shout stream to %s:%i/%s: %s", 
    167232                 psz_host, i_port, psz_mount, shout_get_error(p_shout) ); 
    168233        free( p_access->p_sys ); 
    169         free( parser ); 
     234        free( psz_accessname ); 
    170235        return VLC_EGENERIC; 
    171236    } 
     
    175240    p_access->pf_seek  = Seek; 
    176241 
    177     msg_Dbg( p_access, "shout access output opened (%s@%s:%i%s)", 
     242    msg_Dbg( p_access, "shout access output opened (%s@%s:%i/%s)", 
    178243             psz_user, psz_host, i_port, psz_mount ); 
    179244 
     
    184249    } 
    185250 
    186     /* FIXME: it should be free()d somewhere, but not here.... ? */ 
    187     //free( parser ); 
     251    free( psz_accessname ); 
    188252 
    189253    return VLC_SUCCESS;