mirror of https://code.videolan.org/videolan/vlc
Input options inheritance for playlists
This commit is contained in:
parent
5f57cf5aa7
commit
4db1802cf6
2
TODO
2
TODO
|
@ -115,14 +115,12 @@ Think playlist within playlist, directory structures, SAP section, TV channels l
|
||||||
Todo:<br />
|
Todo:<br />
|
||||||
- Core support<br />
|
- Core support<br />
|
||||||
- *** Fix meta-information (author and duration)<br />
|
- *** Fix meta-information (author and duration)<br />
|
||||||
- ** input options inheritance (down nodes)<br />
|
|
||||||
- *** Improve random mode and fix loop<br />
|
- *** Improve random mode and fix loop<br />
|
||||||
- * "Name finder"<br />
|
- * "Name finder"<br />
|
||||||
- * "Protocol rollover" node<br />
|
- * "Protocol rollover" node<br />
|
||||||
- *** Item moving/copying facilities<br />
|
- *** Item moving/copying facilities<br />
|
||||||
- *** Live directory representation<br />
|
- *** Live directory representation<br />
|
||||||
- Helper modules<br />
|
- Helper modules<br />
|
||||||
- ** Strip path in subdirectories<br />
|
|
||||||
- ** ASX and B4S parsers (see below)<br />
|
- ** ASX and B4S parsers (see below)<br />
|
||||||
- * Rewrite SLP announce discovery<br />
|
- * Rewrite SLP announce discovery<br />
|
||||||
- ** Adapt CDDAX<br />
|
- ** Adapt CDDAX<br />
|
||||||
|
|
|
@ -88,6 +88,19 @@ static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
|
||||||
vlc_mutex_init( p_o, &p_i->lock );
|
vlc_mutex_init( p_o, &p_i->lock );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void vlc_input_item_CopyOptions( input_item_t *p_parent,
|
||||||
|
input_item_t *p_child )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for( i = 0 ; i< p_parent->i_options; i++ )
|
||||||
|
{
|
||||||
|
char *psz_option= strdup( p_parent->ppsz_options[i] );
|
||||||
|
INSERT_ELEM( p_child->ppsz_options,
|
||||||
|
p_child->i_options, p_child->i_options,
|
||||||
|
psz_option );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void vlc_input_item_Clean( input_item_t *p_i )
|
static inline void vlc_input_item_Clean( input_item_t *p_i )
|
||||||
{
|
{
|
||||||
if( p_i->psz_name ) free( p_i->psz_name );
|
if( p_i->psz_name ) free( p_i->psz_name );
|
||||||
|
|
|
@ -112,7 +112,9 @@ static int Demux( demux_t *p_demux )
|
||||||
char **ppsz_options = NULL;
|
char **ppsz_options = NULL;
|
||||||
int i_options = 0, i;
|
int i_options = 0, i;
|
||||||
|
|
||||||
playlist_item_t *p_item;
|
playlist_item_t *p_item, *p_current;
|
||||||
|
|
||||||
|
vlc_bool_t b_play;
|
||||||
|
|
||||||
vlc_bool_t b_cleanup = VLC_FALSE;
|
vlc_bool_t b_cleanup = VLC_FALSE;
|
||||||
|
|
||||||
|
@ -124,8 +126,12 @@ static int Demux( demux_t *p_demux )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_ItemToNode( p_playlist, p_playlist->status.p_item );
|
fprintf(stderr,"playlist item is %p\n", p_playlist->status.p_item );
|
||||||
p_playlist->status.p_item->input.i_type = ITEM_TYPE_PLAYLIST;
|
b_play = FindItem( p_demux, p_playlist, &p_current );
|
||||||
|
fprintf(stderr,"current is %p\n", p_current );
|
||||||
|
|
||||||
|
playlist_ItemToNode( p_playlist, p_current );
|
||||||
|
p_current->input.i_type = ITEM_TYPE_PLAYLIST;
|
||||||
|
|
||||||
psz_line = stream_ReadLine( p_demux->s );
|
psz_line = stream_ReadLine( p_demux->s );
|
||||||
while( psz_line )
|
while( psz_line )
|
||||||
|
@ -196,18 +202,17 @@ static int Demux( demux_t *p_demux )
|
||||||
p_item->input.i_duration = i_duration;
|
p_item->input.i_duration = i_duration;
|
||||||
|
|
||||||
playlist_NodeAddItem( p_playlist, p_item,
|
playlist_NodeAddItem( p_playlist, p_item,
|
||||||
p_playlist->status.p_item->pp_parents[0]->i_view,
|
p_current->pp_parents[0]->i_view,
|
||||||
p_playlist->status.p_item, PLAYLIST_APPEND,
|
p_current, PLAYLIST_APPEND,
|
||||||
PLAYLIST_END );
|
PLAYLIST_END );
|
||||||
|
|
||||||
/* We need to declare the parents of the node as the
|
/* We need to declare the parents of the node as the
|
||||||
* * same of the parent's ones */
|
* * same of the parent's ones */
|
||||||
for( i= 1 ; i< p_playlist->status.p_item->i_parents; i ++ )
|
playlist_CopyParents( p_current, p_item );
|
||||||
{
|
|
||||||
playlist_ItemAddParent( p_item,
|
vlc_input_item_CopyOptions( &p_current->input,
|
||||||
p_playlist->status.p_item->pp_parents[i]->i_view,
|
&p_item->input );
|
||||||
p_playlist->status.p_item );
|
|
||||||
}
|
|
||||||
free( psz_mrl );
|
free( psz_mrl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +238,12 @@ static int Demux( demux_t *p_demux )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go back and play the playlist */
|
/* Go back and play the playlist */
|
||||||
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_playlist->status.i_view,
|
if( b_play )
|
||||||
p_playlist->status.p_item, NULL );
|
{
|
||||||
|
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
|
||||||
|
p_playlist->status.i_view,
|
||||||
|
p_playlist->status.p_item, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
vlc_object_release( p_playlist );
|
vlc_object_release( p_playlist );
|
||||||
return VLC_SUCCESS;
|
return VLC_SUCCESS;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#include <vlc/vlc.h>
|
#include <vlc/vlc.h>
|
||||||
#include <vlc/input.h>
|
#include <vlc/input.h>
|
||||||
|
#include <vlc_playlist.h>
|
||||||
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
|
|
||||||
|
@ -102,3 +103,29 @@ char *ProcessMRL( char *psz_mrl, char *psz_prefix )
|
||||||
asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
|
asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
|
||||||
return psz_mrl;
|
return psz_mrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vlc_bool_t FindItem( demux_t *p_demux, playlist_t *p_playlist,
|
||||||
|
playlist_item_t **pp_item )
|
||||||
|
{
|
||||||
|
vlc_bool_t b_play;
|
||||||
|
if( &p_playlist->status.p_item->input ==
|
||||||
|
((input_thread_t *)p_demux->p_parent)->input.p_item )
|
||||||
|
{
|
||||||
|
msg_Dbg( p_playlist, "starting playlist playback" );
|
||||||
|
*pp_item = p_playlist->status.p_item;
|
||||||
|
b_play = VLC_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)->
|
||||||
|
input.p_item;
|
||||||
|
*pp_item = playlist_ItemGetByInput( p_playlist, p_current );
|
||||||
|
if( !*pp_item )
|
||||||
|
{
|
||||||
|
msg_Dbg( p_playlist, "unable to find item in playlist");
|
||||||
|
}
|
||||||
|
msg_Dbg( p_playlist, "not starting playlist playback");
|
||||||
|
b_play = VLC_FALSE;
|
||||||
|
}
|
||||||
|
return b_play;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
char *ProcessMRL( char *, char * );
|
char *ProcessMRL( char *, char * );
|
||||||
char *FindPrefix( demux_t * );
|
char *FindPrefix( demux_t * );
|
||||||
|
|
||||||
|
vlc_bool_t FindItem( demux_t *, playlist_t *, playlist_item_t **);
|
||||||
|
|
||||||
int Import_Old ( vlc_object_t * );
|
int Import_Old ( vlc_object_t * );
|
||||||
int Import_M3U ( vlc_object_t * );
|
int Import_M3U ( vlc_object_t * );
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ void Close_PLS( vlc_object_t *p_this )
|
||||||
static int Demux( demux_t *p_demux )
|
static int Demux( demux_t *p_demux )
|
||||||
{
|
{
|
||||||
mtime_t i_duration = -1;
|
mtime_t i_duration = -1;
|
||||||
char *psz_name = NULL;
|
char *psz_name = NULL;
|
||||||
char *psz_line;
|
char *psz_line;
|
||||||
char *psz_mrl = NULL;
|
char *psz_mrl = NULL;
|
||||||
char *psz_key;
|
char *psz_key;
|
||||||
|
@ -119,6 +119,7 @@ static int Demux( demux_t *p_demux )
|
||||||
int i_new_item = 0;
|
int i_new_item = 0;
|
||||||
int i_key_length;
|
int i_key_length;
|
||||||
playlist_item_t *p_parent;
|
playlist_item_t *p_parent;
|
||||||
|
vlc_bool_t b_play;
|
||||||
|
|
||||||
p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
|
p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
|
||||||
FIND_PARENT );
|
FIND_PARENT );
|
||||||
|
@ -127,15 +128,16 @@ static int Demux( demux_t *p_demux )
|
||||||
msg_Err( p_demux, "can't find playlist" );
|
msg_Err( p_demux, "can't find playlist" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p_parent = p_playlist->status.p_item;
|
|
||||||
|
b_play = FindItem( p_demux, p_playlist, p_parent );
|
||||||
p_parent->input.i_type = ITEM_TYPE_PLAYLIST;
|
p_parent->input.i_type = ITEM_TYPE_PLAYLIST;
|
||||||
|
|
||||||
// p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
|
/* Change the item to a node */
|
||||||
/* Change the item to a node */
|
if( p_parent->i_children == -1)
|
||||||
if( p_parent->i_children == -1)
|
{
|
||||||
{
|
playlist_ItemToNode( p_playlist,p_parent );
|
||||||
playlist_ItemToNode( p_playlist,p_parent );
|
}
|
||||||
}
|
|
||||||
while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
|
while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
|
||||||
{
|
{
|
||||||
if( !strncasecmp( psz_line, "[playlist]", sizeof("[playlist]")-1 ) )
|
if( !strncasecmp( psz_line, "[playlist]", sizeof("[playlist]")-1 ) )
|
||||||
|
@ -193,12 +195,12 @@ static int Demux( demux_t *p_demux )
|
||||||
{
|
{
|
||||||
playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
|
playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
|
||||||
psz_name );
|
psz_name );
|
||||||
|
|
||||||
playlist_NodeAddItem( p_playlist,p_item,
|
playlist_NodeAddItem( p_playlist,p_item,
|
||||||
p_parent->pp_parents[0]->i_view,
|
p_parent->pp_parents[0]->i_view,
|
||||||
p_parent,
|
p_parent,
|
||||||
PLAYLIST_APPEND, PLAYLIST_END );
|
PLAYLIST_APPEND, PLAYLIST_END );
|
||||||
|
|
||||||
playlist_CopyParents( p_parent, p_item );
|
playlist_CopyParents( p_parent, p_item );
|
||||||
if( i_duration != -1 )
|
if( i_duration != -1 )
|
||||||
{
|
{
|
||||||
|
@ -207,6 +209,9 @@ static int Demux( demux_t *p_demux )
|
||||||
i_position++;
|
i_position++;
|
||||||
free( psz_mrl );
|
free( psz_mrl );
|
||||||
psz_mrl = NULL;
|
psz_mrl = NULL;
|
||||||
|
|
||||||
|
vlc_input_item_CopyOptions( &p_parent->input,
|
||||||
|
&p_item->input );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -248,12 +253,12 @@ static int Demux( demux_t *p_demux )
|
||||||
{
|
{
|
||||||
playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
|
playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
|
||||||
psz_name );
|
psz_name );
|
||||||
|
|
||||||
playlist_NodeAddItem( p_playlist,p_item,
|
playlist_NodeAddItem( p_playlist,p_item,
|
||||||
p_parent->pp_parents[0]->i_view,
|
p_parent->pp_parents[0]->i_view,
|
||||||
p_parent,
|
p_parent,
|
||||||
PLAYLIST_APPEND, PLAYLIST_END );
|
PLAYLIST_APPEND, PLAYLIST_END );
|
||||||
|
|
||||||
playlist_CopyParents( p_parent, p_item );
|
playlist_CopyParents( p_parent, p_item );
|
||||||
if( i_duration != -1 )
|
if( i_duration != -1 )
|
||||||
{
|
{
|
||||||
|
@ -261,6 +266,9 @@ static int Demux( demux_t *p_demux )
|
||||||
}
|
}
|
||||||
free( psz_mrl );
|
free( psz_mrl );
|
||||||
psz_mrl = NULL;
|
psz_mrl = NULL;
|
||||||
|
|
||||||
|
vlc_input_item_CopyOptions( &p_parent->input,
|
||||||
|
&p_item->input );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -272,8 +280,12 @@ static int Demux( demux_t *p_demux )
|
||||||
psz_name = NULL;
|
psz_name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,p_playlist->status.i_view,
|
if( b_play )
|
||||||
p_playlist->status.p_item, NULL );
|
{
|
||||||
|
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
|
||||||
|
p_playlist->status.i_view,
|
||||||
|
p_playlist->status.p_item, NULL );
|
||||||
|
}
|
||||||
vlc_object_release( p_playlist );
|
vlc_object_release( p_playlist );
|
||||||
return VLC_SUCCESS;
|
return VLC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue