Commit 5a922f69 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

stream_out_std: use new SDP API too

parent cf1414dc
...@@ -96,7 +96,8 @@ vlc_module_begin(); ...@@ -96,7 +96,8 @@ vlc_module_begin();
add_string( SOUT_CFG_PREFIX "dst", "", NULL, DST_TEXT, add_string( SOUT_CFG_PREFIX "dst", "", NULL, DST_TEXT,
DST_LONGTEXT, VLC_FALSE ); DST_LONGTEXT, VLC_FALSE );
add_bool( SOUT_CFG_PREFIX "sap", 0, NULL, SAP_TEXT, SAP_LONGTEXT, VLC_TRUE ); add_bool( SOUT_CFG_PREFIX "sap", VLC_FALSE, NULL, SAP_TEXT, SAP_LONGTEXT,
VLC_TRUE );
add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT, NAME_LONGTEXT, add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT, NAME_LONGTEXT,
VLC_TRUE ); VLC_TRUE );
add_string( SOUT_CFG_PREFIX "group", "", NULL, GROUP_TEXT, GROUP_LONGTEXT, add_string( SOUT_CFG_PREFIX "group", "", NULL, GROUP_TEXT, GROUP_LONGTEXT,
...@@ -142,6 +143,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -142,6 +143,7 @@ static int Open( vlc_object_t *p_this )
{ {
sout_stream_t *p_stream = (sout_stream_t*)p_this; sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_instance_t *p_sout = p_stream->p_sout; sout_instance_t *p_sout = p_stream->p_sout;
sout_stream_sys_t *p_sys;
char *psz_mux; char *psz_mux;
char *psz_access; char *psz_access;
...@@ -170,7 +172,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -170,7 +172,7 @@ static int Open( vlc_object_t *p_this )
psz_url = *val.psz_string ? val.psz_string : NULL; psz_url = *val.psz_string ? val.psz_string : NULL;
if( !*val.psz_string ) free( val.psz_string ); if( !*val.psz_string ) free( val.psz_string );
p_stream->p_sys = malloc( sizeof( sout_stream_sys_t) ); p_sys = p_stream->p_sys = malloc( sizeof( sout_stream_sys_t) );
p_stream->p_sys->p_session = NULL; p_stream->p_sys->p_session = NULL;
msg_Dbg( p_this, "creating `%s/%s://%s'", psz_access, psz_mux, psz_url ); msg_Dbg( p_this, "creating `%s/%s://%s'", psz_access, psz_mux, psz_url );
...@@ -334,58 +336,60 @@ static int Open( vlc_object_t *p_this ) ...@@ -334,58 +336,60 @@ static int Open( vlc_object_t *p_this )
/* *** Create the SAP Session structure *** */ /* *** Create the SAP Session structure *** */
if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) ) if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) )
{ {
session_descriptor_t *p_session; /* Create the SDP */
announce_method_t *p_method = sout_SAPMethod (); 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 (VLC_OBJECT (p_stream), dhost, dport, NULL, &res) == 0)
{
memcpy (&dst, res->ai_addr, dstlen = res->ai_addrlen);
vlc_freeaddrinfo (res);
}
static const struct { const char *access; const char *fmt; } fmts[] = if (vlc_getaddrinfo (VLC_OBJECT (p_stream), shost, sport, NULL, &res) == 0)
{ {
/* Plain text: */ memcpy (&src, res->ai_addr, srclen = res->ai_addrlen);
{ "udp", "udp mpeg" }, vlc_freeaddrinfo (res);
{ "rtp", "RTP/AVP 33" }, }
{ NULL, NULL }
};
const char *fmt = NULL;
char *src, *dst;
int sport, dport;
for (unsigned i = 0; fmts[i].access != NULL; i++)
if (strncasecmp (fmts[i].access, psz_access, strlen (fmts[i].access)) == 0)
{
fmt = fmts[i].fmt;
break;
}
src = var_GetNonEmptyString (p_access, "src-addr"); char *head = vlc_sdp_Start (VLC_OBJECT (p_stream), SOUT_CFG_PREFIX,
dst = var_GetNonEmptyString (p_access, "dst-addr"); (struct sockaddr *)&src, srclen,
sport = var_GetInteger (p_access, "src-port"); (struct sockaddr *)&dst, dstlen);
dport = var_GetInteger (p_access, "dst-port"); free (shost);
msg_Dbg( p_stream, "SAP advertized format: %s", fmt); char *psz_sdp = NULL;
if ((fmt == NULL) || ((src == NULL) && (dst == NULL))) if (head != NULL)
{ {
msg_Err (p_access, "SAP announces not supported for access %s", if (asprintf (&psz_sdp, "%s"
psz_access); "m=video %d udp mpeg\r\n", head, dport) == -1)
goto nosap; psz_sdp = NULL;
free (head);
} }
p_session = sout_AnnounceSessionCreate (VLC_OBJECT (p_stream), /* Register the SDP with the SAP thread */
SOUT_CFG_PREFIX); if (psz_sdp != NULL)
sout_SessionSetMedia (VLC_OBJECT (p_stream), p_session, fmt, {
src, sport, dst, dport); announce_method_t *p_method = sout_SAPMethod ();
sout_AnnounceRegister( p_sout, p_session, p_method ); msg_Dbg (p_stream, "Generated SDP:\n%s", psz_sdp);
p_stream->p_sys->p_session = p_session;
sout_MethodRelease (p_method); p_sys->p_session =
sout_AnnounceRegisterSDP (p_sout, SOUT_CFG_PREFIX, psz_sdp,
nosap: dhost, p_method);
free (src); sout_MethodRelease (p_method);
free (dst); }
free (dhost);
} }
p_stream->pf_add = Add; p_stream->pf_add = Add;
p_stream->pf_del = Del; p_stream->pf_del = Del;
p_stream->pf_send = Send; p_stream->pf_send = Send;
p_stream->p_sys->p_mux = p_mux; p_sys->p_mux = p_mux;
free( psz_access ); free( psz_access );
free( psz_mux ); free( psz_mux );
...@@ -409,7 +413,6 @@ static void Close( vlc_object_t * p_this ) ...@@ -409,7 +413,6 @@ static void Close( vlc_object_t * p_this )
sout_AnnounceSessionDestroy( p_sys->p_session ); sout_AnnounceSessionDestroy( p_sys->p_session );
} }
sout_MuxDelete( p_sys->p_mux ); sout_MuxDelete( p_sys->p_mux );
sout_AccessOutDelete( p_access ); sout_AccessOutDelete( p_access );
......
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