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

Announce API simplification

parent d2121795
...@@ -208,12 +208,11 @@ static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, blo ...@@ -208,12 +208,11 @@ static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, blo
} }
/**************************************************************************** /****************************************************************************
* Announce handler mess * Announce handler
****************************************************************************/ ****************************************************************************/
VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *, const char *, const char *, const char *, announce_method_t* ) ); VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *, const char *, const char *, const char *, announce_method_t* ) );
VLC_EXPORT( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) ); VLC_EXPORT( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) );
VLC_EXPORT(void, sout_AnnounceSessionDestroy, (session_descriptor_t *) );
VLC_EXPORT(announce_method_t*, sout_SAPMethod, (void) ); VLC_EXPORT(announce_method_t*, sout_SAPMethod, (void) );
VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) ); VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) );
......
...@@ -1196,25 +1196,24 @@ static int SapSetup( sout_stream_t *p_stream ) ...@@ -1196,25 +1196,24 @@ static int SapSetup( sout_stream_t *p_stream )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout; sout_instance_t *p_sout = p_stream->p_sout;
announce_method_t *p_method = sout_SAPMethod();
/* Remove the previous session */ /* Remove the previous session */
if( p_sys->p_session != NULL) if( p_sys->p_session != NULL)
{ {
sout_AnnounceUnRegister( p_sout, p_sys->p_session); sout_AnnounceUnRegister( p_sout, p_sys->p_session);
sout_AnnounceSessionDestroy( p_sys->p_session );
p_sys->p_session = NULL; p_sys->p_session = NULL;
} }
if( ( p_sys->i_es > 0 || p_sys->p_mux ) && p_sys->psz_sdp && *p_sys->psz_sdp ) if( ( p_sys->i_es > 0 || p_sys->p_mux ) && p_sys->psz_sdp && *p_sys->psz_sdp )
{ {
announce_method_t *p_method = sout_SAPMethod();
p_sys->p_session = sout_AnnounceRegisterSDP( p_sout, SOUT_CFG_PREFIX, p_sys->p_session = sout_AnnounceRegisterSDP( p_sout, SOUT_CFG_PREFIX,
p_sys->psz_sdp, p_sys->psz_sdp,
p_sys->psz_destination, p_sys->psz_destination,
p_method ); p_method );
sout_MethodRelease( p_method );
} }
sout_MethodRelease( p_method );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -408,10 +408,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -408,10 +408,7 @@ static void Close( vlc_object_t * p_this )
sout_access_out_t *p_access = p_sys->p_mux->p_access; sout_access_out_t *p_access = p_sys->p_mux->p_access;
if( p_sys->p_session != NULL ) if( p_sys->p_session != NULL )
{
sout_AnnounceUnRegister( p_stream->p_sout, p_sys->p_session ); sout_AnnounceUnRegister( p_stream->p_sout, 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 );
......
...@@ -265,7 +265,6 @@ sout_AccessOutRead ...@@ -265,7 +265,6 @@ sout_AccessOutRead
sout_AccessOutSeek sout_AccessOutSeek
sout_AccessOutWrite sout_AccessOutWrite
sout_AnnounceRegisterSDP sout_AnnounceRegisterSDP
sout_AnnounceSessionDestroy
sout_AnnounceUnRegister sout_AnnounceUnRegister
sout_MuxAddStream sout_MuxAddStream
sout_MuxDelete sout_MuxDelete
......
...@@ -46,29 +46,18 @@ struct announce_method_t ...@@ -46,29 +46,18 @@ struct announce_method_t
* Sout-side functions * Sout-side functions
****************************************************************************/ ****************************************************************************/
/**
* Create and initialize a session descriptor
*
* \return a new session descriptor
*/
static session_descriptor_t * sout_AnnounceSessionCreate (vlc_object_t *obj,
const char *cfgpref)
{
return calloc (1, sizeof (session_descriptor_t));
}
/** /**
* Register a new session with the announce handler, using a pregenerated SDP * Register a new session with the announce handler, using a pregenerated SDP
* *
* \param p_sout a sout instance structure * \param p_sout a sout instance structure
* \param psz_sdp the SDP to register * \param psz_sdp the SDP to register
* \param psz_uri session address (needed for SAP address auto detection) * \param psz_dst session address (needed for SAP address auto detection)
* \param p_method an announce method descriptor * \param p_method an announce method descriptor
* \return the new session descriptor structure * \return the new session descriptor structure
*/ */
session_descriptor_t * session_descriptor_t *
sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref, sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref,
const char *psz_sdp, const char *psz_uri, const char *psz_sdp, const char *psz_dst,
announce_method_t *p_method ) announce_method_t *p_method )
{ {
session_descriptor_t *p_session; session_descriptor_t *p_session;
...@@ -88,12 +77,13 @@ sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref, ...@@ -88,12 +77,13 @@ sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref,
vlc_object_yield( p_announce ); vlc_object_yield( p_announce );
} }
p_session = sout_AnnounceSessionCreate(VLC_OBJECT (p_sout), cfgpref); p_session = malloc( sizeof( *p_session ) );
memset( p_session, 0, sizeof( *p_session ) );
p_session->psz_sdp = strdup( psz_sdp ); p_session->psz_sdp = strdup( psz_sdp );
/* GRUIK. We should not convert back-and-forth from string to numbers */ /* GRUIK. We should not convert back-and-forth from string to numbers */
struct addrinfo *res; struct addrinfo *res;
if (vlc_getaddrinfo (VLC_OBJECT (p_sout), psz_uri, 0, NULL, &res) == 0) if (vlc_getaddrinfo (VLC_OBJECT (p_sout), psz_dst, 0, NULL, &res) == 0)
{ {
if (res->ai_addrlen <= sizeof (p_session->addr)) if (res->ai_addrlen <= sizeof (p_session->addr))
memcpy (&p_session->addr, res->ai_addr, memcpy (&p_session->addr, res->ai_addr,
...@@ -128,23 +118,14 @@ int sout_AnnounceUnRegister( sout_instance_t *p_sout, ...@@ -128,23 +118,14 @@ int sout_AnnounceUnRegister( sout_instance_t *p_sout,
return VLC_ENOOBJ; return VLC_ENOOBJ;
} }
i_ret = announce_UnRegister( p_announce, p_session ); i_ret = announce_UnRegister( p_announce, p_session );
if( i_ret == 0 )
free( p_session );
vlc_object_release( p_announce ); vlc_object_release( p_announce );
return i_ret; return i_ret;
} }
/**
* Destroy a session descriptor and free all
*
* \param p_session the session to destroy
* \return Nothing
*/
void sout_AnnounceSessionDestroy( session_descriptor_t *p_session )
{
free( p_session );
}
/** /**
* \return the SAP announce method * \return the SAP announce method
*/ */
......
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