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

SD: remove psz_module parameter, shorter function names

parent c4877da8
...@@ -43,7 +43,6 @@ extern "C" { ...@@ -43,7 +43,6 @@ extern "C" {
struct services_discovery_t struct services_discovery_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
char * psz_module;
module_t * p_module; module_t * p_module;
vlc_event_manager_t event_manager; /* Accessed through Setters for non class function */ vlc_event_manager_t event_manager; /* Accessed through Setters for non class function */
...@@ -62,14 +61,19 @@ VLC_EXPORT( char **, __services_discovery_GetServicesNames, ( vlc_object_t * p_s ...@@ -62,14 +61,19 @@ VLC_EXPORT( char **, __services_discovery_GetServicesNames, ( vlc_object_t * p_s
__services_discovery_GetServicesNames(VLC_OBJECT(a),b) __services_discovery_GetServicesNames(VLC_OBJECT(a),b)
/* Creation of a service_discovery object */ /* Creation of a service_discovery object */
VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) ); VLC_EXPORT( services_discovery_t *, vlc_sd_Create, ( vlc_object_t * ) );
VLC_EXPORT( bool, services_discovery_Start, ( services_discovery_t * p_this ) ); VLC_EXPORT( bool, vlc_sd_Start, ( services_discovery_t *, const char * ) );
VLC_EXPORT( void, services_discovery_Stop, ( services_discovery_t * p_this ) ); VLC_EXPORT( void, vlc_sd_Stop, ( services_discovery_t * ) );
static inline void services_discovery_StopAndRelease( services_discovery_t * p_this ) static inline void vlc_sd_Destroy( services_discovery_t *p_sd )
{ {
services_discovery_Stop( p_this ); vlc_object_release( VLC_OBJECT(p_sd) );
vlc_object_release( p_this ); }
static inline void vlc_sd_StopAndDestroy( services_discovery_t * p_this )
{
vlc_sd_Stop( p_this );
vlc_sd_Destroy( p_this );
} }
/* Read info from discovery object */ /* Read info from discovery object */
......
...@@ -174,7 +174,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, ...@@ -174,7 +174,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
libvlc_event_manager_register_event_type( p_mdis->p_event_manager, libvlc_event_manager_register_event_type( p_mdis->p_event_manager,
libvlc_MediaDiscovererEnded, NULL ); libvlc_MediaDiscovererEnded, NULL );
p_mdis->p_sd = services_discovery_Create( (vlc_object_t*)p_inst->p_libvlc_int, psz_name ); p_mdis->p_sd = vlc_sd_Create( (vlc_object_t*)p_inst->p_libvlc_int );
if( !p_mdis->p_sd ) if( !p_mdis->p_sd )
{ {
...@@ -202,8 +202,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, ...@@ -202,8 +202,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
p_mdis ); p_mdis );
/* Here we go */ /* Here we go */
bool ret = services_discovery_Start( p_mdis->p_sd ); if( !vlc_sd_Start( p_mdis->p_sd, psz_name ) )
if(!ret)
{ {
libvlc_media_list_release( p_mdis->p_mlist ); libvlc_media_list_release( p_mdis->p_mlist );
libvlc_exception_raise( p_e, "Can't start the services_discovery module named '%s'", psz_name ); libvlc_exception_raise( p_e, "Can't start the services_discovery module named '%s'", psz_name );
...@@ -223,7 +222,7 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis ) ...@@ -223,7 +222,7 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
int i; int i;
libvlc_media_list_release( p_mdis->p_mlist ); libvlc_media_list_release( p_mdis->p_mlist );
services_discovery_StopAndRelease( p_mdis->p_sd ); vlc_sd_StopAndDestroy( p_mdis->p_sd );
/* Free catname_to_submedialist and all the mlist */ /* Free catname_to_submedialist and all the mlist */
char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist ); char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist );
......
...@@ -317,13 +317,10 @@ sdp_AddAttribute ...@@ -317,13 +317,10 @@ sdp_AddAttribute
sdp_AddMedia sdp_AddMedia
secstotimestr secstotimestr
services_discovery_AddItem services_discovery_AddItem
services_discovery_Create
services_discovery_EventManager services_discovery_EventManager
services_discovery_GetLocalizedName services_discovery_GetLocalizedName
__services_discovery_GetServicesNames __services_discovery_GetServicesNames
services_discovery_RemoveItem services_discovery_RemoveItem
services_discovery_Start
services_discovery_Stop
sout_AccessOutControl sout_AccessOutControl
sout_AccessOutDelete sout_AccessOutDelete
sout_AccessOutNew sout_AccessOutNew
...@@ -496,7 +493,10 @@ vlc_poll ...@@ -496,7 +493,10 @@ vlc_poll
vlc_rand_bytes vlc_rand_bytes
vlc_recvmsg vlc_recvmsg
vlc_release vlc_release
vlc_sd_Create
vlc_sdp_Start vlc_sdp_Start
vlc_sd_Start
vlc_sd_Stop
vlc_sendmsg vlc_sendmsg
vlc_strcasestr vlc_strcasestr
vlc_strlcpy vlc_strlcpy
......
...@@ -55,18 +55,15 @@ char ** __services_discovery_GetServicesNames( vlc_object_t * p_super, ...@@ -55,18 +55,15 @@ char ** __services_discovery_GetServicesNames( vlc_object_t * p_super,
/*********************************************************************** /***********************************************************************
* Create * Create
***********************************************************************/ ***********************************************************************/
services_discovery_t * services_discovery_t *vlc_sd_Create( vlc_object_t *p_super )
services_discovery_Create ( vlc_object_t * p_super, const char * psz_module_name )
{ {
services_discovery_t *p_sd; services_discovery_t *p_sd;
assert( psz_module_name );
p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), VLC_OBJECT_GENERIC, p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), VLC_OBJECT_GENERIC,
"services discovery" ); "services discovery" );
if( !p_sd ) if( !p_sd )
return NULL; return NULL;
p_sd->psz_module = strdup( psz_module_name );
vlc_event_manager_init( &p_sd->event_manager, p_sd, (vlc_object_t *)p_sd ); vlc_event_manager_init( &p_sd->event_manager, p_sd, (vlc_object_t *)p_sd );
vlc_event_manager_register_event_type( &p_sd->event_manager, vlc_event_manager_register_event_type( &p_sd->event_manager,
vlc_ServicesDiscoveryItemAdded ); vlc_ServicesDiscoveryItemAdded );
...@@ -97,11 +94,11 @@ static void ObjectKillChildrens( vlc_object_t *p_obj ) ...@@ -97,11 +94,11 @@ static void ObjectKillChildrens( vlc_object_t *p_obj )
/*********************************************************************** /***********************************************************************
* Stop * Stop
***********************************************************************/ ***********************************************************************/
bool services_discovery_Start ( services_discovery_t * p_sd ) bool vlc_sd_Start ( services_discovery_t * p_sd, const char *module )
{ {
assert(!p_sd->p_module); assert(!p_sd->p_module);
p_sd->p_module = module_need( p_sd, "services_discovery", p_sd->psz_module, true ); p_sd->p_module = module_need( p_sd, "services_discovery", module, true );
if( p_sd->p_module == NULL ) if( p_sd->p_module == NULL )
{ {
...@@ -119,7 +116,7 @@ bool services_discovery_Start ( services_discovery_t * p_sd ) ...@@ -119,7 +116,7 @@ bool services_discovery_Start ( services_discovery_t * p_sd )
/*********************************************************************** /***********************************************************************
* Stop * Stop
***********************************************************************/ ***********************************************************************/
void services_discovery_Stop ( services_discovery_t * p_sd ) void vlc_sd_Stop ( services_discovery_t * p_sd )
{ {
vlc_event_t event = { vlc_event_t event = {
.type = vlc_ServicesDiscoveryEnded .type = vlc_ServicesDiscoveryEnded
...@@ -141,7 +138,6 @@ static void services_discovery_Destructor ( services_discovery_t * p_sd ) ...@@ -141,7 +138,6 @@ static void services_discovery_Destructor ( services_discovery_t * p_sd )
assert(!p_sd->p_module); /* Forgot to call Stop */ assert(!p_sd->p_module); /* Forgot to call Stop */
vlc_event_manager_fini( &p_sd->event_manager ); vlc_event_manager_fini( &p_sd->event_manager );
free( p_sd->psz_module );
vlc_object_release( p_sd ); vlc_object_release( p_sd );
} }
...@@ -261,7 +257,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d ...@@ -261,7 +257,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
vlc_object_unlock( p_parent->p_playlist ); vlc_object_unlock( p_parent->p_playlist );
} }
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules ) int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules )
{ {
const char *psz_parser = psz_modules ?: ""; const char *psz_parser = psz_modules ?: "";
int retval = VLC_SUCCESS; int retval = VLC_SUCCESS;
...@@ -291,7 +287,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu ...@@ -291,7 +287,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
msg_Dbg( p_playlist, "Add services_discovery %s", psz_plugin ); msg_Dbg( p_playlist, "Add services_discovery %s", psz_plugin );
services_discovery_t *p_sd; services_discovery_t *p_sd;
p_sd = services_discovery_Create( (vlc_object_t*)p_playlist, psz_plugin ); p_sd = vlc_sd_Create( (vlc_object_t*)p_playlist );
if( !p_sd ) if( !p_sd )
continue; continue;
...@@ -315,10 +311,9 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu ...@@ -315,10 +311,9 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
playlist_sd_item_removed, playlist_sd_item_removed,
p_cat ); p_cat );
bool ret = services_discovery_Start( p_sd ); if( !vlc_sd_Start( p_sd, psz_plugin ) )
if(!ret)
{ {
vlc_object_release( p_sd ); vlc_sd_Destroy( p_sd );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -351,7 +346,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu ...@@ -351,7 +346,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
} }
int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
const char *psz_module ) const char *psz_module )
{ {
struct playlist_services_discovery_support_t * p_sds = NULL; struct playlist_services_discovery_support_t * p_sds = NULL;
int i; int i;
...@@ -359,7 +354,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, ...@@ -359,7 +354,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
PL_LOCK; PL_LOCK;
for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ ) for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
{ {
if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) ) if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
{ {
p_sds = pl_priv(p_playlist)->pp_sds[i]; p_sds = pl_priv(p_playlist)->pp_sds[i];
REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i ); REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i );
...@@ -404,7 +399,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, ...@@ -404,7 +399,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
} }
PL_UNLOCK; PL_UNLOCK;
services_discovery_StopAndRelease( p_sds->p_sd ); vlc_sd_StopAndDestroy( p_sds->p_sd );
free( p_sds ); free( p_sds );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -418,7 +413,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist, ...@@ -418,7 +413,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ ) for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
{ {
if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) ) if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
{ {
PL_UNLOCK; PL_UNLOCK;
return true; return true;
...@@ -432,5 +427,5 @@ void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist ) ...@@ -432,5 +427,5 @@ void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist )
{ {
while( pl_priv(p_playlist)->i_sds > 0 ) while( pl_priv(p_playlist)->i_sds > 0 )
playlist_ServicesDiscoveryRemove( p_playlist, playlist_ServicesDiscoveryRemove( p_playlist,
pl_priv(p_playlist)->pp_sds[0]->p_sd->psz_module ); module_get_object( pl_priv(p_playlist)->pp_sds[0]->p_sd->p_module ) );
} }
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