Go to the documentation of this file.
4 #include <linux/videodev2.h>
20 #define TVREC_CARDNUM \
21 ((m_tvrec != nullptr) ? QString::number(m_tvrec->GetInputId()) : "NULL")
23 #define LOC QString("V4LRec[%1](%2): ") \
24 .arg(TVREC_CARDNUM, m_videodevice)
58 if (name ==
"audiodevice")
60 else if (name ==
"vbidevice")
62 else if (name ==
"vbiformat")
70 auto *data =
static_cast<struct
VBIData *
>(data_in);
79 LOG(VB_GENERAL, LOG_DEBUG, QString(
"subtitle page %1.%2")
80 .arg(vtp->pgno, 0, 16) .arg(vtp->subno, 0, 16));
82 data->foundteletextpage =
true;
83 memcpy(&(
data->teletextpage), vtp,
sizeof(
vt_page));
100 struct VBIData *vbi_cb =
nullptr;
101 struct vbi *pal_tt =
nullptr;
109 pal_tt =
vbi_open(vbidev.constData(),
nullptr, 99, -1);
114 memset(vbi_cb, 0,
sizeof(
VBIData));
121 fd = open(vbidev.constData(), O_RDONLY);
125 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Invalid CC/Teletext mode");
131 LOG(VB_GENERAL, LOG_ERR,
LOC +
139 struct v4l2_format fmt {};
140 fmt.type = V4L2_BUF_TYPE_VBI_CAPTURE;
141 if (0 != ioctl(fd, VIDIOC_G_FMT, &fmt))
143 LOG(VB_RECORD, LOG_ERR,
"V4L2 VBI setup failed");
147 LOG(VB_RECORD, LOG_INFO,
LOC +
148 QString(
"vbi_format rate: %1"
149 "\n\t\t\t offset: %2"
150 "\n\t\t\tsamples_per_line: %3"
151 "\n\t\t\t starts: %4, %5"
152 "\n\t\t\t counts: %6, %7"
153 "\n\t\t\t flags: 0x%8")
154 .arg(fmt.fmt.vbi.sampling_rate)
155 .arg(fmt.fmt.vbi.offset)
156 .arg(fmt.fmt.vbi.samples_per_line)
157 .arg(fmt.fmt.vbi.start[0])
158 .arg(fmt.fmt.vbi.start[1])
159 .arg(fmt.fmt.vbi.count[0])
160 .arg(fmt.fmt.vbi.count[1])
161 .arg(fmt.fmt.vbi.flags,0,16));
163 width = fmt.fmt.vbi.samples_per_line;
164 start_line = fmt.fmt.vbi.start[0];
165 line_count = fmt.fmt.vbi.count[0];
166 if (line_count != fmt.fmt.vbi.count[1])
168 LOG(VB_GENERAL, LOG_ERR,
LOC +
169 "VBI must have the same number of "
170 "odd and even fields for our decoder");
174 if (start_line > 21 || start_line + line_count < 22)
176 LOG(VB_GENERAL, LOG_ERR,
LOC +
"VBI does not include line 21");
228 unsigned char *buf =
nullptr;
229 unsigned char *ptr =
nullptr;
230 unsigned char *ptr_end =
nullptr;
234 buf = ptr =
new unsigned char[sz];
246 struct timeval tv {0, 5000};
252 int nr = select(
m_vbiFd + 1, &rdset,
nullptr,
nullptr, &tv);
254 LOG(VB_GENERAL, LOG_ERR,
LOC +
"vbi select failed" +
ENO);
259 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"vbi select timed out");
275 ptr = (ret > 0) ? ptr + ret : ptr;
276 if ((ptr_end - ptr) == 0)
278 unsigned char *line21_field1 =
280 unsigned char *line21_field2 =
289 code1 = (0xFFFF==code1) ? -1 : code1;
290 code2 = (0xFFFF==code2) ? -1 : code2;
297 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Reading VBI data" +
ENO);
#define ENO
This can be appended to the LOG args with "+".
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
def read(device=None, features=[])
volatile bool m_requestHelper
bool IsErrored(void) override
Tells us whether an unrecoverable error has been encountered.
struct VBIData * m_palVbiCb
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static uint Parse(const QString &vbiformat)
void vbi_close(struct vbi *vbi)
void SetOption(const QString &name, const QString &value) override
Set an specific option.
void CloseVBIDevice(void)
void StopRecording(void) override
StopRecording() signals to the recorder that it should stop recording and exit cleanly.
struct vbi * vbi_open(const char *vbi_dev_name, [[maybe_unused]] struct cache *ca, int fine_tune, int big_buf)
void SetOption(const QString &name, const QString &value) override
Set an specific option.
virtual bool IsHelperRequested(void) const
int vbi_add_handler(struct vbi *vbi, vbic_handler handler, void *data)
virtual void StopRecording(void)
StopRecording() signals to the recorder that it should stop recording and exit cleanly.
static void vbi_event(void *data_in, struct vt_event *ev)
VBI608Extractor * m_vbi608
void vbi_handler(struct vbi *vbi, [[maybe_unused]] int fd)
bool isRunning(void) const
virtual void FormatCC(uint, uint)
virtual void FormatTT(struct VBIData *)
QString m_audioDeviceName
void vbi_del_handler(struct vbi *vbi, vbic_handler handler, void *data)
QWaitCondition m_unpauseWait
unsigned char data[VT_HEIGHT][VT_WIDTH]
virtual bool PauseAndWait(std::chrono::milliseconds timeout=100ms)
If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused,...
bool m_requestRecording
True if API call has requested a recording be [re]started.