8cd0378747b578b16e6388dac721ea1359b424ff
[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 typedef struct playlist_item
102 {
103 char id[PATH_MAX];
104 char title[PATH_MAX];
105 int in;
106 int dur;
107 int player;
108 playlist_item_type_t type;
109 int omn_idx;
110 int omn_offset;
111 int error;
112 int del;
113 } playlist_item_t;
114
115 #define MAX_PLAYERS 4
116
117 struct instance_desc;
118
119 typedef struct player_desc
120 {
121 int idx;
122 // char name[PATH_MAX];
123 int unit;
124 void* handle;
125 GThread* thread;
126 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
127 struct instance_desc *app;
128 int playlist_start;
129 int playlist_length;
130 } player_t;
131
132 typedef struct instance_desc
133 {
134 GtkWidget *window;
135 GtkWidget *playlist_grid;
136 GtkWidget *library_grid;
137 GtkWidget *buttons[BUTTON_LAST + 1];
138 GtkWidget *status_label;
139 struct
140 {
141 player_t item[MAX_PLAYERS];
142 int count;
143 char host[PATH_MAX];
144 pthread_mutex_t lock;
145 } players;
146 int f_exit;
147 struct
148 {
149 playlist_item_t item[MAX_PLAYLIST_ITEMS];
150 int count;
151 int ver_curr;
152 int ver_prev;
153 pthread_mutex_t lock;
154 char* path;
155 GdkPixbuf *block_icons[8];
156 } playlist;
157 struct
158 {
159 playlist_item_t item[MAX_LIBRARY_ITEMS];
160 int count;
161 char filename[PATH_MAX];
162 char whois[PATH_MAX];
163 pthread_mutex_t lock;
164 GThread* refresh_thread;
165 GtkWidget *search;
166 int id_display_rate;
167 int id_display_idx;
168 } library;
169 struct
170 {
171 playlist_item_t item[MAX_LIBRARY_ITEMS];
172 int count;
173 } clipboard;
174 } instance_t;
175
176 instance_t* instance_create(int argc, char** argv);
177 void instance_init(instance_t* app);
178 void instance_release(instance_t* app);
179 void instance_destroy(instance_t* app);
180
181 #if 0
182 void omnplay_library_load(omnplay_instance_t* app);
183 void omnplay_library_save(omnplay_instance_t* app);
184 void omnplay_library_refresh(omnplay_instance_t* app);
185 void omnplay_library_draw(omnplay_instance_t* app);
186
187 typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data);
188 int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit,
189 omnplay_get_content_cb_proc proc, void* data);
190 int omnplay_whois_list(omnplay_instance_t* app, playlist_item_t *items, int* plimit);
191 int omnplay_library_load_file(playlist_item_t* items, int *pcount, char* filename);
192 playlist_item_t* omnplay_library_find(omnplay_instance_t* app, char* id);
193 int omnplay_library_normalize_item(omnplay_instance_t* app, playlist_item_t* item);
194 int omnplay_library_relink_item(omnplay_instance_t* app, playlist_item_t* item);
195 playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *count);
196 void omnplay_playlist_normalize(omnplay_instance_t* app);
197 void omnplay_library_search(omnplay_instance_t* app, int next);
198 void omnplay_set_status(omnplay_instance_t* app, char* str);
199 int* omnplay_selected_idxs_playlist(omnplay_instance_t* app);
200
201 #endif
202
203 #ifdef __cplusplus
204 };
205 #endif /* __cplusplus */
206
207 #endif /* INSTANCE_H */