VLC  3.0.15
playlist_internal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * playlist_internal.h : Playlist internals
3  *****************************************************************************
4  * Copyright (C) 1999-2008 VLC authors and VideoLAN
5  * $Id: 178933c76d533f19bf3e8707559951ffd7bae098 $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  * ClĂ©ment Stenac <zorglub@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24 
25 #ifndef __LIBVLC_PLAYLIST_INTERNAL_H
26 # define __LIBVLC_PLAYLIST_INTERNAL_H 1
27 
28 /**
29  * \defgroup playlist_internals VLC playlist internals
30  * \ingroup playlist
31  *
32  * @{
33  * \file
34  * VLC playlist internal interface
35  */
36 
37 #include "input/input_interface.h"
38 #include <assert.h>
39 
40 #include "art.h"
41 #include "preparser.h"
42 
44 
46 
47 typedef struct playlist_private_t
48 {
50  struct intf_thread_t *interface; /**< Linked-list of interfaces */
51 
52  void *input_tree; /**< Search tree for input item
53  to playlist item mapping */
54  void *id_tree; /**< Search tree for item ID to item mapping */
55 
57  int i_sds; /**< Number of service discovery modules */
58  input_thread_t * p_input; /**< the input thread associated
59  * with the current item */
60  input_resource_t * p_input_resource; /**< input resources */
62  struct {
63  /* Current status. These fields are readonly, only the playlist
64  * main loop can touch it*/
65  playlist_item_t * p_item; /**< Currently playing/active item */
66  playlist_item_t * p_node; /**< Current node to play from */
67  } status;
68 
69  struct {
70  /* Request. Use this to give orders to the playlist main loop */
71  playlist_item_t * p_node; /**< requested node to play from */
72  playlist_item_t * p_item; /**< requested item to play in the node */
73 
74  int i_skip; /**< Number of items to skip */
75 
76  bool b_request;/**< Set to true by the requester
77  The playlist sets it back to false
78  when processing the request */
79  bool input_dead; /**< Set when input has finished. */
80  } request;
81 
82  vlc_thread_t thread; /**< engine thread */
83  vlc_mutex_t lock; /**< dah big playlist global lock */
84  vlc_cond_t signal; /**< wakes up the playlist engine thread */
85  bool killed; /**< playlist is shutting down */
86  bool cork_effective; /**< Corked while actively playing */
87 
88  int i_last_playlist_id; /**< Last id to an item */
89  bool b_reset_currently_playing; /** Reset current item array */
90  unsigned i_consecutive_errors; /**< Number of consecutive items in error */
91 
92  bool b_tree; /**< Display as a tree */
93  bool b_preparse; /**< Preparse items */
95 
96 #define pl_priv( pl ) container_of(pl, playlist_private_t, public_data)
97 
98 /*****************************************************************************
99  * Prototypes
100  *****************************************************************************/
101 
102 /* Creation/Deletion */
104 void playlist_Destroy( playlist_t * );
105 void playlist_Activate( playlist_t * );
106 
107 /* */
109  input_item_t *p_input );
110 
111 /* Engine */
116 
117 /* Load/Save */
118 int playlist_MLLoad( playlist_t *p_playlist );
119 int playlist_MLDump( playlist_t *p_playlist );
120 
121 /**********************************************************************
122  * Item management
123  **********************************************************************/
124 
125 void playlist_SendAddNotify( playlist_t *p_playlist, playlist_item_t *item );
126 
128  playlist_item_t *, input_item_node_t *, int, bool );
129 
130 /* Tree walking */
132 
133 /**
134  * Flags for playlist_NodeDeleteExplicit
135  * \defgroup playlist_NodeDeleteExplicit_flags
136  * @{
137  **/
138 #define PLAYLIST_DELETE_FORCE 0x01 /**< delete node even if read-only */
139 #define PLAYLIST_DELETE_STOP_IF_CURRENT 0x02 /**< stop playlist playback if
140  node is currently the one
141  played */
142 /** @} */
143 
144 /**
145  * Delete a node with explicit semantics
146  *
147  * This function acts like \ref playlist_NodeDelete with the advantage of the
148  * caller being able control some of the semantics of the function.
149  *
150  * \ref p_playlist the playlist where the node is to be deleted
151  * \ref p_node the node to delete
152  * \ref flags a bitfield consisting of \ref playlist_NodeDeleteExplicit_flags
153  **/
155  int flags);
156 
158 
159 void ResetCurrentlyPlaying( playlist_t *p_playlist, playlist_item_t *p_cur );
160 void ResyncCurrentIndex( playlist_t *p_playlist, playlist_item_t *p_cur );
161 
163  playlist_item_t *p_item, bool b_ena, bool b_unplayed ) VLC_USED;
164 
165 #define PLAYLIST_DEBUG 1
166 //#undef PLAYLIST_DEBUG2
167 
168 #ifdef PLAYLIST_DEBUG
169  #define PL_DEBUG( ... ) msg_Dbg( p_playlist, __VA_ARGS__ )
170  #ifdef PLAYLIST_DEBUG2
171  #define PL_DEBUG2( msg, ... ) msg_Dbg( p_playlist, __VA_ARGS__ )
172  #else
173  #define PL_DEBUG2( msg, ... ) {}
174  #endif
175 #else
176  #define PL_DEBUG( msg, ... ) {}
177  #define PL_DEBUG2( msg, ... ) {}
178 #endif
179 
180 #define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null"
181 
182 #define PL_LOCK_IF( cond ) pl_lock_if( p_playlist, cond )
183 static inline void pl_lock_if( playlist_t * p_playlist, bool cond )
184 {
185  if( cond ) PL_LOCK; else PL_ASSERT_LOCKED;
186 }
187 
188 #define PL_UNLOCK_IF( cond ) pl_unlock_if( p_playlist, cond )
189 static inline void pl_unlock_if( playlist_t * p_playlist, bool cond )
190 {
191  if( cond ) PL_UNLOCK;
192 }
193 
194 /** @} */
195 #endif /* !__LIBVLC_PLAYLIST_INTERNAL_H */
playlist_t
Structure containing information about the playlist.
Definition: vlc_playlist.h:151
input_item_t::event_manager
vlc_event_manager_t event_manager
Definition: vlc_input_item.h:91
playlist_private_t::request
struct playlist_private_t::@75 request
vlc_events.h
playlist_export_t
Helper structure to export to file part of the playlist.
Definition: vlc_playlist.h:117
vlc_fopen
FILE * vlc_fopen(const char *filename, const char *mode)
Opens a FILE pointer.
Definition: filesystem.c:46
playlist_private_t::killed
bool killed
playlist is shutting down
Definition: playlist_internal.h:84
playlist_AddInput
int playlist_AddInput(playlist_t *p_playlist, input_item_t *p_input, bool play_now, bool b_playlist)
Add an input item to the playlist node.
Definition: item.c:491
playlist_Create
playlist_t * playlist_Create(vlc_object_t *)
Create playlist.
Definition: engine.c:195
get_current_status_node
playlist_item_t * get_current_status_node(playlist_t *p_playlist)
Definition: engine.c:403
playlist_Export
int playlist_Export(playlist_t *p_playlist, const char *psz_filename, bool b_playlist, const char *psz_type)
Export a node of the playlist to a certain type of playlistfile.
Definition: loadsave.c:40
playlist_Import
int playlist_Import(playlist_t *p_playlist, const char *psz_file)
Open a playlist file, add its content to the current playlist.
Definition: loadsave.c:91
input_item_subitem_tree_added
static void input_item_subitem_tree_added(const vlc_event_t *p_event, void *user_data)
Definition: loadsave.c:115
playlist_private_t::p_node
playlist_item_t * p_node
Current node to play from.
Definition: playlist_internal.h:65
playlist_private_t::lock
vlc_mutex_t lock
dah big playlist global lock
Definition: playlist_internal.h:82
playlist_ItemRelease
void playlist_ItemRelease(playlist_t *, playlist_item_t *)
Release an item.
Definition: item.c:336
playlist_private_t::input_dead
bool input_dead
Set when input has finished.
Definition: playlist_internal.h:78
vlc_common.h
playlist_item_t
playlist item / node
Definition: vlc_playlist.h:126
playlist_Lock
void playlist_Lock(playlist_t *pl)
Locks the playlist.
Definition: control.c:35
DIR_SEP
#define DIR_SEP
Definition: vlc_common.h:1023
playlist_NodeInsert
int playlist_NodeInsert(playlist_item_t *, playlist_item_t *, int)
Definition: tree.c:147
playlist_SendAddNotify
void playlist_SendAddNotify(playlist_t *p_playlist, playlist_item_t *item)
Send a notification that an item has been added to a node.
Definition: item.c:697
PL_LOCK
#define PL_LOCK
Definition: vlc_playlist.h:216
input_item_t
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:58
get_current_status_item
playlist_item_t * get_current_status_item(playlist_t *p_playlist)
Accessor for status item and status nodes.
Definition: engine.c:396
PL_UNLOCK
#define PL_UNLOCK
Definition: vlc_playlist.h:217
vlc_InputItemSubItemTreeAdded
Definition: vlc_events.h:101
playlist_private_t::cork_effective
bool cork_effective
Corked while actively playing.
Definition: playlist_internal.h:85
ResetCurrentlyPlaying
void ResetCurrentlyPlaying(playlist_t *p_playlist, playlist_item_t *p_cur)
Reset the currently playing playlist.
Definition: thread.c:143
input_item_New
#define input_item_New(psz_uri, psz_name)
Definition: vlc_input_item.h:333
playlist_private_t::p_item
playlist_item_t * p_item
Currently playing/active item.
Definition: playlist_internal.h:64
playlist_private_t
Definition: playlist_internal.h:46
vlc_event_t::u
union vlc_event_t::vlc_event_type_specific u
playlist_MLDump
int playlist_MLDump(playlist_t *p_playlist)
Definition: loadsave.c:177
pl_lock_if
static void pl_lock_if(playlist_t *p_playlist, bool cond)
Definition: playlist_internal.h:182
msg_Dbg
#define msg_Dbg(p_this,...)
Definition: vlc_messages.h:86
playlist_private_t::b_preparse
bool b_preparse
Preparse items.
Definition: playlist_internal.h:92
_
#define _(str)
Definition: vlc_fixups.h:371
set_current_status_node
void set_current_status_node(playlist_t *, playlist_item_t *)
Definition: engine.c:418
VLC_EGENERIC
#define VLC_EGENERIC
Unspecified error.
Definition: vlc_common.h:350
vlc_stat
int vlc_stat(const char *filename, struct stat *buf)
Finds file/inode information - like stat().
Definition: filesystem.c:170
playlist_private_t::i_last_playlist_id
int i_last_playlist_id
Last id to an item.
Definition: playlist_internal.h:87
vlc_event_t
Definition: vlc_events.h:122
vlc_cond_t
pthread_cond_t vlc_cond_t
Condition variable.
Definition: vlc_threads.h:279
playlist_private_t::p_input_resource
input_resource_t * p_input_resource
input resources
Definition: playlist_internal.h:59
asprintf
int asprintf(char **, const char *,...)
var_Create
#define var_Create(a, b, c)
Definition: vlc_variables.h:121
vlc_object_create
#define vlc_object_create(a, b)
Definition: vlc_objects.h:55
playlist_private_t::thread
vlc_thread_t thread
engine thread
Definition: playlist_internal.h:81
vlc_event_t::vlc_event_type_specific::vlc_input_item_subitem_tree_added::p_root
input_item_node_t * p_root
Definition: vlc_events.h:139
ResyncCurrentIndex
void ResyncCurrentIndex(playlist_t *p_playlist, playlist_item_t *p_cur)
Synchronise the current index of the playlist to match the index of the current item.
Definition: thread.c:117
VLC_VAR_VOID
#define VLC_VAR_VOID
Definition: vlc_variables.h:48
playlist_private_t::i_sds
int i_sds
Number of service discovery modules.
Definition: playlist_internal.h:56
playlist_private_t::p_renderer
vlc_renderer_item_t * p_renderer
Definition: playlist_internal.h:60
vlc_object_release
#define vlc_object_release(a)
Definition: vlc_objects.h:63
playlist_private_t::input_tree
void * input_tree
Search tree for input item to playlist item mapping.
Definition: playlist_internal.h:51
vlc_event_attach
int vlc_event_attach(vlc_event_manager_t *p_em, vlc_event_type_t event_type, vlc_event_callback_t pf_callback, void *p_user_data)
Add a callback for an event.
Definition: events.c:117
vlc_rename
int vlc_rename(const char *oldpath, const char *newpath)
Moves a file atomically.
Definition: filesystem.c:194
vlc_unlink
int vlc_unlink(const char *filename)
Removes a file.
Definition: filesystem.c:180
playlist_private_t::status
struct playlist_private_t::@74 status
playlist_Destroy
void playlist_Destroy(playlist_t *)
Destroy playlist.
Definition: engine.c:310
pl_unlock_if
static void pl_unlock_if(playlist_t *p_playlist, bool cond)
Definition: playlist_internal.h:188
module_t
Internal module descriptor.
Definition: modules.h:79
playlist_ServicesDiscoveryKillAll
void playlist_ServicesDiscoveryKillAll(playlist_t *p_playlist)
Definition: services_discovery.c:246
getpid
pid_t getpid(void)
playlist_internal.h
playlist_private_t::b_tree
bool b_tree
Display as a tree.
Definition: playlist_internal.h:91
vlc_thread_t
Thread handle.
Definition: vlc_threads.h:252
PL_ASSERT_LOCKED
#define PL_ASSERT_LOCKED
Definition: vlc_playlist.h:218
VLC_DATA_DIR
Definition: vlc_configuration.h:123
playlist_private_t::i_skip
int i_skip
Number of items to skip.
Definition: playlist_internal.h:73
input_item_Release
void input_item_Release(input_item_t *p_item)
Releases an input item, i.e.
Definition: item.c:477
playlist_private_t::public_data
playlist_t public_data
Definition: playlist_internal.h:48
vlc_fs.h
playlist_NodeDeleteExplicit
void playlist_NodeDeleteExplicit(playlist_t *, playlist_item_t *, int flags)
Delete a node with explicit semantics.
Definition: tree.c:96
art.h
vlc_url.h
vlc_object_t
The main vlc_object_t structure.
Definition: vlc_objects.h:39
VLC_ENOMEM
#define VLC_ENOMEM
Not enough memory.
Definition: vlc_common.h:351
set_current_status_item
void set_current_status_item(playlist_t *, playlist_item_t *)
Definition: engine.c:410
vlc_mutex_t
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:267
input_interface.h
playlist_private_t
struct playlist_private_t playlist_private_t
VLC_SUCCESS
#define VLC_SUCCESS
No error.
Definition: vlc_common.h:349
playlist_private_t::signal
vlc_cond_t signal
wakes up the playlist engine thread
Definition: playlist_internal.h:83
VLC_USED
#define VLC_USED
Definition: fourcc_gen.c:31
playlist_InsertInputItemTree
int playlist_InsertInputItemTree(playlist_t *p_playlist, playlist_item_t *p_parent, input_item_node_t *p_node, int i_pos, bool b_flat)
Insert a tree of input items into a given playlist node.
Definition: item.c:591
vlc_custom_create
#define vlc_custom_create(o, s, n)
Definition: libvlc.h:108
playlist_Activate
void playlist_Activate(playlist_t *)
Creates the main playlist thread.
Definition: thread.c:48
vlc_renderer_item_t
Definition: renderer_discovery.c:33
input_Read
#define input_Read(a, b)
Definition: vlc_input.h:502
config_GetUserDir
char * config_GetUserDir(vlc_userdir_t type)
Definition: specific.c:272
vlc_event_t::vlc_event_type_specific::input_item_subitem_tree_added
struct vlc_event_t::vlc_event_type_specific::vlc_input_item_subitem_tree_added input_item_subitem_tree_added
playlist_private_t::b_reset_currently_playing
bool b_reset_currently_playing
Definition: playlist_internal.h:88
vlc_path2uri
char * vlc_path2uri(const char *path, const char *scheme)
Converts local path to URL.
Definition: url.c:138
playlist_private_t::p_input
input_thread_t * p_input
the input thread associated with the current item
Definition: playlist_internal.h:57
configuration.h
playlist_ItemNewFromInput
playlist_item_t * playlist_ItemNewFromInput(playlist_t *p_playlist, input_item_t *p_input)
Definition: item.c:253
unlikely
#define unlikely(p)
Definition: vlc_common.h:114
playlist_export_t::base_url
char * base_url
Definition: vlc_playlist.h:120
config_CreateDir
int config_CreateDir(vlc_object_t *, const char *)
Definition: file.c:263
playlist_t::p_playing
playlist_item_t * p_playing
Definition: vlc_playlist.h:162
playlist_export_t::p_file
FILE * p_file
Definition: vlc_playlist.h:121
playlist_private_t::b_request
bool b_request
Set to true by the requester The playlist sets it back to false when processing the request.
Definition: playlist_internal.h:75
vlc_strerror_c
const char * vlc_strerror_c(int errnum)
Definition: error.c:34
vlc_sd_internal_t
Definition: services_discovery.c:32
playlist_private_t::interface
struct intf_thread_t * interface
Linked-list of interfaces.
Definition: playlist_internal.h:49
playlist_GetNextLeaf
playlist_item_t * playlist_GetNextLeaf(playlist_t *, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed)
Finds the next item to play.
Definition: tree.c:204
vlc_event_detach
void vlc_event_detach(vlc_event_manager_t *p_em, vlc_event_type_t event_type, vlc_event_callback_t pf_callback, void *p_user_data)
Remove a callback for an event.
Definition: events.c:142
vlc_playlist.h
playlist_t::p_media_library
playlist_item_t * p_media_library
Definition: vlc_playlist.h:163
playlist_MLLoad
int playlist_MLLoad(playlist_t *p_playlist)
Definition: loadsave.c:128
playlist_Unlock
void playlist_Unlock(playlist_t *pl)
Unlocks the playlist.
Definition: control.c:40
playlist_export_t::p_root
playlist_item_t * p_root
Definition: vlc_playlist.h:122
input_thread_t
Main structure representing an input thread.
Definition: vlc_input.h:221
input_item_node_t
Definition: vlc_input_item.h:180
input_resource_t
Definition: resource.c:44
module_unneed
#define module_unneed(a, b)
Definition: vlc_modules.h:49
playlist_private_t::i_consecutive_errors
unsigned i_consecutive_errors
Reset current item array.
Definition: playlist_internal.h:89
preparser.h
playlist_private_t::id_tree
void * id_tree
Search tree for item ID to item mapping.
Definition: playlist_internal.h:53
msg_Err
#define msg_Err(p_this,...)
Definition: vlc_messages.h:82
module_need
#define module_need(a, b, c, d)
Definition: vlc_modules.h:47
intf_thread_t
Describe all interface-specific data of the interface thread.
Definition: vlc_interface.h:46
vlc_modules.h
playlist_private_t::pp_sds
vlc_sd_internal_t ** pp_sds
Definition: playlist_internal.h:55