add library search functions prototype
[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 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif /* __cplusplus */
27
28 typedef enum control_buttons
29 {
30 BUTTON_PLAYLIST_ITEM_ADD = 1,
31 BUTTON_PLAYLIST_ITEM_DEL,
32 BUTTON_PLAYLIST_ITEM_EDIT,
33
34 BUTTON_PLAYLIST_LOAD,
35 BUTTON_PLAYLIST_SAVE,
36
37 BUTTON_PLAYLIST_BLOCK_SINGLE,
38 BUTTON_PLAYLIST_BLOCK_LOOP,
39
40 BUTTON_PLAYLIST_ITEM_UP,
41 BUTTON_PLAYLIST_ITEM_DOWN,
42
43 BUTTON_PLAYER_CUE,
44 BUTTON_PLAYER_PLAY,
45 BUTTON_PLAYER_PAUSE,
46 BUTTON_PLAYER_STOP,
47
48 BUTTON_LIBRARY_ADD,
49 BUTTON_LIBRARY_REFRESH,
50
51 BUTTON_LIBRARY_FIND,
52 BUTTON_LIBRARY_FIND_NEXT,
53
54 BUTTON_LAST
55 } control_buttons_t;
56
57 #define OMNPLAY_PLAYLIST_BLOCK_BEGIN 1
58 #define OMNPLAY_PLAYLIST_BLOCK_BODY 0
59 #define OMNPLAY_PLAYLIST_BLOCK_END 2
60 #define OMNPLAY_PLAYLIST_BLOCK_LOOP 4
61
62 typedef enum playlist_item_type
63 {
64 // 1
65 OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN,
66 // 0
67 OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY,
68 // 2
69 OMNPLAY_PLAYLIST_ITEM_BLOCK_END = OMNPLAY_PLAYLIST_BLOCK_END,
70 // 3
71 OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
72 OMNPLAY_PLAYLIST_BLOCK_BODY |
73 OMNPLAY_PLAYLIST_BLOCK_END,
74 // 5
75 OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
76 OMNPLAY_PLAYLIST_BLOCK_LOOP,
77 // 4
78 OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY |
79 OMNPLAY_PLAYLIST_BLOCK_LOOP,
80 // 6
81 OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END |
82 OMNPLAY_PLAYLIST_BLOCK_LOOP,
83 // 7
84 OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
85 OMNPLAY_PLAYLIST_BLOCK_BODY |
86 OMNPLAY_PLAYLIST_BLOCK_END |
87 OMNPLAY_PLAYLIST_BLOCK_LOOP,
88 } playlist_item_type_t;
89
90 #define MAX_PLAYLIST_ITEMS 1024
91 #define MAX_LIBRARY_ITEMS 10240
92 #define PLAYLIST_ITEM_ERROR_LIB 1
93 #define PLAYLIST_ITEM_ERROR_CUE 2
94
95 typedef struct playlist_item
96 {
97 char id[PATH_MAX];
98 char title[PATH_MAX];
99 int in;
100 int dur;
101 int player;
102 playlist_item_type_t type;
103 int omn_idx;
104 int omn_offset;
105 int error;
106 } playlist_item_t;
107
108 #define MAX_PLAYERS 4
109
110 struct omnplay_instance;
111
112 typedef struct omnplay_player
113 {
114 int idx;
115 char name[PATH_MAX];
116 char host[PATH_MAX];
117 void* handle;
118 pthread_t thread;
119 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
120 struct omnplay_instance *app;
121 int playlist_start;
122 int playlist_length;
123 } omnplay_player_t;
124
125 typedef struct omnplay_instance
126 {
127 GtkWidget *window;
128 GtkWidget *playlist_grid;
129 GtkWidget *library_grid;
130 GtkWidget *buttons[BUTTON_LAST + 1];
131 struct
132 {
133 omnplay_player_t item[MAX_PLAYERS];
134 int count;
135 char path[PATH_MAX];
136 pthread_mutex_t lock;
137 } players;
138 int f_exit;
139 struct
140 {
141 playlist_item_t item[MAX_PLAYLIST_ITEMS];
142 int count;
143 int ver_curr;
144 int ver_prev;
145 pthread_mutex_t lock;
146 char* path;
147 GdkPixbuf *block_icons[8];
148 } playlist;
149 struct
150 {
151 playlist_item_t item[MAX_LIBRARY_ITEMS];
152 int count;
153 char filename[PATH_MAX];
154 char whois[PATH_MAX];
155 pthread_mutex_t lock;
156 pthread_t refresh_thread;
157 GtkWidget *refresh_ui[2];
158 GtkWidget *search;
159 } library;
160 } omnplay_instance_t;
161
162 omnplay_instance_t* omnplay_create(int argc, char** argv);
163 void omnplay_init(omnplay_instance_t* app);
164 void omnplay_release(omnplay_instance_t* app);
165 void omnplay_destroy(omnplay_instance_t* app);
166 void omnplay_playlist_load(omnplay_instance_t* app);
167 void omnplay_playlist_save(omnplay_instance_t* app);
168 void omnplay_playlist_draw(omnplay_instance_t* app);
169 void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx);
170 void omnplay_playlist_draw_item_rem(omnplay_instance_t* app, int idx, char* rem);
171 void omnplay_library_load(omnplay_instance_t* app);
172 void omnplay_library_save(omnplay_instance_t* app);
173 void omnplay_library_refresh(omnplay_instance_t* app);
174 void omnplay_library_draw(omnplay_instance_t* app);
175 typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data);
176 int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit,
177 omnplay_get_content_cb_proc proc, void* data);
178 int omnplay_whois_list(omnplay_instance_t* app, playlist_item_t *items, int* plimit);
179 int omnplay_library_load_file(playlist_item_t* items, int *pcount, char* filename);
180 playlist_item_t* omnplay_library_find(omnplay_instance_t* app, char* id);
181 int omnplay_library_normalize_item(omnplay_instance_t* app, playlist_item_t* item);
182 playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *count);
183 void omnplay_playlist_normalize(omnplay_instance_t* app);
184 void omnplay_library_search(omnplay_instance_t* app, int next);
185
186 #ifdef __cplusplus
187 };
188 #endif /* __cplusplus */
189
190 #endif /* OMNPLAY_H */