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

Compare commits

...

54 Commits

Author SHA1 Message Date
Rolf Ahrenberg
f7369c9578 Silence a compiling warning. 2020-01-03 23:36:58 +02:00
Rolf Ahrenberg
876d0d954e Updated README. 2019-10-27 16:57:31 +02:00
Rolf Ahrenberg
5ae793f030 Updated for vdr-2.4.0. 2018-04-15 22:27:15 +03:00
Rolf Ahrenberg
0fe1cb7ab5 Updated for vdr-2.3.7. 2017-06-24 23:20:33 +03:00
Rolf Ahrenberg
08cecd5eba Merge pull request #4 from tmn505/polish_language
Add polish language
2017-02-28 21:53:04 +02:00
Tomasz Maciej Nowak
22beb1662f Add polish language 2017-02-28 16:34:56 +01:00
Frank Neumann
ce8680cbc9 Add Catalan and Espanol translations. 2017-02-11 19:35:17 +02:00
Rolf Ahrenberg
0d2f32dc6a Use 2MB ringbuffer per device. 2016-05-12 23:51:03 +03:00
Rolf Ahrenberg
201b50eb9d C++11 requires a mandatory space when concatenating string literals. 2016-02-07 13:41:37 +02:00
Rolf Ahrenberg
777be25375 Update README. 2016-01-31 20:22:16 +02:00
Rolf Ahrenberg
ccc9bab5e0 Updated for vdr-2.3.1. 2015-09-19 17:20:56 +03:00
Rolf Ahrenberg
03a1e33e2f Prepared for a release. 2015-04-04 14:13:22 +03:00
Rolf Ahrenberg
130e2d09d0 Got rid of IPTV_DEBUG. 2015-03-08 15:47:12 +02:00
Rolf Ahrenberg
bc6da9dd63 Added support for tracing modes. 2015-03-08 15:40:27 +02:00
Rolf Ahrenberg
63359e4c24 Fixed CURL timeout and added a stale connection detection (Thanks to Daniel Ribeiro). 2015-02-24 20:30:43 +02:00
Rolf Ahrenberg
e9c8b8d4e0 Updated the APIVERSNUM requirement. 2015-02-20 20:43:19 +02:00
Rolf Ahrenberg
f5fcb6df2a Updated version number. 2015-02-15 22:13:45 +02:00
Rolf Ahrenberg
67050306c5 Reworded setup menu items. 2015-02-15 20:15:38 +02:00
Rolf Ahrenberg
a1aba865ed Updated translation file headers. 2015-02-12 23:43:10 +02:00
Rolf Ahrenberg
b8cb4188d2 Merge pull request #2 from varaslt/master
Added lithuanian translation file
2015-02-12 23:38:32 +02:00
Valdemaras Pipiras
1a93fec590 Added lithuanian translation file 2015-02-12 23:16:30 +02:00
Rolf Ahrenberg
4f980e5cd9 Updated German translations (Thanks to Frank Neumann). 2015-02-12 22:17:04 +02:00
Antti Seppälä
68d7183fa9 Fix IPTV Makefile dependency
Every *.c file should depend on Makefile changes as it contians parameters for entire plugin build.
2015-01-02 14:29:44 +02:00
Rolf Ahrenberg
54a990ffe8 Updated HISTORY. 2014-05-10 15:53:36 +03:00
Rolf Ahrenberg
53c2026a60 Added RTP packet error detection. 2014-04-05 19:11:30 +03:00
Rolf Ahrenberg
dc9f9f2b86 Removed unnecessary TS buffer settings. 2014-04-05 19:01:36 +03:00
Rolf Ahrenberg
688c7db1fc Refactored the section filtering. 2014-04-05 18:43:23 +03:00
Rolf Ahrenberg
591fb8431b Updated the section filtering options. 2014-04-05 18:29:45 +03:00
Rolf Ahrenberg
dab869cf3a Updated for vdr-2.1.6. 2014-03-16 16:46:21 +02:00
Rolf Ahrenberg
aaca7cba1a Fixed installation target bugs (Thanks to Alexander Grothe). 2014-03-09 16:04:54 +02:00
Rolf Ahrenberg
935f659e34 Added missing RTSP/UDP support. 2014-02-19 23:17:20 +02:00
Rolf Ahrenberg
9839b47229 Added SetPid() into cIptvProtocolIf(). 2014-02-09 19:22:02 +02:00
Rolf Ahrenberg
57e0af0ade Disabled missing internal cam. 2014-02-07 00:16:37 +02:00
Rolf Ahrenberg
0900e229cf Added initial CAM support. 2014-01-28 17:10:11 +02:00
Rolf Ahrenberg
3dcbff0a71 Updated translation files and version number. 2014-01-19 00:20:08 +02:00
Rolf Ahrenberg
5aefd40d65 Updated translation files and HISTORY. 2014-01-14 18:42:06 +02:00
Rolf Ahrenberg
6b0337d078 Added initial support for cDevice::MaySwitchTransponder(). 2014-01-14 18:40:54 +02:00
Rolf Ahrenberg
9e6d784aec Shutdown devices already in cPluginManager::Stop(). 2014-01-14 18:30:14 +02:00
Rolf Ahrenberg
3f3ba2ad1a Fixed a typo. 2014-01-11 00:35:12 +02:00
Rolf Ahrenberg
a4b9570ae6 Updated copyright headers. 2014-01-11 00:24:31 +02:00
Rolf Ahrenberg
767b1bdac7 Added support for cDevice::GetCurrentlyTunedTransponder(). 2014-01-10 23:59:26 +02:00
Rolf Ahrenberg
6f648401a4 Updated translation files and HISTORY. 2014-01-10 23:22:15 +02:00
Rolf Ahrenberg
b0995c9a9e Added support for cDevice::IsTunedToTransponder(). 2014-01-07 22:24:39 +02:00
Rolf Ahrenberg
412af81271 Fixed a mem leak and re-ordered pointer deletions. 2014-01-07 17:55:13 +02:00
Rolf Ahrenberg
43326bb4ea Whitespace cleanup. 2014-01-07 17:55:08 +02:00
Rolf Ahrenberg
555c08bd4d Updated Makefile. 2014-01-06 22:01:55 +02:00
Rolf Ahrenberg
5ad3103626 Fixed scan-build issues. 2014-01-02 21:47:43 +02:00
Rolf Ahrenberg
a4f0bdf737 Added missing CURL timeouts and improved section id scanner. 2014-01-02 21:35:38 +02:00
Rolf Ahrenberg
01b554a2de Updated README. 2013-04-01 23:11:38 +03:00
Rolf Ahrenberg
225b0cc297 Updated for vdr-2.0.0. 2013-04-01 22:36:41 +03:00
Rolf Ahrenberg
d940e616e3 Fixed and refactored the section filtering code, fixed a possible crash in the file protocol, and updated Makefile's install target. 2013-03-27 22:13:15 +02:00
Rolf Ahrenberg
f30817677e Fixed a nasty network byte order bug. 2013-03-17 01:18:58 +02:00
Rolf Ahrenberg
0c6257e4ca Added SetMenuCategory(mcSetupPlugins). 2013-03-13 23:33:37 +02:00
Rolf Ahrenberg
0caf746ef4 Enabled I/O throttling and tweaked buffer timeouts and tweaked max address string size to include a termination NULL byte. 2013-03-11 18:04:27 +02:00
49 changed files with 1975 additions and 1018 deletions

93
HISTORY
View File

@ -199,3 +199,96 @@ VDR Plugin 'iptv' Revision History
- Fixed bugs found in the CURL implementation (Thanks
to Jeremy Hall).
- Fixed the channel editor.
==================================
VDR Plugin 'iptv' Revision History
==================================
2013-04-01: Version 2.0.0
- Updated for vdr-2.0.0.
- Enabled I/O throttling and tweaked buffer timeouts.
- Fixed a nasty network byte order bug.
- Fixed and refactored the section filtering code.
- Fixed a possible crash in the file protocol.
2014-01-10: Version 2.0.1
- Added missing CURL timeouts.
- Improved section id scanner.
- Added support for cDevice::IsTunedToTransponder() and
cDevice::GetCurrentlyTunedTransponder().
- Fixed a memory leak and some issues reported by scan-build.
2014-01-18: Version 2.0.2
- Made devices to shutdown already in cPluginManager::Stop()
to prevent possible crashes while VDR shutdown.
2014-03-09: Version 2.0.3
- Fixed installation target bugs (Thanks to Alexander Grothe).
==================================
VDR Plugin 'iptv' Revision History
==================================
2014-02-20: Version 2.1.0
- Added initial CAM support.
- Added missing RTSP/UDP support.
2014-03-09: Version 2.1.1
- Fixed installation target bugs (Thanks to Alexander Grothe).
2014-03-16: Version 2.1.2
- Updated for vdr-2.1.6.
2014-05-10: Version 2.1.3
- Updated the section filtering options.
- Removed unnecessary TS buffer settings.
- Added RTP packet error detection.
==================================
VDR Plugin 'iptv' Revision History
==================================
2015-02-19: Version 2.2.0
- Updated for vdr-2.2.0.
- Updated German translations (Thanks to Frank Neumann).
- Updated Lithuanian translations (Thanks to Valdemaras
Pipiras).
2015-04-04: Version 2.2.1
- Fixed CURL timeout and added a stale connection
detection (Thanks to Daniel Ribeiro).
- Got rid of IPTV_DEBUG.
- Added support for tracing modes.
==================================
VDR Plugin 'iptv' Revision History
==================================
2017-06-24: Version 2.3.0
- Updated for vdr-2.3.7.
- Added Polish translation (Thanks to Tomasz Nowak).
- Added Catalan and Spanish translations (Thanks to Gabriel Bonich).
==================================
VDR Plugin 'iptv' Revision History
==================================
2018-04-15: Version 2.4.0
- Updated for vdr-2.4.0.

View File

