map media vicon popup
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / channelinfo.h
1 #ifndef CHANNELINFO_H
2 #define CHANNELINFO_H
3
4 #ifdef HAVE_DVB
5
6 #include "channel.inc"
7 #include "channeldb.h"
8 #include "channelinfo.inc"
9 #include "devicedvbinput.h"
10 #include "guicast.h"
11 #include "mwindow.inc"
12 #include "record.inc"
13 #include "recordbatches.h"
14 #include "signalstatus.h"
15 #include "videodevice.inc"
16 #include "vdevicempeg.inc"
17
18 #define LTBLACK 0x001c1c1c
19
20
21 class ChanSearch : public Thread
22 {
23 public:
24         ChannelInfo *iwindow;
25         ChanSearchGUI *gui;
26         Mutex *window_lock;
27
28         void start();
29         void stop();
30         void run();
31
32         ChanSearch(ChannelInfo *iwindow);
33         ~ChanSearch();
34 };
35
36 class ChanSearchGUI : public BC_Window
37 {
38 public:
39         ChanSearch *cswindow;
40         ChannelInfo *iwindow;
41         ChannelPanel *panel;
42         ChanSearchText *search_text;
43         ChanSearchTitleText *title_text;
44         ChanSearchInfoText *info_text;
45         ChanSearchMatchCase *match_case;
46         ChanSearchStart *search_start;
47         ChanSearchCancel *cancel;
48         ChanSearchList *search_list;
49         BC_Title *click_tip;
50         BC_Title *results;
51
52         int title_text_enable;
53         int info_text_enable;
54         int match_case_enable;
55         ChannelEvent *highlighted_event;
56         int search_x, search_y, text_x, text_y;
57         int cancel_x, cancel_y, cancel_w, cancel_h;
58         int list_x, list_y, list_w, list_h;
59         int results_x, results_y;
60         int sort_column, sort_order;
61
62         const char *search_column_titles[3];
63         int search_column_widths[3];
64         int search_columns[3];
65         ArrayList<BC_ListBoxItem*> search_items[3];
66         ArrayList<ChannelEvent*> search_results;
67
68         void create_objects();
69         int close_event();
70         int resize_event(int x, int y);
71         void update();
72         int search(const char *);
73         void search();
74         static int cmpr_text_dn(const void *a, const void *b);
75         static int cmpr_Text_dn(const void *a, const void *b);
76         static int cmpr_text_up(const void *a, const void *b);
77         static int cmpr_Text_up(const void *a, const void *b);
78         static int cmpr_time_dn(const void *a, const void *b);
79         static int cmpr_time_up(const void *a, const void *b);
80         static int cmpr_title_dn(const void *a, const void *b);
81         static int cmpr_Title_dn(const void *a, const void *b);
82         static int cmpr_title_up(const void *a, const void *b);
83         static int cmpr_Title_up(const void *a, const void *b);
84         void sort_events(int column, int order);
85         void move_column(int src, int dst);
86
87         ChanSearchGUI(ChanSearch *cswindow);
88         ~ChanSearchGUI();
89 };
90
91 class ChanSearchTitleText : public BC_CheckBox
92 {
93 public:
94         ChanSearchGUI *gui;
95
96         int handle_event();
97         void update(int v) { set_value(gui->title_text_enable = v); }
98
99         ChanSearchTitleText(ChanSearchGUI *gui, int x, int y);
100         ~ChanSearchTitleText();
101 };
102
103 class ChanSearchInfoText : public BC_CheckBox
104 {
105 public:
106         ChanSearchGUI *gui;
107
108         int handle_event();
109         void update(int v) { set_value(gui->info_text_enable = v); }
110
111         ChanSearchInfoText(ChanSearchGUI *gui, int x, int y);
112         ~ChanSearchInfoText();
113 };
114
115 class ChanSearchMatchCase : public BC_CheckBox
116 {
117 public:
118         ChanSearchGUI *gui;
119
120         int handle_event();
121
122         ChanSearchMatchCase(ChanSearchGUI *gui, int x, int y);
123         ~ChanSearchMatchCase();
124 };
125
126 class ChanSearchText : public BC_TextBox
127 {
128 public:
129         ChanSearchGUI *gui;
130
131         int handle_event();
132         int keypress_event();
133
134         ChanSearchText(ChanSearchGUI *gui, int x, int y, int w);
135         ~ChanSearchText();
136 };
137
138 class ChanSearchStart : public BC_GenericButton
139 {
140 public:
141         ChanSearchGUI *gui;
142
143         int handle_event();
144
145         ChanSearchStart(ChanSearchGUI *gui, int x, int y);
146         ~ChanSearchStart();
147 };
148
149 class ChanSearchCancel : public BC_CancelButton
150 {
151 public:
152         ChanSearchGUI *gui;
153
154         int handle_event();
155
156         ChanSearchCancel(ChanSearchGUI *gui, int x, int y);
157         ~ChanSearchCancel();
158 };
159
160 class ChanSearchList : public BC_ListBox
161 {
162 public:
163         ChanSearchGUI *gui;
164
165         int handle_event();
166         int sort_order_event();
167         int move_column_event();
168
169         ChanSearchList(ChanSearchGUI *gui, int x, int y, int w, int h);
170         ~ChanSearchList();
171 };
172
173
174 class ChannelProgress : public Thread, public BC_SubWindow
175 {
176         ChannelInfoGUI *gui;
177         BC_Title *eta;
178         BC_ProgressBar *bar;
179         Timer *eta_timer;
180         double length, value;
181         int done;
182 public:
183         void create_objects();
184         void run();
185         void start();
186         void stop();
187         int update();
188         void set_value(int v) { value = v; }
189
190         ChannelProgress(ChannelInfoGUI *gui, int x, int y, int w, int h, int len);
191         ~ChannelProgress();
192 };
193
194
195
196 class ChannelPanel : public BC_SubWindow
197 {
198 public:
199         ChannelInfoGUI *gui;
200         TimeLine *time_line;
201         ChannelData *channel_data;
202         ChannelFrame *channel_frame;
203         ChannelScroll *channel_scroll;
204         TimeLineScroll *time_line_scroll;
205         ArrayList<TimeLineItem*> time_line_items;
206         ArrayList<ChannelDataItem*> channel_data_items;
207         ArrayList<ChannelEventLine *> channel_line_items;
208         ArrayList<ChannelEvent*> channel_event_items;
209
210         int x0, y0, x1, y1, t0, t1;
211         int iwd, iht;
212         int x_moved, y_moved;
213         int iwindow_w, iwindow_h;
214         int path_w, path_h, hhr_w, x_now;
215         int frame_x, frame_y;
216         int frame_w, frame_h;
217         int x_scroll, y_scroll;
218         struct timeval tv;
219         struct timezone tz;
220         time_t st_org;
221
222         void create_objects();
223         ChannelEventLine *NewChannelLine(int y, int h, int color);
224         ChannelEventLine *NewChannelLine(int y) {
225                 return NewChannelLine(y, path_h, LTBLACK);
226         }
227         int separator(int y) {
228                 NewChannelLine(y+path_h/8, path_h/4, BLACK);
229                 return path_h/2;
230         }
231         void resize(int w, int h);
232         void bounding_box(int ix0, int iy0, int ix1, int iy1);
233         void set_x_scroll(int v);
234         void set_y_scroll(int v);
235         void reposition();
236         void get_xtime(int x, char *text);
237         void time_line_update(int ix0, int ix1);
238         int button_press_event();
239
240         ChannelPanel(ChannelInfoGUI *gui, int x, int y, int w, int h);
241         ~ChannelPanel();
242 };
243
244 class TimeLineItem : public BC_Title
245 {
246 public:
247         ChannelPanel *panel;
248         int x0, y0;
249
250         TimeLineItem(ChannelPanel *panel, int x, int y, char *text);
251         ~TimeLineItem();
252 };
253
254 class TimeLine : public BC_SubWindow
255 {
256 public:
257         ChannelPanel *panel;
258         int resize_event(int w, int h);
259
260         TimeLine(ChannelPanel *panel);
261         ~TimeLine();
262 };
263
264 class ChannelDataItem : public BC_Title
265 {
266 public:
267         ChannelPanel *panel;
268         int x0, y0;
269         const char *tip_info;
270
271         int repeat_event(int64_t duration);
272         void set_tooltip(const char *tip);
273
274         ChannelDataItem(ChannelPanel *panel, int x, int y, int w,
275                 int color, const char *text);
276         ~ChannelDataItem();
277 };
278
279 class ChannelData : public BC_SubWindow
280 {
281 public:
282         ChannelPanel *panel;
283
284         int resize_event(int w, int h);
285
286         ChannelData(ChannelPanel *panel, int x, int y, int w, int h);
287         ~ChannelData();
288 };
289
290 class ChannelScroll : public BC_ScrollBar
291 {
292 public:
293         ChannelPanel *panel;
294
295         int handle_event();
296
297         ChannelScroll(ChannelPanel *panel, int x, int y, int h);
298         ~ChannelScroll();
299 };
300
301 class TimeLineScroll : public BC_ScrollBar
302 {
303 public:
304         ChannelPanel *panel;
305
306         int handle_event();
307
308         TimeLineScroll(ChannelPanel *panel, int x, int y, int w);
309         ~TimeLineScroll();
310 };
311
312
313
314 class ChannelEvent : public BC_GenericButton
315 {
316 public:
317         ChannelEventLine *channel_line;
318         time_t start_time, end_time;
319         Channel *channel;
320         int x0, y0, no;
321         const char *tip_info;
322
323         int handle_event();
324         void set_tooltip(const char *tip);
325
326         ChannelEvent(ChannelEventLine *channel_line, Channel *channel,
327                 time_t start_time, time_t end_time, int x, int y, int w,
328                 const char *text);
329         ~ChannelEvent();
330 };
331
332 class ChannelEventLine : public BC_SubWindow
333 {
334 public:
335         ChannelPanel *panel;
336         int x0, y0;
337
338         void resize(int w, int h);
339
340         ChannelEventLine(ChannelPanel *panel, int x, int y, int w, int h, int color);
341         ~ChannelEventLine();
342 };
343
344 class ChannelFrame : public BC_SubWindow
345 {
346 public:
347         ChannelPanel *panel;
348
349         void resize(int w, int h);
350
351         ChannelFrame(ChannelPanel *panel);
352         ~ChannelFrame();
353 };
354
355
356
357 class ChannelInfoGUI : public BC_Window
358 {
359 public:
360         ChannelInfo *iwindow;
361         ChanSearch *channel_search;
362         ChannelPanel *panel;
363         ChannelProgress *progress;
364         ChannelStatus *channel_status;
365         ChannelInfoGUIBatches *batch_bay;
366         ChannelDir *channel_dir;
367         ChannelPath *channel_path;
368         ChannelStart *channel_start;
369         ChannelDuration *channel_duration;
370         ChannelSource *channel_source;
371         ChannelClearBatch *channel_clear_batch;
372         ChannelNewBatch *channel_new_batch;
373         ChannelDeleteBatch *channel_delete_batch;
374         TimeEntryTumbler *early_time, *late_time;
375         BC_Title *directory_title;
376         BC_Title *path_title;
377         BC_Title *start_title;
378         BC_Title *duration_title;
379         BC_Title *source_title;
380         BC_OKButton *ok;
381         BC_CancelButton *cancel;
382         ChannelInfoCron *channel_cron;
383         ChannelInfoPowerOff *channel_poweroff;
384         ChannelInfoFind *channel_find;
385         int x0, y0, title_w, data_w, pad;
386         int path_w, path_h, status_w;
387         int panel_w, panel_h, max_bay_w;
388         int bay_x, bay_y, bay_w, bay_h;
389         const char *cron_caption, *power_caption;
390         int cron_x, cron_y, cron_w, cron_h;
391         int power_x, power_y, power_w, power_h;
392         int find_x, find_y, find_h;
393         int ok_x, ok_y, ok_w, ok_h;
394         int cancel_x, cancel_y, cancel_w, cancel_h;
395
396         void create_objects();
397         void stop(int v);
398         int translation_event();
399         int resize_event(int w, int h);
400         int close_event();
401         void update_channel_tools();
402         void incr_event(int start_time_incr, int duration_incr);
403         void update_progress(int n) { progress->set_value(n); }
404
405         ChannelInfoGUI(ChannelInfo *iwindow, int x, int y, int w, int h);
406         ~ChannelInfoGUI();
407 };
408
409 class ChannelInfoOK : public BC_OKButton
410 {
411 public:
412         ChannelInfoGUI *gui;
413
414         int button_press_event();
415         int keypress_event();
416
417         ChannelInfoOK(ChannelInfoGUI *gui, int x, int y);
418         ~ChannelInfoOK();
419 };
420
421 class ChannelInfoCancel : public BC_CancelButton
422 {
423 public:
424         ChannelInfoGUI *gui;
425
426         int button_press_event();
427
428         ChannelInfoCancel(ChannelInfoGUI *gui, int x, int y);
429         ~ChannelInfoCancel();
430 };
431
432 class ChannelInfoCron : public BC_CheckBox
433 {
434 public:
435         ChannelInfoGUI *gui;
436
437         int handle_event();
438         ChannelInfoCron(ChannelInfoGUI *gui, int x, int y, int *value);
439         ~ChannelInfoCron();
440 };
441
442 class ChannelInfoPowerOff : public BC_CheckBox
443 {
444 public:
445         ChannelInfoGUI *gui;
446
447         int handle_event();
448
449         ChannelInfoPowerOff(ChannelInfoGUI *gui, int x, int y, int *value);
450         ~ChannelInfoPowerOff();
451 };
452
453 class ChannelInfoFind : public BC_GenericButton
454 {
455 public:
456         ChannelInfoGUI *gui;
457
458         int handle_event();
459         ChannelInfoFind(ChannelInfoGUI *gui, int x, int y);
460         ~ChannelInfoFind();
461 };
462
463
464 class ChannelInfoGUIBatches : public RecordBatchesGUI
465 {
466 public:
467         ChannelInfoGUI *gui;
468
469         int handle_event();
470         int selection_changed();
471
472         ChannelInfoGUIBatches(ChannelInfoGUI *gui,
473                 int x, int y, int w, int h);
474         ~ChannelInfoGUIBatches();
475 };
476
477 class ChannelDir : public RecordBatchesGUI::Dir
478 {
479 public:
480         ChannelInfoGUI *gui;
481
482         ChannelDir(ChannelInfoGUI *gui, const char *dir, int x, int y);
483 };
484
485 class ChannelPath : public RecordBatchesGUI::Path
486 {
487 public:
488         ChannelInfoGUI *gui;
489
490         ChannelPath(ChannelInfoGUI *gui, int x, int y);
491 };
492
493 class ChannelStart : public RecordBatchesGUI::StartTime
494 {
495 public:
496         ChannelInfoGUI *gui;
497
498         ChannelStart(ChannelInfoGUI *gui, int x, int y);
499 };
500
501 class ChannelDuration : public RecordBatchesGUI::Duration
502 {
503 public:
504         ChannelInfoGUI *gui;
505
506         ChannelDuration(ChannelInfoGUI *gui, int x, int y, int w);
507 };
508
509 class ChannelEarlyTime : public TimeEntryTumbler
510 {
511 public:
512         ChannelInfoGUI *gui;
513
514         int handle_up_event();
515         int handle_down_event();
516
517         ChannelEarlyTime(ChannelInfoGUI *gui, int x, int y,
518                 double *output_time);
519 };
520
521 class ChannelLateTime : public TimeEntryTumbler
522 {
523 public:
524         ChannelInfoGUI *gui;
525
526         int handle_up_event();
527         int handle_down_event();
528
529         ChannelLateTime(ChannelInfoGUI *gui, int x, int y,
530                 double *output_time);
531 };
532
533 class ChannelSource : public RecordBatchesGUI::Source
534 {
535 public:
536         ChannelInfoGUI *gui;
537         void create_objects();
538         int handle_event();
539         ChannelSource(ChannelInfoGUI *gui, int x, int y);
540 };
541
542
543 class ChannelNewBatch : public RecordBatchesGUI::NewBatch
544 {
545 public:
546         ChannelInfoGUI *gui;
547         int handle_event();
548         ChannelNewBatch(ChannelInfoGUI *gui, int x, int y);
549 };
550
551
552 class ChannelDeleteBatch : public RecordBatchesGUI::DeleteBatch
553 {
554 public:
555         ChannelInfoGUI *gui;
556         int handle_event();
557         ChannelDeleteBatch(ChannelInfoGUI *gui, int x, int y);
558 };
559
560 class ChannelClearBatch : public RecordBatchesGUI::ClearBatch
561 {
562 public:
563         ChannelInfoGUI *gui;
564         int handle_event();
565         ChannelClearBatch(ChannelInfoGUI *gui, int x, int y);
566 };
567
568
569
570 class ChannelInfo : public Thread
571 {
572 public:
573         MWindow *mwindow;
574         Record *record;
575         VideoDevice *vdevice;
576         Mutex *window_lock;
577         Mutex *vdevice_lock;
578         Mutex *progress_lock;
579         DeviceDVBInput *dvb_input;
580         RecordBatches record_batches;
581         ChannelInfoGUI *gui;
582         ChannelThread *thread;
583         ChannelDB *channeldb;
584         Condition *scan_lock;
585         int cron_enable, poweroff_enable;
586         int item;
587         int done, gui_done;
588
589         void run_scan();
590         void toggle_scan();
591         void start();
592         void stop();
593         void run();
594         void close_vdevice();
595         Batch *new_batch();
596         void delete_batch();
597         int current_batch() { return gui->batch_bay->current_batch(); }
598         int editing_batch() { return gui->batch_bay->editing_batch(); }
599         bool is_active() { return gui != 0; }
600
601         ChannelInfo(MWindow *mwindow);
602         ~ChannelInfo();
603 };
604
605 class ChannelThread : public Thread
606 {
607 public:
608         ChannelInfo *iwindow;
609         ChannelInfoGUI *gui;
610         ChannelPanel *panel;
611         zmpeg3_t *fd;
612         int done;
613
614         int load_ident(int n, int y, char *ident);
615         int load_info(Channel *channel, ChannelEventLine *channel_line);
616         void start();
617         void stop();
618         void run();
619         int total_channels() { return iwindow->channeldb->size(); }
620         Channel *get_channel(int ch) { return iwindow->channeldb->get(ch); }
621         int set_channel(Channel *chan);
622
623         ChannelThread(ChannelInfoGUI *gui);
624         ~ChannelThread();
625 };
626
627 class ChannelScan : public BC_MenuItem
628 {
629 public:
630         MWindow *mwindow;
631         int handle_event();
632
633         ChannelScan(MWindow *mwindow);
634         ~ChannelScan();
635 };
636
637 class ChannelStatus : public SignalStatus
638 {
639 public:
640         ChannelInfoGUI *gui;
641
642         ChannelStatus(ChannelInfoGUI *gui, int x, int y) :
643                 SignalStatus(gui, x, y) { this->gui = gui; }
644         ~ChannelStatus() {}
645 };
646
647
648 #endif
649 #endif