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

Minor cosmetic changes.

This commit is contained in:
Rolf Ahrenberg 2007-09-24 17:20:58 +00:00
parent 10173c0eac
commit 49234919ea
4 changed files with 190 additions and 221 deletions

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.38 2007/09/24 16:10:19 ajhseppa Exp $
* $Id: device.c,v 1.39 2007/09/24 17:20:58 rahrenbe Exp $
*/
#include "common.h"
@ -34,7 +34,6 @@ cIptvDevice::cIptvDevice(unsigned int Index)
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
// Initialize filter pointers
memset(&secfilters, '\0', sizeof(secfilters));
StartSectionHandler();
}
@ -45,7 +44,7 @@ cIptvDevice::~cIptvDevice()
delete pUdpProtocol;
delete tsBuffer;
// Destroy all filters
for (int i = 0; i < eMaxFilterCount; ++i)
for (int i = 0; i < eMaxSecFilterCount; ++i)
DeleteFilter(i);
}
@ -155,7 +154,7 @@ bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
bool cIptvDevice::DeleteFilter(unsigned int Index)
{
if ((Index < eMaxFilterCount) && secfilters[Index]) {
if ((Index < eMaxSecFilterCount) && secfilters[Index]) {
debug("cIptvDevice::DeleteFilter(%d) Index=%d\n", deviceIndex, Index);
delete secfilters[Index];
secfilters[Index] = NULL;
@ -167,12 +166,10 @@ bool cIptvDevice::DeleteFilter(unsigned int Index)
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
{
// Search the next free filter slot
for (unsigned int i = 0; i < eMaxFilterCount; ++i) {
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!secfilters[i]) {
debug("cIptvDevice::OpenFilter(%d): Pid=%d Tid=%02X Mask=%02X Index=%d\n", deviceIndex, Pid, Tid, Mask, i);
secfilters[i] = new cIptvSectionFilter(i, deviceIndex, Pid, Tid,
Mask);
secfilters[i] = new cIptvSectionFilter(i, deviceIndex, Pid, Tid, Mask);
return secfilters[i]->GetReadDesc();
}
}
@ -183,7 +180,7 @@ int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
bool cIptvDevice::CloseFilter(int Handle)
{
debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
for (unsigned int i = 0; i < eMaxFilterCount; ++i) {
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i] && Handle == secfilters[i]->GetReadDesc())
return DeleteFilter(i);
}
@ -260,11 +257,10 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
isPacketDelivered = true;
Data = p;
// Run the data through all filters
for (unsigned int i = 0; i < eMaxFilterCount; ++i) {
if (secfilters[i]) {
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i])
secfilters[i]->ProcessData(p);
}
}
return true;
}
}

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.h,v 1.16 2007/09/24 13:03:38 ajhseppa Exp $
* $Id: device.h,v 1.17 2007/09/24 17:20:58 rahrenbe Exp $
*/
#ifndef __IPTV_DEVICE_H
@ -11,14 +11,11 @@
#include <vdr/device.h>
#include "protocoludp.h"
//#include "protocolrtsp.h"
#include "protocolhttp.h"
#include "protocolfile.h"
#include "streamer.h"
#include "sectionfilter.h"
class cIptvDevice : public cDevice {
// static ones
public:
@ -30,7 +27,7 @@ public:
// private parts
private:
enum {
eMaxFilterCount = 32,
eMaxSecFilterCount = 32
};
unsigned int deviceIndex;
bool isPacketDelivered;
@ -42,7 +39,7 @@ private:
cIptvProtocolFile *pFileProtocol;
cIptvStreamer *pIptvStreamer;
cMutex mutex;
cIptvSectionFilter* secfilters[eMaxFilterCount];
cIptvSectionFilter* secfilters[eMaxSecFilterCount];
// constructor & destructor
public:
@ -83,4 +80,3 @@ public:
};
#endif // __IPTV_DEVICE_H

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.c,v 1.2 2007/09/24 16:08:09 ajhseppa Exp $
* $Id: sectionfilter.c,v 1.3 2007/09/24 17:20:58 rahrenbe Exp $
*/
#include "sectionfilter.h"
@ -24,7 +24,6 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
id(Index)
{
debug("cIptvSectionFilter::cIptvSectionFilter(%d)\n", Index);
memset(secbuf_base, '\0', sizeof(secbuf_base));
memset(filter_value, '\0', sizeof(filter_value));
memset(filter_mask, '\0', sizeof(filter_mask));
@ -130,23 +129,19 @@ int cIptvSectionFilter::dvb_dmxdev_section_callback(const uint8_t *buffer1, size
else if (!retval) {
#ifdef DEBUG_PRINTF
printf("id = %d, pid %d would now write %d data to buffer\n", id, pid, buffer1_len);
for (unsigned int i = 0; i < buffer1_len; ++i) {
for (unsigned int i = 0; i < buffer1_len; ++i)
printf("0x%X ", buffer1[i]);
}
printf("\n");
#endif
retval = write(fifoDescriptor, buffer1, buffer1_len);
if (retval < 0) {
char tmp[64];
error("ERROR: write(): %s", strerror_r(errno, tmp, sizeof(tmp)));
}
}
#ifdef DEBUG_PRINTF
else if (retval) {
else if (retval)
printf("id %d pid %d data is already present\n", id, pid);
}
#endif
return 0;
}
@ -158,7 +153,6 @@ void cIptvSectionFilter::dvb_dmx_swfilter_section_new()
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
if (secbufp < tsfeedp) {
int i, n = tsfeedp - secbufp;
/*
* Section padding is done with 0xff bytes entirely.
* Due to speed reasons, we won't check all of them
@ -174,12 +168,10 @@ void cIptvSectionFilter::dvb_dmx_swfilter_section_new()
}
}
#endif
tsfeedp = secbufp = seclen = 0;
secbuf = secbuf_base;
}
int cIptvSectionFilter::dvb_dmx_swfilter_sectionfilter()
{
uint8_t neq = 0;
@ -187,14 +179,12 @@ int cIptvSectionFilter::dvb_dmx_swfilter_sectionfilter()
for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
uint8_t local_xor = filter_value[i] ^ secbuf[i];
if (maskandmode[i] & local_xor) {
#ifdef DEBUG_PRINTF
printf("maskandmode discard\n");
#endif
return 0;
}
neq |= maskandnotmode[i] & local_xor;
}
@ -204,7 +194,6 @@ int cIptvSectionFilter::dvb_dmx_swfilter_sectionfilter()
#endif
return 0;
}
return dvb_dmxdev_section_callback(secbuf, seclen, NULL, 0, DMX_OK);
}
@ -212,9 +201,7 @@ inline int cIptvSectionFilter::dvb_dmx_swfilter_section_feed()
{
if (dvb_dmx_swfilter_sectionfilter() < 0)
return -1;
seclen = 0;
return 0;
}
@ -222,9 +209,9 @@ int cIptvSectionFilter::dvb_dmx_swfilter_section_copy_dump(const uint8_t *buf, u
{
uint16_t limit, seclen_local, n;
if (tsfeedp >= DMX_MAX_SECFEED_SIZE) {
if (tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0;
}
if (tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
printf("dvb_demux.c section buffer full loss: %d/%d\n",
@ -244,28 +231,25 @@ int cIptvSectionFilter::dvb_dmx_swfilter_section_copy_dump(const uint8_t *buf, u
* Dump all the sections we can find in the data (Emard)
*/
limit = tsfeedp;
if (limit > DMX_MAX_SECFEED_SIZE) {
if (limit > DMX_MAX_SECFEED_SIZE)
return -1; /* internal error should never happen */
}
/* to be sure always set secbuf */
secbuf = secbuf_base + secbufp;
for (n = 0; secbufp + 2 < limit; n++) {
seclen_local = section_length(secbuf);
if (seclen_local <= 0 || seclen_local > DMX_MAX_SECTION_SIZE
|| seclen_local + secbufp > limit) {
if (seclen_local <= 0 || seclen_local > DMX_MAX_SECTION_SIZE ||
seclen_local + secbufp > limit)
return 0;
}
#ifdef DEBUG_PRINTF
printf("Non-mismatching seclen! %d, limit = %d\n", seclen_local, limit);
#endif
seclen = seclen_local;
crc_val = ~0;
/* dump [secbuf .. secbuf+seclen) */
if (pusi_seen) {
if (pusi_seen)
dvb_dmx_swfilter_section_feed();
}
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
else
printf("dvb_demux.c pusi not seen, discarding section data\n");
@ -273,11 +257,9 @@ int cIptvSectionFilter::dvb_dmx_swfilter_section_copy_dump(const uint8_t *buf, u
secbufp += seclen_local; /* secbufp and secbuf moving together is */
secbuf += seclen_local; /* redundant but saves pointer arithmetic */
}
return 0;
}
void cIptvSectionFilter::ProcessData(const uint8_t* buf)
{
if (buf[0] != 0x47) {
@ -307,7 +289,6 @@ void cIptvSectionFilter::ProcessData(const uint8_t* buf)
dc_i = 1;
}
if (!ccok || dc_i) {
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
printf("dvb_demux.c discontinuity detected %d bytes lost\n",
@ -346,9 +327,9 @@ void cIptvSectionFilter::ProcessData(const uint8_t* buf)
else if (count > 0)
printf("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
#endif
} else {
}
else {
/* PUSI=0 (is not set), no section boundary */
dvb_dmx_swfilter_section_copy_dump(&buf[p], count);
}
}

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.h,v 1.1 2007/09/24 13:03:39 ajhseppa Exp $
* $Id: sectionfilter.h,v 1.2 2007/09/24 17:20:58 rahrenbe Exp $
*/
#ifndef __IPTV_SECTIONFILTER_H
@ -20,7 +20,6 @@
#include <sys/ioctl.h>
#include <libgen.h>
#include <stdint.h>
#include <sys/param.h>
#include "common.h"
@ -39,7 +38,6 @@
#define DVB_DEMUX_MASK_MAX 18
class cIptvSectionFilter {
private:
enum dmx_success {
DMX_OK = 0, /* Received Ok */
@ -68,7 +66,6 @@ private:
uint16_t pid;
int id;
uint8_t filter_value[DMX_MAX_FILTER_SIZE];
uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
uint8_t filter_mode[DMX_MAX_FILTER_SIZE];
@ -114,4 +111,3 @@ public:
};
#endif // __IPTV_SECTIONFILTER_H