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:17:30 +00:00
parent 0ae7eb654e
commit 0b6d4c820a
2 changed files with 31 additions and 35 deletions

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.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" #include "common.h"
@ -38,12 +38,11 @@ cIptvDevice::cIptvDevice(unsigned int Index)
pFileProtocol = new cIptvProtocolFile(); pFileProtocol = new cIptvProtocolFile();
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex); pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
StartSectionHandler(); StartSectionHandler();
// Initialize filters
for(int i = 0; i < 32; ++i) { for (int i = 0; i < eMaxFilterCount; ++i) {
filters[i].active = false; filters[i].active = false;
filters[i].fifoDesc = -1; filters[i].fifoDesc = -1;
} }
} }
cIptvDevice::~cIptvDevice() cIptvDevice::~cIptvDevice()
@ -52,18 +51,17 @@ cIptvDevice::~cIptvDevice()
delete pIptvStreamer; delete pIptvStreamer;
delete pUdpProtocol; delete pUdpProtocol;
delete tsBuffer; delete tsBuffer;
// Iterate over all filters and clear their settings // 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) { if (filters[i].active) {
close(filters[i].fifoDesc); close(filters[i].fifoDesc);
unlink(filters[i].pipeName); unlink(filters[i].pipeName);
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName)); memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
filters[i].fifoDesc = -1; filters[i].fifoDesc = -1;
filters[i].active = false; filters[i].active = false;
clear_trans_filt(&filter, i); clear_trans_filt(&filter, i);
} }
} }
} }
bool cIptvDevice::Initialize(unsigned int DeviceCount) bool cIptvDevice::Initialize(unsigned int DeviceCount)
@ -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) 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 (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) { for (unsigned int i = 0; i < eMaxFilterCount; ++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 mask = Mask;
uint8_t filt = Tid; uint8_t filt = Tid;
int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0); int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0);
if (err < 0) if (err < 0)
error("Cannot set filter %d\n", i); error("Cannot set filter %d\n", i);
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName)); memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
snprintf(filters[i].pipeName, sizeof(filters[i].pipeName), snprintf(filters[i].pipeName, sizeof(filters[i].pipeName), "/tmp/iptvPipe.%d", i);
"/tmp/iptvPipe.%d", i);
err = mknod(filters[i].pipeName, 0644 | S_IFIFO, 0); err = mknod(filters[i].pipeName, 0644 | S_IFIFO, 0);
if (err < 0) { if (err < 0) {
char tmp[64]; char tmp[64];
@ -255,7 +252,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
Data = p; Data = p;
memcpy(filter.packet, p, sizeof(filter.packet)); memcpy(filter.packet, p, sizeof(filter.packet));
trans_filt(p, TS_SIZE, &filter); 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) { if (filters[i].active) {
section *filtered = get_filt_sec(&filter, i); section *filtered = get_filt_sec(&filter, i);
if (filtered->found) { if (filtered->found) {
@ -267,14 +264,13 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
fd_set rfds; fd_set rfds;
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(filters[i].fifoDesc, &rfds); FD_SET(filters[i].fifoDesc, &rfds);
int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL, int retval = select(filters[i].fifoDesc + 1, &rfds, NULL, NULL, &tv);
&tv);
// Check if error // Check if error
if (retval < 0) { if (retval < 0) {
char tmp[64]; char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp))); error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
// VDR has probably closed the filter file descriptor, so // VDR has probably closed the filter file descriptor, so clear
// clear the filter // the filter
close(filters[i].fifoDesc); close(filters[i].fifoDesc);
unlink(filters[i].pipeName); unlink(filters[i].pipeName);
memset(filters[i].pipeName, '\0', sizeof(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); clear_trans_filt(&filter, i);
} }
// There is no data in the fifo, more can be written // There is no data in the fifo, more can be written
if (!retval) { else if (!retval) {
int err = write(filters[i].fifoDesc, filtered->payload, int err = write(filters[i].fifoDesc, filtered->payload,
filtered->length+3); filtered->length + 3);
if (err < 0) { if (err < 0) {
char tmp[64]; char tmp[64];
error("ERROR: write(): %s", strerror_r(errno, tmp, error("ERROR: write(): %s", strerror_r(errno, tmp, sizeof(tmp)));
sizeof(tmp)));
} }
} }
} }

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.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 #ifndef __IPTV_DEVICE_H
@ -24,7 +24,6 @@ struct filterInfo {
char pipeName[128]; char pipeName[128];
int lastProvided; int lastProvided;
}; };
class cIptvDevice : public cDevice { class cIptvDevice : public cDevice {
// static ones // static ones
@ -36,6 +35,9 @@ public:
// private parts // private parts
private: private:
enum {
eMaxFilterCount = 32
};
unsigned int deviceIndex; unsigned int deviceIndex;
bool isPacketDelivered; bool isPacketDelivered;
bool isOpenDvr; bool isOpenDvr;
@ -44,11 +46,10 @@ private:
cIptvProtocolUdp *pUdpProtocol; cIptvProtocolUdp *pUdpProtocol;
cIptvProtocolHttp *pHttpProtocol; cIptvProtocolHttp *pHttpProtocol;
cIptvProtocolFile *pFileProtocol; cIptvProtocolFile *pFileProtocol;
//cIptvProtocolRtsp *pRtspProtocol;
cIptvStreamer *pIptvStreamer; cIptvStreamer *pIptvStreamer;
cMutex mutex; cMutex mutex;
trans filter; trans filter;
filterInfo filters[32]; filterInfo filters[eMaxFilterCount];
// constructor & destructor // constructor & destructor
public: public: