#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <errno.h>
#include <libzvbi.h>
static vbi_capture * cap;
static const char *
{
static char buffer[32];
switch (pil) {
default:
snprintf (buffer, sizeof (buffer),
"%02u%02uT%02u%02u",
return buffer;
}
}
static void
void * user_data)
{
user_data = user_data;
printf ("Received PIL %s/%02X on LC %u.\n",
}
static void
mainloop (void)
{
struct timeval timeout;
timeout.tv_sec = 2;
timeout.tv_usec = 0;
for (;;) {
vbi_capture_buffer *sliced_buffer;
unsigned int n_lines;
int r;
r = vbi_capture_pull (cap,
NULL,
&sliced_buffer,
&timeout);
switch (r) {
case -1:
fprintf (stderr, "VBI read error %d (%s)\n",
errno, strerror (errno));
exit (EXIT_FAILURE);
case 0:
fprintf (stderr, "VBI read timeout\n");
exit (EXIT_FAILURE);
case 1:
break;
default:
assert (0);
}
n_lines = sliced_buffer->size /
sizeof (
vbi_sliced);
n_lines,
sliced_buffer->timestamp);
}
}
int
main (void)
{
char *errstr;
vbi_bool success;
unsigned int services;
setlocale (LC_ALL, "");
services = (VBI_SLICED_TELETEXT_B |
VBI_SLICED_VPS);
cap = vbi_capture_v4l2_new ("/dev/vbi",
5,
&services,
0,
&errstr,
FALSE);
if (NULL == cap) {
fprintf (stderr,
"Cannot capture VBI data with V4L2 interface:\n"
"%s\n",
errstr);
free (errstr);
exit (EXIT_FAILURE);
}
assert (NULL != dec);
VBI_EVENT_PROG_ID,
NULL);
assert (success);
mainloop ();
vbi_capture_delete (cap);
exit (EXIT_SUCCESS);
}
vbi_bool vbi_event_handler_add(vbi_decoder *vbi, int event_mask, vbi_event_handler handler, void *user_data)
Definition vbi.c:188
#define VBI_PIL_DAY(pil)
Definition pdc.h:79
#define VBI_PIL_HOUR(pil)
Definition pdc.h:82
unsigned int vbi_pil
Program Identification Label.
Definition pdc.h:57
#define VBI_PIL_MINUTE(pil)
Definition pdc.h:85
#define VBI_PIL_MONTH(pil)
Definition pdc.h:76
@ VBI_PIL_CONTINUE
Definition pdc.h:145
@ VBI_PIL_INTERRUPTION
Definition pdc.h:135
@ VBI_PIL_INHIBIT_TERMINATE
Definition pdc.h:120
@ VBI_PIL_NSPV
Definition pdc.h:154
@ VBI_PIL_TIMER_CONTROL
Definition pdc.h:108
vbi_decoder * vbi_decoder_new(void)
Allocate a new data service decoder instance.
Definition vbi.c:870
void vbi_decode(vbi_decoder *vbi, vbi_sliced *sliced, int lines, double time)
Main function of the data service decoder.
Definition vbi.c:423
void vbi_decoder_delete(vbi_decoder *vbi)
Delete a data service decoder instance.
Definition vbi.c:832
Event union.
Definition event.h:736
Program Identification.
Definition pdc.h:351
unsigned int pty
Definition pdc.h:421
vbi_pil pil
Definition pdc.h:375
vbi_pid_channel channel
Definition pdc.h:353
This structure holds one scan line of sliced vbi data.
Definition sliced.h:320