ibeam column select tweaks, fix title alpha fader value popup, title bar border color...
[goodguy/cinelerra.git] / cinelerra-5.1 / 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 #ifdef HAVE_DVB
26
27 #include "devicedvbinput.inc"
28 #include "devicempeginput.h"
29 #include "libzmpeg3.h"
30 #include "signalstatus.h"
31 #include "thread.h"
32 #include "videodevice.h"
33 #include "vdevicedvb.h"
34
35 #include <stdint.h>
36 #include <linux/dvb/dmx.h>
37 #include <linux/dvb/frontend.h>
38
39
40
41 class DVBInputStatus : public Thread
42 {
43         friend class DeviceDVBInput;
44         int done;
45         DeviceDVBInput *dvb_input;
46         SignalStatus *signal_status;
47         void run();
48         void lock_dvb();
49         void unlock_dvb();
50 public:
51         void start();
52         void stop();
53         void update();
54
55         DVBInputStatus(DeviceDVBInput *dvb_input);
56         ~DVBInputStatus();
57 };
58
59 class DeviceDVBInput : public DeviceMPEGInput
60 {
61         friend class DVBInputStatus;
62         friend class SignalStatus;
63         Mutex *dvb_lock;
64         char frontend_path[BCTEXTLEN];
65         char demux_path[BCTEXTLEN];
66         char dvb_path[BCTEXTLEN];
67         int frontend_fd;
68         int demux_fd;
69         int dvb_fd;
70         int dvb_locked;
71         int signal_pwr, signal_crr, signal_lck;
72         int signal_snr, signal_ber, signal_unc;
73         DVBInputStatus *dvb_input_status;
74         struct dvb_frontend_info fe_info;
75         uint32_t pwr_min, pwr_max;
76         uint32_t snr_min, snr_max;
77
78         void reset_signal();
79         int wait_signal(int ms, int trys);
80         int dvb_sync();
81         int dvb_open();
82         void dvb_close(int fe=0);
83         int dvb_status();
84         int drange(int v, int min, int max);
85 public:
86         DeviceDVBInput(const char *name, int no);
87         static DeviceMPEGInput *NewDVBInput(const char *name, int no);
88         ~DeviceDVBInput();
89
90         static DeviceMPEGInput* get_mpeg_input(VideoDevice *device);
91         static DeviceMPEGInput* get_mpeg_input(AudioDevice *device);
92         void put_dvb_video() { put_mpeg_video(); }
93         void put_dvb_audio() { put_mpeg_audio(); }
94
95         int open_dev(int color_model);
96         void close_dev();
97         int status_dev();
98         void set_signal_status(SignalStatus *stat);
99         int has_signal() { return dvb_locked; }
100         int mpeg_fd() { return dvb_fd; }
101
102         VDeviceDVB *dvb_video() {
103                 return video_device ? (VDeviceDVB *)video_device->input_base : 0;
104         }
105         AudioDVB *dvb_audio() {
106                 return audio_device ? (AudioDVB *)audio_device->lowlevel_in : 0;
107         }
108 };
109
110 class DeviceDVBBuffer
111 {
112         int fd, sz, bsz;
113         uint8_t *bfr;
114 public:
115         DeviceDVBBuffer(int ifd, int isz) {
116                 fd = ifd;  sz = 0;
117                 bsz = isz;  bfr = new uint8_t[isz];
118         }
119         ~DeviceDVBBuffer() { delete [] bfr; }
120
121         int read(int retries, int usec, int bsz);
122         int size() { return sz; }
123         int operator [](int i) { return bfr[i]; }
124 };
125
126 #endif
127 #endif