+ sout_mux_t *p_mux;
+
+ char *psz_mux_byext = NULL;
+
+ sout_CfgParse( 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 && !*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 && !*val.psz_string ) free( val.psz_string );
+
+ var_Get( p_stream, SOUT_CFG_PREFIX "url", &val );
+ psz_url = *val.psz_string ? val.psz_string : NULL;
+ if( val.psz_string && !*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 extention */
+ 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" },
+ { NULL, NULL }
+ };
+ char *psz_ext = strrchr( psz_url, '.' ) + 1;
+ int i;
+
+ msg_Dbg( p_this, "extention 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, "extention -> 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, extention 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 ) )
+ {
+ psz_mux = strdup("ts");
+ }
+ else if( psz_mux_byext )
+ {
+ psz_mux = strdup(psz_mux_byext);
+ }
+ else
+ {
+ msg_Err( p_stream, "no mux specified or found by extention" );
+ return VLC_EGENERIC;
+ }
+ }
+ else if( psz_mux && !psz_access )
+ {
+ /* mux given, no access */
+ if( !strncmp( psz_mux, "asfh", 4 ) )
+ {
+ psz_access = strdup("mmsh");
+ }
+ else
+ {
+ /* default file */
+ psz_access = strdup("file");
+ }
+ }