|
|
|
@ -33,8 +33,6 @@ |
|
|
|
|
|
|
|
#include <vlc_network.h> |
|
|
|
#include <vlc_url.h> |
|
|
|
#include <vlc_memstream.h> |
|
|
|
#include "sdp_helper.h" |
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Module descriptor |
|
|
|
@ -56,16 +54,6 @@ |
|
|
|
#define PATH_LONGTEXT N_( \ |
|
|
|
"Filename for stream. "\ |
|
|
|
"Helper setting for dst, dst=bind+'/'+path. dst-parameter overrides this." ) |
|
|
|
#define NAME_TEXT N_("Session name") |
|
|
|
#define NAME_LONGTEXT N_( \ |
|
|
|
"This is the name of the session that will be announced in the SDP " \ |
|
|
|
"(Session Descriptor)." ) |
|
|
|
#define DESC_TEXT N_("Session description") |
|
|
|
#define DESC_LONGTEXT N_( \ |
|
|
|
"This allows you to give a short description with details about the stream, " \ |
|
|
|
"that will be announced in the SDP (Session Descriptor)." ) |
|
|
|
#define SAP_TEXT N_("SAP announcing") |
|
|
|
#define SAP_LONGTEXT N_("Announce this session with SAP.") |
|
|
|
|
|
|
|
static int Open ( vlc_object_t * ); |
|
|
|
static void Close ( vlc_object_t * ); |
|
|
|
@ -82,7 +70,7 @@ vlc_module_begin () |
|
|
|
set_shortname( N_("Standard")) |
|
|
|
set_description( N_("Standard stream output") ) |
|
|
|
set_capability( "sout output", 50 ) |
|
|
|
add_shortcut( "standard", "std", "file", "http", "udp", SRT_SHORTCUT ) |
|
|
|
add_shortcut( "standard", "std", "file", "http", SRT_SHORTCUT ) |
|
|
|
set_category( CAT_SOUT ) |
|
|
|
set_subcategory( SUBCAT_SOUT_STREAM ) |
|
|
|
|
|
|
|
@ -91,9 +79,9 @@ vlc_module_begin () |
|
|
|
add_string( SOUT_CFG_PREFIX "dst", "", DEST_TEXT, DEST_LONGTEXT ) |
|
|
|
add_string( SOUT_CFG_PREFIX "bind", "", BIND_TEXT, BIND_LONGTEXT ) |
|
|
|
add_string( SOUT_CFG_PREFIX "path", "", PATH_TEXT, PATH_LONGTEXT ) |
|
|
|
add_bool( SOUT_CFG_PREFIX "sap", false, SAP_TEXT, SAP_LONGTEXT ) |
|
|
|
add_string( SOUT_CFG_PREFIX "name", "", NAME_TEXT, NAME_LONGTEXT ) |
|
|
|
add_string( SOUT_CFG_PREFIX "description", "", DESC_TEXT, DESC_LONGTEXT ) |
|
|
|
add_obsolete_bool( SOUT_CFG_PREFIX "sap" ) /* since 4.0.0 */ |
|
|
|
add_obsolete_string( SOUT_CFG_PREFIX "name" ) /* since 4.0.0 */ |
|
|
|
add_obsolete_string( SOUT_CFG_PREFIX "description" ) /* since 4.0.0 */ |
|
|
|
add_obsolete_string( SOUT_CFG_PREFIX "url" ) /* since 4.0.0 */ |
|
|
|
add_obsolete_string( SOUT_CFG_PREFIX "email" ) /* since 4.0.0 */ |
|
|
|
add_obsolete_string( SOUT_CFG_PREFIX "phone" ) /* since 3.0.0 */ |
|
|
|
@ -107,12 +95,9 @@ vlc_module_end () |
|
|
|
*****************************************************************************/ |
|
|
|
static const char *const ppsz_sout_options[] = { |
|
|
|
"access", "mux", "url", "dst", |
|
|
|
"sap", "name", "description", |
|
|
|
"bind", "path", NULL |
|
|
|
}; |
|
|
|
|
|
|
|
#define DEFAULT_PORT 1234 |
|
|
|
|
|
|
|
typedef struct |
|
|
|
{ |
|
|
|
sout_mux_t *p_mux; |
|
|
|
@ -144,57 +129,6 @@ static void Flush( sout_stream_t *p_stream, void *id ) |
|
|
|
sout_MuxFlush( p_sys->p_mux, (sout_input_t*)id ); |
|
|
|
} |
|
|
|
|
|
|
|
static void create_SDP(sout_stream_t *p_stream, sout_access_out_t *p_access) |
|
|
|
{ |
|
|
|
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|
|
|
|
|
|
|
static const struct addrinfo hints = { |
|
|
|
.ai_family = AF_UNSPEC, |
|
|
|
.ai_socktype = SOCK_DGRAM, |
|
|
|
.ai_protocol = 0, |
|
|
|
.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV | AI_IDN, |
|
|
|
}; |
|
|
|
char *shost = var_GetNonEmptyString (p_access, "src-addr"); |
|
|
|
char *dhost = var_GetNonEmptyString (p_access, "dst-addr"); |
|
|
|
int sport = var_GetInteger (p_access, "src-port"); |
|
|
|
int dport = var_GetInteger (p_access, "dst-port"); |
|
|
|
struct sockaddr_storage src, dst; |
|
|
|
socklen_t srclen = 0, dstlen = 0; |
|
|
|
struct addrinfo *res; |
|
|
|
|
|
|
|
if (!vlc_getaddrinfo (dhost, dport, &hints, &res)) |
|
|
|
{ |
|
|
|
memcpy (&dst, res->ai_addr, dstlen = res->ai_addrlen); |
|
|
|
freeaddrinfo (res); |
|
|
|
} |
|
|
|
|
|
|
|
if (!vlc_getaddrinfo (shost, sport, &hints, &res)) |
|
|
|
{ |
|
|
|
memcpy (&src, res->ai_addr, srclen = res->ai_addrlen); |
|
|
|
freeaddrinfo (res); |
|
|
|
} |
|
|
|
|
|
|
|
struct vlc_memstream sdp; |
|
|
|
|
|
|
|
if (vlc_sdp_Start(&sdp, VLC_OBJECT (p_stream), SOUT_CFG_PREFIX, |
|
|
|
(struct sockaddr *)&src, srclen, |
|
|
|
(struct sockaddr *)&dst, dstlen) == 0) |
|
|
|
{ |
|
|
|
vlc_memstream_printf(&sdp, "m=video %d udp mpeg\r\n", dport); |
|
|
|
|
|
|
|
/* Register the SDP with the SAP thread */ |
|
|
|
if (vlc_memstream_close(&sdp) == 0) |
|
|
|
{ |
|
|
|
msg_Dbg(p_stream, "Generated SDP:\n%s", sdp.ptr); |
|
|
|
p_sys->p_session = |
|
|
|
sout_AnnounceRegisterSDP(p_stream, sdp.ptr, dhost); |
|
|
|
free(sdp.ptr); |
|
|
|
} |
|
|
|
} |
|
|
|
free(shost); |
|
|
|
free(dhost); |
|
|
|
} |
|
|
|
|
|
|
|
static const char *getMuxFromAlias( const char *psz_alias ) |
|
|
|
{ |
|
|
|
static struct { const char alias[6]; const char mux[32]; } mux_alias[] = |
|
|
|
@ -263,8 +197,6 @@ static int fixAccessMux( sout_stream_t *p_stream, char **ppsz_mux, |
|
|
|
{ |
|
|
|
if( !strncmp( psz_access, "mmsh", 4 ) ) |
|
|
|
*ppsz_mux = strdup("asfh"); |
|
|
|
else if (!strcmp (psz_access, "udp")) |
|
|
|
*ppsz_mux = strdup("ts"); |
|
|
|
else if( psz_mux_byext ) |
|
|
|
*ppsz_mux = strdup(psz_mux_byext); |
|
|
|
else |
|
|
|
@ -301,18 +233,6 @@ static void checkAccessMux( sout_stream_t *p_stream, char *psz_access, |
|
|
|
else if( !exactMatch( psz_access, "file", 4 ) && |
|
|
|
( exactMatch( psz_mux, "mov", 3 ) || exactMatch( psz_mux, "mp4", 3 ) ) ) |
|
|
|
msg_Err( p_stream, "mov and mp4 mux are only valid with file output" ); |
|
|
|
else if( exactMatch( psz_access, "udp", 3 ) ) |
|
|
|
{ |
|
|
|
if( exactMatch( psz_mux, "ffmpeg", 6 ) || exactMatch( psz_mux, "avformat", 8 ) ) |
|
|
|
{ /* why would you use ffmpeg's ts muxer ? YOU DON'T LOVE VLC ??? */ |
|
|
|
char *psz_ffmpeg_mux = var_CreateGetString( p_stream, "sout-avformat-mux" ); |
|
|
|
if( !psz_ffmpeg_mux || strncmp( psz_ffmpeg_mux, "mpegts", 6 ) ) |
|
|
|
msg_Err( p_stream, "UDP output is only valid with TS mux" ); |
|
|
|
free( psz_ffmpeg_mux ); |
|
|
|
} |
|
|
|
else if( !exactMatch( psz_mux, "ts", 2 ) ) |
|
|
|
msg_Err( p_stream, "UDP output is only valid with TS mux" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static int Control(sout_stream_t *stream, int query, va_list args) |
|
|
|
@ -418,9 +338,6 @@ static int Open( vlc_object_t *p_this ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) ) |
|
|
|
create_SDP( p_stream, p_access ); |
|
|
|
|
|
|
|
p_stream->ops = &ops; |
|
|
|
ret = VLC_SUCCESS; |
|
|
|
msg_Dbg( p_this, "using `%s/%s://%s'", psz_access, psz_mux, psz_url ); |
|
|
|
|