aboutsummaryrefslogtreecommitdiffstats
path: root/util/szap/szap.c
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2013-09-03 09:48:45 +0200
committeretobi <git@e-tobi.net>2013-09-03 09:48:45 +0200
commit9fe4d4ea9c054e539ab679ed2e9c076c35beb69d (patch)
treeaffff927f15c8ae6c77890cc9564855efe2e51db /util/szap/szap.c
parent9a5228e0f2b898367b7943d294be58caf6ce8bb3 (diff)
downloadlinux-dvb-apps-9fe4d4ea9c054e539ab679ed2e9c076c35beb69d.tar.gz
Imported Upstream version 1.1.1+rev1355upstream/1.1.1+rev1355
Diffstat (limited to '')
-rw-r--r--util/szap/szap.c97
1 files changed, 5 insertions, 92 deletions
diff --git a/util/szap/szap.c b/util/szap/szap.c
index ed1aa51..78da3a6 100644
--- a/util/szap/szap.c
+++ b/util/szap/szap.c
@@ -48,6 +48,7 @@
#include <linux/dvb/dmx.h>
#include <linux/dvb/audio.h>
#include "lnb.h"
+#include "util.h"
#ifndef TRUE
#define TRUE (1==1)
@@ -92,94 +93,6 @@ static char *usage_str =
" -p : add pat and pmt to TS recording (implies -r)\n"
" or -n numbers for zapping\n";
-static int set_demux(int dmxfd, int pid, int pes_type, int dvr)
-{
- struct dmx_pes_filter_params pesfilter;
-
- if (pid < 0 || pid >= 0x1fff) /* ignore this pid to allow radio services */
- return TRUE;
-
- 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 FALSE;
- }
-
- return TRUE;
-}
-
-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;
- }
-
- 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;
-}
-
struct diseqc_cmd {
struct dvb_diseqc_master_cmd cmd;
uint32_t wait;
@@ -390,10 +303,10 @@ int zap_to(unsigned int adapter, unsigned int frontend, unsigned int demux,
if (diseqc(fefd, sat_no, pol, hiband))
if (do_tune(fefd, ifreq, sr))
- if (set_demux(dmxfdv, vpid, DMX_PES_VIDEO, dvr))
+ if (set_pesfilter(dmxfdv, vpid, DMX_PES_VIDEO, dvr))
if (audiofd >= 0)
(void)ioctl(audiofd, AUDIO_SET_BYPASS_MODE, bypass);
- if (set_demux(dmxfda, apid, DMX_PES_AUDIO, dvr)) {
+ if (set_pesfilter(dmxfda, apid, DMX_PES_AUDIO, dvr)) {
if (rec_psi) {
pmtpid = get_pmt_pid(dmxdev, sid);
if (pmtpid < 0) {
@@ -403,8 +316,8 @@ int zap_to(unsigned int adapter, unsigned int frontend, unsigned int demux,
fprintf(stderr,"couldn't find pmt-pid for sid %04x\n",sid);
result = FALSE;
}
- if (set_demux(patfd, 0, DMX_PES_OTHER, dvr))
- if (set_demux(pmtfd, pmtpid, DMX_PES_OTHER, dvr))
+ if (set_pesfilter(patfd, 0, DMX_PES_OTHER, dvr))
+ if (set_pesfilter(pmtfd, pmtpid, DMX_PES_OTHER, dvr))
result = TRUE;
} else {
result = TRUE;