From fc9dc727694fc549ae363735856078b5e7352f91 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Mon, 12 Jul 2004 20:52:02 +0000 Subject: added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12804 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/dvb_tune.c | 64 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) (limited to 'libmpdemux/dvb_tune.c') diff --git a/libmpdemux/dvb_tune.c b/libmpdemux/dvb_tune.c index cf6e6af219..046105ffe1 100644 --- a/libmpdemux/dvb_tune.c +++ b/libmpdemux/dvb_tune.c @@ -90,8 +90,12 @@ int dvb_get_tuner_type(int fe_fd) } -int dvb_open_devices(dvb_priv_t *priv, int n) +int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype); + +int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt, int *pids) { + int i; + priv->fe_fd = open(dvb_frontenddev[n], O_RDWR | O_NONBLOCK); if(priv->fe_fd < 0) { @@ -109,18 +113,21 @@ int dvb_open_devices(dvb_priv_t *priv, int n) return 0; } #endif - priv->demux_fd[0] = open(dvb_demuxdev[n], O_RDWR); - if(priv->demux_fd[0] < 0) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno); - return 0; - } - - priv->demux_fd[1] = open(dvb_demuxdev[n], O_RDWR); - if(priv->demux_fd[1] < 0) + priv->demux_fds_cnt = 0; + mp_msg(MSGT_DEMUX, MSGL_V, "DVB_OPEN_DEVICES(%d)\n", demux_cnt); + for(i = 0; i < demux_cnt; i++) { - mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 1: %d\n", errno); - return 0; + priv->demux_fds[i] = open(dvb_demuxdev[n], O_RDWR | O_NONBLOCK); + if(priv->demux_fds[i] < 0) + { + mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno); + return 0; + } + else + { + mp_msg(MSGT_DEMUX, MSGL_V, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, dvb_demuxdev[n], priv->demux_fds[i], priv->demux_fds_cnt); + priv->demux_fds_cnt++; + } } @@ -135,6 +142,38 @@ int dvb_open_devices(dvb_priv_t *priv, int n) } +int dvb_fix_demuxes(dvb_priv_t *priv, int cnt, int *pids) +{ + int i; + + mp_msg(MSGT_DEMUX, MSGL_V, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt); + if(priv->demux_fds_cnt >= cnt) + { + for(i = priv->demux_fds_cnt-1; i >= cnt; i--) + { + mp_msg(MSGT_DEMUX, MSGL_V, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]); + close(priv->demux_fds[i]); + } + priv->demux_fds_cnt = cnt; + } + else if(priv->demux_fds_cnt < cnt) + { + for(i = priv->demux_fds_cnt; i < cnt; i++) + { + priv->demux_fds[i] = open(dvb_demuxdev[priv->card], O_RDWR | O_NONBLOCK); + mp_msg(MSGT_DEMUX, MSGL_V, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]); + if(priv->demux_fds[i] < 0) + { + mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno); + return 0; + } + else + priv->demux_fds_cnt++; + } + } + + return 1; +} int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype) { @@ -152,6 +191,7 @@ int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype) pesFilterParams.flags = DMX_IMMEDIATE_START; + errno = 0; if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno); -- cgit v1.2.3