13
#include <linux/dvb/dmx.h>
14
#include <linux/dvb/frontend.h>
15
#include <linux/dvb/video.h>
21
int main(int argc, char **argv)
23
int fd, ffd, packets = 0;
24
struct timeval startt;
25
struct dmx_pes_filter_params flt;
27
unsigned char buffer[BSIZE];
29
fd = open("/dev/dvb/adapter0/dvr0", O_RDONLY);
31
ioctl(fd, DMX_SET_BUFFER_SIZE, 1024 * 1024);
33
ffd = open("/dev/dvb/adapter0/demux0", O_RDWR);
35
perror("/dev/dvb/adapter0/demux0");
40
flt.input = DMX_IN_FRONTEND;
41
flt.output = DMX_OUT_TS_TAP;
42
flt.pes_type = DMX_PES_OTHER;
45
if (ioctl(ffd, DMX_SET_PES_FILTER, &flt) < 0) {
46
perror("DMX_SET_PES_FILTER");
50
if (ioctl(ffd, DMX_START, 0) < 0) {
51
perror("DMX_SET_PES_FILTER");
55
gettimeofday(&startt, 0);
64
if ((r = read(fd, buffer, 188)) <= 0) {
69
printf("only read %d\n", r);
72
if (buffer[0] != 0x47) {
74
printf("desync (%x)\n", buffer[0]);
75
while (buffer[0] != 0x47)
80
pid = ((((unsigned) buffer[1]) << 8) |
81
((unsigned) buffer[2])) & 0x1FFF;
84
int i, sl = strlen(search);
87
for (i = 0; i < (188 - sl); ++i) {
88
if (!memcmp(buffer + i, search, sl))
101
if (!(packets & 0xFF)) {
104
gettimeofday(&now, 0);
106
(now.tv_sec - startt.tv_sec) * 1000 +
107
(now.tv_usec - startt.tv_usec) / 1000;
110
for (pid = 0; pid < 0x2001; pid++) {
112
printf("%04x %5d p/s %5d kb/s %5d kbit\n",
114
pidt[pid] * 1000 / diff,
115
pidt[pid] * 1000 / diff * 188 / 1024,
116
pidt[pid] * 8 * 1000 / diff * 188 / 1000);
120
printf("-PID--FREQ-----BANDWIDTH-BANDWIDTH-\n");