[vlc-devel] [PATCH 3/4] avahi: Prepare code for support of renderer discovery

Stefan Brüns stefan.bruens at rwth-aachen.de
Fri Dec 28 16:33:16 CET 2018


On Mittwoch, 26. Dezember 2018 09:03:58 CET you wrote:
> Le mercredi 26 décembre 2018, 04:21:42 EET Stefan Brüns a écrit :
> > Instead of passing the services_discovery_t as userdata for the callbacks,
> > use a struct (discovery_sys_t) which can be used regardless of the service
> > type (input or renderer).
> > ---
> > 
> >  modules/services_discovery/avahi.c | 83 ++++++++++++++++++------------
> >  1 file changed, 50 insertions(+), 33 deletions(-)
> > 
> > diff --git a/modules/services_discovery/avahi.c
> > b/modules/services_discovery/ avahi.c
> > index aa58c7f673..1ea60ab152 100644
> > --- a/modules/services_discovery/avahi.c
> > +++ b/modules/services_discovery/avahi.c
> > @@ -46,8 +46,8 @@
> > 
> > **************************************************************************
> > *
> > **/
> > 
> >  /* Callbacks */
> > 
> > -static int  Open ( vlc_object_t * );
> > -static void Close( vlc_object_t * );
> > +static int  OpenSD ( vlc_object_t * );
> > +static void CloseSD( vlc_object_t * );
> > 
> >  VLC_SD_PROBE_HELPER("avahi", N_("Zeroconf network services"), SD_CAT_LAN)
> > 
> > @@ -57,7 +57,7 @@ vlc_module_begin ()
> > 
> >      set_category( CAT_PLAYLIST )
> >      set_subcategory( SUBCAT_PLAYLIST_SD )
> >      set_capability( "services_discovery", 0 )
> > 
> > -    set_callbacks( Open, Close )
> > +    set_callbacks( OpenSD, CloseSD )
> > 
> >      add_shortcut( "mdns", "avahi" )
> >      
> >      VLC_SD_PROBE_SUBMODULE
> > 
> > @@ -72,7 +72,14 @@ typedef struct
> > 
> >      AvahiThreadedPoll   *poll;
> >      AvahiClient         *client;
> >      vlc_dictionary_t    services_name_to_input_item;
> > 
> > -} services_discovery_sys_t;
> > +    vlc_object_t        *parent;
> > +    bool                renderer;
> > +} discovery_sys_t;
> > +
> > +struct services_discovery_sys_t
> > +{
> > +    discovery_sys_t s;
> > +};
> 
> Uh, should there not be some SD-specific members there?

vlc_renderer_discovery_t and services_discovery_t both have a private data 
pointer called p_sys. Unfortunately, one has the type services_discovery_sys_t 
and the other one is vlc_renderer_discovery_t.

To avoid crosscasting the common userdata struct required for the avahi 
callbacks, the struct is embedded into both structs.

The same approach is used in the microdns implementation.

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034     mobile: +49 151 50412019
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20181228/8cd9053b/attachment.sig>


More information about the vlc-devel mailing list