4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #ifndef DEVICEDVBINPUT_H
23 #define DEVICEDVBINPUT_H
25 #include "devicedvbinput.inc"
26 #include "devicempeginput.h"
27 #include "libzmpeg3.h"
28 #include "signalstatus.h"
30 #include "videodevice.h"
31 #include "vdevicedvb.h"
34 #include <linux/dvb/dmx.h>
35 #include <linux/dvb/frontend.h>
39 class DVBInputStatus : public Thread
41 friend class DeviceDVBInput;
43 DeviceDVBInput *dvb_input;
44 SignalStatus *signal_status;
53 DVBInputStatus(DeviceDVBInput *dvb_input);
57 class DeviceDVBInput : public DeviceMPEGInput
59 friend class DVBInputStatus;
60 friend class SignalStatus;
62 char frontend_path[BCTEXTLEN];
63 char demux_path[BCTEXTLEN];
64 char dvb_path[BCTEXTLEN];
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;
77 int wait_signal(int ms, int trys);
80 void dvb_close(int fe=0);
82 int drange(int v, int min, int max);
84 DeviceDVBInput(const char *name, int no);
85 static DeviceMPEGInput *NewDVBInput(const char *name, int no);
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(); }
93 int open_dev(int color_model);
96 void set_signal_status(SignalStatus *stat);
97 int has_signal() { return dvb_locked; }
98 int mpeg_fd() { return dvb_fd; }
100 VDeviceDVB *dvb_video() {
101 return video_device ? (VDeviceDVB *)video_device->input_base : 0;
103 AudioDVB *dvb_audio() {
104 return audio_device ? (AudioDVB *)audio_device->lowlevel_in : 0;
108 class DeviceDVBBuffer
113 DeviceDVBBuffer(int ifd, int isz) {
115 bsz = isz; bfr = new uint8_t[isz];
117 ~DeviceDVBBuffer() { delete [] bfr; }
119 int read(int retries, int usec, int bsz);
120 int size() { return sz; }
121 int operator [](int i) { return bfr[i]; }