9cceb616648f58686f3cb6be993ad77efe7e8a63
[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_LAST
52 } control_buttons_t;
53
54 #define OMNPLAY_PLAYLIST_BLOCK_BEGIN 1
55 #define OMNPLAY_PLAYLIST_BLOCK_BODY 0
56 #define OMNPLAY_PLAYLIST_BLOCK_END 2
57 #define OMNPLAY_PLAYLIST_BLOCK_LOOP 4
58
59 typedef enum playlist_item_type
60 {
61 // 1
62 OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN,
63 // 0
64 OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY,
65 // 2
66 OMNPLAY_PLAYLIST_ITEM_BLOCK_END = OMNPLAY_PLAYLIST_BLOCK_END,
67 // 3
68 OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
69 OMNPLAY_PLAYLIST_BLOCK_BODY |
70 OMNPLAY_PLAYLIST_BLOCK_END,
71 // 5
72 OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
73 OMNPLAY_PLAYLIST_BLOCK_LOOP,
74 // 4
75 OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY |
76 OMNPLAY_PLAYLIST_BLOCK_LOOP,
77 // 6
78 OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END |
79 OMNPLAY_PLAYLIST_BLOCK_LOOP,
80 // 7
81 OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN |
82 OMNPLAY_PLAYLIST_BLOCK_BODY |
83 OMNPLAY_PLAYLIST_BLOCK_END |
84 OMNPLAY_PLAYLIST_BLOCK_LOOP,
85 } playlist_item_type_t;
86
87 #define MAX_PLAYLIST_ITEMS 1024
88 #define MAX_LIBRARY_ITEMS 10240
89
90 typedef struct playlist_item
91 {
92 char id[PATH_MAX];
93 char title[PATH_MAX];
94 int in;
95 int dur;
96 int player;
97 playlist_item_type_t type;
98 int omn_idx;
99 int omn_offset;
100 } playlist_item_t;
101
102 #define MAX_PLAYERS 4
103
104 struct omnplay_instance;
105
106 typedef struct omnplay_player
107 {
108 int idx;
109 char name[PATH_MAX];
110 char host[PATH_MAX];
111 void* handle;
112 pthread_t thread;
113 GtkWidget *label_status, *label_state, *label_tc_cur, *label_tc_rem, *label_clip;
114 struct omnplay_instance *app;
115 int playlist_start;
116 int playlist_length;
117 } omnplay_player_t;
118
119 typedef struct omnplay_instance
120 {
121 GtkWidget *window;
122 GtkWidget *playlist_grid;
123 GtkWidget *library_grid;
124 GtkWidget *buttons[BUTTON_LAST + 1];
125 struct
126 {
127 omnplay_player_t item[MAX_PLAYERS];
128 int count;
129 char path[PATH_MAX];
130 pthread_mutex_t lock;
131 } players;
132 int f_exit;
133 struct
134 {
135 playlist_item_t item[MAX_PLAYLIST_ITEMS];
136 int count;
137 int ver_curr;
138 int ver_prev;
139 pthread_mutex_t lock;
140 char* path;
141 GdkPixbuf *block_icons[8];
142 } playlist;
143 struct
144 {
145 playlist_item_t item[MAX_LIBRARY_ITEMS];
146 int count;
147 char filename[PATH_MAX];
148 char whois[PATH_MAX];
149 pthread_mutex_t lock;
150 } library;
151 } omnplay_instance_t;
152
153 omnplay_instance_t* omnplay_create(int argc, char** argv);
154 void omnplay_init(omnplay_instance_t* app);
155 void omnplay_release(omnplay_instance_t* app);
156 void omnplay_destroy(omnplay_instance_t* app);
157 void omnplay_playlist_load(omnplay_instance_t* app);
158 void omnplay_playlist_save(omnplay_instance_t* app);
159 void omnplay_playlist_draw(omnplay_instance_t* app);
160 void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx);
161 void omnplay_playlist_draw_item_rem(omnplay_instance_t* app, int idx, char* rem);
162 void omnplay_library_load(omnplay_instance_t* app);
163 void omnplay_library_save(omnplay_instance_t* app);
164 void omnplay_library_refresh(omnplay_instance_t* app);
165 void omnplay_library_draw(omnplay_instance_t* app);
166
167 #ifdef __cplusplus
168 };
169 #endif /* __cplusplus */
170
171 #endif /* OMNPLAY_H */