* [PATCH 1 of 7] szap: move duplicate function set_pesfilter|demux to a common object
[not found] <patchbomb.1265826616@aniel.lan>
@ 2010-02-10 18:36 ` Janne Grunau
2010-02-10 18:36 ` [PATCH 2 of 7] szap: move get_pmt_pid() to utils.c Janne Grunau
` (5 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:36 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
util/szap/Makefile | 2 +-
util/szap/azap.c | 27 +--------------------
util/szap/czap.c | 27 +--------------------
util/szap/szap.c | 37 ++++--------------------------
util/szap/tzap.c | 27 +--------------------
util/szap/util.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
util/szap/util.h | 22 ++++++++++++++++++
7 files changed, 99 insertions(+), 108 deletions(-)
[-- Attachment #2: dvb-apps-1.patch --]
[-- Type: text/x-patch, Size: 9578 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265820041 -3600
# Node ID 28369a87b6c7db2a5704be5dda8ed60a4cbf3397
# Parent 80e9da1c00934139c817b33430bf44836f51406e
szap: move duplicate function set_pesfilter|demux to a common object
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/Makefile
--- a/util/szap/Makefile Sun Feb 07 17:01:50 2010 +0100
+++ b/util/szap/Makefile Wed Feb 10 17:40:41 2010 +0100
@@ -1,6 +1,6 @@
# Makefile for linuxtv.org dvb-apps/util/szap
-objects = lnb.o
+objects = lnb.o util.o
binaries = azap \
czap \
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/azap.c
--- a/util/szap/azap.c Sun Feb 07 17:01:50 2010 +0100
+++ b/util/szap/azap.c Wed Feb 10 17:40:41 2010 +0100
@@ -13,6 +13,8 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
+#include "util.h"
+
static char FRONTEND_DEV [80];
static char DEMUX_DEV [80];
@@ -209,31 +211,6 @@
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;
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/czap.c
--- a/util/szap/czap.c Sun Feb 07 17:01:50 2010 +0100
+++ b/util/szap/czap.c Wed Feb 10 17:40:41 2010 +0100
@@ -13,6 +13,8 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
+#include "util.h"
+
static char FRONTEND_DEV [80];
static char DEMUX_DEV [80];
@@ -178,31 +180,6 @@
}
-
-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)
{
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/szap.c
--- a/util/szap/szap.c Sun Feb 07 17:01:50 2010 +0100
+++ b/util/szap/szap.c Wed Feb 10 17:40:41 2010 +0100
@@ -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,34 +93,6 @@
" -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;
@@ -390,10 +363,10 @@
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 +376,8 @@
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;
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/tzap.c
--- a/util/szap/tzap.c Sun Feb 07 17:01:50 2010 +0100
+++ b/util/szap/tzap.c Wed Feb 10 17:40:41 2010 +0100
@@ -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];
@@ -351,31 +353,6 @@
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;
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/util.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util/szap/util.c Wed Feb 10 17:40:41 2010 +0100
@@ -0,0 +1,65 @@
+/*
+ * util functions for various ?zap implementations
+ *
+ * Copyright (C) 2001 Johannes Stezenbach (js@convergence.de)
+ * for convergence integrated media
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <linux/dvb/frontend.h>
+#include <linux/dvb/dmx.h>
+
+
+int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr)
+{
+ 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;
+
+ 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;
+}
diff -r 80e9da1c0093 -r 28369a87b6c7 util/szap/util.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util/szap/util.h Wed Feb 10 17:40:41 2010 +0100
@@ -0,0 +1,22 @@
+/*
+ * util functions for various ?zap implementations
+ *
+ * Copyright (C) 2001 Johannes Stezenbach (js@convergence.de)
+ * for convergence integrated media
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr);
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 2 of 7] szap: move get_pmt_pid() to utils.c
[not found] <patchbomb.1265826616@aniel.lan>
2010-02-10 18:36 ` [PATCH 1 of 7] szap: move duplicate function set_pesfilter|demux to a common object Janne Grunau
@ 2010-02-10 18:36 ` Janne Grunau
2010-02-10 18:36 ` [PATCH 3 of 7] czap: reformat and extend usage string Janne Grunau
` (4 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:36 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
util/szap/szap.c | 60 -------------------------------------------------------
util/szap/util.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
util/szap/util.h | 2 +
3 files changed, 63 insertions(+), 60 deletions(-)
[-- Attachment #2: dvb-apps-2.patch --]
[-- Type: text/x-patch, Size: 4094 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265820330 -3600
# Node ID d79f9e2901a05fbee905998294d9cb1ae46a422d
# Parent 28369a87b6c7db2a5704be5dda8ed60a4cbf3397
szap: move get_pmt_pid() to utils.c
to be reused by the other zap implemetations
diff -r 28369a87b6c7 -r d79f9e2901a0 util/szap/szap.c
--- a/util/szap/szap.c Wed Feb 10 17:40:41 2010 +0100
+++ b/util/szap/szap.c Wed Feb 10 17:45:30 2010 +0100
@@ -93,66 +93,6 @@
" -p : add pat and pmt to TS recording (implies -r)\n"
" or -n numbers for zapping\n";
-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;
diff -r 28369a87b6c7 -r d79f9e2901a0 util/szap/util.c
--- a/util/szap/util.c Wed Feb 10 17:40:41 2010 +0100
+++ b/util/szap/util.c Wed Feb 10 17:45:30 2010 +0100
@@ -63,3 +63,64 @@
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;
+ }
+
+ 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;
+}
diff -r 28369a87b6c7 -r d79f9e2901a0 util/szap/util.h
--- a/util/szap/util.h Wed Feb 10 17:40:41 2010 +0100
+++ b/util/szap/util.h Wed Feb 10 17:45:30 2010 +0100
@@ -20,3 +20,5 @@
*/
int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr);
+
+int get_pmt_pid(char *dmxdev, int sid);
\ No newline at end of file
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 3 of 7] czap: reformat and extend usage string
[not found] <patchbomb.1265826616@aniel.lan>
2010-02-10 18:36 ` [PATCH 1 of 7] szap: move duplicate function set_pesfilter|demux to a common object Janne Grunau
2010-02-10 18:36 ` [PATCH 2 of 7] szap: move get_pmt_pid() to utils.c Janne Grunau
@ 2010-02-10 18:36 ` Janne Grunau
2010-02-10 18:37 ` [PATCH 4 of 7] czap: use %m modifier in sscanf instead of %a Janne Grunau
` (3 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:36 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 94 bytes --]
util/szap/czap.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
[-- Attachment #2: dvb-apps-3.patch --]
[-- Type: text/x-patch, Size: 1273 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265823779 -3600
# Node ID c1e4c34da4fd395755d98dbbdd7af2950d723a9d
# Parent d79f9e2901a05fbee905998294d9cb1ae46a422d
czap: reformat and extend usage string
diff -r d79f9e2901a0 -r c1e4c34da4fd util/szap/czap.c
--- a/util/szap/czap.c Wed Feb 10 17:45:30 2010 +0100
+++ b/util/szap/czap.c Wed Feb 10 18:42:59 2010 +0100
@@ -241,9 +241,19 @@
}
-static const char *usage = "\nusage: %s [-a adapter_num] [-f frontend_id] [-d demux_id] [-c conf_file] [ -H ] {<channel name>| -n channel_num} [-x]\n"
- " or: %s [-c conf_file] -l\n\n";
-
+static const char *usage =
+ "\nusage: %s [options] -l\n"
+ " list known channels\n"
+ " %s [options] {-n channel-number|channel_name}\n"
+ " zap to channel via number or full name (case insensitive)\n"
+ " -a number : use given adapter (default 0)\n"
+ " -f number : use given frontend (default 0)\n"
+ " -d number : use given demux (default 0)\n"
+ " -c file : read channels list from 'file'\n"
+ " -x : exit after tuning\n"
+ " -H : human readable output\n"
+ " -r : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
+;
int main(int argc, char **argv)
{
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 4 of 7] czap: use %m modifier in sscanf instead of %a
[not found] <patchbomb.1265826616@aniel.lan>
` (2 preceding siblings ...)
2010-02-10 18:36 ` [PATCH 3 of 7] czap: reformat and extend usage string Janne Grunau
@ 2010-02-10 18:37 ` Janne Grunau
2010-02-10 18:37 ` [PATCH 5 of 7] czap: implement -p option to record PAT & PMT (PSI) Janne Grunau
` (2 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:37 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 78 bytes --]
util/szap/czap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
[-- Attachment #2: dvb-apps-4.patch --]
[-- Type: text/x-patch, Size: 778 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265823785 -3600
# Node ID 0163e837905411bb9932bb65fecde5735e5bd7e9
# Parent c1e4c34da4fd395755d98dbbdd7af2950d723a9d
czap: use %m modifier in sscanf instead of %a
%a is a old glibc extension and conflicts with
the floating point modifier %a in C99
diff -r c1e4c34da4fd -r 0163e8379054 util/szap/czap.c
--- a/util/szap/czap.c Wed Feb 10 18:42:59 2010 +0100
+++ b/util/szap/czap.c Wed Feb 10 18:43:05 2010 +0100
@@ -143,7 +143,7 @@
}
printf("%3d %s", chan_no, chan);
- if ((sscanf(chan, "%a[^:]:%d:%a[^:]:%d:%a[^:]:%a[^:]:%d:%d\n",
+ if ((sscanf(chan, "%m[^:]:%d:%m[^:]:%d:%m[^:]:%m[^:]:%d:%d\n",
&name, &frontend->frequency,
&inv, &frontend->u.qam.symbol_rate,
&fec, &mod, vpid, apid) != 8)
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 5 of 7] czap: implement -p option to record PAT & PMT (PSI)
[not found] <patchbomb.1265826616@aniel.lan>
` (3 preceding siblings ...)
2010-02-10 18:37 ` [PATCH 4 of 7] czap: use %m modifier in sscanf instead of %a Janne Grunau
@ 2010-02-10 18:37 ` Janne Grunau
2010-02-10 18:37 ` [PATCH 6 of 7] tzap: implement recording program and service information with -p Janne Grunau
2010-02-10 18:37 ` [PATCH 7 of 7] azap: implement record " Janne Grunau
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:37 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 127 bytes --]
util/szap/czap.c | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
[-- Attachment #2: dvb-apps-5.patch --]
[-- Type: text/x-patch, Size: 3902 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265820428 -3600
# Node ID c46ead95be23c07b1c95329c713b4dfc649fd67d
# Parent 0163e837905411bb9932bb65fecde5735e5bd7e9
czap: implement -p option to record PAT & PMT (PSI)
diff -r 0163e8379054 -r c46ead95be23 util/szap/czap.c
--- a/util/szap/czap.c Wed Feb 10 18:43:05 2010 +0100
+++ b/util/szap/czap.c Wed Feb 10 17:47:08 2010 +0100
@@ -120,7 +120,7 @@
int parse(const char *fname, int list_channels, int chan_no, const char *channel,
- struct dvb_frontend_parameters *frontend, int *vpid, int *apid)
+ struct dvb_frontend_parameters *frontend, int *vpid, int *apid, int *sid)
{
FILE *f;
char *chan;
@@ -143,10 +143,10 @@
}
printf("%3d %s", chan_no, chan);
- if ((sscanf(chan, "%m[^:]:%d:%m[^:]:%d:%m[^:]:%m[^:]:%d:%d\n",
+ if ((sscanf(chan, "%m[^:]:%d:%m[^:]:%d:%m[^:]:%m[^:]:%d:%d:%d\n",
&name, &frontend->frequency,
&inv, &frontend->u.qam.symbol_rate,
- &fec, &mod, vpid, apid) != 8)
+ &fec, &mod, vpid, apid, sid) != 9)
|| !name || !inv || !fec | !mod) {
ERROR("cannot parse service data");
return -3;
@@ -167,10 +167,10 @@
ERROR("modulation field syntax '%s'", mod);
return -6;
}
- printf("%3d %s: f %d, s %d, i %d, fec %d, qam %d, v %#x, a %#x\n",
+ printf("%3d %s: f %d, s %d, i %d, fec %d, qam %d, v %#x, a %#x, s %#x \n",
chan_no, name, frontend->frequency, frontend->u.qam.symbol_rate,
frontend->inversion, frontend->u.qam.fec_inner,
- frontend->u.qam.modulation, *vpid, *apid);
+ frontend->u.qam.modulation, *vpid, *apid, *sid);
free(name);
free(inv);
free(fec);
@@ -253,6 +253,7 @@
" -x : exit after tuning\n"
" -H : human readable output\n"
" -r : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
+ " -p : add pat and pmt to TS recording (implies -r)\n"
;
int main(int argc, char **argv)
@@ -262,12 +263,12 @@
char *confname = NULL;
char *channel = NULL;
int adapter = 0, frontend = 0, demux = 0, dvr = 0;
- int vpid, apid;
- int frontend_fd, video_fd, audio_fd;
+ int vpid, apid, sid, pmtpid = 0;
+ int frontend_fd, video_fd, audio_fd, pat_fd, pmt_fd;
int opt, list_channels = 0, chan_no = 0;
- int human_readable = 0;
+ int human_readable = 0, rec_psi = 0;
- while ((opt = getopt(argc, argv, "Hln:hrn:a:f:d:c:x")) != -1) {
+ while ((opt = getopt(argc, argv, "Hln:hrn:a:f:d:c:x:p")) != -1) {
switch (opt) {
case 'a':
adapter = strtoul(optarg, NULL, 0);
@@ -287,6 +288,9 @@
case 'n':
chan_no = strtoul(optarg, NULL, 0);
break;
+ case 'p':
+ rec_psi = 1;
+ break;
case 'x':
exit_after_tuning = 1;
break;
@@ -339,7 +343,7 @@
memset(&frontend_param, 0, sizeof(struct dvb_frontend_parameters));
- if (parse(confname, list_channels, chan_no, channel, &frontend_param, &vpid, &apid))
+ if (parse(confname, list_channels, chan_no, channel, &frontend_param, &vpid, &apid, &sid))
return -1;
if (list_channels)
return 0;
@@ -352,6 +356,28 @@
if (setup_frontend(frontend_fd, &frontend_param) < 0)
return -1;
+ 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;
@@ -370,6 +396,8 @@
check_frontend (frontend_fd, human_readable);
+ close (pat_fd);
+ close (pmt_fd);
close (audio_fd);
close (video_fd);
close (frontend_fd);
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 6 of 7] tzap: implement recording program and service information with -p
[not found] <patchbomb.1265826616@aniel.lan>
` (4 preceding siblings ...)
2010-02-10 18:37 ` [PATCH 5 of 7] czap: implement -p option to record PAT & PMT (PSI) Janne Grunau
@ 2010-02-10 18:37 ` Janne Grunau
2010-02-10 18:37 ` [PATCH 7 of 7] azap: implement record " Janne Grunau
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:37 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 124 bytes --]
util/szap/tzap.c | 46 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 40 insertions(+), 6 deletions(-)
[-- Attachment #2: dvb-apps-6.patch --]
[-- Type: text/x-patch, Size: 3295 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265824478 -3600
# Node ID c38dce87f96ab87a59c3565da978d3564ff438c3
# Parent c46ead95be23c07b1c95329c713b4dfc649fd67d
tzap: implement recording program and service information with -p
diff -r c46ead95be23 -r c38dce87f96a util/szap/tzap.c
--- a/util/szap/tzap.c Wed Feb 10 17:47:08 2010 +0100
+++ b/util/szap/tzap.c Wed Feb 10 18:54:38 2010 +0100
@@ -271,7 +271,8 @@
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;
@@ -345,7 +346,11 @@
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;
@@ -480,6 +485,7 @@
" -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"
@@ -496,15 +502,16 @@
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);
@@ -525,6 +532,9 @@
case 'r':
dvr = 1;
break;
+ case 'p':
+ rec_psi = 1;
+ break;
case 'x':
exit_after_tuning = 1;
break;
@@ -587,7 +597,7 @@
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) {
@@ -601,6 +611,28 @@
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;
@@ -666,6 +698,8 @@
check_frontend (frontend_fd, human_readable);
}
+ close (pat_fd);
+ close (pmt_fd);
close (audio_fd);
close (video_fd);
close (frontend_fd);
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 7 of 7] azap: implement record program and service information with -p
[not found] <patchbomb.1265826616@aniel.lan>
` (5 preceding siblings ...)
2010-02-10 18:37 ` [PATCH 6 of 7] tzap: implement recording program and service information with -p Janne Grunau
@ 2010-02-10 18:37 ` Janne Grunau
6 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2010-02-10 18:37 UTC (permalink / raw)
To: linux-media
[-- Attachment #1: Type: text/plain, Size: 123 bytes --]
util/szap/azap.c | 45 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 38 insertions(+), 7 deletions(-)
[-- Attachment #2: dvb-apps-7.patch --]
[-- Type: text/x-patch, Size: 2863 bytes --]
# HG changeset patch
# User Janne Grunau <j@jannau.net>
# Date 1265824500 -3600
# Node ID eb8e295536aa230a2b5f1fbab777786ab4b99527
# Parent c38dce87f96ab87a59c3565da978d3564ff438c3
azap: implement record program and service information with -p
diff -r c38dce87f96a -r eb8e295536aa util/szap/azap.c
--- a/util/szap/azap.c Wed Feb 10 18:54:38 2010 +0100
+++ b/util/szap/azap.c Wed Feb 10 18:55:00 2010 +0100
@@ -171,7 +171,8 @@
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 *pno)
{
int fd;
int err;
@@ -202,7 +203,10 @@
return -5;
if ((err = try_parse_int(fd, apid, "Audio PID")))
- return -6;
+ return -6;
+
+ if ((err = try_parse_int(fd, pno, "MPEG Program Number")))
+ return -7;
close(fd);
@@ -275,12 +279,12 @@
char *homedir = getenv ("HOME");
char *confname = NULL;
char *channel = NULL;
- int adapter = 0, frontend = 0, demux = 0, dvr = 0;
- int vpid, apid;
- int frontend_fd, audio_fd, video_fd;
+ int adapter = 0, frontend = 0, demux = 0, dvr = 0, rec_psi = 0;
+ int vpid, apid, pno, pmtpid = 0;
+ int frontend_fd, audio_fd, video_fd, pat_fd, pmt_fd;
int opt;
- while ((opt = getopt(argc, argv, "hrn:a:f:d:c:")) != -1) {
+ while ((opt = getopt(argc, argv, "hrpn:a:f:d:c:")) != -1) {
switch (opt) {
case 'a':
adapter = strtoul(optarg, NULL, 0);
@@ -294,6 +298,9 @@
case 'r':
dvr = 1;
break;
+ case 'p':
+ rec_psi = 1;
+ break;
case 'c':
confname = optarg;
break;
@@ -333,7 +340,7 @@
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, &pno))
return -1;
if ((frontend_fd = open(FRONTEND_DEV, O_RDWR)) < 0) {
@@ -344,6 +351,28 @@
if (setup_frontend (frontend_fd, &frontend_param) < 0)
return -1;
+ if (rec_psi) {
+ pmtpid = get_pmt_pid(DEMUX_DEV, pno);
+ if (pmtpid <= 0) {
+ fprintf(stderr,"couldn't find pmt-pid for program number %04x\n", pno);
+ 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;
@@ -363,6 +392,8 @@
check_frontend (frontend_fd);
+ close (pat_fd);
+ close (pmt_fd);
close (audio_fd);
close (video_fd);
close (frontend_fd);
^ permalink raw reply [flat|nested] 7+ messages in thread