prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / devicedvbinput.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef DEVICEDVBINPUT_H
23 #define DEVICEDVBINPUT_H
24
25 #include "devicedvbinput.inc"
26 #include "devicempeginput.h"
27 #include "libzmpeg3.h"
28 #include "signalstatus.h"
29 #include "thread.h"
30 #include "videodevice.h"
31 #include "vdevicedvb.h"
32
33 #include <stdint.h>
34 #include <linux/dvb/dmx.h>
35 #include <linux/dvb/frontend.h>
36
37
38
39 class DVBInputStatus : public Thread
40 {
41         friend class DeviceDVBInput;
42         int done;
43         DeviceDVBInput *dvb_input;
44         SignalStatus *signal_status;
45         void run();
46         void lock_dvb();
47         void unlock_dvb();
48 public:
49         void start();
50         void stop();
51         void update();
52
53         DVBInputStatus(DeviceDVBInput *dvb_input);
54         ~DVBInputStatus();
55 };
56
57 class DeviceDVBInput : public DeviceMPEGInput
58 {
59         friend class DVBInputStatus;
60         friend class SignalStatus;
61         Mutex *dvb_lock;
62         char frontend_path[BCTEXTLEN];
63         char demux_path[BCTEXTLEN];
64         char dvb_path[BCTEXTLEN];
65         int frontend_fd;
66         int demux_fd;
67         int dvb_fd;
68         int dvb_locked;
69         int signal_pwr, signal_crr, signal_lck;
70         int signal_snr, signal_ber, signal_unc;
71         DVBInputStatus *dvb_input_status;
72         struct dvb_frontend_info fe_info;
73         uint32_t pwr_min, pwr_max;
74         uint32_t snr_min, snr_max;
75
76         void reset_signal();
77         int wait_signal(int ms, int trys);
78         int dvb_sync();
79         int dvb_open();
80         void dvb_close(int fe=0);
81         int dvb_status();
82         int drange(int v, int min, int max);
83 public:
84         DeviceDVBInput(const char *name, int no);
85         static DeviceMPEGInput *NewDVBInput(const char *name, int no);
86         ~DeviceDVBInput();
87
88         static DeviceMPEGInput* get_mpeg_input(VideoDevice *device);
89         static DeviceMPEGInput* get_mpeg_input(AudioDevice *device);
90         void put_dvb_video() { put_mpeg_video(); }
91         void put_dvb_audio() { put_mpeg_audio(); }
92
93         int open_dev(int color_model);
94         void close_dev();
95         int status_dev();
96         void set_signal_status(SignalStatus *stat);
97         int has_signal() { return dvb_locked; }
98         int mpeg_fd() { return dvb_fd; }
99
100         VDeviceDVB *dvb_video() {
101                 return video_device ? (VDeviceDVB *)video_device->input_base : 0;
102         }
103         AudioDVB *dvb_audio() {
104                 return audio_device ? (AudioDVB *)audio_device->lowlevel_in : 0;
105         }
106 };
107
108 class DeviceDVBBuffer
109 {
110         int fd, sz, bsz;
111         uint8_t *bfr;
112 public:
113         DeviceDVBBuffer(int ifd, int isz) {
114                 fd = ifd;  sz = 0;
115                 bsz = isz;  bfr = new uint8_t[isz];
116         }
117         ~DeviceDVBBuffer() { delete [] bfr; }
118
119         int read(int retries, int usec, int bsz);
120         int size() { return sz; }
121         int operator [](int i) { return bfr[i]; }
122 };
123
124 #endif