unsigned int flags);
/**
- * @fn dvb_get_pmt_pid(const char *dmxdev, int sid)
+ * @fn int dvb_get_pmt_pid(int dmxfd, int sid)
* @brief read the contents of the MPEG-TS PAT table, seeking for
* an specific service ID
*
- * @param dmxdev File name of the demux to be opened
+ * @param dmxfd File descriptor for the demux device
* @param sid Session ID to seeking
*
* This function currently assumes that the hope PAT fits into one session.
- * At return, it returns a negative value if error or the PID associated with
+ *
+ * @return At return, it returns a negative value if error or the PID associated with
* the desired Session ID.
*/
-int dvb_get_pmt_pid(const char *dmxdev, int sid);
+int dvb_get_pmt_pid(int dmxfd, int sid);
#ifdef __cplusplus
}
return 0;
}
-int dvb_get_pmt_pid(const char *dmxdev, int sid)
+int dvb_get_pmt_pid(int dmxfd, int sid)
{
int patfd, count;
int pmt_pid = 0;
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);
}
}
- close(patfd);
return pmt_pid;
}
int lnb = -1, idx = -1;
int vpid = -1, apid = -1, sid = -1;
int pmtpid = 0;
- int pat_fd = -1, pmt_fd = -1;
+ int pat_fd = -1, pmt_fd = -1, sid_fd = -1;
int audio_fd = -1, video_fd = -1;
int dvr_fd = -1, file_fd = -1;
int err = -1;
sid);
goto err;
}
- pmtpid = dvb_get_pmt_pid(args.demux_dev, sid);
+
+ sid_fd = dvb_dmx_open(args.adapter, args.demux);
+ if (sid_fd < 0) {
+ perror("opening pat demux failed");
+ return -1;
+ }
+ pmtpid = dvb_get_pmt_pid(sid_fd, sid);
+ dvb_dmx_close(sid_fd);
if (pmtpid <= 0) {
fprintf(stderr, "couldn't find pmt-pid for sid %04x\n",
sid);
+
goto err;
}