fix README
[melted_gui] / src / instance.h
1 /*
2 * omnplay.h -- GTK+ 2 melted gui
3 * Copyright (C) 2012 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 INSTANCE_H
21 #define INSTANCE_H
22
23 #include <pthread.h>
24
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif /* __cplusplus */
29
30 #define PRODUCT_NAME "Melted GUI"
31
32 typedef enum control_buttons
33 {
34 BUTTON_PLAYLIST_ITEM_ADD = 1,
35 BUTTON_PLAYLIST_ITEM_DEL,
36 BUTTON_PLAYLIST_ITEM_EDIT,
37
38 BUTTON_PLAYLIST_LOAD,
39 BUTTON_PLAYLIST_SAVE,
40
41 BUTTON_PLAYLIST_BLOCK_SINGLE,
42 BUTTON_PLAYLIST_BLOCK_LOOP,
43
44 BUTTON_PLAYLIST_ITEM_UP,
45 BUTTON_PLAYLIST_ITEM_DOWN,
46
47 BUTTON_PLAYER_CUE,
48 BUTTON_PLAYER_PLAY,
49 BUTTON_PLAYER_PAUSE,
50 BUTTON_PLAYER_STOP,
51
52 BUTTON_LIBRARY_ADD,
53 BUTTON_LIBRARY_REFRESH,
54
55 BUTTON_LIBRARY_FIND,
56 BUTTON_LIBRARY_FIND_NEXT,
57
58 BUTTON_PLAYLIST_RELINK,
59
60 BUTTON_LAST
61 } control_buttons_t;
62
63 #define PLAYLIST_BLOCK_BEGIN 1
64 #define PLAYLIST_BLOCK_BODY 0
65 #define PLAYLIST_BLOCK_END 2
66 #define PLAYLIST_BLOCK_LOOP 4
67
68 typedef enum playlist_item_type
69 {
70 // 1
71 PLAYLIST_ITEM_BLOCK_BEGIN = PLAYLIST_BLOCK_BEGIN,
72 // 0
73 PLAYLIST_ITEM_BLOCK_BODY = PLAYLIST_BLOCK_BODY,
74 // 2
75 PLAYLIST_ITEM_BLOCK_END = PLAYLIST_BLOCK_END,
76 // 3
77 PLAYLIST_ITEM_BLOCK_SINGLE = PLAYLIST_BLOCK_BEGIN |
78 PLAYLIST_BLOCK_BODY |
79 PLAYLIST_BLOCK_END,
80 // 5
81 PLAYLIST_ITEM_LOOP_BEGIN = PLAYLIST_BLOCK_BEGIN |
82 PLAYLIST_BLOCK_LOOP,
83 // 4
84 PLAYLIST_ITEM_LOOP_BODY = PLAYLIST_BLOCK_BODY |
85 PLAYLIST_BLOCK_LOOP,
86 // 6
87 PLAYLIST_ITEM_LOOP_END = PLAYLIST_BLOCK_END |
88 PLAYLIST_BLOCK_LOOP,
89 // 7
90 PLAYLIST_ITEM_LOOP_SINGLE = PLAYLIST_BLOCK_BEGIN |
91 PLAYLIST_BLOCK_BODY |
92 PLAYLIST_BLOCK_END |
93 PLAYLIST_BLOCK_LOOP,
94 } playlist_item_type_t;
95
96 #define MAX_PLAYLIST_ITEMS 1024
97 #define MAX_LIBRARY_ITEMS 10240
98 #define PLAYLIST_ITEM_ERROR_LIB 1
99 #define PLAYLIST_ITEM_ERROR_CUE 2
100
101 /**
102 * @anchor playlist_item_t
103 *
104 * fu
105 */
106 typedef struct playlist_item
107 {
108 /*@{*/
109 char id[PATH_MAX]; /**< id of item, i.e. internal id or filename */
110 char title[PATH_MAX]; /**< title */
111 int in;
112 int dur;
113 int player; /**< player index that item currenly associated, -1 otherwise */
114 playlist_item_type_t type; /**< block type of item */
115 int int_idx; /**< internal playlist index */
116 // int omn_offset;
117 int error; /**< flag indicates if any error occured with item */
118 int del; /**< */
119 /*@}*/
120 } playlist_item_t;
121
122 #define MAX_PLAYERS 4
123
124 struct instance_desc;
125
126 typedef struct player_desc
127 {
128 int idx;
129 int unit;
130 void* handle;
131 GThread* thread;
132 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
133 struct instance_desc *app;
134 int playlist_start;
135 int playlist_length;
136 } player_t;
137
138 typedef struct instance_desc
139 {
140 GtkWidget *window;
141 GtkWidget *playlist_grid;
142 GtkWidget *library_tree;
143 GtkWidget *buttons[BUTTON_LAST + 1];
144 GtkWidget *status_label;
145 struct
146 {
147 player_t item[MAX_PLAYERS];
148 int count;
149 char host[PATH_MAX];
150 int port;
151 pthread_mutex_t lock;
152 } players;
153 int f_exit;
154 struct
155 {
156 playlist_item_t item[MAX_PLAYLIST_ITEMS];
157 int count;
158 int ver_curr;
159 int ver_prev;
160 pthread_mutex_t lock;
161 char* path;
162 GdkPixbuf *block_icons[8];
163 } playlist;
164 struct
165 {
166 int port;
167 void* handle[2];
168 GdkPixbuf *icons[8];
169
170
171 playlist_item_t item[MAX_LIBRARY_ITEMS];
172 int count;
173 char filename[PATH_MAX];
174 char whois[PATH_MAX];
175 pthread_mutex_t lock;
176 GThread* refresh_thread;
177 GtkWidget *search;
178 int id_display_rate;
179 int id_display_idx;
180 } library;
181 struct
182 {
183 playlist_item_t item[MAX_LIBRARY_ITEMS];
184 int count;
185 } clipboard;
186 } instance_t;
187
188 instance_t* instance_create(int argc, char** argv);
189 void instance_init(instance_t* app);
190 void instance_release(instance_t* app);
191 void instance_destroy(instance_t* app);
192
193 #if 0
194 void omnplay_library_load(omnplay_instance_t* app);
195 void omnplay_library_save(omnplay_instance_t* app);
196 void omnplay_library_refresh(omnplay_instance_t* app);
197 void omnplay_library_draw(omnplay_instance_t* app);
198
199 typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data);
200 int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit,
201 omnplay_get_content_cb_proc proc, void* data);
202 int omnplay_whois_list(omnplay_instance_t* app, playlist_item_t *items, int* plimit);
203 int omnplay_library_load_file(playlist_item_t* items, int *pcount, char* filename);
204 playlist_item_t* omnplay_library_find(omnplay_instance_t* app, char* id);
205 int omnplay_library_normalize_item(omnplay_instance_t* app, playlist_item_t* item);
206 int omnplay_library_relink_item(omnplay_instance_t* app, playlist_item_t* item);
207 playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *count);
208 void omnplay_playlist_normalize(omnplay_instance_t* app);
209 void omnplay_library_search(omnplay_instance_t* app, int next);
210 void omnplay_set_status(omnplay_instance_t* app, char* str);
211 int* omnplay_selected_idxs_playlist(omnplay_instance_t* app);
212
213 #endif
214
215 #ifdef __cplusplus
216 };
217 #endif /* __cplusplus */
218
219 #endif /* INSTANCE_H */