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

Compare commits

..

1 Commits

Author SHA1 Message Date
Rolf Ahrenberg
cbd734fc0d Updated HISTORY. 2010-03-04 17:50:34 +02:00
48 changed files with 1914 additions and 1556 deletions

69
HISTORY
View File

@@ -1,6 +1,5 @@
==================================
VDR Plugin 'iptv' Revision History
==================================
----------------------------------
2007-10-14: Version 0.0.1
@@ -122,69 +121,3 @@ VDR Plugin 'iptv' Revision History
- Updated patches.
- Fixed argument corruption.
==================================
VDR Plugin 'iptv' Revision History
==================================
2010-03-05: Version 0.4.0
- Updated for vdr-1.7.13.
- Fixed argument corruption.
2010-03-09: Version 0.4.1
- Fixed channel parameter corruption.
- Added Dutch translation (Thanks to Carel).
2010-06-06: Version 0.4.2
- Updated for vdr-1.7.15.
2012-02-02: Version 0.5.0
- Updated for vdr-1.7.23.
- Renamed Sid scanner to section id scanner and added
experimental Tid/Nid support into it.
- Added optional source address validation for UDP protocol.
- Fixed audio pid detection in pid scanner.
- Changed ProvidesChannel() to set the need of detaching
receivers due to VDR's channel selection mechanism.
- Enabled partial content responses for HTTP protocol.
- Fixed EXT protocol execution (Thanks to Peter Holik).
- Disable detaching of receivers if retuned to an existing
channel (Thanks to Zdeněk Kopřivík).
- Canonicalized the configuration directory.
- Added support for LDFLAGS.
- Added cppcheck target into Makefile.
2012-04-02: Version 0.5.1
- Updated for vdr-1.7.27.
- Updated Makefile.
- Silenced compilation warnings.
- Fixed channel switching bugs.
- Added support for a service interface.
- Changed UDP protocol to always utilize the source address
validation.
2012-04-26: Version 0.5.2
- Fixed connection problems in HTTP protocol.
2012-06-03: Version 1.0.0
- Optimized reading from UDP sockets.
- Fixed ProvidesChannel method.
2012-07-10: Version 1.0.1
- Added FreeBSD support (Thanks to Jürgen Lock).
2012-09-30: Version 1.1.0
- Updated for vdr-1.7.30.
- Added support for source-specific multicasts (SSM).
- Changed default external script directory from the
configuration to the resource.

View File

@@ -5,15 +5,9 @@
# Debugging on/off
#IPTV_DEBUG = 1
# Default shell for EXT protocol
#IPTV_EXTSHELL = /bin/bash
# Strip debug symbols? Set eg. to /bin/true if not
STRIP = strip
# Install command
INSTALL = cp --remove-destination
# The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the plugin.
# By default the main source file also carries this name.
@@ -24,24 +18,18 @@ PLUGIN = iptv
### The version number of this plugin (taken from the main source file):
VERSION = $(shell grep 'const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g')
GITTAG = $(shell git describe --always 2>/dev/null)
VERSION = $(shell grep 'static const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -fPIC -g -O3 -Wall -Wextra -Wswitch-default -Wfloat-equal -Wundef -Wpointer-arith -Wconversion -Wcast-align -Wredundant-decls -Wno-unused-parameter -Werror=overloaded-virtual -Wno-parentheses
LDFLAGS ?= -Wl,--as-needed
CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -Wswitch-default -Wfloat-equal -Wundef -Wpointer-arith -Wconversion -Wcast-align -Wredundant-decls -Wno-unused-parameter -Woverloaded-virtual -Wno-parentheses
### The directory environment:
VDRDIR ?= ../../..
LIBDIR ?= ../../lib
TMPDIR ?= /tmp
### Make sure that necessary options are included:
-include $(VDRDIR)/Make.global
VDRDIR = ../../..
LIBDIR = ../../lib
TMPDIR = /tmp
### Allow user defined options to overwrite defaults:
@@ -66,14 +54,6 @@ ifdef IPTV_DEBUG
DEFINES += -DDEBUG
endif
ifdef IPTV_EXTSHELL
DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"'
endif
ifneq ($(strip $(GITTAG)),)
DEFINES += -DGITVERSION='"-GIT-$(GITTAG)"'
endif
.PHONY: all all-redirect
all-redirect: all
@@ -81,7 +61,7 @@ all-redirect: all
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \
protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \
sidscanner.o pidscanner.o statistics.o common.o socket.o source.o
sidscanner.o pidscanner.o statistics.o common.o socket.o
### The main target:
@@ -89,7 +69,7 @@ all: libvdr-$(PLUGIN).so i18n
### Implicit rules:
%.o: %.c Makefile
%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
### Dependencies:
@@ -113,7 +93,7 @@ I18Npot = $(PODIR)/$(PLUGIN).pot
msgfmt -c -o $@ $<
$(I18Npot): $(wildcard *.c)
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name='vdr-$(PLUGIN)' --package-version='$(VERSION)' --msgid-bugs-address='<see README>' -o $@ `ls $^`
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $^
%.po: $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
@@ -129,13 +109,13 @@ i18n: $(I18Nmsgs) $(I18Npot)
### Targets:
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
ifndef IPTV_DEBUG
@$(STRIP) $@
endif
@$(INSTALL) $@ $(LIBDIR)/$@.$(APIVERSION)
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
dist: $(I18Npo) clean
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@@ -145,6 +125,3 @@ dist: $(I18Npo) clean
clean:
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
cppcheck: $(OBJS)
@cppcheck --enable=information,style,unusedFunction -v -f $(OBJS:%.o=%.c)

82
README
View File

@@ -17,7 +17,7 @@ See the file COPYING for more information.
Requirements:
DVB compatible MPEG1/2 or H.264 network video streams.
An IPTV patched VDR setup and DVB compatible MPEG1/2 network video streams.
Description:
@@ -44,7 +44,9 @@ cd /put/your/path/here/VDR/PLUGINS/src
tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz
ln -s iptv-X.Y.Z iptv
cd /put/your/path/here/VDR
cp -R PLUGINS/src/iptv/iptv /path/to/vdrresource/plugins/
patch -p1 < PLUGINS/src/iptv/patches/vdr-X.Y.Z-pluginparam.patch
cp sources.conf /path/to/vdrconf/
cp -R PLUGINS/src/iptv/iptv /path/to/vdrconf/plugins/
make
make plugins
./vdr -P iptv
@@ -75,8 +77,29 @@ Setup menu:
options which allow you to disable the
individual section filters.
Valid range: 0...7
- [Red:Channels] Opens IPTV channel editor.
- [Blue:Info] Opens IPTV information/statistics menu.
Channel editor menu:
- Because of the different nature and content the VDR channel editor is not
best suited for editing of IPTV channels. Therefore an alternative editor
is provided which allows more IPTV centric editing of channel information.
An IPTV channel editor is accessible via "Setup -> Plugins -> IPTV" and
pressing the Red button. The channel editor is functionally similar to
VDR's built-in channel editor.
- Scan Sid: [yes|no] Defines whether service id shall be
scanned automatically. Service id is
used in channel identification and
EPG information is set according to it.
This option requires section filtering.
- Scan pids: [yes|no] Defines whether video and audio pids
shall be scanned automatically. This
option is useful with streams missing
correct PAT/PMT information.
Information menu:
- [Red:General] Opens the general information page.
@@ -88,41 +111,34 @@ Configuration:
- channels.conf
TV4;IPTV:40:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:4:0:0:0
TV3;IPTV:30:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:3:0:0:0
TV2;IPTV:20:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:2:0:0:0
TV1;IPTV:10:S=1|P=0|F=UDP|U=127.0.0.1@127.0.0.1|A=1234:I:0:512:650:2321:0:1:0:0:0
TV1;IPTV:10:S=1|P=0|F=UDP|U=127.0.0.1|A=1234:I:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^ ^
| | | | | | Source type ("I")
| | | | | Stream parameter (multicast port
| | | | | number, HTTP port number, file delay
| | | | | (ms), script parameter)
| | | | Stream address (multicast source@group address,
| | | | URL, file location, script location)
| | | Stream protocol ("UDP", "HTTP", "FILE", "EXT")
| | Pid scanner ("0" disable, "1" enable)
| Section id (Sid/Nid/Tid) scanner ("0" disable, "1" enable)
TV4;IPTV:40:IPTV|S1P0|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0
TV3;IPTV:30:IPTV|S0P1|FILE|/video/stream.ts|5:P:0:514:670:2321:0:3:0:0:0
TV2;IPTV:20:IPTV|S0P1|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0
TV1;IPTV:10:IPTV|S1P0|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^ ^
| | | | | | Source type ("P")
| | | | | IP Port Number, File delay (ms), Script parameter
| | | | IP Address, File location, Script location
| | | Protocol ("UDP", "HTTP", "FILE", "EXT")
| | Parameters ("S" Sid scan, "P" Pid scan, "0" disable, "1" enable)
| Plugin ID ("IPTV")
Unique enumeration
- UDP multicast rules for iptables firewall
# Multicast UDP packets
# Multicast UDP -packets
iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT
# IGMP required by multicasts
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
# Default routing for multicast
route add -net 224.0.0.0 netmask 224.0.0.0 eth0
External streaming:
- To watch an externally received channel add an EXT entry to channels.conf
and specify a script name and parameter. The specified script is executed
from plugin resource directory when VDR tunes to the channel. The specified
script parameter is passed to the script and it can be used to select for
example between different URLs.
from plugin configuration directory when VDR tunes to the channel. The
specified script parameter is passed to the script and it can be used to
select for example between different URLs.
- When an EXT channel is opened the IPTV plugin opens an UDP listening port
on the localhost. The external script is responsible for supplying IPTV
@@ -135,7 +151,8 @@ External streaming:
devices can be used simultaneously.
- IPTV plugin includes an example script which uses VLC media player for
receiving streams, transcoding and handing the result to IPTV plugin.
receiving streams, transcoding and handing the result to IPTV plugin. The
plugin was tested with VLC version 0.8.6c.
Notes:
@@ -158,21 +175,6 @@ Notes:
script and the iptvstream-notrap.sh script should be used instead in these
cases.
- If received MPEG-2 TS streams carry CA descriptors, you'll have to apply
"disable_ca_updates" patch to the VDR in order to get rid of "Channel not
available" messages.
- EIT scanning functionality can be disabled for all IPTV channels by applying
the "disable_eitscan" patch to the VDR.
- Section id and pid scanners should be disabled after the correct data is
found. This can be made via VDR's channel editor.
- Source-specific multicast (SSM) can be enabled by defining both the source
address and the group address separated by a '@' character. This will use
IGMP v3 protocol:
"U=<source address>@<group address>"
Acknowledgements:
- The IPTV section filtering code is derived from Linux kernel.

View File

@@ -20,18 +20,20 @@
#define error(x...) esyslog("ERROR: " x);
#endif
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#ifndef trNOOP
#define trNOOP(s) (s)
#endif
#ifndef trVDR
#define trVDR(s) tr(s)
#endif
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
#define IPTV_SOURCE_CHARACTER 'I'
#define IPTV_DEVICE_INFO_ALL 0
#define IPTV_DEVICE_INFO_GENERAL 1
#define IPTV_DEVICE_INFO_PIDS 2
#define IPTV_DEVICE_INFO_FILTERS 3
#define IPTV_DEVICE_INFO_PROTOCOL 4
#define IPTV_DEVICE_INFO_BITRATE 5
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
@@ -39,14 +41,13 @@
#define SECTION_FILTER_TABLE_SIZE 7
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
strerror_r(errno, tmp, sizeof(tmp)); \
error(errstr": %s", tmp); \
func; \
ret; \
} \
do { \
if (exp) { \
char tmp[64]; \
error(errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
} while (0)
@@ -80,7 +81,5 @@ struct section_filter_table_type {
extern const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE];
extern const char VERSION[];
#endif // __IPTV_COMMON_H

View File

@@ -42,6 +42,6 @@ void cIptvConfig::SetDisabledFilters(unsigned int Index, int Number)
void cIptvConfig::SetConfigDirectory(const char *directoryP)
{
debug("cIptvConfig::SetConfigDirectory(%s)\n", directoryP);
ERROR_IF(!realpath(directoryP, configDirectory), "Cannot canonicalize configuration directory");
debug("cIptvConfig::SetConfigDirectory(%s)", directoryP);
strn0cpy(configDirectory, directoryP, sizeof(configDirectory));
}

View File

@@ -20,7 +20,7 @@ private:
unsigned int useBytes;
unsigned int sectionFiltering;
int disabledFilters[SECTION_FILTER_TABLE_SIZE];
char configDirectory[PATH_MAX];
char configDirectory[255];
public:
cIptvConfig();

189
device.c
View File

@@ -6,7 +6,6 @@
*/
#include "config.h"
#include "source.h"
#include "device.h"
#define IPTV_MAX_DEVICES MAXDEVICES
@@ -21,10 +20,9 @@ cIptvDevice::cIptvDevice(unsigned int Index)
isPacketDelivered(false),
isOpenDvr(false),
sidScanEnabled(false),
pidScanEnabled(false),
channelId(tChannelID::InvalidID)
pidScanEnabled(false)
{
unsigned int bufsize = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize());
unsigned int bufsize = MEGABYTE(IptvConfig.GetTsBufferSize());
bufsize -= (bufsize % TS_SIZE);
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndex, CardIndex());
tsBuffer = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
@@ -36,13 +34,13 @@ cIptvDevice::cIptvDevice(unsigned int Index)
pFileProtocol = new cIptvProtocolFile();
pExtProtocol = new cIptvProtocolExt();
pIptvStreamer = new cIptvStreamer(tsBuffer, (100 * TS_SIZE));
pPidScanner = new cPidScanner();
pPidScanner = new cPidScanner;
// Initialize filter pointers
memset(secfilters, '\0', sizeof(secfilters));
// Start section handler for iptv device
StartSectionHandler();
// Sid scanner must be created after the section handler
pSidScanner = new cSidScanner();
pSidScanner = new cSidScanner;
if (pSidScanner)
AttachFilter(pSidScanner);
// Check if dvr fifo exists
@@ -87,7 +85,6 @@ cIptvDevice::~cIptvDevice()
bool cIptvDevice::Initialize(unsigned int DeviceCount)
{
debug("cIptvDevice::Initialize(): DeviceCount=%d\n", DeviceCount);
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
if (DeviceCount > IPTV_MAX_DEVICES)
DeviceCount = IPTV_MAX_DEVICES;
for (unsigned int i = 0; i < DeviceCount; ++i)
@@ -123,7 +120,7 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
cString cIptvDevice::GetGeneralInformation(void)
{
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
deviceIndex, CardIndex(),
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
@@ -169,12 +166,6 @@ cString cIptvDevice::GetInformation(unsigned int Page)
case IPTV_DEVICE_INFO_FILTERS:
info = GetFiltersInformation();
break;
case IPTV_DEVICE_INFO_PROTOCOL:
info = pIptvStreamer ? *pIptvStreamer->GetInformation() : "";
break;
case IPTV_DEVICE_INFO_BITRATE:
info = pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "";
break;
default:
info = cString::sprintf("%s%s%s",
*GetGeneralInformation(),
@@ -185,69 +176,88 @@ cString cIptvDevice::GetInformation(unsigned int Page)
return info;
}
cString cIptvDevice::DeviceType(void) const
cString cIptvDevice::GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol)
{
debug("cIptvDevice::DeviceType(%d)\n", deviceIndex);
return "IPTV";
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
char *tag = NULL;
char *proto = NULL;
char *loc = NULL;
if (sscanf(IptvParam, "%a[^|]|S%dP%d|%a[^|]|%a[^|]|%u", &tag, SidScan, PidScan, &proto, &loc, Parameter) == 6) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = pUdpProtocol;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = pHttpProtocol;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = pFileProtocol;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = pExtProtocol;
else
return NULL;
// return location
return locstr;
}
}
else if (sscanf(IptvParam, "%a[^|]|P%dS%d|%a[^|]|%a[^|]|%u", &tag, PidScan, SidScan, &proto, &loc, Parameter) == 6) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = pUdpProtocol;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = pHttpProtocol;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = pFileProtocol;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = pExtProtocol;
else
return NULL;
// return location
return locstr;
}
}
return NULL;
}
cString cIptvDevice::DeviceName(void) const
bool cIptvDevice::ProvidesIptv(const char *Param) const
{
debug("cIptvDevice::DeviceName(%d)\n", deviceIndex);
return cString::sprintf("IPTV %d", deviceIndex);
}
int cIptvDevice::SignalStrength(void) const
{
debug("cIptvDevice::SignalStrength(%d)\n", deviceIndex);
return (100);
}
int cIptvDevice::SignalQuality(void) const
{
debug("cIptvDevice::SignalQuality(%d)\n", deviceIndex);
return (100);
debug("cIptvDevice::ProvidesIptv(%d)\n", deviceIndex);
return (strncasecmp(Param, "IPTV", 4) == 0);
}
bool cIptvDevice::ProvidesSource(int Source) const
{
debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex);
return (cSource::IsType(Source, IPTV_SOURCE_CHARACTER));
return (cSource::IsPlug(Source));
}
bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const
{
debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex);
return (ProvidesSource(Channel->Source()));
return (ProvidesSource(Channel->Source()) && ProvidesIptv(Channel->PluginParam()));
}
bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
{
bool result = false;
bool hasPriority = Priority == IDLEPRIORITY || Priority > this->Priority();
bool needsDetachReceivers = false;
debug("cIptvDevice::ProvidesChannel(%d)\n", deviceIndex);
if (Channel && ProvidesTransponder(Channel)) {
result = hasPriority;
if (Receiving()) {
if (Channel->GetChannelID() == channelId)
result = true;
else
needsDetachReceivers = Receiving();
}
}
if (ProvidesTransponder(Channel))
result = true;
if (NeedsDetachReceivers)
*NeedsDetachReceivers = needsDetachReceivers;
return result;
}
bool cIptvDevice::ProvidesEIT(void) const
{
return false;
}
int cIptvDevice::NumProvidedSystems(void) const
{
return 1;
@@ -255,41 +265,23 @@ int cIptvDevice::NumProvidedSystems(void) const
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
int parameter, sidscan, pidscan;
cString location;
cIptvProtocolIf *protocol;
cIptvTransponderParameters itp(Channel->Parameters());
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
if (isempty(itp.Address())) {
error("Unrecognized IPTV address: %s", Channel->Parameters());
location = GetChannelSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol);
if (isempty(location)) {
error("Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false;
}
switch (itp.Protocol()) {
case cIptvTransponderParameters::eProtocolUDP:
protocol = pUdpProtocol;
break;
case cIptvTransponderParameters::eProtocolHTTP:
protocol = pHttpProtocol;
break;
case cIptvTransponderParameters::eProtocolFILE:
protocol = pFileProtocol;
break;
case cIptvTransponderParameters::eProtocolEXT:
protocol = pExtProtocol;
break;
default:
error("Unrecognized IPTV protocol: %s", Channel->Parameters());
return false;
break;
}
sidScanEnabled = itp.SidScan() ? true : false;
pidScanEnabled = itp.PidScan() ? true : false;
if (pIptvStreamer->Set(itp.Address(), itp.Parameter(), deviceIndex, protocol)) {
channelId = Channel->GetChannelID();
sidScanEnabled = sidscan ? true : false;
pidScanEnabled = pidscan ? true : false;
if (pIptvStreamer->Set(location, parameter, deviceIndex, protocol)) {
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetChannel(channelId);
pSidScanner->SetChannel(Channel);
if (pidScanEnabled && pPidScanner)
pPidScanner->SetChannel(channelId);
pPidScanner->SetChannel(Channel);
}
return true;
}
@@ -343,37 +335,26 @@ int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
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(deviceIndex, Pid, Tid, Mask);
if (secfilters[i])
return i;
break;
secfilters[i] = new cIptvSectionFilter(deviceIndex, i, Pid, Tid, Mask);
return secfilters[i]->GetReadDesc();
}
}
// No free filter slot found
return -1;
}
int cIptvDevice::ReadFilter(int Handle, void *Buffer, size_t Length)
{
// Lock
cMutexLock MutexLock(&mutex);
// ... and load
if (secfilters[Handle]) {
return secfilters[Handle]->Read(Buffer, Length);
//debug("cIptvDevice::ReadFilter(%d): %d %d\n", deviceIndex, Handle, Length);
}
return 0;
}
void cIptvDevice::CloseFilter(int Handle)
{
// Lock
cMutexLock MutexLock(&mutex);
// ... and load
if (secfilters[Handle]) {
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
DeleteFilter(Handle);
}
// Search the filter for deletion
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) {
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
DeleteFilter(i);
break;
}
}
}
bool cIptvDevice::OpenDvr(void)
@@ -406,17 +387,11 @@ bool cIptvDevice::HasLock(int TimeoutMs)
return (!IsBuffering());
}
bool cIptvDevice::HasInternalCam(void)
{
//debug("cIptvDevice::HasInternalCam(%d)\n", deviceIndex);
return true;
}
void cIptvDevice::ResetBuffering(void)
{
debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndex);
// pad prefill to multiple of TS_SIZE
tsBufferPrefill = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
IptvConfig.GetTsBufferPrefillRatio() / 100;
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
}
@@ -433,6 +408,7 @@ bool cIptvDevice::IsBuffering(void)
bool cIptvDevice::GetTSPacket(uchar *&Data)
{
int Count = 0;
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
if (tsBuffer && !IsBuffering()) {
if (isPacketDelivered) {
@@ -441,7 +417,6 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
// Update buffer statistics
AddBufferStatistic(TS_SIZE, tsBuffer->Available());
}
int Count = 0;
uchar *p = tsBuffer->Get(Count);
if (p && Count >= TS_SIZE) {
if (*p != TS_SYNC_BYTE) {

View File

@@ -41,7 +41,6 @@ private:
bool pidScanEnabled;
cRingBufferLinear *tsBuffer;
int tsBufferPrefill;
tChannelID channelId;
cIptvProtocolUdp *pUdpProtocol;
cIptvProtocolHttp *pHttpProtocol;
cIptvProtocolFile *pFileProtocol;
@@ -50,7 +49,7 @@ private:
cPidScanner *pPidScanner;
cSidScanner *pSidScanner;
cMutex mutex;
cIptvSectionFilter *secfilters[eMaxSecFilterCount];
cIptvSectionFilter* secfilters[eMaxSecFilterCount];
// constructor & destructor
public:
@@ -70,24 +69,18 @@ private:
// for channel parsing & buffering
private:
cString GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol);
bool ProvidesIptv(const char *Param) const;
void ResetBuffering(void);
bool IsBuffering(void);
bool DeleteFilter(unsigned int Index);
bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const;
// for channel info
public:
virtual cString DeviceType(void) const;
virtual cString DeviceName(void) const;
virtual int SignalStrength(void) const;
virtual int SignalQuality(void) const;
// for channel selection
public:
virtual bool ProvidesSource(int Source) const;
virtual bool ProvidesTransponder(const cChannel *Channel) const;
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
virtual bool ProvidesEIT(void) const;
virtual int NumProvidedSystems(void) const;
protected:
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
@@ -102,16 +95,11 @@ protected:
// for section filtering
public:
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
virtual int ReadFilter(int Handle, void *Buffer, size_t Length);
virtual void CloseFilter(int Handle);
// for transponder lock
public:
virtual bool HasLock(int);
// for common interface
public:
virtual bool HasInternalCam(void);
};
#endif // __IPTV_DEVICE_H

27
iptv.c
View File

@@ -11,17 +11,16 @@
#include "config.h"
#include "setup.h"
#include "device.h"
#include "iptvservice.h"
#if defined(APIVERSNUM) && APIVERSNUM < 10730
#error "VDR-1.7.30 API version or greater is required!"
#ifndef PLUGINPARAMPATCHVERSNUM
#error "You must apply the pluginparam patch for VDR!"
#endif
#ifndef GITVERSION
#define GITVERSION ""
#if defined(APIVERSNUM) && APIVERSNUM < 10600
#error "VDR-1.6.0 API version or greater is required!"
#endif
const char VERSION[] = "1.1.0" GITVERSION;
static const char VERSION[] = "0.3.2";
static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin {
@@ -99,7 +98,7 @@ bool cPluginIptv::Initialize(void)
{
debug("cPluginIptv::Initialize()\n");
// Initialize any background activities the plugin shall perform.
IptvConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
return cIptvDevice::Initialize(deviceCount);
}
@@ -201,18 +200,8 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value)
bool cPluginIptv::Service(const char *Id, void *Data)
{
debug("cPluginIptv::Service()\n");
if (strcmp(Id,"IptvService-v1.0") == 0) {
if (Data) {
IptvService_v1_0 *data = (IptvService_v1_0*)Data;
cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex);
if (!dev)
return false;
data->protocol = dev->GetInformation(IPTV_DEVICE_INFO_PROTOCOL);
data->bitrate = dev->GetInformation(IPTV_DEVICE_INFO_BITRATE);
}
return true;
}
//debug("cPluginIptv::Service()\n");
// Handle custom service requests from other plugins
return false;
}

View File

@@ -8,12 +8,12 @@ set -e
# The script originates from Peter Holik
#
# Example channels.conf entries:
# Energy;IPTV:50:S=0|P=0|F=EXT|U=png.sh|A=1:I:0:256:257:0:0:3:0:0:0
# Temperature;IPTV:60:S=0|P=0|EXT|U=png.sh|A=2:I:0:256:257:0:0:3:0:0:0
# Temperature Week;IPTV:70:S=0|P=0|EXT|U=png.sh|A=3:I:0:256:257:0:0:3:0:0:0
# Server Temperature;IPTV:80:S=0|P=0|EXT|U=png.sh|A=4:I:0:256:257:0:0:3:0:0:0
# Server Temperature Week;IPTV:90:S=0|P=0|EXT|U=png.sh|A=5:I:0:256:257:0:0:3:0:0:0
# Traffic;IPTV:100:S=0|P=0|EXT|U=png.sh|A=6:I:0:256:257:0:0:3:0:0:0
# Energy;IPTV:50:IPTV|S0P0|EXT|png.sh|1:P:0:256:257:0:0:3:0:0:0
# Temperature;IPTV:60:IPTV|S0P0|EXT|png.sh|2:P:0:256:257:0:0:3:0:0:0
# Temperature Week;IPTV:70:IPTV|S0P0|EXT|png.sh|3:P:0:256:257:0:0:3:0:0:0
# Server Temperature;IPTV:80:IPTV|S0P0|EXT|png.sh|4:P:0:256:257:0:0:3:0:0:0
# Server Temperature Week;IPTV:90:IPTV|S0P0|EXT|png.sh|5:P:0:256:257:0:0:3:0:0:0
# Traffic;IPTV:100:IPTV|S0P0|EXT|png.sh|6:P:0:256:257:0:0:3:0:0:0
#
# webcam.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -7,7 +7,7 @@
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# internetradio;IPTV:2:S=0|P=0|F=EXT|U=internetradio.sh|A=0:P:0:0:256:0:0:2:0:0:0
# internetradio;IPTV:2:IPTV|S0P0|EXT|internetradio.sh|0:P:0:0:256:0:0:2:0:0:0
#
# internetradio.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -44,7 +44,6 @@ case ${PARAMETER} in
URL=""
WIDTH=720
HEIGHT=576
FPS=25
;;
2)
URL=""
@@ -67,9 +66,6 @@ TRANSCODE_OPTS="vcodec=${VCODEC},acodec=${ACODEC},vb=${VBITRATE},ab=${ABITRATE}"
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
fi
if [ -n "${FPS}" ] ; then
TRANSCODE_OPTS="${TRANSCODE_OPTS},fps=${FPS}"
fi
# Create unique pids for the stream
let VPID=${PARAMETER}+1

