mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libtriple: remember the filedescriptor belonging to each pid in cDemux()
This commit is contained in:
@@ -102,12 +102,12 @@ void cDemux::Close(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||||
{
|
{
|
||||||
lt_debug("cDemux::Close: stopping and closing demux fd %d\n", *i);
|
lt_debug("cDemux::Close: stopping and closing demux fd %d pid 0x%04x\n", (*i).fd, (*i).pid);
|
||||||
if (ioctl(*i, DEMUX_STOP) < 0)
|
if (ioctl((*i).fd, DEMUX_STOP) < 0)
|
||||||
perror("DEMUX_STOP");
|
perror("DEMUX_STOP");
|
||||||
if (close(*i) < 0)
|
if (close((*i).fd) < 0)
|
||||||
perror("close");
|
perror("close");
|
||||||
}
|
}
|
||||||
pesfds.clear();
|
pesfds.clear();
|
||||||
@@ -124,10 +124,10 @@ bool cDemux::Start(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||||
{
|
{
|
||||||
lt_debug("cDemux::Start: starting demux fd %d\n", *i);
|
lt_debug("cDemux::Start: starting demux fd %d pid 0x%04x\n", (*i).fd, (*i).pid);
|
||||||
if (ioctl(*i, DEMUX_START) < 0)
|
if (ioctl((*i).fd, DEMUX_START) < 0)
|
||||||
perror("DEMUX_START");
|
perror("DEMUX_START");
|
||||||
}
|
}
|
||||||
ioctl(fd, DEMUX_START);
|
ioctl(fd, DEMUX_START);
|
||||||
@@ -141,10 +141,10 @@ bool cDemux::Stop(void)
|
|||||||
fprintf(stderr, "cDemux::%s #%d: not open!\n", __FUNCTION__, num);
|
fprintf(stderr, "cDemux::%s #%d: not open!\n", __FUNCTION__, num);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (std::vector<int>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||||
{
|
{
|
||||||
lt_debug("cDemux::Stop: stopping demux fd %d\n", *i);
|
lt_debug("cDemux::Stop: stopping demux fd %d pid 0x%04x\n", (*i).fd, (*i).pid);
|
||||||
if (ioctl(*i, DEMUX_STOP) < 0)
|
if (ioctl((*i).fd, DEMUX_STOP) < 0)
|
||||||
perror("DEMUX_STOP");
|
perror("DEMUX_STOP");
|
||||||
}
|
}
|
||||||
ioctl(fd, DEMUX_STOP);
|
ioctl(fd, DEMUX_STOP);
|
||||||
@@ -381,7 +381,7 @@ void *cDemux::getChannel()
|
|||||||
|
|
||||||
void cDemux::addPid(unsigned short Pid)
|
void cDemux::addPid(unsigned short Pid)
|
||||||
{
|
{
|
||||||
int pfd;
|
pes_pids pfd;
|
||||||
int ret;
|
int ret;
|
||||||
struct demux_pes_para p;
|
struct demux_pes_para p;
|
||||||
if (dmx_type != DMX_TP_CHANNEL)
|
if (dmx_type != DMX_TP_CHANNEL)
|
||||||
@@ -391,8 +391,8 @@ void cDemux::addPid(unsigned short Pid)
|
|||||||
}
|
}
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
fprintf(stderr, "cDemux::%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid);
|
fprintf(stderr, "cDemux::%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid);
|
||||||
pfd = open(devname[num], O_RDWR);
|
pfd.fd = open(devname[num], O_RDWR);
|
||||||
if (pfd < 0)
|
if (pfd.fd < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "cDemux::%s #%d Pid = %hx open failed (%m)\n", __FUNCTION__, num, Pid);
|
fprintf(stderr, "cDemux::%s #%d Pid = %hx open failed (%m)\n", __FUNCTION__, num, Pid);
|
||||||
return;
|
return;
|
||||||
@@ -406,22 +406,23 @@ void cDemux::addPid(unsigned short Pid)
|
|||||||
p.unloader.unloader_type = UNLOADER_TYPE_BUCKET;
|
p.unloader.unloader_type = UNLOADER_TYPE_BUCKET;
|
||||||
p.unloader.threshold = 128;
|
p.unloader.threshold = 128;
|
||||||
|
|
||||||
ioctl(pfd, DEMUX_SELECT_SOURCE, INPUT_FROM_CHANNEL0);
|
ioctl(pfd.fd, DEMUX_SELECT_SOURCE, INPUT_FROM_CHANNEL0);
|
||||||
ret = ioctl(pfd, DEMUX_SET_BUFFER_SIZE, 0x10000); // 64k
|
ret = ioctl(pfd.fd, DEMUX_SET_BUFFER_SIZE, 0x10000); // 64k
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
perror("DEMUX_SET_BUFFER_SIZE");
|
perror("DEMUX_SET_BUFFER_SIZE");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = ioctl(pfd, DEMUX_FILTER_PES_SET, &p);
|
ret = ioctl(pfd.fd, DEMUX_FILTER_PES_SET, &p);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
perror("DEMUX_FILTER_PES_SET");
|
perror("DEMUX_FILTER_PES_SET");
|
||||||
}
|
}
|
||||||
|
pfd.pid = Pid;
|
||||||
if (ret != -1)
|
if (ret != -1)
|
||||||
/* success! */
|
/* success! */
|
||||||
pesfds.push_back(pfd);
|
pesfds.push_back(pfd);
|
||||||
else
|
else
|
||||||
/* error! */
|
/* error! */
|
||||||
close(pfd);
|
close(pfd.fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,6 +23,12 @@ typedef enum
|
|||||||
DMX_PCR_ONLY_CHANNEL
|
DMX_PCR_ONLY_CHANNEL
|
||||||
} DMX_CHANNEL_TYPE;
|
} DMX_CHANNEL_TYPE;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
unsigned short pid;
|
||||||
|
} pes_pids;
|
||||||
|
|
||||||
class cDemux
|
class cDemux
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -30,7 +36,7 @@ class cDemux
|
|||||||
int fd;
|
int fd;
|
||||||
int buffersize;
|
int buffersize;
|
||||||
DMX_CHANNEL_TYPE dmx_type;
|
DMX_CHANNEL_TYPE dmx_type;
|
||||||
std::vector<int> pesfds;
|
std::vector<pes_pids> pesfds;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool Open(DMX_CHANNEL_TYPE pes_type, void * x = NULL, int y = 0);
|
bool Open(DMX_CHANNEL_TYPE pes_type, void * x = NULL, int y = 0);
|
||||||
|
Reference in New Issue
Block a user