Commit fa7924ac authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

lib: change libvlc_media_discoverer_t creation

libvlc_media_discoverer_new_from_name was creating a services_discovery_t and
was starting it, so libvlc_MediaDiscovererStarted event (or any other events)
could not be received.

To fix that, Split libvlc_media_discoverer_new_from_name into
libvlc_media_discoverer_new and libvlc_media_discoverer_start. That way, we can
attach events between create and start.

libvlc_media_discoverer_new_from_name is now deprecated, but it still works
like before.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent e5de71d0
......@@ -78,6 +78,12 @@ Qt interface:
Skins2:
* Support key accelerators
libVLC:
* split of libvlc_media_discoverer_new_from_name into libvlc_media_discoverer_new,
libvlc_media_discoverer_new and libvlc_media_discoverer_start.
This allows to attach media events between create and start.
Changes between 2.1.x and 2.2.0:
--------------------------------
......
......@@ -48,15 +48,61 @@ extern "C" {
typedef struct libvlc_media_discoverer_t libvlc_media_discoverer_t;
/**
* Discover media service by name.
* \deprecated Use libvlc_media_discoverer_new() and libvlc_media_discoverer_start().
*/
LIBVLC_DEPRECATED LIBVLC_API libvlc_media_discoverer_t *
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
const char * psz_name );
/**
* Create a media discoverer object by name.
*
* After this object is created, you should attach to events in order to be
* notified of the discoverer state.
* You should also attach to media_list events in order to be notified of new
* items discovered.
*
* You need to call libvlc_media_discoverer_start() in order to start the
* discovery.
*
* \see libvlc_media_discoverer_media_list
* \see libvlc_media_discoverer_event_manager
* \see libvlc_media_discoverer_start
*
* \param p_inst libvlc instance
* \param psz_name service name
* \return media discover object or NULL in case of error
* \version LibVLC 3.0.0 or later
*/
LIBVLC_API libvlc_media_discoverer_t *
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
const char * psz_name );
libvlc_media_discoverer_new( libvlc_instance_t * p_inst,
const char * psz_name );
/**
* Start media discovery.
*
* To stop it, call libvlc_media_discoverer_stop() or
* libvlc_media_discoverer_release() directly.
*
* \see libvlc_media_discoverer_stop
*
* \param p_mdis media discover object
* \return -1 in case of error, 0 otherwise
* \version LibVLC 3.0.0 or later
*/
LIBVLC_API int
libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis );
/**
* Stop media discovery.
*
* \see libvlc_media_discoverer_start
*
* \param p_mdis media discover object
* \version LibVLC 3.0.0 or later
*/
LIBVLC_API void
libvlc_media_discoverer_stop( libvlc_media_discoverer_t * p_mdis );
/**
* Release media discover object. If the reference count reaches 0, then
......
......@@ -76,8 +76,11 @@ libvlc_media_discoverer_event_manager
libvlc_media_discoverer_is_running
libvlc_media_discoverer_localized_name
libvlc_media_discoverer_media_list
libvlc_media_discoverer_new
libvlc_media_discoverer_new_from_name
libvlc_media_discoverer_release
libvlc_media_discoverer_start
libvlc_media_discoverer_stop
libvlc_media_duplicate
libvlc_media_event_manager
libvlc_media_get_duration
......
......@@ -181,12 +181,9 @@ static void services_discovery_ended( const vlc_event_t * p_event,
/**************************************************************************
* new (Public)
*
* Init an object.
**************************************************************************/
libvlc_media_discoverer_t *
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
const char * psz_name )
libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name )
{
/* podcast SD is a hack and only works with custom playlist callbacks. */
if( !strncasecmp( psz_name, "podcast", 7 ) )
......@@ -250,14 +247,45 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
services_discovery_removeall,
p_mdis );
return p_mdis;
}
/**************************************************************************
* start (Public)
**************************************************************************/
LIBVLC_API int
libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis )
{
/* Here we go */
if( !vlc_sd_Start( p_mdis->p_sd ) )
return vlc_sd_Start( p_mdis->p_sd ) ? 0 : -1;
}
/**************************************************************************
* stop (Public)
**************************************************************************/
LIBVLC_API void
libvlc_media_discoverer_stop( libvlc_media_discoverer_t * p_mdis )
{
return vlc_sd_Stop( p_mdis->p_sd );
}
/**************************************************************************
* new_from_name (Public)
*
* \deprecated Use libvlc_media_discoverer_new and libvlc_media_discoverer_start
**************************************************************************/
libvlc_media_discoverer_t *
libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
const char * psz_name )
{
libvlc_media_discoverer_t *p_mdis = libvlc_media_discoverer_new( p_inst, psz_name );
if( !p_mdis )
return NULL;
if( libvlc_media_discoverer_start( p_mdis ) != 0)
{
libvlc_printerr( "%s: internal module error",
p_mdis->p_sd->psz_name );
libvlc_media_list_release( p_mdis->p_mlist );
libvlc_event_manager_release( p_mdis->p_event_manager );
free( p_mdis );
libvlc_media_discoverer_release( p_mdis );
return NULL;
}
......@@ -295,7 +323,10 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
libvlc_media_list_release( p_mdis->p_mlist );
vlc_sd_StopAndDestroy( p_mdis->p_sd );
if( p_mdis->running )
vlc_sd_Stop( p_mdis->p_sd );
vlc_sd_Destroy( p_mdis->p_sd );
/* Free catname_to_submedialist and all the mlist */
char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist );
......
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