View File

@@ -7,7 +7,7 @@
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# linein;IPTV:5:S=0|P=0|F=EXT|U=linein.sh|A=0:I:27500:0:256:0:0:5:5:5:0
# linein;IPTV:5:IPTV|S0P0|EXT|linein.sh|0:P:27500:0:256:0:0:5:5:5:0
#
# linein.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -52,7 +52,7 @@ lookup_channel_and_pids()
[ ! -e "$CHANNELS_CONF" ] && \
exit_with_error "channels.conf not found ($CHANNELS_CONF)"
local CHANNEL_RECORD=`grep "[:]S=[10][|]P=[10][|]F=EXT[|]U=vlc2iptv[|]A=$PARAMETER[:]I" $CHANNELS_CONF`
local CHANNEL_RECORD=`grep "[:]IPTV[|][SP][10][SP][10][|]EXT[|]vlc2iptv[|]$PARAMETER[:]" $CHANNELS_CONF`
[ -z "$CHANNEL_RECORD" ] && \
exit_with_error "no iptv channel with parameter $PARAMETER found"

View File

@@ -7,7 +7,7 @@
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# webcam;IPTV:3:S=0|P=0|F=EXT|U=webcam.sh|A=0:I:0:256:257:0:0:3:0:0:0
# webcam;IPTV:3:IPTV|S0P0|EXT|webcam.sh|0:P:0:256:257:0:0:3:0:0:0
#
# webcam.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,22 +0,0 @@
/*
* iptvservice.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTVSERVICE_H
#define __IPTVSERVICE_H
#include <vdr/tools.h>
#define stIptv ('I' << 24)
struct IptvService_v1_0 {
unsigned int cardIndex;
cString protocol;
cString bitrate;
};
#endif //__IPTVSERVICE_H

View File

@@ -0,0 +1,11 @@
diff -Nru vdr-1.6.0-vanilla/pat.c vdr-1.6.0-disable-ca-updates/pat.c
--- vdr-1.6.0-vanilla/pat.c 2008-02-08 15:48:31.000000000 +0200
+++ vdr-1.6.0-disable-ca-updates/pat.c 2009-03-07 14:56:42.000000000 +0200
@@ -440,6 +440,7 @@
}
if (Setup.UpdateChannels >= 2) {
Channel->SetPids(Vpid, Vpid ? Ppid : 0, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
+ if (!Channel->IsPlug())
Channel->SetCaIds(CaDescriptors->CaIds());
}
Channel->SetCaDescriptors(CaDescriptorHandler.AddCaDescriptors(CaDescriptors));

View File

@@ -0,0 +1,12 @@
diff -Nru vdr-1.6.0-vanilla/eitscan.c vdr-1.6.0-disable_eitscan/eitscan.c
--- vdr-1.6.0-vanilla/eitscan.c 2006-01-07 16:10:17.000000000 +0200
+++ vdr-1.6.0-disable_eitscan/eitscan.c 2009-06-17 16:04:23.000000000 +0300
@@ -146,7 +146,7 @@
if (Device) {
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
const cChannel *Channel = ScanData->GetChannel();
- if (Channel) {
+ if (Channel && !Channel->IsPlug()) {
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
if (Device->ProvidesTransponder(Channel)) {
if (!Device->Receiving()) {

View File

@@ -0,0 +1,287 @@
diff -Nru vdr-1.6.0-vanilla/channels.c vdr-1.6.0-pluginparam/channels.c
--- vdr-1.6.0-vanilla/channels.c 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/channels.c 2008-03-27 22:06:47.000000000 +0200
@@ -166,6 +166,7 @@
shortName = strdup("");
provider = strdup("");
portalName = strdup("");
+ pluginParam = strdup("");
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
inversion = INVERSION_AUTO;
bandwidth = BANDWIDTH_AUTO;
@@ -187,6 +188,7 @@
shortName = NULL;
provider = NULL;
portalName = NULL;
+ pluginParam = NULL;
schedule = NULL;
linkChannels = NULL;
refChannel = NULL;
@@ -215,6 +217,7 @@
free(shortName);
free(provider);
free(portalName);
+ free(pluginParam);
}
cChannel& cChannel::operator= (const cChannel &Channel)
@@ -223,6 +226,7 @@
shortName = strcpyrealloc(shortName, Channel.shortName);
provider = strcpyrealloc(provider, Channel.provider);
portalName = strcpyrealloc(portalName, Channel.portalName);
+ pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
return *this;
}
@@ -280,9 +284,26 @@
transmission = Channel->transmission;
guard = Channel->guard;
hierarchy = Channel->hierarchy;
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
}
}
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
+{
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
+ if (Number()) {
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ source = Source;
+ frequency = Frequency;
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ schedule = NULL;
+ }
+ return true;
+}
+
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH)
{
// Workarounds for broadcaster stupidity:
@@ -407,6 +428,18 @@
}
}
+void cChannel::SetPluginParam(const char *PluginParam)
+{
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
+ if (Number()) {
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ }
+}
+
#define STRDIFF 0x01
#define VALDIFF 0x02
@@ -593,7 +626,7 @@
if (isdigit(type))
type = 'S';
#define ST(s) if (strchr(s, type))
- char buffer[64];
+ char buffer[256];
char *q = buffer;
*q = 0;
ST(" S ") q += sprintf(q, "%c", polarization);
@@ -605,6 +638,7 @@
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
+ ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
return buffer;
}
@@ -626,7 +660,7 @@
bool cChannel::StringToParameters(const char *s)
{
- while (s && *s) {
+ while (s && *s && !IsPlug()) {
switch (toupper(*s)) {
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
case 'C': s = ParseParameter(s, coderateH, CoderateValues); break;
@@ -736,7 +770,7 @@
dpids[0] = 0;
ok = false;
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
+ ok = ((source = cSource::FromString(sourcebuf)) >= 0) && StringToParameters(parambuf);
char *p = strchr(vpidbuf, '+');
if (p)
@@ -827,6 +861,7 @@
shortName = strcpyrealloc(shortName, p);
}
name = strcpyrealloc(name, namebuf);
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
free(parambuf);
free(sourcebuf);
diff -Nru vdr-1.6.0-vanilla/channels.h vdr-1.6.0-pluginparam/channels.h
--- vdr-1.6.0-vanilla/channels.h 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/channels.h 2008-03-27 22:06:47.000000000 +0200
@@ -114,6 +114,7 @@
char *shortName;
char *provider;
char *portalName;
+ char *pluginParam;
int __BeginData__;
int frequency; // MHz
int source;
@@ -165,6 +166,7 @@
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
+ const char *PluginParam(void) const { return pluginParam; }
int Source(void) const { return source; }
int Srate(void) const { return srate; }
int Vpid(void) const { return vpid; }
@@ -199,6 +201,7 @@
int Hierarchy(void) const { return hierarchy; }
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
const cChannel *RefChannel(void) const { return refChannel; }
+ bool IsPlug(void) const { return cSource::IsPlug(source); }
bool IsCable(void) const { return cSource::IsCable(source); }
bool IsSat(void) const { return cSource::IsSat(source); }
bool IsTerr(void) const { return cSource::IsTerr(source); }
@@ -206,12 +209,14 @@
bool HasTimer(void) const;
int Modification(int Mask = CHANNELMOD_ALL);
void CopyTransponderData(const cChannel *Channel);
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
void SetName(const char *Name, const char *ShortName, const char *Provider);
void SetPortalName(const char *PortalName);
+ void SetPluginParam(const char *PluginParam);
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
void SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level);
diff -Nru vdr-1.6.0-vanilla/config.h vdr-1.6.0-pluginparam/config.h
--- vdr-1.6.0-vanilla/config.h 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/config.h 2008-03-27 22:06:47.000000000 +0200
@@ -30,6 +30,8 @@
#define APIVERSION "1.6.0"
#define APIVERSNUM 10600 // Version * 10000 + Major * 100 + Minor
+#define PLUGINPARAMPATCHVERSNUM 1
+
// When loading plugins, VDR searches them by their APIVERSION, which
// may be smaller than VDRVERSION in case there have been no changes to
// VDR header files since the last APIVERSION. This allows compiled
diff -Nru vdr-1.6.0-vanilla/menu.c vdr-1.6.0-pluginparam/menu.c
--- vdr-1.6.0-vanilla/menu.c 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/menu.c 2008-03-27 22:06:47.000000000 +0200
@@ -253,6 +253,7 @@
cChannel *channel;
cChannel data;
char name[256];
+ char pluginParam[256];
void Setup(void);
public:
cMenuEditChannel(cChannel *Channel, bool New = false);
@@ -285,6 +286,7 @@
// Parameters for all types of sources:
strn0cpy(name, data.name, sizeof(name));
+ strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name)));
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
@@ -315,6 +317,7 @@
ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
SetCurrent(Get(current));
Display();
@@ -329,6 +332,7 @@
if (Key == kOk) {
if (Channels.HasUniqueChannelID(&data, channel)) {
data.name = strcpyrealloc(data.name, name);
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
if (channel) {
*channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.6.0-vanilla/po/fi_FI.po vdr-1.6.0-pluginparam/po/fi_FI.po
--- vdr-1.6.0-vanilla/po/fi_FI.po 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/po/fi_FI.po 2008-03-27 22:06:47.000000000 +0200
@@ -1001,3 +1001,6 @@
#, c-format
msgid "VDR will shut down in %s minutes"
msgstr "VDR sammuu %s minuutin kuluttua"
+
+msgid "Parameters"
+msgstr "Parametrit"
diff -Nru vdr-1.6.0-vanilla/po/fr_FR.po vdr-1.6.0-pluginparam/po/fr_FR.po
--- vdr-1.6.0-vanilla/po/fr_FR.po 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/po/fr_FR.po 2008-03-27 22:06:47.000000000 +0200
@@ -1004,3 +1004,6 @@
#, c-format
msgid "VDR will shut down in %s minutes"
msgstr "VDR s'arr<72>tera dans %s minutes"
+
+msgid "Parameters"
+msgstr "Param<61>tres"
diff -Nru vdr-1.6.0-vanilla/sources.c vdr-1.6.0-pluginparam/sources.c
--- vdr-1.6.0-vanilla/sources.c 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/sources.c 2008-03-27 22:06:47.000000000 +0200
@@ -37,6 +37,7 @@
char buffer[16];
char *q = buffer;
switch (Code & st_Mask) {
+ case stPlug: *q++ = 'P'; break;
case stCable: *q++ = 'C'; break;
case stSat: *q++ = 'S';
{
@@ -56,6 +57,7 @@
{
int type = stNone;
switch (toupper(*s)) {
+ case 'P': type = stPlug; break;
case 'C': type = stCable; break;
case 'S': type = stSat; break;
case 'T': type = stTerr; break;
diff -Nru vdr-1.6.0-vanilla/sources.conf vdr-1.6.0-pluginparam/sources.conf
--- vdr-1.6.0-vanilla/sources.conf 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/sources.conf 2008-03-27 22:06:47.000000000 +0200
@@ -188,3 +188,7 @@
# Terrestrial
T Terrestrial
+
+# Plugin
+
+P Plugin
diff -Nru vdr-1.6.0-vanilla/sources.h vdr-1.6.0-pluginparam/sources.h
--- vdr-1.6.0-vanilla/sources.h 2008-03-27 21:43:25.000000000 +0200
+++ vdr-1.6.0-pluginparam/sources.h 2008-03-27 22:06:47.000000000 +0200
@@ -16,10 +16,11 @@
public:
enum eSourceType {
stNone = 0x0000,
+ stPlug = 0x2000,
stCable = 0x4000,
stSat = 0x8000,
stTerr = 0xC000,
- st_Mask = 0xC000,
+ st_Mask = 0xE000,
st_Neg = 0x0800,
st_Pos = 0x07FF,
};
@@ -35,6 +36,7 @@
static cString ToString(int Code);
static int FromString(const char *s);
static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
+ static bool IsPlug(int Code) { return (Code & st_Mask) == stPlug; }
static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }

View File

@@ -0,0 +1,11 @@
diff -Nru vdr-1.7.12-vanilla/pat.c vdr-1.7.12-disable_ca_updates/pat.c
--- vdr-1.7.12-vanilla/pat.c 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.12-disable_ca_updates/pat.c 2010-02-01 13:54:32.000000000 +0200
@@ -458,6 +458,7 @@
}
if (Setup.UpdateChannels >= 2) {
Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
+ if (!Channel->IsPlug())
Channel->SetCaIds(CaDescriptors->CaIds());
Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
}

View File

@@ -0,0 +1,12 @@
diff -Nru vdr-1.7.12-vanilla/eitscan.c vdr-1.7.12-disable_eitscan/eitscan.c
--- vdr-1.7.12-vanilla/eitscan.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-disable_eitscan/eitscan.c 2010-02-01 13:54:20.000000000 +0200
@@ -146,7 +146,7 @@
if (Device) {
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
const cChannel *Channel = ScanData->GetChannel();
- if (Channel) {
+ if (Channel && !Channel->IsPlug()) {
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
if (Device->ProvidesTransponder(Channel)) {
if (!Device->Receiving()) {

View File

@@ -0,0 +1,287 @@
diff -Nru vdr-1.7.12-vanilla/channels.c vdr-1.7.12-pluginparam/channels.c
--- vdr-1.7.12-vanilla/channels.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/channels.c 2010-02-01 13:52:56.000000000 +0200
@@ -188,6 +188,7 @@
shortName = strdup("");
provider = strdup("");
portalName = strdup("");
+ pluginParam = strdup("");
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
inversion = INVERSION_AUTO;
bandwidth = 8000000;
@@ -211,6 +212,7 @@
shortName = NULL;
provider = NULL;
portalName = NULL;
+ pluginParam = NULL;
schedule = NULL;
linkChannels = NULL;
refChannel = NULL;
@@ -239,6 +241,7 @@
free(shortName);
free(provider);
free(portalName);
+ free(pluginParam);
}
cChannel& cChannel::operator= (const cChannel &Channel)
@@ -247,6 +250,7 @@
shortName = strcpyrealloc(shortName, Channel.shortName);
provider = strcpyrealloc(provider, Channel.provider);
portalName = strcpyrealloc(portalName, Channel.portalName);
+ pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
return *this;
}
@@ -307,9 +311,26 @@
guard = Channel->guard;
hierarchy = Channel->hierarchy;
rollOff = Channel->rollOff;
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
}
}
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
+{
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
+ if (Number()) {
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ source = Source;
+ frequency = Frequency;
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ schedule = NULL;
+ }
+ return true;
+}
+
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff)
{
// Workarounds for broadcaster stupidity:
@@ -439,6 +460,18 @@
}
}
+void cChannel::SetPluginParam(const char *PluginParam)
+{
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
+ if (Number()) {
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ }
+}
+
#define STRDIFF 0x01
#define VALDIFF 0x02
@@ -652,7 +685,7 @@
if (isdigit(type))
type = 'S';
#define ST(s) if (strchr(s, type))
- char buffer[64];
+ char buffer[256];
char *q = buffer;
*q = 0;
ST(" S ") q += sprintf(q, "%c", polarization);
@@ -666,6 +699,7 @@
ST(" S ") q += PrintParameter(q, 'S', MapToUser(system, SystemValues));
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
+ ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
return buffer;
}
@@ -694,7 +728,7 @@
bool cChannel::StringToParameters(const char *s)
{
- while (s && *s) {
+ while (s && *s && !IsPlug()) {
switch (toupper(*s)) {
case 'A': s = SkipDigits(s); break; // for compatibility with the "multiproto" approach - may be removed in future versions
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
@@ -814,7 +848,7 @@
dpids[0] = 0;
ok = false;
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
+ ok = ((source = cSource::FromString(sourcebuf)) >= 0) && StringToParameters(parambuf);
char *p;
if ((p = strchr(vpidbuf, '=')) != NULL) {
@@ -911,6 +945,7 @@
shortName = strcpyrealloc(shortName, p);
}
name = strcpyrealloc(name, namebuf);
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
free(parambuf);
free(sourcebuf);
diff -Nru vdr-1.7.12-vanilla/channels.h vdr-1.7.12-pluginparam/channels.h
--- vdr-1.7.12-vanilla/channels.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/channels.h 2010-02-01 13:52:56.000000000 +0200
@@ -116,6 +116,7 @@
char *shortName;
char *provider;
char *portalName;
+ char *pluginParam;
int __BeginData__;
int frequency; // MHz
int source;
@@ -174,6 +175,7 @@
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
+ const char *PluginParam(void) const { return pluginParam; }
int Source(void) const { return source; }
int Srate(void) const { return srate; }
int Vpid(void) const { return vpid; }
@@ -214,6 +216,7 @@
int RollOff(void) const { return rollOff; }
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
const cChannel *RefChannel(void) const { return refChannel; }
+ bool IsPlug(void) const { return cSource::IsPlug(source); }
bool IsCable(void) const { return cSource::IsCable(source); }
bool IsSat(void) const { return cSource::IsSat(source); }
bool IsTerr(void) const { return cSource::IsTerr(source); }
@@ -221,12 +224,14 @@
bool HasTimer(void) const;
int Modification(int Mask = CHANNELMOD_ALL);
void CopyTransponderData(const cChannel *Channel);
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff);
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
void SetName(const char *Name, const char *ShortName, const char *Provider);
void SetPortalName(const char *PortalName);
+ void SetPluginParam(const char *PluginParam);
void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
void SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level);
diff -Nru vdr-1.7.12-vanilla/config.h vdr-1.7.12-pluginparam/config.h
--- vdr-1.7.12-vanilla/config.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/config.h 2010-02-01 13:52:56.000000000 +0200
@@ -30,6 +30,8 @@
#define APIVERSION "1.7.12"
#define APIVERSNUM 10712 // Version * 10000 + Major * 100 + Minor
+#define PLUGINPARAMPATCHVERSNUM 1
+
// When loading plugins, VDR searches them by their APIVERSION, which
// may be smaller than VDRVERSION in case there have been no changes to
// VDR header files since the last APIVERSION. This allows compiled
diff -Nru vdr-1.7.12-vanilla/menu.c vdr-1.7.12-pluginparam/menu.c
--- vdr-1.7.12-vanilla/menu.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/menu.c 2010-02-01 13:52:56.000000000 +0200
@@ -190,6 +190,7 @@
cChannel *channel;
cChannel data;
char name[256];
+ char pluginParam[256];
void Setup(void);
public:
cMenuEditChannel(cChannel *Channel, bool New = false);
@@ -222,6 +223,7 @@
// Parameters for all types of sources:
strn0cpy(name, data.name, sizeof(name));
+ strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name)));
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
@@ -254,6 +256,7 @@
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues));
ST(" S ") Add(new cMenuEditMapItem( tr("Rolloff"), &data.rollOff, RollOffValues));
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
SetCurrent(Get(current));
Display();
@@ -268,6 +271,7 @@
if (Key == kOk) {
if (Channels.HasUniqueChannelID(&data, channel)) {
data.name = strcpyrealloc(data.name, name);
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
if (channel) {
*channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.7.12-vanilla/po/fi_FI.po vdr-1.7.12-pluginparam/po/fi_FI.po
--- vdr-1.7.12-vanilla/po/fi_FI.po 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.12-pluginparam/po/fi_FI.po 2010-02-01 13:52:56.000000000 +0200
@@ -1306,3 +1306,6 @@
#, c-format
msgid "VDR will shut down in %s minutes"
msgstr "VDR sammuu %s minuutin kuluttua"
+
+msgid "Parameters"
+msgstr "Parametrit"
diff -Nru vdr-1.7.12-vanilla/po/fr_FR.po vdr-1.7.12-pluginparam/po/fr_FR.po
--- vdr-1.7.12-vanilla/po/fr_FR.po 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.12-pluginparam/po/fr_FR.po 2010-02-01 13:52:56.000000000 +0200
@@ -1309,3 +1309,6 @@
#, c-format
msgid "VDR will shut down in %s minutes"
msgstr "VDR s'arr<72>tera dans %s minutes"
+
+msgid "Parameters"
+msgstr "Param<61>tres"
diff -Nru vdr-1.7.12-vanilla/sources.c vdr-1.7.12-pluginparam/sources.c
--- vdr-1.7.12-vanilla/sources.c 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.12-pluginparam/sources.c 2010-02-01 13:52:56.000000000 +0200
@@ -37,6 +37,7 @@
char buffer[16];
char *q = buffer;
switch (Code & st_Mask) {
+ case stPlug: *q++ = 'P'; break;
case stCable: *q++ = 'C'; break;
case stSat: *q++ = 'S';
{
@@ -56,6 +57,7 @@
{
int type = stNone;
switch (toupper(*s)) {
+ case 'P': type = stPlug; break;
case 'C': type = stCable; break;
case 'S': type = stSat; break;
case 'T': type = stTerr; break;
diff -Nru vdr-1.7.12-vanilla/sources.conf vdr-1.7.12-pluginparam/sources.conf
--- vdr-1.7.12-vanilla/sources.conf 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/sources.conf 2010-02-01 13:52:56.000000000 +0200
@@ -195,3 +195,7 @@
# Terrestrial
T Terrestrial
+
+# Plugin
+
+P Plugin
diff -Nru vdr-1.7.12-vanilla/sources.h vdr-1.7.12-pluginparam/sources.h
--- vdr-1.7.12-vanilla/sources.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-pluginparam/sources.h 2010-02-01 13:52:56.000000000 +0200
@@ -16,10 +16,11 @@
public:
enum eSourceType {
stNone = 0x0000,
+ stPlug = 0x2000,
stCable = 0x4000,
stSat = 0x8000,
stTerr = 0xC000,
- st_Mask = 0xC000,
+ st_Mask = 0xE000,
st_Neg = 0x0800,
st_Pos = 0x07FF,
};
@@ -35,6 +36,7 @@
static cString ToString(int Code);
static int FromString(const char *s);
static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
+ static bool IsPlug(int Code) { return (Code & st_Mask) == stPlug; }
static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }

View File

@@ -13,9 +13,8 @@
#define PIDSCANNER_VPID_COUNT 5 /* minimum count of video pid samples for pid detection */
#define PIDSCANNER_PID_DELTA_COUNT 100 /* minimum count of pid samples for audio/video only pid detection */
cPidScanner::cPidScanner(void)
cPidScanner::cPidScanner(void)
: timeout(0),
channelId(tChannelID::InvalidID),
process(true),
Vpid(0xFFFF),
Apid(0xFFFF),
@@ -23,17 +22,24 @@ cPidScanner::cPidScanner(void)
numApids(0)
{
debug("cPidScanner::cPidScanner()\n");
channel = cChannel();
}
cPidScanner::~cPidScanner()
cPidScanner::~cPidScanner()
{
debug("cPidScanner::~cPidScanner()\n");
}
void cPidScanner::SetChannel(const tChannelID &ChannelId)
void cPidScanner::SetChannel(const cChannel *Channel)
{
debug("cPidScanner::SetChannel(): %s\n", *ChannelId.ToString());
channelId = ChannelId;
if (Channel) {
debug("cPidScanner::SetChannel(): %s\n", Channel->PluginParam());
channel = *Channel;
}
else {
debug("cPidScanner::SetChannel()\n");
channel = cChannel();
}
Vpid = 0xFFFF;
numVpids = 0;
Apid = 0xFFFF;
@@ -113,17 +119,14 @@ void cPidScanner::Process(const uint8_t* buf)
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
return;
}
cChannel *IptvChannel = Channels.GetByChannelID(channelId);
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
if (IptvChannel) {
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
int Atypes[MAXAPIDS + 1] = { 0 };
int Dpids[MAXDPIDS + 1] = { 0 };
int Dtypes[MAXDPIDS + 1] = { 0 };
int Spids[MAXSPIDS + 1] = { 0 };
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
int Vtype = IptvChannel->Vtype();
int Ppid = IptvChannel->Ppid();
int Tpid = IptvChannel->Tpid();
bool foundApid = false;
@@ -131,24 +134,24 @@ void cPidScanner::Process(const uint8_t* buf)
Vpid = 0; // No detected video pid
else if (numApids < PIDSCANNER_APID_COUNT)
Apid = 0; // No detected audio pid
for (unsigned int i = 0; i < MAXAPIDS; ++i) {
for (unsigned int i = 1; i < MAXAPIDS; ++i) {
Apids[i] = IptvChannel->Apid(i);
Atypes[i] = IptvChannel->Atype(i);
if (Apids[i] && (Apids[i] == Apid))
foundApid = true;
}
if (!foundApid) {
if (!foundApid)
Apids[0] = Apid;
Atypes[0] = 4;
}
for (unsigned int i = 0; i < MAXDPIDS; ++i) {
for (unsigned int i = 0; i < MAXDPIDS; ++i)
Dpids[i] = IptvChannel->Dpid(i);
Dtypes[i] = IptvChannel->Dtype(i);
}
for (unsigned int i = 0; i < MAXSPIDS; ++i)
Spids[i] = IptvChannel->Spid(i);
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid);
IptvChannel->SetPids(Vpid, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
int Vtype = IptvChannel->Vtype();
IptvChannel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#else
IptvChannel->SetPids(Vpid, Ppid, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#endif
}
Channels.Unlock();
process = false;

View File

@@ -14,7 +14,7 @@
class cPidScanner {
private:
cTimeMs timeout;
tChannelID channelId;
cChannel channel;
bool process;
int Vpid;
int Apid;
@@ -24,7 +24,7 @@ private:
public:
cPidScanner(void);
~cPidScanner();
void SetChannel(const tChannelID &ChannelId);
void SetChannel(const cChannel *Channel);
void Process(const uint8_t* buf);
};

View File

@@ -5,13 +5,12 @@
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Project-Id-Version: iptv 0.2.5\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
"PO-Revision-Date: 2007-10-29 21:19+0100\n"
"Last-Translator: Tobias Grimm <tg@e-tobi.net>\n"
"Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -41,6 +40,60 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Erlebe IPTV"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "DATEI"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Protokoll"
msgid "Delay (ms)"
msgstr "Verzögerung (ms)"
msgid "Script"
msgstr "Skript"
msgid "Parameter"
msgstr "Parameter"
msgid "Address"
msgstr "Adresse"
msgid "Port"
msgstr "Port"
msgid "Scan Sid"
msgstr "Scanne SID"
msgid "Scan pids"
msgstr "Scanne PIDS"
msgid "Vtype"
msgstr "Vtype"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Kann eindeutige Kanaleinstellungen nicht finden!"
msgid "IPTV Channels"
msgstr "IPTV Kanäle"
msgid "IPTV Information"
msgstr "IPTV Informationen"
@@ -114,39 +167,3 @@ msgstr ""
msgid "Help"
msgstr "Hilfe"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "DATEI"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scanne Section IDS"
msgid "Scan pids"
msgstr "Scanne PIDS"
msgid "Protocol"
msgstr "Protokoll"
msgid "Address"
msgstr "Adresse"
msgid "Parameter"
msgstr "Parameter"

View File

@@ -5,13 +5,12 @@
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Project-Id-Version: iptv 0.2.5\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n"
"Language-Team: <vdr@linuxtv.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -40,6 +39,60 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Protokolla"
msgid "Delay (ms)"
msgstr "Viive (ms)"
msgid "Script"
msgstr "Skripti"
msgid "Parameter"
msgstr "Parametri"
msgid "Address"
msgstr "Osoite"
msgid "Port"
msgstr "Portti"
msgid "Scan Sid"
msgstr "Etsi palvelu-ID"
msgid "Scan pids"
msgstr "Etsi pidit"
msgid "Vtype"
msgstr "Kuvatyyppi"
msgid "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "Lähete-ID"
msgid "Rid"
msgstr "Radio-ID"
msgid "Cannot find unique channel settings!"
msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!"
msgid "IPTV Channels"
msgstr "IPTV-kanavat"
msgid "IPTV Information"
msgstr "IPTV-tiedot"
@@ -129,39 +182,3 @@ msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle
msgid "Help"
msgstr "Opaste"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "Lähete-ID"
msgid "Rid"
msgstr "Radio-ID"
msgid "Scan section ids"
msgstr "Etsi sektiotunnisteet"
msgid "Scan pids"
msgstr "Etsi pidit"
msgid "Protocol"
msgstr "Protokolla"
msgid "Address"
msgstr "Osoite"
msgid "Parameter"
msgstr "Parametri"

View File

@@ -6,13 +6,12 @@
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Project-Id-Version: iptv 0.2.5\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
"PO-Revision-Date: 2008-01-26 13:14+0100\n"
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
"Language-Team: French <vdr@linuxtv.org>\n"
"Language: fr\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -42,6 +41,60 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "L'expérience IPTV"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FICHIER"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Protocole"
msgid "Delay (ms)"
msgstr "Délai (ms)"
msgid "Script"
msgstr "Script"
msgid "Parameter"
msgstr "Paramètre"
msgid "Address"
msgstr "Adresse"
msgid "Port"
msgstr "Port"
msgid "Scan Sid"
msgstr "Scanne les SID"
msgid "Scan pids"
msgstr "Scanne les PID"
msgid "Vtype"
msgstr "Vtype"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Impossible de trouver un paramètre de chaîne unique !"
msgid "IPTV Channels"
msgstr "Canal IPTV"
msgid "IPTV Information"
msgstr "Information sur IPTV"
@@ -131,39 +184,3 @@ msgstr "Définit les mauvais comportement qui doivent être désactivé."
msgid "Help"
msgstr "Aide"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FICHIER"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scanne les section ID"
msgid "Scan pids"
msgstr "Scanne les PID"
msgid "Protocol"
msgstr "Protocole"
msgid "Address"
msgstr "Adresse"
msgid "Parameter"
msgstr "Paramètre"

View File

@@ -5,13 +5,12 @@
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Project-Id-Version: iptv 0.2.5\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
"PO-Revision-Date: 2008-07-13 03:28+0100\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: Italian <vdr@linuxtv.org>\n"
"Language: it\n"
"Language-Team: Italian\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -41,6 +40,60 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Scopri la IPTV"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Protocollo"
msgid "Delay (ms)"
msgstr "Ritardo (ms)"
msgid "Script"
msgstr "Script"
msgid "Parameter"
msgstr "Parametro"
msgid "Address"
msgstr "Indirizzo"
msgid "Port"
msgstr "Porta"
msgid "Scan Sid"
msgstr "Scansione Sid"
msgid "Scan pids"
msgstr "Scansione Pids"
msgid "Vtype"
msgstr "Vtype"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Impossibile trovare impostazioni canale unico!"
msgid "IPTV Channels"
msgstr "Canali IPTV"
msgid "IPTV Information"
msgstr "Informazione IPTV"
@@ -130,39 +183,3 @@ msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
msgid "Help"
msgstr "Aiuto"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scansione Section Ids"
msgid "Scan pids"
msgstr "Scansione Pids"
msgid "Protocol"
msgstr "Protocollo"
msgid "Address"
msgstr "Indirizzo"
msgid "Parameter"
msgstr "Parametro"

View File

@@ -1,167 +0,0 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Carel, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Last-Translator: Carel\n"
"Language-Team: Dutch <vdr@linuxtv.org>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "TV programma's via IP"
msgid "IPTV Information"
msgstr "IPTV informatie"
msgid "General"
msgstr "Algemeen"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filter"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "IPTV informatie niet beschikbaar!"
msgid "TS buffer size [MB]"
msgstr "TS buffergrootte [MB]"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr ""
"Stel de grootte van de ringbuffer vast voor transportstreams in megabytes.\n"
"\n"
"Bij lage waarden zapt VDR sneller maar kunnen leiden tot bufferoverschreidingen en dus dropouts."
msgid "TS buffer prefill ratio [%]"
msgstr "TS buffer-preload [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
"Stel een 'prefil ratio' in voor de ringbuffer voor transportstreams voor de data naar VDR wordt verstuurd.\n"
"\n"
"Dit is aan te bevelen bij onbetrouwbare of langzame verbindingen."
msgid "EXT protocol base port"
msgstr "EXT protocol basispoort"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
"Bepaal de basispoort voor het EXT protocol.\n"
"\n"
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het EXT protocol wordt gebruikt."
msgid "Use section filtering"
msgstr "Benutze Abschnittsfilterung"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
"Bepaal of er sectionfilterimg moet worden gebrukt.\n"
"\n"
"Bij sectiefiltering zal de IPTV plugin VDR van extra informatie over de stream voorzien. VDR kan dan bijvoorbeeld automatisch de PIDs wijzigen of de EPG tonen.Het gebruik van deze mogelijkheid heeft geen effect op streams die geen sectiedata bevatten."
msgid "Disable filters"
msgstr "Deactiveer filter"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Bepaal het aantal de de-activeren sectiefilters.\n"
"\n"
"Sommige sctiefilters kunnen ongewenste effecten veroorzaken. Door ze hier op te nemen blijft de data intact zodat VDR het kan blijven gebruiken."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Deactiveer filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Blacklist een probleem veroorzakend filter "
msgid "Help"
msgstr "Help"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "BESTAND"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scan section IDS"
msgid "Scan pids"
msgstr "Scan PIDS"
msgid "Protocol"
msgstr "Protocol"
msgid "Address"
msgstr "Adres"
msgid "Parameter"
msgstr "Parameter"

View File

@@ -5,13 +5,12 @@
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.0.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
"Project-Id-Version: iptv 0.2.5\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
"PO-Revision-Date: 2008-03-16 12:14+0100\n"
"Last-Translator: Alexander Gross <Bikalexander@gmail.com>\n"
"Language-Team: Russian <vdr@linuxtv.org>\n"
"Language: ru\n"
"Language-Team: Russian <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -42,6 +41,60 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Попробуй IPTV"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "ФАЙЛ"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Протокол"
msgid "Delay (ms)"
msgstr "Задержка (мс)"
msgid "Script"
msgstr "Скрипт"
msgid "Parameter"
msgstr "Параметр"
msgid "Address"
msgstr "Адрес"
msgid "Port"
msgstr "Порт"
msgid "Scan Sid"
msgstr "Сканировать SID"
msgid "Scan pids"
msgstr "Сканировать пиды"
msgid "Vtype"
msgstr "Vtype"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Невозможно найти уникальные настройки канала!"
msgid "IPTV Channels"
msgstr "IPTV каналы"
msgid "IPTV Information"
msgstr "IPTV информация"
@@ -115,39 +168,3 @@ msgstr "Неправильно работающий фильтр, занести
msgid "Help"
msgstr "Справка"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "ФАЙЛ"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Сканировать section ids"
msgid "Scan pids"
msgstr "Сканировать пиды"
msgid "Protocol"
msgstr "Протокол"
msgid "Address"
msgstr "Адрес"
msgid "Parameter"
msgstr "Параметр"

View File

@@ -19,15 +19,10 @@
#include "config.h"
#include "protocolext.h"
#ifndef EXTSHELL
#define EXTSHELL "/bin/bash"
#endif
cIptvProtocolExt::cIptvProtocolExt()
: pid(-1),
scriptFile(""),
scriptParameter(0),
streamPort(0)
scriptParameter(0)
{
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
}
@@ -43,8 +38,6 @@ void cIptvProtocolExt::ExecuteScript(void)
{
debug("cIptvProtocolExt::ExecuteScript()\n");
// Check if already executing
if (isActive || isempty(scriptFile))
return;
if (pid > 0) {
error("Cannot execute script!");
return;
@@ -58,11 +51,9 @@ void cIptvProtocolExt::ExecuteScript(void)
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
close(i);
// Execute the external script
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, streamPort);
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort);
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
// Create a new session for a process group
ERROR_IF_RET(setsid() == -1, "setsid()", _exit(-1));
if (execl(EXTSHELL, "sh", "-c", *cmd, (char *)NULL) == -1) {
if (execl("/bin/sh", "sh", "-c", *cmd, NULL) == -1) {
error("Script execution failed: %s", *cmd);
_exit(-1);
}
@@ -76,41 +67,30 @@ void cIptvProtocolExt::ExecuteScript(void)
void cIptvProtocolExt::TerminateScript(void)
{
debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pid);
if (!isActive || isempty(scriptFile))
return;
if (pid > 0) {
const unsigned int timeoutms = 100;
unsigned int waitms = 0;
siginfo_t waitStatus;
bool waitOver = false;
// Signal and wait for termination
int retval = killpg(pid, SIGINT);
// signal and wait for termination
int retval = kill(pid, SIGINT);
ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
while (!waitOver) {
retval = 0;
waitms += timeoutms;
if ((waitms % 2000) == 0) {
error("Script '%s' won't terminate - killing it!", *scriptFile);
killpg(pid, SIGKILL);
kill(pid, SIGKILL);
}
// Clear wait status to make sure child exit status is accessible
// and wait for child termination
#ifdef __FreeBSD__
int waitStatus = 0;
retval = waitpid(pid, &waitStatus, WNOHANG);
#else // __FreeBSD__
siginfo_t waitStatus;
memset(&waitStatus, '\0', sizeof(waitStatus));
// Wait for child termination
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
#endif // __FreeBSD__
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
// These are the acceptable conditions under which child exit is
// regarded as successful
#ifdef __FreeBSD__
if (retval > 0 && (WIFEXITED(waitStatus) || WIFSIGNALED(waitStatus))) {
#else // __FreeBSD__
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
#endif // __FreeBSD__
debug("Child (%d) exited as expected\n", pid);
waitOver = true;
}
@@ -129,7 +109,7 @@ bool cIptvProtocolExt::Open(void)
if (!strlen(*scriptFile))
return false;
// Create the listening socket
OpenSocket(streamPort);
OpenSocket(socketPort);
// Execute the external script
ExecuteScript();
isActive = true;
@@ -139,11 +119,11 @@ bool cIptvProtocolExt::Open(void)
bool cIptvProtocolExt::Close(void)
{
debug("cIptvProtocolExt::Close()\n");
// Close the socket
CloseSocket();
// Terminate the external script
TerminateScript();
isActive = false;
// Close the socket
CloseSocket();
return true;
}
@@ -165,7 +145,7 @@ bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int
}
scriptParameter = Parameter;
// Update listen port
streamPort = IptvConfig.GetExtProtocolBasePort() + Index;
socketPort = IptvConfig.GetExtProtocolBasePort() + Index;
}
return true;
}

View File

@@ -17,7 +17,6 @@ private:
int pid;
cString scriptFile;
int scriptParameter;
int streamPort;
private:
void TerminateScript(void);

View File

@@ -19,11 +19,10 @@
#include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp()
: streamAddr(strdup("")),
streamPath(strdup("/")),
streamPort(0)
{
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
streamAddr = strdup("");
streamPath = strdup("/");
}
cIptvProtocolHttp::~cIptvProtocolHttp()
@@ -41,29 +40,66 @@ bool cIptvProtocolHttp::Connect(void)
debug("cIptvProtocolHttp::Connect()\n");
// Check that stream address is valid
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
// Ensure that socket is valid and connect
OpenSocket(streamPort, streamAddr);
if (!ConnectSocket()) {
// Ensure that socket is valid
OpenSocket(socketPort);
// First try only the IP address
sockAddr.sin_addr.s_addr = inet_addr(streamAddr);
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
debug("Cannot convert %s directly to internet address\n", streamAddr);
// It may be a host name, get the name
struct hostent *host;
host = gethostbyname(streamAddr);
if (!host) {
char tmp[64];
error("%s is not valid address: %s", streamAddr, strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list);
}
int err = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected
ERROR_IF_FUNC(err < 0 && errno != EINPROGRESS, "connect()", CloseSocket(), return false);
// Select with 800ms timeout on the socket completion, check if it is writable
int retval = select_single_desc(socketDesc, 800000, true);
if (retval < 0)
return retval;
// Select has returned. Get socket errors if there are any
int socketStatus = 0;
socklen_t len = sizeof(socketStatus);
getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &socketStatus, &len);
// If not any errors, then socket must be ready and connected
if (socketStatus != 0) {
char tmp[64];
error("Cannot connect to %s: %s", streamAddr, strerror_r(socketStatus, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Formulate and send HTTP request
cString buffer = cString::sprintf("GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: vdr-%s/%s\r\n"
"User-Agent: vdr-iptv\r\n"
"Range: bytes=0-\r\n"
"Connection: Close\r\n"
"\r\n", streamPath, streamAddr, PLUGIN_NAME_I18N, VERSION);
"\r\n", streamPath, streamAddr);
debug("Sending http request: %s\n", *buffer);
if (!Write(*buffer, (unsigned int)strlen(*buffer))) {
CloseSocket();
return false;
}
ssize_t err2 = send(socketDesc, buffer, strlen(buffer), 0);
ERROR_IF_FUNC(err2 < 0, "send()", CloseSocket(), return false);
// Now process headers
if (!ProcessHeaders()) {
CloseSocket();
return false;
}
// Update active flag
isActive = true;
}
@@ -73,6 +109,7 @@ bool cIptvProtocolHttp::Connect(void)
bool cIptvProtocolHttp::Disconnect(void)
{
debug("cIptvProtocolHttp::Disconnect()\n");
// Check that stream address is valid
if (isActive) {
// Close the socket
CloseSocket();
@@ -88,15 +125,24 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
debug("cIptvProtocolHttp::GetHeaderLine()\n");
bool linefeed = false;
bool newline = false;
char *bufptr = dest;
char buf[4096];
char *bufptr = buf;
memset(buf, '\0', sizeof(buf));
recvLen = 0;
if (!dest)
return false;
while (!newline || !linefeed) {
socklen_t addrlen = sizeof(sockAddr);
// Wait 500ms for data
if (ReadChar(bufptr, 500)) {
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return false;
// Check if data available
else if (retval) {
ssize_t retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
if (retval <= 0)
return false;
// Parsing end conditions, if line ends with \r\n
if (linefeed && *bufptr == '\n')
newline = true;
@@ -109,18 +155,19 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
++recvLen;
}
++bufptr;
// Check that buffer won't be exceeded
if (recvLen >= destLen) {
// Check that buffers won't be exceeded
if (recvLen >= sizeof(buf) || recvLen >= destLen) {
error("Header wouldn't fit into buffer\n");
recvLen = 0;
return false;
}
}
else {
error("No HTTP response received in 500ms\n");
error("No HTTP response received\n");
return false;
}
}
memcpy(dest, buf, recvLen);
return true;
}
@@ -128,27 +175,22 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
{
debug("cIptvProtocolHttp::ProcessHeaders()\n");
unsigned int lineLength = 0;
int version = 0, response = 0;
int response = 0;
bool responseFound = false;
char fmt[32];
char buf[4096];
// Generate HTTP response format string with 2 arguments
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
while (!responseFound || lineLength != 0) {
memset(buf, '\0', sizeof(buf));
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
return false;
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
if (!responseFound && sscanf(buf, "HTTP/1.%*i %i ", &response) != 1) {
error("Expected HTTP header not found\n");
continue;
}
else
responseFound = true;
// Allow only 'OK' and 'Partial Content'
if ((response != 200) && (response != 206)) {
error("Invalid HTTP response (%d): %s\n", response, buf);
if (response != 200) {
error("%s\n", buf);
return false;
}
}
@@ -190,8 +232,8 @@ bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int
}
else
streamPath = strcpyrealloc(streamPath, "/");
streamPort = Parameter;
//debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
socketPort = Parameter;
//debug("http://%s:%d%s\n", streamAddr, socketPort, streamPath);
// Re-connect the socket
Connect();
}
@@ -201,5 +243,5 @@ bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int
cString cIptvProtocolHttp::GetInformation(void)
{
//debug("cIptvProtocolHttp::GetInformation()");
return cString::sprintf("http://%s:%d%s", streamAddr, streamPort, streamPath);
return cString::sprintf("http://%s:%d%s", streamAddr, socketPort, streamPath);
}

View File

@@ -16,7 +16,6 @@ class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
private:
char* streamAddr;
char* streamPath;
int streamPort;
private:
bool Connect(void);

View File

@@ -19,12 +19,9 @@
#include "socket.h"
cIptvProtocolUdp::cIptvProtocolUdp()
: isIGMPv3(false),
sourceAddr(strdup("")),
streamAddr(strdup("")),
streamPort(0)
{
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
streamAddr = strdup("");
}
cIptvProtocolUdp::~cIptvProtocolUdp()
@@ -34,34 +31,63 @@ cIptvProtocolUdp::~cIptvProtocolUdp()
cIptvProtocolUdp::Close();
// Free allocated memory
free(streamAddr);
free(sourceAddr);
}
bool cIptvProtocolUdp::JoinMulticast(void)
{
debug("cIptvProtocolUdp::JoinMulticast()\n");
// Check that stream address is valid
if (!isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(socketPort);
// Join a new multicast group
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
int err = setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq));
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = true;
}
return true;
}
bool cIptvProtocolUdp::DropMulticast(void)
{
debug("cIptvProtocolUdp::DropMulticast()\n");
// Check that stream address is valid
if (isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(socketPort);
// Drop the multicast group
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
int err = setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq,
sizeof(mreq));
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = false;
}
return true;
}
bool cIptvProtocolUdp::Open(void)
{
debug("cIptvProtocolUdp::Open(): streamAddr=%s\n", streamAddr);
OpenSocket(streamPort, streamAddr, sourceAddr, isIGMPv3);
if (!isempty(streamAddr)) {
// Join a new multicast group
JoinMulticast();
}
debug("cIptvProtocolUdp::Open()\n");
// Join a new multicast group
JoinMulticast();
return true;
}
bool cIptvProtocolUdp::Close(void)
{
debug("cIptvProtocolUdp::Close(): streamAddr=%s\n", streamAddr);
if (!isempty(streamAddr)) {
// Drop the multicast group
OpenSocket(streamPort, streamAddr, sourceAddr, isIGMPv3);
DropMulticast();
}
debug("cIptvProtocolUdp::Close()\n");
// Drop the multicast group
DropMulticast();
// Close the socket
CloseSocket();
// Do NOT reset stream and source addresses
//sourceAddr = strcpyrealloc(sourceAddr, "");
//streamAddr = strcpyrealloc(streamAddr, "");
//streamPort = 0;
return true;
}
@@ -74,39 +100,19 @@ bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int
{
debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Drop the multicast group
if (!isempty(streamAddr)) {
OpenSocket(streamPort, streamAddr, sourceAddr, isIGMPv3);
DropMulticast();
}
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Location);
// <group address> or <source address>@<group address>
char *p = strstr(streamAddr, "@");
if (p) {
*p = 0;
sourceAddr = strcpyrealloc(sourceAddr, streamAddr);
streamAddr = strcpyrealloc(streamAddr, p + 1);
isIGMPv3 = true;
}
else {
sourceAddr = strcpyrealloc(sourceAddr, streamAddr);
isIGMPv3 = false;
}
streamPort = Parameter;
// Join a new multicast group
if (!isempty(streamAddr)) {
OpenSocket(streamPort, streamAddr, sourceAddr, isIGMPv3);
JoinMulticast();
}
}
// Drop the multicast group
DropMulticast();
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Location);
socketPort = Parameter;
// Join a new multicast group
JoinMulticast();
}
return true;
}
cString cIptvProtocolUdp::GetInformation(void)
{
//debug("cIptvProtocolUdp::GetInformation()");
if (isIGMPv3)
return cString::sprintf("udp://%s@%s:%d", sourceAddr, streamAddr, streamPort);
return cString::sprintf("udp://%s:%d", streamAddr, streamPort);
return cString::sprintf("udp://%s:%d", streamAddr, socketPort);
}

View File

@@ -14,10 +14,11 @@
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
private:
bool isIGMPv3;
char* sourceAddr;
char* streamAddr;
int streamPort;
private:
bool JoinMulticast(void);
bool DropMulticast(void);
public:
cIptvProtocolUdp();

View File

@@ -5,10 +5,10 @@
*
*/
#include "config.h"
#include "sectionfilter.h"
cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, uint16_t Pid, uint8_t Tid, uint8_t Mask)
cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
uint16_t Pid, uint8_t Tid, uint8_t Mask)
: pusi_seen(0),
feedcc(0),
doneq(0),
@@ -17,9 +17,10 @@ cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, uint16_t Pid, uint8_t Ti
seclen(0),
tsfeedp(0),
pid(Pid),
devid(DeviceIndex)
devid(DeviceIndex),
id(Index)
{
//debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, pid);
//debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, id);
int i;
memset(secbuf_base, '\0', sizeof(secbuf_base));
@@ -46,30 +47,35 @@ cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, uint16_t Pid, uint8_t Ti
}
doneq = local_doneq ? 1 : 0;
// Create filtering buffer
ringbuffer = new cRingBufferLinear(KILOBYTE(128), 0, false, *cString::sprintf("IPTV SECTION %d/%d", devid, pid));
if (ringbuffer)
ringbuffer->SetTimeouts(10, 10);
else
error("Failed to allocate buffer for section filter (device=%d pid=%d): ", devid, pid);
// Create sockets
socket[0] = socket[1] = -1;
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, socket) != 0) {
char tmp[64];
error("Opening section filter sockets failed (device=%d id=%d): %s\n", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
}
else if ((fcntl(socket[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socket[1], F_SETFL, O_NONBLOCK) != 0)) {
char tmp[64];
error("Setting section filter socket to non-blocking mode failed (device=%d id=%d): %s", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
}
}
cIptvSectionFilter::~cIptvSectionFilter()
{
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, pid);
DELETE_POINTER(ringbuffer);
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, id);
int tmp = socket[1];
socket[1] = -1;
if (tmp >= 0)
close(tmp);
tmp = socket[0];
socket[0] = -1;
if (tmp >= 0)
close(tmp);
secbuf = NULL;
}
int cIptvSectionFilter::Read(void *Data, size_t Length)
int cIptvSectionFilter::GetReadDesc(void)
{
int count = 0;
uchar *p = ringbuffer->Get(count);
if (p && count > 0) {
memcpy(Data, p, count);
ringbuffer->Del(count);
}
return count;
return socket[0];
}
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *Data)
@@ -85,10 +91,10 @@ void cIptvSectionFilter::New(void)
int cIptvSectionFilter::Filter(void)
{
if (secbuf) {
int i;
uint8_t neq = 0;
uint8_t neq = 0;
int i;
if (secbuf) {
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
uint8_t local_xor = (uint8_t)(filter_value[i] ^ secbuf[i]);
if (maskandmode[i] & local_xor)
@@ -99,10 +105,10 @@ int cIptvSectionFilter::Filter(void)
if (doneq && !neq)
return 0;
if (ringbuffer) {
int len = ringbuffer->Put(secbuf, seclen);
if (len != seclen)
ringbuffer->ReportOverflow(seclen - len);
// There is no data in the read socket, more can be written
if ((socket[0] >= 0) && (socket[1] >= 0) /*&& !select_single_desc(socket[0], 0, false)*/) {
ssize_t len = write(socket[1], secbuf, seclen);
ERROR_IF(len < 0, "write()");
// Update statistics
AddSectionStatistic(len, 1);
}
@@ -132,7 +138,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
return 0;
memcpy(secbuf_base + tsfeedp, buf, len);
tsfeedp = uint16_t(tsfeedp + len);
tsfeedp += len;
limit = tsfeedp;
if (limit > DMX_MAX_SECFEED_SIZE)
@@ -148,7 +154,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
seclen = seclen_local;
if (pusi_seen)
Feed();
secbufp = uint16_t(secbufp + seclen_local);
secbufp += seclen_local;
secbuf += seclen_local;
}
return 0;

View File

@@ -8,9 +8,6 @@
#ifndef __IPTV_SECTIONFILTER_H
#define __IPTV_SECTIONFILTER_H
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif // __FreeBSD__
#include <vdr/device.h>
#include "common.h"
@@ -36,6 +33,8 @@ private:
uint16_t pid;
int devid;
int id;
int socket[2];
uint8_t filter_value[DMX_MAX_FILTER_SIZE];
uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
@@ -44,8 +43,6 @@ private:
uint8_t maskandmode[DMX_MAX_FILTER_SIZE];
uint8_t maskandnotmode[DMX_MAX_FILTER_SIZE];
cRingBufferLinear *ringbuffer;
inline uint16_t GetLength(const uint8_t *Data);
void New(void);
int Filter(void);
@@ -54,10 +51,11 @@ private:
public:
// constructor & destructor
cIptvSectionFilter(int DeviceIndex, uint16_t Pid, uint8_t Tid, uint8_t Mask);
cIptvSectionFilter(int Index, int DeviceIndex, uint16_t Pid,
uint8_t Tid, uint8_t Mask);
virtual ~cIptvSectionFilter();
void Process(const uint8_t* Data);
int Read(void *Buffer, size_t Length);
int GetReadDesc(void);
uint16_t GetPid(void) const { return pid; }
};

532
setup.c
View File

@@ -5,6 +5,10 @@
*
*/
#include <string.h>
#include <vdr/device.h>
#include <vdr/interface.h>
#include <vdr/status.h>
#include <vdr/menu.h>
@@ -13,6 +17,521 @@
#include "device.h"
#include "setup.h"
// --- cIptvMenuEditChannel --------------------------------------------------
class cIptvMenuEditChannel : public cOsdMenu
{
private:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
struct tIptvChannel {
int frequency, source, protocol, parameter, vpid, ppid, vtype, tpid, sid, nid, tid, rid;
int apid[MAXAPIDS + 1], dpid[MAXDPIDS + 1], spid[MAXSPIDS + 1], caids[MAXCAIDS + 1];
int sidscan, pidscan;
char name[256], location[256];
} data;
cChannel *channel;
const char *protocols[eProtocolCount];
void Setup(void);
cString GetIptvSettings(const char *Param, int *Parameter, int *SidScan, int *PidScan, int *Protocol);
void GetChannelData(cChannel *Channel);
void SetChannelData(cChannel *Channel);
public:
cIptvMenuEditChannel(cChannel *Channel, bool New = false);
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
:cOsdMenu(trVDR("Edit channel"), 16)
{
protocols[eProtocolUDP] = tr("UDP");
protocols[eProtocolHTTP] = tr("HTTP");
protocols[eProtocolFILE] = tr("FILE");
protocols[eProtocolEXT] = tr("EXT");
channel = Channel;
GetChannelData(channel);
if (New) {
channel = NULL;
data.nid = 0;
data.tid = 0;
data.rid = 0;
}
Setup();
}
cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Parameter, int *SidScan, int *PidScan, int *Protocol)
{
char *tag = NULL;
char *proto = NULL;
char *loc = NULL;
if (sscanf(Param, "%a[^|]|S%dP%d|%a[^|]|%a[^|]|%d", &tag, SidScan, PidScan, &proto, &loc, Parameter) == 6) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = eProtocolUDP;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = eProtocolHTTP;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = eProtocolFILE;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = eProtocolEXT;
else
return NULL;
// return location
return locstr;
}
}
else if (sscanf(Param, "%a[^|]|P%dS%d|%a[^|]|%a[^|]|%d", &tag, PidScan, SidScan, &proto, &loc, Parameter) == 6) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = eProtocolUDP;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = eProtocolHTTP;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = eProtocolFILE;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = eProtocolEXT;
else
return NULL;
// return location
return locstr;
}
}
return NULL;
}
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
{
if (Channel) {
int parameter, protocol, sidscan, pidscan;
data.frequency = Channel->Frequency();
data.source = Channel->Source();
data.vpid = Channel->Vpid();
data.ppid = Channel->Ppid();
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
data.vtype = Channel->Vtype();
#endif
data.tpid = Channel->Tpid();
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
data.apid[i] = Channel->Apid(i);
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
data.dpid[i] = Channel->Dpid(i);
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
data.spid[i] = Channel->Spid(i);
for (unsigned int i = 0; i < ARRAY_SIZE(data.caids); ++i)
data.caids[i] = Channel->Ca(i);
data.sid = Channel->Sid();
data.nid = Channel->Nid();
data.tid = Channel->Tid();
data.rid = Channel->Rid();
strn0cpy(data.name, Channel->Name(), sizeof(data.name));
strn0cpy(data.location, *GetIptvSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol), sizeof(data.location));
data.sidscan = sidscan;
data.pidscan = pidscan;
data.protocol = protocol;
data.parameter = parameter;
}
else {
data.frequency = 1;
data.source = cSource::FromData(cSource::stPlug);
data.vpid = 0;
data.ppid = 0;
data.vtype = 0;
data.tpid = 0;
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
data.apid[i] = 0;
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
data.dpid[i] = 0;
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
data.spid[i] = 0;
for (unsigned int i = 0; i < ARRAY_SIZE(data.caids); ++i)
data.caids[i] = 0;
data.sid = 1;
data.nid = 0;
data.tid = 0;
data.rid = 0;
strn0cpy(data.name, "IPTV", sizeof(data.name));
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.sidscan = 0;
data.pidscan = 0;
data.protocol = eProtocolUDP;
data.parameter = 1234;
}
}
void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
{
if (Channel) {
cString param;
char alangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char dlangs[MAXDPIDS][MAXLANGCODE2] = { "" };
switch (data.protocol) {
case eProtocolEXT:
param = cString::sprintf("IPTV|S%dP%d|EXT|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
break;
case eProtocolFILE:
param = cString::sprintf("IPTV|S%dP%d|FILE|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
break;
case eProtocolHTTP:
param = cString::sprintf("IPTV|S%dP%d|HTTP|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
break;
default:
case eProtocolUDP:
param = cString::sprintf("IPTV|S%dP%d|UDP|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
break;
}
char slangs[MAXSPIDS][MAXLANGCODE2] = { "" };
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
Channel->SetPids(data.vpid, data.ppid, data.vtype, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
#else
Channel->SetPids(data.vpid, data.ppid, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
#endif
Channel->SetCaIds(data.caids);
Channel->SetId(data.nid, data.tid, data.sid, data.rid);
Channel->SetName(data.name, "", "IPTV");
Channel->SetPlugTransponderData(cSource::stPlug, data.frequency, param);
}
}
void cIptvMenuEditChannel::Setup(void)
{
int current = Current();
Clear();
// IPTV specific settings
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol,
eProtocolCount, protocols));
switch (data.protocol) {
case eProtocolFILE:
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location)));
Add(new cMenuEditIntItem(tr("Delay (ms)"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolEXT:
Add(new cMenuEditStrItem(tr("Script"), data.location, sizeof(data.location)));
Add(new cMenuEditIntItem(tr("Parameter"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolHTTP:
case eProtocolUDP:
default:
Add(new cMenuEditStrItem(tr("Address"), data.location, sizeof(data.location)));
Add(new cMenuEditIntItem(tr("Port"), &data.parameter, 0, 0xFFFF));
break;
}
cOsdItem *sidScanItem = new cMenuEditBoolItem(tr("Scan Sid"), &data.sidscan);
if (!IptvConfig.GetSectionFiltering())
sidScanItem->SetSelectable(false);
Add(sidScanItem);
Add(new cMenuEditBoolItem(tr("Scan pids"), &data.pidscan));
// Normal settings
Add(new cMenuEditStrItem(trVDR("Name"), data.name, sizeof(data.name)));
Add(new cMenuEditIntItem(trVDR("Frequency"), &data.frequency));
Add(new cMenuEditIntItem(trVDR("Vpid"), &data.vpid, 0, 0x1FFF));
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
Add(new cMenuEditIntItem(tr ("Vtype"), &data.vtype, 0, 0xFF));
#endif
Add(new cMenuEditIntItem(trVDR("Ppid"), &data.ppid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid1"), &data.apid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid2"), &data.apid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid1"), &data.dpid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid2"), &data.dpid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Spid1"), &data.spid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Spid2"), &data.spid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Tpid"), &data.tpid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("CA"), &data.caids[0], 0, 0xFFFF));
Add(new cMenuEditIntItem(trVDR("Sid"), &data.sid, 1, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Nid"), &data.nid, 0, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Tid"), &data.tid, 0, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Rid"), &data.rid, 0, 0x1FFF));
SetCurrent(Get(current));
Display();
}
eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
{
int oldProtocol = data.protocol;
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
if (Key == kOk) {
cChannel newchannel;
SetChannelData(&newchannel);
bool uniquityFailed = false;
bool firstIncrement = true;
// Search for identical channels as these will be ignored by vdr
for (cChannel *iteratorChannel = Channels.First(); iteratorChannel;
iteratorChannel = Channels.Next(iteratorChannel)) {
// This is one of the channels cause the uniquity check to fail
if (!iteratorChannel->GroupSep() && iteratorChannel != channel &&
iteratorChannel->GetChannelID() == newchannel.GetChannelID()) {
// See if it has unique Plugin param. If yes then increment
// the corresponding Rid until it is unique
if (strcmp(iteratorChannel->PluginParam(),
newchannel.PluginParam())) {
// If the channel RID is already at maximum, then fail the
// channel modification
if (iteratorChannel->Rid() >= 0x1FFF) {
debug("Cannot increment RID over maximum value\n");
uniquityFailed = true;
break;
}
debug("Incrementing conflicting channel RID\n");
iteratorChannel->SetId(iteratorChannel->Nid(),
iteratorChannel->Tid(),
iteratorChannel->Sid(),
firstIncrement ?
0 : iteratorChannel->Rid() + 1);
// Try zero Rid:s at first increment. Prevents them from
// creeping slowly towards their maximum value
firstIncrement = false;
// Re-set the search and start again
iteratorChannel = Channels.First();
continue;
// Cannot work around by incrementing rid because channels
// are actually copies of each other
}
else {
uniquityFailed = true;
break;
}
}
}
if (!uniquityFailed) {
if (channel) {
SetChannelData(channel);
isyslog("edited channel %d %s", channel->Number(), *channel->ToText());
state = osBack;
}
else {
channel = new cChannel;
SetChannelData(channel);
Channels.Add(channel);
Channels.ReNumber();
isyslog("added channel %d %s", channel->Number(), *channel->ToText());
state = osUser1;
}
Channels.SetModified(true);
}
else {
Skins.Message(mtError, tr("Cannot find unique channel settings!"));
state = osContinue;
}
}
}
if ((Key != kNone) && (data.protocol != oldProtocol)) {
switch (data.protocol) {
case eProtocolEXT:
strn0cpy(data.location, "iptvstream.sh", sizeof(data.location));
data.parameter = 0;
break;
case eProtocolFILE:
strn0cpy(data.location, "/video/stream.ts", sizeof(data.location));
data.parameter = 0;
break;
case eProtocolHTTP:
strn0cpy(data.location, "127.0.0.1/TS/1", sizeof(data.location));
data.parameter = 3000;
break;
default:
case eProtocolUDP:
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.parameter = 1234;
break;
}
Setup();
}
return state;
}
// --- cIptvMenuChannelItem --------------------------------------------------
class cIptvMenuChannelItem : public cOsdItem
{
private:
cChannel *channel;
public:
cIptvMenuChannelItem(cChannel *Channel);
virtual void Set(void);
cChannel *Channel(void) { return channel; }
};
cIptvMenuChannelItem::cIptvMenuChannelItem(cChannel *Channel)
{
channel = Channel;
Set();
}
void cIptvMenuChannelItem::Set(void)
{
SetText(cString::sprintf("%d\t%s", channel->Number(), channel->Name()));
}
// --- cIptvMenuChannels -----------------------------------------------------
class cIptvMenuChannels : public cOsdMenu
{
private:
void Setup(void);
cChannel *GetChannel(int Index) const;
void Propagate(void);
protected:
eOSState Edit(void);
eOSState New(void);
eOSState Delete(void);
eOSState Switch(void);
public:
cIptvMenuChannels();
~cIptvMenuChannels();
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuChannels::cIptvMenuChannels(void)
:cOsdMenu(tr("IPTV Channels"), numdigits(Channels.MaxNumber()) + 1)
{
Setup();
Channels.IncBeingEdited();
}
cIptvMenuChannels::~cIptvMenuChannels()
{
Channels.DecBeingEdited();
}
void cIptvMenuChannels::Setup(void)
{
Clear();
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() && channel->IsPlug() && !strncasecmp(channel->PluginParam(), "IPTV", 4)) {
cIptvMenuChannelItem *item = new cIptvMenuChannelItem(channel);
Add(item);
}
}
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
Display();
}
cChannel *cIptvMenuChannels::GetChannel(int Index) const
{
cIptvMenuChannelItem *p = dynamic_cast<cIptvMenuChannelItem *>(Get(Index));
return p ? (cChannel *)p->Channel() : NULL;
}
void cIptvMenuChannels::Propagate(void)
{
Channels.ReNumber();
for (cIptvMenuChannelItem *ci = dynamic_cast<cIptvMenuChannelItem *>(First()); ci; ci = dynamic_cast<cIptvMenuChannelItem *>(ci->Next()))
ci->Set();
Display();
Channels.SetModified(true);
}
eOSState cIptvMenuChannels::Switch(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cChannel *ch = GetChannel(Current());
if (ch)
return cDevice::PrimaryDevice()->SwitchChannel(ch, true) ? osEnd : osContinue;
return osEnd;
}
eOSState cIptvMenuChannels::Edit(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cChannel *ch = GetChannel(Current());
if (ch)
return AddSubMenu(new cIptvMenuEditChannel(ch));
return osContinue;
}
eOSState cIptvMenuChannels::New(void)
{
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuEditChannel(GetChannel(Current()), true));
}
eOSState cIptvMenuChannels::Delete(void)
{
if (!HasSubMenu() && Count() > 0) {
int CurrentChannelNr = cDevice::CurrentChannel();
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
int Index = Current();
cChannel *channel = GetChannel(Current());
int DeletedChannel = channel->Number();
// Check if there is a timer using this channel:
if (channel->HasTimer()) {
Skins.Message(mtError, trVDR("Channel is being used by a timer!"));
return osContinue;
}
if (Interface->Confirm(trVDR("Delete channel?"))) {
if (CurrentChannel && channel == CurrentChannel) {
int n = Channels.GetNextNormal(CurrentChannel->Index());
if (n < 0)
n = Channels.GetPrevNormal(CurrentChannel->Index());
CurrentChannel = Channels.Get(n);
CurrentChannelNr = 0; // triggers channel switch below
}
Channels.Del(channel);
cOsdMenu::Del(Index);
Propagate();
isyslog("channel %d deleted", DeletedChannel);
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
Channels.SwitchTo(CurrentChannel->Number());
else
cDevice::SetCurrentChannel(CurrentChannel);
}
}
}
return osContinue;
}
eOSState cIptvMenuChannels::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
switch (state) {
case osUser1: {
cChannel *channel = Channels.Last();
if (channel) {
Add(new cIptvMenuChannelItem(channel), true);
return CloseSubMenu();
}
}
break;
default:
if (state == osUnknown) {
switch (Key) {
case kOk: return Switch();
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Delete();
default: break;
}
}
}
return state;
}
// --- cIptvMenuInfo ---------------------------------------------------------
class cIptvMenuInfo : public cOsdMenu
@@ -66,7 +585,7 @@ void cIptvMenuInfo::Display(void)
eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
{
switch (int(Key)) {
switch (Key) {
case kUp|k_Repeat:
case kUp:
case kDown|k_Repeat:
@@ -124,7 +643,7 @@ cIptvPluginSetup::cIptvPluginSetup()
disabledFilterNames[i] = tr(section_filter_table[i].description);
}
Setup();
SetHelp(NULL, NULL, NULL, trVDR("Button$Info"));
SetHelp(trVDR("Channels"), NULL, NULL, trVDR("Button$Info"));
}
void cIptvPluginSetup::Setup(void)
@@ -161,6 +680,14 @@ void cIptvPluginSetup::Setup(void)
Display();
}
eOSState cIptvPluginSetup::EditChannel(void)
{
debug("cIptvPluginSetup::EditChannel()\n");
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuChannels());
}
eOSState cIptvPluginSetup::ShowInfo(void)
{
debug("cIptvPluginSetup::ShowInfo()\n");
@@ -177,6 +704,7 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
if (state == osUnknown) {
switch (Key) {
case kRed: return EditChannel();
case kBlue: return ShowInfo();
case kInfo: if (Current() < help.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()]));

48
setup.h
View File

@@ -9,55 +9,8 @@
#define __IPTV_SETUP_H
#include <vdr/menuitems.h>
#include <vdr/sourceparams.h>
#include "common.h"
class cIptvTransponderParameters
{
friend class cIptvSourceParam;
private:
int sidscan;
int pidscan;
int protocol;
char address[MaxFileName];
int parameter;
public:
cIptvTransponderParameters(const char *Parameters = NULL);
int SidScan(void) const { return sidscan; }
int PidScan(void) const { return pidscan; }
int Protocol(void) const { return protocol; }
const char *Address(void) const { return address; }
int Parameter(void) const { return parameter; }
void SetSidScan(int SidScan) { sidscan = SidScan; }
void SetPidScan(int PidScan) { pidscan = PidScan; }
void SetProtocol(int Protocol) { protocol = Protocol; }
void SetAddress(const char *Address) { strncpy(address, Address, sizeof(address)); }
void SetParameter(int Parameter) { parameter = Parameter; }
cString ToString(char Type) const;
bool Parse(const char *s);
};
class cIptvSourceParam : public cSourceParam
{
private:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
int param;
cChannel data;
cIptvTransponderParameters itp;
const char *protocols[eProtocolCount];
public:
cIptvSourceParam(char Source, const char *Description);
virtual void SetData(cChannel *Channel);
virtual void GetData(cChannel *Channel);
virtual cOsdItem *GetOsdItem(void);
};
class cIptvPluginSetup : public cMenuSetupPage
{
private:
@@ -70,6 +23,7 @@ private:
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
cVector<const char*> help;
eOSState EditChannel(void);
eOSState ShowInfo(void);
void Setup(void);
void StoreFilters(const char *Name, int *Values);

View File

@@ -11,19 +11,10 @@
#include "sidscanner.h"
cSidScanner::cSidScanner(void)
: channelId(tChannelID::InvalidID),
sidFound(false),
nidFound(false),
tidFound(false)
{
debug("cSidScanner::cSidScanner()\n");
channel = cChannel();
Set(0x00, 0x00); // PAT
Set(0x10, 0x40); // NIT
}
cSidScanner::~cSidScanner()
{
debug("cSidScanner::~cSidScanner()\n");
}
void cSidScanner::SetStatus(bool On)
@@ -32,70 +23,43 @@ void cSidScanner::SetStatus(bool On)
cFilter::SetStatus(On);
}
void cSidScanner::SetChannel(const tChannelID &ChannelId)
void cSidScanner::SetChannel(const cChannel *Channel)
{
debug("cSidScanner::SetChannel(): %s\n", *ChannelId.ToString());
channelId = ChannelId;
sidFound = false;
nidFound = false;
tidFound = false;
if (Channel) {
debug("cSidScanner::SetChannel(): %s\n", Channel->PluginParam());
channel = *Channel;
}
else {
debug("cSidScanner::SetChannel()\n");
channel = cChannel();
}
}
void cSidScanner::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
{
int newSid = -1, newNid = -1, newTid = -1;
//debug("cSidScanner::Process()\n");
if (channelId.Valid()) {
if ((Pid == 0x00) && (Tid == 0x00)) {
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
SI::PAT pat(Data, false);
if (!pat.CheckCRCAndParse())
return;
SI::PAT::Association assoc;
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channelId.Sid()) {
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
newSid = assoc.getServiceId();
}
sidFound = true;
break;
}
}
}
else if ((Pid == 0x10) && (Tid == 0x40)) {
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
SI::NIT nit(Data, false);
if (!nit.CheckCRCAndParse())
return;
SI::NIT::TransportStream ts;
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
if (ts.getTransportStreamId() != channelId.Tid()) {
debug("cSidScanner::Process(): TSid=%d\n", ts.getTransportStreamId());
newTid = ts.getTransportStreamId();
}
tidFound = true;
break; // default to the first one
}
if (nit.getNetworkId() != channelId.Nid()) {
debug("cSidScanner::Process(): Nid=%d\n", ts.getTransportStreamId());
newNid = nit.getNetworkId();
}
nidFound = true;
}
}
if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) {
if (!Channels.Lock(true, 10))
if ((Pid == 0x00) && (Tid == 0x00) && channel.GetChannelID().Valid()) {
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
SI::PAT pat(Data, false);
if (!pat.CheckCRCAndParse())
return;
cChannel *IptvChannel = Channels.GetByChannelID(channelId);
if (IptvChannel)
IptvChannel->SetId((newNid < 0) ? IptvChannel->Nid() : newNid, (newTid < 0) ? IptvChannel->Tid() : newTid,
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
Channels.Unlock();
}
if (sidFound && nidFound && tidFound) {
SetChannel(tChannelID::InvalidID);
SetStatus(false);
SI::PAT::Association assoc;
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channel.Sid()) {
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
if (!Channels.Lock(true, 10))
return;
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
if (IptvChannel)
IptvChannel->SetId(IptvChannel->Nid(), IptvChannel->Tid(),
assoc.getServiceId(), IptvChannel->Rid());
Channels.Unlock();
}
SetChannel(NULL);
SetStatus(false);
return;
}
}
}
}

