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