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