This plugin reads infosat EPG data from DVB-S.

WWW: http://projects.vdr-developer.org/projects/show/plg-infosatepg
This commit is contained in:
Juergen Lock 2011-03-26 19:18:18 +00:00
parent cebeac8771
commit 64f3861442
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=271801
13 changed files with 341 additions and 0 deletions

View file

@ -338,6 +338,7 @@
SUBDIR += vdr-plugin-control
SUBDIR += vdr-plugin-epgsearch
SUBDIR += vdr-plugin-femon
SUBDIR += vdr-plugin-infosatepg
SUBDIR += vic
SUBDIR += vlc
SUBDIR += vodcatcher

View file

@ -0,0 +1,36 @@
# New ports collection makefile for: vdr-plugin-infosatepg
# Date created: Wed Apr 14 18:11:42 CEST 2010
# Whom: Juergen Lock <nox@freebsd.org>
#
# $FreeBSD$
#
PORTNAME= vdr-plugin-infosatepg
PORTVERSION= 0.0.11
PORTREVISION= 6
CATEGORIES= multimedia
MASTER_SITES= http://projects.vdr-developer.org/attachments/download/342/
DISTNAME= ${PORTNAME:S/-plugin-/-/}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
EXTRACT_SUFX= .tgz
MAINTAINER= nox@FreeBSD.org
COMMENT= Video Disk Recorder - infosat EPG plugin
PATCH_STRIP= -p1
HAVE_CONFIGURE= yes
PORTDOCS= COPYING README
MAKE_JOBS_SAFE= yes
WRKSRC= ${WRKDIR}/${PLUGIN}-${DISTVERSION}
.include "${.CURDIR}/../vdr/Makefile.plugins"
post-patch: post-patch-plugin
post-install: post-install-pluginlocales
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
(cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR})
.endif
${INSTALL} -o ${VDR_USER} -g ${VDR_GROUP} -d /var/cache/vdr/${PLUGIN}
.include <bsd.port.mk>

View file

@ -0,0 +1,2 @@
SHA256 (vdr/vdr-infosatepg-0.0.11.tgz) = 14495b07f15f928b9ae66d6ec2f6e9639aa0cf86865900b7d6a9e212d7eb80ac
SIZE (vdr/vdr-infosatepg-0.0.11.tgz) = 35585

View file

@ -0,0 +1,21 @@
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,11 @@ i18n: $(I18Nmsgs) $(I18Npot)
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
+ifdef FREEBSD
+ @cp -f $@ $(LIBDIR)/$@.$(APIVERSION)
+else
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
+endif
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@@ -110,3 +114,6 @@ dist: clean
clean:
@-rm -f $(OBJS) $(DEPFILE) *.so* *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
+
+install:
+ ${INSTALL_PROGRAM} $(LIBDIR)/libvdr-$(PLUGIN).so.$(APIVERSION) $(PREFIX)/lib/vdr/libvdr-$(PLUGIN).so.$(APIVERSION)

View file

