Commit 116d2616 authored by Laurent Aimar's avatar Laurent Aimar

* 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).
 
parent 3c0c2a2a
......@@ -37,10 +37,15 @@
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
#define SOUT_CFG_PREFIX "sout-display-"
vlc_module_begin();
set_description( _("Display stream output") );
set_capability( "sout stream", 50 );
add_shortcut( "display" );
add_bool( SOUT_CFG_PREFIX "audio", 1, NULL, "audio", "", VLC_TRUE );
add_bool( SOUT_CFG_PREFIX "video", 1, NULL, "video", "", VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "delay", 100, NULL, "delay", "", VLC_TRUE );
set_callbacks( Open, Close );
vlc_module_end();
......@@ -48,6 +53,10 @@ vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"audio", "video", "delay", NULL
};
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
......@@ -69,7 +78,10 @@ static int Open( vlc_object_t *p_this )
{
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys;
char *val;
vlc_value_t val;
sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg );
p_sys = malloc( sizeof( sout_stream_sys_t ) );
p_sys->p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_sys->p_input )
......@@ -79,21 +91,14 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
p_sys->b_audio = VLC_TRUE;
p_sys->b_video = VLC_TRUE;
p_sys->i_delay = 100*1000;
if( sout_cfg_find( p_stream->p_cfg, "noaudio" ) )
{
p_sys->b_audio = VLC_FALSE;
}
if( sout_cfg_find( p_stream->p_cfg, "novideo" ) )
{
p_sys->b_video = VLC_FALSE;
}
if( ( val = sout_cfg_find_value( p_stream->p_cfg, "delay" ) ) )
{
p_sys->i_delay = (mtime_t)atoi( val ) * (mtime_t)1000;
}
var_Get( p_stream, SOUT_CFG_PREFIX "audio", &val );
p_sys->b_audio = val.b_bool;
var_Get( p_stream, SOUT_CFG_PREFIX "video", &val );
p_sys->b_video = val.b_bool;
var_Get( p_stream, SOUT_CFG_PREFIX "delay", &val );
p_sys->i_delay = (int64_t)val.i_int * 1000;
p_stream->pf_add = Add;
p_stream->pf_del = Del;
......
......@@ -31,27 +31,50 @@
#include <vlc/input.h>
#include <vlc/sout.h>
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
/*****************************************************************************
* Exported prototypes
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
#define SOUT_CFG_PREFIX "sout-es-"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("Elementary stream output") );
set_capability( "sout stream", 50 );
add_shortcut( "es" );
add_string( SOUT_CFG_PREFIX "access", "", NULL, "access", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "access-audio", "", NULL, "access audio", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "access-video", "", NULL, "access video", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "mux-audio", "", NULL, "mux audio", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "mux-video", "", NULL, "mux video", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "dst", "", NULL, "dst", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "dst-audio", "", NULL, "dst audio", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "dst-video", "", NULL, "dst video", "", VLC_TRUE );
set_callbacks( Open, Close );
vlc_module_end();
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"access", "access-audio", "access-video",
"mux", "mux-audio", "mux-video",
"dst", "dst-audio", "dst-video",
NULL
};
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
struct sout_stream_sys_t
{
int i_count_audio;
......@@ -66,9 +89,9 @@ struct sout_stream_sys_t
char *psz_access_audio;
char *psz_access_video;
char *psz_url;
char *psz_url_audio;
char *psz_url_video;
char *psz_dst;
char *psz_dst_audio;
char *psz_dst_video;
};
/*****************************************************************************
......@@ -78,26 +101,35 @@ static int Open( vlc_object_t *p_this )
{
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys;
vlc_value_t val;
/* p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader ); */
sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg );
p_sys = malloc( sizeof( sout_stream_sys_t ) );
p_sys->i_count = 0;
p_sys->i_count_audio = 0;
p_sys->i_count_video = 0;
p_sys->psz_access = sout_cfg_find_value( p_stream->p_cfg, "access" );
p_sys->psz_access_audio = sout_cfg_find_value( p_stream->p_cfg, "access_audio" );
p_sys->psz_access_video = sout_cfg_find_value( p_stream->p_cfg, "access_video" );
p_sys->psz_mux = sout_cfg_find_value( p_stream->p_cfg, "mux" );
p_sys->psz_mux_audio = sout_cfg_find_value( p_stream->p_cfg, "mux_audio" );
p_sys->psz_mux_video = sout_cfg_find_value( p_stream->p_cfg, "mux_video" );
p_sys->psz_url = sout_cfg_find_value( p_stream->p_cfg, "url" );
p_sys->psz_url_audio = sout_cfg_find_value( p_stream->p_cfg, "url_audio" );
p_sys->psz_url_video = sout_cfg_find_value( p_stream->p_cfg, "url_video" );
var_Get( p_stream, SOUT_CFG_PREFIX "access", &val );
p_sys->psz_access = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "access-audio", &val );
p_sys->psz_access_audio = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "access-video", &val );
p_sys->psz_access_video = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val );
p_sys->psz_mux = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "mux-audio", &val );
p_sys->psz_mux_audio = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "mux-video", &val );
p_sys->psz_mux_video = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val );
p_sys->psz_dst = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "dst-audio", &val );
p_sys->psz_dst_audio = val.psz_string;
var_Get( p_stream, SOUT_CFG_PREFIX "dst-video", &val );
p_sys->psz_dst_video = val.psz_string;
p_stream->pf_add = Add;
p_stream->pf_del = Del;
......@@ -117,6 +149,18 @@ static void Close( vlc_object_t * p_this )
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys = p_stream->p_sys;
free( p_sys->psz_access );
free( p_sys->psz_access_audio );
free( p_sys->psz_access_video );
free( p_sys->psz_mux );
free( p_sys->psz_mux_audio );
free( p_sys->psz_mux_video );
free( p_sys->psz_dst );
free( p_sys->psz_dst_audio );
free( p_sys->psz_dst_video );
free( p_sys );
}
......@@ -129,14 +173,14 @@ struct sout_stream_id_t
static char * es_print_url( char *psz_fmt, vlc_fourcc_t i_fourcc, int i_count,
char *psz_access, char *psz_mux )
{
char *psz_url, *p;
char *psz_dst, *p;
if( psz_fmt == NULL || !*psz_fmt )
{
psz_fmt = "stream-%n-%c.%m";
}
p = psz_url = malloc( 4096 );
p = psz_dst = malloc( 4096 );
memset( p, 0, 4096 );
for( ;; )
{
......@@ -182,7 +226,7 @@ static char * es_print_url( char *psz_fmt, vlc_fourcc_t i_fourcc, int i_count,
}
}
return( psz_url );
return( psz_dst );
}
static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
......@@ -193,17 +237,17 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
char *psz_access;
char *psz_mux;
char *psz_url;
char *psz_dst;
sout_access_out_t *p_access;
sout_mux_t *p_mux;
/* *** get access name *** */
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_access_audio )
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_access_audio && *p_sys->psz_access_audio )
{
psz_access = p_sys->psz_access_audio;
}
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_access_video )
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_access_video && *p_sys->psz_access_video )
{
psz_access = p_sys->psz_access_video;
}
......@@ -213,11 +257,11 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
}
/* *** get mux name *** */
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_mux_audio )
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_mux_audio && *p_sys->psz_mux_audio )
{
psz_mux = p_sys->psz_mux_audio;
}
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_mux_video )
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_mux_video && *p_sys->psz_mux_video )
{
psz_mux = p_sys->psz_mux_video;
}
......@@ -227,14 +271,14 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
}
/* Get url (%d expanded as a codec count, %c expanded as codec fcc ) */
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_url_audio )
if( p_fmt->i_cat == AUDIO_ES && p_sys->psz_dst_audio && *p_sys->psz_dst_audio )
{
psz_url = es_print_url( p_sys->psz_url_audio, p_fmt->i_codec,
psz_dst = es_print_url( p_sys->psz_dst_audio, p_fmt->i_codec,
p_sys->i_count_audio, psz_access, psz_mux );
}
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_url_video )
else if( p_fmt->i_cat == VIDEO_ES && p_sys->psz_dst_video && *p_sys->psz_dst_video )
{
psz_url = es_print_url( p_sys->psz_url_video, p_fmt->i_codec,
psz_dst = es_print_url( p_sys->psz_dst_video, p_fmt->i_codec,
p_sys->i_count_video, psz_access, psz_mux );
}
else
......@@ -253,7 +297,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
i_count = p_sys->i_count;
}
psz_url = es_print_url( p_sys->psz_url, p_fmt->i_codec,
psz_dst = es_print_url( p_sys->psz_dst, p_fmt->i_codec,
i_count, psz_access, psz_mux );
}
......@@ -267,14 +311,14 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
p_sys->i_count_audio++;
}
msg_Dbg( p_stream, "creating `%s/%s://%s'",
psz_access, psz_mux, psz_url );
psz_access, psz_mux, psz_dst );
/* *** find and open appropriate access module *** */
p_access = sout_AccessOutNew( p_sout, psz_access, psz_url );
p_access = sout_AccessOutNew( p_sout, psz_access, psz_dst );
if( p_access == NULL )
{
msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'",
psz_access, psz_mux, psz_url );
psz_access, psz_mux, psz_dst );
return( NULL );
}
......@@ -283,7 +327,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
if( p_mux == NULL )
{
msg_Err( p_stream, "no suitable sout mux module for `%s/%s://%s'",
psz_access, psz_mux, psz_url );
psz_access, psz_mux, psz_dst );
sout_AccessOutDelete( p_access );
return( NULL );
}
......
......@@ -39,16 +39,30 @@
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
#define SOUT_CFG_PREFIX "sout-rtp-"
vlc_module_begin();
set_description( _("RTP stream output") );
set_capability( "sout stream", 0 );
add_shortcut( "rtp" );
add_string( SOUT_CFG_PREFIX "dst", "", NULL, "destination", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "name", "", NULL, "name", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "sdp", "", NULL, "sdp", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, "port", "", VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL, "port", "", VLC_TRUE );
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"dst", "name", "port", "sdp", "ttl", "mux", NULL
};
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *,
......@@ -182,43 +196,42 @@ static int Open( vlc_object_t *p_this )
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_instance_t *p_sout = p_stream->p_sout;
sout_stream_sys_t *p_sys;
vlc_value_t val;
char *val;
sout_ParseCfg( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg );
p_sys = malloc( sizeof( sout_stream_sys_t ) );
p_sys->psz_destination = sout_cfg_find_value( p_stream->p_cfg, "dst" );
p_sys->psz_session_name = sout_cfg_find_value( p_stream->p_cfg, "name" );
if( ( val = sout_cfg_find_value( p_stream->p_cfg, "port" ) ) )
{
p_sys->i_port = atoi( val );
}
else
{
p_sys->i_port = 1234;
}
var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val );
p_sys->psz_destination = *val.psz_string ? val.psz_string : NULL;
var_Get( p_stream, SOUT_CFG_PREFIX "name", &val );
p_sys->psz_session_name = *val.psz_string ? val.psz_string : NULL;
var_Get( p_stream, SOUT_CFG_PREFIX "port", &val );
p_sys->i_port = val.i_int;
if( !p_sys->psz_session_name )
{
if( p_sys->psz_destination )
{
p_sys->psz_session_name = strdup( p_sys->psz_destination );
}
else
{
p_sys->psz_session_name = strdup( "NONE" );
}
}
if( !p_sys->psz_destination || *p_sys->psz_destination == '\0' )
{
val = sout_cfg_find_value( p_stream->p_cfg, "sdp" );
if( val == NULL || strncasecmp( val, "rtsp", 4 ) )
var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val );
if( strncasecmp( val.psz_string, "rtsp", 4 ) )
{
msg_Err( p_stream, "missing destination and not in rtsp mode" );
free( p_sys );
return VLC_EGENERIC;
}
p_sys->psz_destination = NULL;
free( val.psz_string );
}
else if( p_sys->i_port <= 0 )
{
......@@ -227,14 +240,8 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
if( ( val = sout_cfg_find_value( p_stream->p_cfg, "ttl" ) ) )
{
p_sys->i_ttl = atoi( val );
}
else
{
p_sys->i_ttl = config_GetInt( p_stream, "ttl" );
}
var_Get( p_stream, SOUT_CFG_PREFIX "ttl", &val );
p_sys->i_ttl = val.i_int;
p_sys->i_payload_type = 96;
p_sys->i_es = 0;
......@@ -266,7 +273,8 @@ static int Open( vlc_object_t *p_this )
p_stream->p_sys = p_sys;
if( ( val = sout_cfg_find_value( p_stream->p_cfg, "mux" ) ) )
var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val );
if( *val.psz_string )
{
sout_access_out_t *p_grab;
......@@ -275,11 +283,11 @@ static int Open( vlc_object_t *p_this )
char url[strlen( p_sys->psz_destination ) + 1 + 12 + 1];
/* Check muxer type */
if( !strncasecmp( val, "ps", 2 ) || !strncasecmp( val, "mpeg1", 5 ) )
if( !strncasecmp( val.psz_string, "ps", 2 ) || !strncasecmp( val.psz_string, "mpeg1", 5 ) )
{
psz_rtpmap = "MP2P/90000";
}
else if( !strncasecmp( val, "ts", 2 ) )
else if( !strncasecmp( val.psz_string, "ts", 2 ) )
{
psz_rtpmap = "MP2T/90000";
p_sys->i_payload_type = 33;
......@@ -327,9 +335,9 @@ static int Open( vlc_object_t *p_this )
p_grab->pf_write = AccessOutGrabberWrite;
/* the muxer */
if( !( p_sys->p_mux = sout_MuxNew( p_sout, val, p_sys->p_grab ) ) )
if( !( p_sys->p_mux = sout_MuxNew( p_sout, val.psz_string, p_sys->p_grab ) ) )
{
msg_Err( p_stream, "cannot create the muxer (%s)", val );
msg_Err( p_stream, "cannot create the muxer (%s)", val.psz_string );
sout_AccessOutDelete( p_sys->p_grab );
sout_AccessOutDelete( p_sys->p_access );
free( p_sys );
......@@ -369,12 +377,15 @@ static int Open( vlc_object_t *p_this )
p_sys->p_access = NULL;
p_sys->p_grab = NULL;
}
free( val.psz_string );
if( ( val = sout_cfg_find_value( p_stream->p_cfg, "sdp" ) ) )
var_Get( p_stream, SOUT_CFG_PREFIX "sdp", &val );
if( *val.psz_string )
{
vlc_url_t url;
vlc_UrlParse( &url, val, 0 );
vlc_UrlParse( &url, val.psz_string, 0 );
if( url.psz_protocol && !strcasecmp( url.psz_protocol, "http" ) )
{
if( HttpSetup( p_stream, &url ) )
......@@ -402,6 +413,7 @@ static int Open( vlc_object_t *p_this )
}
vlc_UrlClean( &url );
}
free( val.psz_string );
/* update p_sout->i_out_pace_nocontrol */
p_stream->p_sout->i_out_pace_nocontrol++;
......
......@@ -34,30 +34,42 @@
#include "announce.h"
#include "network.h"
#define DEFAULT_IPV6_SCOPE '8'
#define DEFAULT_PORT 1234
/*****************************************************************************
* Exported prototypes
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
#define SOUT_CFG_PREFIX "sout-standard-"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("Standard stream output") );
set_capability( "sout stream", 50 );
add_shortcut( "standard" );
add_shortcut( "std" );
add_string( SOUT_CFG_PREFIX "access", "", NULL, "access", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "mux", "", NULL, "mux", "", VLC_TRUE );
add_string( SOUT_CFG_PREFIX "url", "", NULL, "url", "", VLC_TRUE );
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"access", "mux", "url", NULL
};
#define DEFAULT_IPV6_SCOPE '8'
#define DEFAULT_PORT 1234
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
struct sout_stream_sys_t
{
sout_mux_t *p_mux;
......@@ -73,24 +85,34 @@ static int Open( vlc_object_t *p_this )
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_instance_t *p_sout = p_stream->p_sout;
slp_session_t *p_slp = NULL;
session_descriptor_t *p_session = NULL;
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_sdp = NULL;
char *psz_mux;
char *psz_access;
char *psz_url;
vlc_url_t *p_url;
sout_cfg_t *p_sap_cfg = sout_cfg_find( p_stream->p_cfg, "sap" );
#ifdef HAVE_SLP_H
sout_cfg_t *p_slp_cfg = sout_cfg_find( p_stream->p_cfg, "slp" );
#endif
vlc_value_t val;
sout_access_out_t *p_access;
sout_mux_t *p_mux;
char *psz_mux_byext = NULL;
sout_ParseCfg( 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;
var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val );
psz_mux = *val.psz_string ? val.psz_string : NULL;
var_Get( p_stream, SOUT_CFG_PREFIX "url", &val );
psz_url = *val.psz_string ? val.psz_string : NULL;
p_stream->p_sys = malloc( sizeof( sout_stream_sys_t) );
p_stream->p_sys->p_session = NULL;
......@@ -137,8 +159,7 @@ static int Open( vlc_object_t *p_this )
/* We fix access/mux to valid couple */
if( ( psz_access == NULL || *psz_access == '\0' )&&
( psz_mux == NULL || *psz_mux == '\0' ) )
if( psz_access == NULL && psz_mux == NULL )
{
if( psz_mux_byext )
{
......@@ -155,8 +176,7 @@ static int Open( vlc_object_t *p_this )
}
}
if( psz_access && *psz_access &&
( psz_mux == NULL || *psz_mux == '\0' ) )
if( psz_access && psz_mux == NULL )
{
/* access given, no mux */
if( !strncmp( psz_access, "mmsh", 4 ) )
......@@ -172,8 +192,7 @@ static int Open( vlc_object_t *p_this )
psz_mux = psz_mux_byext;
}
}
else if( psz_mux && *psz_mux &&
( psz_access == NULL || *psz_access == '\0' ) )
else if( psz_mux && psz_access == NULL )
{
/* mux given, no access */
if( !strncmp( psz_mux, "asfh", 4 ) )
......@@ -188,7 +207,7 @@ static int Open( vlc_object_t *p_this )
}
/* fix or warm of incompatible couple */
if( psz_mux && *psz_mux && psz_access && *psz_access )
if( psz_mux && psz_access )
{
if( !strncmp( psz_access, "mmsh", 4 ) && strncmp( psz_mux, "asfh", 4 ) )
{
......@@ -245,12 +264,13 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_stream, "mux opened" );
/* *** Create the SAP Session structure *** */
if( psz_access && p_sap_cfg && ( strstr( psz_access, "udp" ) ||
strstr( psz_access , "rtp" ) ) )
if( psz_access && p_sap_cfg &&
( strstr( psz_access, "udp" ) || strstr( psz_access , "rtp" ) ) )
{
session_descriptor_t *p_session= sout_AnnounceSessionCreate();
announce_method_t *p_method = sout_AnnounceMethodCreate(
METHOD_TYPE_SAP);
session_descriptor_t *p_session = sout_AnnounceSessionCreate();
announce_method_t *p_method =
sout_AnnounceMethodCreate( METHOD_TYPE_SAP );
vlc_url_t url;
/* Parse user input */
if( p_sap_cfg->psz_value )
......@@ -276,9 +296,8 @@ static int Open( vlc_object_t *p_this )
psz_curr = sout_cfg_find_value( p_cfg,"ip_version");
if( psz_curr != NULL)
{
p_method->i_ip_version = atoi( psz_curr ) != 0 ?
atoi(psz_curr) :
4;
p_method->i_ip_version =
atoi( psz_curr ) != 0 ? atoi(psz_curr) : 4;
}
}
else
......@@ -292,29 +311,20 @@ static int Open( vlc_object_t *p_this )
}
/* Now, parse the URL to extract host and port */
p_url = (vlc_url_t *)malloc( sizeof(vlc_url_t ) );
if ( ! p_url )
{
return NULL;
}
vlc_UrlParse( p_url, psz_url , 0);
vlc_UrlParse( &url, psz_url , 0);
if (!p_url->psz_host)
if( url.psz_host )
{
return NULL;
}
if(p_url->i_port == 0)
if( url.i_port == 0 )
{
p_url->i_port = DEFAULT_PORT;
url.i_port = DEFAULT_PORT;
}
p_session->psz_uri = p_url->psz_host;
p_session->i_port = p_url->i_port;
p_session->psz_uri = url.psz_host;
p_session->i_port = url.i_port;
p_session->psz_sdp = NULL;
p_session->i_ttl = config_GetInt( p_sout,"ttl" );
p_session->i_ttl = config_GetInt( p_sout, "ttl" );
p_session->i_payload = 33;
msg_Info( p_this, "SAP Enabled");
......@@ -324,13 +334,8 @@ static int Open( vlc_object_t *p_this )
/* FIXME: Free p_method */
p_stream->p_sys->p_session = p_session;
if( p_url )
{
vlc_UrlClean( p_url );
free( p_url );
p_url = NULL;
}
vlc_UrlClean( &url );
}
/* *** Register with slp *** */
......@@ -346,13 +351,7 @@ static int Open( vlc_object_t *p_this )
}
else
{
p_slp = (slp_session_t*)malloc(sizeof(slp_session_t));
if(!p_slp)
{
msg_Warn(p_sout,"out of memory");
// if( p_sap ) free( p_sap );
return -1;
}
p_slp = malloc(sizeof(slp_session_t));
p_slp->psz_url= strdup(psz_url);
p_slp->psz_name = strdup(
p_slp_cfg->psz_value ? p_slp_cfg->psz_value : psz_url);
......@@ -438,7 +437,6 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout;
sout_MuxSendBuffer( p_sys->p_mux, id->p_input, p_buffer );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment