[vlc-devel] [PATCH 5/7] input: Preparse: fetch sub items too

Thomas Guillem thomas at gllm.fr
Tue Jan 13 16:48:23 CET 2015



On Tue, Jan 13, 2015, at 13:23, Thomas Guillem wrote:
> 
> 
> On Tue, Jan 13, 2015, at 05:42, Rémi Denis-Courmont wrote:
> > Le 2015-01-08 20:10, Thomas Guillem a écrit :
> > > ---
> > >  src/input/input.c | 11 ++++++++++-
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/src/input/input.c b/src/input/input.c
> > > index 48e085d..b7634a8 100644
> > > --- a/src/input/input.c
> > > +++ b/src/input/input.c
> > > @@ -192,8 +192,17 @@ int input_Preparse( vlc_object_t *p_parent,
> > > input_item_t *p_item )
> > >      if( !p_input )
> > >          return VLC_EGENERIC;
> > >
> > > -    if( !Init( p_input ) )
> > > +    if( !Init( p_input ) ) {
> > > +        /* if the demux can have subitems, call Mainloop that will 
> > > call
> > > +         * demux_Demux in order to fetch sub items */
> > > +        bool b_can_have_sub_items = false;
> > > +        demux_Control( p_input->p->input.p_demux,
> > > +                       DEMUX_CAN_HAVE_SUB_ITEMS,
> > > +                       &b_can_have_sub_items );
> > > +        if( b_can_have_sub_items )
> > > +            MainLoop( p_input, false );
> > >          End( p_input );
> > > +    }
> > 
> > I may be missing some pre-existing magic. Otherwise will that not 
> > duplicate sub-items when the item gets "opened" after it has already 
> > been preparsed?
> 
> No you're right, I missed it.

If you open an item that had been preparsed, you'll receive
vlc_InputItemSubItemAdded and vlc_InputItemSubItemTreeAdded one more
time.

The vlc playlist handle it well: there are no duplicate items since the
preparsed item won't be opened again in the playlist thread if
input_Preparse had sent sub items (input_item_add_subitem_tree will be
called from input_Preparse and not from PlayItem in playlist/thread.c).

For libvlc, you can preparse an item only one time. But there will be
duplicate items if you play with the media_player a media that has been
preparsed. Maybe I can check for duplicate before sending libvlc events.

> 
> > 
> > Also how does that work if the item has both sub-items and elementary 
> > streams, or -more realistically- if it is not known at demux activation 
> > whether the item is a normal stream or a playlist, e.g. MP4...
> 
> I didn't know that case could happen.
> Do you have a sample with sub items and elementary streams ?

If it's not known at demux activation, you won't be able to get sub
items via input_Preparse (behavior not changed).

If a demux can have elementary streams, DEMUX_CAN_HAVE_SUB_ITEMS should
not return true because you don't want to call Mainloop and loop in
demux_Demux in input_Preparse.

So, maybe the DEMUX_CAN_HAVE_SUB_ITEMS name is not good.
It could be DEMUX_PREPARSE_NEED_DEMUX, DEMUX_IS_PLAYLIST, or
DEMUX_IS_PLAYLIST_OR_DIRECTORY. (dsm access is used by the directory
demux that is a playlist, so a directory is a playlist from vlc point of
view)


> 
> > 
> > >
> > >      vlc_object_release( p_input );
> > 
> > -- 
> > Rémi Denis-Courmont
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list