View File

@@ -13,10 +13,7 @@
class cSidScanner : public cFilter {
private:
tChannelID channelId;
bool sidFound;
bool nidFound;
bool tidFound;
cChannel channel;
protected:
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
@@ -24,8 +21,7 @@ protected:
public:
cSidScanner(void);
~cSidScanner();
void SetChannel(const tChannelID &ChannelId);
void SetChannel(const cChannel *Channel);
void Open() { SetStatus(true); }
void Close() { SetStatus(false); }
};

318
socket.c
View File

@@ -7,7 +7,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
@@ -24,7 +23,6 @@ cIptvSocket::cIptvSocket()
isActive(false)
{
debug("cIptvSocket::cIptvSocket()\n");
memset(&sockAddr, '\0', sizeof(sockAddr));
}
cIptvSocket::~cIptvSocket()
@@ -53,18 +51,13 @@ bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
// Make it use non-blocking I/O to avoid stuck read calls
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()",
CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)",
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt()",
CloseSocket(), return false);
#ifndef __FreeBSD__
// Allow packet information to be fetched
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)",
CloseSocket(), return false);
#endif // __FreeBSD__
// Bind socket
memset(&sockAddr, 0, sizeof(sockAddr));
memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons((uint16_t)(Port & 0xFFFF));
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -85,38 +78,11 @@ void cIptvSocket::CloseSocket(void)
if (socketDesc >= 0) {
close(socketDesc);
socketDesc = -1;
socketPort = 0;
memset(&sockAddr, 0, sizeof(sockAddr));
}
}
bool cIptvSocket::CheckAddress(const char *Addr, in_addr_t *InAddr)
{
if (InAddr) {
// First try only the IP address
*InAddr = htonl(inet_addr(Addr));
if (*InAddr == htonl(INADDR_NONE)) {
debug("Cannot convert %s directly to internet address\n", Addr);
// It may be a host name, get the name
struct hostent *host;
host = gethostbyname(Addr);
if (!host) {
char tmp[64];
error("gethostbyname() failed: %s is not valid address: %s", Addr, strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
*InAddr = htonl(inet_addr(*host->h_addr_list));
}
return true;
}
return false;
}
// UDP socket class
cIptvUdpSocket::cIptvUdpSocket()
: streamAddr(htonl(INADDR_ANY)),
sourceAddr(htonl(INADDR_ANY)),
useIGMPv3(false)
{
debug("cIptvUdpSocket::cIptvUdpSocket()\n");
}
@@ -129,99 +95,9 @@ cIptvUdpSocket::~cIptvUdpSocket()
bool cIptvUdpSocket::OpenSocket(const int Port)
{
debug("cIptvUdpSocket::OpenSocket()\n");
streamAddr = htonl(INADDR_ANY);
sourceAddr = htonl(INADDR_ANY);
useIGMPv3 = false;
return cIptvSocket::OpenSocket(Port, true);
}
bool cIptvUdpSocket::OpenSocket(const int Port, const char *StreamAddr, const char *SourceAddr, bool UseIGMPv3)
{
debug("cIptvUdpSocket::OpenSocket()\n");
CheckAddress(StreamAddr, &streamAddr);
CheckAddress(SourceAddr, &sourceAddr);
useIGMPv3 = UseIGMPv3;
return cIptvSocket::OpenSocket(Port, true);
}
void cIptvUdpSocket::CloseSocket(void)
{
debug("cIptvUdpSocket::CloseSocket()\n");
streamAddr = htonl(INADDR_ANY);
sourceAddr = htonl(INADDR_ANY);
useIGMPv3 = false;
cIptvSocket::CloseSocket();
}
bool cIptvUdpSocket::JoinMulticast(void)
{
debug("cIptvUdpSocket::JoinMulticast()\n");
// Check if socket exists
if (!isActive && (socketDesc >= 0)) {
// Join a new multicast group
if (useIGMPv3) {
// Source-specific multicast (SSM) is used
struct group_source_req gsr;
struct sockaddr_in *grp;
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = streamAddr;
grp->sin_port = 0;
src = (struct sockaddr_in*)&gsr.gsr_source;
src->sin_family = AF_INET;
src->sin_addr.s_addr = sourceAddr;
src->sin_port = 0;
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_JOIN_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddr;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
}
// Update multicasting flag
isActive = true;
}
return true;
}
bool cIptvUdpSocket::DropMulticast(void)
{
debug("cIptvUdpSocket::DropMulticast()\n");
// Check if socket exists
if (isActive && (socketDesc >= 0)) {
// Drop the existing multicast group
if (useIGMPv3) {
// Source-specific multicast (SSM) is used
struct group_source_req gsr;
struct sockaddr_in *grp;
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = streamAddr;
grp->sin_port = 0;
src = (struct sockaddr_in*)&gsr.gsr_source;
src->sin_family = AF_INET;
src->sin_addr.s_addr = sourceAddr;
src->sin_port = 0;
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_LEAVE_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddr;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
}
// Update multicasting flag
isActive = false;
}
return true;
}
int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{
//debug("cIptvUdpSocket::Read()\n");
@@ -230,77 +106,43 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
error("Invalid socket in %s\n", __FUNCTION__);
return -1;
}
socklen_t addrlen = sizeof(sockAddr);
int len = 0;
// Read data from socket in a loop
do {
socklen_t addrlen = sizeof(sockAddr);
struct msghdr msgh;
struct iovec iov;
char cbuf[256];
len = 0;
// Initialize iov and msgh structures
memset(&msgh, 0, sizeof(struct msghdr));
iov.iov_base = BufferAddr;
iov.iov_len = BufferLen;
msgh.msg_control = cbuf;
msgh.msg_controllen = sizeof(cbuf);
msgh.msg_name = &sockAddr;
msgh.msg_namelen = addrlen;
msgh.msg_iov = &iov;
msgh.msg_iovlen = 1;
msgh.msg_flags = 0;
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
len = (int)recvmsg(socketDesc, &msgh, MSG_DONTWAIT);
else
break;
if (len > 0) {
#ifndef __FreeBSD__
// Process auxiliary received data and validate source address
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
if ((i->ipi_addr.s_addr == streamAddr) || (htonl(INADDR_ANY) == streamAddr)) {
#endif // __FreeBSD__
if (BufferAddr[0] == TS_SYNC_BYTE)
return len;
else if (len > 3) {
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
// version
unsigned int v = (BufferAddr[0] >> 6) & 0x03;
// extension bit
unsigned int x = (BufferAddr[0] >> 4) & 0x01;
// cscr count
unsigned int cc = BufferAddr[0] & 0x0F;
// payload type: MPEG2 TS = 33
//unsigned int pt = readBuffer[1] & 0x7F;
// header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// check if extension
if (x) {
// extension header length
unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
(BufferAddr[headerlen + 3] & 0xFF));
// update header length
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
}
// Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
(BufferAddr[headerlen] == TS_SYNC_BYTE)) {
// Set argument point to payload in read buffer
memmove(BufferAddr, &BufferAddr[headerlen], (len - headerlen));
return (len - headerlen);
}
}
#ifndef __FreeBSD__
}
}
}
#endif // __FreeBSD__
}
} while (len > 0);
ERROR_IF_RET(len < 0 && errno != EAGAIN, "recvmsg()", return -1);
// Read data from socket
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
if ((len > 0) && (BufferAddr[0] == TS_SYNC_BYTE)) {
return len;
}
else if (len > 3) {
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
// version
unsigned int v = (BufferAddr[0] >> 6) & 0x03;
// extension bit
unsigned int x = (BufferAddr[0] >> 4) & 0x01;
// cscr count
unsigned int cc = BufferAddr[0] & 0x0F;
// payload type: MPEG2 TS = 33
//unsigned int pt = readBuffer[1] & 0x7F;
// header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// check if extension
if (x) {
// extension header length
unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
(BufferAddr[headerlen + 3] & 0xFF));
// update header length
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
}
// Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
(BufferAddr[headerlen] == TS_SYNC_BYTE)) {
// Set argument point to payload in read buffer
memmove(BufferAddr, &BufferAddr[headerlen], (len - headerlen));
return (len - headerlen);
}
}
return 0;
}
@@ -315,43 +157,10 @@ cIptvTcpSocket::~cIptvTcpSocket()
debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
}
bool cIptvTcpSocket::OpenSocket(const int Port, const char *StreamAddr)
bool cIptvTcpSocket::OpenSocket(const int Port)
{
debug("cIptvTcpSocket::OpenSocket()\n");
// Socket must be opened before setting the host address
return (cIptvSocket::OpenSocket(Port, false) && CheckAddress(StreamAddr, &sockAddr.sin_addr.s_addr));
}
void cIptvTcpSocket::CloseSocket(void)
{
debug("cIptvTcpSocket::CloseSocket()\n");
cIptvSocket::CloseSocket();
}
bool cIptvTcpSocket::ConnectSocket(void)
{
debug("cIptvTcpSocket::ConnectSocket()\n");
if (!isActive && (socketDesc >= 0)) {
int retval = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected
ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false);
// Select with 800ms timeout on the socket completion, check if it is writable
retval = select_single_desc(socketDesc, 800000, true);
if (retval < 0)
return retval;
// Select has returned. Get socket errors if there are any
retval = 0;
socklen_t len = sizeof(retval);
getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &retval, &len);
// If not any errors, then socket must be ready and connected
if (retval != 0) {
char tmp[64];
error("Connect() failed: %s", strerror_r(retval, tmp, sizeof(tmp)));
return false;
}
}
return true;
return cIptvSocket::OpenSocket(Port, false);
}
int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
@@ -362,49 +171,10 @@ int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
error("Invalid socket in %s\n", __FUNCTION__);
return -1;
}
int len = 0;
socklen_t addrlen = sizeof(sockAddr);
// Read data from socket
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
return len;
}
bool cIptvTcpSocket::ReadChar(char* BufferAddr, unsigned int TimeoutMs)
{
//debug("cIptvTcpSocket::ReadChar()\n");
// Error out if socket not initialized
if (socketDesc <= 0) {
error("Invalid socket in %s\n", __FUNCTION__);
return false;
}
socklen_t addrlen = sizeof(sockAddr);
// Wait 500ms for data
int retval = select_single_desc(socketDesc, 1000 * TimeoutMs, false);
// Check if error
if (retval < 0)
return false;
// Check if data available
else if (retval) {
retval = (int)recvfrom(socketDesc, BufferAddr, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
if (retval <= 0)
return false;
}
return true;
}
bool cIptvTcpSocket::Write(const char* BufferAddr, unsigned int BufferLen)
{
//debug("cIptvTcpSocket::Write()\n");
// Error out if socket not initialized
if (socketDesc <= 0) {
error("Invalid socket in %s\n", __FUNCTION__);
return false;
}
ERROR_IF_RET(send(socketDesc, BufferAddr, BufferLen, 0) < 0, "send()", return false);
return true;
return (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
return 0;
}

View File

@@ -9,15 +9,10 @@
#define __IPTV_SOCKET_H
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif // __FreeBSD__
class cIptvSocket {
private:
int socketPort;
protected:
int socketPort;
int socketDesc;
struct sockaddr_in sockAddr;
bool isActive;
@@ -25,7 +20,6 @@ protected:
protected:
bool OpenSocket(const int Port, const bool isUdp);
void CloseSocket(void);
bool CheckAddress(const char *Addr, in_addr_t *InAddr);
public:
cIptvSocket();
@@ -33,20 +27,11 @@ public:
};
class cIptvUdpSocket : public cIptvSocket {
private:
in_addr_t streamAddr;
in_addr_t sourceAddr;
bool useIGMPv3;
public:
cIptvUdpSocket();
virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool OpenSocket(const int Port);
bool OpenSocket(const int Port, const char *StreamAddr, const char *SourceAddr, bool UseIGMPv3);
void CloseSocket(void);
bool JoinMulticast(void);
bool DropMulticast(void);
};
class cIptvTcpSocket : public cIptvSocket {
@@ -54,11 +39,7 @@ public:
cIptvTcpSocket();
virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool OpenSocket(const int Port, const char *StreamAddr);
void CloseSocket(void);
bool ConnectSocket(void);
bool ReadChar(char* BufferAddr, unsigned int TimeoutMs);
bool Write(const char* BufferAddr, unsigned int BufferLen);
bool OpenSocket(const int Port);
};
#endif // __IPTV_SOCKET_H

176
source.c
View File

@@ -1,176 +0,0 @@
/*
* source.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include "common.h"
#include "source.h"
// --- cIptvTransponderParameters --------------------------------------------
cIptvTransponderParameters::cIptvTransponderParameters(const char *Parameters)
: sidscan(0),
pidscan(0),
protocol(eProtocolUDP),
parameter(0)
{
debug("cIptvTransponderParameters::cIptvTransponderParameters(): Parameters=%s\n", Parameters);
memset(&address, 0, sizeof(address));
Parse(Parameters);
}
cString cIptvTransponderParameters::ToString(char Type) const
{
debug("cIptvTransponderParameters::ToString() Type=%c\n", Type);
const char *protocolstr;
switch (protocol) {
case eProtocolEXT:
protocolstr = "EXT";
break;
case eProtocolHTTP:
protocolstr = "HTTP";
break;
case eProtocolFILE:
protocolstr = "FILE";
break;
default:
case eProtocolUDP:
protocolstr = "UDP";
break;
}
return cString::sprintf("S=%d|P=%d|F=%s|U=%s|A=%d", sidscan, pidscan, protocolstr, address, parameter);
}
bool cIptvTransponderParameters::Parse(const char *s)
{
debug("cIptvTransponderParameters::Parse(): s=%s\n", s);
bool result = false;
if (s && *s) {
const char *delim = "|";
char *str = strdup(s);
char *saveptr = NULL;
char *token = NULL;
bool found_s = false;
bool found_p = false;
bool found_f = false;
bool found_u = false;
bool found_a = false;
while ((token = strtok_r(str, delim, &saveptr)) != NULL) {
char *data = token;
++data;
if (data && (*data == '=')) {
++data;
switch (*token) {
case 'S':
sidscan = (int)strtol(data, (char **)NULL, 10);
found_s = true;
break;
case 'P':
pidscan = (int)strtol(data, (char **)NULL, 10);
found_p = true;
break;
case 'F':
if (strstr(data, "UDP")) {
protocol = eProtocolUDP;
found_f = true;
}
else if (strstr(data, "HTTP")) {
protocol = eProtocolHTTP;
found_f = true;
}
else if (strstr(data, "FILE")) {
protocol = eProtocolFILE;
found_f = true;
}
else if (strstr(data, "EXT")) {
protocol = eProtocolEXT;
found_f = true;
}
break;
case 'U':
strn0cpy(address, data, sizeof(address));
found_u = true;
break;
case 'A':
parameter = (int)strtol(data, (char **)NULL, 10);
found_a = true;
break;
default:
break;
}
}
str = NULL;
}
if (found_s && found_p && found_f && found_u && found_a)
result = true;
else
error("Invalid channel parameters: %s\n", str);
free(str);
}
return (result);
}
// --- cIptvSourceParam ------------------------------------------------------
cIptvSourceParam::cIptvSourceParam(char Source, const char *Description)
: cSourceParam(Source, Description),
param(0),
nid(0),
tid(0),
rid(0),
data(),
itp()
{
debug("cIptvSourceParam::cIptvSourceParam(): Source=%c Description=%s\n", Source, Description);
protocols[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
protocols[cIptvTransponderParameters::eProtocolHTTP] = tr("HTTP");
protocols[cIptvTransponderParameters::eProtocolFILE] = tr("FILE");
protocols[cIptvTransponderParameters::eProtocolEXT] = tr("EXT");
}
void cIptvSourceParam::SetData(cChannel *Channel)
{
debug("cIptvSourceParam::SetData(): Channel=%s)\n", Channel->Parameters());
data = *Channel;
nid = data.Nid();
tid = data.Tid();
rid = data.Rid();
itp.Parse(data.Parameters());
param = 0;
}
void cIptvSourceParam::GetData(cChannel *Channel)
{
debug("cIptvSourceParam::GetData(): Channel=%s\n", Channel->Parameters());
data.SetTransponderData(Channel->Source(), Channel->Frequency(), data.Srate(), itp.ToString(Source()), true);
data.SetId(nid, tid, Channel->Sid(), rid);
*Channel = data;
}
cOsdItem *cIptvSourceParam::GetOsdItem(void)
{
debug("cIptvSourceParam::GetOsdItem()\n");
switch (param++) {
case 0: return new cMenuEditIntItem( tr("Nid"), &nid, 0);
case 1: return new cMenuEditIntItem( tr("Tid"), &tid, 0);
case 2: return new cMenuEditIntItem( tr("Rid"), &rid, 0);
case 3: return new cMenuEditBoolItem(tr("Scan section ids"), &itp.sidscan);
case 4: return new cMenuEditBoolItem(tr("Scan pids"), &itp.pidscan);
case 5: return new cMenuEditStraItem(tr("Protocol"), &itp.protocol, ELEMENTS(protocols), protocols);
case 6: return new cMenuEditStrItem( tr("Address"), itp.address, sizeof(itp.address));
case 7: return new cMenuEditIntItem( tr("Parameter"), &itp.parameter, 0, 0xFFFF);
default: return NULL;
}
return NULL;
}

View File

@@ -1,67 +0,0 @@
/*
* source.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_SOURCE_H
#define __IPTV_SOURCE_H
#include <vdr/menuitems.h>
#include <vdr/sourceparams.h>
#include "common.h"
class cIptvTransponderParameters
{
friend class cIptvSourceParam;
private:
int sidscan;
int pidscan;
int protocol;
char address[MaxFileName];
int parameter;
public:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
cIptvTransponderParameters(const char *Parameters = NULL);
int SidScan(void) const { return sidscan; }
int PidScan(void) const { return pidscan; }
int Protocol(void) const { return protocol; }
const char *Address(void) const { return address; }
int Parameter(void) const { return parameter; }
void SetSidScan(int SidScan) { sidscan = SidScan; }
void SetPidScan(int PidScan) { pidscan = PidScan; }
void SetProtocol(int Protocol) { protocol = Protocol; }
void SetAddress(const char *Address) { strncpy(address, Address, sizeof(address)); }
void SetParameter(int Parameter) { parameter = Parameter; }
cString ToString(char Type) const;
bool Parse(const char *s);
};
class cIptvSourceParam : public cSourceParam
{
private:
int param;
int nid;
int tid;
int rid;
cChannel data;
cIptvTransponderParameters itp;
const char *protocols[cIptvTransponderParameters::eProtocolCount];
public:
cIptvSourceParam(char Source, const char *Description);
virtual void SetData(cChannel *Channel);
virtual void GetData(cChannel *Channel);
virtual cOsdItem *GetOsdItem(void);
};
#endif // __IPTV_SOURCE_H

View File

@@ -148,7 +148,7 @@ cString cIptvStreamerStatistics::GetStreamerStatistic()
long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes())
bitrate *= 8;
cString info = cString::sprintf("%ld k%s/s", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
cString info = cString::sprintf("Stream bitrate: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
dataBytes = 0;
return info;
}
@@ -164,7 +164,6 @@ void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
// Buffer statistic class
cIptvBufferStatistics::cIptvBufferStatistics()
: dataBytes(0),
freeSpace(0),
usedSpace(0),
timer(),
mutex()

View File

@@ -108,8 +108,8 @@ bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Ind
cString cIptvStreamer::GetInformation(void)
{
//debug("cIptvStreamer::GetInformation()");
cString info;
cString info("Stream:");
if (protocol)
info = protocol->GetInformation();
return info;
info = cString::sprintf("%s %s", *info, *protocol->GetInformation());
return cString::sprintf("%s\n", *info);
}