mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-04 09:11:33 +02:00
Announce API simplification
This commit is contained in:
parent
d212179528
commit
979f5cc201
@ -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( 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(void, sout_MethodRelease, (announce_method_t *) );
|
||||
|
||||
|
@ -1196,25 +1196,24 @@ static int SapSetup( sout_stream_t *p_stream )
|
||||
{
|
||||
sout_stream_sys_t *p_sys = p_stream->p_sys;
|
||||
sout_instance_t *p_sout = p_stream->p_sout;
|
||||
announce_method_t *p_method = sout_SAPMethod();
|
||||
|
||||
/* Remove the previous session */
|
||||
if( p_sys->p_session != NULL)
|
||||
{
|
||||
sout_AnnounceUnRegister( p_sout, p_sys->p_session);
|
||||
sout_AnnounceSessionDestroy( p_sys->p_session );
|
||||
p_sys->p_session = NULL;
|
||||
}
|
||||
|
||||
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->psz_sdp,
|
||||
p_sys->psz_destination,
|
||||
p_method );
|
||||
sout_MethodRelease( p_method );
|
||||
}
|
||||
|
||||
sout_MethodRelease( p_method );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -408,10 +408,7 @@ static void Close( vlc_object_t * p_this )
|
||||
sout_access_out_t *p_access = p_sys->p_mux->p_access;
|
||||
|
||||
if( p_sys->p_session != NULL )
|
||||
{
|
||||
sout_AnnounceUnRegister( p_stream->p_sout, p_sys->p_session );
|
||||
sout_AnnounceSessionDestroy( p_sys->p_session );
|
||||
}
|
||||
|
||||
sout_MuxDelete( p_sys->p_mux );
|
||||
sout_AccessOutDelete( p_access );
|
||||
|
@ -265,7 +265,6 @@ sout_AccessOutRead
|
||||
sout_AccessOutSeek
|
||||
sout_AccessOutWrite
|
||||
sout_AnnounceRegisterSDP
|
||||
sout_AnnounceSessionDestroy
|
||||
sout_AnnounceUnRegister
|
||||
sout_MuxAddStream
|
||||
sout_MuxDelete
|
||||
|
@ -46,29 +46,18 @@ struct announce_method_t
|
||||
* 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
|
||||
*
|
||||
* \param p_sout a sout instance structure
|
||||
* \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
|
||||
* \return the new session descriptor structure
|
||||
*/
|
||||
session_descriptor_t *
|
||||
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 )
|
||||
{
|
||||
session_descriptor_t *p_session;
|
||||
@ -88,12 +77,13 @@ sout_AnnounceRegisterSDP( sout_instance_t *p_sout, const char *cfgpref,
|
||||
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 );
|
||||
|
||||
/* GRUIK. We should not convert back-and-forth from string to numbers */
|
||||
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))
|
||||
memcpy (&p_session->addr, res->ai_addr,
|
||||
@ -128,23 +118,14 @@ int sout_AnnounceUnRegister( sout_instance_t *p_sout,
|
||||
return VLC_ENOOBJ;
|
||||
}
|
||||
i_ret = announce_UnRegister( p_announce, p_session );
|
||||
if( i_ret == 0 )
|
||||
free( p_session );
|
||||
|
||||
vlc_object_release( p_announce );
|
||||
|
||||
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user