aboutsummaryrefslogtreecommitdiffstats
path: root/util/szap/tzap.c
diff options
context:
space:
mode:
authorMark Purcell <msp@debian.org>2010-02-25 21:13:46 +1100
committeretobi <git@e-tobi.net>2013-09-03 09:48:46 +0200
commit665818f1969f893f05edf5b70eb1804c89b2829e (patch)
tree34ba68cee03c52d769a5a51b456b7e9d63cd091a /util/szap/tzap.c
parent109c7947d6a11a2a54eff1b19615ed80ea2f0602 (diff)
parent9fe4d4ea9c054e539ab679ed2e9c076c35beb69d (diff)
downloadlinux-dvb-apps-debian/1.1.1+rev1355-1.tar.gz
Imported Debian patch 1.1.1+rev1355-1debian/1.1.1+rev1355-1
Diffstat (limited to 'util/szap/tzap.c')
-rw-r--r--util/szap/tzap.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/util/szap/tzap.c b/util/szap/tzap.c
index cd87bfa..b24bc2c 100644
--- a/util/szap/tzap.c
+++ b/util/szap/tzap.c
@@ -35,6 +35,8 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
+#include "util.h"
+
static char FRONTEND_DEV [80];
static char DEMUX_DEV [80];
static char DVR_DEV [80];
@@ -269,7 +271,8 @@ static int check_fec(fe_code_rate_t *fec)
int parse(const char *fname, const char *channel,
- struct dvb_frontend_parameters *frontend, int *vpid, int *apid)
+ struct dvb_frontend_parameters *frontend, int *vpid, int *apid,
+ int *sid)
{
int fd;
int err;
@@ -343,7 +346,11 @@ int parse(const char *fname, const char *channel,
if ((err = try_parse_int(fd, apid, "Audio PID")))
return -13;
-
+
+ if ((err = try_parse_int(fd, sid, "Service ID")))
+ return -14;
+
+
close(fd);
return 0;
@@ -351,31 +358,6 @@ int parse(const char *fname, const char *channel,
static
-int set_pesfilter (int fd, int pid, dmx_pes_type_t type, int dvr)
-{
- struct dmx_pes_filter_params pesfilter;
-
- if (pid <= 0 || pid >= 0x1fff)
- return 0;
-
- pesfilter.pid = pid;
- pesfilter.input = DMX_IN_FRONTEND;
- pesfilter.output = dvr ? DMX_OUT_TS_TAP : DMX_OUT_DECODER;
- pesfilter.pes_type = type;
- pesfilter.flags = DMX_IMMEDIATE_START;
-
- if (ioctl(fd, DMX_SET_PES_FILTER, &pesfilter) < 0) {
- PERROR ("ioctl(DMX_SET_PES_FILTER) for %s PID failed",
- type == DMX_PES_AUDIO ? "Audio" :
- type == DMX_PES_VIDEO ? "Video" : "??");
- return -1;
- }
-
- return 0;
-}
-
-
-static
int setup_frontend (int fe_fd, struct dvb_frontend_parameters *frontend)
{
struct dvb_frontend_info fe_info;
@@ -503,6 +485,7 @@ static char *usage =
" -c file : read channels list from 'file'\n"
" -x : exit after tuning\n"
" -r : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
+ " -p : add pat and pmt to TS recording (implies -r)\n"
" -s : only print summary\n"
" -S : run silently (no output)\n"
" -H : human readable output\n"
@@ -519,15 +502,16 @@ int main(int argc, char **argv)
char *confname = NULL;
char *channel = NULL;
int adapter = 0, frontend = 0, demux = 0, dvr = 0;
- int vpid, apid;
+ int vpid, apid, sid, pmtpid = 0;
+ int pat_fd, pmt_fd;
int frontend_fd, audio_fd = 0, video_fd = 0, dvr_fd, file_fd;
int opt;
int record = 0;
int frontend_only = 0;
char *filename = NULL;
- int human_readable = 0;
+ int human_readable = 0, rec_psi = 0;
- while ((opt = getopt(argc, argv, "H?hrxRsFSn:a:f:d:c:t:o:")) != -1) {
+ while ((opt = getopt(argc, argv, "H?hrpxRsFSn:a:f:d:c:t:o:")) != -1) {
switch (opt) {
case 'a':
adapter = strtoul(optarg, NULL, 0);
@@ -548,6 +532,9 @@ int main(int argc, char **argv)
case 'r':
dvr = 1;
break;
+ case 'p':
+ rec_psi = 1;
+ break;
case 'x':
exit_after_tuning = 1;
break;
@@ -610,7 +597,7 @@ int main(int argc, char **argv)
memset(&frontend_param, 0, sizeof(struct dvb_frontend_parameters));
- if (parse (confname, channel, &frontend_param, &vpid, &apid))
+ if (parse (confname, channel, &frontend_param, &vpid, &apid, &sid))
return -1;
if ((frontend_fd = open(FRONTEND_DEV, O_RDWR)) < 0) {
@@ -624,6 +611,28 @@ int main(int argc, char **argv)
if (frontend_only)
goto just_the_frontend_dude;
+ if (rec_psi) {
+ pmtpid = get_pmt_pid(DEMUX_DEV, sid);
+ if (pmtpid <= 0) {
+ fprintf(stderr,"couldn't find pmt-pid for sid %04x\n",sid);
+ return -1;
+ }
+
+ if ((pat_fd = open(DEMUX_DEV, O_RDWR)) < 0) {
+ perror("opening pat demux failed");
+ return -1;
+ }
+ if (set_pesfilter(pat_fd, 0, DMX_PES_OTHER, dvr) < 0)
+ return -1;
+
+ if ((pmt_fd = open(DEMUX_DEV, O_RDWR)) < 0) {
+ perror("opening pmt demux failed");
+ return -1;
+ }
+ if (set_pesfilter(pmt_fd, pmtpid, DMX_PES_OTHER, dvr) < 0)
+ return -1;
+ }
+
if ((video_fd = open(DEMUX_DEV, O_RDWR)) < 0) {
PERROR("failed opening '%s'", DEMUX_DEV);
return -1;
@@ -689,6 +698,8 @@ just_the_frontend_dude:
check_frontend (frontend_fd, human_readable);
}
+ close (pat_fd);
+ close (pmt_fd);
close (audio_fd);
close (video_fd);
close (frontend_fd);