@ -0,0 +1,110 @@
--- a/filter.cpp
+++ b/filter.cpp
@@ -6,6 +6,9 @@
* $Id$
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <unistd.h>
@@ -47,24 +50,32 @@ u_short cFilterInfosatepg::foldsum(u_lon
return ((u_short) ~sum);
}
-u_short cFilterInfosatepg::IPChecksum(iphdr *ipHeader)
+u_short cFilterInfosatepg::IPChecksum(ip *ipHeader)
{
- return foldsum(do_sum(0, (u_char*) ipHeader, sizeof(iphdr)));
+ return foldsum(do_sum(0, (u_char*) ipHeader, sizeof(ip)));
} /* IpChecksum() */
-u_short cFilterInfosatepg::UDPChecksum(iphdr *ipHeader, udphdr *udpHeader)
+u_short cFilterInfosatepg::UDPChecksum(ip *ipHeader, udphdr *udpHeader)
{
u_long sum = 0;
// Ip-Pseudo-Header
- sum = do_sum(sum, (u_char*)(&ipHeader->saddr), sizeof(ipHeader->saddr));
- sum = do_sum(sum, (u_char*)(&ipHeader->daddr), sizeof(ipHeader->daddr));
+ sum = do_sum(sum, (u_char*)(&ipHeader->ip_src), sizeof(ipHeader->ip_src));
+ sum = do_sum(sum, (u_char*)(&ipHeader->ip_dst), sizeof(ipHeader->ip_dst));
+#ifdef __linux__
sum += udpHeader->len;
- sum += ipHeader->protocol<<8;
+#else
+ sum += udpHeader->uh_ulen;
+#endif
+ sum += ipHeader->ip_p<<8;
+#ifdef __linux__
sum = do_sum(sum, (u_char*)udpHeader, ntohs(udpHeader->len));
+#else
+ sum = do_sum(sum, (u_char*)udpHeader, ntohs(udpHeader->uh_ulen));
+#endif
return foldsum(sum);
}
@@ -78,27 +89,27 @@ void cFilterInfosatepg::Process(u_short
if (Data[0]!=0x3E) return;
- struct ethhdr eth_hdr;
- memset(&eth_hdr,0,sizeof(struct ethhdr));
+ struct ether_header eth_hdr;
+ memset(&eth_hdr,0,sizeof(struct ether_header));
- eth_hdr.h_dest[0]=Data[11];
- eth_hdr.h_dest[1]=Data[10];
- eth_hdr.h_dest[2]=Data[9];
- eth_hdr.h_dest[3]=Data[8];
- eth_hdr.h_dest[4]=Data[4];
- eth_hdr.h_dest[5]=Data[3];
+ eth_hdr.ether_dhost[0]=Data[11];
+ eth_hdr.ether_dhost[1]=Data[10];
+ eth_hdr.ether_dhost[2]=Data[9];
+ eth_hdr.ether_dhost[3]=Data[8];
+ eth_hdr.ether_dhost[4]=Data[4];
+ eth_hdr.ether_dhost[5]=Data[3];
// check mac and range
if (!global->CheckMAC(&eth_hdr)) return;
- int mac = eth_hdr.h_dest[5];
+ int mac = eth_hdr.ether_dhost[5];
global->ActualMac=mac;
- struct iphdr *ip_hdr = (iphdr *) &Data[SECT_IP_HDR_START];
+ struct ip *ip_hdr = (ip *) &Data[SECT_IP_HDR_START];
struct udphdr *udp_hdr = (udphdr *) &Data[SECT_UDP_HDR_START];
// Only IPv4
- if (ip_hdr->version!=4) return;
+ if (ip_hdr->ip_v!=4) return;
// Check IP checksum
if (IPChecksum(ip_hdr)!=0)
@@ -108,7 +119,7 @@ void cFilterInfosatepg::Process(u_short
}
// Only UDP
- if (ip_hdr->protocol!=17) return;
+ if (ip_hdr->ip_p!=17) return;
// Check UDP checksum
if (UDPChecksum(ip_hdr,udp_hdr)!=0)
@@ -149,8 +160,8 @@ void cFilterInfosatepg::Process(u_short
#ifdef VDRDEBUG
- dsyslog("infosatepg: mac=%02x-%02x-%02x-%02x-%02x-%02x",eth_hdr.h_dest[0],eth_hdr.h_dest[1],
- eth_hdr.h_dest[2],eth_hdr.h_dest[3],eth_hdr.h_dest[4],eth_hdr.h_dest[5] );
+ dsyslog("infosatepg: mac=%02x-%02x-%02x-%02x-%02x-%02x",eth_hdr.ether_dhost[0],eth_hdr.ether_dhost[1],
+ eth_hdr.ether_dhost[2],eth_hdr.ether_dhost[3],eth_hdr.ether_dhost[4],eth_hdr.ether_dhost[5] );
dsyslog("infosatepg: tid=%04i tbl=%04i stbl=%04i day=%02i month=%02i pktnr=%03i pktcnt=%03i len=%i",
ntohs(ishdr->technisatId),ishdr->tableId,ishdr->tablesubId,ishdr->day,

View file

@ -0,0 +1,13 @@
--- a/filter.h
+++ b/filter.h
@@ -33,8 +33,8 @@ private:
cGlobalInfosatepg *global;
u_long do_sum(u_long sum, u_char *buf, int nBytes);
u_short foldsum(u_long sum);
- u_short IPChecksum(iphdr *ipHeader);
- u_short UDPChecksum(iphdr *ipHeader, udphdr *udpHeader);
+ u_short IPChecksum(ip *ipHeader);
+ u_short UDPChecksum(ip *ipHeader, udphdr *udpHeader);
protected:
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
public:

View file

@ -0,0 +1,40 @@
--- a/global.cpp
+++ b/global.cpp
@@ -164,7 +164,11 @@ cGlobalInfosatepg::cGlobalInfosatepg()
MAC[3]=0x02;
MAC[4]=0x02;
WaitTime=10; // default 10 seconds
+#ifdef __FreeBSD__
+ SetDirectory ("/var/cache/vdr/infosatepg");
+#else
SetDirectory ("/tmp");
+#endif
NoWakeup=false;
NoDeferredShutdown=false;
ActualMac=0;
@@ -194,17 +198,17 @@ bool cGlobalInfosatepg::SetDirectory(con
return true;
}
-bool cGlobalInfosatepg::CheckMAC(struct ethhdr *eth_hdr)
+bool cGlobalInfosatepg::CheckMAC(ether_header *eth_hdr)
{
if (!eth_hdr) return false;
- if (eth_hdr->h_dest[0]!=MAC[0]) return false;
- if (eth_hdr->h_dest[1]!=MAC[1]) return false;
- if (eth_hdr->h_dest[2]!=MAC[2]) return false;
- if (eth_hdr->h_dest[3]!=MAC[3]) return false;
- if (eth_hdr->h_dest[4]!=MAC[4]) return false;
+ if (eth_hdr->ether_dhost[0]!=MAC[0]) return false;
+ if (eth_hdr->ether_dhost[1]!=MAC[1]) return false;
+ if (eth_hdr->ether_dhost[2]!=MAC[2]) return false;
+ if (eth_hdr->ether_dhost[3]!=MAC[3]) return false;
+ if (eth_hdr->ether_dhost[4]!=MAC[4]) return false;
- if (eth_hdr->h_dest[5]<EPG_FIRST_DAY_MAC) return false;
- if (eth_hdr->h_dest[5]>EPG_LAST_DAY_MAC) return false;
+ if (eth_hdr->ether_dhost[5]<EPG_FIRST_DAY_MAC) return false;
+ if (eth_hdr->ether_dhost[5]>EPG_LAST_DAY_MAC) return false;
return true;
}

View file

@ -0,0 +1,22 @@
--- a/global.h
+++ b/global.h
@@ -9,8 +9,10 @@
#ifndef __global_h_
#define __global_h_
+#include <sys/socket.h>
#include <netinet/if_ether.h>
#include <sys/types.h>
+#include <ctype.h>
#include <vdr/channels.h>
#include <vdr/timers.h>
@@ -162,7 +164,7 @@ public:
return directory;
}
bool SetDirectory (const char *Directory);
- bool CheckMAC (struct ethhdr *eth_hdr);
+ bool CheckMAC (ether_header *eth_hdr);
void SetWaitTimer()
{
timer=time (NULL);

View file

@ -0,0 +1,11 @@
--- a/infosatepg.cpp
+++ b/infosatepg.cpp
@@ -403,7 +403,7 @@ cString cPluginInfosatepg::SVDRPCommand(
cString head2;
head2="\n" \
" | | missed | | | unlocated\n" \
- " Day | Date | Packets | Received %% | Processed | Events\n" \
+ " Day | Date | Packets | Received % | Processed | Events\n" \
"------+--------+---------+------------+------------+----------\n";
cString mstr;

View file

@ -0,0 +1,26 @@
--- a/process.cpp
+++ b/process.cpp
@@ -1047,7 +1047,9 @@ bool cProcessInfosatepg::ParseInfosatepg
int ieventnr=1;
cChannel *chan=NULL;
cInfosatevent *ievent=NULL;
-#if VDRVERSNUM < 10701
+// XXX don't default to assuming UTF-8 on FreeBSD (that's what the NULL does),
+// its still often used without.
+#if VDRVERSNUM < 10701 || defined(__FreeBSD__)
cCharSetConv *conv = new cCharSetConv("ISO-8859-1",cCharSetConv::SystemCharacterTable() ?
cCharSetConv::SystemCharacterTable() : "UTF-8");
#else
@@ -1139,7 +1141,12 @@ bool cProcessInfosatepg::ParseInfosatepg
}
int shour,sminute;
char *title;
+#ifdef __FreeBSD__
+ title = (char *)malloc(strlen(s));
+ fields=sscanf(s,"%d:%d %[^^]",&shour,&sminute,title);
+#else
fields=sscanf(s,"%d:%d %a[^^]",&shour,&sminute,&title);
+#endif
if (fields==3)
{
if (!ievent) ievent = new cInfosatevent;

View file

@ -0,0 +1,50 @@
--- a/readline.cpp
+++ b/readline.cpp
@@ -10,6 +10,15 @@
#include <stdio.h>
#include "readline.h"
+#ifdef __FreeBSD__
+#include <string.h>
+#if __FreeBSD_version > 800000
+#define HAVE_GETLINE
+#endif
+#else
+#define HAVE_GETLINE
+#endif
+
extern char *strcatrealloc(char *dest, const char *src);
// --- cReadLineInfosatepg ---------------------------------------------------
@@ -36,7 +45,31 @@ char *cReadLineInfosatepg::Read(FILE *f,
do
{
ext=false;
+#ifndef HAVE_GETLINE
+ size_t n;
+
+ if (!tempbuffer)
+ {
+ if (!(tempbuffer = (char *)malloc(tempsize = 4096)))
+ return NULL;
+ }
+ if (!fgets(tempbuffer, tempsize, f))
+ {
+ if (tempbuffer) free(tempbuffer);
+ return buffer;
+ }
+ while ((n = strlen(tempbuffer)) >= tempsize - 1 &&
+ tempbuffer[n - 1] != '\n')
+ {
+ if (!(tempbuffer = (char *)realloc(tempbuffer, tempsize * 2)))
+ return NULL;
+ tempsize *= 2;
+ if (!fgets(tempbuffer + n, tempsize - n, f))
+ break;
+ }
+#else
int n = getline(&tempbuffer, &tempsize, f);
+#endif
if (n > 0)
{
if (tempbuffer[n-1] == '\n')

View file

@ -0,0 +1,5 @@
http://vdr-wiki.de/wiki/index.php/Infosatepg-plugin
This plugin reads infosat EPG data from DVB-S.
WWW: http://projects.vdr-developer.org/projects/show/plg-infosatepg

View file

@ -0,0 +1,4 @@
lib/vdr/libvdr-infosatepg.so.1.7.17
@exec /usr/bin/install -o %%VDR_USER%% -g %%VDR_GROUP%% -d /var/cache/vdr/infosatepg
%%NLS%%share/locale/de_DE/LC_MESSAGES/vdr-infosatepg.mo
%%NLS%%share/locale/it_IT/LC_MESSAGES/vdr-infosatepg.mo