2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \file
|
|
|
|
/// \ingroup Playtree
|
|
|
|
|
2007-07-02 22:34:45 +00:00
|
|
|
#ifndef PLAYTREE_H
|
|
|
|
#define PLAYTREE_H
|
2002-01-14 23:38:49 +00:00
|
|
|
|
2002-11-12 01:56:42 +00:00
|
|
|
struct stream_st;
|
|
|
|
struct m_config;
|
2002-01-14 23:38:49 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \defgroup PlaytreeIterReturn Playtree iterator return code
|
|
|
|
/// \ingroup PlaytreeIter
|
|
|
|
///@{
|
2002-01-08 01:24:25 +00:00
|
|
|
#define PLAY_TREE_ITER_ERROR 0
|
|
|
|
#define PLAY_TREE_ITER_ENTRY 1
|
|
|
|
#define PLAY_TREE_ITER_NODE 2
|
|
|
|
#define PLAY_TREE_ITER_END 3
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \defgroup PlaytreeEntryTypes Playtree entry types
|
|
|
|
/// \ingroup Playtree
|
|
|
|
///@{
|
2002-01-17 20:24:28 +00:00
|
|
|
#define PLAY_TREE_ENTRY_NODE -1
|
|
|
|
#define PLAY_TREE_ENTRY_DVD 0
|
|
|
|
#define PLAY_TREE_ENTRY_VCD 1
|
|
|
|
#define PLAY_TREE_ENTRY_TV 2
|
|
|
|
#define PLAY_TREE_ENTRY_FILE 3
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
|
|
|
|
2002-01-17 20:24:28 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \defgroup PlaytreeEntryFlags Playtree flags
|
|
|
|
/// \ingroup Playtree
|
|
|
|
///@{
|
2007-07-28 14:27:55 +00:00
|
|
|
/// Play the item children in random order.
|
2002-11-12 23:39:35 +00:00
|
|
|
#define PLAY_TREE_RND (1<<0)
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Playtree flags used by the iterator to mark items already "randomly" played.
|
2002-11-12 23:39:35 +00:00
|
|
|
#define PLAY_TREE_RND_PLAYED (1<<8)
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
2002-11-12 23:39:35 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \defgroup PlaytreeIterMode Playtree iterator mode
|
|
|
|
/// \ingroup PlaytreeIter
|
|
|
|
///@{
|
2002-11-12 23:39:35 +00:00
|
|
|
#define PLAY_TREE_ITER_NORMAL 0
|
|
|
|
#define PLAY_TREE_ITER_RND 1
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
/// \defgroup Playtree
|
|
|
|
///@{
|
2002-11-12 23:39:35 +00:00
|
|
|
|
2002-01-08 01:24:25 +00:00
|
|
|
typedef struct play_tree play_tree_t;
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \ingroup PlaytreeIter
|
2002-01-08 01:24:25 +00:00
|
|
|
typedef struct play_tree_iter play_tree_iter_t;
|
2002-01-14 23:38:49 +00:00
|
|
|
typedef struct play_tree_param play_tree_param_t;
|
|
|
|
|
2002-01-08 01:24:25 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
typedef struct play_tree_info play_tree_info_t;
|
|
|
|
// TODO : a attrib,val pair system and not something hardcoded
|
|
|
|
struct play_tree_info {
|
|
|
|
char* title;
|
|
|
|
char* author;
|
|
|
|
char* copyright;
|
|
|
|
char* abstract;
|
|
|
|
// Some more ??
|
|
|
|
}
|
2002-01-14 23:38:49 +00:00
|
|
|
#endif
|
2002-01-08 01:24:25 +00:00
|
|
|
|
|
|
|
struct play_tree_param {
|
|
|
|
char* name;
|
|
|
|
char* value;
|
2002-01-14 23:38:49 +00:00
|
|
|
};
|
|
|
|
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Playtree item
|
2002-01-08 01:24:25 +00:00
|
|
|
struct play_tree {
|
|
|
|
play_tree_t* parent;
|
|
|
|
play_tree_t* child;
|
|
|
|
play_tree_t* next;
|
|
|
|
play_tree_t* prev;
|
|
|
|
|
|
|
|
//play_tree_info_t info;
|
2002-01-14 23:38:49 +00:00
|
|
|
play_tree_param_t* params;
|
2002-01-08 01:24:25 +00:00
|
|
|
int loop;
|
|
|
|
char** files;
|
2002-01-17 20:24:28 +00:00
|
|
|
int entry_type;
|
2002-11-12 23:39:35 +00:00
|
|
|
int flags;
|
2002-01-08 01:24:25 +00:00
|
|
|
};
|
2006-04-25 01:26:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// \defgroup PlaytreeIter Playtree iterator
|
|
|
|
/// \ingroup Playtree
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Playtree iterator
|
2002-01-08 01:24:25 +00:00
|
|
|
struct play_tree_iter {
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Root of the iterated tree.
|
|
|
|
play_tree_t* root;
|
|
|
|
/// Current position in the tree.
|
|
|
|
play_tree_t* tree;
|
|
|
|
/// \ref Config used.
|
|
|
|
struct m_config* config;
|
|
|
|
/// Looping status
|
|
|
|
int loop;
|
|
|
|
/// Selected file in the current item.
|
2002-01-08 01:24:25 +00:00
|
|
|
int file;
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Number of files in the current item.
|
2002-01-08 01:24:25 +00:00
|
|
|
int num_files;
|
2002-01-14 23:38:49 +00:00
|
|
|
int entry_pushed;
|
2002-11-12 23:39:35 +00:00
|
|
|
int mode;
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// loop/valid stack to save/revert status when we go up/down.
|
|
|
|
int* status_stack;
|
|
|
|
/// status stack size
|
|
|
|
int stack_size;
|
2002-01-08 01:24:25 +00:00
|
|
|
};
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Create a new empty playtree item.
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_t*
|
|
|
|
play_tree_new(void);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Free a playtree item.
|
|
|
|
/** \param pt Item to free.
|
2007-07-28 14:27:55 +00:00
|
|
|
* \param children If non-zero the item's children are recursively freed.
|
2006-04-25 01:26:10 +00:00
|
|
|
*/
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
2007-07-28 14:27:55 +00:00
|
|
|
play_tree_free(play_tree_t* pt, int children);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Free an item and its siblings.
|
|
|
|
/** \param pt Item to free.
|
2007-07-28 14:27:55 +00:00
|
|
|
* \param children If non-zero the items' children are recursively freed.
|
2006-04-25 01:26:10 +00:00
|
|
|
*/
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
2007-07-28 14:27:55 +00:00
|
|
|
play_tree_free_list(play_tree_t* pt, int children);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
|
|
|
|
2007-07-28 14:27:55 +00:00
|
|
|
/// Set the children of a playtree item.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_set_child(play_tree_t* pt, play_tree_t* child);
|
2006-04-25 01:26:10 +00:00
|
|
|
|
|
|
|
/// Set the parent of a playtree item.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_set_parent(play_tree_t* pt, play_tree_t* parent);
|
|
|
|
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Append an item after its siblings.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_append_entry(play_tree_t* pt, play_tree_t* entry);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Prepend an item before its siblings.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_prepend_entry(play_tree_t* pt, play_tree_t* entry);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Insert an item right after a siblings.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_insert_entry(play_tree_t* pt, play_tree_t* entry);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Detach an item from the tree.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
2007-07-28 14:27:55 +00:00
|
|
|
play_tree_remove(play_tree_t* pt, int free_it,int with_children);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Add a file to an item.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_add_file(play_tree_t* pt,char* file);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Remove a file from an item.
|
2002-01-08 01:24:25 +00:00
|
|
|
int
|
|
|
|
play_tree_remove_file(play_tree_t* pt,char* file);
|
|
|
|
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Add a config paramter to an item.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_set_param(play_tree_t* pt, char* name, char* val);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Remove a config parameter from an item.
|
2002-01-08 01:24:25 +00:00
|
|
|
int
|
|
|
|
play_tree_unset_param(play_tree_t* pt, char* name);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Copy the config parameters from one item to another.
|
2002-03-20 10:27:27 +00:00
|
|
|
void
|
|
|
|
play_tree_set_params_from(play_tree_t* dest,play_tree_t* src);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \addtogroup PlaytreeIter
|
|
|
|
///@{
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Create a new iterator.
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_iter_t*
|
2002-11-12 01:56:42 +00:00
|
|
|
play_tree_iter_new(play_tree_t* pt, struct m_config* config);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Duplicate an iterator.
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_iter_t*
|
|
|
|
play_tree_iter_new_copy(play_tree_iter_t* old);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Free an iterator.
|
2002-01-08 01:24:25 +00:00
|
|
|
void
|
|
|
|
play_tree_iter_free(play_tree_iter_t* iter);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Step an iterator.
|
|
|
|
/** \param iter The iterator.
|
|
|
|
* \param d The direction: d > 0 == next , d < 0 == prev
|
2007-07-28 14:27:55 +00:00
|
|
|
* \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
|
2006-04-25 01:26:10 +00:00
|
|
|
* \return See \ref PlaytreeIterReturn.
|
|
|
|
*/
|
2002-01-08 01:24:25 +00:00
|
|
|
int
|
|
|
|
play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes);
|
|
|
|
|
2007-02-22 00:18:10 +00:00
|
|
|
/// Step up, useful to break a loop, etc.
|
2006-04-25 01:26:10 +00:00
|
|
|
/** \param iter The iterator.
|
|
|
|
* \param d The direction: d > 0 == next , d < 0 == prev
|
2007-07-28 14:27:55 +00:00
|
|
|
* \param with_node TRUE == stop on nodes with children, FALSE == go directly to the next child
|
2006-04-25 01:26:10 +00:00
|
|
|
* \return See \ref PlaytreeIterReturn.
|
|
|
|
*/
|
|
|
|
int
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes);
|
|
|
|
|
2007-02-22 00:18:10 +00:00
|
|
|
/// Enter a node child list, only useful when stopping on nodes.
|
2006-04-25 01:26:10 +00:00
|
|
|
int
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Get a file from the current item.
|
2002-01-08 01:24:25 +00:00
|
|
|
char*
|
|
|
|
play_tree_iter_get_file(play_tree_iter_t* iter, int d);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
|
|
|
// PlaytreeIter group
|
|
|
|
|
|
|
|
/// Create a playtree from a playlist file.
|
|
|
|
/** \ingroup PlaytreeParser
|
|
|
|
*/
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_t*
|
2003-01-12 19:41:38 +00:00
|
|
|
parse_playtree(struct stream_st *stream, int forced);
|
2002-01-08 01:24:25 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Clean a tree by destroying all empty elements.
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_t*
|
|
|
|
play_tree_cleanup(play_tree_t* pt);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Create a playtree from a playlist file.
|
|
|
|
/** \ingroup PlaytreeParser
|
|
|
|
*/
|
2002-01-08 01:24:25 +00:00
|
|
|
play_tree_t*
|
|
|
|
parse_playlist_file(char* file);
|
2002-01-14 23:38:49 +00:00
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \defgroup PtAPI Playtree highlevel API
|
|
|
|
/// \ingroup Playtree
|
|
|
|
/// Highlevel API with pt-suffix to different from low-level API
|
|
|
|
/// by Fabian Franz (mplayer@fabian-franz.de).
|
|
|
|
///@{
|
2003-02-05 23:02:05 +00:00
|
|
|
|
2006-04-27 13:22:23 +00:00
|
|
|
// Cleans up pt and creates a new iter.
|
2003-02-05 23:02:05 +00:00
|
|
|
play_tree_iter_t* pt_iter_create(play_tree_t** pt, struct m_config* config);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Frees the iter.
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_iter_destroy(play_tree_iter_t** iter);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Gets the next available file in the direction (d=-1 || d=+1).
|
2003-02-05 23:02:05 +00:00
|
|
|
char* pt_iter_get_file(play_tree_iter_t* iter, int d);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
// Two Macros that implement forward and backward direction.
|
2003-02-05 23:02:05 +00:00
|
|
|
#define pt_iter_get_next_file(iter) pt_iter_get_file(iter, 1)
|
|
|
|
#define pt_iter_get_prev_file(iter) pt_iter_get_file(iter, -1)
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Inserts entry into the playtree.
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Replaces current entry in playtree with entry by doing insert and remove.
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_iter_replace_entry(play_tree_iter_t* iter, play_tree_t* entry);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Adds a new file to the playtree, if it is not valid it is created.
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_add_file(play_tree_t** ppt, char* filename);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// \brief Performs a convert to playtree-syntax, by concat path/file
|
|
|
|
/// and performs pt_add_file
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_add_gui_file(play_tree_t** ppt, char* path, char* file);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
// Two macros to use only the iter and not the other things.
|
2003-02-05 23:02:05 +00:00
|
|
|
#define pt_iter_add_file(iter, filename) pt_add_file(&iter->tree, filename)
|
|
|
|
#define pt_iter_add_gui_file(iter, path, name) pt_add_gui_file(&iter->tree, path, name)
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
/// Resets the iter and goes back to head.
|
2003-02-05 23:02:05 +00:00
|
|
|
void pt_iter_goto_head(play_tree_iter_t* iter);
|
|
|
|
|
2006-04-25 01:26:10 +00:00
|
|
|
///@}
|
|
|
|
|
2007-12-31 16:15:50 +00:00
|
|
|
#endif /* PLAYTREE_H */
|
2006-04-25 01:26:10 +00:00
|
|
|
|
|
|
|
///@}
|