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:
parent
0ae7eb654e
commit
0b6d4c820a
33
device.c
33
device.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.25 2007/09/19 18:02:38 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.26 2007/09/19 18:17:30 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -38,12 +38,11 @@ cIptvDevice::cIptvDevice(unsigned int Index)
|
||||
pFileProtocol = new cIptvProtocolFile();
|
||||
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
|
||||
StartSectionHandler();
|
||||
|
||||
for(int i = 0; i < 32; ++i) {
|
||||
// Initialize filters
|
||||
for (int i = 0; i < eMaxFilterCount; ++i) {
|
||||
filters[i].active = false;
|
||||
filters[i].fifoDesc = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cIptvDevice::~cIptvDevice()
|
||||
@ -52,9 +51,8 @@ cIptvDevice::~cIptvDevice()
|
||||
delete pIptvStreamer;
|
||||
delete pUdpProtocol;
|
||||
delete tsBuffer;
|
||||
|
||||
// Iterate over all filters and clear their settings
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
for (int i = 0; i < eMaxFilterCount; ++i) {
|
||||
if (filters[i].active) {
|
||||
close(filters[i].fifoDesc);
|
||||
unlink(filters[i].pipeName);
|
||||
@ -177,17 +175,16 @@ bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
|
||||
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
|
||||
{
|
||||
// Search the next free filter slot
|
||||
for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
|
||||
for (unsigned int i = 0; i < eMaxFilterCount; ++i) {
|
||||
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;
|
||||
int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0);
|
||||
if (err < 0)
|
||||
error("Cannot set filter %d\n", i);
|
||||
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
|
||||
snprintf(filters[i].pipeName, sizeof(filters[i].pipeName),
|
||||
"/tmp/iptvPipe.%d", i);
|
||||
snprintf(filters[i].pipeName, sizeof(filters[i].pipeName), "/tmp/iptvPipe.%d", i);
|
||||
err = mknod(filters[i].pipeName, 0644 | S_IFIFO, 0);
|
||||
if (err < 0) {
|
||||
char tmp[64];
|
||||
@ -255,7 +252,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
Data = p;
|
||||
memcpy(filter.packet, p, sizeof(filter.packet));
|
||||
trans_filt(p, TS_SIZE, &filter);
|
||||
for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
|
||||
for (unsigned int i = 0; i < eMaxFilterCount; ++i) {
|
||||
if (filters[i].active) {
|
||||
section *filtered = get_filt_sec(&filter, i);
|
||||
if (filtered->found) {
|
||||
@ -267,14 +264,13 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
fd_set rfds;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(filters[i].fifoDesc, &rfds);
|
||||
int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL,
|
||||
&tv);
|
||||
int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL, &tv);
|
||||
// Check if error
|
||||
if (retval < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
// VDR has probably closed the filter file descriptor, so
|
||||
// clear the filter
|
||||
// VDR has probably closed the filter file descriptor, so clear
|
||||
// the filter
|
||||
close(filters[i].fifoDesc);
|
||||
unlink(filters[i].pipeName);
|
||||
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
|
||||
@ -283,13 +279,12 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
clear_trans_filt(&filter, i);
|
||||
}
|
||||
// There is no data in the fifo, more can be written
|
||||
if (!retval) {
|
||||
else if (!retval) {
|
||||
int err = write(filters[i].fifoDesc, filtered->payload,
|
||||
filtered->length+3);
|
||||
filtered->length + 3);
|
||||
if (err < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: write(): %s", strerror_r(errno, tmp,
|
||||
sizeof(tmp)));
|
||||
error("ERROR: write(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
device.h
9
device.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.h,v 1.10 2007/09/19 15:14:32 ajhseppa Exp $
|
||||
* $Id: device.h,v 1.11 2007/09/19 18:17:30 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_DEVICE_H
|
||||
@ -25,7 +25,6 @@ struct filterInfo {
|
||||
int lastProvided;
|
||||
};
|
||||
|
||||
|
||||
class cIptvDevice : public cDevice {
|
||||
// static ones
|
||||
public:
|
||||
@ -36,6 +35,9 @@ public:
|
||||
|
||||
// private parts
|
||||
private:
|
||||
enum {
|
||||
eMaxFilterCount = 32
|
||||
};
|
||||
unsigned int deviceIndex;
|
||||
bool isPacketDelivered;
|
||||
bool isOpenDvr;
|
||||
@ -44,11 +46,10 @@ private:
|
||||
cIptvProtocolUdp *pUdpProtocol;
|
||||
cIptvProtocolHttp *pHttpProtocol;
|
||||
cIptvProtocolFile *pFileProtocol;
|
||||
//cIptvProtocolRtsp *pRtspProtocol;
|
||||
cIptvStreamer *pIptvStreamer;
|
||||
cMutex mutex;
|
||||
trans filter;
|
||||
filterInfo filters[32];
|
||||
filterInfo filters[eMaxFilterCount];
|
||||
|
||||
// constructor & destructor
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user