1 /*
2   This file is part of Deadbeef Player source code
3   http://deadbeef.sourceforge.net
4 
5   streamer implementation
6 
7   Copyright (C) 2009-2013 Alexey Yakovenko
8 
9   This software is provided 'as-is', without any express or implied
10   warranty.  In no event will the authors be held liable for any damages
11   arising from the use of this software.
12 
13   Permission is granted to anyone to use this software for any purpose,
14   including commercial applications, and to alter it and redistribute it
15   freely, subject to the following restrictions:
16 
17   1. The origin of this software must not be misrepresented; you must not
18      claim that you wrote the original software. If you use this software
19      in a product, an acknowledgment in the product documentation would be
20      appreciated but is not required.
21   2. Altered source versions must be plainly marked as such, and must not be
22      misrepresented as being the original software.
23   3. This notice may not be removed or altered from any source distribution.
24 
25   Alexey Yakovenko waker@users.sourceforge.net
26 */
27 #ifndef __STREAMER_H
28 #define __STREAMER_H
29 
30 #include "playlist.h"
31 #include "deadbeef.h"
32 
33 // events to pass to streamer thread
34 enum {
35     STR_EV_PLAY_TRACK_IDX, // p1 = idx, p2 = pstate; see streamer_set_nextsong semantics
36     STR_EV_PLAY_CURR, // will play the current streamer track (playing_track), see more details in streamer_play_current_track
37     STR_EV_NEXT, // streamer_move_to_nextsong
38     STR_EV_PREV, // streamer_move_to_prevsong
39     STR_EV_RAND, // streamer_move_to_randomsong
40     STR_EV_SEEK, // streamer_set_seek; p1: float pos
41     STR_EV_SET_CURR_PLT, // streamer_set_current_playlist
42     STR_EV_DSP_RELOAD, // reload dsp settings
43     STR_EV_SET_DSP_CHAIN, // set new dsp chain
44     STR_EV_ORDER_CHANGED, // tell the streamer that playback order has changed, p1=old, p2=new
45 };
46 
47 int
48 streamer_init (void);
49 
50 void
51 streamer_free (void);
52 
53 int
54 streamer_read (char *bytes, int size);
55 
56 void
57 streamer_reset (int full);
58 
59 void
60 streamer_lock (void);
61 
62 void
63 streamer_unlock (void);
64 
65 // pstate indicates what to do with playback
66 // -1 means "don't do anything"
67 // -2 means "end of playlist"
68 // 0 stop
69 // 1 switch to current (gui) playlist, play if not playing
70 // 2 pause
71 // 3 play if not playing, don't switch playlist
72 // 4 same as 1, but stops playback before proceeding
73 void
74 streamer_set_nextsong (int song, int pstate);
75 
76 void
77 streamer_set_seek (float pos);
78 
79 int
80 streamer_ok_to_read (int len);
81 
82 float
83 streamer_get_playpos (void);
84 
85 void
86 streamer_song_removed_notify (playItem_t *it);
87 
88 playItem_t *
89 streamer_get_streaming_track (void);
90 
91 playItem_t *
92 streamer_get_playing_track (void);
93 
94 void
95 streamer_configchanged (void);
96 
97 // if paused -- resume
98 // else, if have cursor track -- stop current, play cursor
99 // else, play next
100 void
101 streamer_play_current_track (void);
102 
103 void
104 streamer_set_bitrate (int bitrate);
105 
106 int
107 streamer_get_apx_bitrate (void);
108 
109 // returns -1 if theres no next song, or playlist finished
110 // reason 0 means "prev song finished", 1 means "interrupt"
111 int
112 streamer_move_to_nextsong (int r);
113 
114 int
115 streamer_move_to_prevsong (int r);
116 
117 int
118 streamer_move_to_randomsong (int r);
119 
120 struct DB_fileinfo_s *
121 streamer_get_current_fileinfo (void);
122 
123 void
124 streamer_set_current_playlist (int plt);
125 
126 int
127 streamer_get_current_playlist (void);
128 
129 // returns track index in current streamer playlist
130 int
131 str_get_idx_of (playItem_t *it);
132 
133 void
134 streamer_notify_playlist_deleted (playlist_t *plt);
135 
136 struct ddb_dsp_context_s *
137 streamer_get_dsp_chain (void);
138 
139 void
140 streamer_set_dsp_chain (struct ddb_dsp_context_s *chain);
141 
142 void
143 streamer_dsp_refresh (void);
144 
145 void
146 streamer_get_output_format (ddb_waveformat_t *fmt);
147 
148 int
149 streamer_dsp_chain_save (void);
150 
151 void
152 streamer_notify_order_changed (int prev_order, int new_order);
153 
154 void
155 audio_get_waveform_data (int type, float *data);
156 
157 void
158 streamer_set_streamer_playlist (playlist_t *plt);
159 
160 struct handler_s *
161 streamer_get_handler (void);
162 
163 void
164 vis_waveform_listen (void *ctx, void (*callback)(void *ctx, ddb_audio_data_t *data));
165 
166 void
167 vis_waveform_unlisten (void *ctx);
168 
169 void
170 vis_spectrum_listen (void *ctx, void (*callback)(void *ctx, ddb_audio_data_t *data));
171 
172 void
173 vis_spectrum_unlisten (void *ctx);
174 
175 void
176 streamer_set_playing_track (playItem_t *it);
177 
178 #endif // __STREAMER_H
179