Commit f3c6bbcc authored by Clément Stenac's avatar Clément Stenac

Some infrastructure work for playlist autoload/autosave

parent 3c47829f
...@@ -352,7 +352,7 @@ VLC_EXPORT( int, playlist_NodeSort, ( playlist_t *, playlist_item_t *,int, int ...@@ -352,7 +352,7 @@ VLC_EXPORT( int, playlist_NodeSort, ( playlist_t *, playlist_item_t *,int, int
VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) ); VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
/* Load/Save */ /* Load/Save */
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char * ) ); VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char *, playlist_item_t *, vlc_bool_t ) );
VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, playlist_item_t *, const char * ) ); VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, playlist_item_t *, const char * ) );
/*********************************************************************** /***********************************************************************
......
...@@ -312,7 +312,7 @@ struct module_symbols_t ...@@ -312,7 +312,7 @@ struct module_symbols_t
int (*playlist_NodeGroup_inner) (playlist_t *, playlist_item_t *,playlist_item_t **,int, int, int); int (*playlist_NodeGroup_inner) (playlist_t *, playlist_item_t *,playlist_item_t **,int, int, int);
int (*playlist_NodeSort_inner) (playlist_t *, playlist_item_t *,int, int); int (*playlist_NodeSort_inner) (playlist_t *, playlist_item_t *,int, int);
int (*playlist_RecursiveNodeSort_inner) (playlist_t *, playlist_item_t *,int, int); int (*playlist_RecursiveNodeSort_inner) (playlist_t *, playlist_item_t *,int, int);
int (*playlist_Import_inner) (playlist_t *, const char *); int (*playlist_Import_inner) (playlist_t *, const char *, playlist_item_t *, vlc_bool_t);
int (*playlist_Export_inner) (playlist_t *, const char *, playlist_item_t *, const char *); int (*playlist_Export_inner) (playlist_t *, const char *, playlist_item_t *, const char *);
spu_t * (*__spu_Create_inner) (vlc_object_t *); spu_t * (*__spu_Create_inner) (vlc_object_t *);
int (*spu_Init_inner) (spu_t *); int (*spu_Init_inner) (spu_t *);
...@@ -517,6 +517,8 @@ struct module_symbols_t ...@@ -517,6 +517,8 @@ struct module_symbols_t
void *stats_TimerClean_deprecated; void *stats_TimerClean_deprecated;
void *stats_TimersClean_deprecated; void *stats_TimersClean_deprecated;
void (*__stats_TimersClean_inner) (vlc_object_t *); void (*__stats_TimersClean_inner) (vlc_object_t *);
void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float);
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -984,6 +986,8 @@ struct module_symbols_t ...@@ -984,6 +986,8 @@ struct module_symbols_t
# define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner # define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner
# define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner # define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner
# define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner # define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner
# define __intf_IntfProgressUpdate (p_symbols)->__intf_IntfProgressUpdate_inner
# define __intf_IntfProgress (p_symbols)->__intf_IntfProgress_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/****************************************************************** /******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...@@ -1454,6 +1458,8 @@ struct module_symbols_t ...@@ -1454,6 +1458,8 @@ struct module_symbols_t
((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \ ((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \
((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \ ((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \
((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \ ((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \
((p_symbols)->__intf_IntfProgressUpdate_inner) = __intf_IntfProgressUpdate; \
((p_symbols)->__intf_IntfProgress_inner) = __intf_IntfProgress; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
(p_symbols)->playlist_ItemAddParent_deprecated = NULL; \ (p_symbols)->playlist_ItemAddParent_deprecated = NULL; \
......
...@@ -1280,6 +1280,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1280,6 +1280,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
} }
else if( !strcmp( psz_cmd, "playlist" ) ) else if( !strcmp( psz_cmd, "playlist" ) )
{ {
playlist_Import( p_playlist, "/home/zorglub/vlc-trunk/foo.xspf",
p_playlist->p_ml_category, VLC_FALSE );
playlist_NodeDump( p_playlist, p_playlist->p_root_category, 0 ); playlist_NodeDump( p_playlist, p_playlist->p_root_category, 0 );
playlist_NodeDump( p_playlist, p_playlist->p_root_onelevel, 0 ); playlist_NodeDump( p_playlist, p_playlist->p_root_onelevel, 0 );
} }
......
...@@ -486,10 +486,10 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE ...@@ -486,10 +486,10 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
{ {
FREE_ATT(); FREE_ATT();
/* Add it */ /* Add it */
/*playlist_AddWhereverNeeded( p_playlist, p_new_input, playlist_AddWhereverNeeded( p_playlist, p_new_input,
p_item, p_demux->p_sys->p_item_in_category, p_item, p_demux->p_sys->p_item_in_category,
(p_demux->p_sys->i_parent_id >0 ) ? VLC_TRUE: (p_demux->p_sys->i_parent_id >0 ) ? VLC_TRUE:
VLC_FALSE, PLAYLIST_APPEND );*/ VLC_FALSE, PLAYLIST_APPEND );
if( p_demux->p_sys->i_identifier < if( p_demux->p_sys->i_identifier <
p_demux->p_sys->i_tracklist_entries ) p_demux->p_sys->i_tracklist_entries )
{ {
......
...@@ -277,6 +277,7 @@ int playlist_BothAddInput( playlist_t *p_playlist, ...@@ -277,6 +277,7 @@ int playlist_BothAddInput( playlist_t *p_playlist,
AddItem( p_playlist, p_item_cat, p_direct_parent, i_pos ); AddItem( p_playlist, p_item_cat, p_direct_parent, i_pos );
/* Add to onelevel */ /* Add to onelevel */
/** \todo make a faster case for ml import */
p_item_one = playlist_ItemNewFromInput( p_playlist, p_input ); p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
if( p_item_one == NULL ) return VLC_EGENERIC; if( p_item_one == NULL ) return VLC_EGENERIC;
...@@ -389,6 +390,10 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist, ...@@ -389,6 +390,10 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
* useful for later BothAddInput ) * useful for later BothAddInput )
*/ */
/* Fast track the media library, no time to loose */
if( p_item == p_playlist->p_ml_category )
return p_item;
/** \todo First look if we don't already have it */ /** \todo First look if we don't already have it */
playlist_item_t *p_item_in_category = playlist_ItemFindFromInputAndRoot( playlist_item_t *p_item_in_category = playlist_ItemFindFromInputAndRoot(
p_playlist, p_item->p_input->i_id, p_playlist, p_item->p_input->i_id,
......
...@@ -36,42 +36,36 @@ ...@@ -36,42 +36,36 @@
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5" #define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
/** /**
* Import a certain playlist file into the library * Import a playlist file at a given point of a given view
* This file will get inserted as a new category
*
* XXX: TODO
* \param p_playlist the playlist to which the new items will be added * \param p_playlist the playlist to which the new items will be added
* \param psz_filename the name of the playlistfile to import * \param psz_filename the name of the playlistfile to import
* \return VLC_SUCCESS on success * \return VLC_SUCCESS on success
*/ */
int playlist_Import( playlist_t * p_playlist, const char *psz_filename ) int playlist_Import( playlist_t * p_playlist, const char *psz_filename,
playlist_item_t *p_root, vlc_bool_t b_only_there )
{ {
playlist_item_t *p_item; char *psz_uri, *psz_opt;
char *psz_uri; input_item_t *p_input;
int i_id;
asprintf( &psz_uri, "file/playlist://%s", psz_filename );
msg_Info( p_playlist, "clearing playlist"); p_input = input_ItemNewExt( p_playlist, psz_uri, "playlist", 0, NULL, -1 );
playlist_Clear( p_playlist ); if( b_only_there )
{
asprintf( &psz_opt, "parent-item=%i", p_root->i_id );
psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 ); vlc_input_item_AddOption( p_input, psz_opt );
sprintf( psz_uri, "file/playlist://%s", psz_filename); free( psz_opt );
}
i_id = playlist_PlaylistAdd( p_playlist, psz_uri, psz_uri, if( p_root == p_playlist->p_ml_category )
PLAYLIST_INSERT , PLAYLIST_END); p_input->i_id = p_playlist->p_ml_category->p_input->i_id;
input_Read( p_playlist, p_input, VLC_TRUE );
vlc_mutex_lock( &p_playlist->object_lock ); free( psz_uri );
p_item = playlist_ItemGetById( p_playlist, i_id );
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play(p_playlist);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/** /**
* Load a certain playlist file into the playlist * Load a playlist file to the playlist. It will create a new node in
* This file will replace the contents of the "current" view * category
* *
* \param p_playlist the playlist to which the new items will be added * \param p_playlist the playlist to which the new items will be added
* \param psz_filename the name of the playlistfile to import * \param psz_filename the name of the playlistfile to import
......
...@@ -68,14 +68,15 @@ playlist_item_t * playlist_ItemGetByInput( playlist_t * p_playlist , ...@@ -68,14 +68,15 @@ playlist_item_t * playlist_ItemGetByInput( playlist_t * p_playlist ,
input_item_t *p_item ) input_item_t *p_item )
{ {
int i; int i;
if( p_playlist->status.p_item && p_playlist->status.p_item->p_input == p_item ) if( p_playlist->status.p_item &&
p_playlist->status.p_item->p_input == p_item )
{ {
return p_playlist->status.p_item; return p_playlist->status.p_item;
} }
for( i = 0 ; i < p_playlist->i_all_size; i++ ) for( i = 0 ; i < p_playlist->i_all_size; i++ )
{ {
if( p_playlist->pp_all_items[i]->p_input == p_item ) if( p_playlist->pp_all_items[i]->p_input->i_id == p_item->i_id )
{ {
return p_playlist->pp_all_items[i]; return p_playlist->pp_all_items[i];
} }
......
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