From: Janne Grunau <j@jannau.net>
To: linux-media@vger.kernel.org
Subject: [PATCH 2 of 7] szap: move get_pmt_pid() to utils.c
Date: Wed, 10 Feb 2010 19:36:35 +0100 [thread overview]
Message-ID: <20100210183635.GM8026@aniel.lan> (raw)
In-Reply-To: <patchbomb.1265826616@aniel.lan>
[-- 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
next prev parent reply other threads:[~2010-02-10 18:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
2010-02-10 18:36 ` [PATCH 3 of 7] czap: reformat and extend usage string Janne Grunau
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 ` [PATCH 5 of 7] czap: implement -p option to record PAT & PMT (PSI) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100210183635.GM8026@aniel.lan \
--to=j@jannau.net \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox