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

Rework SDP API a little

parent d5f7a3c1
...@@ -222,6 +222,7 @@ VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) ); ...@@ -222,6 +222,7 @@ VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) );
/** SDP */ /** SDP */
VLC_EXPORT( char *, vlc_sdp_Start, ( vlc_object_t *obj, const char *cfgpref, const struct sockaddr *src, size_t srclen, const struct sockaddr *addr, size_t addrlen ) );
VLC_EXPORT( char *, sdp_Start, (const char *name, const char *description, const char *url, const char *email, const char *phone, const struct sockaddr *orig, size_t origlen, const struct sockaddr *addr, size_t addrlen) ); VLC_EXPORT( char *, sdp_Start, (const char *name, const char *description, const char *url, const char *email, const char *phone, const struct sockaddr *orig, size_t origlen, const struct sockaddr *addr, size_t addrlen) );
VLC_EXPORT( char *, sdp_AddMedia, (char **sdp, const char *type, const char *protocol, int dport, unsigned pt, vlc_bool_t bw_indep, unsigned bw, const char *rtpmap, const char *fmtp) ); VLC_EXPORT( char *, sdp_AddMedia, (char **sdp, const char *type, const char *protocol, int dport, unsigned pt, vlc_bool_t bw_indep, unsigned bw, const char *rtpmap, const char *fmtp) );
VLC_EXPORT( char *, sdp_AddAttribute, (char **sdp, const char *name, const char *fmt, ...) ATTRIBUTE_FORMAT( 3, 4 ) ); VLC_EXPORT( char *, sdp_AddAttribute, (char **sdp, const char *name, const char *fmt, ...) ATTRIBUTE_FORMAT( 3, 4 ) );
......
...@@ -69,10 +69,10 @@ ...@@ -69,10 +69,10 @@
#define NAME_LONGTEXT N_( \ #define NAME_LONGTEXT N_( \
"This is the name of the session that will be announced in the SDP " \ "This is the name of the session that will be announced in the SDP " \
"(Session Descriptor)." ) "(Session Descriptor)." )
#define DESC_TEXT N_("Session description") #define DESC_TEXT N_("Session descriptipn")
#define DESC_LONGTEXT N_( \ #define DESC_LONGTEXT N_( \
"This allows you to give a broader description of the stream, that will " \ "This allows you to give a short description with details about the stream, " \
"be announced in the SDP (Session Descriptor)." ) "that will be announced in the SDP (Session Descriptor)." )
#define URL_TEXT N_("Session URL") #define URL_TEXT N_("Session URL")
#define URL_LONGTEXT N_( \ #define URL_LONGTEXT N_( \
"This allows you to give an URL with more details about the stream " \ "This allows you to give an URL with more details about the stream " \
...@@ -82,6 +82,11 @@ ...@@ -82,6 +82,11 @@
#define EMAIL_LONGTEXT N_( \ #define EMAIL_LONGTEXT N_( \
"This allows you to give a contact mail address for the stream, that will " \ "This allows you to give a contact mail address for the stream, that will " \
"be announced in the SDP (Session Descriptor)." ) "be announced in the SDP (Session Descriptor)." )
#define PHONE_TEXT N_("Session phone number")
#define PHONE_LONGTEXT N_( \
"This allows you to give a contact telephone number for the stream, that will " \
"be announced in the SDP (Session Descriptor)." )
#define PORT_TEXT N_("Port") #define PORT_TEXT N_("Port")
#define PORT_LONGTEXT N_( \ #define PORT_LONGTEXT N_( \
"This allows you to specify the base port for the RTP streaming." ) "This allows you to specify the base port for the RTP streaming." )
...@@ -141,6 +146,8 @@ vlc_module_begin(); ...@@ -141,6 +146,8 @@ vlc_module_begin();
URL_LONGTEXT, VLC_TRUE ); URL_LONGTEXT, VLC_TRUE );
add_string( SOUT_CFG_PREFIX "email", "", NULL, EMAIL_TEXT, add_string( SOUT_CFG_PREFIX "email", "", NULL, EMAIL_TEXT,
EMAIL_LONGTEXT, VLC_TRUE ); EMAIL_LONGTEXT, VLC_TRUE );
add_string( SOUT_CFG_PREFIX "phone", "", NULL, PHONE_TEXT,
PHONE_LONGTEXT, VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, PORT_TEXT, add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, PORT_TEXT,
PORT_LONGTEXT, VLC_TRUE ); PORT_LONGTEXT, VLC_TRUE );
...@@ -170,7 +177,7 @@ vlc_module_end(); ...@@ -170,7 +177,7 @@ vlc_module_end();
*****************************************************************************/ *****************************************************************************/
static const char *ppsz_sout_options[] = { static const char *ppsz_sout_options[] = {
"dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux", "dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux",
"description", "url", "email", "description", "url", "email", "phone",
"dccp", "tcp", "udplite", "dccp", "tcp", "udplite",
"mp4a-latm", NULL "mp4a-latm", NULL
}; };
...@@ -686,14 +693,11 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url ) ...@@ -686,14 +693,11 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
dstlen = sizeof( struct sockaddr_in ); dstlen = sizeof( struct sockaddr_in );
} }
psz_sdp = sdp_Start( p_sys->psz_session_name, psz_sdp = vlc_sdp_Start( VLC_OBJECT( p_stream ), SOUT_CFG_PREFIX,
p_sys->psz_session_description, NULL, 0, (struct sockaddr *)&dst, dstlen );
p_sys->psz_session_url, p_sys->psz_session_email,
NULL, NULL, 0, (struct sockaddr *)&dst, dstlen );
if( psz_sdp == NULL ) if( psz_sdp == NULL )
return NULL; return NULL;
/* TODO: a=source-filter */ /* TODO: a=source-filter */
if( rtsp_url != NULL ) if( rtsp_url != NULL )
......
...@@ -257,7 +257,7 @@ playlist_ServicesDiscoveryRemove ...@@ -257,7 +257,7 @@ playlist_ServicesDiscoveryRemove
playlist_TreeMove playlist_TreeMove
resolve_xml_special_chars resolve_xml_special_chars
secstotimestr secstotimestr
sdp_Start vlc_sdp_Start
sdp_AddAttribute sdp_AddAttribute
sdp_AddMedia sdp_AddMedia
sout_AccessOutDelete sout_AccessOutDelete
......
...@@ -244,3 +244,45 @@ char *sdp_AddMedia (char **sdp, ...@@ -244,3 +244,45 @@ char *sdp_AddMedia (char **sdp,
return newsdp; return newsdp;
} }
char *vlc_sdp_Start (vlc_object_t *obj, const char *cfgpref,
const struct sockaddr *src, size_t srclen,
const struct sockaddr *addr, size_t addrlen)
{
size_t cfglen = strlen (cfgpref);
if (cfglen > 100)
return NULL;
char varname[cfglen + sizeof ("description")], *subvar = varname + cfglen;
strcpy (varname, cfgpref);
session_descriptor_t *p_session = calloc (1, sizeof (*p_session));
if (p_session == NULL)
return NULL;
strcpy (subvar, "name");
char *name = var_GetNonEmptyString (obj, varname);
strcpy (subvar, "description");
char *description = var_GetNonEmptyString (obj, varname);
strcpy (subvar, "url");
char *url = var_GetNonEmptyString (obj, varname);
strcpy (subvar, "email");
char *email = var_GetNonEmptyString (obj, varname);
strcpy (subvar, "phone");
char *phone = var_GetNonEmptyString (obj, varname);
#if 0
strcpy (subvar, "group");
char *group = var_GetNonEmptyString (obj, varname);
#endif
char *sdp = sdp_Start (name, description, url, email, phone,
src, srclen, addr, addrlen);
free (name);
free (description);
free (url);
free (email);
free (phone);
return sdp;
}
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