Commit 17557ea6 authored by Clément Stenac's avatar Clément Stenac

* Makefile.am : Added src/playlist/item-ext.c and src/playlist/info.c

* src/playlist/item.c
  src/playlist/info.c
  src/playlist/item-ext.c
  src/playlist/group.c
  src/playlist/sort.c
  src/playlist/loadsave.c
  include/vlc_playlist.h
      - New playlist_info structures and accessors
        It works pretty like the old input_info (with categories)
        It provides modularity to the playlist
      - Removed ppsz_options and i_options from playlist_item
        (we use the special category Options)
      - Added a unique id to each playlist_item to be able to track the
        items accross playlist reorders
      - Simplified adding of items.
           - playlist_AddExt is removed
           - playlist_AddItem is still here and exported but should not be used
           - use playlist_Add( p_playlist, uri, name, duration, mode, pos )
             and use the accessors for all other things
      - Added setters for fields of the playlist_item structure
      - Introduced "item-change" and "playlist-current" playlist variables
        to give more flexibility than only intf-change

      At the moment, duration is still in the structure (easier to use, IMHO)

* src/input/input.c
  src/libvlc.c :
        playlist item options parsing changed

* include/vlc_common.h : added playlist_info structures
parent 051ce627
......@@ -317,6 +317,8 @@ SOURCES_libvlc_common = \
src/playlist/loadsave.c \
src/playlist/group.c \
src/playlist/item.c \
src/playlist/item-ext.c \
src/playlist/info.c \
src/input/input.c \
src/input/es_out.c \
src/input/stream.c \
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.96 2003/12/06 22:45:53 jpsaman Exp $
* $Id: vlc_common.h,v 1.97 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -190,6 +190,8 @@ typedef struct msg_subscription_t msg_subscription_t;
typedef struct playlist_t playlist_t;
typedef struct playlist_item_t playlist_item_t;
typedef struct playlist_group_t playlist_group_t;
typedef struct item_info_t item_info_t;
typedef struct item_info_category_t item_info_category_t;
/* Modules */
typedef struct module_bank_t module_bank_t;
......
......@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: vlc_playlist.h,v 1.18 2003/12/03 21:58:42 sigmunau Exp $
* $Id: vlc_playlist.h,v 1.19 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -33,6 +33,29 @@
* @{
*/
/**
* Playlist info item
* \see playlist_item_t
*/
struct item_info_t
{
char * psz_name; /**< Name of this info */
char * psz_value; /**< Value of the info */
};
/**
* playlist item info category
* \see playlist_item_t
* \see item_info_t
*/
struct item_info_category_t
{
char * psz_name; /**< Name of this category */
int i_infos; /**< Number of infos in the category */
item_info_t **pp_infos; /**< Pointer to an array of infos */
};
/**
* playlist item
* \see playlist_t
......@@ -41,23 +64,27 @@ struct playlist_item_t
{
char * psz_name; /**< text describing this item */
char * psz_uri; /**< mrl of this item */
mtime_t i_duration; /**< A hint about the duration of this item */
char ** ppsz_options; /**< options passed with the :foo=bar syntax */
int i_options; /**< number of items in the
* ppsz_options array */
int i_type; /**< unused yet */
mtime_t i_duration; /**< A hint about the duration of this
* item, in miliseconds*/
int i_categories; /**< Number of info categories */
item_info_category_t **pp_categories;
/**< Pointer to the first info category */
int i_status; /**< unused yet */
int i_nb_played; /**< How many times was this item played ? */
vlc_bool_t b_autodeletion; /**< Indicates whther this item is to
* be deleted after playback. True mean
* that this item is to be deleted
* after playback, false otherwise */
vlc_bool_t b_enabled; /**< Indicates whether this item is to be
* played or skipped */
int i_group; /**< unused yet */
char * psz_author; /**< Author */
int i_group; /**< Which group does this item belongs to ? */
int i_id; /**< Unique id to track this item */
};
/**
* playlist group
* \see playlist_t
*/
struct playlist_group_t
{
char * psz_name; /**< name of the group */
......@@ -89,9 +116,10 @@ struct playlist_t
int i_groups; /**< How many groups are in the playlist */
playlist_group_t ** pp_groups;/**< array of pointers to the playlist
* groups */
int i_max_id; /**< Maximal group id given */
int i_last_group; /**< Maximal group id given */
input_thread_t * p_input; /**< the input thread ascosiated
* with the current item */
int i_last_id; /**< Last id to an item */
/*@}*/
};
......@@ -120,10 +148,13 @@ void playlist_Destroy ( playlist_t * );
#define playlist_Prev(p) playlist_Command(p,PLAYLIST_SKIP,-1)
#define playlist_Skip(p,i) playlist_Command(p,PLAYLIST_SKIP,i)
#define playlist_Goto(p,i) playlist_Command(p,PLAYLIST_GOTO,i)
VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) );
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char **, int, int, int ) );
VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, mtime_t, const char **, int, int, int ) );
/* Item functions */
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int ) );
/* For internal use. Do not use this one anymore */
VLC_EXPORT( int, playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) );
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) );
......@@ -131,18 +162,47 @@ VLC_EXPORT( int, playlist_Enable, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_DisableGroup, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_EnableGroup, ( playlist_t *, int ) );
/* Basic item informations accessors */
VLC_EXPORT( int, playlist_SetGroup, (playlist_t *, int, int ) );
VLC_EXPORT( int, playlist_SetName, (playlist_t *, int, char * ) );
VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int, int ) );
/* Item search functions */
VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *, int) );
VLC_EXPORT( playlist_item_t *, playlist_GetItemById, (playlist_t *, int) );
/* Group management functions */
VLC_EXPORT( playlist_group_t *, playlist_CreateGroup, (playlist_t *, char* ) );
VLC_EXPORT( int, playlist_DeleteGroup, (playlist_t *, int ) );
VLC_EXPORT( char *, playlist_FindGroup, (playlist_t *, int ) );
VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) );
/* Info functions */
VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) );
VLC_EXPORT( char * , playlist_GetItemInfo, ( playlist_item_t * , const char *, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_GetCategory, ( playlist_t *, int, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_GetItemCategory, ( playlist_item_t *, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_CreateCategory, ( playlist_t *, int, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_CreateItemCategory, ( playlist_item_t *, const char *) );
VLC_EXPORT( int, playlist_AddInfo, (playlist_t *, int, const char * , const char *, const char *, ...) );
VLC_EXPORT( int, playlist_AddItemInfo, (playlist_item_t *, const char * , const char *, const char *, ...) );
/* Option functions */
VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) );
VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) );
/* Playlist sorting */
#define playlist_SortTitle(p, i) playlist_Sort( p, SORT_TITLE, i)
#define playlist_SortAuthor(p, i) playlist_Sort( p, SORT_AUTHOR, i)
#define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
VLC_EXPORT( int, playlist_Sort, ( playlist_t *, int, int) );
VLC_EXPORT( int, playlist_Move, ( playlist_t *, int, int ) );
/* Load/Save */
VLC_EXPORT( int, playlist_LoadFile, ( playlist_t *, const char * ) );
VLC_EXPORT( int, playlist_SaveFile, ( playlist_t *, const char * ) );
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.271 2003/12/03 22:14:38 sigmunau Exp $
* $Id: input.c,v 1.272 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -86,8 +86,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
{
input_thread_t * p_input; /* thread descriptor */
input_info_category_t * p_info;
item_info_category_t *p_cat;
vlc_value_t val;
int i;
int i,j;
/* Allocate descriptor */
p_input = vlc_object_create( p_parent, VLC_OBJECT_INPUT );
......@@ -98,9 +99,21 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
}
/* Parse input options */
for( i = 0; i < p_item->i_options; i++ )
for( i = 0 ; i < p_item->i_categories ; i++ )
{
if( !strncmp( p_item->pp_categories[i]->psz_name, "Options", 7 ) )
{
msg_Dbg(p_input,"Parsing %i options for item",
p_item->pp_categories[i]->i_infos );
for( j = 0; j< p_item->pp_categories[i]->i_infos ; j++ )
{
ParseOption( p_input, p_item->ppsz_options[i] );
msg_Dbg(p_input,"Option : %s",
p_item->pp_categories[i]->pp_infos[j]->psz_name);
ParseOption( p_input,
p_item->pp_categories[i]->pp_infos[j]->psz_value);
}
break;
}
}
/* Create a few object variables we'll need later on */
......@@ -789,11 +802,9 @@ static int InitThread( input_thread_t * p_input )
FIND_PARENT );
if( p_playlist )
{
vlc_mutex_lock( &p_playlist->object_lock );
p_playlist->pp_items[ p_playlist->i_index ]->i_duration = i_length;
playlist_SetDuration( p_playlist, -1 , i_length );
val.b_bool = VLC_TRUE;
vlc_mutex_unlock( &p_playlist->object_lock );
var_Set( p_playlist, "intf-change", val );
var_Set( p_playlist, "item-change", val );
vlc_object_release( p_playlist );
}
}
......
......@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.106 2003/12/24 10:06:53 gbazin Exp $
* $Id: libvlc.c,v 1.107 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -796,6 +796,7 @@ int VLC_AddTarget( int i_object, char const *psz_target,
char const **ppsz_options, int i_options,
int i_mode, int i_pos )
{
int i;
int i_err;
playlist_t *p_playlist;
vlc_t *p_vlc = vlc_current_object( i_object );
......@@ -821,9 +822,14 @@ int VLC_AddTarget( int i_object, char const *psz_target,
vlc_object_yield( p_playlist );
}
i_err = playlist_Add( p_playlist, psz_target, ppsz_options, i_options,
i_err = playlist_Add( p_playlist, psz_target, psz_target,
i_mode, i_pos );
for( i = 0 ; i< i_options ; i++ )
{
playlist_AddOption( p_playlist, i_err , ppsz_options[i] );
}
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_vlc );
......
......@@ -2,7 +2,7 @@
* playlist.c : Playlist groups management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: group.c,v 1.4 2003/12/11 11:30:37 zorglub Exp $
* $Id: group.c,v 1.5 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -61,7 +61,7 @@ playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name)
}
p_group->psz_name = strdup( psz_name );
p_group->i_id = ++p_playlist->i_max_id;
p_group->i_id = ++p_playlist->i_last_group;
msg_Dbg(p_playlist,"Creating group %s with id %i at position %i",
p_group->psz_name,
......@@ -110,7 +110,7 @@ int playlist_DeleteGroup( playlist_t *p_playlist, int i_id )
}
/**
* Find the name with the ID
* Find the name of the group given its ID
*
* \param p_playlist the playlist where to find the group
* \param i_id the ID to search for
......@@ -131,7 +131,7 @@ char *playlist_FindGroup( playlist_t *p_playlist, int i_id )
}
/**
* Find the Id with the given name
* Find the Id of a group given its name
*
* \param p_playlist the playlist where to find the group
* \param char * the name to search for
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
* loadsave.c : Playlist loading / saving functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: loadsave.c,v 1.1 2003/10/29 18:00:46 zorglub Exp $
* $Id: loadsave.c,v 1.2 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -118,8 +118,8 @@ int playlist_LoadFile( playlist_t * p_playlist, const char *psz_filename )
}
if( i_format == 5 )
{
playlist_Add ( p_playlist , (char *)&line ,
0, 0, PLAYLIST_APPEND , PLAYLIST_END );
playlist_Add ( p_playlist , (char *)&line , (char *)&line,
PLAYLIST_APPEND , PLAYLIST_END );
}
else
{
......
......@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: playlist.c,v 1.70 2003/12/13 17:16:11 gbazin Exp $
* $Id: playlist.c,v 1.71 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -44,10 +44,6 @@ static void RunThread ( playlist_t * );
static void SkipItem ( playlist_t *, int );
static void PlayItem ( playlist_t * );
#if 0
static void Poubellize ( playlist_t *, input_thread_t * );
#endif
/**
* Create playlist
*
......@@ -72,6 +68,14 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
var_Create( p_playlist, "item-change", VLC_VAR_INTEGER );
val.i_int = -1;
var_Set( p_playlist, "item-change", val );
var_Create( p_playlist, "playlist-current", VLC_VAR_INTEGER );
val.i_int = -1;
var_Set( p_playlist, "playlist-current", val );
var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL );
var_Create( p_playlist, "intf-show", VLC_VAR_BOOL );
......@@ -90,7 +94,8 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
p_playlist->i_groups = 0;
p_playlist->pp_groups = NULL;
p_playlist->i_max_id = 0;
p_playlist->i_last_group = 0;
p_playlist->i_last_id = 0;
playlist_CreateGroup( p_playlist, "Normal" );
......@@ -121,6 +126,7 @@ void playlist_Destroy( playlist_t * p_playlist )
vlc_thread_join( p_playlist );
var_Destroy( p_playlist, "intf-change" );
var_Destroy( p_playlist, "item-change" );
while( p_playlist->i_groups > 0 )
{
......@@ -157,6 +163,8 @@ void playlist_Destroy( playlist_t * p_playlist )
if( p_playlist->p_input )
{
input_StopThread( p_playlist->p_input );
val.i_int = p_playlist->i_index;
var_Set( p_playlist, "item-change",val );
}
break;
......@@ -231,13 +239,13 @@ void playlist_Destroy( playlist_t * p_playlist )
}
vlc_mutex_unlock( &p_playlist->object_lock );
#if 0
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
#endif
return;
}
/* Following functions are local */
static void ObjectGarbageCollector( playlist_t *p_playlist,
int i_type,
......@@ -353,8 +361,12 @@ static void RunThread ( playlist_t *p_playlist )
vlc_mutex_unlock( &p_playlist->object_lock );
}
val.i_int = p_playlist->i_index;
var_Set( p_playlist, "playlist-current", val);
#if 0
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
#endif
continue;
}
else if( p_playlist->p_input->stream.control.i_status != INIT_S )
......@@ -538,6 +550,7 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
*****************************************************************************/
static void PlayItem( playlist_t *p_playlist )
{
vlc_value_t val;
if( p_playlist->i_index == -1 )
{
if( p_playlist->i_size == 0 || p_playlist->i_enabled == 0)
......@@ -556,4 +569,7 @@ static void PlayItem( playlist_t *p_playlist )
msg_Dbg( p_playlist, "creating new input thread" );
p_playlist->p_input = input_CreateThread( p_playlist,
p_playlist->pp_items[p_playlist->i_index] );
val.i_int = p_playlist->i_index;
var_Set( p_playlist, "item-change", val );
}
......@@ -2,7 +2,7 @@
* sort.c : Playlist sorting functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: sort.c,v 1.3 2003/12/13 17:46:07 asmax Exp $
* $Id: sort.c,v 1.4 2004/01/05 12:59:43 zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -64,7 +64,7 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
}
vlc_mutex_unlock( &p_playlist->object_lock );
/* Notify the interfaces (XXX: use a different variable) */
/* Notify the interfaces */
var_Set( p_playlist, "intf-change", val );
return 0;
......@@ -89,8 +89,11 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
}
else if( i_mode == SORT_AUTHOR )
{
i_test = strcasecmp( p_playlist->pp_items[i]->psz_author,
p_playlist->pp_items[i_small]->psz_author );
i_test = strcasecmp(
playlist_GetInfo( p_playlist, i,
_("General") , _("Author") ),
playlist_GetInfo( p_playlist, i_small,
_("General") , _("Author") ) );
}
if( ( i_type == SORT_NORMAL && i_test < 0 ) ||
......@@ -111,7 +114,7 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
}
vlc_mutex_unlock( &p_playlist->object_lock );
/* Notify the interfaces (XXX: use a different variable) */
/* Notify the interfaces */
var_Set( p_playlist, "intf-change", val );
return 0;
......
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