1fdec39a628a8737db25d51b8a1a4517cafe8bfb
[omnplay] / src / omnplay.h
1 /*
2 * omnplay.h -- GTK+ 2 omnplay
3 * Copyright (C) 2011 Maksym Veremeyenko <verem@m1stereo.tv>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef OMNPLAY_H
21 #define OMNPLAY_H
22
23 #include <pthread.h>
24
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif /* __cplusplus */
29
30 typedef enum control_buttons
31 {
32 BUTTON_PLAYLIST_ITEM_ADD = 1,
33 BUTTON_PLAYLIST_ITEM_DEL,
34 BUTTON_PLAYLIST_ITEM_EDIT,
35
36 BUTTON_PLAYLIST_LOAD,
37 BUTTON_PLAYLIST_SAVE,
38
39 BUTTON_PLAYLIST_BLOCK_SINGLE,
40 BUTTON_PLAYLIST_BLOCK_LOOP,
41
42 BUTTON_PLAYLIST_ITEM_UP,
43 BUTTON_PLAYLIST_ITEM_DOWN,
44
45 BUTTON_PLAYER_CUE,
46 BUTTON_PLAYER_PLAY,
47 BUTTON_PLAYER_PAUSE,
48 BUTTON_PLAYER_STOP,
49
50 BUTTON_LIBRARY_ADD,
51 BUTTON_LIBRARY_REFRESH,
52
53 BUTTON_LIBRARY_FIND,
54 BUTTON_LIBRARY_FIND_NEXT,
55
56 BUTTON_LAST
57 } control_buttons_t;
58
59 #define OMNPLAY_PLAYLIST_BLOCK_BEGIN 1
60 #define OMNPLAY_PLAYLIST_BLOCK_BODY 0
61 #define OMNPLAY_PLAYLIST_BLOCK_END 2
62 #define OMNPLAY_PLAYLIST_BLOCK_LOOP 4
63
64 typedef enum playlist_item_type
65 {
66 // 1
67 OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN,
68 // 0
69 OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY,
70 // 2
71 OMNPLAY_PLAYLIST_ITEM_BLOCK_END = OMNPLAY_PLAYLIST_BLOCK_END,
72 // 3
73 OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
74 OMNPLAY_PLAYLIST_BLOCK_BODY |
75 OMNPLAY_PLAYLIST_BLOCK_END,
76 // 5
77 OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
78 OMNPLAY_PLAYLIST_BLOCK_LOOP,
79 // 4
80 OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY |
81 OMNPLAY_PLAYLIST_BLOCK_LOOP,
82 // 6
83 OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END |
84 OMNPLAY_PLAYLIST_BLOCK_LOOP,
85 // 7
86 OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
87 OMNPLAY_PLAYLIST_BLOCK_BODY |
88 OMNPLAY_PLAYLIST_BLOCK_END |
89 OMNPLAY_PLAYLIST_BLOCK_LOOP,
90 } playlist_item_type_t;
91
92 #define MAX_PLAYLIST_ITEMS 1024
93 #define MAX_LIBRARY_ITEMS 10240
94 #define PLAYLIST_ITEM_ERROR_LIB 1
95 #define PLAYLIST_ITEM_ERROR_CUE 2
96
97 typedef struct playlist_item
98 {
99 char id[PATH_MAX];
100 char title[PATH_MAX];
101 int in;
102 int dur;
103 int player;
104 playlist_item_type_t type;
105 int omn_idx;
106 int omn_offset;
107 int error;
108 } playlist_item_t;
109
110 #define MAX_PLAYERS 4
111
112 struct omnplay_instance;
113
114 typedef struct omnplay_player
115 {
116 int idx;
117 char name[PATH_MAX];
118 char host[PATH_MAX];
119 void* handle;
120 pthread_t thread;
121 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
122 struct omnplay_instance *app;
123 int playlist_start;
124 int playlist_length;
125 } omnplay_player_t;
126
127 typedef struct omnplay_instance
128 {
129 GtkWidget *window;
130 GtkWidget *playlist_grid;
131 GtkWidget *library_grid;
132 GtkWidget *buttons[BUTTON_LAST + 1];
133 struct
134 {
135 omnplay_player_t item[MAX_PLAYERS];
136 int count;
137 char path[PATH_MAX];
138 pthread_mutex_t lock;
139 } players;
140 int f_exit;
141 struct
142 {
143 playlist_item_t item[MAX_PLAYLIST_ITEMS];
144 int count;
145 int ver_curr;
146 int ver_prev;
147 pthread_mutex_t lock;
148 char* path;
149 GdkPixbuf *block_icons[8];
150 } playlist;
151 struct
152 {
153 playlist_item_t item[MAX_LIBRARY_ITEMS];
154 int count;
155 char filename[PATH_MAX];
156 char whois[PATH_MAX];
157 pthread_mutex_t lock;
158 pthread_t refresh_thread;
159 int refresh_thread_r;
160 GtkWidget *search;
161 } library;
162 struct
163 {
164 playlist_item_t item[MAX_LIBRARY_ITEMS];
165 int count;
166 } clipboard;
167 } omnplay_instance_t;
168
169 omnplay_instance_t* omnplay_create(int argc, char** argv);
170 void omnplay_init(omnplay_instance_t* app);
171 void omnplay_release(omnplay_instance_t* app);
172 void omnplay_destroy(omnplay_instance_t* app);
173 void omnplay_playlist_load(omnplay_instance_t* app);
174 void omnplay_playlist_save(omnplay_instance_t* app);
175 void omnplay_playlist_draw(omnplay_instance_t* app);
176 void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx);
177 void omnplay_playlist_draw_item_rem(omnplay_instance_t* app, int idx, char* rem);
178 void omnplay_library_load(omnplay_instance_t* app);
179 void omnplay_library_save(omnplay_instance_t* app);
180 void omnplay_library_refresh(omnplay_instance_t* app);
181 void omnplay_library_draw(omnplay_instance_t* app);
182 typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data);
183 int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit,
184 omnplay_get_content_cb_proc proc, void* data);
185 int omnplay_whois_list(omnplay_instance_t* app, playlist_item_t *items, int* plimit);
186 int omnplay_library_load_file(playlist_item_t* items, int *pcount, char* filename);
187 playlist_item_t* omnplay_library_find(omnplay_instance_t* app, char* id);
188 int omnplay_library_normalize_item(omnplay_instance_t* app, playlist_item_t* item);
189 playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *count);
190 void omnplay_playlist_normalize(omnplay_instance_t* app);
191 void omnplay_library_search(omnplay_instance_t* app, int next);
192
193 #ifdef __cplusplus
194 };
195 #endif /* __cplusplus */
196
197 #endif /* OMNPLAY_H */