@ -2,18 +2,10 @@
# Makefile for IPTV plugin
#
# 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
# 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.
@ -28,10 +20,12 @@ GITTAG = $(shell git describe --always 2>/dev/null)
### The directory environment:
# Use package data if installed...otherwise assume we're under the VDR source directory:
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --variable=$(1) vdr || pkg-config --variable=$(1) ../../../vdr.pc))
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr))
LIBDIR = $(call PKGCFG,libdir)
LOCDIR = $(call PKGCFG,locdir)
PLGCFG = $(call PKGCFG,plgcfg)
RESDIR = $(call PKGCFG,resdir)
CFGDIR = $(call PKGCFG,configdir)
#
TMPDIR ?= /tmp
@ -39,6 +33,7 @@ TMPDIR ?= /tmp
export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags)
STRIP ?= /bin/true
### The version number of VDR's plugin API:
@ -67,10 +62,6 @@ INCLUDES +=
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
ifdef IPTV_DEBUG
DEFINES += -DDEBUG
endif
ifdef IPTV_EXTSHELL
DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"'
endif
@ -95,15 +86,16 @@ all: $(SOFILE) i18n
### Implicit rules:
%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
%.o: %.c Makefile
@echo CC $@
$(Q)$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
### Dependencies:
MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
$(Q)$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
-include $(DEPFILE)
@ -116,17 +108,21 @@ I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLU
I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po
msgfmt -c -o $@ $<
@echo MO $@
$(Q)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 $^`
@echo GT $@
$(Q)xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ `ls $^`
%.po: $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
@echo PO $@
$(Q)msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
@touch $@
$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
install -D -m644 $< $@
@echo IN $@
$(Q)install -D -m644 $< $@
.PHONY: i18n
i18n: $(I18Nmo) $(I18Npot)
@ -136,15 +132,20 @@ install-i18n: $(I18Nmsgs)
### Targets:
$(SOFILE): $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
ifndef IPTV_DEBUG
@$(STRIP) $@
endif
@echo LD $@
$(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
$(Q)$(STRIP) $@
install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
@echo IN $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
$(Q)install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
install: install-lib install-i18n
install-conf:
@mkdir -p $(DESTDIR)$(CFGDIR)/plugins/$(PLUGIN)
@mkdir -p $(DESTDIR)$(RESDIR)/plugins/$(PLUGIN)
@cp -pn $(PLUGIN)/* $(DESTDIR)$(RESDIR)/plugins/$(PLUGIN)/
install: install-lib install-i18n install-conf
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@ -160,4 +161,4 @@ clean:
.PHONY: cppcheck
cppcheck:
@cppcheck --language=c++ --enable=all -v -f $(OBJS:%.o=%.c)
$(Q)cppcheck --language=c++ --enable=all -v -f $(OBJS:%.o=%.c)

69
README
View File

@ -29,40 +29,29 @@ filtering capabilities which allow for example EIT information to be
extracted from the incoming stream.
Currently the IPTV plugin has direct support for both multicast UDP/RTP
and unicast HTTP MPEG1/2 transport streams. Also a file input method is
supported, but a file delay must be selected individually to prevent
VDR's transfer buffer over/underflow. Therefore the file input should be
considered as a testing feature only.
and unicast HTTP MPEG1/2, H.264 and H.265 transport streams. Also a file
input method is supported, but a file delay must be selected individually
to prevent VDR's transfer buffer over/underflow. Therefore the file input
should be considered as a testing feature only.
IPTV plugin also features a support for external streaming applications.
With proper helper applications and configuration IPTV plugin is able to
display not only MPEG1/2 transport streams but also other formats like
MP3 radio streams, mms video streams and so on.
display not only MPEG1/2, H.264 and H.265 transport streams but also other
formats like MP3 radio streams, mms video streams and so on.
Installation:
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/
make
make plugins
./vdr -P iptv
make -C iptv-X.Y.Z install
Setup menu:
- TS buffer size [MB] = 2 Defines ringbuffer size for transport
stream in MB.
Valid range: 1...4
- TS buffer prefill ratio [%] = 0 Defines prefill ratio for transport
stream ringbuffer before data is
transferred to VDR.
Valid range: 0...40
- EXT protocol base port = 4321 Defines base port used in EXT protocol.
- Protocol base port = 4321 Defines base port used in CURL/EXT
protocol. Two ports are defined for
each device.
The port range is defined by the number
of IPTV devices (max. 8).
Valid range: 0...65527
of IPTV devices times two (max. 32).
Valid range: 0...65503
- Use section filtering = 1 Defines whether section filtering shall
be used.
Valid range: 0...1
@ -89,11 +78,11 @@ Configuration:
- channels.conf
TV4;IPTV:60:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:6:0:0:0
TV3;IPTV:50:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:5:0:0:0
TV2;IPTV:40:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:4:0:0:0
TV1;IPTV:30:S=1|P=0|F=CURL|U=http%3A//foo%3Abar@127.0.0.1%3A3000/TS/2|A=0:I:0:512:650:2321:0:3:0:0:0
TV1;IPTV:20:S=1|P=0|F=UDP|U=127.0.0.1@127.0.0.1|A=1234:I:0:512:650:2321:0:2:0:0:0
TV6;IPTV:60:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:6:0:0:0
TV5;IPTV:50:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:5:0:0:0
TV4;IPTV:40:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:4:0:0:0
TV3;IPTV:30:S=1|P=0|F=CURL|U=http%3A//foo%3Abar@127.0.0.1%3A3000/TS/2|A=0:I:0:512:650:2321:0:3:0:0:0
TV2;IPTV:20:S=1|P=0|F=UDP|U=127.0.0.1@127.0.0.1|A=1234:I:0:512:650:2321:0:2: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")
@ -133,11 +122,11 @@ External streaming:
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
plugin with MPEG2 TS data in UDP/RTP format to the listening port. The
data will be processed in VDR like a normal DVB broadcast. The listening
base port can be specified in the plugin configuration menu.
- When an EXT or CURL/RTSP channel is opened the IPTV plugin opens an UDP
listening port on the localhost. The external script is responsible for
supplying IPTV plugin with MPEG2 TS data in UDP/RTP format to the listening
port. The data will be processed in VDR like a normal DVB broadcast. The
listening base port can be specified in the plugin configuration menu.
- Each IPTV device has different listen port. The port number is specified
as a base port number plus IPTV device index minus one. Maximum of 8 IPTV
@ -171,8 +160,7 @@ Notes:
"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.
- EIT scanning functionality is disabled by default.
- Section id and pid scanners should be disabled after the correct data is
found. This can be made via VDR's channel editor.
@ -182,11 +170,16 @@ Notes:
IGMP v3 protocol:
"U=<source address>@<group address>"
- The CURL implementation supports only HTTP/HTTPS protocols and an optional
netrc configuration file for authentication:
- The CURL implementation supports only RTSP/HTTP/HTTPS protocols and an
optional netrc configuration file for authentication:
$(CONFDIR)/iptv/netrc
- CURL implementation
- You can quite easily figure out correct DVB triplet values by using the
multicat and dvbsnoop tools:
$ multicat -u -d 1620000000 @127.0.0.1:1234 /tmp/video.ts
$ dvbsnoop -s ts -if /tmp/video.ts -tssubdecode -hexdumpbuffer 0x12 | \
grep -m1 -A8 Service_ID | grep _ID
Acknowledgements:
- The IPTV section filtering code is derived from Linux kernel.

View File

@ -75,12 +75,10 @@ cString ChangeCase(const cString &strP, bool upperP)
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
{
/* description tag pid tid mask */
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
{trNOOP("EIT (0x4E/0x4F)"), "EIT", 0x12, 0x4E, 0xFE},
{trNOOP("EIT (0x5X)"), "EIT", 0x12, 0x50, 0xF0},
{trNOOP("EIT (0x6X)"), "EIT", 0x12, 0x60, 0xF0},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
/* description tag pid tid mask */
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
{trNOOP("EIT (0x4E/0x4F/0x5X/0x6X)"), "EIT", 0x12, 0x40, 0xC0},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
};

View File

@ -12,18 +12,10 @@
#include <vdr/config.h>
#include <vdr/i18n.h>
#ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x);
#define info(x...) isyslog("IPTV: " x);
#define error(x...) esyslog("ERROR: " x);
#else
#define debug(x...) ;
#define info(x...) isyslog("IPTV: " x);
#define error(x...) esyslog("ERROR: " x);
#endif
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define IPTV_BUFFER_SIZE KILOBYTE(2048)
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
#define IPTV_SOURCE_CHARACTER 'I'
@ -38,19 +30,19 @@
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
#define SECTION_FILTER_TABLE_SIZE 7
#define SECTION_FILTER_TABLE_SIZE 5
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
error(errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
esyslog("[%s,%d]: " errstr ": %s", __FILE__, __LINE__, \
strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
} while (0)
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );

View File

@ -5,20 +5,21 @@
*
*/
#include "log.h"
#include "config.h"
cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void)
: tsBufferSizeM(2),
tsBufferPrefillRatioM(0),
extProtocolBasePortM(4321),
: traceModeM(eTraceModeNormal),
protocolBasePortM(4321),
useBytesM(1),
sectionFilteringM(1)
{
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
disabledFiltersM[i] = -1;
memset(configDirectoryM, 0, sizeof(configDirectoryM));
memset(resourceDirectoryM, 0, sizeof(resourceDirectoryM));
}
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
@ -42,6 +43,12 @@ void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP)
void cIptvConfig::SetConfigDirectory(const char *directoryP)
{
debug("cIptvConfig::%s(%s)", __FUNCTION__, directoryP);
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
}
void cIptvConfig::SetResourceDirectory(const char *directoryP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory");
}

View File

@ -14,31 +14,52 @@
class cIptvConfig
{
private:
unsigned int tsBufferSizeM;
unsigned int tsBufferPrefillRatioM;
unsigned int extProtocolBasePortM;
unsigned int traceModeM;
unsigned int protocolBasePortM;
unsigned int useBytesM;
unsigned int sectionFilteringM;
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE];
char configDirectoryM[PATH_MAX];
char resourceDirectoryM[PATH_MAX];
public:
enum eTraceMode {
eTraceModeNormal = 0x0000,
eTraceModeDebug1 = 0x0001,
eTraceModeDebug2 = 0x0002,
eTraceModeDebug3 = 0x0004,
eTraceModeDebug4 = 0x0008,
eTraceModeDebug5 = 0x0010,
eTraceModeDebug6 = 0x0020,
eTraceModeDebug7 = 0x0040,
eTraceModeDebug8 = 0x0080,
eTraceModeDebug9 = 0x0100,
eTraceModeDebug10 = 0x0200,
eTraceModeDebug11 = 0x0400,
eTraceModeDebug12 = 0x0800,
eTraceModeDebug13 = 0x1000,
eTraceModeDebug14 = 0x2000,
eTraceModeDebug15 = 0x4000,
eTraceModeDebug16 = 0x8000,
eTraceModeMask = 0xFFFF
};
cIptvConfig();
unsigned int GetTsBufferSize(void) const { return tsBufferSizeM; }
unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatioM; }
unsigned int GetExtProtocolBasePort(void) const { return extProtocolBasePortM; }
unsigned int GetTraceMode(void) const { return traceModeM; }
bool IsTraceMode(eTraceMode modeP) const { return (traceModeM & modeP); }
unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; }
unsigned int GetUseBytes(void) const { return useBytesM; }
unsigned int GetSectionFiltering(void) const { return sectionFilteringM; }
const char *GetConfigDirectory(void) const { return configDirectoryM; }
const char *GetResourceDirectory(void) const { return resourceDirectoryM; }
unsigned int GetDisabledFiltersCount(void) const;
int GetDisabledFilters(unsigned int indexP) const;
void SetTsBufferSize(unsigned int sizeP) { tsBufferSizeM = sizeP; }
void SetTsBufferPrefillRatio(unsigned int ratioP) { tsBufferPrefillRatioM = ratioP; }
void SetExtProtocolBasePort(unsigned int portNumberP) { extProtocolBasePortM = portNumberP; }
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); }
void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; }
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; }
void SetDisabledFilters(unsigned int indexP, int numberP);
void SetConfigDirectory(const char *directoryP);
void SetResourceDirectory(const char *directoryP);
};
extern cIptvConfig IptvConfig;

353
device.c
View File

@ -20,25 +20,26 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
isOpenDvrM(false),
sidScanEnabledM(false),
pidScanEnabledM(false),
channelIdM(tChannelID::InvalidID)
channelM()
{
unsigned int bufsize = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize());
unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE;
bufsize -= (bufsize % TS_SIZE);
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex());
info("Creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex());
tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
*cString::sprintf("IPTV %d", deviceIndexM));
tsBufferM->SetTimeouts(10, 10);
ResetBuffering();
*cString::sprintf("IPTV TS %d", deviceIndexM));
if (tsBufferM) {
tsBufferM->SetTimeouts(100, 100);
tsBufferM->SetIoThrottle();
pIptvStreamerM = new cIptvStreamer(*this, tsBufferM->Free());
}
pUdpProtocolM = new cIptvProtocolUdp();
pCurlProtocolM = new cIptvProtocolCurl();
pHttpProtocolM = new cIptvProtocolHttp();
pFileProtocolM = new cIptvProtocolFile();
pExtProtocolM = new cIptvProtocolExt();
pIptvStreamerM = new cIptvStreamer(tsBufferM, (100 * TS_SIZE));
pPidScannerM = new cPidScanner();
// Initialize filter pointers
memset(secFiltersM, 0, sizeof(secFiltersM));
// Start section handler for iptv device
pIptvSectionM = new cIptvSectionFilterHandler(deviceIndexM, bufsize + 1);
StartSectionHandler();
// Sid scanner must be created after the section handler
AttachFilter(pSidScannerM = new cSidScanner());
@ -49,28 +50,25 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0)
dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
}
}
cIptvDevice::~cIptvDevice()
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
DELETE_POINTER(pIptvStreamerM);
DELETE_POINTER(pUdpProtocolM);
DELETE_POINTER(pCurlProtocolM);
DELETE_POINTER(pHttpProtocolM);
DELETE_POINTER(pFileProtocolM);
DELETE_POINTER(pExtProtocolM);
DELETE_POINTER(tsBufferM);
DELETE_POINTER(pPidScannerM);
DELETE_POINTER(pSidScannerM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop section handler of iptv device
StopSectionHandler();
// Destroy all filters
cMutexLock MutexLock(&mutexM);
for (int i = 0; i < eMaxSecFilterCount; ++i)
DeleteFilter(i);
DELETE_POINTER(pIptvSectionM);
DELETE_POINTER(pSidScannerM);
DELETE_POINTER(pPidScannerM);
DELETE_POINTER(pIptvStreamerM);
DELETE_POINTER(pExtProtocolM);
DELETE_POINTER(pFileProtocolM);
DELETE_POINTER(pHttpProtocolM);
DELETE_POINTER(pCurlProtocolM);
DELETE_POINTER(pUdpProtocolM);
DELETE_POINTER(tsBufferM);
// Close dvr fifo
if (dvrFdM >= 0) {
int fd = dvrFdM;
@ -81,7 +79,7 @@ cIptvDevice::~cIptvDevice()
bool cIptvDevice::Initialize(unsigned int deviceCountP)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceCountP);
debug1("%s (%u)", __PRETTY_FUNCTION__, deviceCountP);
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
if (deviceCountP > IPTV_MAX_DEVICES)
deviceCountP = IPTV_MAX_DEVICES;
@ -92,10 +90,19 @@ bool cIptvDevice::Initialize(unsigned int deviceCountP)
return true;
}
void cIptvDevice::Shutdown(void)
{
debug1("%s", __PRETTY_FUNCTION__);
for (int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i])
IptvDevicesS[i]->CloseDvr();
}
}
unsigned int cIptvDevice::Count(void)
{
unsigned int count = 0;
debug("cIptvDevice::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i] != NULL)
count++;
@ -105,10 +112,10 @@ unsigned int cIptvDevice::Count(void)
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, cardIndexP);
debug16("%s (%d)", __PRETTY_FUNCTION__, cardIndexP);
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if ((IptvDevicesS[i] != NULL) && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
//debug("cIptvDevice::%s(%d): found!", __FUNCTION__, cardIndexP);
if (IptvDevicesS[i] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
debug16("%s (%d) Found", __PRETTY_FUNCTION__, cardIndexP);
return IptvDevicesS[i];
}
}
@ -117,38 +124,26 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
cString cIptvDevice::GetGeneralInformation(void)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
LOCK_CHANNELS_READ;
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
deviceIndexM, CardIndex(),
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "",
pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "",
*GetBufferStatistic(),
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
*Channels->GetByNumber(cDevice::CurrentChannel())->ToText());
}
cString cIptvDevice::GetPidsInformation(void)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return GetPidStatistic();
}
cString cIptvDevice::GetFiltersInformation(void)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
unsigned int count = 0;
cString s("Active section filters:\n");
// loop through active section filters
cMutexLock MutexLock(&mutexM);
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secFiltersM[i]) {
s = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *s, i,
*secFiltersM[i]->GetSectionStatistic(), secFiltersM[i]->GetPid(),
id_pid(secFiltersM[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
}
}
return s;
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return cString::sprintf("Active section filters:\n%s", pIptvSectionM ? *pIptvSectionM->GetInformation() : "");
}
cString cIptvDevice::GetInformation(unsigned int pageP)
@ -183,37 +178,37 @@ cString cIptvDevice::GetInformation(unsigned int pageP)
cString cIptvDevice::DeviceType(void) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return "IPTV";
}
cString cIptvDevice::DeviceName(void) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return cString::sprintf("IPTV %d", deviceIndexM);
}
int cIptvDevice::SignalStrength(void) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100);
}
int cIptvDevice::SignalQuality(void) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100);
}
bool cIptvDevice::ProvidesSource(int sourceP) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER));
}
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (ProvidesSource(channelP->Source()));
}
@ -223,12 +218,12 @@ bool cIptvDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
bool needsDetachReceivers = false;
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (channelP && ProvidesTransponder(channelP)) {
result = hasPriority;
if (Receiving()) {
if (channelP->GetChannelID() == channelIdM)
if (channelP->GetChannelID() == channelM.GetChannelID())
result = true;
else
needsDetachReceivers = Receiving();
@ -249,12 +244,27 @@ int cIptvDevice::NumProvidedSystems(void) const
return 1;
}
const cChannel *cIptvDevice::GetCurrentlyTunedTransponder(void) const
{
return &channelM;
}
bool cIptvDevice::IsTunedToTransponder(const cChannel *channelP) const
{
return channelP ? (channelP->GetChannelID() == channelM.GetChannelID()) : false;
}
bool cIptvDevice::MaySwitchTransponder(const cChannel *channelP) const
{
return cDevice::MaySwitchTransponder(channelP);
}
bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
{
cIptvProtocolIf *protocol;
cIptvTransponderParameters itp(channelP->Parameters());
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isempty(itp.Address())) {
error("Unrecognized IPTV address: %s", channelP->Parameters());
@ -283,116 +293,66 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
}
sidScanEnabledM = itp.SidScan() ? true : false;
pidScanEnabledM = itp.PidScan() ? true : false;
if (pIptvStreamerM->Set(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) {
channelIdM = channelP->GetChannelID();
if (pIptvStreamerM && pIptvStreamerM->SetSource(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) {
channelM = *channelP;
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
pSidScannerM->SetChannel(channelIdM);
pSidScannerM->SetChannel(channelM.GetChannelID());
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->SetChannel(channelIdM);
pPidScannerM->SetChannel(channelM.GetChannelID());
}
return true;
}
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
{
debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP->pid, typeP, onP);
debug1("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM);
if (pIptvStreamerM && handleP)
return pIptvStreamerM->SetPid(handleP->pid, typeP, onP);
return true;
}
bool cIptvDevice::DeleteFilter(unsigned int indexP)
{
if ((indexP < eMaxSecFilterCount) && secFiltersM[indexP]) {
//debug("cIptvDevice::%s(%d): index=%d", __FUNCTION__, deviceIndexM, indexP);
cIptvSectionFilter *tmp = secFiltersM[indexP];
secFiltersM[indexP] = NULL;
delete tmp;
return true;
}
return false;
}
bool cIptvDevice::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
{
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X", __FUNCTION__, deviceIndexM, pidP, tidP, maskP);
// loop through section filter table
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
int index = IptvConfig.GetDisabledFilters(i);
// Check if matches
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
(section_filter_table[index].mask == maskP)) {
//debug("cIptvDevice::%s(%d): found %s", __FUNCTION__, deviceIndexM, section_filter_table[index].description);
return true;
}
}
return false;
}
int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
{
// Check if disabled by user
if (!IptvConfig.GetSectionFiltering())
return -1;
// Lock
cMutexLock MutexLock(&mutexM);
// Blacklist check, refuse certain filters
if (IsBlackListed(pidP, tidP, maskP))
return -1;
// Search the next free filter slot
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!secFiltersM[i]) {
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X index=%d", __FUNCTION__, deviceIndexM, pidP, tidP, maskP, i);
secFiltersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
if (secFiltersM[i])
return i;
break;
}
}
// No free filter slot found
return -1;
}
int cIptvDevice::ReadFilter(int handleP, void *bufferP, size_t lengthP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// ... and load
if (secFiltersM[handleP]) {
return secFiltersM[handleP]->Read(bufferP, lengthP);
//debug("cIptvDevice::%s(%d): handle=%d length=%d", __FUNCTION__, deviceIndexM, handleP, lengthP);
debug16("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
if (pIptvSectionM && IptvConfig.GetSectionFiltering()) {
if (pIptvStreamerM)
pIptvStreamerM->SetPid(pidP, ptOther, true);
return pIptvSectionM->Open(pidP, tidP, maskP);
}
return 0;
return -1;
}
void cIptvDevice::CloseFilter(int handleP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// ... and load
if (secFiltersM[handleP]) {
//debug("cIptvDevice::%s(%d): handle=%d", __FUNCTION__, deviceIndexM, handleP);
DeleteFilter(handleP);
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, handleP, deviceIndexM);
if (pIptvSectionM) {
if (pIptvStreamerM)
pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false);
pIptvSectionM->Close(handleP);
}
}
bool cIptvDevice::OpenDvr(void)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
isPacketDeliveredM = false;
tsBufferM->Clear();
ResetBuffering();
if (pIptvStreamerM)
pIptvStreamerM->Open();
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
pSidScannerM->Open();
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Open();
isOpenDvrM = true;
return true;
}
void cIptvDevice::CloseDvr(void)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (sidScanEnabledM && pSidScannerM )
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Close();
if (sidScanEnabledM && pSidScannerM)
pSidScannerM->Close();
if (pIptvStreamerM)
pIptvStreamerM->Close();
@ -401,81 +361,102 @@ void cIptvDevice::CloseDvr(void)
bool cIptvDevice::HasLock(int timeoutMsP) const
{
//debug("cIptvDevice::%s(%d): timeoutMs=%d", __FUNCTION__, deviceIndexM, timeoutMsP);
return (!IsBuffering());
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, timeoutMsP, deviceIndexM);
return (pIptvStreamerM && pIptvStreamerM->Active());
}
bool cIptvDevice::HasInternalCam(void)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
return true;
}
void cIptvDevice::ResetBuffering(void)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
// Pad prefill to multiple of TS_SIZE
tsBufferPrefillM = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
IptvConfig.GetTsBufferPrefillRatio() / 100;
tsBufferPrefillM -= (tsBufferPrefillM % TS_SIZE);
}
bool cIptvDevice::IsBuffering(void) const
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (tsBufferPrefillM && tsBufferM && tsBufferM->Available() < tsBufferPrefillM)
return true;
else
tsBufferPrefillM = 0;
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return false;
}
bool cIptvDevice::GetTSPacket(uchar *&Data)
void cIptvDevice::WriteData(uchar *bufferP, int lengthP)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (tsBufferM && !IsBuffering()) {
if (isPacketDeliveredM) {
tsBufferM->Del(TS_SIZE);
isPacketDeliveredM = false;
// Update buffer statistics
AddBufferStatistic(TS_SIZE, tsBufferM->Available());
}
int Count = 0;
uchar *p = tsBufferM->Get(Count);
if (p && Count >= TS_SIZE) {
debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
int len;
// Send data to dvr fifo
if (dvrFdM >= 0)
len = write(dvrFdM, bufferP, lengthP);
// Fill up TS buffer
if (tsBufferM) {
len = tsBufferM->Put(bufferP, lengthP);
if (len != lengthP)
tsBufferM->ReportOverflow(lengthP - len);
}
// Filter the sections
if (pIptvSectionM && IptvConfig.GetSectionFiltering())
pIptvSectionM->Write(bufferP, lengthP);
}
unsigned int cIptvDevice::CheckData(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (tsBufferM)
return (unsigned int)tsBufferM->Free();
return 0;
}
uchar *cIptvDevice::GetData(int *availableP)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isOpenDvrM && tsBufferM) {
int count = 0;
if (isPacketDeliveredM)
SkipData(TS_SIZE);
uchar *p = tsBufferM->Get(count);
if (p && count >= TS_SIZE) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < Count; i++) {
for (int i = 1; i < count; i++) {
if (p[i] == TS_SYNC_BYTE) {
Count = i;
count = i;
break;
}
}
tsBufferM->Del(Count);
error("Skipped %d bytes to sync on TS packet\n", Count);
return false;
tsBufferM->Del(count);
info("Skipped %d bytes to sync on TS packet", count);
return NULL;
}
isPacketDeliveredM = true;
Data = p;
if (availableP)
*availableP = count;
// Update pid statistics
AddPidStatistic(ts_pid(p), payload(p));
// Send data also to dvr fifo
if (dvrFdM >= 0)
Count = (int)write(dvrFdM, p, TS_SIZE);
// Analyze incomplete streams with built-in pid analyzer
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Process(p);
// Lock
cMutexLock MutexLock(&mutexM);
// Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secFiltersM[i])
secFiltersM[i]->Process(p);
}
return true;
return p;
}
}
return NULL;
}
void cIptvDevice::SkipData(int countP)
{
debug16("%s (%d) [device %d]]", __PRETTY_FUNCTION__, countP, deviceIndexM);
tsBufferM->Del(countP);
isPacketDeliveredM = false;
// Update buffer statistics
AddBufferStatistic(countP, tsBufferM->Available());
}
bool cIptvDevice::GetTSPacket(uchar *&dataP)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (tsBufferM) {
if (cCamSlot *cs = CamSlot()) {
if (cs->WantsTsData()) {
int available;
dataP = GetData(&available);
if (dataP) {
dataP = cs->Decrypt(dataP, available);
SkipData(available);
}
return true;
}
}
dataP = GetData();
return true;
}
// Reduce cpu load by preventing busylooping
cCondWait::SleepMs(10);
Data = NULL;
dataP = NULL;
return true;
}

View File

@ -10,6 +10,7 @@
#include <vdr/device.h>
#include "common.h"
#include "deviceif.h"
#include "protocoludp.h"
#include "protocolcurl.h"
#include "protocolhttp.h"
@ -21,19 +22,17 @@
#include "sidscanner.h"
#include "statistics.h"
class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics {
class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics, public cIptvDeviceIf {
// static ones
public:
static unsigned int deviceCount;
static bool Initialize(unsigned int DeviceCount);
static void Shutdown(void);
static unsigned int Count(void);
static cIptvDevice *GetIptvDevice(int CardIndex);
// private parts
private:
enum {
eMaxSecFilterCount = 32
};
unsigned int deviceIndexM;
int dvrFdM;
bool isPacketDeliveredM;
@ -41,18 +40,17 @@ private:
bool sidScanEnabledM;
bool pidScanEnabledM;
cRingBufferLinear *tsBufferM;
mutable int tsBufferPrefillM;
tChannelID channelIdM;
cChannel channelM;
cIptvProtocolUdp *pUdpProtocolM;
cIptvProtocolCurl *pCurlProtocolM;
cIptvProtocolHttp *pHttpProtocolM;
cIptvProtocolFile *pFileProtocolM;
cIptvProtocolExt *pExtProtocolM;
cIptvStreamer *pIptvStreamerM;
cIptvSectionFilterHandler *pIptvSectionM;
cPidScanner *pPidScannerM;
cSidScanner *pSidScannerM;
cMutex mutexM;
cIptvSectionFilter *secFiltersM[eMaxSecFilterCount];
// constructor & destructor
public:
@ -70,13 +68,6 @@ private:
cString GetPidsInformation(void);
cString GetFiltersInformation(void);
// for channel parsing & buffering
private:
void ResetBuffering(void);
bool IsBuffering(void) const;
bool DeleteFilter(unsigned int indexP);
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
// for channel info
public:
virtual cString DeviceType(void) const;
@ -91,10 +82,18 @@ public:
virtual bool ProvidesChannel(const cChannel *channelP, int priorityP = -1, bool *needsDetachReceiversP = NULL) const;
virtual bool ProvidesEIT(void) const;
virtual int NumProvidedSystems(void) const;
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
virtual bool IsTunedToTransponder(const cChannel *channelP) const;
virtual bool MaySwitchTransponder(const cChannel *channelP) const;
protected:
virtual bool SetChannelDevice(const cChannel *channelP, bool liveViewP);
// for recording
private:
uchar *GetData(int *availableP = NULL);
void SkipData(int countP);
protected:
virtual bool SetPid(cPidHandle *handleP, int typeP, bool onP);
virtual bool OpenDvr(void);
@ -104,7 +103,6 @@ protected:
// for section filtering
public:
virtual int OpenFilter(u_short pidP, u_char tidP, u_char maskP);
virtual int ReadFilter(int handleP, void *bufferP, size_t lengthP);
virtual void CloseFilter(int handleP);
// for transponder lock
@ -114,6 +112,11 @@ public:
// for common interface
public:
virtual bool HasInternalCam(void);
// for internal device interface
public:
virtual void WriteData(u_char *bufferP, int lengthP);
virtual unsigned int CheckData(void);
};
#endif // __IPTV_DEVICE_H

23
deviceif.h Normal file
View File

@ -0,0 +1,23 @@
/*
* deviceif.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_DEVICEIF_H
#define __IPTV_DEVICEIF_H
class cIptvDeviceIf {
public:
cIptvDeviceIf() {}
virtual ~cIptvDeviceIf() {}
virtual void WriteData(u_char *bufferP, int lengthP) = 0;
virtual unsigned int CheckData(void) = 0;
private:
cIptvDeviceIf(const cIptvDeviceIf&);
cIptvDeviceIf& operator=(const cIptvDeviceIf&);
};
#endif // __IPTV_DEVICEIF_H

82
iptv.c
View File

@ -13,15 +13,15 @@
#include "device.h"
#include "iptvservice.h"
#if defined(APIVERSNUM) && APIVERSNUM < 10738
#error "VDR-1.7.38 API version or greater is required!"
#if defined(APIVERSNUM) && APIVERSNUM < 20400
#error "VDR-2.4.0 API version or greater is required!"
#endif
#ifndef GITVERSION
#define GITVERSION ""
#endif
const char VERSION[] = "1.2.1" GITVERSION;
const char VERSION[] = "2.4.0" GITVERSION;
static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin {
@ -54,7 +54,7 @@ public:
cPluginIptv::cPluginIptv(void)
: deviceCountM(1)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Initialize any member variables here.
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
@ -62,23 +62,25 @@ cPluginIptv::cPluginIptv(void)
cPluginIptv::~cPluginIptv()
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Clean up after yourself!
}
const char *cPluginIptv::CommandLineHelp(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Return a string that describes all known command line options.
return " -d <num>, --devices=<number> number of devices to be created\n";
return " -d <num>, --devices=<number> number of devices to be created\n"
" -t <mode>, --trace=<mode> set the tracing mode\n";
}
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Implement command line argument processing here if applicable.
static const struct option long_options[] = {
{ "devices", required_argument, NULL, 'd' },
{ "trace", required_argument, NULL, 't' },
{ NULL, no_argument, NULL, 0 }
};
@ -88,6 +90,9 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
case 'd':
deviceCountM = atoi(optarg);
break;
case 't':
IptvConfig.SetTraceMode(strtol(optarg, NULL, 0));
break;
default:
return false;
}
@ -97,80 +102,89 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
bool cPluginIptv::Initialize(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Initialize any background activities the plugin shall perform.
IptvConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
IptvConfig.SetResourceDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
return cIptvDevice::Initialize(deviceCountM);
}
bool cPluginIptv::Start(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Start any background activities the plugin shall perform.
if (curl_global_init(CURL_GLOBAL_ALL) == CURLE_OK) {
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
info("Using CURL %s", data->version);
cString info = cString::sprintf("Using CURL %s", data->version);
for (int i = 0; data->protocols[i]; ++i) {
// Supported protocols: HTTP(S), RTSP, FILE
if (startswith(data->protocols[i], "http") || startswith(data->protocols[i], "rtsp") ||
startswith(data->protocols[i], "file"))
info = cString::sprintf("%s %s", *info, data->protocols[i]);
}
info("%s", *info);
}
return true;
}
void cPluginIptv::Stop(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Stop any background activities the plugin is performing.
cIptvDevice::Shutdown();
curl_global_cleanup();
}
void cPluginIptv::Housekeeping(void)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Perform any cleanup or other regular tasks.
}
void cPluginIptv::MainThreadHook(void)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Perform actions in the context of the main program thread.
// WARNING: Use with great care - see PLUGINS.html!
}
cString cPluginIptv::Active(void)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Return a message string if shutdown should be postponed
return NULL;
}
time_t cPluginIptv::WakeupTime(void)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Return custom wakeup time for shutdown script
return 0;
}
cOsdObject *cPluginIptv::MainMenuAction(void)
{
//debug("cPluginIptv::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Perform the action when selected from the main VDR menu.
return NULL;
}
cMenuSetupPage *cPluginIptv::SetupMenu(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Return a setup menu in case the plugin supports one.
return new cIptvPluginSetup();
}
int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
{
debug("cPluginIptv::%s(%s)", __FUNCTION__, valueP);
debug1("%s (%s, )", __PRETTY_FUNCTION__, valueP);
char buffer[256];
int n = 0;
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) {
strn0cpy(buffer, valueP, sizeof(buffer));
int i = atoi(buffer);
//debug("cPluginIptv::%s(): filters[%d]=%d", __FUNCTION__, n, i);
debug16("%s (%s, ) filters[%d]=%d", __PRETTY_FUNCTION__, valueP, n, i);
if (i >= 0)
filtersP[n++] = i;
if ((valueP = strchr(valueP, ' ')) != NULL)
@ -181,14 +195,10 @@ int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, valueP);
// Parse your own setup parameters and store their values.
if (!strcasecmp(nameP, "TsBufferSize"))
IptvConfig.SetTsBufferSize(atoi(valueP));
else if (!strcasecmp(nameP, "TsBufferPrefill"))
IptvConfig.SetTsBufferPrefillRatio(atoi(valueP));
else if (!strcasecmp(nameP, "ExtProtocolBasePort"))
IptvConfig.SetExtProtocolBasePort(atoi(valueP));
if (!strcasecmp(nameP, "ExtProtocolBasePort"))
IptvConfig.SetProtocolBasePort(atoi(valueP));
else if (!strcasecmp(nameP, "SectionFiltering"))
IptvConfig.SetSectionFiltering(atoi(valueP));
else if (!strcasecmp(nameP, "DisabledFilters")) {
@ -206,8 +216,8 @@ bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
bool cPluginIptv::Service(const char *idP, void *dataP)
{
debug("cPluginIptv::%s()", __FUNCTION__);
if (strcmp(idP,"IptvService-v1.0") == 0) {
debug1("%s (%s, )", __PRETTY_FUNCTION__, idP);
if (strcmp(idP, "IptvService-v1.0") == 0) {
if (dataP) {
IptvService_v1_0 *data = reinterpret_cast<IptvService_v1_0*>(dataP);
cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex);
@ -223,7 +233,7 @@ bool cPluginIptv::Service(const char *idP, void *dataP)
const char **cPluginIptv::SVDRPHelpPages(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
static const char *HelpPages[] = {
"INFO [ <page> ]\n"
" Print IPTV device information and statistics.\n"
@ -231,6 +241,8 @@ const char **cPluginIptv::SVDRPHelpPages(void)
" option: 1=general 2=pids 3=section filters.\n",
"MODE\n"
" Toggles between bit or byte information mode.\n",
"TRAC [ <mode> ]\n"
" Gets and/or sets used tracing mode.\n",
NULL
};
return HelpPages;
@ -238,7 +250,7 @@ const char **cPluginIptv::SVDRPHelpPages(void)
cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
{
debug("cPluginIptv::%s(%s, %s)", __FUNCTION__, commandP, optionP);
debug1("%s (%s, %s, )", __PRETTY_FUNCTION__, commandP, optionP);
if (strcasecmp(commandP, "INFO") == 0) {
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
if (device) {
@ -260,6 +272,12 @@ cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int
IptvConfig.SetUseBytes(mode);
return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits");
}
else if (strcasecmp(commandP, "TRAC") == 0) {
if (optionP && *optionP)
IptvConfig.SetTraceMode(strtol(optionP, NULL, 0));
return cString::sprintf("IPTV tracing mode: 0x%04X\n", IptvConfig.GetTraceMode());
}
return NULL;
}

48
log.h Normal file
View File

@ -0,0 +1,48 @@
/*
* log.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_LOG_H
#define __IPTV_LOG_H
#include "config.h"
#define error(x...) esyslog("IPTV-ERROR: " x)
#define info(x...) isyslog("IPTV: " x)
// 0x0001: Generic call stack
#define debug1(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug1) ? dsyslog("IPTV1: " x) : void() )
// 0x0002: TBD
#define debug2(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug2) ? dsyslog("IPTV2: " x) : void() )
// 0x0004: TBD
#define debug3(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug3) ? dsyslog("IPTV3: " x) : void() )
// 0x0008: TBD
#define debug4(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug4) ? dsyslog("IPTV4: " x) : void() )
// 0x0010: TBD
#define debug5(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug5) ? dsyslog("IPTV5: " x) : void() )
// 0x0020: TBD
#define debug6(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug6) ? dsyslog("IPTV6: " x) : void() )
// 0x0040: TBD
#define debug7(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug7) ? dsyslog("IPTV7: " x) : void() )
// 0x0080: CURL
#define debug8(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug8) ? dsyslog("IPTV8: " x) : void() )
// 0x0100: TBD
#define debug9(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug9) ? dsyslog("IPTV9: " x) : void() )
// 0x0200: TBD
#define debug10(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug10) ? dsyslog("IPTV10: " x) : void() )
// 0x0400: TBD
#define debug11(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug11) ? dsyslog("IPTV11: " x) : void() )
// 0x0800: TBD
#define debug12(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug12) ? dsyslog("IPTV12: " x) : void() )
// 0x1000: TBD
#define debug13(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug13) ? dsyslog("IPTV13: " x) : void() )
// 0x2000: TBD
#define debug14(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug14) ? dsyslog("IPTV14: " x) : void() )
// 0x4000: TBD
#define debug15(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug15) ? dsyslog("IPTV15: " x) : void() )
// 0x8000; Extra call stack
#define debug16(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug16) ? dsyslog("IPTV16: " x) : void() )
#endif // __IPTV_LOG_H

View File

@ -22,41 +22,40 @@ cPidScanner::cPidScanner(void)
numVpidsM(0),
numApidsM(0)
{
debug("cPidScanner::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cPidScanner::~cPidScanner()
{
debug("cPidScanner::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
void cPidScanner::SetChannel(const tChannelID &channelIdP)
{
debug("cPidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString());
channelIdM = channelIdP;
vPidM = 0xFFFF;
numVpidsM = 0;
aPidM = 0xFFFF;
numApidsM = 0;
processM = true;
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
}
void cPidScanner::Process(const uint8_t* bufP)
{
//debug("cPidScanner::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
if (!processM)
return;
// Stop scanning after defined timeout
if (timeoutM.TimedOut()) {
debug("cPidScanner::%s(): timed out determining pids", __FUNCTION__);
debug1("%s Timed out determining pids", __PRETTY_FUNCTION__);
processM = false;
}
// Verify TS packet
if (bufP[0] != 0x47) {
error("Not TS packet: 0x%X\n", bufP[0]);
error("Not TS packet: 0x%02X", bufP[0]);
return;
}
@ -85,35 +84,37 @@ void cPidScanner::Process(const uint8_t* bufP)
// Stream ID
if ((sid >= 0xC0) && (sid <= 0xDF)) {
if (pid < aPidM) {
debug("cPidScanner::%s(): found lower Apid: 0x%X instead of 0x%X", __FUNCTION__, pid, aPidM);
debug1("%s Found lower Apid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, aPidM);
aPidM = pid;
numApidsM = 1;
}
else if (pid == aPidM) {
++numApidsM;
debug("cPidScanner::%s(): incrementing Apids, now at %d", __FUNCTION__, numApidsM);
debug1("%s Incrementing Apids, now at %d", __PRETTY_FUNCTION__, numApidsM);
}
}
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
if (pid < vPidM) {
debug("cPidScanner::%s(): found lower Vpid: 0x%X instead of 0x%X", __FUNCTION__, pid, vPidM);
debug1("%s Found lower Vpid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, vPidM);
vPidM = pid;
numVpidsM = 1;
}
else if (pid == vPidM) {
++numVpidsM;
debug("cPidScanner::%s(): incrementing Vpids, now at %d", __FUNCTION__, numVpidsM);
debug1("%s Incrementing Vpids, now at %d", __PRETTY_FUNCTION__, numVpidsM);
}
}
}
if (((numVpidsM >= PIDSCANNER_VPID_COUNT) && (numApidsM >= PIDSCANNER_APID_COUNT)) ||
(abs(numApidsM - numVpidsM) >= PIDSCANNER_PID_DELTA_COUNT)) {
// Lock channels for pid updates
if (!Channels.Lock(true, 10)) {
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
cStateKey StateKey;
cChannels *Channels = cChannels::GetChannelsWrite(StateKey, 10);
if (!Channels)
return;
}
cChannel *IptvChannel = Channels.GetByChannelID(channelIdM);
bool ChannelsModified = false;
cChannel *IptvChannel = Channels->GetByChannelID(channelIdM);
if (IptvChannel) {
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
int Atypes[MAXAPIDS + 1] = { 0 };
@ -147,10 +148,10 @@ void cPidScanner::Process(const uint8_t* bufP)
}
for (unsigned int i = 0; i < MAXSPIDS; ++i)
Spids[i] = IptvChannel->Spid(i);
debug("cPidScanner::%s(): vpid=0x%04X, apid=0x%04X", __FUNCTION__, vPidM, aPidM);
IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
debug1("%s vpid=0x%04X, apid=0x%04X", __PRETTY_FUNCTION__, vPidM, aPidM);
ChannelsModified |= IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
}
Channels.Unlock();
StateKey.Remove(ChannelsModified);
processM = false;
}
}

View File

@ -11,8 +11,16 @@
#include <vdr/tools.h>
#include <vdr/channels.h>
#include "log.h"
class cPidScanner {
private:
enum {
PIDSCANNER_APID_COUNT = 5, /* minimum count of audio pid samples for pid detection */
PIDSCANNER_VPID_COUNT = 5, /* minimum count of video pid samples for pid detection */
PIDSCANNER_PID_DELTA_COUNT = 100, /* minimum count of pid samples for audio/video only pid detection */
PIDSCANNER_TIMEOUT_IN_MS = 15000 /* 15s timeout for detection */
};
cTimeMs timeoutM;
tChannelID channelIdM;
bool processM;
@ -26,6 +34,8 @@ public:
~cPidScanner();
void SetChannel(const tChannelID &channelIdP);
void Process(const uint8_t* bufP);
void Open() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); }
void Close() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(0); }
};
#endif // __PIDSCANNER_H

134
po/ca_ES.po Normal file
View File

@ -0,0 +1,134 @@
# VDR plugin language source file.
# Copyright (C) 2007-2017 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Gabriel Bonich, 2017
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Catalan <vdr@linuxtv.org>\n"
"Language: ca\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/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Experimenta la IPTV"
msgid "IPTV Information"
msgstr "Informació IPTV"
msgid "General"
msgstr "General"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtres"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Informació IPTV no disponible!"
msgid "Protocol base port"
msgstr "Port Protocol"
msgid ""
"Define a base port used by CURL/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 CURL/EXT protocol."
msgstr ""
"Definir el port utilizat por el protocol CURL/EXT.\n"
"\n"
"El nombre de ports es defineix por el nombre de dispositius IPTV. Aquesta configuració estableix el port que escolta a las conexions de las aplicaciones externas quant s'utiliza el protocol CURL / EXT."
msgid "Use section filtering"
msgstr "Utilitzi la secció de filtrat"
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 ""
"Definir si s'utilizarà la secció de filtrat.\n"
"\n"
"Secció de filtrat significa que el plugin IPTV tracta de analitzar i proporcionar a VDR les dades secundaries sobre el fluxe actiu. VDR pot utilitzar aquestes dades per proporcionar diverses funcionalitats com ara la detecció de canvis automatics del PID,EPG, etc.\n"
"L'activació d'aquesta funció no afecta als fluxes que no contenen dades de la secció."
msgid "Disabled filters"
msgstr "Desactivar Filtres"
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 ""
"Definir el nombre de filtres de sección a desactivar.\n"
"\n"
"Certs filtres de secció podrien causar un comportament no desitjat a VDR, com el temps que sincronitza malament. Aquí la llista negra dels filtres, les dades útils de la secció es poden deixar intactes perquè VDR els processi."
msgid "Filter"
msgstr "Filtre"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definir un filtre que no funcioni per ser inclos a la llista negre."
msgid "Help"
msgstr "Ajuda"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "ARXIU"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Escaneja secció ids"
msgid "Scan pids"
msgstr "Escaneja pids"
msgid "Protocol"
msgstr "Protocol"
msgid "Address"
msgstr "Direcció"
msgid "Parameter"
msgstr "Parametre"

View File

@ -1,15 +1,16 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Tobias <vdr@e-tobi.net>, 2007.
# Frank Neumann, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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: Tobias Grimm <tg@e-tobi.net>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
"Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
@ -26,14 +27,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -57,37 +52,22 @@ msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "IPTV Informationen nicht verfügbar!"
msgstr "Keine IPTV Informationen verfügbar!"
msgid "TS buffer size [MB]"
msgstr "TS Puffergröße [MB]"
msgid "Protocol base port"
msgstr "Basis Port Protokoll"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
"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 CURL/EXT protocol."
msgstr ""
msgid "TS buffer prefill ratio [%]"
msgstr "TS Puffer-Preload [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"Bestimme einen Basis Port für das CURL/EXT Protokoll.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
msgid "EXT protocol base port"
msgstr "EXT Protokoll Basisport"
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 ""
"Der Bereich der Ports wird durch die Anzahl der IPTV Geräte festgelegt. Diese Einstellung bestimmt den Port auf den für Verbindungen gelauscht wird, wenn externe Applikationen das CURL/EXT Protokoll nutzen."
msgid "Use section filtering"
msgstr "Benutze Abschnittsfilterung"
msgstr "Benutze Abschnittsfilter"
msgid ""
"Define whether the section filtering shall be used.\n"
@ -95,22 +75,28 @@ msgid ""
"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 ""
"Legt fest ob Abschnittsfilter genutzt werden sollen.\n"
"\n"
"Mit Abschnittsfiltern versucht das IPTV Plugin Sekundärdaten der aktiven Quelle zu analysieren und VDR bereitzustellen. VDR kann mit diesen Daten verschiedene Funktionen, wie automatische PID Erkennung und EPG, bereitstellen.\n"
"Die Nutzung dieser Fähigkeit hat keinen Einfluss auf Quellen, die keine Abschnittsdaten enthalten."
msgid "Disable filters"
msgstr "Deaktiviere Filter"
msgid "Disabled filters"
msgstr "Deaktivierte 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 ""
"Bestimme die Anzahl der Abschnittsfilter die deaktiviert werden sollen.\n"
"\n"
"Bestimmte Abschnittsfilter können unerwünschtes Verhalten mit VDR, z.B. falsche Zeit-Synchronisation, verursachen. Durch das Ausblenden einzelner Filter können nützliche Daten dieser Abschnitte für den VDR erhalten werden."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Deaktiviere Filter"
msgid "Filter"
msgstr "Filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr ""
msgstr "Bestimme einen fehlerhaften Filter der ausgeblendet werden soll."
msgid "Help"
msgstr "Hilfe"
@ -130,20 +116,14 @@ 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"
msgstr "Suche Abschnitt IDs"
msgid "Scan pids"
msgstr "Scanne PIDS"
msgstr "Suche PIDs"
msgid "Protocol"
msgstr "Protokoll"

134
po/es_ES.po Normal file
View File

@ -0,0 +1,134 @@
# VDR plugin language source file.
# Copyright (C) 2007-2017 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Gabriel Bonich, 2017
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Spanish <vdr@linuxtv.org>\n"
"Language: es\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/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Experimente la IPTV"
msgid "IPTV Information"
msgstr "Información IPTV"
msgid "General"
msgstr "General"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtros"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Información IPTV no disponible!"
msgid "Protocol base port"
msgstr "Puerto Protocolo"
msgid ""
"Define a base port used by CURL/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 CURL/EXT protocol."
msgstr ""
"Definir el puerto utilizado por el protocolo CURL/EXT.\n"
"\n"
"El rango de puertos se define por el número de dispositivos IPTV. Esta configuración establece el puerto que se escucha para las conexiones de las aplicaciones externas cuando se utiliza el protocolo CURL / EXT."
msgid "Use section filtering"
msgstr "Utilice la sección de filtrado"
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 ""
"Definir si se utilizará la sección de filtrado.\n"
"\n"
"Sección de filtrado significa que el plugin IPTV trata de analizar y proporcionar a VDR los datos secundarios sobre el flujo activo. VDR puede entonces utilizar estos datos para proporcionar diversas funcionalidades tales como detección automática del cambio del PID, EPG, etc.\n"
"El uso de esta capacidad no afecta a fuentes que no contienen datos de la sección."
msgid "Disabled filters"
msgstr "Desactivar Filtros"
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 ""
"Defina el número de filtros de sección a deshabilitar.\n"
"\n"
"Ciertos filtros de sección pueden causar algún comportamiento no deseado a VDR, como el tiempo que sincroniza mal. Aquí la lista negra de los filtros, los datos útiles de la sección se pueden dejar intactos para que VDR los procese."
msgid "Filter"
msgstr "Filtro"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Defina un filtro que no funcione para ser incluido en la lista negra."
msgid "Help"
msgstr "Ayuda"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "ARCHIVO"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Escanea sección ids"
msgid "Scan pids"
msgstr "Escanea pids"
msgid "Protocol"
msgstr "Protocolo"
msgid "Address"
msgstr "Dirección"
msgid "Parameter"
msgstr "Parametro"

View File

@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Rolf Ahrenberg
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n"
@ -25,14 +25,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -58,41 +52,17 @@ msgstr "Bitit/tavut"
msgid "IPTV information not available!"
msgstr "IPTV-tietoja ei saatavilla!"
msgid "TS buffer size [MB]"
msgstr "TS-puskurin koko [MB]"
msgid "Protocol base port"
msgstr "Protokollan perusportti"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
"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 CURL/EXT protocol."
msgstr ""
"Määritä rengaspuskurin koko TS-lähetteelle megatavuina.\n"
"Määrittele protokollan käyttämä perusportti.\n"
"\n"
"Pienempi rengaspuskuri vähentää muistinkulutusta, mutta on virhealttiimpi puskurin ylivuodolle."
msgid "TS buffer prefill ratio [%]"
msgstr "TS-puskurin esitäyttöaste [%]"
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 ""
"Määrittele TS-rengaspuskurin esitäyttöaste, jonka jälkeen lähetettä aletaan siirtämään eteenpäin VDR:lle.\n"
"\n"
"Puskurin esitäyttö parantaa suoratoistoa hitailla ja epäluotettavilla yhteyksillä."
msgid "EXT protocol base port"
msgstr "EXT-protokollan perusportti"
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 ""
"Määrittele EXT-protokollan käyttämä perusportti.\n"
"\n"
"Porttiavaruuden koko määräytyy käytettyjen IPTV-laitteiden mukaan. Laajennos lukee EXT-protokollan yhteydessä perusportista dataa, jota ulkoiset ohjelmistot tarjoavat."
"Porttiavaruuden koko määräytyy käytettyjen IPTV-laitteiden mukaan. Laajennos lukee CURL/EXT-protokollan yhteydessä perusportista dataa, jota ulkoiset ohjelmistot tarjoavat."
msgid "Use section filtering"
msgstr "Käytä sektioiden suodatusta"
@ -108,7 +78,7 @@ msgstr ""
"IPTV-laajennos voi suodattaa lähetteestä VDR:lle tarjottavia sektioita, joita käytetään esim. ohjelmaoppaan ja ohjelmatunnisteiden (PID) päivittämiseen.\n"
"Toiminto ei vaikuta lähetteeseen, jossa ei ole sektioita."
msgid "Disable filters"
msgid "Disabled filters"
msgstr "Poista suodattimia käytöstä"
msgid ""
@ -120,9 +90,8 @@ msgstr ""
"\n"
"Tietyt sektiot saattavat aiheuttaa virheellistä toimintaa VDR:ssä, esimerkiksi asettavat väärän kellonajan, ja näiden poistaminen auttaa VDR:ää toimimaan kunnolla jäljelle jäävien sektioiden kanssa."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Poista suodatin käytöstä"
msgid "Filter"
msgstr "Suodatin"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle listalle."
@ -145,12 +114,6 @@ msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "Lähete-ID"
msgid "Rid"
msgstr "Radio-ID"

View File

@ -1,15 +1,15 @@
# French translations for iptv package.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Bruno ROUSSEL <bruno.roussel@free.fr>, 2007.
# NIVAL Michaël <mnival@club-internet.fr>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
"Language-Team: French <vdr@linuxtv.org>\n"
"Language: fr\n"
@ -27,14 +27,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -60,41 +54,17 @@ msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Information sur IPTV non disponible !"
msgid "TS buffer size [MB]"
msgstr "Taille du buffer TS [MB]"
msgid "Protocol base port"
msgstr "Port de base du protocole"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
"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 CURL/EXT protocol."
msgstr ""
"Définit la taille du ringbuffer pour le transport du flux en megabytes.\n"
"Définit le port de base utilisé par le protocole CURL/EXT.\n"
"\n"
"Une taille plus petite taille aide la consommation de mémoire, mais c'est sujet à plus de débordement de tampon."
msgid "TS buffer prefill ratio [%]"
msgstr "Taux du buffer de pré-remplissage TS [%]"
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 ""
"Définit le ratio de pré-remplissage du ringbuffer pour le transport du flux avant transfert dans VDR.\n"
"\n"
"Cette option est utile si le streaming est sur une connexion lente ou peu fiables."
msgid "EXT protocol base port"
msgstr "Port de base du protocole EXT"
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 ""
"Définit le port de base utilisé par le protocole EXT.\n"
"\n"
"La plage de port est défini par le nombre de dispositif IPTV. Ce paramètre défini le port qui est écouté pour les connexions à partir d'applications externes en utilisant le protocole EXT."
"La plage de port est défini par le nombre de dispositif IPTV. Ce paramètre défini le port qui est écouté pour les connexions à partir d'applications externes en utilisant le protocole CURL/EXT."
msgid "Use section filtering"
msgstr "Utiliser le filtrage de section"
@ -110,7 +80,7 @@ msgstr ""
"La section filtrage signifie que le plugin IPTV essayera d'analyser et de fournir à VDR des données secondaires disponible sur le flux. VDR peut alors utiliser ces données pour fournir des fonctionnalitées supplémentaires tel que la détection de changement de pid et d'EPG etc.\n"
"L'activation de cette fonctionnalité n'a pas d'incidence sur les flux qui ne contiennent pas de données de la section."
msgid "Disable filters"
msgid "Disabled filters"
msgstr "Désactiver les filtres"
msgid ""
@ -122,9 +92,8 @@ msgstr ""
"\n"
"Certains filtrage de section peux engendrer des comportement indésirables. Blacklist les filtres qui seront laissé intact pour VDR."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Désactiver le filtre"
msgid "Filter"
msgstr "Filtre"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Définit les mauvais comportement qui doivent être désactivé."
@ -147,12 +116,6 @@ msgstr "FICHIER"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"

View File

@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Diego Pierotto <vdr-italian@tiscali.it>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: Italian <vdr@linuxtv.org>\n"
"Language: it\n"
@ -26,14 +26,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -59,41 +53,17 @@ msgstr "Bits/bytes"
msgid "IPTV information not available!"
msgstr "Informazione IPTV non disponibile!"
msgid "TS buffer size [MB]"
msgstr "Dimensione buffer TS [MB]"
msgid "Protocol base port"
msgstr "Porta base protocollo"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
"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 CURL/EXT protocol."
msgstr ""
"Definisci una dimensione del buffer in MB per i flussi di trasporto.\n"
"Definisci una porta base usata dal protocollo CURL/EXT.\n"
"\n"
"Dimensioni più piccole aiutano il consumo di memoria, ma sono più inclini a generare buffer overflows."
msgid "TS buffer prefill ratio [%]"
msgstr "Riempimento buffer TS [%]"
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 ""
"Definisci un rapporto di riempimento del buffer per i flussi di trasporto prima che i dati siano trasferiti a VDR.\n"
"\n"
"Questo è utile se si trasmette dati su una connessione lenta oppure inaffidabile."
msgid "EXT protocol base port"
msgstr "Porta base protocollo EXT"
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 ""
"Definisci una porta base usata dal protocollo EXT.\n"
"\n"
"Il range della porta è definito dal numero di periferiche IPTV. Questo parametro imposta la porta che è in ascolto per connessioni da applicazioni esterne quando si usa il protocollo EXT."
"Il range della porta è definito dal numero di periferiche IPTV. Questo parametro imposta la porta che è in ascolto per connessioni da applicazioni esterne quando si usa il protocollo CURL/EXT."
msgid "Use section filtering"
msgstr "Utilizza sezione filtri"
@ -109,7 +79,7 @@ msgstr ""
"La sezioni filtri significa che il plugin IPTV prova a elaborare e fornire a VDR dati secondari sul flusso attualmente attivo. VDR può successivamente usare questi dati per fornire varie funzionalità come il rilevamento del cambio Pid automatico, EPG, etc.\n"
"Abilitare questa funzione non influisce sui flussi che non contengono dati di sezione."
msgid "Disable filters"
msgid "Disabled filters"
msgstr "Disabilita filtri"
msgid ""
@ -121,9 +91,8 @@ msgstr ""
"\n"
"Certe sezioni filtri potrebbero generare alcuni comportamenti indesiderati per VDR come la non sincronizzazione dell'ora. Inserendo qui i filtri nella lista nera i dati di sezione utili possono essere lasciati intatti per l'elaborazione da parte di VDR."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Disabilita filtro"
msgid "Filter"
msgstr "Filtro"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
@ -146,12 +115,6 @@ msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"

133
po/lt_LT.po Normal file
View File

@ -0,0 +1,133 @@
# VDR plugin language source file.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Valdemaras Pipiras
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Valdemaras Pipiras\n"
"Language-Team: Lithuanian <vdr@linuxtv.org>\n"
"Language: fi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Išbandyk IPTV"
msgid "IPTV Information"
msgstr "IPTV informacija"
msgid "General"
msgstr "Pagrindinis"
msgid "Pids"
msgstr "Pidai"
msgid "Filters"
msgstr "Filtrai"
msgid "Bits/bytes"
msgstr "Bitai/baitai"
msgid "IPTV information not available!"
msgstr "Nėra IPTV informacijos!"
msgid "Protocol base port"
msgstr "Numatytasis protokolo portas"
msgid ""
"Define a base port used by CURL/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 CURL/EXT protocol."
msgstr ""
"Nustatykite pagrindinį portą naudojamą CURL/EXT transliavimo metodų.\n"
"\n"
"Portų rėžis nustatomas pagal IPTV įrenginių skaičių. Šis nustatymas nustato portą kuris priima išorinių programų užklausas, kai naudojamas CURL/EXT transliavimo metodas."
msgid "Use section filtering"
msgstr "Naudoti paketų filtravimą"
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 ""
"Numatyti ar paketų firltravimas bus naudojamas.\n"
"\n"
"Dalinis filtravimas reiškia tai kad IPTV pluginas bando ištraukti informaciją ir VDR sistemai pateikti papildomus duomenis apie dabar aktyvius srautus. VDR sistema po to gali naudoti šiuos duomenis įvairiems fokusams, tokiems kaip automatinis pid'ų pasikeitimo nustatymas arba EPG informacija it t.t.\n"
"Jei srautai neturi paketinės informacijos, jie nebus analizuojami net įjungus šį nustatymą."
msgid "Disabled filters"
msgstr "Išjungti filtrus"
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 ""
"Nurodyti kokį kiekį paketų filtrų išjungti.\n"
"\n"
"Šitie paketų filtrai gali sutrikdyti sistemos darbą, pavyzdžiui gali atsirasti laiko asinchronizacija. Atjungiant čia filtrus, gali būti palikta tik naudinga paketinė informacija nepažeidžianti sistemos darbo."
msgid "Filter"
msgstr "Filtrą"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Nustatyti kad netinkamai veikiantis filtras būtu išjungtas."
msgid "Help"
msgstr "Pagalba"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FAILAS"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Radio-ID"
msgid "Scan section ids"
msgstr "Skanuoti paketų id"
msgid "Scan pids"
msgstr "Skanuoti pidus"
msgid "Protocol"
msgstr "Protokolas"
msgid "Address"
msgstr "Adresas"
msgid "Parameter"
msgstr "Parametras"

View File

@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 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.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Carel\n"
"Language-Team: Dutch <vdr@linuxtv.org>\n"
"Language: nl\n"
@ -26,14 +26,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -59,41 +53,17 @@ msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "IPTV informatie niet beschikbaar!"
msgid "TS buffer size [MB]"
msgstr "TS buffergrootte [MB]"
msgid "Protocol base port"
msgstr "Protocol basispoort"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
"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 CURL/EXT protocol."
msgstr ""
"Stel de grootte van de ringbuffer vast voor transportstreams in megabytes.\n"
"Bepaal de basispoort voor het CURL/EXT protocol.\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."
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het CURL/EXT protocol wordt gebruikt."
msgid "Use section filtering"
msgstr "Benutze Abschnittsfilterung"
@ -108,7 +78,7 @@ msgstr ""
"\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"
msgid "Disabled filters"
msgstr "Deactiveer filter"
msgid ""
@ -120,9 +90,8 @@ msgstr ""
"\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 "Filter"
msgstr "Filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Blacklist een probleem veroorzakend filter "
@ -145,12 +114,6 @@ msgstr "BESTAND"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"

134
po/pl_PL.po Normal file
View File

@ -0,0 +1,134 @@
# VDR plugin language source file.
# Copyright (C) 2007-2017 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the vdr-iptv package.
# Tomasz Maciej Nowak, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Tomasz Maciej Nowak <tomek_n@o2.pl>\n"
"Language-Team: Polish <vdr@linuxtv.org>\n"
"Language: pl_PL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Poznaj IPTV"
msgid "IPTV Information"
msgstr "IPTV - informacje"
msgid "General"
msgstr "Główne"
msgid "Pids"
msgstr "Pidy"
msgid "Filters"
msgstr "Filtry"
msgid "Bits/bytes"
msgstr "Bity/bajty"
msgid "IPTV information not available!"
msgstr "Brak dostępnych informacji IPTV!"
msgid "Protocol base port"
msgstr "Podstawowy port protokołu"
msgid ""
"Define a base port used by CURL/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 CURL/EXT protocol."
msgstr ""
"Określa podstawowy port używany przez protokół CURL/EXT.\n"
"\n"
"Zakres portów jest zdefiniowany liczbą urządzeń IPTV. To ustawienie nadaje port, który nasłuchuje połączeń z zewnętrznych aplikacji używających protokołu CURL/EXT."
msgid "Use section filtering"
msgstr "Używaj filtrowania sekcji"
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 ""
"Określa czy włączyć filtrowanie sekcji.\n"
"\n"
"Filtrowanie sekcji oznacza że wtyczka IPTV próbuje analizować i dostarczyć VDR dodatkowe informacje o aktywnym strumieniu. VDR może użyć tych danych aby dostarczyć dodatkowe usługi jak automatyczne wykrycie zmiany pidów i EPG, etc.\n"
"Włączenie tej funkcji nie wpływa na strumienie nie posiadające danych sekcji."
msgid "Disabled filters"
msgstr "Wyłączone filtry"
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 ""
"Określa liczbę wyłączonych filtrów sekcji.\n"
"\n"
"Niektóre filtry sekcji mogą powodować niezamierzone efekty w VDR, takie jak zły czas synchronizacji. Poprzez wyłączenie niektórych filtrów, użyteczne dane sekcji będą dostępne do przetworzenia dla VDR."
msgid "Filter"
msgstr "Filtr"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Określa filtry powodujące zakłócenia, które mają być wyłączone."
msgid "Help"
msgstr "Pomoc"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "PLIK"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Skanuj sekcję identyfikatorów"
msgid "Scan pids"
msgstr "Skanuj pidy"
msgid "Protocol"
msgstr "Protokół"
msgid "Address"
msgstr "Adres"
msgid "Parameter"
msgstr "Parametr"

View File

@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Alexander Gross <Bikalexander@gmail.com>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 1.2.1\n"
"Project-Id-Version: vdr-iptv 2.4.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"
"POT-Creation-Date: 2018-04-15 04:15+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
"Last-Translator: Alexander Gross <Bikalexander@gmail.com>\n"
"Language-Team: Russian <vdr@linuxtv.org>\n"
"Language: ru\n"
@ -27,14 +27,8 @@ 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 "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -60,31 +54,13 @@ msgstr "Биты / байт"
msgid "IPTV information not available!"
msgstr "IPTV информация отсутствует!"
msgid "TS buffer size [MB]"
msgstr "Размер TS буфера [MB]"
msgid "Protocol base port"
msgstr "Базисный порт протокола"
msgid ""
"Define a ringbuffer size for transport streams in megabytes.\n"
"Define a base port used by CURL/EXT protocol.\n"
"\n"
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr ""
msgid "TS buffer prefill ratio [%]"
msgstr "Предварительный буфер TS [%]"
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 ""
msgid "EXT protocol base port"
msgstr "Базисный порт EXT протокола"
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."
"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 CURL/EXT protocol."
msgstr ""
msgid "Use section filtering"
@ -97,7 +73,7 @@ msgid ""
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
msgid "Disable filters"
msgid "Disabled filters"
msgstr "Деактивировать фильтры"
msgid ""
@ -106,9 +82,8 @@ msgid ""
"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 ""
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Деактивировать фильтр"
msgid "Filter"
msgstr "фильтр"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Неправильно работающий фильтр, занести в черный список."
@ -131,12 +106,6 @@ msgstr "ФАЙЛ"
msgid "EXT"
msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"

View File

@ -7,51 +7,88 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolcurl.h"
#ifdef CURLOPT_RTSPHEADER
#define USE_RTSP
#endif
#define iptv_curl_easy_setopt(X, Y, Z) \
if ((res = curl_easy_setopt((X), (Y), (Z))) != CURLE_OK) { \
error("curl_easy_setopt(%s, %s, %s) failed: %d\n", #X, #Y, #Z, res); \
error("curl_easy_setopt(%s, %s) failed: %s (%d)", #Y, #Z, curl_easy_strerror(res), res); \
}
#define iptv_curl_easy_perform(X) \
if ((res = curl_easy_perform((X))) != CURLE_OK) { \
error("curl_easy_perform(%s) failed: %d\n", #X, res); \
error("curl_easy_perform() failed: %s (%d)", curl_easy_strerror(res), res); \
}
cIptvProtocolCurl::cIptvProtocolCurl()
: streamUrlM(""),
streamParamM(0),
streamPortM(0),
mutexM(),
handleM(NULL),
multiM(NULL),
headerListM(NULL),
ringBufferM(new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
7 * TS_SIZE, false, "IPTV CURL")),
rtspControlM(),
ringBufferM(new cRingBufferLinear(IPTV_BUFFER_SIZE, 7 * TS_SIZE, false, "IPTV CURL")),
rtspControlM(""),
modeM(eModeUnknown),
timeoutM(),
connectedM(false),
pausedM(false)
{
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
if (ringBufferM)
debug1("%s", __PRETTY_FUNCTION__);
if (ringBufferM) {
ringBufferM->SetTimeouts(100, 0);
ringBufferM->SetIoThrottle();
}
Connect();
}
cIptvProtocolCurl::~cIptvProtocolCurl()
{
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
Disconnect();
// Free allocated memory
DELETE_POINTER(ringBufferM);
}
int cIptvProtocolCurl::DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP)
{
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
if (obj) {
switch (typeP) {
case CURLINFO_TEXT:
debug8("%s INFO %.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP);
break;
case CURLINFO_HEADER_IN:
debug8("%s HEAD <<< %.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP);
break;
case CURLINFO_HEADER_OUT:
debug8("%s HEAD >>>\n%.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP);
break;
case CURLINFO_DATA_IN:
debug8("%s DATA <<< %zu", __PRETTY_FUNCTION__, sizeP);
break;
case CURLINFO_DATA_OUT:
debug8("%s DATA >>> %zu", __PRETTY_FUNCTION__, sizeP);
break;
default:
break;
}
}
return 0;
}
size_t cIptvProtocolCurl::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
if (obj && !obj->PutData((unsigned char *)ptrP, (int)len))
return CURL_WRITEFUNC_PAUSE;
@ -64,10 +101,10 @@ size_t cIptvProtocolCurl::WriteRtspCallback(void *ptrP, size_t sizeP, size_t nme
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
unsigned char *p = (unsigned char *)ptrP;
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
// Validate packet header ('$') and channel (0)
if (obj && (p[0] == 0x24 ) && (p[1] == 0)) {
if (obj && (p[0] == 0x24) && (p[1] == 0)) {
int length = (p[2] << 8) | p[3];
if (length > 3) {
// Skip interleave header
@ -106,19 +143,26 @@ size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmem
{
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
bool found = false;
cString control = "";
char *p = (char *)ptrP;
char *r = strtok(p, "\r\n");
while (r) {
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
if (strstr(r, "a=control")) {
debug16("%s (, %zu, %zu, ) len=%zu r=%s", __PRETTY_FUNCTION__, sizeP, nmembP, len, r);
// Look for a media name: "video"
if (strstr(r, "m=video")) {
found = true;
}
// ... and find out its' attribute
if (found && strstr(r, "a=control")) {
char *s = NULL;
if (sscanf(r, "a=control:%64ms", &s) == 1)
if (sscanf(r, "a=control:%255ms", &s) == 1)
control = compactspace(s);
free(s);
break;
}
r = strtok(NULL, "\r\n");
}
@ -133,13 +177,13 @@ size_t cIptvProtocolCurl::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP
{
//cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
char *p = (char *)ptrP;
char *r = strtok(p, "\r\n");
while (r) {
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
debug16("%s (, %zu, %zu, ) len=%zu r=%s", __PRETTY_FUNCTION__, sizeP, nmembP, len, r);
r = strtok(NULL, "\r\n");
}
@ -149,20 +193,26 @@ size_t cIptvProtocolCurl::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP
void cIptvProtocolCurl::SetRtspControl(const char *controlP)
{
cMutexLock MutexLock(&mutexM);
debug("cIptvProtocolCurl::%s(%s)", __FUNCTION__, controlP);
rtspControlM = controlP;
debug16("%s (%s)", __PRETTY_FUNCTION__, controlP);
cString protocol = ChangeCase(controlP, false).Truncate(7);
if (startswith(*protocol, "rtsp://")) {
streamUrlM = controlP;
rtspControlM = "";
}
else
rtspControlM = controlP;
}
bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
{
cMutexLock MutexLock(&mutexM);
//debug("cIptvProtocolCurl::%s(%d)", __FUNCTION__, lenP);
debug16("%s (, %d)", __PRETTY_FUNCTION__, lenP);
if (pausedM)
return false;
if (ringBufferM && (lenP >= 0)) {
// Should we pause the transfer ?
if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) {
debug("cIptvProtocolCurl::%s(pause): free=%d available=%d len=%d", __FUNCTION__,
debug1("%s Pause free=%d available=%d len=%d", __PRETTY_FUNCTION__,
ringBufferM->Free(), ringBufferM->Available(), lenP);
pausedM = true;
return false;
@ -178,14 +228,14 @@ bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
void cIptvProtocolCurl::DelData(int lenP)
{
cMutexLock MutexLock(&mutexM);
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM && (lenP >= 0))
ringBufferM->Del(lenP);
}
void cIptvProtocolCurl::ClearData()
{
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM)
ringBufferM->Clear();
}
@ -193,7 +243,7 @@ void cIptvProtocolCurl::ClearData()
unsigned char *cIptvProtocolCurl::GetData(int &lenP)
{
cMutexLock MutexLock(&mutexM);
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
unsigned char *p = NULL;
lenP = 0;
if (ringBufferM) {
@ -208,7 +258,7 @@ unsigned char *cIptvProtocolCurl::GetData(int &lenP)
break;
}
}
error("IPTV skipped %d bytes to sync on TS packet\n", count);
error("IPTV skipped %d bytes to sync on TS packet", count);
ringBufferM->Del(count);
lenP = 0;
return NULL;
@ -225,24 +275,22 @@ unsigned char *cIptvProtocolCurl::GetData(int &lenP)
bool cIptvProtocolCurl::Connect()
{
cMutexLock MutexLock(&mutexM);
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
if (connectedM)
return true;
// Initialize the curl session
if (!handleM)
handleM = curl_easy_init();
if (!multiM)
multiM = curl_multi_init();
if (handleM && multiM && !isempty(*streamUrlM)) {
if (handleM && !isempty(*streamUrlM)) {
CURLcode res = CURLE_OK;
cString netrc = cString::sprintf("%s/netrc", IptvConfig.GetConfigDirectory());
#ifdef DEBUG
// Verbose output
iptv_curl_easy_setopt(handleM, CURLOPT_VERBOSE, 1L);
#endif
iptv_curl_easy_setopt(handleM, CURLOPT_DEBUGFUNCTION, cIptvProtocolCurl::DebugCallback);
iptv_curl_easy_setopt(handleM, CURLOPT_DEBUGDATA, this);
// Set callbacks
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEFUNCTION, cIptvProtocolCurl::WriteCallback);
@ -258,8 +306,10 @@ bool cIptvProtocolCurl::Connect()
iptv_curl_easy_setopt(handleM, CURLOPT_NETRC, (long)CURL_NETRC_OPTIONAL);
iptv_curl_easy_setopt(handleM, CURLOPT_NETRC_FILE, *netrc);
// Set timeout
// Set timeouts
iptv_curl_easy_setopt(handleM, CURLOPT_CONNECTTIMEOUT, (long)eConnectTimeoutS);
iptv_curl_easy_setopt(handleM, CURLOPT_LOW_SPEED_LIMIT, (long)eLowSpeedLimitBytes);
iptv_curl_easy_setopt(handleM, CURLOPT_LOW_SPEED_TIME, (long)eLowSpeedTimeoutS);
// Set user-agent
iptv_curl_easy_setopt(handleM, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s", PLUGIN_NAME_I18N, VERSION));
@ -272,10 +322,15 @@ bool cIptvProtocolCurl::Connect()
// Protocol specific initializations
switch (modeM) {
#ifdef USE_RTSP
case eModeRtsp:
{
cString uri, control, transport, range;
// Create the listening socket for UDP mode
if (!streamParamM)
OpenSocket(streamPortM);
// Request server options
uri = cString::sprintf("%s", *streamUrlM);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
@ -293,8 +348,14 @@ bool cIptvProtocolCurl::Connect()
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEDATA, NULL);
// Setup media stream
uri = cString::sprintf("%s/%s", *streamUrlM, *rtspControlM);
transport = "RTP/AVP/TCP;unicast;interleaved=0-1";
if (isempty(*rtspControlM))
uri = cString::sprintf("%s", *streamUrlM);
else
uri = cString::sprintf("%s/%s", *streamUrlM, *rtspControlM);
if (streamParamM)
transport = "RTP/AVP/TCP;unicast;interleaved=0-1";
else
transport = cString::sprintf("RTP/AVP;unicast;client_port=%d-%d", streamPortM, streamPortM + 1);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_TRANSPORT, *transport);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_SETUP);
@ -304,18 +365,23 @@ bool cIptvProtocolCurl::Connect()
uri = cString::sprintf("%s/", *streamUrlM);
range = "0.000-";
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
iptv_curl_easy_setopt(handleM, CURLOPT_RANGE, *range);
//iptv_curl_easy_setopt(handleM, CURLOPT_RANGE, *range);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
iptv_curl_easy_perform(handleM);
// Start receiving
iptv_curl_easy_setopt(handleM, CURLOPT_INTERLEAVEFUNCTION, cIptvProtocolCurl::WriteRtspCallback);
iptv_curl_easy_setopt(handleM, CURLOPT_INTERLEAVEDATA, this);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_RECEIVE);
iptv_curl_easy_perform(handleM);
if (streamParamM) {
iptv_curl_easy_setopt(handleM, CURLOPT_INTERLEAVEFUNCTION, cIptvProtocolCurl::WriteRtspCallback);
iptv_curl_easy_setopt(handleM, CURLOPT_INTERLEAVEDATA, this);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_RECEIVE);
iptv_curl_easy_perform(handleM);
}
// Don't add handle into multi set
isActiveM = true;
}
break;
#endif
case eModeHttp:
case eModeHttps:
{
@ -334,18 +400,34 @@ bool cIptvProtocolCurl::Connect()
headerListM = curl_slist_append(headerListM, "Pragma: no-cache");
headerListM = curl_slist_append(headerListM, "Expires: Mon, 26 Jul 1997 05:00:00 GMT");
iptv_curl_easy_setopt(handleM, CURLOPT_HTTPHEADER, headerListM);
// Initialize multi set and add handle into it
if (!multiM)
multiM = curl_multi_init();
if (multiM)
curl_multi_add_handle(multiM, handleM);
}
break;
case eModeFile:
{
// Set timeout
iptv_curl_easy_setopt(handleM, CURLOPT_TIMEOUT_MS, 10L);
// Initialize multi set and add handle into it
if (!multiM)
multiM = curl_multi_init();
if (multiM)
curl_multi_add_handle(multiM, handleM);
}
break;
case eModeUnknown:
default:
break;
}
// Add handle into multi set
curl_multi_add_handle(multiM, handleM);
timeoutM.Set(eKeepAliveIntervalMs);
connectedM = true;
return true;
}
@ -356,14 +438,22 @@ bool cIptvProtocolCurl::Connect()
bool cIptvProtocolCurl::Disconnect()
{
cMutexLock MutexLock(&mutexM);
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
if (!connectedM)
return true;
// Terminate curl session
if (handleM && multiM) {
if (handleM) {
// Remove handle from multi set
if (multiM) {
curl_multi_remove_handle(multiM, handleM);
curl_multi_cleanup(multiM);
multiM = NULL;
}
// Mode specific tricks
switch (modeM) {
#ifdef USE_RTSP
case eModeRtsp:
{
CURLcode res = CURLE_OK;
@ -373,9 +463,12 @@ bool cIptvProtocolCurl::Disconnect()
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_TEARDOWN);
iptv_curl_easy_perform(handleM);
rtspControlM = "";
isActiveM = false;
// Close the listening socket
CloseSocket();
}
break;
#endif
case eModeHttp:
case eModeHttps:
case eModeFile:
@ -389,11 +482,8 @@ bool cIptvProtocolCurl::Disconnect()
curl_slist_free_all(headerListM);
headerListM = NULL;
}
curl_multi_remove_handle(multiM, handleM);
curl_easy_cleanup(handleM);
handleM = NULL;
curl_multi_cleanup(multiM);
multiM = NULL;
}
ClearData();
@ -403,71 +493,87 @@ bool cIptvProtocolCurl::Disconnect()
bool cIptvProtocolCurl::Open(void)
{
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
return Connect();
}
bool cIptvProtocolCurl::Close(void)
{
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
Disconnect();
return true;
}
int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
{
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
int len = 0;
if (ringBufferM) {
// Fill up the buffer
if (handleM && multiM) {
if (handleM) {
switch (modeM) {
#ifdef USE_RTSP
case eModeRtsp:
{
cMutexLock MutexLock(&mutexM);
CURLcode res = CURLE_OK;
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_RECEIVE);
iptv_curl_easy_perform(handleM);
// @todo - How to detect eof?
// Remember the heart beat
if (timeoutM.TimedOut()) {
debug1("%s KeepAlive", __PRETTY_FUNCTION__);
cString uri = cString::sprintf("%s", *streamUrlM);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
iptv_curl_easy_perform(handleM);
timeoutM.Set(eKeepAliveIntervalMs);
}
// Check whether UDP or TCP mode used
if (streamParamM) {
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_RECEIVE);
iptv_curl_easy_perform(handleM);
}
else
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
}
break;
#endif
case eModeFile:
case eModeHttp:
case eModeHttps:
{
CURLMcode res;
int running_handles;
if (multiM) {
CURLMcode res;
int running_handles;
do {
cMutexLock MutexLock(&mutexM);
res = curl_multi_perform(multiM, &running_handles);
} while (res == CURLM_CALL_MULTI_PERFORM);
do {
cMutexLock MutexLock(&mutexM);
res = curl_multi_perform(multiM, &running_handles);
} while (res == CURLM_CALL_MULTI_PERFORM);
// Shall we continue filling up the buffer?
mutexM.Lock();
if (pausedM && (ringBufferM->Free() > ringBufferM->Available())) {
debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__,
ringBufferM->Free(), ringBufferM->Available());
pausedM = false;
curl_easy_pause(handleM, CURLPAUSE_CONT);
}
mutexM.Unlock();
// Check if end of file
if (running_handles == 0) {
int msgcount;
// Use 20% threshold before continuing to filling up the buffer.
mutexM.Lock();
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
if (pausedM && (ringBufferM->Available() < (IPTV_BUFFER_SIZE / 5))) {
debug1("%s Continue free=%d available=%d", __PRETTY_FUNCTION__,
ringBufferM->Free(), ringBufferM->Available());
pausedM = false;
curl_easy_pause(handleM, CURLPAUSE_CONT);
}
mutexM.Unlock();
if (msg && (msg->msg == CURLMSG_DONE)) {
debug("cIptvProtocolCurl::%s(done): %s (%d)", __FUNCTION__,
curl_easy_strerror(msg->data.result), msg->data.result);
Disconnect();
Connect();
// Check if end of file
if (running_handles == 0) {
int msgcount;
mutexM.Lock();
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
mutexM.Unlock();
if (msg && (msg->msg == CURLMSG_DONE)) {
debug1("%s Done %s (%d)", __PRETTY_FUNCTION__,
curl_easy_strerror(msg->data.result), msg->data.result);
Disconnect();
Connect();
}
}
}
}
break;
case eModeUnknown:
@ -482,16 +588,16 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
len = min(len, (int)bufferLenP);
memcpy(bufferAddrP, p, len);
DelData(len);
//debug("cIptvProtocolCurl::%s(): get %d bytes", __FUNCTION__, len);
debug16("%s Get %d bytes", __PRETTY_FUNCTION__, len);
}
}
return len;
}
bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const int indexP)
bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug("cIptvProtocolCurl::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Disconnect
Disconnect();
@ -508,17 +614,25 @@ bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const i
modeM = eModeFile;
else
modeM = eModeUnknown;
debug("cIptvProtocolCurl::%s(): %s (%d)", __FUNCTION__, *protocol, modeM);
// Update stream parameter
streamParamM = parameterP;
debug1("%s (%s, %d, %d) protocol=%s mode=%d", __PRETTY_FUNCTION__, locationP, parameterP, indexP, *protocol, modeM);
// Update stream parameter - force UDP mode for RTSP
streamParamM = (modeM == eModeRtsp) ? 0 : parameterP;
// Update listen port
streamPortM = IptvConfig.GetProtocolBasePort() + indexP * 2;
// Reconnect
Connect();
}
return true;
}
bool cIptvProtocolCurl::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolCurl::GetInformation(void)
{
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
}

View File

@ -16,8 +16,9 @@
#include <vdr/tools.h>
#include "protocolif.h"
#include "socket.h"
class cIptvProtocolCurl : public cIptvProtocolIf {
class cIptvProtocolCurl : public cIptvUdpSocket, public cIptvProtocolIf {
private:
enum eModeType {
eModeUnknown = 0,
@ -28,10 +29,14 @@ private:
eModeCount
};
enum {
eConnectTimeoutS = 5, // in seconds
eMaxDownloadSpeedMBits = 20 // in megabits per second
eConnectTimeoutS = 5, // in seconds
eLowSpeedTimeoutS = 3, // in seconds
eLowSpeedLimitBytes = 100, // in bytes per second
eMaxDownloadSpeedMBits = 20, // in megabits per second
eKeepAliveIntervalMs = 300000 // in milliseconds
};
static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP);
static size_t WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
static size_t WriteRtspCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
static size_t DescribeCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
@ -39,6 +44,7 @@ private:
cString streamUrlM;
int streamParamM;
int streamPortM;
cMutex mutexM;
CURL *handleM;
CURLM *multiM;
@ -46,6 +52,7 @@ private:
cRingBufferLinear *ringBufferM;
cString rtspControlM;
eModeType modeM;
cTimeMs timeoutM;
bool connectedM;
bool pausedM;
@ -60,7 +67,8 @@ public:
cIptvProtocolCurl();
virtual ~cIptvProtocolCurl();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool Set(const char* locationP, const int parameterP, const int indexP);
bool SetSource(const char* locationP, const int parameterP, const int indexP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);

View File

@ -17,6 +17,7 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolext.h"
#ifndef EXTSHELL
@ -29,19 +30,19 @@ cIptvProtocolExt::cIptvProtocolExt()
scriptParameterM(0),
streamPortM(0)
{
debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvProtocolExt::~cIptvProtocolExt()
{
debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Drop the socket connection
cIptvProtocolExt::Close();
}
void cIptvProtocolExt::ExecuteScript(void)
{
debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check if already executing
if (isActiveM || isempty(scriptFileM))
return;
@ -59,7 +60,7 @@ void cIptvProtocolExt::ExecuteScript(void)
close(i);
// Execute the external script
cString cmd = cString::sprintf("%s %d %d", *scriptFileM, scriptParameterM, streamPortM);
debug("cIptvProtocolExt::%s(child): %s", __FUNCTION__, *cmd);
debug1("%s Child %s", __PRETTY_FUNCTION__, *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) {
@ -69,13 +70,13 @@ void cIptvProtocolExt::ExecuteScript(void)
_exit(0);
}
else {
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM);
}
}
void cIptvProtocolExt::TerminateScript(void)
{
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM);
if (!isActiveM || isempty(scriptFileM))
return;
if (pidM > 0) {
@ -111,7 +112,7 @@ void cIptvProtocolExt::TerminateScript(void)
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pidM) &&
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
#endif // __FreeBSD__
debug("cIptvProtocolExt::%s(): child (%d) exited as expected", __FUNCTION__, pidM);
debug1("%s Child (%d) exited as expected", __PRETTY_FUNCTION__, pidM);
waitOver = true;
}
// Unsuccessful wait, avoid busy looping
@ -124,7 +125,7 @@ void cIptvProtocolExt::TerminateScript(void)
bool cIptvProtocolExt::Open(void)
{
debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Reject empty script files
if (!strlen(*scriptFileM))
return false;
@ -138,7 +139,7 @@ bool cIptvProtocolExt::Open(void)
bool cIptvProtocolExt::Close(void)
{
debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Terminate the external script
TerminateScript();
isActiveM = false;
@ -152,26 +153,32 @@ int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
}
bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const int indexP)
bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug("cIptvProtocolExt::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
struct stat stbuf;
// Update script file and parameter
scriptFileM = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), locationP);
scriptFileM = cString::sprintf("%s/%s", IptvConfig.GetResourceDirectory(), locationP);
if ((stat(*scriptFileM, &stbuf) != 0) || (strstr(*scriptFileM, "..") != 0)) {
error("Non-existent or relative path script '%s'", *scriptFileM);
return false;
}
scriptParameterM = parameterP;
// Update listen port
streamPortM = IptvConfig.GetExtProtocolBasePort() + indexP;
streamPortM = IptvConfig.GetProtocolBasePort() + indexP * 2;
}
return true;
}
bool cIptvProtocolExt::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolExt::GetInformation(void)
{
//debug("cIptvProtocolExt::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM);
}

View File

@ -27,7 +27,8 @@ public:
cIptvProtocolExt();
virtual ~cIptvProtocolExt();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool Set(const char* locationP, const int parameterP, const int indexP);
bool SetSource(const char* locationP, const int parameterP, const int indexP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);

View File

@ -12,6 +12,7 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile()
@ -20,12 +21,12 @@ cIptvProtocolFile::cIptvProtocolFile()
fileStreamM(NULL),
isActiveM(false)
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvProtocolFile::~cIptvProtocolFile()
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Drop open handles
cIptvProtocolFile::Close();
// Free allocated memory
@ -34,7 +35,7 @@ cIptvProtocolFile::~cIptvProtocolFile()
bool cIptvProtocolFile::OpenFile(void)
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check that stream address is valid
if (!isActiveM && !isempty(fileLocationM)) {
fileStreamM = fopen(fileLocationM, "rb");
@ -47,7 +48,7 @@ bool cIptvProtocolFile::OpenFile(void)
void cIptvProtocolFile::CloseFile(void)
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check that file stream is valid
if (isActiveM && !isempty(fileLocationM)) {
fclose(fileStreamM);
@ -58,10 +59,10 @@ void cIptvProtocolFile::CloseFile(void)
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
{
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
// Check errors
if (ferror(fileStreamM)) {
debug("cIptvProtocolFile::%s(): stream error", __FUNCTION__);
if (!fileStreamM || ferror(fileStreamM)) {
debug1("%s (, %d) Stream error", __PRETTY_FUNCTION__, bufferLenP);
return -1;
}
// Rewind if EOF
@ -81,7 +82,7 @@ int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolFile::Open(void)
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Open the file stream
OpenFile();
return true;
@ -89,15 +90,15 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void)
{
debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Close the file stream
CloseFile();
return true;
}
bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const int indexP)
bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug("cIptvProtocolFile::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Close the file stream
CloseFile();
@ -110,8 +111,14 @@ bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const i
return true;
}
bool cIptvProtocolFile::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolFile::GetInformation(void)
{
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
}

View File

@ -26,7 +26,8 @@ public:
cIptvProtocolFile();
virtual ~cIptvProtocolFile();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool Set(const char* locationP, const int parameterP, const int indexP);
bool SetSource(const char* locationP, const int parameterP, const int indexP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);

View File

@ -16,6 +16,7 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp()
@ -23,12 +24,12 @@ cIptvProtocolHttp::cIptvProtocolHttp()
streamPathM(strdup("/")),
streamPortM(0)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvProtocolHttp::~cIptvProtocolHttp()
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Close the socket
cIptvProtocolHttp::Close();
// Free allocated memory
@ -38,7 +39,7 @@ cIptvProtocolHttp::~cIptvProtocolHttp()
bool cIptvProtocolHttp::Connect(void)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check that stream address is valid
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) {
// Ensure that socket is valid and connect
@ -56,7 +57,7 @@ bool cIptvProtocolHttp::Connect(void)
"\r\n", streamPathM, streamAddrM,
PLUGIN_NAME_I18N, VERSION);
unsigned int len = strlen(*buffer);
debug("cIptvProtocolHttp::%s(): requesting %d: %s", __FUNCTION__, len, *buffer);
debug1("%s Requesting %d: %s", __PRETTY_FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) {
CloseSocket();
return false;
@ -74,7 +75,7 @@ bool cIptvProtocolHttp::Connect(void)
bool cIptvProtocolHttp::Disconnect(void)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
if (isActiveM) {
// Close the socket
CloseSocket();
@ -87,7 +88,7 @@ bool cIptvProtocolHttp::Disconnect(void)
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
unsigned int &recvLenP)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s (, %u, )", __PRETTY_FUNCTION__, destLenP);
bool linefeed = false;
bool newline = false;
char *bufptr = destP;
@ -113,13 +114,13 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
++bufptr;
// Check that buffer won't be exceeded
if (recvLenP >= destLenP) {
error("Header wouldn't fit into buffer\n");
error("Header wouldn't fit into buffer");
recvLenP = 0;
return false;
}
}
else {
error("No HTTP response received in 500ms\n");
error("No HTTP response received in 500ms");
return false;
}
}
@ -128,7 +129,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
bool cIptvProtocolHttp::ProcessHeaders(void)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
unsigned int lineLength = 0;
int version = 0, response = 0;
bool responseFound = false;
@ -143,14 +144,14 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
return false;
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
error("Expected HTTP header not found\n");
error("Expected HTTP header not found");
continue;
}
else
responseFound = true;
// Allow only 'OK' and 'Partial Content'
if ((response != 200) && (response != 206)) {
error("Invalid HTTP response (%d): %s\n", response, buf);
error("Invalid HTTP response (%d): %s", response, buf);
return false;
}
}
@ -159,14 +160,14 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
bool cIptvProtocolHttp::Open(void)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Connect the socket
return Connect();
}
bool cIptvProtocolHttp::Close(void)
{
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Disconnect the current stream
Disconnect();
return true;
@ -177,9 +178,9 @@ int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
return cIptvTcpSocket::Read(bufferAddrP, bufferLenP);
}
bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const int indexP)
bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug("cIptvProtocolHttp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Disconnect the current socket
Disconnect();
@ -199,8 +200,14 @@ bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const i
return true;
}
bool cIptvProtocolHttp::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolHttp::GetInformation(void)
{
//debug("cIptvProtocolHttp::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
}

View File

@ -28,7 +28,8 @@ public:
cIptvProtocolHttp();
virtual ~cIptvProtocolHttp();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool Set(const char* locationP, const int parameterP, const int indexP);
bool SetSource(const char* locationP, const int parameterP, const int indexP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);

View File

@ -13,7 +13,8 @@ public:
cIptvProtocolIf() {}
virtual ~cIptvProtocolIf() {}
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP) = 0;
virtual bool Set(const char* locationP, const int parameterP, const int indexP) = 0;
virtual bool SetSource(const char* locationP, const int parameterP, const int indexP) = 0;
virtual bool SetPid(int pidP, int typeP, bool onP) = 0;
virtual bool Open(void) = 0;
virtual bool Close(void) = 0;
virtual cString GetInformation(void) = 0;

View File

@ -15,8 +15,9 @@
#include "common.h"
#include "config.h"
#include "protocoludp.h"
#include "log.h"
#include "socket.h"
#include "protocoludp.h"
cIptvProtocolUdp::cIptvProtocolUdp()
: isIGMPv3M(false),
@ -24,12 +25,12 @@ cIptvProtocolUdp::cIptvProtocolUdp()
streamAddrM(strdup("")),
streamPortM(0)
{
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvProtocolUdp::~cIptvProtocolUdp()
{
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Drop the multicast group and close the socket
cIptvProtocolUdp::Close();
// Free allocated memory
@ -39,7 +40,7 @@ cIptvProtocolUdp::~cIptvProtocolUdp()
bool cIptvProtocolUdp::Open(void)
{
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
if (!isempty(streamAddrM)) {
// Join a new multicast group
@ -50,7 +51,7 @@ bool cIptvProtocolUdp::Open(void)
bool cIptvProtocolUdp::Close(void)
{
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
if (!isempty(streamAddrM)) {
// Drop the multicast group
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
@ -70,9 +71,9 @@ int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
}
bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const int indexP)
bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug("cIptvProtocolUdp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Drop the multicast group
if (!isempty(streamAddrM)) {
@ -103,9 +104,15 @@ bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const in
return true;
}
bool cIptvProtocolUdp::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolUdp::GetInformation(void)
{
//debug("cIptvProtocolUdp::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
if (isIGMPv3M)
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);

View File

@ -23,7 +23,8 @@ public:
cIptvProtocolUdp();
virtual ~cIptvProtocolUdp();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool Set(const char* locationP, const int parameterP, const int indexP);
bool SetSource(const char* locationP, const int parameterP, const int indexP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);

View File

@ -6,6 +6,7 @@
*/
#include "config.h"
#include "log.h"
#include "sectionfilter.h"
cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP)
@ -17,9 +18,10 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
secLenM(0),
tsFeedpM(0),
pidM(pidP),
devIdM(deviceIndexP)
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)),
deviceIndexM(deviceIndexP)
{
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int i;
memset(secBufBaseM, 0, sizeof(secBufBaseM));
@ -33,11 +35,11 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
filterMaskM[0] = maskP;
// Invert the filter
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i)
for (i = 0; i < eDmxMaxFilterSize; ++i)
filterValueM[i] ^= 0xFF;
uint8_t mask, mode, doneq = 0;
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
for (i = 0; i < eDmxMaxFilterSize; ++i) {
mode = filterModeM[i];
mask = filterMaskM[i];
maskAndModeM[i] = (uint8_t)(mask & mode);
@ -46,30 +48,31 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
}
doneqM = doneq ? 1 : 0;
// Create filtering buffer
ringbufferM = new cRingBufferLinear(KILOBYTE(128), 0, false, *cString::sprintf("IPTV SECTION %d/%d", devIdM, pidM));
if (ringbufferM)
ringbufferM->SetTimeouts(10, 10);
else
error("Failed to allocate buffer for section filter (device=%d pid=%d): ", devIdM, pidM);
// Create sockets
socketM[0] = socketM[1] = -1;
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketM) != 0) {
char tmp[64];
error("Opening section filter sockets failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp)));
}
else if ((fcntl(socketM[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socketM[1], F_SETFL, O_NONBLOCK) != 0)) {
char tmp[64];
error("Setting section filter socket to non-blocking mode failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp)));
}
}
cIptvSectionFilter::~cIptvSectionFilter()
{
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
DELETE_POINTER(ringbufferM);
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int tmp = socketM[1];
socketM[1] = -1;
if (tmp >= 0)
close(tmp);
tmp = socketM[0];
socketM[0] = -1;
if (tmp >= 0)
close(tmp);
secBufM = NULL;
}
int cIptvSectionFilter::Read(void *Data, size_t Length)
{
int count = 0;
uchar *p = ringbufferM->Get(count);
if (p && count > 0) {
memcpy(Data, p, count);
ringbufferM->Del(count);
}
return count;
DELETENULL(ringBufferM);
}
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *dataP)
@ -89,7 +92,7 @@ int cIptvSectionFilter::Filter(void)
int i;
uint8_t neq = 0;
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
for (i = 0; i < eDmxMaxFilterSize; ++i) {
uint8_t calcxor = (uint8_t)(filterValueM[i] ^ secBufM[i]);
if (maskAndModeM[i] & calcxor)
return 0;
@ -99,13 +102,8 @@ int cIptvSectionFilter::Filter(void)
if (doneqM && !neq)
return 0;
if (ringbufferM) {
int len = ringbufferM->Put(secBufM, secLenM);
if (len != secLenM)
ringbufferM->ReportOverflow(secLenM - len);
// Update statistics
AddSectionStatistic(len, 1);
}
if (ringBufferM && (secLenM > 0))
ringBufferM->Put(new cFrame(secBufM, secLenM));
}
return 0;
}
@ -122,11 +120,11 @@ int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
{
uint16_t limit, seclen, n;
if (tsFeedpM >= DMX_MAX_SECFEED_SIZE)
if (tsFeedpM >= eDmxMaxSectionFeedSize)
return 0;
if (tsFeedpM + lenP > DMX_MAX_SECFEED_SIZE)
lenP = (uint8_t)(DMX_MAX_SECFEED_SIZE - tsFeedpM);
if (tsFeedpM + lenP > eDmxMaxSectionFeedSize)
lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM);
if (lenP <= 0)
return 0;
@ -135,7 +133,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
tsFeedpM = uint16_t(tsFeedpM + lenP);
limit = tsFeedpM;
if (limit > DMX_MAX_SECFEED_SIZE)
if (limit > eDmxMaxSectionFeedSize)
return -1; // internal error should never happen
// Always set secbuf
@ -143,7 +141,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
for (n = 0; secBufpM + 2 < limit; ++n) {
seclen = GetLength(secBufM);
if ((seclen <= 0) || (seclen > DMX_MAX_SECTION_SIZE) || ((seclen + secBufpM) > limit))
if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit))
return 0;
secLenM = seclen;
if (pusiSeenM)
@ -210,3 +208,220 @@ void cIptvSectionFilter::Process(const uint8_t* dataP)
CopyDump(&dataP[p], count);
}
}
bool cIptvSectionFilter::Send(void)
{
bool result = false;
cFrame *section = ringBufferM->Get();
if (section) {
uchar *data = section->Data();
int count = section->Count();
if (data && (count > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) {
ssize_t len = send(socketM[1], data, count, MSG_EOR);
ERROR_IF(len < 0 && errno != EAGAIN, "send()");
if (len > 0) {
ringBufferM->Drop(section);
result = !!ringBufferM->Available();
// Update statistics
AddSectionStatistic(len, 1);
}
}
}
return result;
}
cIptvSectionFilterHandler::cIptvSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP)
: cThread("IPTV section handler"),
ringBufferM(new cRingBufferLinear(bufferLenP, TS_SIZE, false, *cString::sprintf("IPTV SECTION HANDLER %d", deviceIndexP))),
mutexM(),
deviceIndexM(deviceIndexP)
{
debug1("%s (%d, %d) [device %d]", __PRETTY_FUNCTION__, deviceIndexP, bufferLenP, deviceIndexM);
// Initialize filter pointers
memset(filtersM, 0, sizeof(filtersM));
// Create input buffer
if (ringBufferM) {
ringBufferM->SetTimeouts(100, 100);
ringBufferM->SetIoThrottle();
}
else
error("Failed to allocate buffer for section filter handler (device=%d): ", deviceIndexM);
Start();
}
cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop thread
if (Running())
Cancel(3);
DELETE_POINTER(ringBufferM);
// Destroy all filters
cMutexLock MutexLock(&mutexM);
for (int i = 0; i < eMaxSecFilterCount; ++i)
Delete(i);
}
void cIptvSectionFilterHandler::Action(void)
{
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
bool processed = false;
// Do the thread loop
while (Running()) {
// Send demuxed section packets through all filters
bool retry = false;
mutexM.Lock();
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && filtersM[i]->Send())
retry = true;
}
mutexM.Unlock();
if (retry)
continue;
// Read one TS packet
if (ringBufferM) {
int len = 0;
if (processed) {
ringBufferM->Del(TS_SIZE);
processed = false;
}
uchar *p = ringBufferM->Get(len);
if (p && (len >= TS_SIZE)) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < len; ++i) {
if (p[i] == TS_SYNC_BYTE) {
len = i;
break;
}
}
ringBufferM->Del(len);
debug1("%s Skipped %d bytes to sync on TS packet [device %d]]", __PRETTY_FUNCTION__, len, deviceIndexM);
continue;
}
// Process TS packet through all filters
mutexM.Lock();
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i])
filtersM[i]->Process(p);
}
mutexM.Unlock();
processed = true;
continue;
}
}
cCondWait::SleepMs(10); // to avoid busy loop and reduce cpu load
}
debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
}
cString cIptvSectionFilterHandler::GetInformation(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// loop through active section filters
cMutexLock MutexLock(&mutexM);
cString s = "";
unsigned int count = 0;
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i]) {
s = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *s, i,
*filtersM[i]->GetSectionStatistic(), filtersM[i]->GetPid(),
id_pid(filtersM[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
}
}
return s;
}
bool cIptvSectionFilterHandler::Delete(unsigned int indexP)
{
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
if ((indexP < eMaxSecFilterCount) && filtersM[indexP]) {
debug16("%s (%d) Found [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
cIptvSectionFilter *tmp = filtersM[indexP];
filtersM[indexP] = NULL;
delete tmp;
return true;
}
return false;
}
bool cIptvSectionFilterHandler::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
{
debug16("%s (%d, %02X, %02X) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
// loop through section filter table
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
int index = IptvConfig.GetDisabledFilters(i);
// Check if matches
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
(section_filter_table[index].mask == maskP)) {
debug16("%s (%d, %02X, %02X) Found %s [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, section_filter_table[index].description, deviceIndexM);
return true;
}
}
return false;
}
int cIptvSectionFilterHandler::Open(u_short pidP, u_char tidP, u_char maskP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Blacklist check, refuse certain filters
if (IsBlackListed(pidP, tidP, maskP))
return -1;
// Search the next free filter slot
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!filtersM[i]) {
filtersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
debug16("%s (%d, %02X, %02X) handle=%d index=%u [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetFd();
}
}
// No free filter slot found
return -1;
}
void cIptvSectionFilterHandler::Close(int handleP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Search the filter for deletion
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
Delete(i);
break;
}
}
}
int cIptvSectionFilterHandler::GetPid(int handleP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Search the filter for data
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetPid();
}
}
return -1;
}
void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP)
{
debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
// Fill up the buffer
if (ringBufferM) {
int len = ringBufferM->Put(bufferP, lengthP);
if (len != lengthP)
ringBufferM->ReportOverflow(lengthP - len);
}
}

View File

@ -18,10 +18,11 @@
class cIptvSectionFilter : public cIptvSectionStatistics {
private:
enum dmx_limits {
DMX_MAX_FILTER_SIZE = 18,
DMX_MAX_SECTION_SIZE = 4096,
DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE)
enum {
eDmxMaxFilterSize = 18,
eDmxMaxSectionCount = 64,
eDmxMaxSectionSize = 4096,
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
};
int pusiSeenM;
@ -29,22 +30,22 @@ private:
int doneqM;
uint8_t *secBufM;
uint8_t secBufBaseM[DMX_MAX_SECFEED_SIZE];
uint8_t secBufBaseM[eDmxMaxSectionFeedSize];
uint16_t secBufpM;
uint16_t secLenM;
uint16_t tsFeedpM;
uint16_t pidM;
int devIdM;
cRingBufferFrame *ringBufferM;
int deviceIndexM;
int socketM[2];
uint8_t filterValueM[DMX_MAX_FILTER_SIZE];
uint8_t filterMaskM[DMX_MAX_FILTER_SIZE];
uint8_t filterModeM[DMX_MAX_FILTER_SIZE];
uint8_t filterValueM[eDmxMaxFilterSize];
uint8_t filterMaskM[eDmxMaxFilterSize];
uint8_t filterModeM[eDmxMaxFilterSize];
uint8_t maskAndModeM[DMX_MAX_FILTER_SIZE];
uint8_t maskAndNotModeM[DMX_MAX_FILTER_SIZE];
cRingBufferLinear *ringbufferM;
uint8_t maskAndModeM[eDmxMaxFilterSize];
uint8_t maskAndNotModeM[eDmxMaxFilterSize];
inline uint16_t GetLength(const uint8_t *dataP);
void New(void);
@ -57,8 +58,35 @@ public:
cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
virtual ~cIptvSectionFilter();
void Process(const uint8_t* dataP);
int Read(void *bufferP, size_t lengthP);
bool Send(void);
int GetFd(void) { return socketM[0]; }
uint16_t GetPid(void) const { return pidM; }
};
class cIptvSectionFilterHandler : public cThread {
private:
enum {
eMaxSecFilterCount = 32
};
cRingBufferLinear *ringBufferM;
cMutex mutexM;
int deviceIndexM;
cIptvSectionFilter *filtersM[eMaxSecFilterCount];
bool Delete(unsigned int indexP);
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
protected:
virtual void Action(void);
public:
cIptvSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP);
virtual ~cIptvSectionFilterHandler();
cString GetInformation(void);
int Open(u_short pidP, u_char tidP, u_char maskP);
void Close(int handleP);
int GetPid(int handleP);
void Write(u_char *bufferP, int lengthP);
};
#endif // __IPTV_SECTIONFILTER_H

36
setup.c
View File

@ -112,10 +112,8 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
cIptvPluginSetup::cIptvPluginSetup()
{
debug("cIptvPluginSetup::%s()", __FUNCTION__);
tsBufferSizeM = IptvConfig.GetTsBufferSize();
tsBufferPrefillM = IptvConfig.GetTsBufferPrefillRatio();
extProtocolBasePortM = IptvConfig.GetExtProtocolBasePort();
debug1("%s", __PRETTY_FUNCTION__);
protocolBasePortM = IptvConfig.GetProtocolBasePort();
sectionFilteringM = IptvConfig.GetSectionFiltering();
numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount();
if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE)
@ -124,6 +122,7 @@ cIptvPluginSetup::cIptvPluginSetup()
disabledFilterIndexesM[i] = IptvConfig.GetDisabledFilters(i);
disabledFilterNamesM[i] = tr(section_filter_table[i].description);
}
SetMenuCategory(mcSetupPlugins);
Setup();
SetHelp(NULL, NULL, NULL, trVDR("Button$Info"));
}
@ -135,25 +134,18 @@ void cIptvPluginSetup::Setup(void)
Clear();
helpM.Clear();
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSizeM, 1, 4));
helpM.Append(tr("Define a ringbuffer size for transport streams in megabytes.\n\nSmaller sizes help memory consumption, but are more prone to buffer overflows."));
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefillM, 0, 40));
helpM.Append(tr("Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n\nThis is useful if streaming media over a slow or unreliable connection."));
Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePortM, 0, 0xFFF7));
helpM.Append(tr("Define a base port used by EXT protocol.\n\nThe 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."));
Add(new cMenuEditIntItem(tr("Protocol base port"), &protocolBasePortM, 0, 0xFFFF - MAXDEVICES * 2));
helpM.Append(tr("Define a base port used by CURL/EXT protocol.\n\nThe 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 CURL/EXT protocol."));
Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFilteringM));
helpM.Append(tr("Define whether the section filtering shall be used.\n\nSection 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.\nEnabling this feature does not affect streams that do not contain section data."));
if (sectionFilteringM) {
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE));
Add(new cMenuEditIntItem(tr("Disabled filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE));
helpM.Append(tr("Define number of section filters to be disabled.\n\nCertain 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."));
for (int i = 0; i < numDisabledFiltersM; ++i) {
// TRANSLATORS: note the singular!
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM));
Add(new cMenuEditStraItem(*cString::sprintf(" %s %d", tr("Filter"), i + 1), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM));
helpM.Append(tr("Define an ill-behaving filter to be blacklisted."));
}
}
@ -164,7 +156,7 @@ void cIptvPluginSetup::Setup(void)
eOSState cIptvPluginSetup::ShowInfo(void)
{
debug("cIptvPluginSetup::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuInfo());
@ -200,7 +192,7 @@ void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP)
char *q = buffer;
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
char s[3];
if (valuesP[i] < 0)
if ((valuesP[i] < 0) || (valuesP[i] >= SECTION_FILTER_TABLE_SIZE))
break;
if (q > buffer)
*q++ = ' ';
@ -209,22 +201,18 @@ void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP)
q += strlen(s);
}
*q = 0;
debug("cIptvPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, buffer);
debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, buffer);
SetupStore(nameP, buffer);
}
void cIptvPluginSetup::Store(void)
{
// Store values into setup.conf
SetupStore("TsBufferSize", tsBufferSizeM);
SetupStore("TsBufferPrefill", tsBufferPrefillM);
SetupStore("ExtProtocolBasePort", extProtocolBasePortM);
SetupStore("ExtProtocolBasePort", protocolBasePortM);
SetupStore("SectionFiltering", sectionFilteringM);
StoreFilters("DisabledFilters", disabledFilterIndexesM);
// Update global config
IptvConfig.SetTsBufferSize(tsBufferSizeM);
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefillM);
IptvConfig.SetExtProtocolBasePort(extProtocolBasePortM);
IptvConfig.SetProtocolBasePort(protocolBasePortM);
IptvConfig.SetSectionFiltering(sectionFilteringM);
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
IptvConfig.SetDisabledFilters(i, disabledFilterIndexesM[i]);

View File

@ -15,9 +15,7 @@
class cIptvPluginSetup : public cMenuSetupPage
{
private:
int tsBufferSizeM;
int tsBufferPrefillM;
int extProtocolBasePortM;
int protocolBasePortM;
int sectionFilteringM;
int numDisabledFiltersM;
int disabledFilterIndexesM[SECTION_FILTER_TABLE_SIZE];

View File

@ -17,19 +17,19 @@ cSidScanner::cSidScanner(void)
tidFoundM(false),
isActiveM(false)
{
debug("cSidScanner::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
Set(0x00, 0x00); // PAT
Set(0x10, 0x40); // NIT
}
cSidScanner::~cSidScanner()
{
debug("cSidScanner::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
void cSidScanner::SetChannel(const tChannelID &channelIdP)
{
debug("cSidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString());
channelIdM = channelIdP;
sidFoundM = false;
nidFoundM = false;
@ -40,12 +40,12 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
{
int newSid = -1, newNid = -1, newTid = -1;
//debug("cSidScanner::%s()", __FUNCTION__);
debug16("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
if (!isActiveM)
return;
if (channelIdM.Valid()) {
if ((pidP == 0x00) && (tidP == 0x00)) {
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
debug16("%s (%d, %02X, , %d) pat", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::PAT pat(dataP, false);
if (!pat.CheckCRCAndParse())
return;
@ -53,7 +53,7 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channelIdM.Sid()) {
debug("cSidScanner::%s(): sid=%d", __FUNCTION__, assoc.getServiceId());
debug1("%s (%d, %02X, , %d) sid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, assoc.getServiceId());
newSid = assoc.getServiceId();
}
sidFoundM = true;
@ -62,34 +62,44 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
}
}
else if ((pidP == 0x10) && (tidP == 0x40)) {
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
debug1("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::NIT nit(dataP, false);
if (!nit.CheckCRCAndParse())
return;
SI::NIT::TransportStream ts;
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
if (ts.getTransportStreamId() != channelIdM.Tid()) {
debug("cSidScanner::%s(): tsid=%d", __FUNCTION__, ts.getTransportStreamId());
debug1("%s (%d, %02X, , %d) tsid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getTransportStreamId());
newTid = ts.getTransportStreamId();
tidFoundM = true;
}
if (ts.getOriginalNetworkId() != channelIdM.Nid()) {
debug1("%s (%d, %02X, , %d) onid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getOriginalNetworkId());
newNid = ts.getOriginalNetworkId();
nidFoundM = true;
}
tidFoundM = true;
break; // default to the first one
}
if (nit.getNetworkId() != channelIdM.Nid()) {
debug("cSidScanner::%s(): nid=%d\n", __FUNCTION__, ts.getTransportStreamId());
// fallback for network id if not found already
if (!nidFoundM && (nit.getNetworkId() != channelIdM.Nid())) {
debug1("%s (%d, %02X, , %d) nid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, nit.getNetworkId());
newNid = nit.getNetworkId();
nidFoundM = true;
}
nidFoundM = true;
}
}
if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) {
if (!Channels.Lock(true, 10))
cStateKey StateKey;
cChannels *Channels = cChannels::GetChannelsWrite(StateKey, 10);
if (!Channels)
return;
cChannel *IptvChannel = Channels.GetByChannelID(channelIdM);
bool ChannelsModified = false;
cChannel *IptvChannel = Channels->GetByChannelID(channelIdM);
if (IptvChannel)
IptvChannel->SetId((newNid < 0) ? IptvChannel->Nid() : newNid, (newTid < 0) ? IptvChannel->Tid() : newTid,
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
Channels.Unlock();
ChannelsModified |= IptvChannel->SetId(Channels, (newNid < 0) ? IptvChannel->Nid() : newNid,
(newTid < 0) ? IptvChannel->Tid() : newTid,
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
StateKey.Remove(ChannelsModified);
}
if (sidFoundM && nidFoundM && tidFoundM) {
SetChannel(tChannelID::InvalidID);

View File

@ -11,6 +11,8 @@
#include <vdr/channels.h>
#include <vdr/filter.h>
#include "log.h"
class cSidScanner : public cFilter {
private:
tChannelID channelIdM;
@ -26,8 +28,8 @@ public:
cSidScanner(void);
~cSidScanner();
void SetChannel(const tChannelID &channelIdP);
void Open() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = true; }
void Close() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = false; }
void Open() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = true; }
void Close() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = false; }
};
#endif // __SIDSCANNER_H

View File

@ -16,31 +16,35 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "socket.h"
cIptvSocket::cIptvSocket()
: socketPortM(0),
socketDescM(-1),
lastErrorReportM(0),
packetErrorsM(0),
sequenceNumberM(-1),
isActiveM(false)
{
debug("cIptvSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
memset(&sockAddrM, 0, sizeof(sockAddrM));
}
cIptvSocket::~cIptvSocket()
{
debug("cIptvSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Close the socket
CloseSocket();
}
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
{
debug("cIptvSocket::%s()", __FUNCTION__);
debug1("%s (%d, %d)", __PRETTY_FUNCTION__, portP, isUdpP);
// If socket is there already and it is bound to a different port, it must
// be closed first
if (portP != socketPortM) {
debug("cIptvSocket::%s(): socket tear-down", __FUNCTION__);
debug1("%s (%d, %d) Socket tear-down", __PRETTY_FUNCTION__, portP, isUdpP);
CloseSocket();
}
// Bind to the socket if it is not active already
@ -79,7 +83,7 @@ bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
void cIptvSocket::CloseSocket(void)
{
debug("cIptvSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists
if (socketDescM >= 0) {
close(socketDescM);
@ -87,15 +91,20 @@ void cIptvSocket::CloseSocket(void)
socketPortM = 0;
memset(&sockAddrM, 0, sizeof(sockAddrM));
}
if (packetErrorsM) {
info("Detected %d RTP packet errors", packetErrorsM);
packetErrorsM = 0;
lastErrorReportM = time(NULL);
}
}
bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
{
if (inAddrP) {
// First try only the IP address
*inAddrP = htonl(inet_addr(addrP));
*inAddrP = inet_addr(addrP);
if (*inAddrP == htonl(INADDR_NONE)) {
debug("cIptvSocket::%s(%s): cannot convert to address", __FUNCTION__, addrP);
debug1("%s (%s, ) Cannot convert to address", __PRETTY_FUNCTION__, addrP);
// It may be a host name, get the name
struct hostent *host = gethostbyname(addrP);
if (!host) {
@ -104,7 +113,7 @@ bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
*inAddrP = htonl(inet_addr(*host->h_addr_list));
*inAddrP = inet_addr(*host->h_addr_list);
}
return true;
}
@ -117,17 +126,17 @@ cIptvUdpSocket::cIptvUdpSocket()
sourceAddrM(htonl(INADDR_ANY)),
useIGMPv3M(false)
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvUdpSocket::~cIptvUdpSocket()
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
bool cIptvUdpSocket::OpenSocket(const int portP)
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s (%d)", __PRETTY_FUNCTION__, portP);
streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false;
@ -136,7 +145,7 @@ bool cIptvUdpSocket::OpenSocket(const int portP)
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
{
debug("cIptvUdpSocket::%s(%d, %s, %s, %d)", __FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
debug1("%s (%d, %s, %s, %d)", __PRETTY_FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
CheckAddress(streamAddrP, &streamAddrM);
CheckAddress(sourceAddrP, &sourceAddrM);
useIGMPv3M = useIGMPv3P;
@ -145,7 +154,7 @@ bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const
void cIptvUdpSocket::CloseSocket(void)
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false;
@ -154,7 +163,7 @@ void cIptvUdpSocket::CloseSocket(void)
bool cIptvUdpSocket::JoinMulticast(void)
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists
if (!isActiveM && (socketDescM >= 0)) {
// Join a new multicast group
@ -188,7 +197,7 @@ bool cIptvUdpSocket::JoinMulticast(void)
bool cIptvUdpSocket::DropMulticast(void)
{
debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists
if (isActiveM && (socketDescM >= 0)) {
// Drop the existing multicast group
@ -223,10 +232,10 @@ bool cIptvUdpSocket::DropMulticast(void)
int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{
//debug("cIptvUdpSocket::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("Invalid socket in cIptvUdpSocket::%s()\n", __FUNCTION__);
error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1;
}
int len = 0;
@ -274,6 +283,21 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
unsigned int cc = bufferAddrP[0] & 0x0F;
// Payload type: MPEG2 TS = 33
//unsigned int pt = bufferAddrP[1] & 0x7F;
// Sequence number
int seq = ((bufferAddrP[2] & 0xFF) << 8) | (bufferAddrP[3] & 0xFF);
if ((((sequenceNumberM + 1) % 0xFFFF) == 0) && (seq == 0xFFFF))
sequenceNumberM = -1;
else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) {
packetErrorsM++;
if (time(NULL) - lastErrorReportM > eReportIntervalS) {
info("Detected %d RTP packet errors", packetErrorsM);
packetErrorsM = 0;
lastErrorReportM = time(NULL);
}
sequenceNumberM = seq;
}
else
sequenceNumberM = seq;
// Header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// Check if extension
@ -307,30 +331,30 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
// TCP socket class
cIptvTcpSocket::cIptvTcpSocket()
{
debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvTcpSocket::~cIptvTcpSocket()
{
debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP)
{
debug("cIptvTcpSocket::%s(%d, %s)", __FUNCTION__, portP, streamAddrP);
debug1("%s (%d, %s)", __PRETTY_FUNCTION__, portP, streamAddrP);
// Socket must be opened before setting the host address
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.sin_addr.s_addr));
}
void cIptvTcpSocket::CloseSocket(void)
{
debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug1("%s()", __PRETTY_FUNCTION__);
cIptvSocket::CloseSocket();
}
bool cIptvTcpSocket::ConnectSocket(void)
{
debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
if (!isActiveM && (socketDescM >= 0)) {
int retval = connect(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM));
// Non-blocking sockets always report in-progress error when connected
@ -356,10 +380,10 @@ bool cIptvTcpSocket::ConnectSocket(void)
int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1;
}
int len = 0;
@ -373,10 +397,10 @@ int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
{
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
error("%s Invalid socket", __PRETTY_FUNCTION__);
return false;
}
socklen_t addrlen = sizeof(sockAddrM);
@ -398,10 +422,10 @@ bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP)
{
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
error("%s Invalid socket", __PRETTY_FUNCTION__);
return false;
}
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false);

View File

@ -18,8 +18,14 @@ private:
int socketPortM;
protected:
enum {
eReportIntervalS = 300 // in seconds
};
int socketDescM;
struct sockaddr_in sockAddrM;
time_t lastErrorReportM;
int packetErrorsM;
int sequenceNumberM;
bool isActiveM;
protected:

View File

@ -6,7 +6,9 @@
*/
#include <ctype.h>
#include "common.h"
#include "log.h"
#include "source.h"
// --- cIptvTransponderParameters --------------------------------------------
@ -17,7 +19,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
protocolM(eProtocolUDP),
parameterM(0)
{
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, parametersP);
debug1("%s (%s)", __PRETTY_FUNCTION__, parametersP);
memset(&addressM, 0, sizeof(addressM));
Parse(parametersP);
@ -25,7 +27,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
cString cIptvTransponderParameters::ToString(char typeP) const
{
debug("cIptvTransponderParameters::%s(%c)", __FUNCTION__, typeP);
debug1("%s (%c)", __PRETTY_FUNCTION__, typeP);
const char *protocolstr;
@ -52,12 +54,13 @@ cString cIptvTransponderParameters::ToString(char typeP) const
bool cIptvTransponderParameters::Parse(const char *strP)
{
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, strP);
debug1("%s (%s)", __PRETTY_FUNCTION__, strP);
bool result = false;
if (strP && *strP) {
const char *delim = "|";
char *str = strdup(strP);
char *p = str;
char *saveptr = NULL;
char *token = NULL;
bool found_s = false;
@ -120,9 +123,9 @@ bool cIptvTransponderParameters::Parse(const char *strP)
if (found_s && found_p && found_f && found_u && found_a)
result = true;
else
error("Invalid channel parameters: %s\n", str);
error("Invalid channel parameters: %s", p);
free(str);
free(p);
}
return (result);
@ -135,13 +138,11 @@ const char *cIptvSourceParam::allowedProtocolCharsS = " abcdefghijklmnopqrstuvwx
cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
: cSourceParam(sourceP, descriptionP),
paramM(0),
nidM(0),
tidM(0),
ridM(0),
dataM(),
itpM()
{
debug("cIptvSourceParam::%s(%c, %s)", __FUNCTION__, sourceP, descriptionP);
debug1("%s (%c, %s)", __PRETTY_FUNCTION__, sourceP, descriptionP);
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL");
@ -152,10 +153,8 @@ cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
void cIptvSourceParam::SetData(cChannel *channelP)
{
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
dataM = *channelP;
nidM = dataM.Nid();
tidM = dataM.Tid();
ridM = dataM.Rid();
itpM.Parse(dataM.Parameters());
paramM = 0;
@ -163,23 +162,21 @@ void cIptvSourceParam::SetData(cChannel *channelP)
void cIptvSourceParam::GetData(cChannel *channelP)
{
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
channelP->SetId(nidM, tidM, channelP->Sid(), ridM);
channelP->SetId(NULL, channelP->Nid(), channelP->Tid(), channelP->Sid(), ridM);
}
cOsdItem *cIptvSourceParam::GetOsdItem(void)
{
debug("cIptvSourceParam::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
switch (paramM++) {
case 0: return new cMenuEditIntItem( tr("Nid"), &nidM, 0);
case 1: return new cMenuEditIntItem( tr("Tid"), &tidM, 0);
case 2: return new cMenuEditIntItem( tr("Rid"), &ridM, 0);
case 3: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM);
case 4: return new cMenuEditBoolItem(tr("Scan pids"), &itpM.pidScanM);
case 5: return new cMenuEditStraItem(tr("Protocol"), &itpM.protocolM, ELEMENTS(protocolsM), protocolsM);
case 6: return new cMenuEditStrItem( tr("Address"), itpM.addressM, sizeof(itpM.addressM), allowedProtocolCharsS);
case 7: return new cMenuEditIntItem( tr("Parameter"), &itpM.parameterM, 0, 0xFFFF);
case 0: return new cMenuEditIntItem( tr("Rid"), &ridM, 0);
case 1: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM);
case 2: return new cMenuEditBoolItem(tr("Scan pids"), &itpM.pidScanM);
case 3: return new cMenuEditStraItem(tr("Protocol"), &itpM.protocolM, ELEMENTS(protocolsM), protocolsM);
case 4: return new cMenuEditStrItem( tr("Address"), itpM.addressM, sizeof(itpM.addressM), allowedProtocolCharsS);
case 5: return new cMenuEditIntItem( tr("Parameter"), &itpM.parameterM, 0, 0xFFFF);
default: return NULL;
}
return NULL;

View File

@ -20,7 +20,7 @@ private:
int sidScanM;
int pidScanM;
int protocolM;
char addressM[NAME_MAX];
char addressM[NAME_MAX + 1];
int parameterM;
public:
@ -51,8 +51,6 @@ class cIptvSourceParam : public cSourceParam
{
private:
int paramM;
int nidM;
int tidM;
int ridM;
cChannel dataM;
cIptvTransponderParameters itpM;

View File

@ -8,8 +8,9 @@
#include <limits.h>
#include "common.h"
#include "statistics.h"
#include "config.h"
#include "log.h"
#include "statistics.h"
// Section statistics class
cIptvSectionStatistics::cIptvSectionStatistics()
@ -18,17 +19,17 @@ cIptvSectionStatistics::cIptvSectionStatistics()
timerM(),
mutexM()
{
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
}
cIptvSectionStatistics::~cIptvSectionStatistics()
{
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
}
cString cIptvSectionStatistics::GetSectionStatistic()
{
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
timerM.Set();
@ -44,7 +45,7 @@ cString cIptvSectionStatistics::GetSectionStatistic()
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
{
//debug("cIptvSectionStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, callsP);
debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, callsP);
cMutexLock MutexLock(&mutexM);
filteredDataM += bytesP;
numberOfCallsM += callsP;
@ -57,25 +58,30 @@ cIptvPidStatistics::cIptvPidStatistics()
: timerM(),
mutexM()
{
debug("cIptvPidStatistics::%s()", __FUNCTION__);
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
debug1("%s", __PRETTY_FUNCTION__);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
for (int i = 0; i < numberOfElements; ++i) {
mostActivePidsM[i].pid = -1;
mostActivePidsM[i].dataAmount = 0L;
}
}
cIptvPidStatistics::~cIptvPidStatistics()
{
debug("cIptvPidStatistics::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cString cIptvPidStatistics::GetPidStatistic()
{
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
timerM.Set();
cString s("Active pids:\n");
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
if (mostActivePidsM[i].pid) {
long bitrate = elapsed ? (long)(1000.0L * mostActivePidsM[i].DataAmount / KILOBYTE(1) / elapsed) : 0L;
for (int i = 0; i < numberOfElements; ++i) {
if (mostActivePidsM[i].pid >= 0) {
long bitrate = elapsed ? (long)(1000.0L * mostActivePidsM[i].dataAmount / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes())
bitrate *= 8;
s = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *s, i,
@ -83,31 +89,34 @@ cString cIptvPidStatistics::GetPidStatistic()
IptvConfig.GetUseBytes() ? "B" : "bit");
}
}
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
for (int i = 0; i < numberOfElements; ++i) {
mostActivePidsM[i].pid = -1;
mostActivePidsM[i].dataAmount = 0L;
}
return s;
}
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
{
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P);
const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P);
if (comp1->DataAmount > comp2->DataAmount)
if (comp1->dataAmount > comp2->dataAmount)
return -1;
if (comp1->DataAmount < comp2->DataAmount)
if (comp1->dataAmount < comp2->dataAmount)
return 1;
return 0;
}
void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
void cIptvPidStatistics::AddPidStatistic(int pidP, long payloadP)
{
//debug("cIptvPidStatistics::%s(%ld, %ld)", __FUNCTION__, pidP, payloadP);
debug16("%s (%d, %ld)", __PRETTY_FUNCTION__, pidP, payloadP);
cMutexLock MutexLock(&mutexM);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
// If our statistic already is in the array, update it and quit
for (int i = 0; i < numberOfElements; ++i) {
if (mostActivePidsM[i].pid == pidP) {
mostActivePidsM[i].DataAmount += payloadP;
mostActivePidsM[i].dataAmount += payloadP;
// Now re-sort the array and quit
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
return;
@ -115,9 +124,9 @@ void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
}
// Apparently our pid isn't in the array. Replace the last element with this
// one if new payload is greater
if (mostActivePidsM[numberOfElements - 1].DataAmount < payloadP) {
if (mostActivePidsM[numberOfElements - 1].dataAmount < payloadP) {
mostActivePidsM[numberOfElements - 1].pid = pidP;
mostActivePidsM[numberOfElements - 1].DataAmount = payloadP;
mostActivePidsM[numberOfElements - 1].dataAmount = payloadP;
// Re-sort
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
}
@ -131,17 +140,17 @@ cIptvStreamerStatistics::cIptvStreamerStatistics()
timerM(),
mutexM()
{
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvStreamerStatistics::~cIptvStreamerStatistics()
{
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cString cIptvStreamerStatistics::GetStreamerStatistic()
{
//debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
timerM.Set();
@ -155,7 +164,7 @@ cString cIptvStreamerStatistics::GetStreamerStatistic()
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
{
//debug("cIptvStreamerStatistics::%s(%ld)", __FUNCTION__, bytesP);
debug16("%s (%ld)", __PRETTY_FUNCTION__, bytesP);
cMutexLock MutexLock(&mutexM);
dataBytesM += bytesP;
}
@ -169,22 +178,22 @@ cIptvBufferStatistics::cIptvBufferStatistics()
timerM(),
mutexM()
{
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvBufferStatistics::~cIptvBufferStatistics()
{
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
}
cString cIptvBufferStatistics::GetBufferStatistic()
{
//debug("cIptvBufferStatistics::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
timerM.Set();
long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L;
long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
long totalSpace = IPTV_BUFFER_SIZE;
float percentage = (float)((float)usedSpaceM / (float)totalSpace * 100.0);
long totalKilos = totalSpace / KILOBYTE(1);
long usedKilos = usedSpaceM / KILOBYTE(1);
@ -203,7 +212,7 @@ cString cIptvBufferStatistics::GetBufferStatistic()
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
{
//debug("cIptvBufferStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, usedP);
debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, usedP);
cMutexLock MutexLock(&mutexM);
dataBytesM += bytesP;
if (usedP > usedSpaceM)

View File

@ -35,12 +35,12 @@ public:
cString GetPidStatistic();
protected:
void AddPidStatistic(u_short pidP, long payloadP);
void AddPidStatistic(int pidP, long payloadP);
private:
struct pidStruct {
u_short pid;
long DataAmount;
int pid;
long dataAmount;
};
pidStruct mostActivePidsM[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timerM;

View File

@ -5,20 +5,18 @@
*
*/
#include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "common.h"
#include "log.h"
#include "streamer.h"
cIptvStreamer::cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packetLenP)
cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP)
: cThread("IPTV streamer"),
ringBufferM(ringBufferP),
sleepM(),
deviceM(&deviceP),
packetBufferLenM(packetLenP),
protocolM(NULL)
{
debug("cIptvStreamer::%s(%d)", __FUNCTION__, packetBufferLenM);
debug1("%s (, %d)", __PRETTY_FUNCTION__, packetBufferLenM);
// Allocate packet buffer
packetBufferM = MALLOC(unsigned char, packetBufferLenM);
if (packetBufferM)
@ -29,43 +27,38 @@ cIptvStreamer::cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packet
cIptvStreamer::~cIptvStreamer()
{
debug("cIptvStreamer::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Close the protocol
Close();
protocolM = NULL;
ringBufferM = NULL;
// Free allocated memory
free(packetBufferM);
}
void cIptvStreamer::Action(void)
{
debug("cIptvStreamer::%s(): entering", __FUNCTION__);
debug1("%s() Entering", __PRETTY_FUNCTION__);
// Increase priority
//SetPriority(-1);
// Do the thread loop
while (packetBufferM && Running()) {
int length = -1;
unsigned int size = min((unsigned int)ringBufferM->Free(), packetBufferLenM);
unsigned int size = min(deviceM->CheckData(), packetBufferLenM);
if (protocolM && (size > 0))
length = protocolM->Read(packetBufferM, size);
if (length > 0) {
AddStreamerStatistic(length);
if (ringBufferM) {
int p = ringBufferM->Put(packetBufferM, length);
if (p != length)
ringBufferM->ReportOverflow(length - p);
}
deviceM->WriteData(packetBufferM, length);
}
else
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
}
debug("cIptvStreamer::%s(): exiting", __FUNCTION__);
debug1("%s Exiting", __PRETTY_FUNCTION__);
}
bool cIptvStreamer::Open(void)
{
debug("cIptvStreamer::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Open the protocol
if (protocolM && !protocolM->Open())
return false;
@ -76,7 +69,7 @@ bool cIptvStreamer::Open(void)
bool cIptvStreamer::Close(void)
{
debug("cIptvStreamer::%s()", __FUNCTION__);
debug1("%s", __PRETTY_FUNCTION__);
// Stop thread
sleepM.Signal();
if (Running())
@ -87,9 +80,9 @@ bool cIptvStreamer::Close(void)
return true;
}
bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
{
debug("cIptvStreamer::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
debug1("%s (%s, %d, %d, )", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Update protocol and set location and parameter; Close the existing one if changed
if (protocolM != protocolP) {
@ -97,19 +90,27 @@ bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int i
protocolM->Close();
protocolM = protocolP;
if (protocolM) {
protocolM->Set(locationP, parameterP, indexP);
protocolM->SetSource(locationP, parameterP, indexP);
protocolM->Open();
}
}
else if (protocolM)
protocolM->Set(locationP, parameterP, indexP);
protocolM->SetSource(locationP, parameterP, indexP);
}
return true;
}
bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP)
{
debug1("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
if (protocolM)
return protocolM->SetPid(pidP, typeP, onP);
return true;
}
cString cIptvStreamer::GetInformation(void)
{
//debug("cIptvStreamer::%s()", __FUNCTION__);
debug16("%s", __PRETTY_FUNCTION__);
cString s;
if (protocolM)
s = protocolM->GetInformation();

View File

@ -11,15 +11,15 @@
#include <arpa/inet.h>
#include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "deviceif.h"
#include "protocolif.h"
#include "statistics.h"
class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
private:
cRingBufferLinear* ringBufferM;
cCondWait sleepM;
cIptvDeviceIf* deviceM;
unsigned char* packetBufferM;
unsigned int packetBufferLenM;
cIptvProtocolIf* protocolM;
@ -28,9 +28,10 @@ protected:
virtual void Action(void);
public:
cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packetLenP);
cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP);
virtual ~cIptvStreamer();
bool Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP);
bool SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void);
bool Close(void);
cString GetInformation(void);