2010-04-04 06:43:15 -04:00
|
|
|
|
|
|
|
#ifndef __PLAYER_H__
|
|
|
|
#define __PLAYER_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/* AirTunes v2 packet interval in ns */
|
2011-02-17 10:21:35 -05:00
|
|
|
/* (352 samples/packet * 1e9 ns/s) / 44100 samples/s = 7981859 ns/packet */
|
2014-02-08 16:59:07 -05:00
|
|
|
# define AIRTUNES_V2_STREAM_PERIOD 7981859
|
2010-04-04 06:43:15 -04:00
|
|
|
|
|
|
|
/* AirTunes v2 number of samples per packet */
|
|
|
|
#define AIRTUNES_V2_PACKET_SAMPLES 352
|
|
|
|
|
|
|
|
|
|
|
|
/* Samples to bytes, bytes to samples */
|
|
|
|
#define STOB(s) ((s) * 4)
|
|
|
|
#define BTOS(b) ((b) / 4)
|
|
|
|
|
2014-04-19 11:18:20 -04:00
|
|
|
/* Maximum number of previously played songs that are remembered */
|
|
|
|
#define MAX_HISTORY_COUNT 20
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
enum play_status {
|
|
|
|
PLAY_STOPPED = 2,
|
|
|
|
PLAY_PAUSED = 3,
|
|
|
|
PLAY_PLAYING = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum repeat_mode {
|
|
|
|
REPEAT_OFF = 0,
|
|
|
|
REPEAT_SONG = 1,
|
|
|
|
REPEAT_ALL = 2,
|
|
|
|
};
|
|
|
|
|
2014-03-11 18:20:29 -04:00
|
|
|
enum source_type {
|
|
|
|
SOURCE_FFMPEG = 0,
|
2014-03-31 07:10:18 -04:00
|
|
|
SOURCE_SPOTIFY,
|
|
|
|
SOURCE_PIPE,
|
2014-03-11 18:20:29 -04:00
|
|
|
};
|
|
|
|
|
2011-03-05 04:25:44 -05:00
|
|
|
struct spk_flags {
|
|
|
|
unsigned selected:1;
|
|
|
|
unsigned has_password:1;
|
2011-03-05 04:29:05 -05:00
|
|
|
|
|
|
|
unsigned has_video:1;
|
2011-03-05 04:25:44 -05:00
|
|
|
};
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
struct player_status {
|
|
|
|
enum play_status status;
|
|
|
|
enum repeat_mode repeat;
|
|
|
|
char shuffle;
|
|
|
|
|
|
|
|
int volume;
|
|
|
|
|
2010-07-31 06:30:51 -04:00
|
|
|
uint32_t plid;
|
2010-04-04 06:43:15 -04:00
|
|
|
uint32_t id;
|
|
|
|
uint32_t pos_ms;
|
|
|
|
int pos_pl;
|
|
|
|
};
|
|
|
|
|
2011-03-05 04:25:44 -05:00
|
|
|
typedef void (*spk_enum_cb)(uint64_t id, const char *name, int relvol, struct spk_flags flags, void *arg);
|
2010-09-12 08:31:41 -04:00
|
|
|
typedef void (*player_status_handler)(void);
|
2010-04-04 06:43:15 -04:00
|
|
|
|
2013-11-14 17:14:58 -05:00
|
|
|
struct player_source
|
|
|
|
{
|
|
|
|
uint32_t id;
|
|
|
|
|
2014-03-11 18:20:29 -04:00
|
|
|
enum source_type type;
|
|
|
|
int setup_done;
|
|
|
|
|
2013-11-14 17:14:58 -05:00
|
|
|
uint64_t stream_start;
|
|
|
|
uint64_t output_start;
|
|
|
|
uint64_t end;
|
|
|
|
|
|
|
|
struct transcode_ctx *ctx;
|
|
|
|
|
|
|
|
struct player_source *pl_next;
|
|
|
|
struct player_source *pl_prev;
|
|
|
|
|
|
|
|
struct player_source *shuffle_next;
|
|
|
|
struct player_source *shuffle_prev;
|
2010-04-04 06:43:15 -04:00
|
|
|
|
2013-11-14 17:14:58 -05:00
|
|
|
struct player_source *play_next;
|
|
|
|
};
|
2010-04-04 06:43:15 -04:00
|
|
|
|
2014-04-19 11:18:20 -04:00
|
|
|
struct player_history
|
|
|
|
{
|
|
|
|
/* Buffer index of the oldest remembered song */
|
|
|
|
unsigned int start_index;
|
|
|
|
|
|
|
|
/* Count of song ids in the buffer */
|
|
|
|
unsigned int count;
|
|
|
|
|
|
|
|
/* Circular buffer of song ids previously played by forked-daapd */
|
2014-05-03 13:44:26 -04:00
|
|
|
uint32_t id[MAX_HISTORY_COUNT];
|
2014-04-19 11:18:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
int
|
|
|
|
player_get_current_pos(uint64_t *pos, struct timespec *ts, int commit);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_get_status(struct player_status *status);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_now_playing(uint32_t *id);
|
|
|
|
|
|
|
|
void
|
|
|
|
player_speaker_enumerate(spk_enum_cb cb, void *arg);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_speaker_set(uint64_t *ids);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_start(uint32_t *idx_id);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_stop(void);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_pause(void);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_seek(int ms);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_next(void);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_playback_prev(void);
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
player_volume_set(int vol);
|
|
|
|
|
2010-11-19 16:51:46 -05:00
|
|
|
int
|
|
|
|
player_volume_setrel_speaker(uint64_t id, int relvol);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_volume_setabs_speaker(uint64_t id, int vol);
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
int
|
|
|
|
player_repeat_set(enum repeat_mode mode);
|
|
|
|
|
|
|
|
int
|
|
|
|
player_shuffle_set(int enable);
|
|
|
|
|
2013-11-21 17:33:03 -05:00
|
|
|
int
|
2013-11-22 10:41:57 -05:00
|
|
|
player_queue_make_daap(struct player_source **head, const char *query, const char *queuefilter, const char *sort, int quirk);
|
2010-04-04 06:43:15 -04:00
|
|
|
|
2010-07-31 05:41:36 -04:00
|
|
|
struct player_source *
|
|
|
|
player_queue_make_pl(int plid, uint32_t *id);
|
|
|
|
|
2013-11-14 17:14:58 -05:00
|
|
|
struct player_source *
|
|
|
|
player_queue_get(void);
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
int
|
|
|
|
player_queue_add(struct player_source *ps);
|
|
|
|
|
2014-04-19 03:12:58 -04:00
|
|
|
int
|
|
|
|
player_queue_add_next(struct player_source *ps);
|
|
|
|
|
2014-04-19 02:09:32 -04:00
|
|
|
int
|
|
|
|
player_queue_move(int ps_pos_from, int ps_pos_to);
|
|
|
|
|
2014-04-19 02:35:07 -04:00
|
|
|
int
|
|
|
|
player_queue_remove(int ps_pos_remove);
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
void
|
|
|
|
player_queue_clear(void);
|
|
|
|
|
2014-05-17 08:06:50 -04:00
|
|
|
void
|
|
|
|
player_queue_empty(int clear_hist);
|
|
|
|
|
2010-07-31 06:30:51 -04:00
|
|
|
void
|
|
|
|
player_queue_plid(uint32_t plid);
|
|
|
|
|
2014-04-19 11:18:20 -04:00
|
|
|
struct player_history *
|
|
|
|
player_history_get(void);
|
|
|
|
|
2010-04-04 06:43:15 -04:00
|
|
|
void
|
2010-09-12 08:31:41 -04:00
|
|
|
player_set_update_handler(player_status_handler handler);
|
2010-04-04 06:43:15 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
player_init(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
player_deinit(void);
|
|
|
|
|
|
|
|
#endif /* !__PLAYER_H__ */
|