diff options
author | Mark Purcell <msp@debian.org> | 2012-05-13 19:42:13 +1000 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:54 +0200 |
commit | a537361120f6d717bfdf2793c82d2435ee0c9126 (patch) | |
tree | 73c81bb7e5d5d7e7b604b785d3a3ca7e46537850 /util/szap/util.c | |
parent | 96bce3638e9b6d3f3bac79494e11d877857de81e (diff) | |
parent | 5501530a778ad588a8ccd3f1584ea58f74c0cec9 (diff) | |
download | linux-dvb-apps-a537361120f6d717bfdf2793c82d2435ee0c9126.tar.gz |
Imported Debian patch 1.1.1+rev1483-1debian/1.1.1+rev1483-1
Diffstat (limited to '')
-rw-r--r-- | util/szap/util.c | 153 |
1 files changed, 75 insertions, 78 deletions
diff --git a/util/szap/util.c b/util/szap/util.c index 301d666..99d303a 100644 --- a/util/szap/util.c +++ b/util/szap/util.c @@ -35,92 +35,89 @@ int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr) { - struct dmx_pes_filter_params pesfilter; + struct dmx_pes_filter_params pesfilter; - /* ignore this pid to allow radio services */ - if (pid < 0 || - pid >= 0x1fff || - (pid == 0 && pes_type != DMX_PES_OTHER)) - return 0; + /* ignore this pid to allow radio services */ + if (pid < 0 || pid >= 0x1fff || (pid == 0 && pes_type != DMX_PES_OTHER)) + return 0; + + if (dvr) { + int buffersize = 64 * 1024; + if (ioctl(dmxfd, DMX_SET_BUFFER_SIZE, buffersize) == -1) + perror("DMX_SET_BUFFER_SIZE failed"); + } - if (dvr) { - int buffersize = 64 * 1024; - if (ioctl(dmxfd, DMX_SET_BUFFER_SIZE, buffersize) == -1) - perror("DMX_SET_BUFFER_SIZE failed"); - } - - pesfilter.pid = pid; - pesfilter.input = DMX_IN_FRONTEND; - pesfilter.output = dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER; - pesfilter.pes_type = pes_type; - pesfilter.flags = DMX_IMMEDIATE_START; - - if (ioctl(dmxfd, DMX_SET_PES_FILTER, &pesfilter) == -1) { - fprintf(stderr, "DMX_SET_PES_FILTER failed " - "(PID = 0x%04x): %d %m\n", pid, errno); - return -1; - } - - return 0; + pesfilter.pid = pid; + pesfilter.input = DMX_IN_FRONTEND; + pesfilter.output = dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER; + pesfilter.pes_type = pes_type; + pesfilter.flags = DMX_IMMEDIATE_START; + + if (ioctl(dmxfd, DMX_SET_PES_FILTER, &pesfilter) == -1) { + fprintf(stderr, "DMX_SET_PES_FILTER failed " + "(PID = 0x%04x): %d %m\n", pid, errno); + return -1; + } + return 0; } int get_pmt_pid(char *dmxdev, int sid) { - int patfd, count; - int pmt_pid = 0; - int patread = 0; - int section_length; - unsigned char buft[4096]; - unsigned char *buf = buft; - struct dmx_sct_filter_params f; - - memset(&f, 0, sizeof(f)); - f.pid = 0; - f.filter.filter[0] = 0x00; - f.filter.mask[0] = 0xff; - f.timeout = 0; - f.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC; - - if ((patfd = open(dmxdev, O_RDWR)) < 0) { - perror("openening pat demux failed"); - return -1; - } - - if (ioctl(patfd, DMX_SET_FILTER, &f) == -1) { - perror("ioctl DMX_SET_FILTER failed"); - close(patfd); - return -1; - } - - while (!patread){ - if (((count = read(patfd, buf, sizeof(buft))) < 0) && errno == EOVERFLOW) - count = read(patfd, buf, sizeof(buft)); - if (count < 0) { - perror("read_sections: read error"); - close(patfd); - return -1; + int patfd, count; + int pmt_pid = 0; + int patread = 0; + int section_length; + unsigned char buft[4096]; + unsigned char *buf = buft; + struct dmx_sct_filter_params f; + + memset(&f, 0, sizeof(f)); + f.pid = 0; + f.filter.filter[0] = 0x00; + f.filter.mask[0] = 0xff; + f.timeout = 0; + f.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC; + + if ((patfd = open(dmxdev, O_RDWR)) < 0) { + perror("openening pat demux failed"); + return -1; } - - section_length = ((buf[1] & 0x0f) << 8) | buf[2]; - if (count != section_length + 3) - continue; - - buf += 8; - section_length -= 8; - - patread = 1; /* assumes one section contains the whole pat */ - while (section_length > 0) { - int service_id = (buf[0] << 8) | buf[1]; - if (service_id == sid) { - pmt_pid = ((buf[2] & 0x1f) << 8) | buf[3]; - section_length = 0; - } - buf += 4; - section_length -= 4; + + if (ioctl(patfd, DMX_SET_FILTER, &f) == -1) { + perror("ioctl DMX_SET_FILTER failed"); + close(patfd); + return -1; } - } - close(patfd); - return pmt_pid; + while (!patread) { + if (((count = read(patfd, buf, sizeof(buft))) < 0) && errno == EOVERFLOW) + count = read(patfd, buf, sizeof(buft)); + + if (count < 0) { + perror("read_sections: read error"); + close(patfd); + return -1; + } + section_length = ((buf[1] & 0x0f) << 8) | buf[2]; + if (count != section_length + 3) + continue; + + buf += 8; + section_length -= 8; + + patread = 1; /* assumes one section contains the whole pat */ + while (section_length > 0) { + int service_id = (buf[0] << 8) | buf[1]; + + if (service_id == sid) { + pmt_pid = ((buf[2] & 0x1f) << 8) | buf[3]; + section_length = 0; + } + buf += 4; + section_length -= 4; + } + } + close(patfd); + return pmt_pid; } |