relink funcionality added
[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_PLAYLIST_RELINK,
57
58 BUTTON_LAST
59 } control_buttons_t;
60
61 #define OMNPLAY_PLAYLIST_BLOCK_BEGIN 1
62 #define OMNPLAY_PLAYLIST_BLOCK_BODY 0
63 #define OMNPLAY_PLAYLIST_BLOCK_END 2
64 #define OMNPLAY_PLAYLIST_BLOCK_LOOP 4
65
66 typedef enum playlist_item_type
67 {
68 // 1
69 OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN,
70 // 0
71 OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY,
72 // 2
73 OMNPLAY_PLAYLIST_ITEM_BLOCK_END = OMNPLAY_PLAYLIST_BLOCK_END,
74 // 3
75 OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
76 OMNPLAY_PLAYLIST_BLOCK_BODY |
77 OMNPLAY_PLAYLIST_BLOCK_END,
78 // 5
79 OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
80 OMNPLAY_PLAYLIST_BLOCK_LOOP,
81 // 4
82 OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY |
83 OMNPLAY_PLAYLIST_BLOCK_LOOP,
84 // 6
85 OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END |
86 OMNPLAY_PLAYLIST_BLOCK_LOOP,
87 // 7
88 OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
89 OMNPLAY_PLAYLIST_BLOCK_BODY |
90 OMNPLAY_PLAYLIST_BLOCK_END |
91 OMNPLAY_PLAYLIST_BLOCK_LOOP,
92 } playlist_item_type_t;
93
94 #define MAX_PLAYLIST_ITEMS 1024
95 #define MAX_LIBRARY_ITEMS 10240
96 #define PLAYLIST_ITEM_ERROR_LIB 1
97 #define PLAYLIST_ITEM_ERROR_CUE 2
98
99 typedef struct playlist_item
100 {
101 char id[PATH_MAX];
102 char title[PATH_MAX];
103 int in;
104 int dur;
105 int player;
106 playlist_item_type_t type;
107 int omn_idx;
108 int omn_offset;
109 int error;
110 int del;
111 } playlist_item_t;
112
113 #define MAX_PLAYERS 4
114
115 struct omnplay_instance;
116
117 typedef struct omnplay_player
118 {
119 int idx;
120 char name[PATH_MAX];
121 char host[PATH_MAX];
122 void* handle;
123 GThread* thread;
124 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
125 struct omnplay_instance *app;
126 int playlist_start;
127 int playlist_length;
128 } omnplay_player_t;
129
130 typedef struct omnplay_instance
131 {
132 GtkWidget *window;
133 GtkWidget *playlist_grid;
134 GtkWidget *library_grid;
135 GtkWidget *buttons[BUTTON_LAST + 1];
136 GtkWidget *status_label;
137 struct
138 {
139 omnplay_player_t item[MAX_PLAYERS];
140 int count;
141 char path[PATH_MAX];
142 pthread_mutex_t lock;
143 } players;
144 int f_exit;
145 struct
146 {
147 playlist_item_t item[MAX_PLAYLIST_ITEMS];
148 int count;
149 int ver_curr;
150 int ver_prev;
151 pthread_mutex_t lock;
152 char* path;
153 GdkPixbuf *block_icons[8];
154 } playlist;
155 struct
156 {
157 playlist_item_t item[MAX_LIBRARY_ITEMS];
158 int count;
159 char filename[PATH_MAX];
160 char whois[PATH_MAX];
161 pthread_mutex_t lock;
162 GThread* refresh_thread;
163 GtkWidget *search;
164 int id_display_rate;
165 int id_display_idx;
166 } library;
167 struct
168 {
169 playlist_item_t item[MAX_LIBRARY_ITEMS];
170 int count;
171 } clipboard;
172 } omnplay_instance_t;
173
174 omnplay_instance_t* omnplay_create(int argc, char** argv);
175 void omnplay_init(omnplay_instance_t* app);
176 void omnplay_release(omnplay_instance_t* app);
177 void omnplay_destroy(omnplay_instance_t* app);
178 void omnplay_playlist_load(omnplay_instance_t* app);
179 void omnplay_playlist_save(omnplay_instance_t* app);
180 void omnplay_playlist_relink(omnplay_instance_t* app);
181 void omnplay_playlist_draw(omnplay_instance_t* app);
182 void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx);
183 void omnplay_playlist_draw_item_rem(omnplay_instance_t* app, int idx, char* rem);
184 void omnplay_library_load(omnplay_instance_t* app);
185 void omnplay_library_save(omnplay_instance_t* app);
186 void omnplay_library_refresh(omnplay_instance_t* app);
187 void omnplay_library_draw(omnplay_instance_t* app);
188 typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data);
189 int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit,
190 omnplay_get_content_cb_proc proc, void* data);
191 int omnplay_whois_list(omnplay_instance_t* app, playlist_item_t *items, int* plimit);
192 int omnplay_library_load_file(playlist_item_t* items, int *pcount, char* filename);
193 playlist_item_t* omnplay_library_find(omnplay_instance_t* app, char* id);
194 int omnplay_library_normalize_item(omnplay_instance_t* app, playlist_item_t* item);
195 int omnplay_library_relink_item(omnplay_instance_t* app, playlist_item_t* item);
196 playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *count);
197 void omnplay_playlist_normalize(omnplay_instance_t* app);
198 void omnplay_library_search(omnplay_instance_t* app, int next);
199 void omnplay_set_status(omnplay_instance_t* app, char* str);
200 int* omnplay_selected_idxs_playlist(omnplay_instance_t* app);
201
202 #ifdef __cplusplus
203 };
204 #endif /* __cplusplus */
205
206 #endif /* OMNPLAY_H */