2007-02-24 15:50:33 -05:00
|
|
|
/*
|
2015-01-07 17:44:44 -05:00
|
|
|
* Copyright (c) 2007 Moritz Grimm <mgrimm@mrsserver.net>
|
2007-02-24 15:50:33 -05:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLAYLIST_H__
|
|
|
|
#define __PLAYLIST_H__
|
|
|
|
|
2015-05-26 17:40:48 -04:00
|
|
|
typedef struct playlist * playlist_t;
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the playlist routines. Should be called before any of the other
|
|
|
|
* playlist functions.
|
|
|
|
*/
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
int playlist_init(void);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up for clean shutdowns. No-op at the moment.
|
|
|
|
*/
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
void playlist_exit(void);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a playlist file (in .M3U format), and return a new playlist handler
|
|
|
|
* on success, or NULL on failure.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
playlist_t playlist_read(const char * /* filename */);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
2007-02-28 16:26:16 -05:00
|
|
|
/*
|
|
|
|
* For each call to playlist_get_next(), the specified program is run. This
|
|
|
|
* program is supposed to print one line to standard output, containing the
|
|
|
|
* path and filename of a media file.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
playlist_t playlist_program(const char * /* program name */);
|
2007-02-28 16:26:16 -05:00
|
|
|
|
2007-02-24 15:50:33 -05:00
|
|
|
/*
|
|
|
|
* Free all memory used by a playlist handler that was created with
|
|
|
|
* playlist_read().
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
void playlist_free(playlist_t *);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the next item in the playlist. Returns a NUL-terminated string of a
|
|
|
|
* playlist entry, or NULL if the end of the list has been reached.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
const char * playlist_get_next(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
2007-02-28 16:26:16 -05:00
|
|
|
/*
|
|
|
|
* The functions below work on playlist handlers obtained with playlist_read()
|
|
|
|
* and are no-ops (i.e. return failure) for playlists from playlist_program().
|
|
|
|
*/
|
|
|
|
|
2007-02-24 15:50:33 -05:00
|
|
|
/*
|
|
|
|
* Skip the playlist item that would be played next.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
void playlist_skip_next(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the number of items in the playlist.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
unsigned long playlist_get_num_items(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the current position in the playlist.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
unsigned long playlist_get_position(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for a given entry in the playlist and reposition to it. Returns 1 on
|
|
|
|
* success and 0 on failure. A subsequent call to playlist_get_next() will
|
|
|
|
* return this list item again.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
int playlist_goto_entry(playlist_t, const char * /* name */);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Rewind the playlist to the beginning, so that it can be replayed. Does
|
|
|
|
* not reread the playlist file.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
void playlist_rewind(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reread the playlist file and rewind to the beginning. Equivalent to calling
|
|
|
|
* playlist_free() and playlist_read(). Entries will no longer be shuffled
|
|
|
|
* after calling this function.
|
|
|
|
* Returns 1 on success, and 0 on error.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
int playlist_reread(playlist_t*);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Shuffle the entries of the playlist randomly.
|
|
|
|
*/
|
2015-05-26 17:40:48 -04:00
|
|
|
void playlist_shuffle(playlist_t);
|
2007-02-24 15:50:33 -05:00
|
|
|
|
|
|
|
#endif /* __PLAYLIST_H__ */
|