- sout_stream_sys_t *p_sys = malloc( sizeof( sout_stream_sys_t) );
-
- char *psz_mux = sout_cfg_find_value( p_stream->p_cfg, "mux" );
- char *psz_access = sout_cfg_find_value( p_stream->p_cfg, "access" );
- char *psz_url = sout_cfg_find_value( p_stream->p_cfg, "url" );
- char *psz_ipv = sout_cfg_find_value( p_stream->p_cfg, "sap_ipv" );
- char *psz_v6_scope = sout_cfg_find_value( p_stream->p_cfg, "sap_v6scope");
- sout_cfg_t *p_sap_cfg = sout_cfg_find( p_stream->p_cfg, "sap" );
-
-
- char *psz_sap = NULL;
-
- char *psz_port = "1234";
-
- sap_session_t *p_sap = NULL;
-
- sout_access_out_t *p_access;
- sout_mux_t *p_mux;
-
- p_sys->b_sap=0;
- /* SAP is only valid for UDP or RTP streaming */
- if( psz_access == NULL )
- psz_access="udp";
-
- if(p_sap_cfg && (strstr(psz_access,"udp") || strstr( psz_access , "rtp" )))
- {
- msg_Info( p_this, "SAP Enabled");
- p_sys->b_sap=1;
- if(p_sap_cfg->psz_value)
+
+ char *psz_mux;
+ char *psz_access;
+ char *psz_url;
+
+ vlc_value_t val;
+
+ sout_access_out_t *p_access;
+ sout_mux_t *p_mux;
+
+ char *psz_mux_byext = NULL;
+
+ config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options,
+ p_stream->p_cfg );
+
+ var_Get( p_stream, SOUT_CFG_PREFIX "access", &val );
+ psz_access = *val.psz_string ? val.psz_string : NULL;
+ if( !*val.psz_string ) free( val.psz_string );
+
+ var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val );
+ psz_mux = *val.psz_string ? val.psz_string : NULL;
+ if( !*val.psz_string ) free( val.psz_string );
+
+
+ var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val );
+ psz_url = *val.psz_string ? val.psz_string : NULL;
+ if( !*val.psz_string ) free( val.psz_string );
+
+ p_stream->p_sys = malloc( sizeof( sout_stream_sys_t) );
+ p_stream->p_sys->p_session = NULL;
+
+ msg_Dbg( p_this, "creating `%s/%s://%s'", psz_access, psz_mux, psz_url );
+
+ /* ext -> muxer name */
+ if( psz_url && strrchr( psz_url, '.' ) )
+ {
+ /* by extension */
+ static struct { char *ext; char *mux; } exttomux[] =
+ {
+ { "avi", "avi" },
+ { "ogg", "ogg" },
+ { "ogm", "ogg" },
+ { "mp4", "mp4" },
+ { "mov", "mov" },
+ { "moov","mov" },
+ { "asf", "asf" },
+ { "wma", "asf" },
+ { "wmv", "asf" },
+ { "trp", "ts" },
+ { "ts", "ts" },
+ { "mpg", "ps" },
+ { "mpeg","ps" },
+ { "ps", "ps" },
+ { "mpeg1","mpeg1" },
+ { "wav","wav" },
+ { NULL, NULL }
+ };
+ char *psz_ext = strrchr( psz_url, '.' ) + 1;
+ int i;
+
+ msg_Dbg( p_this, "extension is %s", psz_ext );
+ for( i = 0; exttomux[i].ext != NULL; i++ )
+ {
+ if( !strcasecmp( psz_ext, exttomux[i].ext ) )
+ {
+ psz_mux_byext = exttomux[i].mux;
+ break;
+ }
+ }
+ msg_Dbg( p_this, "extension -> mux=%s", psz_mux_byext );
+ }
+
+ /* We fix access/mux to valid couple */
+
+ if( !psz_access && !psz_mux )
+ {
+ if( psz_mux_byext )
+ {
+ msg_Warn( p_stream,
+ "no access _and_ no muxer, extension gives file/%s",
+ psz_mux_byext );
+ psz_access = strdup("file");
+ psz_mux = strdup(psz_mux_byext);
+ }
+ else
+ {
+ msg_Err( p_stream, "no access _and_ no muxer (fatal error)" );
+ return VLC_EGENERIC;
+ }
+ }
+
+ if( psz_access && !psz_mux )
+ {
+ /* access given, no mux */
+ if( !strncmp( psz_access, "mmsh", 4 ) )
+ {
+ psz_mux = strdup("asfh");
+ }
+ else if( !strncmp( psz_access, "udp", 3 ) ||
+ !strncmp( psz_access, "rtp", 3 ) )
+ {
+ psz_mux = strdup("ts");
+ }
+ else if( psz_mux_byext )
+ {
+ psz_mux = strdup(psz_mux_byext);
+ }
+ else