1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Some cosmetic changes.

This commit is contained in:
Rolf Ahrenberg 2007-09-19 18:02:38 +00:00
parent 30ced52a0c
commit 0ae7eb654e

156
device.c
View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: device.c,v 1.24 2007/09/19 15:14:32 ajhseppa Exp $ * $Id: device.c,v 1.25 2007/09/19 18:02:38 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -170,50 +170,39 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On) bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
{ {
debug("cIptvDevice::SetPid(%d) Type=%d On=%d\n", deviceIndex, Type, On); debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndex, Handle->pid, Type, On);
return true; return true;
} }
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask) int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
{ {
// Search the next free filter slot // Search the next free filter slot
for (int i = 0; i < 32; ++i) { for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
if(!filters[i].active) { if (!filters[i].active) {
debug("cIptvDevice::OpenFilter(): Pid=0x%X Tid=%02X Mask=%02X, filterCount = %d\n", Pid, Tid, Mask, i);
debug("cIptvDevice::OpenFilter(): Pid=0x%X Tid=%02X Mask=%02X, filterCount = %d\n", Pid, Tid, Mask, i); uint8_t mask = Mask;
uint8_t filt = Tid;
uint8_t mask = Mask; int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0);
uint8_t filt = Tid; if (err < 0)
error("Cannot set filter %d\n", i);
int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0); memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
if (err < 0) snprintf(filters[i].pipeName, sizeof(filters[i].pipeName),
error("Cannot set filter %d\n", i); "/tmp/iptvPipe.%d", i);
err = mknod(filters[i].pipeName, 0644 | S_IFIFO, 0);
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName)); if (err < 0) {
snprintf(filters[i].pipeName, sizeof(filters[i].pipeName), char tmp[64];
"/tmp/iptvPipe.%d", i); error("ERROR: mknod(): %s", strerror_r(errno, tmp, sizeof(tmp)));
err = mknod(filters[i].pipeName, 0644 | S_IFIFO, 0); unlink(filters[i].pipeName);
if (err < 0) { }
char tmp[64]; // Create descriptors
error("ERROR: mknod(): %s", strerror_r(errno, tmp, sizeof(tmp))); int fifoDescriptor = open(filters[i].pipeName, O_RDWR | O_NONBLOCK);
unlink(filters[i].pipeName); int returnDescriptor = open(filters[i].pipeName, O_RDONLY | O_NONBLOCK);
} // Store the write pipe and set active flag
filters[i].active = true;
// Create descriptors filters[i].fifoDesc = fifoDescriptor;
int fifoDescriptor = open(filters[i].pipeName, O_RDWR | O_NONBLOCK); return returnDescriptor;
int returnDescriptor = open(filters[i].pipeName, O_RDONLY | O_NONBLOCK); }
}
// Store the write pipe and set active flag
filters[i].active = true;
filters[i].fifoDesc = fifoDescriptor;
//++filterCount;
return returnDescriptor;
}
}
// No free filter slot found // No free filter slot found
return -1; return -1;
} }
@ -265,54 +254,47 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
isPacketDelivered = true; isPacketDelivered = true;
Data = p; Data = p;
memcpy(filter.packet, p, sizeof(filter.packet)); memcpy(filter.packet, p, sizeof(filter.packet));
trans_filt(p, 188, &filter); trans_filt(p, TS_SIZE, &filter);
for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
if (filters[i].active) {
for(int i = 0; i < 32; ++i) { section *filtered = get_filt_sec(&filter, i);
if (filtered->found) {
if(filters[i].active) { // Select on the fifo emptyness. Using null timeout to return
// immediately
section *filtered = get_filt_sec(&filter, i); struct timeval tv;
tv.tv_sec = 0;
if (filtered->found) { tv.tv_usec = 0;
fd_set rfds;
// Select on the fifo emptyness. Using null timeout to return FD_ZERO(&rfds);
// immediately FD_SET(filters[i].fifoDesc, &rfds);
struct timeval tv; int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL,
tv.tv_sec = 0; &tv);
tv.tv_usec = 0; // Check if error
fd_set rfds; if (retval < 0) {
FD_ZERO(&rfds); char tmp[64];
FD_SET(filters[i].fifoDesc, &rfds); error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL, // VDR has probably closed the filter file descriptor, so
&tv); // clear the filter
// Check if error close(filters[i].fifoDesc);
if (retval < 0) { unlink(filters[i].pipeName);
char tmp[64]; memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp))); filters[i].fifoDesc = -1;
filters[i].active = false;
// VDR has probably closed the filter file descriptor. clear_trans_filt(&filter, i);
// Clear the filter }
close(filters[i].fifoDesc); // There is no data in the fifo, more can be written
unlink(filters[i].pipeName); if (!retval) {
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName)); int err = write(filters[i].fifoDesc, filtered->payload,
filters[i].fifoDesc = -1; filtered->length+3);
filters[i].active = false; if (err < 0) {
clear_trans_filt(&filter, i); char tmp[64];
} error("ERROR: write(): %s", strerror_r(errno, tmp,
// There is no data in the fifo, more can be written sizeof(tmp)));
if (!retval) { }
int err = write(filters[i].fifoDesc, filtered->payload, }
filtered->length+3); }
if (err < 0) { }
char tmp[64]; }
error("ERROR: write(): %s", strerror_r(errno, tmp,
sizeof(tmp)));
}
}
}
}
}
return true; return true;
} }
Data = NULL; Data = NULL;