Changeset 116d261645f35f4acd87b595935d4f3a2b44895f

Show
Ignore:
Timestamp:
24/04/04 05:38:10 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1082777890 +0000
git-parent:

[3c0c2a2a6f73ef0c806a1713e9b04dd5f2361656]

git-author:
Laurent Aimar <fenrir@videolan.org> 1082777890 +0000
Message:
  • all: use sout_ParseCfg. But "standard" can't use it for sap/slp

options (because we can't do the difference between missing option,
option and option="" when option is a string).


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/stream_out/display.c

    r8547ffa r116d261  
    3838static void Close( vlc_object_t * ); 
    3939 
     40#define SOUT_CFG_PREFIX "sout-display-" 
     41 
    4042vlc_module_begin(); 
    4143    set_description( _("Display stream output") ); 
    4244    set_capability( "sout stream", 50 ); 
    4345    add_shortcut( "display" ); 
     46    add_bool( SOUT_CFG_PREFIX "audio", 1, NULL, "audio", "", VLC_TRUE ); 
     47    add_bool( SOUT_CFG_PREFIX "video", 1, NULL, "video", "", VLC_TRUE ); 
     48    add_integer( SOUT_CFG_PREFIX "delay", 100, NULL, "delay", "", VLC_TRUE ); 
    4449    set_callbacks( Open, Close ); 
    4550vlc_module_end(); 
     
    4954 * Exported prototypes 
    5055 *****************************************************************************/ 
     56static const char *ppsz_sout_options[] = { 
     57    "audio", "video", "delay", NULL 
     58}; 
     59 
    5160static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
    5261static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
     
    7079    sout_stream_t     *p_stream = (sout_stream_t*)p_this; 
    7180    sout_stream_sys_t *p_sys; 
    72     char              *val; 
     81    vlc_value_t val; 
     82 
     83    sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); 
     84 
    7385    p_sys           = malloc( sizeof( sout_stream_sys_t ) ); 
    7486    p_sys->p_input  = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_ANYWHERE ); 
     
    8092    } 
    8193 
    82     p_sys->b_audio = VLC_TRUE; 
    83     p_sys->b_video = VLC_TRUE; 
    84     p_sys->i_delay = 100*1000; 
    85     if( sout_cfg_find( p_stream->p_cfg, "noaudio" ) ) 
    86     { 
    87         p_sys->b_audio = VLC_FALSE; 
    88     } 
    89     if( sout_cfg_find( p_stream->p_cfg, "novideo" ) ) 
    90     { 
    91         p_sys->b_video = VLC_FALSE; 
    92     } 
    93     if( ( val = sout_cfg_find_value( p_stream->p_cfg, "delay" ) ) ) 
    94     { 
    95         p_sys->i_delay = (mtime_t)atoi( val ) * (mtime_t)1000; 
    96     } 
     94    var_Get( p_stream, SOUT_CFG_PREFIX "audio", &val ); 
     95    p_sys->b_audio = val.b_bool; 
     96 
     97    var_Get( p_stream, SOUT_CFG_PREFIX "video", &val ); 
     98    p_sys->b_video = val.b_bool; 
     99 
     100    var_Get( p_stream, SOUT_CFG_PREFIX "delay", &val ); 
     101    p_sys->i_delay = (int64_t)val.i_int * 1000; 
    97102 
    98103    p_stream->pf_add    = Add; 
  • modules/stream_out/es.c

    r8547ffa r116d261  
    3232#include <vlc/sout.h> 
    3333 
    34 #define FREE( p ) if( p ) { free( p ); (p) = NULL; } 
    35 /***************************************************************************** 
    36  * Exported prototypes 
     34/***************************************************************************** 
     35 * Module descriptor 
    3736 *****************************************************************************/ 
    3837static int      Open    ( vlc_object_t * ); 
    3938static void     Close   ( vlc_object_t * ); 
    4039 
    41 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
    42 static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
    43 static int               Send( sout_stream_t *, sout_stream_id_t *, block_t* ); 
    44  
    45 /***************************************************************************** 
    46  * Module descriptor 
    47  *****************************************************************************/ 
     40#define SOUT_CFG_PREFIX "sout-es-" 
     41 
    4842vlc_module_begin(); 
    4943    set_description( _("Elementary stream output") ); 
    5044    set_capability( "sout stream", 50 ); 
    5145    add_shortcut( "es" ); 
     46 
     47    add_string( SOUT_CFG_PREFIX "access", "", NULL, "access", "", VLC_TRUE ); 
     48    add_string( SOUT_CFG_PREFIX "access-audio", "", NULL, "access audio", "", VLC_TRUE ); 
     49    add_string( SOUT_CFG_PREFIX "access-video", "", NULL, "access video", "", VLC_TRUE ); 
     50 
     51    add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE ); 
     52    add_string( SOUT_CFG_PREFIX "mux-audio", "", NULL, "mux audio", "", VLC_TRUE ); 
     53    add_string( SOUT_CFG_PREFIX "mux-video", "", NULL, "mux video", "", VLC_TRUE ); 
     54 
     55    add_string( SOUT_CFG_PREFIX "dst", "", NULL, "dst", "", VLC_TRUE ); 
     56    add_string( SOUT_CFG_PREFIX "dst-audio", "", NULL, "dst audio", "", VLC_TRUE ); 
     57    add_string( SOUT_CFG_PREFIX "dst-video", "", NULL, "dst video", "", VLC_TRUE ); 
     58 
    5259    set_callbacks( Open, Close ); 
    5360vlc_module_end(); 
     61 
     62 
     63#define FREE( p ) if( p ) { free( p ); (p) = NULL; } 
     64/***************************************************************************** 
     65 * Exported prototypes 
     66 *****************************************************************************/ 
     67static const char *ppsz_sout_options[] = { 
     68    "access", "access-audio", "access-video", 
     69    "mux", "mux-audio", "mux-video", 
     70    "dst", "dst-audio", "dst-video", 
     71    NULL 
     72}; 
     73 
     74static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
     75static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
     76static int               Send( sout_stream_t *, sout_stream_id_t *, block_t* ); 
    5477 
    5578struct sout_stream_sys_t 
     
    6790    char *psz_access_video; 
    6891 
    69     char *psz_url
    70     char *psz_url_audio; 
    71     char *psz_url_video; 
     92    char *psz_dst
     93    char *psz_dst_audio; 
     94    char *psz_dst_video; 
    7295}; 
    7396 
     
    79102    sout_stream_t       *p_stream = (sout_stream_t*)p_this; 
    80103    sout_stream_sys_t   *p_sys; 
    81  
    82     /* p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader ); */ 
    83  
     104    vlc_value_t         val; 
     105 
     106    sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); 
    84107    p_sys                   = malloc( sizeof( sout_stream_sys_t ) ); 
    85108 
     
    88111    p_sys->i_count_video    = 0; 
    89112 
    90     p_sys->psz_access       = sout_cfg_find_value( p_stream->p_cfg, "access" ); 
    91     p_sys->psz_access_audio = sout_cfg_find_value( p_stream->p_cfg, "access_audio" ); 
    92     p_sys->psz_access_video = sout_cfg_find_value( p_stream->p_cfg, "access_video" ); 
    93  
    94     p_sys->psz_mux       = sout_cfg_find_value( p_stream->p_cfg, "mux" ); 
    95     p_sys->psz_mux_audio = sout_cfg_find_value( p_stream->p_cfg, "mux_audio" ); 
    96     p_sys->psz_mux_video = sout_cfg_find_value( p_stream->p_cfg, "mux_video" ); 
    97  
    98     p_sys->psz_url       = sout_cfg_find_value( p_stream->p_cfg, "url" ); 
    99     p_sys->psz_url_audio = sout_cfg_find_value( p_stream->p_cfg, "url_audio" ); 
    100     p_sys->psz_url_video = sout_cfg_find_value( p_stream->p_cfg, "url_video" ); 
     113    var_Get( p_stream, SOUT_CFG_PREFIX "access", &val ); 
     114    p_sys->psz_access       = val.psz_string; 
     115    var_Get( p_stream, SOUT_CFG_PREFIX "access-audio", &val ); 
     116    p_sys->psz_access_audio = val.psz_string; 
     117    var_Get( p_stream, SOUT_CFG_PREFIX "access-video", &val ); 
     118    p_sys->psz_access_video = val.psz_string; 
     119 
     120    var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val ); 
     121    p_sys->psz_mux       = val.psz_string; 
     122    var_Get( p_stream, SOUT_CFG_PREFIX "mux-audio", &val ); 
     123    p_sys->psz_mux_audio = val.psz_string; 
     124    var_Get( p_stream, SOUT_CFG_PREFIX "mux-video", &val ); 
     125    p_sys->psz_mux_video = val.psz_string; 
     126 
     127    var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val ); 
     128    p_sys->psz_dst       = val.psz_string; 
     129    var_Get( p_stream, SOUT_CFG_PREFIX "dst-audio", &val ); 
     130    p_sys->psz_dst_audio = val.psz_string; 
     131    var_Get( p_stream, SOUT_CFG_PREFIX "dst-video", &val ); 
     132    p_sys->psz_dst_video = val.psz_string; 
    101133 
    102134    p_stream->pf_add    = Add; 
     
    118150    sout_stream_sys_t *p_sys = p_stream->p_sys; 
    119151 
     152    free( p_sys->psz_access ); 
     153    free( p_sys->psz_access_audio ); 
     154    free( p_sys->psz_access_video ); 
     155 
     156    free( p_sys->psz_mux ); 
     157    free( p_sys->psz_mux_audio ); 
     158    free( p_sys->psz_mux_video ); 
     159 
     160    free( p_sys->psz_dst ); 
     161    free( p_sys->psz_dst_audio ); 
     162    free( p_sys->psz_dst_video ); 
     163 
    120164    free( p_sys ); 
    121165} 
     
    130174                            char *psz_access, char *psz_mux ) 
    131175{ 
    132     char *psz_url, *p; 
     176    char *psz_dst, *p; 
    133177 
    134178    if( psz_fmt == NULL || !*psz_fmt ) 
     
    137181    } 
    138182 
    139     p = psz_url = malloc( 4096 ); 
     183    p = psz_dst = malloc( 4096 ); 
    140184    memset( p, 0, 4096 ); 
    141185    for( ;; ) 
     
    183227    } 
    184228 
    185     return( psz_url ); 
     229    return( psz_dst ); 
    186230} 
    187231 
     
    194238    char              *psz_access; 
    195239    char              *psz_mux; 
    196     char              *psz_url
     240    char              *psz_dst
    197241 
    198242    sout_access_out_t *p_access; 
     
    200244 
    201245    /* *** get access name *** */ 
    202     if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_access_audio
     246    if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_access_audio && *p_sys->psz_access_audio
    203247    { 
    204248        psz_access = p_sys->psz_access_audio; 
    205249    } 
    206     else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_access_video
     250    else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_access_video && *p_sys->psz_access_video
    207251    { 
    208252        psz_access = p_sys->psz_access_video; 
     
    214258 
    215259    /* *** get mux name *** */ 
    216     if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_mux_audio
     260    if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_mux_audio && *p_sys->psz_mux_audio
    217261    { 
    218262        psz_mux = p_sys->psz_mux_audio; 
    219263    } 
    220     else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_mux_video
     264    else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_mux_video && *p_sys->psz_mux_video
    221265    { 
    222266        psz_mux = p_sys->psz_mux_video; 
     
    228272 
    229273    /* Get url (%d expanded as a codec count, %c expanded as codec fcc ) */ 
    230     if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_url_audio ) 
    231     { 
    232         psz_url = es_print_url( p_sys->psz_url_audio, p_fmt->i_codec, 
     274    if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_dst_audio && *p_sys->psz_dst_audio ) 
     275    { 
     276        psz_dst = es_print_url( p_sys->psz_dst_audio, p_fmt->i_codec, 
    233277                                p_sys->i_count_audio, psz_access, psz_mux ); 
    234278    } 
    235     else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_url_video ) 
    236     { 
    237         psz_url = es_print_url( p_sys->psz_url_video, p_fmt->i_codec, 
     279    else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_dst_video && *p_sys->psz_dst_video ) 
     280    { 
     281        psz_dst = es_print_url( p_sys->psz_dst_video, p_fmt->i_codec, 
    238282                                p_sys->i_count_video, psz_access, psz_mux ); 
    239283    } 
     
    254298        } 
    255299 
    256         psz_url = es_print_url( p_sys->psz_url, p_fmt->i_codec, 
     300        psz_dst = es_print_url( p_sys->psz_dst, p_fmt->i_codec, 
    257301                                i_count, psz_access, psz_mux ); 
    258302    } 
     
    268312    } 
    269313    msg_Dbg( p_stream, "creating `%s/%s://%s'", 
    270              psz_access, psz_mux, psz_url ); 
     314             psz_access, psz_mux, psz_dst ); 
    271315 
    272316    /* *** find and open appropriate access module *** */ 
    273     p_access = sout_AccessOutNew( p_sout, psz_access, psz_url ); 
     317    p_access = sout_AccessOutNew( p_sout, psz_access, psz_dst ); 
    274318    if( p_access == NULL ) 
    275319    { 
    276320        msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'", 
    277                  psz_access, psz_mux, psz_url ); 
     321                 psz_access, psz_mux, psz_dst ); 
    278322        return( NULL ); 
    279323    } 
     
    284328    { 
    285329        msg_Err( p_stream, "no suitable sout mux module for `%s/%s://%s'", 
    286                  psz_access, psz_mux, psz_url ); 
     330                 psz_access, psz_mux, psz_dst ); 
    287331        sout_AccessOutDelete( p_access ); 
    288332        return( NULL ); 
  • modules/stream_out/rtp.c

    rfab59c0 r116d261  
    4040static void Close( vlc_object_t * ); 
    4141 
     42#define SOUT_CFG_PREFIX "sout-rtp-" 
     43 
    4244vlc_module_begin(); 
    4345    set_description( _("RTP stream output") ); 
    4446    set_capability( "sout stream", 0 ); 
    4547    add_shortcut( "rtp" ); 
     48    add_string( SOUT_CFG_PREFIX "dst", "", NULL, "destination", "", VLC_TRUE ); 
     49    add_string( SOUT_CFG_PREFIX "name", "", NULL, "name", "", VLC_TRUE ); 
     50    add_string( SOUT_CFG_PREFIX "sdp", "", NULL, "sdp", "", VLC_TRUE ); 
     51    add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE ); 
     52 
     53    add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, "port", "", VLC_TRUE ); 
     54    add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL, "port", "", VLC_TRUE ); 
     55 
    4656    set_callbacks( Open, Close ); 
    4757vlc_module_end(); 
     
    5060 * Exported prototypes 
    5161 *****************************************************************************/ 
     62static const char *ppsz_sout_options[] = { 
     63    "dst", "name", "port", "sdp", "ttl", "mux", NULL 
     64}; 
     65 
    5266static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
    5367static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
     
    183197    sout_instance_t     *p_sout = p_stream->p_sout; 
    184198    sout_stream_sys_t   *p_sys; 
    185  
    186     char *val; 
     199    vlc_value_t         val; 
     200 
     201    sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); 
    187202 
    188203    p_sys = malloc( sizeof( sout_stream_sys_t ) ); 
    189     p_sys->psz_destination = sout_cfg_find_value( p_stream->p_cfg, "dst" ); 
    190     p_sys->psz_session_name = sout_cfg_find_value( p_stream->p_cfg, "name" ); 
    191     if( ( val = sout_cfg_find_value( p_stream->p_cfg, "port" ) ) ) 
    192     { 
    193         p_sys->i_port = atoi( val ); 
    194     } 
    195     else 
    196     { 
    197         p_sys->i_port = 1234
    198     } 
     204 
     205    var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val ); 
     206    p_sys->psz_destination = *val.psz_string ? val.psz_string : NULL; 
     207 
     208    var_Get( p_stream, SOUT_CFG_PREFIX "name", &val ); 
     209    p_sys->psz_session_name = *val.psz_string ? val.psz_string : NULL; 
     210 
     211    var_Get( p_stream, SOUT_CFG_PREFIX "port", &val ); 
     212    p_sys->i_port = val.i_int
     213 
    199214 
    200215    if( !p_sys->psz_session_name ) 
    201216    { 
    202217        if( p_sys->psz_destination ) 
    203         { 
    204218            p_sys->psz_session_name = strdup( p_sys->psz_destination ); 
    205         } 
    206219        else 
    207         { 
    208220           p_sys->psz_session_name = strdup( "NONE" ); 
    209         } 
    210221    } 
    211222 
    212223    if( !p_sys->psz_destination || *p_sys->psz_destination == '\0' ) 
    213224    { 
    214         val = sout_cfg_find_value( p_stream->p_cfg, "sdp" ); 
    215         if( val == NULL || strncasecmp( val, "rtsp", 4 ) ) 
     225        var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val ); 
     226 
     227        if( strncasecmp( val.psz_string, "rtsp", 4 ) ) 
    216228        { 
    217229            msg_Err( p_stream, "missing destination and not in rtsp mode" ); 
     
    220232        } 
    221233        p_sys->psz_destination = NULL; 
     234        free( val.psz_string ); 
    222235    } 
    223236    else if( p_sys->i_port <= 0 ) 
     
    228241    } 
    229242 
    230     if( ( val = sout_cfg_find_value( p_stream->p_cfg, "ttl" ) ) ) 
    231     { 
    232         p_sys->i_ttl = atoi( val ); 
    233     } 
    234     else 
    235     { 
    236         p_sys->i_ttl = config_GetInt( p_stream, "ttl" ); 
    237     } 
     243    var_Get( p_stream, SOUT_CFG_PREFIX "ttl", &val ); 
     244    p_sys->i_ttl = val.i_int; 
    238245 
    239246    p_sys->i_payload_type = 96; 
     
    267274    p_stream->p_sys     = p_sys; 
    268275 
    269     if( ( val = sout_cfg_find_value( p_stream->p_cfg, "mux" ) ) ) 
     276    var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val ); 
     277    if( *val.psz_string ) 
    270278    { 
    271279        sout_access_out_t *p_grab; 
     
    276284 
    277285        /* Check muxer type */ 
    278         if( !strncasecmp( val, "ps", 2 ) || !strncasecmp( val, "mpeg1", 5 ) ) 
     286        if( !strncasecmp( val.psz_string, "ps", 2 ) || !strncasecmp( val.psz_string, "mpeg1", 5 ) ) 
    279287        { 
    280288            psz_rtpmap = "MP2P/90000"; 
    281289        } 
    282         else if( !strncasecmp( val, "ts", 2 ) ) 
     290        else if( !strncasecmp( val.psz_string, "ts", 2 ) ) 
    283291        { 
    284292            psz_rtpmap = "MP2T/90000"; 
     
    328336 
    329337        /* the muxer */ 
    330         if( !( p_sys->p_mux = sout_MuxNew( p_sout, val, p_sys->p_grab ) ) ) 
    331         { 
    332             msg_Err( p_stream, "cannot create the muxer (%s)", val ); 
     338        if( !( p_sys->p_mux = sout_MuxNew( p_sout, val.psz_string, p_sys->p_grab ) ) ) 
     339        { 
     340            msg_Err( p_stream, "cannot create the muxer (%s)", val.psz_string ); 
    333341            sout_AccessOutDelete( p_sys->p_grab ); 
    334342            sout_AccessOutDelete( p_sys->p_access ); 
     
    370378        p_sys->p_grab   = NULL; 
    371379    } 
    372  
    373     if( ( val = sout_cfg_find_value( p_stream->p_cfg, "sdp" ) ) ) 
     380    free( val.psz_string ); 
     381 
     382 
     383    var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val ); 
     384    if( *val.psz_string ) 
    374385    { 
    375386        vlc_url_t url; 
    376387 
    377         vlc_UrlParse( &url, val, 0 ); 
     388        vlc_UrlParse( &url, val.psz_string, 0 ); 
    378389        if( url.psz_protocol && !strcasecmp( url.psz_protocol, "http" ) ) 
    379390        { 
     
    403414        vlc_UrlClean( &url ); 
    404415    } 
     416    free( val.psz_string ); 
    405417 
    406418    /* update p_sout->i_out_pace_nocontrol */ 
  • modules/stream_out/standard.c

    rfab59c0 r116d261  
    3535#include "network.h" 
    3636 
    37 #define DEFAULT_IPV6_SCOPE '8' 
    38 #define DEFAULT_PORT 1234 
    39  
    40 /***************************************************************************** 
    41  * Exported prototypes 
     37/***************************************************************************** 
     38 * Module descriptor 
    4239 *****************************************************************************/ 
    4340static int      Open    ( vlc_object_t * ); 
    4441static void     Close   ( vlc_object_t * ); 
    4542 
    46 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
    47 static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
    48 static int               Send( sout_stream_t *, sout_stream_id_t *, block_t* ); 
    49  
    50 /***************************************************************************** 
    51  * Module descriptor 
    52  *****************************************************************************/ 
     43#define SOUT_CFG_PREFIX "sout-standard-" 
     44 
    5345vlc_module_begin(); 
    5446    set_description( _("Standard stream output") ); 
     
    5648    add_shortcut( "standard" ); 
    5749    add_shortcut( "std" ); 
     50 
     51    add_string( SOUT_CFG_PREFIX "access", "", NULL, "access", "", VLC_TRUE ); 
     52    add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE ); 
     53    add_string( SOUT_CFG_PREFIX "url", "", NULL, "url", "", VLC_TRUE ); 
     54 
    5855    set_callbacks( Open, Close ); 
    5956vlc_module_end(); 
     57 
     58 
     59/***************************************************************************** 
     60 * Exported prototypes 
     61 *****************************************************************************/ 
     62static const char *ppsz_sout_options[] = { 
     63    "access", "mux", "url", NULL 
     64}; 
     65 
     66#define DEFAULT_IPV6_SCOPE '8' 
     67#define DEFAULT_PORT 1234 
     68 
     69static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); 
     70static int               Del ( sout_stream_t *, sout_stream_id_t * ); 
     71static int               Send( sout_stream_t *, sout_stream_id_t *, block_t* ); 
    6072 
    6173struct sout_stream_sys_t 
     
    7486    sout_instance_t     *p_sout = p_stream->p_sout; 
    7587    slp_session_t       *p_slp = NULL; 
    76     session_descriptor_t *p_session = NULL; 
    77  
    78     char *psz_mux      = sout_cfg_find_value( p_stream->p_cfg, "mux" ); 
    79     char *psz_access   = sout_cfg_find_value( p_stream->p_cfg, "access" ); 
    80     char *psz_url      = sout_cfg_find_value( p_stream->p_cfg, "url" ); 
    81     char *psz_sdp      = NULL; 
    82  
    83     vlc_url_t      *p_url; 
     88 
     89    char *psz_mux; 
     90    char *psz_access; 
     91    char *psz_url; 
     92 
    8493    sout_cfg_t *p_sap_cfg = sout_cfg_find( p_stream->p_cfg, "sap" ); 
    8594#ifdef HAVE_SLP_H 
     
    8796#endif 
    8897 
     98    vlc_value_t val; 
     99 
    89100    sout_access_out_t   *p_access; 
    90101    sout_mux_t          *p_mux; 
    91102 
    92103    char                *psz_mux_byext = NULL; 
     104 
     105    sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); 
     106 
     107    var_Get( p_stream, SOUT_CFG_PREFIX "access", &val ); 
     108    psz_access = *val.psz_string ? val.psz_string : NULL; 
     109 
     110    var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val ); 
     111    psz_mux = *val.psz_string ? val.psz_string : NULL; 
     112 
     113    var_Get( p_stream, SOUT_CFG_PREFIX "url", &val ); 
     114    psz_url = *val.psz_string ? val.psz_string : NULL; 
    93115 
    94116    p_stream->p_sys        = malloc( sizeof( sout_stream_sys_t) ); 
     
    138160    /* We fix access/mux to valid couple */ 
    139161 
    140     if( ( psz_access == NULL || *psz_access == '\0' )&& 
    141         ( psz_mux == NULL ||  *psz_mux == '\0' ) ) 
     162    if( psz_access == NULL && psz_mux == NULL ) 
    142163    { 
    143164        if( psz_mux_byext ) 
     
    156177    } 
    157178 
    158     if( psz_access && *psz_access && 
    159         ( psz_mux == NULL || *psz_mux == '\0' ) ) 
     179    if( psz_access && psz_mux == NULL ) 
    160180    { 
    161181        /* access given, no mux */ 
     
    173193        } 
    174194    } 
    175     else if( psz_mux && *psz_mux && 
    176              ( psz_access == NULL || *psz_access == '\0' ) ) 
     195    else if( psz_mux && psz_access == NULL ) 
    177196    { 
    178197        /* mux given, no access */ 
     
    189208 
    190209    /* fix or warm of incompatible couple */ 
    191     if( psz_mux && *psz_mux && psz_access && *psz_access ) 
     210    if( psz_mux && psz_access ) 
    192211    { 
    193212        if( !strncmp( psz_access, "mmsh", 4 ) && strncmp( psz_mux, "asfh", 4 ) ) 
     
    246265 
    247266    /*  *** Create the SAP Session structure *** */ 
    248     if( psz_access &&  p_sap_cfg && ( strstr( psz_access, "udp" ) || 
    249                     strstr( psz_access ,  "rtp" ) ) ) 
    250     { 
    251         session_descriptor_t *p_session=  sout_AnnounceSessionCreate(); 
    252         announce_method_t *p_method = sout_AnnounceMethodCreate( 
    253                                                   METHOD_TYPE_SAP); 
     267    if( psz_access &&  p_sap_cfg && 
     268        ( strstr( psz_access, "udp" ) || strstr( psz_access ,  "rtp" ) ) ) 
     269    { 
     270        session_descriptor_t *p_session = sout_AnnounceSessionCreate(); 
     271        announce_method_t *p_method = 
     272            sout_AnnounceMethodCreate( METHOD_TYPE_SAP ); 
     273        vlc_url_t url; 
    254274 
    255275        /* Parse user input */ 
     
    277297                if( psz_curr != NULL) 
    278298                { 
    279                     p_method->i_ip_version = atoi( psz_curr ) != 0 ? 
    280                                                      atoi(psz_curr) : 
    281                                                      4; 
     299                    p_method->i_ip_version = 
     300                        atoi( psz_curr ) != 0 ? atoi(psz_curr) : 4; 
    282301                } 
    283302            } 
     
    293312 
    294313        /* Now, parse the URL to extract host and port */ 
    295         p_url = (vlc_url_t *)malloc( sizeof(vlc_url_t ) ); 
    296         if ( ! p_url ) 
    297         { 
    298             return NULL; 
    299         } 
    300  
    301         vlc_UrlParse( p_url, psz_url , 0); 
    302  
    303         if (!p_url->psz_host) 
    304         { 
    305             return NULL; 
    306         } 
    307  
    308         if(p_url->i_port == 0) 
    309         { 
    310                 p_url->i_port = DEFAULT_PORT; 
    311         } 
    312  
    313         p_session->psz_uri = p_url->psz_host; 
    314         p_session->i_port = p_url->i_port; 
    315         p_session->psz_sdp = NULL; 
    316  
    317         p_session->i_ttl = config_GetInt( p_sout,"ttl" ); 
    318         p_session->i_payload = 33; 
    319  
    320         msg_Info( p_this, "SAP Enabled"); 
    321  
    322         sout_AnnounceRegister( p_sout, p_session, p_method ); 
    323  
    324         /* FIXME: Free p_method */ 
    325  
    326         p_stream->p_sys->p_session = p_session; 
    327  
    328         if( p_url ) 
    329         { 
    330             vlc_UrlClean( p_url ); 
    331             free( p_url ); 
    332             p_url = NULL; 
    333         } 
     314        vlc_UrlParse( &url, psz_url , 0); 
     315 
     316        if( url.psz_host ) 
     317        { 
     318            if( url.i_port == 0 ) 
     319            { 
     320                url.i_port = DEFAULT_PORT; 
     321            } 
     322 
     323            p_session->psz_uri = url.psz_host; 
     324            p_session->i_port = url.i_port; 
     325            p_session->psz_sdp = NULL; 
     326 
     327            p_session->i_ttl = config_GetInt( p_sout, "ttl" ); 
     328            p_session->i_payload = 33; 
     329 
     330            msg_Info( p_this, "SAP Enabled"); 
     331 
     332            sout_AnnounceRegister( p_sout, p_session, p_method ); 
     333 
     334            /* FIXME: Free p_method */ 
     335 
     336            p_stream->p_sys->p_session = p_session; 
     337        } 
     338        vlc_UrlClean( &url ); 
    334339    } 
    335340 
     
    347352        else 
    348353        { 
    349             p_slp = (slp_session_t*)malloc(sizeof(slp_session_t)); 
    350             if(!p_slp) 
    351             { 
    352                 msg_Warn(p_sout,"out of memory"); 
    353 //                if( p_sap ) free( p_sap ); 
    354                 return -1; 
    355             } 
     354            p_slp = malloc(sizeof(slp_session_t)); 
    356355            p_slp->psz_url= strdup(psz_url); 
    357356            p_slp->psz_name = strdup( 
     
    439438{ 
    440439    sout_stream_sys_t *p_sys = p_stream->p_sys; 
    441     sout_instance_t   *p_sout = p_stream->p_sout; 
    442440 
    443441    sout_MuxSendBuffer( p_sys->p_mux, id->p_input, p_buffer );