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
27 #include "devicedvbinput.inc"
28 #include "devicempeginput.h"
29 #include "libzmpeg3.h"
30 #include "signalstatus.h"
32 #include "videodevice.h"
33 #include "vdevicedvb.h"
36 #include <linux/dvb/dmx.h>
37 #include <linux/dvb/frontend.h>
41 class DVBInputStatus : public Thread
43 friend class DeviceDVBInput;
45 DeviceDVBInput *dvb_input;
46 SignalStatus *signal_status;
55 DVBInputStatus(DeviceDVBInput *dvb_input);
59 class DeviceDVBInput : public DeviceMPEGInput
61 friend class DVBInputStatus;
62 friend class SignalStatus;
64 char frontend_path[BCTEXTLEN];
65 char demux_path[BCTEXTLEN];
66 char dvb_path[BCTEXTLEN];
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;
79 int wait_signal(int ms, int trys);
82 void dvb_close(int fe=0);
84 int drange(int v, int min, int max);
86 DeviceDVBInput(const char *name, int no);
87 static DeviceMPEGInput *NewDVBInput(const char *name, int no);
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(); }
95 int open_dev(int color_model);
98 void set_signal_status(SignalStatus *stat);
99 int has_signal() { return dvb_locked; }
100 int mpeg_fd() { return dvb_fd; }
102 VDeviceDVB *dvb_video() {
103 return video_device ? (VDeviceDVB *)video_device->input_base : 0;
105 AudioDVB *dvb_audio() {
106 return audio_device ? (AudioDVB *)audio_device->lowlevel_in : 0;
110 class DeviceDVBBuffer
115 DeviceDVBBuffer(int ifd, int isz) {
117 bsz = isz; bfr = new uint8_t[isz];
119 ~DeviceDVBBuffer() { delete [] bfr; }
121 int read(int retries, int usec, int bsz);
122 int size() { return sz; }
123 int operator [](int i) { return bfr[i]; }