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

Compare commits

..

No commits in common. "master" and "v0.5.1" have entirely different histories.

50 changed files with 1877 additions and 3643 deletions

124
HISTORY
View File

@ -168,127 +168,3 @@ VDR Plugin 'iptv' Revision History
- Added support for a service interface. - Added support for a service interface.
- Changed UDP protocol to always utilize the source address - Changed UDP protocol to always utilize the source address
validation. validation.
2012-04-26: Version 0.5.2
- Fixed connection problems in HTTP protocol.
2012-06-03: Version 1.0.0
- Optimized reading from UDP sockets.
- Fixed ProvidesChannel method.
2012-07-10: Version 1.0.1
- Added FreeBSD support (Thanks to Jürgen Lock).
2012-09-30: Version 1.1.0
- Updated for vdr-1.7.30.
- Added support for source-specific multicasts (SSM).
- Changed default external script directory from the
configuration to the resource.
2013-02-24: Version 1.2.0
- Updated for vdr-1.7.38.
- Added a new CURL protocol for HTTP/HTTPS.
2013-03-06: Version 1.2.1
- 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.

124
Makefile
View File

@ -2,14 +2,18 @@
# Makefile for IPTV plugin # Makefile for IPTV plugin
# #
# Default shell for EXT protocol # Debugging on/off
#IPTV_DEBUG = 1
#IPTV_EXTSHELL = /bin/bash # Strip debug symbols? Set eg. to /bin/true if not
STRIP = strip
# The official name of this plugin. # The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the 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. # By default the main source file also carries this name.
# IMPORTANT: the presence of this macro is important for the Make.config
# file. So it must be defined, even if it is not used here!
#
PLUGIN = iptv PLUGIN = iptv
### The version number of this plugin (taken from the main source file): ### The version number of this plugin (taken from the main source file):
@ -17,53 +21,43 @@ PLUGIN = iptv
VERSION = $(shell grep 'const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g') VERSION = $(shell grep 'const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g')
GITTAG = $(shell git describe --always 2>/dev/null) GITTAG = $(shell git describe --always 2>/dev/null)
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -fPIC -g -O3 -Wall -Wextra -Wswitch-default -Wfloat-equal -Wundef -Wpointer-arith -Wconversion -Wcast-align -Wredundant-decls -Wno-unused-parameter -Werror=overloaded-virtual -Wno-parentheses
LDFLAGS ?= -Wl,--as-needed
### The directory environment: ### The directory environment:
# Use package data if installed...otherwise assume we're under the VDR source directory: VDRDIR ?= ../../..
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr)) LIBDIR ?= ../../lib
LIBDIR = $(call PKGCFG,libdir)
LOCDIR = $(call PKGCFG,locdir)
PLGCFG = $(call PKGCFG,plgcfg)
RESDIR = $(call PKGCFG,resdir)
CFGDIR = $(call PKGCFG,configdir)
#
TMPDIR ?= /tmp TMPDIR ?= /tmp
### The compiler options: ### Make sure that necessary options are included:
export CFLAGS = $(call PKGCFG,cflags) -include $(VDRDIR)/Make.global
export CXXFLAGS = $(call PKGCFG,cxxflags)
STRIP ?= /bin/true
### The version number of VDR's plugin API:
APIVERSION = $(call PKGCFG,apiversion)
### Allow user defined options to overwrite defaults: ### Allow user defined options to overwrite defaults:
-include $(PLGCFG) -include $(VDRDIR)/Make.config
### The version number of VDR's plugin API (taken from VDR's "config.h"):
APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
### The name of the distribution archive: ### The name of the distribution archive:
ARCHIVE = $(PLUGIN)-$(VERSION) ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE) PACKAGE = vdr-$(ARCHIVE)
### The name of the shared object file:
SOFILE = libvdr-$(PLUGIN).so
### Libraries
LIBS = $(shell curl-config --libs)
### Includes and Defines (add further entries here): ### Includes and Defines (add further entries here):
INCLUDES += INCLUDES += -I$(VDRDIR)/include
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
ifdef IPTV_EXTSHELL ifdef IPTV_DEBUG
DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"' DEFINES += -DDEBUG
endif endif
ifneq ($(strip $(GITTAG)),) ifneq ($(strip $(GITTAG)),)
@ -75,77 +69,61 @@ all-redirect: all
### The object files (add further files here): ### The object files (add further files here):
OBJS = $(PLUGIN).o common.o config.o device.o pidscanner.o \ OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \
protocolcurl.o protocolext.o protocolfile.o protocolhttp.o \ protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \
protocoludp.o sectionfilter.o setup.o sidscanner.o socket.o \ sidscanner.o pidscanner.o statistics.o common.o socket.o source.o
source.o statistics.o streamer.o
### The main target: ### The main target:
all: $(SOFILE) i18n all: libvdr-$(PLUGIN).so i18n
### Implicit rules: ### Implicit rules:
%.o: %.c Makefile %.o: %.c Makefile
@echo CC $@ $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
$(Q)$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
### Dependencies: ### Dependencies:
MAKEDEP = $(CXX) -MM -MG MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies DEPFILE = .dependencies
$(DEPFILE): Makefile $(DEPFILE): Makefile
$(Q)$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
-include $(DEPFILE) -include $(DEPFILE)
### Internationalization (I18N): ### Internationalization (I18N):
PODIR = po PODIR = po
LOCALEDIR = $(VDRDIR)/locale
I18Npo = $(wildcard $(PODIR)/*.po) I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file)))) I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po %.mo: %.po
@echo MO $@ msgfmt -c -o $@ $<
$(Q)msgfmt -c -o $@ $<
$(I18Npot): $(wildcard *.c) $(I18Npot): $(wildcard *.c)
@echo GT $@ xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name='vdr-$(PLUGIN)' --package-version='$(VERSION)' --msgid-bugs-address='<see README>' -o $@ `ls $^`
$(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) %.po: $(I18Npot)
@echo PO $@ msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
$(Q)msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
@touch $@ @touch $@
$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo $(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
@echo IN $@ @mkdir -p $(dir $@)
$(Q)install -D -m644 $< $@ cp $< $@
.PHONY: i18n .PHONY: i18n
i18n: $(I18Nmo) $(I18Npot) i18n: $(I18Nmsgs) $(I18Npot)
install-i18n: $(I18Nmsgs)
### Targets: ### Targets:
$(SOFILE): $(OBJS) libvdr-$(PLUGIN).so: $(OBJS)
@echo LD $@ $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@
$(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@ ifndef IPTV_DEBUG
$(Q)$(STRIP) $@ @$(STRIP) $@
endif
install-lib: $(SOFILE) @cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
@echo IN $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
$(Q)install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
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 dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE) @-rm -rf $(TMPDIR)/$(ARCHIVE)
@ -156,9 +134,7 @@ dist: $(I18Npo) clean
@echo Distribution package created as $(PACKAGE).tgz @echo Distribution package created as $(PACKAGE).tgz
clean: clean:
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
.PHONY: cppcheck cppcheck: $(OBJS)
cppcheck: @cppcheck --enable=information,style,unusedFunction -v -f $(OBJS:%.o=%.c)
$(Q)cppcheck --language=c++ --enable=all -v -f $(OBJS:%.o=%.c)

108
README
View File

@ -17,8 +17,7 @@ See the file COPYING for more information.
Requirements: Requirements:
- Libcurl - the multiprotocol file transfer library DVB compatible MPEG1/2 or H.264 network video streams.
http://curl.haxx.se/libcurl/
Description: Description:
@ -29,29 +28,40 @@ filtering capabilities which allow for example EIT information to be
extracted from the incoming stream. extracted from the incoming stream.
Currently the IPTV plugin has direct support for both multicast UDP/RTP Currently the IPTV plugin has direct support for both multicast UDP/RTP
and unicast HTTP MPEG1/2, H.264 and H.265 transport streams. Also a file and unicast HTTP MPEG1/2 transport streams. Also a file input method is
input method is supported, but a file delay must be selected individually supported, but a file delay must be selected individually to prevent
to prevent VDR's transfer buffer over/underflow. Therefore the file input VDR's transfer buffer over/underflow. Therefore the file input should be
should be considered as a testing feature only. considered as a testing feature only.
IPTV plugin also features a support for external streaming applications. IPTV plugin also features a support for external streaming applications.
With proper helper applications and configuration IPTV plugin is able to With proper helper applications and configuration IPTV plugin is able to
display not only MPEG1/2, H.264 and H.265 transport streams but also other display not only MPEG1/2 transport streams but also other formats like
formats like MP3 radio streams, mms video streams and so on. MP3 radio streams, mms video streams and so on.
Installation: Installation:
cd /put/your/path/here/VDR/PLUGINS/src
tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz
make -C iptv-X.Y.Z install ln -s iptv-X.Y.Z iptv
cd /put/your/path/here/VDR
cp -R PLUGINS/src/iptv/iptv /path/to/vdrconf/plugins/
make
make plugins
./vdr -P iptv
Setup menu: Setup menu:
- Protocol base port = 4321 Defines base port used in CURL/EXT - TS buffer size [MB] = 2 Defines ringbuffer size for transport
protocol. Two ports are defined for stream in MB.
each device. 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.
The port range is defined by the number The port range is defined by the number
of IPTV devices times two (max. 32). of IPTV devices (max. 8).
Valid range: 0...65503 Valid range: 0...65527
- Use section filtering = 1 Defines whether section filtering shall - Use section filtering = 1 Defines whether section filtering shall
be used. be used.
Valid range: 0...1 Valid range: 0...1
@ -78,55 +88,43 @@ Configuration:
- channels.conf - channels.conf
TV6;IPTV:60:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:6:0:0:0 TV4;IPTV:40:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:4: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 TV3;IPTV:30:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:3:0:0:0
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 TV2;IPTV:20:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:2:0:0:0
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 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") | | | | | | Source type ("I")
| | | | | Stream parameter | | | | | Stream parameter (multicast port
| | | | | UDP: multicast port | | | | | number, HTTP port number, file delay
| | | | | CURL: <<to be defined>> | | | | | (ms), script parameter)
| | | | | HTTP: HTTP port number | | | | Stream address (multicast address, URL, file
| | | | | FILE: file delay (ms) | | | | location, script location)
| | | | | EXT: script parameter | | | Stream protocol ("UDP", "HTTP", "FILE", "EXT")
| | | | Stream address
| | | | UDP: multicast [source@]group address
| | | | CURL: HTTP/HTTPS URL; colons (%3A) and pipes (%7C) shall be URL encoded
| | | | HTTP: URL; missing the scheme name part and possible port declaration
| | | | FILE: file location
| | | | EXT: script location
| | | Stream protocol ("UDP", "CURL", "HTTP", "FILE", "EXT")
| | Pid scanner ("0" disable, "1" enable) | | Pid scanner ("0" disable, "1" enable)
| Section id (Sid/Nid/Tid) scanner ("0" disable, "1" enable) | Section id (Sid/Nid/Tid) scanner ("0" disable, "1" enable)
Unique enumeration Unique enumeration
- UDP multicast rules for iptables firewall - UDP multicast rules for iptables firewall
# Multicast UDP packets # Multicast UDP -packets
iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT
# IGMP required by multicasts # IGMP required by multicasts
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
# Default routing for multicast
route add -net 224.0.0.0 netmask 224.0.0.0 eth0
External streaming: External streaming:
- To watch an externally received channel add an EXT entry to channels.conf - To watch an externally received channel add an EXT entry to channels.conf
and specify a script name and parameter. The specified script is executed and specify a script name and parameter. The specified script is executed
from plugin resource directory when VDR tunes to the channel. The specified from plugin configuration directory when VDR tunes to the channel. The
script parameter is passed to the script and it can be used to select for specified script parameter is passed to the script and it can be used to
example between different URLs. select for example between different URLs.
- When an EXT or CURL/RTSP channel is opened the IPTV plugin opens an UDP - When an EXT channel is opened the IPTV plugin opens an UDP listening port
listening port on the localhost. The external script is responsible for on the localhost. The external script is responsible for supplying IPTV
supplying IPTV plugin with MPEG2 TS data in UDP/RTP format to the listening plugin with MPEG2 TS data in UDP/RTP format to the listening port. The
port. The data will be processed in VDR like a normal DVB broadcast. The data will be processed in VDR like a normal DVB broadcast. The listening
listening base port can be specified in the plugin configuration menu. base port can be specified in the plugin configuration menu.
- Each IPTV device has different listen port. The port number is specified - 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 as a base port number plus IPTV device index minus one. Maximum of 8 IPTV
@ -160,26 +158,12 @@ Notes:
"disable_ca_updates" patch to the VDR in order to get rid of "Channel not "disable_ca_updates" patch to the VDR in order to get rid of "Channel not
available" messages. available" messages.
- EIT scanning functionality is disabled by default. - EIT scanning functionality can be disabled for all IPTV channels by applying
the "disable_eitscan" patch to the VDR.
- Section id and pid scanners should be disabled after the correct data is - Section id and pid scanners should be disabled after the correct data is
found. This can be made via VDR's channel editor. found. This can be made via VDR's channel editor.
- Source-specific multicast (SSM) can be enabled by defining both the source
address and the group address separated by a '@' character. This will use
IGMP v3 protocol:
"U=<source address>@<group address>"
- The CURL implementation supports only RTSP/HTTP/HTTPS protocols and an
optional netrc configuration file for authentication:
$(CONFDIR)/iptv/netrc
- 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: Acknowledgements:
- The IPTV section filtering code is derived from Linux kernel. - The IPTV section filtering code is derived from Linux kernel.

View File

@ -5,80 +5,67 @@
* *
*/ */
#include <ctype.h>
#include <vdr/tools.h> #include <vdr/tools.h>
#include "common.h" #include "common.h"
uint16_t ts_pid(const uint8_t *bufP) uint16_t ts_pid(const uint8_t *buf)
{ {
return (uint16_t)(((bufP[1] & 0x1f) << 8) + bufP[2]); return (uint16_t)(((buf[1] & 0x1f) << 8) + buf[2]);
} }
uint8_t payload(const uint8_t *bufP) uint8_t payload(const uint8_t *tsp)
{ {
if (!(bufP[3] & 0x10)) // no payload? if (!(tsp[3] & 0x10)) // no payload?
return 0; return 0;
if (bufP[3] & 0x20) { // adaptation field? if (tsp[3] & 0x20) { // adaptation field?
if (bufP[4] > 183) // corrupted data? if (tsp[4] > 183) // corrupted data?
return 0; return 0;
else else
return (uint8_t)((184 - 1) - bufP[4]); return (uint8_t)((184 - 1) - tsp[4]);
} }
return 184; return 184;
} }
const char *id_pid(const u_short pidP) const char *id_pid(const u_short Pid)
{ {
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) { for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
if (pidP == section_filter_table[i].pid) if (Pid == section_filter_table[i].pid)
return section_filter_table[i].tag; return section_filter_table[i].tag;
} }
return "---"; return "---";
} }
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP) int select_single_desc(int descriptor, const int usecs, const bool selectWrite)
{ {
// Wait for data // Wait for data
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = usecsP; tv.tv_usec = usecs;
// Use select // Use select
fd_set infd; fd_set fds;
fd_set outfd; FD_ZERO(&fds);
fd_set errfd; FD_SET(descriptor, &fds);
FD_ZERO(&infd); int retval = 0;
FD_ZERO(&outfd); if (selectWrite)
FD_ZERO(&errfd); retval = select(descriptor + 1, NULL, &fds, NULL, &tv);
FD_SET(descriptorP, &errfd);
if (selectWriteP)
FD_SET(descriptorP, &outfd);
else else
FD_SET(descriptorP, &infd); retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
// Check if error // Check if error
ERROR_IF_RET(retval < 0, "select()", return retval); ERROR_IF_RET(retval < 0, "select()", return retval);
return retval; return retval;
} }
cString ChangeCase(const cString &strP, bool upperP)
{
cString res(strP);
char *p = (char *)*res;
while (p && *p) {
*p = upperP ? toupper(*p) : tolower(*p);
++p;
}
return res;
}
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] = const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
{ {
/* description tag pid tid mask */ /* description tag pid tid mask */
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF}, {trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF}, {trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF}, {trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
{trNOOP("EIT (0x4E/0x4F/0x5X/0x6X)"), "EIT", 0x12, 0x40, 0xC0}, {trNOOP("EIT (0x4E/0x4F)"), "EIT", 0x12, 0x4E, 0xFE},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF}, {trNOOP("EIT (0x5X)"), "EIT", 0x12, 0x50, 0xF0},
{trNOOP("EIT (0x6X)"), "EIT", 0x12, 0x60, 0xF0},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
}; };

View File

@ -12,9 +12,15 @@
#include <vdr/config.h> #include <vdr/config.h>
#include <vdr/i18n.h> #include <vdr/i18n.h>
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0])) #ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x);
#define error(x...) esyslog("ERROR: " x);
#else
#define debug(x...) ;
#define error(x...) esyslog("ERROR: " x);
#endif
#define IPTV_BUFFER_SIZE KILOBYTE(2048) #define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr" #define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
@ -30,19 +36,19 @@
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10 #define IPTV_STATS_ACTIVE_PIDS_COUNT 10
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10 #define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
#define SECTION_FILTER_TABLE_SIZE 5 #define SECTION_FILTER_TABLE_SIZE 7
#define ERROR_IF_FUNC(exp, errstr, func, ret) \ #define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \ do { \
if (exp) { \ if (exp) { \
char tmp[64]; \ char tmp[64]; \
esyslog("[%s,%d]: " errstr ": %s", __FILE__, __LINE__, \ error(errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
strerror_r(errno, tmp, sizeof(tmp))); \ func; \
func; \ ret; \
ret; \ } \
} \
} while (0) } while (0)
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret); #define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , ); #define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );
@ -58,11 +64,10 @@
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
uint16_t ts_pid(const uint8_t *bufP); uint16_t ts_pid(const uint8_t *buf);
uint8_t payload(const uint8_t *bufP); uint8_t payload(const uint8_t *tsp);
const char *id_pid(const u_short pidP); const char *id_pid(const u_short Pid);
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP); int select_single_desc(int descriptor, const int usecs, const bool selectWrite);
cString ChangeCase(const cString &strP, bool upperP);
struct section_filter_table_type { struct section_filter_table_type {
const char *description; const char *description;

View File

@ -5,50 +5,43 @@
* *
*/ */
#include "log.h"
#include "config.h" #include "config.h"
cIptvConfig IptvConfig; cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void) cIptvConfig::cIptvConfig(void)
: traceModeM(eTraceModeNormal), : tsBufferSize(2),
protocolBasePortM(4321), tsBufferPrefillRatio(0),
useBytesM(1), extProtocolBasePort(4321),
sectionFilteringM(1) useBytes(1),
sectionFiltering(1)
{ {
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i) for (unsigned int i = 0; i < ARRAY_SIZE(disabledFilters); ++i)
disabledFiltersM[i] = -1; disabledFilters[i] = -1;
memset(configDirectoryM, 0, sizeof(configDirectoryM)); memset(configDirectory, '\0', sizeof(configDirectory));
memset(resourceDirectoryM, 0, sizeof(resourceDirectoryM));
} }
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
{ {
unsigned int n = 0; unsigned int n = 0;
while ((n < ARRAY_SIZE(disabledFiltersM) && (disabledFiltersM[n] != -1))) while ((n < ARRAY_SIZE(disabledFilters) && (disabledFilters[n] != -1)))
n++; n++;
return n; return n;
} }
int cIptvConfig::GetDisabledFilters(unsigned int indexP) const int cIptvConfig::GetDisabledFilters(unsigned int Index) const
{ {
return (indexP < ARRAY_SIZE(disabledFiltersM)) ? disabledFiltersM[indexP] : -1; return (Index < ARRAY_SIZE(disabledFilters)) ? disabledFilters[Index] : -1;
} }
void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP) void cIptvConfig::SetDisabledFilters(unsigned int Index, int Number)
{ {
if (indexP < ARRAY_SIZE(disabledFiltersM)) if (Index < ARRAY_SIZE(disabledFilters))
disabledFiltersM[indexP] = numberP; disabledFilters[Index] = Number;
} }
void cIptvConfig::SetConfigDirectory(const char *directoryP) void cIptvConfig::SetConfigDirectory(const char *directoryP)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP); debug("cIptvConfig::SetConfigDirectory(%s)\n", directoryP);
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory"); ERROR_IF(!realpath(directoryP, configDirectory), "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,52 +14,31 @@
class cIptvConfig class cIptvConfig
{ {
private: private:
unsigned int traceModeM; unsigned int tsBufferSize;
unsigned int protocolBasePortM; unsigned int tsBufferPrefillRatio;
unsigned int useBytesM; unsigned int extProtocolBasePort;
unsigned int sectionFilteringM; unsigned int useBytes;
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE]; unsigned int sectionFiltering;
char configDirectoryM[PATH_MAX]; int disabledFilters[SECTION_FILTER_TABLE_SIZE];
char resourceDirectoryM[PATH_MAX]; char configDirectory[PATH_MAX];
public: 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(); cIptvConfig();
unsigned int GetTraceMode(void) const { return traceModeM; } unsigned int GetTsBufferSize(void) const { return tsBufferSize; }
bool IsTraceMode(eTraceMode modeP) const { return (traceModeM & modeP); } unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatio; }
unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; } unsigned int GetExtProtocolBasePort(void) const { return extProtocolBasePort; }
unsigned int GetUseBytes(void) const { return useBytesM; } unsigned int GetUseBytes(void) const { return useBytes; }
unsigned int GetSectionFiltering(void) const { return sectionFilteringM; } unsigned int GetSectionFiltering(void) const { return sectionFiltering; }
const char *GetConfigDirectory(void) const { return configDirectoryM; } const char *GetConfigDirectory(void) const { return configDirectory; }
const char *GetResourceDirectory(void) const { return resourceDirectoryM; }
unsigned int GetDisabledFiltersCount(void) const; unsigned int GetDisabledFiltersCount(void) const;
int GetDisabledFilters(unsigned int indexP) const; int GetDisabledFilters(unsigned int Index) const;
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); } void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; } void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; } void SetExtProtocolBasePort(unsigned int PortNumber) { extProtocolBasePort = PortNumber; }
void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; } void SetUseBytes(unsigned int On) { useBytes = On; }
void SetDisabledFilters(unsigned int indexP, int numberP); void SetSectionFiltering(unsigned int On) { sectionFiltering = On; }
void SetDisabledFilters(unsigned int Index, int Number);
void SetConfigDirectory(const char *directoryP); void SetConfigDirectory(const char *directoryP);
void SetResourceDirectory(const char *directoryP);
}; };
extern cIptvConfig IptvConfig; extern cIptvConfig IptvConfig;

526
device.c
View File

@ -11,112 +11,110 @@
#define IPTV_MAX_DEVICES MAXDEVICES #define IPTV_MAX_DEVICES MAXDEVICES
static cIptvDevice * IptvDevicesS[IPTV_MAX_DEVICES] = { NULL }; static cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL };
cIptvDevice::cIptvDevice(unsigned int indexP) unsigned int cIptvDevice::deviceCount = 0;
: deviceIndexM(indexP),
dvrFdM(-1), cIptvDevice::cIptvDevice(unsigned int Index)
isPacketDeliveredM(false), : deviceIndex(Index),
isOpenDvrM(false), dvrFd(-1),
sidScanEnabledM(false), isPacketDelivered(false),
pidScanEnabledM(false), isOpenDvr(false),
channelM() sidScanEnabled(false),
pidScanEnabled(false),
channelId(tChannelID::InvalidID)
{ {
unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE; unsigned int bufsize = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize());
bufsize -= (bufsize % TS_SIZE); bufsize -= (bufsize % TS_SIZE);
info("Creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex()); isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndex, CardIndex());
tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false, tsBuffer = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
*cString::sprintf("IPTV TS %d", deviceIndexM)); *cString::sprintf("IPTV %d", deviceIndex));
if (tsBufferM) { tsBuffer->SetTimeouts(10, 10);
tsBufferM->SetTimeouts(100, 100); ResetBuffering();
tsBufferM->SetIoThrottle(); pUdpProtocol = new cIptvProtocolUdp();
pIptvStreamerM = new cIptvStreamer(*this, tsBufferM->Free()); pHttpProtocol = new cIptvProtocolHttp();
} pFileProtocol = new cIptvProtocolFile();
pUdpProtocolM = new cIptvProtocolUdp(); pExtProtocol = new cIptvProtocolExt();
pCurlProtocolM = new cIptvProtocolCurl(); pIptvStreamer = new cIptvStreamer(tsBuffer, (100 * TS_SIZE));
pHttpProtocolM = new cIptvProtocolHttp(); pPidScanner = new cPidScanner();
pFileProtocolM = new cIptvProtocolFile(); // Initialize filter pointers
pExtProtocolM = new cIptvProtocolExt(); memset(secfilters, '\0', sizeof(secfilters));
pPidScannerM = new cPidScanner();
// Start section handler for iptv device // Start section handler for iptv device
pIptvSectionM = new cIptvSectionFilterHandler(deviceIndexM, bufsize + 1);
StartSectionHandler(); StartSectionHandler();
// Sid scanner must be created after the section handler // Sid scanner must be created after the section handler
AttachFilter(pSidScannerM = new cSidScanner()); pSidScanner = new cSidScanner();
if (pSidScanner)
AttachFilter(pSidScanner);
// Check if dvr fifo exists // Check if dvr fifo exists
struct stat sb; struct stat sb;
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndexM); cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndex);
stat(filename, &sb); stat(filename, &sb);
if (S_ISFIFO(sb.st_mode)) { if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK); dvrFd = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0) if (dvrFd >= 0)
info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename); dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndex, *filename);
} }
} }
cIptvDevice::~cIptvDevice() cIptvDevice::~cIptvDevice()
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::~cIptvDevice(%d)\n", deviceIndex);
// Stop section handler of iptv device // Stop section handler of iptv device
StopSectionHandler(); StopSectionHandler();
DELETE_POINTER(pIptvSectionM); DELETE_POINTER(pIptvStreamer);
DELETE_POINTER(pSidScannerM); DELETE_POINTER(pUdpProtocol);
DELETE_POINTER(pPidScannerM); DELETE_POINTER(pHttpProtocol);
DELETE_POINTER(pIptvStreamerM); DELETE_POINTER(pFileProtocol);
DELETE_POINTER(pExtProtocolM); DELETE_POINTER(pExtProtocol);
DELETE_POINTER(pFileProtocolM); DELETE_POINTER(tsBuffer);
DELETE_POINTER(pHttpProtocolM); DELETE_POINTER(pPidScanner);
DELETE_POINTER(pCurlProtocolM); // Detach and destroy sid filter
DELETE_POINTER(pUdpProtocolM); if (pSidScanner) {
DELETE_POINTER(tsBufferM); Detach(pSidScanner);
DELETE_POINTER(pSidScanner);
}
// Destroy all filters
for (int i = 0; i < eMaxSecFilterCount; ++i)
DeleteFilter(i);
// Close dvr fifo // Close dvr fifo
if (dvrFdM >= 0) { if (dvrFd >= 0) {
int fd = dvrFdM; int fd = dvrFd;
dvrFdM = -1; dvrFd = -1;
close(fd); close(fd);
} }
} }
bool cIptvDevice::Initialize(unsigned int deviceCountP) bool cIptvDevice::Initialize(unsigned int DeviceCount)
{ {
debug1("%s (%u)", __PRETTY_FUNCTION__, deviceCountP); debug("cIptvDevice::Initialize(): DeviceCount=%d\n", DeviceCount);
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV"); new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
if (deviceCountP > IPTV_MAX_DEVICES) if (DeviceCount > IPTV_MAX_DEVICES)
deviceCountP = IPTV_MAX_DEVICES; DeviceCount = IPTV_MAX_DEVICES;
for (unsigned int i = 0; i < deviceCountP; ++i) for (unsigned int i = 0; i < DeviceCount; ++i)
IptvDevicesS[i] = new cIptvDevice(i); IptvDevices[i] = new cIptvDevice(i);
for (unsigned int i = deviceCountP; i < IPTV_MAX_DEVICES; ++i) for (unsigned int i = DeviceCount; i < IPTV_MAX_DEVICES; ++i)
IptvDevicesS[i] = NULL; IptvDevices[i] = NULL;
return true; 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 cIptvDevice::Count(void)
{ {
unsigned int count = 0; unsigned int count = 0;
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvDevice::Count()\n");
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) { for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i] != NULL) if (IptvDevices[i] != NULL)
count++; count++;
} }
return count; return count;
} }
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP) cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
{ {
debug16("%s (%d)", __PRETTY_FUNCTION__, cardIndexP); //debug("cIptvDevice::GetIptvDevice(%d)\n", CardIndex);
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) { for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) { if ((IptvDevices[i] != NULL) && (IptvDevices[i]->CardIndex() == CardIndex)) {
debug16("%s (%d) Found", __PRETTY_FUNCTION__, cardIndexP); //debug("cIptvDevice::GetIptvDevice(%d): FOUND!\n", CardIndex);
return IptvDevicesS[i]; return IptvDevices[i];
} }
} }
return NULL; return NULL;
@ -124,113 +122,115 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
cString cIptvDevice::GetGeneralInformation(void) cString cIptvDevice::GetGeneralInformation(void)
{ {
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); //debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
LOCK_CHANNELS_READ;
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s", return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
deviceIndexM, CardIndex(), deviceIndex, CardIndex(),
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "", pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "", pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
*GetBufferStatistic(), *GetBufferStatistic(),
*Channels->GetByNumber(cDevice::CurrentChannel())->ToText()); *Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
} }
cString cIptvDevice::GetPidsInformation(void) cString cIptvDevice::GetPidsInformation(void)
{ {
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); //debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
return GetPidStatistic(); return GetPidStatistic();
} }
cString cIptvDevice::GetFiltersInformation(void) cString cIptvDevice::GetFiltersInformation(void)
{ {
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); //debug("cIptvDevice::GetFiltersInformation(%d)\n", deviceIndex);
return cString::sprintf("Active section filters:\n%s", pIptvSectionM ? *pIptvSectionM->GetInformation() : ""); unsigned int count = 0;
cString info("Active section filters:\n");
// loop through active section filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i]) {
info = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *info, i,
*secfilters[i]->GetSectionStatistic(), secfilters[i]->GetPid(),
id_pid(secfilters[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
}
}
return info;
} }
cString cIptvDevice::GetInformation(unsigned int pageP) cString cIptvDevice::GetInformation(unsigned int Page)
{ {
// generate information string // generate information string
cString s; cString info;
switch (pageP) { switch (Page) {
case IPTV_DEVICE_INFO_GENERAL: case IPTV_DEVICE_INFO_GENERAL:
s = GetGeneralInformation(); info = GetGeneralInformation();
break; break;
case IPTV_DEVICE_INFO_PIDS: case IPTV_DEVICE_INFO_PIDS:
s = GetPidsInformation(); info = GetPidsInformation();
break; break;
case IPTV_DEVICE_INFO_FILTERS: case IPTV_DEVICE_INFO_FILTERS:
s = GetFiltersInformation(); info = GetFiltersInformation();
break; break;
case IPTV_DEVICE_INFO_PROTOCOL: case IPTV_DEVICE_INFO_PROTOCOL:
s = pIptvStreamerM ? *pIptvStreamerM->GetInformation() : ""; info = pIptvStreamer ? *pIptvStreamer->GetInformation() : "";
break; break;
case IPTV_DEVICE_INFO_BITRATE: case IPTV_DEVICE_INFO_BITRATE:
s = pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : ""; info = pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "";
break; break;
default: default:
s = cString::sprintf("%s%s%s", info = cString::sprintf("%s%s%s",
*GetGeneralInformation(), *GetGeneralInformation(),
*GetPidsInformation(), *GetPidsInformation(),
*GetFiltersInformation()); *GetFiltersInformation());
break; break;
} }
return s; return info;
} }
cString cIptvDevice::DeviceType(void) const cString cIptvDevice::DeviceType(void) const
{ {
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::DeviceType(%d)\n", deviceIndex);
return "IPTV"; return "IPTV";
} }
cString cIptvDevice::DeviceName(void) const cString cIptvDevice::DeviceName(void) const
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::DeviceName(%d)\n", deviceIndex);
return cString::sprintf("IPTV %d", deviceIndexM); return cString::sprintf("IPTV %d", deviceIndex);
} }
int cIptvDevice::SignalStrength(void) const int cIptvDevice::SignalStrength(void) const
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::SignalStrength(%d)\n", deviceIndex);
return (100); return (100);
} }
int cIptvDevice::SignalQuality(void) const int cIptvDevice::SignalQuality(void) const
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::SignalQuality(%d)\n", deviceIndex);
return (100); return (100);
} }
bool cIptvDevice::ProvidesSource(int sourceP) const bool cIptvDevice::ProvidesSource(int Source) const
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex);
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER)); return (cSource::IsType(Source, IPTV_SOURCE_CHARACTER));
} }
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex);
return (ProvidesSource(channelP->Source())); return (ProvidesSource(Channel->Source()));
} }
bool cIptvDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool *needsDetachReceiversP) const bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
{ {
bool result = false; bool result = false;
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority()); bool needsDetachReceivers = Receiving(true) && Channel && !(Channel->GetChannelID() == channelId);
bool needsDetachReceivers = false;
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::ProvidesChannel(%d)\n", deviceIndex);
if (ProvidesTransponder(Channel))
if (channelP && ProvidesTransponder(channelP)) { result = true;
result = hasPriority; if (NeedsDetachReceivers)
if (Receiving()) { *NeedsDetachReceivers = needsDetachReceivers;
if (channelP->GetChannelID() == channelM.GetChannelID())
result = true;
else
needsDetachReceivers = Receiving();
}
}
if (needsDetachReceiversP)
*needsDetachReceiversP = needsDetachReceivers;
return result; return result;
} }
@ -244,219 +244,213 @@ int cIptvDevice::NumProvidedSystems(void) const
return 1; return 1;
} }
const cChannel *cIptvDevice::GetCurrentlyTunedTransponder(void) const bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
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; cIptvProtocolIf *protocol;
cIptvTransponderParameters itp(channelP->Parameters()); cIptvTransponderParameters itp(Channel->Parameters());
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
if (isempty(itp.Address())) { if (isempty(itp.Address())) {
error("Unrecognized IPTV address: %s", channelP->Parameters()); error("Unrecognized IPTV address: %s", Channel->Parameters());
return false; return false;
} }
switch (itp.Protocol()) { switch (itp.Protocol()) {
case cIptvTransponderParameters::eProtocolUDP: case cIptvTransponderParameters::eProtocolUDP:
protocol = pUdpProtocolM; protocol = pUdpProtocol;
break;
case cIptvTransponderParameters::eProtocolCURL:
protocol = pCurlProtocolM;
break; break;
case cIptvTransponderParameters::eProtocolHTTP: case cIptvTransponderParameters::eProtocolHTTP:
protocol = pHttpProtocolM; protocol = pHttpProtocol;
break; break;
case cIptvTransponderParameters::eProtocolFILE: case cIptvTransponderParameters::eProtocolFILE:
protocol = pFileProtocolM; protocol = pFileProtocol;
break; break;
case cIptvTransponderParameters::eProtocolEXT: case cIptvTransponderParameters::eProtocolEXT:
protocol = pExtProtocolM; protocol = pExtProtocol;
break; break;
default: default:
error("Unrecognized IPTV protocol: %s", channelP->Parameters()); error("Unrecognized IPTV protocol: %s", Channel->Parameters());
return false; return false;
break; break;
} }
sidScanEnabledM = itp.SidScan() ? true : false; sidScanEnabled = itp.SidScan() ? true : false;
pidScanEnabledM = itp.PidScan() ? true : false; pidScanEnabled = itp.PidScan() ? true : false;
if (pIptvStreamerM && pIptvStreamerM->SetSource(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) { if (pIptvStreamer->Set(itp.Address(), itp.Parameter(), deviceIndex, protocol)) {
channelM = *channelP; channelId = Channel->GetChannelID();
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering()) if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScannerM->SetChannel(channelM.GetChannelID()); pSidScanner->SetChannel(channelId);
if (pidScanEnabledM && pPidScannerM) if (pidScanEnabled && pPidScanner)
pPidScannerM->SetChannel(channelM.GetChannelID()); pPidScanner->SetChannel(channelId);
} }
return true; return true;
} }
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP) bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
{ {
debug1("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM); debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndex, Handle->pid, Type, On);
if (pIptvStreamerM && handleP)
return pIptvStreamerM->SetPid(handleP->pid, typeP, onP);
return true; return true;
} }
int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP) bool cIptvDevice::DeleteFilter(unsigned int Index)
{ {
debug16("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM); if ((Index < eMaxSecFilterCount) && secfilters[Index]) {
if (pIptvSectionM && IptvConfig.GetSectionFiltering()) { //debug("cIptvDevice::DeleteFilter(%d) Index=%d\n", deviceIndex, Index);
if (pIptvStreamerM) cIptvSectionFilter *tmp = secfilters[Index];
pIptvStreamerM->SetPid(pidP, ptOther, true); secfilters[Index] = NULL;
return pIptvSectionM->Open(pidP, tidP, maskP); delete tmp;
return true;
} }
return false;
}
bool cIptvDevice::IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const
{
//debug("cIptvDevice::IsBlackListed(%d) Pid=%d Tid=%02X Mask=%02X\n", deviceIndex, Pid, Tid, Mask);
// 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 == Pid) && (section_filter_table[index].tid == Tid) &&
(section_filter_table[index].mask == Mask)) {
//debug("cIptvDevice::IsBlackListed(%d) Found=%s\n", deviceIndex, section_filter_table[index].description);
return true;
}
}
return false;
}
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
{
// Check if disabled by user
if (!IptvConfig.GetSectionFiltering())
return -1;
// Blacklist check, refuse certain filters
if (IsBlackListed(Pid, Tid, Mask))
return -1;
// Lock
cMutexLock MutexLock(&mutex);
// Search the next free filter slot
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!secfilters[i]) {
//debug("cIptvDevice::OpenFilter(%d): Pid=%d Tid=%02X Mask=%02X Index=%d\n", deviceIndex, Pid, Tid, Mask, i);
secfilters[i] = new cIptvSectionFilter(deviceIndex, i, Pid, Tid, Mask);
return secfilters[i]->GetReadDesc();
}
}
// No free filter slot found
return -1; return -1;
} }
void cIptvDevice::CloseFilter(int handleP) void cIptvDevice::CloseFilter(int Handle)
{ {
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, handleP, deviceIndexM); // Lock
if (pIptvSectionM) { cMutexLock MutexLock(&mutex);
if (pIptvStreamerM) // Search the filter for deletion
pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false); for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
pIptvSectionM->Close(handleP); if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) {
} //debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
DeleteFilter(i);
break;
}
}
} }
bool cIptvDevice::OpenDvr(void) bool cIptvDevice::OpenDvr(void)
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::OpenDvr(%d)\n", deviceIndex);
isPacketDeliveredM = false; isPacketDelivered = false;
tsBufferM->Clear(); tsBuffer->Clear();
if (pIptvStreamerM) ResetBuffering();
pIptvStreamerM->Open(); if (pIptvStreamer)
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering()) pIptvStreamer->Open();
pSidScannerM->Open(); if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
if (pidScanEnabledM && pPidScannerM) pSidScanner->Open();
pPidScannerM->Open(); isOpenDvr = true;
isOpenDvrM = true;
return true; return true;
} }
void cIptvDevice::CloseDvr(void) void cIptvDevice::CloseDvr(void)
{ {
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex);
if (pidScanEnabledM && pPidScannerM) if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pPidScannerM->Close(); pSidScanner->Close();
if (sidScanEnabledM && pSidScannerM) if (pIptvStreamer)
pSidScannerM->Close(); pIptvStreamer->Close();
if (pIptvStreamerM) isOpenDvr = false;
pIptvStreamerM->Close();
isOpenDvrM = false;
} }
bool cIptvDevice::HasLock(int timeoutMsP) const bool cIptvDevice::HasLock(int TimeoutMs)
{ {
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, timeoutMsP, deviceIndexM); //debug("cIptvDevice::HasLock(%d): %d\n", deviceIndex, TimeoutMs);
return (pIptvStreamerM && pIptvStreamerM->Active()); return (!IsBuffering());
} }
bool cIptvDevice::HasInternalCam(void) void cIptvDevice::ResetBuffering(void)
{ {
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndex);
// pad prefill to multiple of TS_SIZE
tsBufferPrefill = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
IptvConfig.GetTsBufferPrefillRatio() / 100;
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
}
bool cIptvDevice::IsBuffering(void)
{
//debug("cIptvDevice::IsBuffering(%d): %d\n", deviceIndex);
if (tsBufferPrefill && tsBuffer->Available() < tsBufferPrefill)
return true;
else
tsBufferPrefill = 0;
return false; return false;
} }
void cIptvDevice::WriteData(uchar *bufferP, int lengthP) bool cIptvDevice::GetTSPacket(uchar *&Data)
{ {
debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM); //debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
int len; if (tsBuffer && !IsBuffering()) {
// Send data to dvr fifo if (isPacketDelivered) {
if (dvrFdM >= 0) tsBuffer->Del(TS_SIZE);
len = write(dvrFdM, bufferP, lengthP); isPacketDelivered = false;
// Fill up TS buffer // Update buffer statistics
if (tsBufferM) { AddBufferStatistic(TS_SIZE, tsBuffer->Available());
len = tsBufferM->Put(bufferP, lengthP); }
if (len != lengthP) int Count = 0;
tsBufferM->ReportOverflow(lengthP - len); uchar *p = tsBuffer->Get(Count);
} if (p && Count >= TS_SIZE) {
// 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) { 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) { if (p[i] == TS_SYNC_BYTE) {
count = i; Count = i;
break; break;
} }
} }
tsBufferM->Del(count); tsBuffer->Del(Count);
info("Skipped %d bytes to sync on TS packet", count); error("Skipped %d bytes to sync on TS packet\n", Count);
return NULL; return false;
} }
isPacketDeliveredM = true; isPacketDelivered = true;
if (availableP) Data = p;
*availableP = count;
// Update pid statistics // Update pid statistics
AddPidStatistic(ts_pid(p), payload(p)); AddPidStatistic(ts_pid(p), payload(p));
return p; // Send data also to dvr fifo
if (dvrFd >= 0)
Count = (int)write(dvrFd, p, TS_SIZE);
// Analyze incomplete streams with built-in pid analyzer
if (pidScanEnabled && pPidScanner)
pPidScanner->Process(p);
// Lock
cMutexLock MutexLock(&mutex);
// Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i])
secfilters[i]->Process(p);
}
return true;
} }
} }
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 // Reduce cpu load by preventing busylooping
cCondWait::SleepMs(10); cCondWait::SleepMs(10);
dataP = NULL; Data = NULL;
return true; return true;
} }

View File

@ -10,9 +10,7 @@
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
#include "deviceif.h"
#include "protocoludp.h" #include "protocoludp.h"
#include "protocolcurl.h"
#include "protocolhttp.h" #include "protocolhttp.h"
#include "protocolfile.h" #include "protocolfile.h"
#include "protocolext.h" #include "protocolext.h"
@ -22,41 +20,43 @@
#include "sidscanner.h" #include "sidscanner.h"
#include "statistics.h" #include "statistics.h"
class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics, public cIptvDeviceIf { class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics {
// static ones // static ones
public: public:
static unsigned int deviceCount; static unsigned int deviceCount;
static bool Initialize(unsigned int DeviceCount); static bool Initialize(unsigned int DeviceCount);
static void Shutdown(void);
static unsigned int Count(void); static unsigned int Count(void);
static cIptvDevice *GetIptvDevice(int CardIndex); static cIptvDevice *GetIptvDevice(int CardIndex);
// private parts // private parts
private: private:
unsigned int deviceIndexM; enum {
int dvrFdM; eMaxSecFilterCount = 32
bool isPacketDeliveredM; };
bool isOpenDvrM; unsigned int deviceIndex;
bool sidScanEnabledM; int dvrFd;
bool pidScanEnabledM; bool isPacketDelivered;
cRingBufferLinear *tsBufferM; bool isOpenDvr;
cChannel channelM; bool sidScanEnabled;
cIptvProtocolUdp *pUdpProtocolM; bool pidScanEnabled;
cIptvProtocolCurl *pCurlProtocolM; cRingBufferLinear *tsBuffer;
cIptvProtocolHttp *pHttpProtocolM; int tsBufferPrefill;
cIptvProtocolFile *pFileProtocolM; tChannelID channelId;
cIptvProtocolExt *pExtProtocolM; cIptvProtocolUdp *pUdpProtocol;
cIptvStreamer *pIptvStreamerM; cIptvProtocolHttp *pHttpProtocol;
cIptvSectionFilterHandler *pIptvSectionM; cIptvProtocolFile *pFileProtocol;
cPidScanner *pPidScannerM; cIptvProtocolExt *pExtProtocol;
cSidScanner *pSidScannerM; cIptvStreamer *pIptvStreamer;
cMutex mutexM; cPidScanner *pPidScanner;
cSidScanner *pSidScanner;
cMutex mutex;
cIptvSectionFilter *secfilters[eMaxSecFilterCount];
// constructor & destructor // constructor & destructor
public: public:
cIptvDevice(unsigned int deviceIndexP); cIptvDevice(unsigned int DeviceIndex);
virtual ~cIptvDevice(); virtual ~cIptvDevice();
cString GetInformation(unsigned int pageP = IPTV_DEVICE_INFO_ALL); cString GetInformation(unsigned int Page = IPTV_DEVICE_INFO_ALL);
// copy and assignment constructors // copy and assignment constructors
private: private:
@ -68,8 +68,14 @@ private:
cString GetPidsInformation(void); cString GetPidsInformation(void);
cString GetFiltersInformation(void); cString GetFiltersInformation(void);
// for channel parsing & buffering
private:
void ResetBuffering(void);
bool IsBuffering(void);
bool DeleteFilter(unsigned int Index);
bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const;
// for channel info // for channel info
public:
virtual cString DeviceType(void) const; virtual cString DeviceType(void) const;
virtual cString DeviceName(void) const; virtual cString DeviceName(void) const;
virtual int SignalStrength(void) const; virtual int SignalStrength(void) const;
@ -77,46 +83,29 @@ public:
// for channel selection // for channel selection
public: public:
virtual bool ProvidesSource(int sourceP) const; virtual bool ProvidesSource(int Source) const;
virtual bool ProvidesTransponder(const cChannel *channelP) const; virtual bool ProvidesTransponder(const cChannel *Channel) const;
virtual bool ProvidesChannel(const cChannel *channelP, int priorityP = -1, bool *needsDetachReceiversP = NULL) const; virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
virtual bool ProvidesEIT(void) const; virtual bool ProvidesEIT(void) const;
virtual int NumProvidedSystems(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: protected:
virtual bool SetChannelDevice(const cChannel *channelP, bool liveViewP); virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
// for recording // for recording
private:
uchar *GetData(int *availableP = NULL);
void SkipData(int countP);
protected: protected:
virtual bool SetPid(cPidHandle *handleP, int typeP, bool onP); virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
virtual bool OpenDvr(void); virtual bool OpenDvr(void);
virtual void CloseDvr(void); virtual void CloseDvr(void);
virtual bool GetTSPacket(uchar *&dataP); virtual bool GetTSPacket(uchar *&Data);
// for section filtering // for section filtering
public: public:
virtual int OpenFilter(u_short pidP, u_char tidP, u_char maskP); virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
virtual void CloseFilter(int handleP); virtual void CloseFilter(int Handle);
// for transponder lock // for transponder lock
public: public:
virtual bool HasLock(int timeoutMsP) const; virtual bool HasLock(int);
// 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 #endif // __IPTV_DEVICE_H

View File

@ -1,23 +0,0 @@
/*
* 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

133
iptv.c
View File

@ -13,21 +13,21 @@
#include "device.h" #include "device.h"
#include "iptvservice.h" #include "iptvservice.h"
#if defined(APIVERSNUM) && APIVERSNUM < 20400 #if defined(APIVERSNUM) && APIVERSNUM < 10727
#error "VDR-2.4.0 API version or greater is required!" #error "VDR-1.7.27 API version or greater is required!"
#endif #endif
#ifndef GITVERSION #ifndef GITVERSION
#define GITVERSION "" #define GITVERSION ""
#endif #endif
const char VERSION[] = "2.4.0" GITVERSION; const char VERSION[] = "0.5.1" GITVERSION;
static const char DESCRIPTION[] = trNOOP("Experience the IPTV"); static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin { class cPluginIptv : public cPlugin {
private: private:
unsigned int deviceCountM; unsigned int deviceCount;
int ParseFilters(const char *valueP, int *filtersP); int ParseFilters(const char *Value, int *Values);
public: public:
cPluginIptv(void); cPluginIptv(void);
virtual ~cPluginIptv(); virtual ~cPluginIptv();
@ -52,9 +52,9 @@ public:
}; };
cPluginIptv::cPluginIptv(void) cPluginIptv::cPluginIptv(void)
: deviceCountM(1) : deviceCount(1)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::cPluginIptv()\n");
// Initialize any member variables here. // Initialize any member variables here.
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
@ -62,25 +62,23 @@ cPluginIptv::cPluginIptv(void)
cPluginIptv::~cPluginIptv() cPluginIptv::~cPluginIptv()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::~cPluginIptv()\n");
// Clean up after yourself! // Clean up after yourself!
} }
const char *cPluginIptv::CommandLineHelp(void) const char *cPluginIptv::CommandLineHelp(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::CommandLineHelp()\n");
// Return a string that describes all known command line options. // 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[]) bool cPluginIptv::ProcessArgs(int argc, char *argv[])
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::ProcessArgs()\n");
// Implement command line argument processing here if applicable. // Implement command line argument processing here if applicable.
static const struct option long_options[] = { static const struct option long_options[] = {
{ "devices", required_argument, NULL, 'd' }, { "devices", required_argument, NULL, 'd' },
{ "trace", required_argument, NULL, 't' },
{ NULL, no_argument, NULL, 0 } { NULL, no_argument, NULL, 0 }
}; };
@ -88,10 +86,7 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
deviceCountM = atoi(optarg); deviceCount = atoi(optarg);
break;
case 't':
IptvConfig.SetTraceMode(strtol(optarg, NULL, 0));
break; break;
default: default:
return false; return false;
@ -102,110 +97,100 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
bool cPluginIptv::Initialize(void) bool cPluginIptv::Initialize(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::Initialize()\n");
// Initialize any background activities the plugin shall perform. // Initialize any background activities the plugin shall perform.
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
IptvConfig.SetResourceDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); return cIptvDevice::Initialize(deviceCount);
return cIptvDevice::Initialize(deviceCountM);
} }
bool cPluginIptv::Start(void) bool cPluginIptv::Start(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::Start()\n");
// Start any background activities the plugin shall perform. // 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);
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; return true;
} }
void cPluginIptv::Stop(void) void cPluginIptv::Stop(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::Stop()\n");
// Stop any background activities the plugin is performing. // Stop any background activities the plugin is performing.
cIptvDevice::Shutdown();
curl_global_cleanup();
} }
void cPluginIptv::Housekeeping(void) void cPluginIptv::Housekeeping(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::Housekeeping()\n");
// Perform any cleanup or other regular tasks. // Perform any cleanup or other regular tasks.
} }
void cPluginIptv::MainThreadHook(void) void cPluginIptv::MainThreadHook(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::MainThreadHook()\n");
// Perform actions in the context of the main program thread. // Perform actions in the context of the main program thread.
// WARNING: Use with great care - see PLUGINS.html! // WARNING: Use with great care - see PLUGINS.html!
} }
cString cPluginIptv::Active(void) cString cPluginIptv::Active(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::Active()\n");
// Return a message string if shutdown should be postponed // Return a message string if shutdown should be postponed
return NULL; return NULL;
} }
time_t cPluginIptv::WakeupTime(void) time_t cPluginIptv::WakeupTime(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::WakeupTime()\n");
// Return custom wakeup time for shutdown script // Return custom wakeup time for shutdown script
return 0; return 0;
} }
cOsdObject *cPluginIptv::MainMenuAction(void) cOsdObject *cPluginIptv::MainMenuAction(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPluginIptv::MainMenuAction()\n");
// Perform the action when selected from the main VDR menu. // Perform the action when selected from the main VDR menu.
return NULL; return NULL;
} }
cMenuSetupPage *cPluginIptv::SetupMenu(void) cMenuSetupPage *cPluginIptv::SetupMenu(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::SetupMenu()\n");
// Return a setup menu in case the plugin supports one. // Return a setup menu in case the plugin supports one.
return new cIptvPluginSetup(); return new cIptvPluginSetup();
} }
int cPluginIptv::ParseFilters(const char *valueP, int *filtersP) int cPluginIptv::ParseFilters(const char *Value, int *Filters)
{ {
debug1("%s (%s, )", __PRETTY_FUNCTION__, valueP); debug("cPluginIptv::ParseFilters(): Value=%s\n", Value);
char buffer[256]; char buffer[256];
int n = 0; int n = 0;
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) { while (Value && *Value && (n < SECTION_FILTER_TABLE_SIZE)) {
strn0cpy(buffer, valueP, sizeof(buffer)); strn0cpy(buffer, Value, sizeof(buffer));
int i = atoi(buffer); int i = atoi(buffer);
debug16("%s (%s, ) filters[%d]=%d", __PRETTY_FUNCTION__, valueP, n, i); //debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
if (i >= 0) if (i >= 0)
filtersP[n++] = i; Filters[n++] = i;
if ((valueP = strchr(valueP, ' ')) != NULL) if ((Value = strchr(Value, ' ')) != NULL)
valueP++; Value++;
} }
return n; return n;
} }
bool cPluginIptv::SetupParse(const char *nameP, const char *valueP) bool cPluginIptv::SetupParse(const char *Name, const char *Value)
{ {
debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, valueP); debug("cPluginIptv::SetupParse()\n");
// Parse your own setup parameters and store their values. // Parse your own setup parameters and store their values.
if (!strcasecmp(nameP, "ExtProtocolBasePort")) if (!strcasecmp(Name, "TsBufferSize"))
IptvConfig.SetProtocolBasePort(atoi(valueP)); IptvConfig.SetTsBufferSize(atoi(Value));
else if (!strcasecmp(nameP, "SectionFiltering")) else if (!strcasecmp(Name, "TsBufferPrefill"))
IptvConfig.SetSectionFiltering(atoi(valueP)); IptvConfig.SetTsBufferPrefillRatio(atoi(Value));
else if (!strcasecmp(nameP, "DisabledFilters")) { else if (!strcasecmp(Name, "ExtProtocolBasePort"))
IptvConfig.SetExtProtocolBasePort(atoi(Value));
else if (!strcasecmp(Name, "SectionFiltering"))
IptvConfig.SetSectionFiltering(atoi(Value));
else if (!strcasecmp(Name, "DisabledFilters")) {
int DisabledFilters[SECTION_FILTER_TABLE_SIZE]; int DisabledFilters[SECTION_FILTER_TABLE_SIZE];
for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i) for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i)
DisabledFilters[i] = -1; DisabledFilters[i] = -1;
unsigned int DisabledFiltersCount = ParseFilters(valueP, DisabledFilters); unsigned int DisabledFiltersCount = ParseFilters(Value, DisabledFilters);
for (unsigned int i = 0; i < DisabledFiltersCount; ++i) for (unsigned int i = 0; i < DisabledFiltersCount; ++i)
IptvConfig.SetDisabledFilters(i, DisabledFilters[i]); IptvConfig.SetDisabledFilters(i, DisabledFilters[i]);
} }
@ -214,12 +199,12 @@ bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
return true; return true;
} }
bool cPluginIptv::Service(const char *idP, void *dataP) bool cPluginIptv::Service(const char *Id, void *Data)
{ {
debug1("%s (%s, )", __PRETTY_FUNCTION__, idP); debug("cPluginIptv::Service()\n");
if (strcmp(idP, "IptvService-v1.0") == 0) { if (strcmp(Id,"IptvService-v1.0") == 0) {
if (dataP) { if (Data) {
IptvService_v1_0 *data = reinterpret_cast<IptvService_v1_0*>(dataP); IptvService_v1_0 *data = (IptvService_v1_0*)Data;
cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex); cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex);
if (!dev) if (!dev)
return false; return false;
@ -233,7 +218,7 @@ bool cPluginIptv::Service(const char *idP, void *dataP)
const char **cPluginIptv::SVDRPHelpPages(void) const char **cPluginIptv::SVDRPHelpPages(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPluginIptv::SVDRPHelpPages()\n");
static const char *HelpPages[] = { static const char *HelpPages[] = {
"INFO [ <page> ]\n" "INFO [ <page> ]\n"
" Print IPTV device information and statistics.\n" " Print IPTV device information and statistics.\n"
@ -241,43 +226,35 @@ const char **cPluginIptv::SVDRPHelpPages(void)
" option: 1=general 2=pids 3=section filters.\n", " option: 1=general 2=pids 3=section filters.\n",
"MODE\n" "MODE\n"
" Toggles between bit or byte information mode.\n", " Toggles between bit or byte information mode.\n",
"TRAC [ <mode> ]\n"
" Gets and/or sets used tracing mode.\n",
NULL NULL
}; };
return HelpPages; return HelpPages;
} }
cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP) cString cPluginIptv::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{ {
debug1("%s (%s, %s, )", __PRETTY_FUNCTION__, commandP, optionP); debug("cPluginIptv::SVDRPCommand(): Command=%s Option=%s\n", Command, Option);
if (strcasecmp(commandP, "INFO") == 0) { if (strcasecmp(Command, "INFO") == 0) {
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex()); cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
if (device) { if (device) {
int page = IPTV_DEVICE_INFO_ALL; int page = IPTV_DEVICE_INFO_ALL;
if (optionP) { if (Option) {
page = atoi(optionP); page = atoi(Option);
if ((page < IPTV_DEVICE_INFO_ALL) || (page > IPTV_DEVICE_INFO_FILTERS)) if ((page < IPTV_DEVICE_INFO_ALL) || (page > IPTV_DEVICE_INFO_FILTERS))
page = IPTV_DEVICE_INFO_ALL; page = IPTV_DEVICE_INFO_ALL;
} }
return device->GetInformation(page); return device->GetInformation(page);
} }
else { else {
replyCodeP = 550; // Requested action not taken ReplyCode = 550; // Requested action not taken
return cString("IPTV information not available!"); return cString("IPTV information not available!");
} }
} }
else if (strcasecmp(commandP, "MODE") == 0) { else if (strcasecmp(Command, "MODE") == 0) {
unsigned int mode = !IptvConfig.GetUseBytes(); unsigned int mode = !IptvConfig.GetUseBytes();
IptvConfig.SetUseBytes(mode); IptvConfig.SetUseBytes(mode);
return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits"); 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; return NULL;
} }

48
log.h
View File

@ -1,48 +0,0 @@
/*
* 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

@ -0,0 +1,11 @@
diff -Nru vdr-1.7.27-vanilla/pat.c vdr-1.7.27-disable_ca_updates/pat.c
--- vdr-1.7.27-vanilla/pat.c 2012-03-25 15:17:57.000000000 +0300
+++ vdr-1.7.27-disable_ca_updates/pat.c 2012-03-31 20:42:14.000000000 +0300
@@ -537,6 +537,7 @@
}
if (Setup.UpdateChannels >= 2) {
Channel->SetPids(Vpid, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
+ if (!cSource::IsType(Channel->Source(), 'I'))
Channel->SetCaIds(CaDescriptors->CaIds());
Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
}

View File

@ -14,107 +14,106 @@
#define PIDSCANNER_PID_DELTA_COUNT 100 /* minimum count of pid samples for audio/video only pid detection */ #define PIDSCANNER_PID_DELTA_COUNT 100 /* minimum count of pid samples for audio/video only pid detection */
cPidScanner::cPidScanner(void) cPidScanner::cPidScanner(void)
: timeoutM(0), : timeout(0),
channelIdM(tChannelID::InvalidID), channelId(tChannelID::InvalidID),
processM(true), process(true),
vPidM(0xFFFF), Vpid(0xFFFF),
aPidM(0xFFFF), Apid(0xFFFF),
numVpidsM(0), numVpids(0),
numApidsM(0) numApids(0)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPidScanner::cPidScanner()\n");
} }
cPidScanner::~cPidScanner() cPidScanner::~cPidScanner()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cPidScanner::~cPidScanner()\n");
} }
void cPidScanner::SetChannel(const tChannelID &channelIdP) void cPidScanner::SetChannel(const tChannelID &ChannelId)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString()); debug("cPidScanner::SetChannel(): %s\n", *ChannelId.ToString());
channelIdM = channelIdP; channelId = ChannelId;
vPidM = 0xFFFF; Vpid = 0xFFFF;
numVpidsM = 0; numVpids = 0;
aPidM = 0xFFFF; Apid = 0xFFFF;
numApidsM = 0; numApids = 0;
processM = true; process = true;
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
} }
void cPidScanner::Process(const uint8_t* bufP) void cPidScanner::Process(const uint8_t* buf)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cPidScanner::Process()\n");
if (!processM) if (!process)
return; return;
// Stop scanning after defined timeout // Stop scanning after defined timeout
if (timeoutM.TimedOut()) { if (timeout.TimedOut()) {
debug1("%s Timed out determining pids", __PRETTY_FUNCTION__); debug("cPidScanner::Process: Timed out determining pids\n");
processM = false; process = false;
} }
// Verify TS packet // Verify TS packet
if (bufP[0] != 0x47) { if (buf[0] != 0x47) {
error("Not TS packet: 0x%02X", bufP[0]); error("Not TS packet: 0x%X\n", buf[0]);
return; return;
} }
// Found TS packet // Found TS packet
int pid = ts_pid(bufP); int pid = ts_pid(buf);
int xpid = (bufP[1] << 8 | bufP[2]); int xpid = (buf[1] << 8 | buf[2]);
// Check if payload available // Check if payload available
uint8_t count = payload(bufP); uint8_t count = payload(buf);
if (count == 0) if (count == 0)
return; return;
if (xpid & 0x4000) { if (xpid & 0x4000) {
// Stream start (Payload Unit Start Indicator) // Stream start (Payload Unit Start Indicator)
uchar *d = (uint8_t*)bufP; uchar *d = (uint8_t*)buf;
d += 4; d += 4;
// pointer to payload // pointer to payload
if (bufP[3] & 0x20) if (buf[3] & 0x20)
d += d[0] + 1; d += d[0] + 1;
// Skip adaption field // Skip adaption field
if (bufP[3] & 0x10) { if (buf[3] & 0x10) {
// Payload present // Payload present
if ((d[0] == 0) && (d[1] == 0) && (d[2] == 1)) { if ((d[0] == 0) && (d[1] == 0) && (d[2] == 1)) {
// PES packet start // PES packet start
int sid = d[3]; int sid = d[3];
// Stream ID // Stream ID
if ((sid >= 0xC0) && (sid <= 0xDF)) { if ((sid >= 0xC0) && (sid <= 0xDF)) {
if (pid < aPidM) { if (pid < Apid) {
debug1("%s Found lower Apid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, aPidM); debug("cPidScanner::Process: Found lower Apid: 0x%X instead of 0x%X\n", pid, Apid);
aPidM = pid; Apid = pid;
numApidsM = 1; numApids = 1;
} }
else if (pid == aPidM) { else if (pid == Apid) {
++numApidsM; ++numApids;
debug1("%s Incrementing Apids, now at %d", __PRETTY_FUNCTION__, numApidsM); debug("cPidScanner::Process: Incrementing Apids, now at %d\n", numApids);
} }
} }
else if ((sid >= 0xE0) && (sid <= 0xEF)) { else if ((sid >= 0xE0) && (sid <= 0xEF)) {
if (pid < vPidM) { if (pid < Vpid) {
debug1("%s Found lower Vpid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, vPidM); debug("cPidScanner::Process: Found lower Vpid: 0x%X instead of 0x%X\n", pid, Vpid);
vPidM = pid; Vpid = pid;
numVpidsM = 1; numVpids = 1;
} }
else if (pid == vPidM) { else if (pid == Vpid) {
++numVpidsM; ++numVpids;
debug1("%s Incrementing Vpids, now at %d", __PRETTY_FUNCTION__, numVpidsM); debug("cPidScanner::Process: Incrementing Vpids, now at %d\n", numVpids);
} }
} }
} }
if (((numVpidsM >= PIDSCANNER_VPID_COUNT) && (numApidsM >= PIDSCANNER_APID_COUNT)) || if (((numVpids >= PIDSCANNER_VPID_COUNT) && (numApids >= PIDSCANNER_APID_COUNT)) ||
(abs(numApidsM - numVpidsM) >= PIDSCANNER_PID_DELTA_COUNT)) { (abs(numApids - numVpids) >= PIDSCANNER_PID_DELTA_COUNT)) {
// Lock channels for pid updates // Lock channels for pid updates
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); if (!Channels.Lock(true, 10)) {
cStateKey StateKey; timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
cChannels *Channels = cChannels::GetChannelsWrite(StateKey, 10);
if (!Channels)
return; return;
bool ChannelsModified = false; }
cChannel *IptvChannel = Channels->GetByChannelID(channelIdM); cChannel *IptvChannel = Channels.GetByChannelID(channelId);
if (IptvChannel) { if (IptvChannel) {
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
int Atypes[MAXAPIDS + 1] = { 0 }; int Atypes[MAXAPIDS + 1] = { 0 };
@ -128,18 +127,18 @@ void cPidScanner::Process(const uint8_t* bufP)
int Ppid = IptvChannel->Ppid(); int Ppid = IptvChannel->Ppid();
int Tpid = IptvChannel->Tpid(); int Tpid = IptvChannel->Tpid();
bool foundApid = false; bool foundApid = false;
if (numVpidsM < PIDSCANNER_VPID_COUNT) if (numVpids < PIDSCANNER_VPID_COUNT)
vPidM = 0; // No detected video pid Vpid = 0; // No detected video pid
else if (numApidsM < PIDSCANNER_APID_COUNT) else if (numApids < PIDSCANNER_APID_COUNT)
aPidM = 0; // No detected audio pid Apid = 0; // No detected audio pid
for (unsigned int i = 0; i < MAXAPIDS; ++i) { for (unsigned int i = 0; i < MAXAPIDS; ++i) {
Apids[i] = IptvChannel->Apid(i); Apids[i] = IptvChannel->Apid(i);
Atypes[i] = IptvChannel->Atype(i); Atypes[i] = IptvChannel->Atype(i);
if (Apids[i] && (Apids[i] == aPidM)) if (Apids[i] && (Apids[i] == Apid))
foundApid = true; foundApid = true;
} }
if (!foundApid) { if (!foundApid) {
Apids[0] = aPidM; Apids[0] = Apid;
Atypes[0] = 4; Atypes[0] = 4;
} }
for (unsigned int i = 0; i < MAXDPIDS; ++i) { for (unsigned int i = 0; i < MAXDPIDS; ++i) {
@ -148,11 +147,11 @@ void cPidScanner::Process(const uint8_t* bufP)
} }
for (unsigned int i = 0; i < MAXSPIDS; ++i) for (unsigned int i = 0; i < MAXSPIDS; ++i)
Spids[i] = IptvChannel->Spid(i); Spids[i] = IptvChannel->Spid(i);
debug1("%s vpid=0x%04X, apid=0x%04X", __PRETTY_FUNCTION__, vPidM, aPidM); debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid);
ChannelsModified |= IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid); IptvChannel->SetPids(Vpid, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
} }
StateKey.Remove(ChannelsModified); Channels.Unlock();
processM = false; process = false;
} }
} }
} }

View File

@ -11,31 +11,21 @@
#include <vdr/tools.h> #include <vdr/tools.h>
#include <vdr/channels.h> #include <vdr/channels.h>
#include "log.h"
class cPidScanner { class cPidScanner {
private: private:
enum { cTimeMs timeout;
PIDSCANNER_APID_COUNT = 5, /* minimum count of audio pid samples for pid detection */ tChannelID channelId;
PIDSCANNER_VPID_COUNT = 5, /* minimum count of video pid samples for pid detection */ bool process;
PIDSCANNER_PID_DELTA_COUNT = 100, /* minimum count of pid samples for audio/video only pid detection */ int Vpid;
PIDSCANNER_TIMEOUT_IN_MS = 15000 /* 15s timeout for detection */ int Apid;
}; int numVpids;
cTimeMs timeoutM; int numApids;
tChannelID channelIdM;
bool processM;
int vPidM;
int aPidM;
int numVpidsM;
int numApidsM;
public: public:
cPidScanner(void); cPidScanner(void);
~cPidScanner(); ~cPidScanner();
void SetChannel(const tChannelID &channelIdP); void SetChannel(const tChannelID &ChannelId);
void Process(const uint8_t* bufP); void Process(const uint8_t* buf);
void Open() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); }
void Close() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(0); }
}; };
#endif // __PIDSCANNER_H #endif // __PIDSCANNER_H

View File

@ -1,134 +0,0 @@
# 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,16 +1,15 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala # Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package. # This file is distributed under the same license as the iptv package.
# Tobias <vdr@e-tobi.net>, 2007. # Tobias <vdr@e-tobi.net>, 2007.
# Frank Neumann, 2015.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n" "Project-Id-Version: vdr-iptv 0.5.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n" "POT-Creation-Date: 2012-02-02 02:02+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n" "PO-Revision-Date: 2012-02-02 02:02+0300\n"
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n" "Last-Translator: Tobias Grimm <tg@e-tobi.net>\n"
"Language-Team: German <vdr@linuxtv.org>\n" "Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n" "Language: de\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -27,8 +26,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)" msgid "SDT (0x42)"
msgstr "SDT (0x42)" msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)" msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)" msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)" msgid "TDT (0x70)"
msgstr "TDT (0x70)" msgstr "TDT (0x70)"
@ -52,22 +57,37 @@ msgid "Bits/bytes"
msgstr "Bits/Bytes" msgstr "Bits/Bytes"
msgid "IPTV information not available!" msgid "IPTV information not available!"
msgstr "Keine IPTV Informationen verfügbar!" msgstr "IPTV Informationen nicht verfügbar!"
msgid "Protocol base port" msgid "TS buffer size [MB]"
msgstr "Basis Port Protokoll" msgstr "TS Puffergröße [MB]"
msgid "" msgid ""
"Define a base port used by CURL/EXT protocol.\n" "Define a ringbuffer size for transport streams in megabytes.\n"
"\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." "Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr "" msgstr ""
"Bestimme einen Basis Port für das CURL/EXT Protokoll.\n"
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"
"\n" "\n"
"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." "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 ""
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Benutze Abschnittsfilter" msgstr "Benutze Abschnittsfilterung"
msgid "" msgid ""
"Define whether the section filtering shall be used.\n" "Define whether the section filtering shall be used.\n"
@ -75,28 +95,22 @@ 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" "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." "Enabling this feature does not affect streams that do not contain section data."
msgstr "" 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 "Disabled filters" msgid "Disable filters"
msgstr "Deaktivierte Filter" msgstr "Deaktiviere Filter"
msgid "" msgid ""
"Define number of section filters to be disabled.\n" "Define number of section filters to be disabled.\n"
"\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." "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 "" 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."
msgid "Filter" #. TRANSLATORS: note the singular!
msgstr "Filter" msgid "Disable filter"
msgstr "Deaktiviere Filter"
msgid "Define an ill-behaving filter to be blacklisted." msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Bestimme einen fehlerhaften Filter der ausgeblendet werden soll." msgstr ""
msgid "Help" msgid "Help"
msgstr "Hilfe" msgstr "Hilfe"
@ -104,9 +118,6 @@ msgstr "Hilfe"
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
@ -116,14 +127,20 @@ msgstr "DATEI"
msgid "EXT" msgid "EXT"
msgstr "EXT" msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid" msgid "Rid"
msgstr "Rid" msgstr "Rid"
msgid "Scan section ids" msgid "Scan section ids"
msgstr "Suche Abschnitt IDs" msgstr "Scanne Section IDS"
msgid "Scan pids" msgid "Scan pids"
msgstr "Suche PIDs" msgstr "Scanne PIDS"
msgid "Protocol" msgid "Protocol"
msgstr "Protokoll" msgstr "Protokoll"

View File

@ -1,134 +0,0 @@
# 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. # VDR plugin language source file.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala # Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package. # This file is distributed under the same license as the iptv package.
# Rolf Ahrenberg # Rolf Ahrenberg
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n" "Project-Id-Version: vdr-iptv 0.5.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n" "POT-Creation-Date: 2012-02-02 02:02+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n" "PO-Revision-Date: 2012-02-02 02:02+0300\n"
"Last-Translator: Rolf Ahrenberg\n" "Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n" "Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n" "Language: fi\n"
@ -25,8 +25,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)" msgid "SDT (0x42)"
msgstr "SDT (0x42)" msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)" msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)" msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)" msgid "TDT (0x70)"
msgstr "TDT (0x70)" msgstr "TDT (0x70)"
@ -52,17 +58,41 @@ msgstr "Bitit/tavut"
msgid "IPTV information not available!" msgid "IPTV information not available!"
msgstr "IPTV-tietoja ei saatavilla!" msgstr "IPTV-tietoja ei saatavilla!"
msgid "Protocol base port" msgid "TS buffer size [MB]"
msgstr "Protokollan perusportti" msgstr "TS-puskurin koko [MB]"
msgid "" msgid ""
"Define a base port used by CURL/EXT protocol.\n" "Define a ringbuffer size for transport streams in megabytes.\n"
"\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." "Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr "" msgstr ""
"Määrittele protokollan käyttämä perusportti.\n" "Määritä rengaspuskurin koko TS-lähetteelle megatavuina.\n"
"\n" "\n"
"Porttiavaruuden koko määräytyy käytettyjen IPTV-laitteiden mukaan. Laajennos lukee CURL/EXT-protokollan yhteydessä perusportista dataa, jota ulkoiset ohjelmistot tarjoavat." "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."
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Käytä sektioiden suodatusta" msgstr "Käytä sektioiden suodatusta"
@ -78,7 +108,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" "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." "Toiminto ei vaikuta lähetteeseen, jossa ei ole sektioita."
msgid "Disabled filters" msgid "Disable filters"
msgstr "Poista suodattimia käytöstä" msgstr "Poista suodattimia käytöstä"
msgid "" msgid ""
@ -90,8 +120,9 @@ msgstr ""
"\n" "\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." "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."
msgid "Filter" #. TRANSLATORS: note the singular!
msgstr "Suodatin" msgid "Disable filter"
msgstr "Poista suodatin käytöstä"
msgid "Define an ill-behaving filter to be blacklisted." msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle listalle." msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle listalle."
@ -102,9 +133,6 @@ msgstr "Opaste"
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
@ -114,6 +142,12 @@ msgstr "FILE"
msgid "EXT" msgid "EXT"
msgstr "EXT" msgstr "EXT"
msgid "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "Lähete-ID"
msgid "Rid" msgid "Rid"
msgstr "Radio-ID" msgstr "Radio-ID"

View File

@ -1,15 +1,15 @@
# French translations for iptv package. # French translations for iptv package.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala # Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package. # This file is distributed under the same license as the iptv package.
# Bruno ROUSSEL <bruno.roussel@free.fr>, 2007. # Bruno ROUSSEL <bruno.roussel@free.fr>, 2007.
# NIVAL Michaël <mnival@club-internet.fr>, 2008. # NIVAL Michaël <mnival@club-internet.fr>, 2008.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n" "Project-Id-Version: vdr-iptv 0.5.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n" "POT-Creation-Date: 2012-02-02 02:02+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n" "PO-Revision-Date: 2010-09-09 09:09+0300\n"
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n" "Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
"Language-Team: French <vdr@linuxtv.org>\n" "Language-Team: French <vdr@linuxtv.org>\n"
"Language: fr\n" "Language: fr\n"
@ -27,8 +27,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)" msgid "SDT (0x42)"
msgstr "SDT (0x42)" msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)" msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)" msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)" msgid "TDT (0x70)"
msgstr "TDT (0x70)" msgstr "TDT (0x70)"
@ -54,17 +60,41 @@ msgstr "Bits/Bytes"
msgid "IPTV information not available!" msgid "IPTV information not available!"
msgstr "Information sur IPTV non disponible !" msgstr "Information sur IPTV non disponible !"
msgid "Protocol base port" msgid "TS buffer size [MB]"
msgstr "Port de base du protocole" msgstr "Taille du buffer TS [MB]"
msgid "" msgid ""
"Define a base port used by CURL/EXT protocol.\n" "Define a ringbuffer size for transport streams in megabytes.\n"
"\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." "Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr "" msgstr ""
"Définit le port de base utilisé par le protocole CURL/EXT.\n" "Définit la taille du ringbuffer pour le transport du flux en megabytes.\n"
"\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 CURL/EXT." "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."
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Utiliser le filtrage de section" msgstr "Utiliser le filtrage de section"
@ -80,7 +110,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" "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." "L'activation de cette fonctionnalité n'a pas d'incidence sur les flux qui ne contiennent pas de données de la section."
msgid "Disabled filters" msgid "Disable filters"
msgstr "Désactiver les filtres" msgstr "Désactiver les filtres"
msgid "" msgid ""
@ -92,8 +122,9 @@ msgstr ""
"\n" "\n"
"Certains filtrage de section peux engendrer des comportement indésirables. Blacklist les filtres qui seront laissé intact pour VDR." "Certains filtrage de section peux engendrer des comportement indésirables. Blacklist les filtres qui seront laissé intact pour VDR."
msgid "Filter" #. TRANSLATORS: note the singular!
msgstr "Filtre" msgid "Disable filter"
msgstr "Désactiver le filtre"
msgid "Define an ill-behaving filter to be blacklisted." msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Définit les mauvais comportement qui doivent être désactivé." msgstr "Définit les mauvais comportement qui doivent être désactivé."
@ -104,9 +135,6 @@ msgstr "Aide"
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
@ -116,6 +144,12 @@ msgstr "FICHIER"
msgid "EXT" msgid "EXT"
msgstr "EXT" msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid" msgid "Rid"
msgstr "Rid" msgstr "Rid"

View File

@ -1,14 +1,14 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala # Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package. # This file is distributed under the same license as the iptv package.
# Diego Pierotto <vdr-italian@tiscali.it>, 2008. # Diego Pierotto <vdr-italian@tiscali.it>, 2008.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n" "Project-Id-Version: vdr-iptv 0.5.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n" "POT-Creation-Date: 2012-02-02 02:02+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n" "PO-Revision-Date: 2012-02-02 02:02+0300\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: Italian <vdr@linuxtv.org>\n" "Language-Team: Italian <vdr@linuxtv.org>\n"
"Language: it\n" "Language: it\n"
@ -26,8 +26,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)" msgid "SDT (0x42)"
msgstr "SDT (0x42)" msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)" msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)" msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)" msgid "TDT (0x70)"
msgstr "TDT (0x70)" msgstr "TDT (0x70)"
@ -53,17 +59,41 @@ msgstr "Bits/bytes"
msgid "IPTV information not available!" msgid "IPTV information not available!"
msgstr "Informazione IPTV non disponibile!" msgstr "Informazione IPTV non disponibile!"
msgid "Protocol base port" msgid "TS buffer size [MB]"
msgstr "Porta base protocollo" msgstr "Dimensione buffer TS [MB]"
msgid "" msgid ""
"Define a base port used by CURL/EXT protocol.\n" "Define a ringbuffer size for transport streams in megabytes.\n"
"\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." "Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr "" msgstr ""
"Definisci una porta base usata dal protocollo CURL/EXT.\n" "Definisci una dimensione del buffer in MB per i flussi di trasporto.\n"
"\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 CURL/EXT." "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."
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Utilizza sezione filtri" msgstr "Utilizza sezione filtri"
@ -79,7 +109,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" "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." "Abilitare questa funzione non influisce sui flussi che non contengono dati di sezione."
msgid "Disabled filters" msgid "Disable filters"
msgstr "Disabilita filtri" msgstr "Disabilita filtri"
msgid "" msgid ""
@ -91,8 +121,9 @@ msgstr ""
"\n" "\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." "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."
msgid "Filter" #. TRANSLATORS: note the singular!
msgstr "Filtro" msgid "Disable filter"
msgstr "Disabilita filtro"
msgid "Define an ill-behaving filter to be blacklisted." msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definisci un filtro corrotto che sarà messo nella lista nera." msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
@ -103,9 +134,6 @@ msgstr "Aiuto"
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
@ -115,6 +143,12 @@ msgstr "FILE"
msgid "EXT" msgid "EXT"
msgstr "EXT" msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid" msgid "Rid"
msgstr "Rid" msgstr "Rid"

View File

@ -1,133 +0,0 @@
# 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. # VDR plugin language source file.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala # Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package. # This file is distributed under the same license as the iptv package.
# Carel, 2010. # Carel, 2010.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-iptv 2.4.0\n" "Project-Id-Version: vdr-iptv 0.5.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2018-04-15 04:15+0300\n" "POT-Creation-Date: 2012-02-02 02:02+0300\n"
"PO-Revision-Date: 2018-04-15 04:15+0300\n" "PO-Revision-Date: 2012-02-02 02:02+0300\n"
"Last-Translator: Carel\n" "Last-Translator: Carel\n"
"Language-Team: Dutch <vdr@linuxtv.org>\n" "Language-Team: Dutch <vdr@linuxtv.org>\n"
"Language: nl\n" "Language: nl\n"
@ -26,8 +26,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)" msgid "SDT (0x42)"
msgstr "SDT (0x42)" msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)" msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)" msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)" msgid "TDT (0x70)"
msgstr "TDT (0x70)" msgstr "TDT (0x70)"
@ -53,17 +59,41 @@ msgstr "Bits/Bytes"
msgid "IPTV information not available!" msgid "IPTV information not available!"
msgstr "IPTV informatie niet beschikbaar!" msgstr "IPTV informatie niet beschikbaar!"
msgid "Protocol base port" msgid "TS buffer size [MB]"
msgstr "Protocol basispoort" msgstr "TS buffergrootte [MB]"
msgid "" msgid ""
"Define a base port used by CURL/EXT protocol.\n" "Define a ringbuffer size for transport streams in megabytes.\n"
"\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." "Smaller sizes help memory consumption, but are more prone to buffer overflows."
msgstr "" msgstr ""
"Bepaal de basispoort voor het CURL/EXT protocol.\n" "Stel de grootte van de ringbuffer vast voor transportstreams in megabytes.\n"
"\n" "\n"
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het CURL/EXT protocol wordt gebruikt." "Bij lage waarden zapt VDR sneller maar kunnen leiden tot bufferoverschreidingen en dus dropouts."
msgid "TS buffer prefill ratio [%]"
msgstr "TS buffer-preload [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
"Stel een 'prefil ratio' in voor de ringbuffer voor transportstreams voor de data naar VDR wordt verstuurd.\n"
"\n"
"Dit is aan te bevelen bij onbetrouwbare of langzame verbindingen."
msgid "EXT protocol base port"
msgstr "EXT protocol basispoort"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
"Bepaal de basispoort voor het EXT protocol.\n"
"\n"
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het EXT protocol wordt gebruikt."
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Benutze Abschnittsfilterung" msgstr "Benutze Abschnittsfilterung"
@ -78,7 +108,7 @@ msgstr ""
"\n" "\n"
"Bij sectiefiltering zal de IPTV plugin VDR van extra informatie over de stream voorzien. VDR kan dan bijvoorbeeld automatisch de PIDs wijzigen of de EPG tonen.Het gebruik van deze mogelijkheid heeft geen effect op streams die geen sectiedata bevatten." "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 "Disabled filters" msgid "Disable filters"
msgstr "Deactiveer filter" msgstr "Deactiveer filter"
msgid "" msgid ""
@ -90,8 +120,9 @@ msgstr ""
"\n" "\n"
"Sommige sctiefilters kunnen ongewenste effecten veroorzaken. Door ze hier op te nemen blijft de data intact zodat VDR het kan blijven gebruiken." "Sommige sctiefilters kunnen ongewenste effecten veroorzaken. Door ze hier op te nemen blijft de data intact zodat VDR het kan blijven gebruiken."
msgid "Filter" #. TRANSLATORS: note the singular!
msgstr "Filter" msgid "Disable filter"
msgstr "Deactiveer filter"
msgid "Define an ill-behaving filter to be blacklisted." msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Blacklist een probleem veroorzakend filter " msgstr "Blacklist een probleem veroorzakend filter "
@ -102,9 +133,6 @@ msgstr "Help"
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
@ -114,6 +142,12 @@ msgstr "BESTAND"
msgid "EXT" msgid "EXT"
msgstr "EXT" msgstr "EXT"
msgid "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid" msgid "Rid"
msgstr "Rid" msgstr "Rid"

View File

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

View File

@ -1,638 +0,0 @@
/*
* protocolcurl.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include "common.h"
#include "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) 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() 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(IPTV_BUFFER_SIZE, 7 * TS_SIZE, false, "IPTV CURL")),
rtspControlM(""),
modeM(eModeUnknown),
timeoutM(),
connectedM(false),
pausedM(false)
{
debug1("%s", __PRETTY_FUNCTION__);
if (ringBufferM) {
ringBufferM->SetTimeouts(100, 0);
ringBufferM->SetIoThrottle();
}
Connect();
}
cIptvProtocolCurl::~cIptvProtocolCurl()
{
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;
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
if (obj && !obj->PutData((unsigned char *)ptrP, (int)len))
return CURL_WRITEFUNC_PAUSE;
return len;
}
size_t cIptvProtocolCurl::WriteRtspCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
unsigned char *p = (unsigned char *)ptrP;
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)) {
int length = (p[2] << 8) | p[3];
if (length > 3) {
// Skip interleave header
p += 4;
// http://tools.ietf.org/html/rfc3550
// http://tools.ietf.org/html/rfc2250
// Version
unsigned int v = (p[0] >> 6) & 0x03;
// Extension bit
unsigned int x = (p[0] >> 4) & 0x01;
// CSCR count
unsigned int cc = p[0] & 0x0F;
// Payload type: MPEG2 TS = 33
//unsigned int pt = p[1] & 0x7F;
// Header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// Check if extension
if (x) {
// Extension header length
unsigned int ehl = (((p[headerlen + 2] & 0xFF) << 8) |(p[headerlen + 3] & 0xFF));
// Update header length
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
}
// Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((length - headerlen) % TS_SIZE) == 0) && (p[headerlen] == TS_SYNC_BYTE)) {
// Set argument point to payload in read buffer
obj->PutData(&p[headerlen], (length - headerlen));
}
}
}
return len;
}
size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
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) {
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:%255ms", &s) == 1)
control = compactspace(s);
free(s);
break;
}
r = strtok(NULL, "\r\n");
}
if (!isempty(*control) && obj)
obj->SetRtspControl(*control);
return len;
}
size_t cIptvProtocolCurl::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
//cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
size_t len = sizeP * nmembP;
debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
char *p = (char *)ptrP;
char *r = strtok(p, "\r\n");
while (r) {
debug16("%s (, %zu, %zu, ) len=%zu r=%s", __PRETTY_FUNCTION__, sizeP, nmembP, len, r);
r = strtok(NULL, "\r\n");
}
return len;
}
void cIptvProtocolCurl::SetRtspControl(const char *controlP)
{
cMutexLock MutexLock(&mutexM);
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);
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)) {
debug1("%s Pause free=%d available=%d len=%d", __PRETTY_FUNCTION__,
ringBufferM->Free(), ringBufferM->Available(), lenP);
pausedM = true;
return false;
}
int p = ringBufferM->Put(dataP, lenP);
if (p != lenP)
ringBufferM->ReportOverflow(lenP - p);
}
return true;
}
void cIptvProtocolCurl::DelData(int lenP)
{
cMutexLock MutexLock(&mutexM);
debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM && (lenP >= 0))
ringBufferM->Del(lenP);
}
void cIptvProtocolCurl::ClearData()
{
debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM)
ringBufferM->Clear();
}
unsigned char *cIptvProtocolCurl::GetData(int &lenP)
{
cMutexLock MutexLock(&mutexM);
debug16("%s", __PRETTY_FUNCTION__);
unsigned char *p = NULL;
lenP = 0;
if (ringBufferM) {
int count = 0;
p = ringBufferM->Get(count);
#if 0
if (p && count >= TS_SIZE) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < count; ++i) {
if (p[i] == TS_SYNC_BYTE) {
count = i;
break;
}
}
error("IPTV skipped %d bytes to sync on TS packet", count);
ringBufferM->Del(count);
lenP = 0;
return NULL;
}
}
#endif
count -= (count % TS_SIZE);
lenP = count;
}
return p;
}
bool cIptvProtocolCurl::Connect()
{
cMutexLock MutexLock(&mutexM);
debug1("%s", __PRETTY_FUNCTION__);
if (connectedM)
return true;
// Initialize the curl session
if (!handleM)
handleM = curl_easy_init();
if (handleM && !isempty(*streamUrlM)) {
CURLcode res = CURLE_OK;
cString netrc = cString::sprintf("%s/netrc", IptvConfig.GetConfigDirectory());
// Verbose output
iptv_curl_easy_setopt(handleM, CURLOPT_VERBOSE, 1L);
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);
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEDATA, this);
iptv_curl_easy_setopt(handleM, CURLOPT_HEADERFUNCTION, cIptvProtocolCurl::HeaderCallback);
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEHEADER, this);
// No progress meter and no signaling
iptv_curl_easy_setopt(handleM, CURLOPT_NOPROGRESS, 1L);
iptv_curl_easy_setopt(handleM, CURLOPT_NOSIGNAL, 1L);
// Support netrc
iptv_curl_easy_setopt(handleM, CURLOPT_NETRC, (long)CURL_NETRC_OPTIONAL);
iptv_curl_easy_setopt(handleM, CURLOPT_NETRC_FILE, *netrc);
// 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));
// Set URL
char *p = curl_easy_unescape(handleM, *streamUrlM, 0, NULL);
streamUrlM = p;
curl_free(p);
iptv_curl_easy_setopt(handleM, CURLOPT_URL, *streamUrlM);
// 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);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
iptv_curl_easy_perform(handleM);
// Request session description - SDP is delivered in message body and not in the header!
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEFUNCTION, cIptvProtocolCurl::DescribeCallback);
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEDATA, this);
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_DESCRIBE);
iptv_curl_easy_perform(handleM);
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEFUNCTION, NULL);
iptv_curl_easy_setopt(handleM, CURLOPT_WRITEDATA, NULL);
// Setup media stream
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);
iptv_curl_easy_perform(handleM);
// Start playing
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_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
iptv_curl_easy_perform(handleM);
// Start receiving
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:
{
// Limit download speed (bytes/s)
iptv_curl_easy_setopt(handleM, CURLOPT_MAX_RECV_SPEED_LARGE, eMaxDownloadSpeedMBits * 131072L);
// Follow location
iptv_curl_easy_setopt(handleM, CURLOPT_FOLLOWLOCATION, 1L);
// Fail if HTTP return code is >= 400
iptv_curl_easy_setopt(handleM, CURLOPT_FAILONERROR, 1L);
// Set additional headers to prevent caching
headerListM = curl_slist_append(headerListM, "Cache-Control: no-store, no-cache, must-revalidate");
headerListM = curl_slist_append(headerListM, "Cache-Control: post-check=0, pre-check=0");
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;
}
timeoutM.Set(eKeepAliveIntervalMs);
connectedM = true;
return true;
}
return false;
}
bool cIptvProtocolCurl::Disconnect()
{
cMutexLock MutexLock(&mutexM);
debug1("%s", __PRETTY_FUNCTION__);
if (!connectedM)
return true;
// Terminate curl session
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;
// Teardown rtsp session
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_TEARDOWN);
iptv_curl_easy_perform(handleM);
rtspControlM = "";
isActiveM = false;
// Close the listening socket
CloseSocket();
}
break;
#endif
case eModeHttp:
case eModeHttps:
case eModeFile:
case eModeUnknown:
default:
break;
}
// Cleanup curl stuff
if (headerListM) {
curl_slist_free_all(headerListM);
headerListM = NULL;
}
curl_easy_cleanup(handleM);
handleM = NULL;
}
ClearData();
connectedM = false;
return true;
}
bool cIptvProtocolCurl::Open(void)
{
debug1("%s", __PRETTY_FUNCTION__);
return Connect();
}
bool cIptvProtocolCurl::Close(void)
{
debug1("%s", __PRETTY_FUNCTION__);
Disconnect();
return true;
}
int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
{
debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
int len = 0;
if (ringBufferM) {
// Fill up the buffer
if (handleM) {
switch (modeM) {
#ifdef USE_RTSP
case eModeRtsp:
{
cMutexLock MutexLock(&mutexM);
CURLcode res = CURLE_OK;
// 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:
if (multiM) {
CURLMcode res;
int running_handles;
do {
cMutexLock MutexLock(&mutexM);
res = curl_multi_perform(multiM, &running_handles);
} while (res == CURLM_CALL_MULTI_PERFORM);
// Use 20% threshold before continuing to filling up the buffer.
mutexM.Lock();
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();
// 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:
default:
break;
}
}
// ... and try to empty it
unsigned char *p = GetData(len);
if (p && (len > 0)) {
len = min(len, (int)bufferLenP);
memcpy(bufferAddrP, p, len);
DelData(len);
debug16("%s Get %d bytes", __PRETTY_FUNCTION__, len);
}
}
return len;
}
bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, const int indexP)
{
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Disconnect
Disconnect();
// Update stream URL
streamUrlM = locationP;
cString protocol = ChangeCase(streamUrlM, false).Truncate(5);
if (startswith(*protocol, "rtsp"))
modeM = eModeRtsp;
else if (startswith(*protocol, "https"))
modeM = eModeHttps;
else if (startswith(*protocol, "http"))
modeM = eModeHttp;
else if (startswith(*protocol, "file"))
modeM = eModeFile;
else
modeM = eModeUnknown;
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)
{
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
}

View File

@ -1,79 +0,0 @@
/*
* protocolcurl.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_PROTOCOLCURL_H
#define __IPTV_PROTOCOLCURL_H
#include <curl/curl.h>
#include <curl/easy.h>
#include <vdr/ringbuffer.h>
#include <vdr/thread.h>
#include <vdr/tools.h>
#include "protocolif.h"
#include "socket.h"
class cIptvProtocolCurl : public cIptvUdpSocket, public cIptvProtocolIf {
private:
enum eModeType {
eModeUnknown = 0,
eModeHttp,
eModeHttps,
eModeRtsp,
eModeFile,
eModeCount
};
enum {
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);
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
cString streamUrlM;
int streamParamM;
int streamPortM;
cMutex mutexM;
CURL *handleM;
CURLM *multiM;
struct curl_slist *headerListM;
cRingBufferLinear *ringBufferM;
cString rtspControlM;
eModeType modeM;
cTimeMs timeoutM;
bool connectedM;
bool pausedM;
bool Connect(void);
bool Disconnect(void);
bool PutData(unsigned char *dataP, int lenP);
void DelData(int lenP);
void ClearData(void);
unsigned char *GetData(int &lenP);
public:
cIptvProtocolCurl();
virtual ~cIptvProtocolCurl();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
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);
void SetRtspControl(const char *controlP);
};
#endif // __IPTV_PROTOCOLCURL_H

View File

@ -17,168 +17,146 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolext.h" #include "protocolext.h"
#ifndef EXTSHELL
#define EXTSHELL "/bin/bash"
#endif
cIptvProtocolExt::cIptvProtocolExt() cIptvProtocolExt::cIptvProtocolExt()
: pidM(-1), : pid(-1),
scriptFileM(""), scriptFile(""),
scriptParameterM(0), scriptParameter(0),
streamPortM(0) streamPort(0)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolExt::cIptvProtocolExt()\n");
} }
cIptvProtocolExt::~cIptvProtocolExt() cIptvProtocolExt::~cIptvProtocolExt()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolExt::~cIptvProtocolExt()\n");
// Drop the socket connection // Drop the socket connection
cIptvProtocolExt::Close(); cIptvProtocolExt::Close();
} }
void cIptvProtocolExt::ExecuteScript(void) void cIptvProtocolExt::ExecuteScript(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolExt::ExecuteScript()\n");
// Check if already executing // Check if already executing
if (isActiveM || isempty(scriptFileM)) if (isActive || isempty(scriptFile))
return; return;
if (pidM > 0) { if (pid > 0) {
error("Cannot execute script!"); error("Cannot execute script!");
return; return;
} }
// Let's fork // Let's fork
ERROR_IF_RET((pidM = fork()) == -1, "fork()", return); ERROR_IF_RET((pid = fork()) == -1, "fork()", return);
// Check if child process // Check if child process
if (pidM == 0) { if (pid == 0) {
// Close all dup'ed filedescriptors // Close all dup'ed filedescriptors
int MaxPossibleFileDescriptors = getdtablesize(); int MaxPossibleFileDescriptors = getdtablesize();
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++) for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
close(i); close(i);
// Execute the external script // Execute the external script
cString cmd = cString::sprintf("%s %d %d", *scriptFileM, scriptParameterM, streamPortM); cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, streamPort);
debug1("%s Child %s", __PRETTY_FUNCTION__, *cmd); debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
// Create a new session for a process group if (execl("/bin/bash", "sh", "-c", *cmd, (char *)NULL) == -1) {
ERROR_IF_RET(setsid() == -1, "setsid()", _exit(-1));
if (execl(EXTSHELL, "sh", "-c", *cmd, (char *)NULL) == -1) {
error("Script execution failed: %s", *cmd); error("Script execution failed: %s", *cmd);
_exit(-1); _exit(-1);
} }
_exit(0); _exit(0);
} }
else { else {
debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM); debug("cIptvProtocolExt::ExecuteScript(): pid=%d\n", pid);
} }
} }
void cIptvProtocolExt::TerminateScript(void) void cIptvProtocolExt::TerminateScript(void)
{ {
debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM); debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pid);
if (!isActiveM || isempty(scriptFileM)) if (!isActive || isempty(scriptFile))
return; return;
if (pidM > 0) { if (pid > 0) {
const unsigned int timeoutms = 100; const unsigned int timeoutms = 100;
unsigned int waitms = 0; unsigned int waitms = 0;
siginfo_t waitStatus;
bool waitOver = false; bool waitOver = false;
// Signal and wait for termination // signal and wait for termination
int retval = killpg(pidM, SIGINT); int retval = kill(pid, SIGINT);
ERROR_IF_RET(retval < 0, "kill()", waitOver = true); ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
while (!waitOver) { while (!waitOver) {
retval = 0; retval = 0;
waitms += timeoutms; waitms += timeoutms;
if ((waitms % 2000) == 0) { if ((waitms % 2000) == 0) {
error("Script '%s' won't terminate - killing it!", *scriptFileM); error("Script '%s' won't terminate - killing it!", *scriptFile);
killpg(pidM, SIGKILL); kill(pid, SIGKILL);
} }
// Clear wait status to make sure child exit status is accessible // Clear wait status to make sure child exit status is accessible
// and wait for child termination memset(&waitStatus, '\0', sizeof(waitStatus));
#ifdef __FreeBSD__ // Wait for child termination
int waitStatus = 0; retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
retval = waitpid(pidM, &waitStatus, WNOHANG);
#else // __FreeBSD__
siginfo_t waitStatus;
memset(&waitStatus, 0, sizeof(waitStatus));
retval = waitid(P_PID, pidM, &waitStatus, (WNOHANG | WEXITED));
#endif // __FreeBSD__
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true); ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
// These are the acceptable conditions under which child exit is // These are the acceptable conditions under which child exit is
// regarded as successful // regarded as successful
#ifdef __FreeBSD__ if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
if (retval > 0 && (WIFEXITED(waitStatus) || WIFSIGNALED(waitStatus))) {
#else // __FreeBSD__
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pidM) &&
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) { ((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
#endif // __FreeBSD__ debug("Child (%d) exited as expected\n", pid);
debug1("%s Child (%d) exited as expected", __PRETTY_FUNCTION__, pidM);
waitOver = true; waitOver = true;
} }
// Unsuccessful wait, avoid busy looping // Unsuccessful wait, avoid busy looping
if (!waitOver) if (!waitOver)
cCondWait::SleepMs(timeoutms); cCondWait::SleepMs(timeoutms);
} }
pidM = -1; pid = -1;
} }
} }
bool cIptvProtocolExt::Open(void) bool cIptvProtocolExt::Open(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolExt::Open()\n");
// Reject empty script files // Reject empty script files
if (!strlen(*scriptFileM)) if (!strlen(*scriptFile))
return false; return false;
// Create the listening socket // Create the listening socket
OpenSocket(streamPortM); OpenSocket(streamPort);
// Execute the external script // Execute the external script
ExecuteScript(); ExecuteScript();
isActiveM = true; isActive = true;
return true; return true;
} }
bool cIptvProtocolExt::Close(void) bool cIptvProtocolExt::Close(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolExt::Close()\n");
// Terminate the external script // Terminate the external script
TerminateScript(); TerminateScript();
isActiveM = false; isActive = false;
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
return true; return true;
} }
int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) int cIptvProtocolExt::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP); return cIptvUdpSocket::Read(BufferAddr, BufferLen);
} }
bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int Index)
{ {
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP); debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(locationP)) { if (!isempty(Location)) {
struct stat stbuf; struct stat stbuf;
// Update script file and parameter // Update script file and parameter
scriptFileM = cString::sprintf("%s/%s", IptvConfig.GetResourceDirectory(), locationP); scriptFile = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), Location);
if ((stat(*scriptFileM, &stbuf) != 0) || (strstr(*scriptFileM, "..") != 0)) { if ((stat(*scriptFile, &stbuf) != 0) || (strstr(*scriptFile, "..") != 0)) {
error("Non-existent or relative path script '%s'", *scriptFileM); error("Non-existent or relative path script '%s'", *scriptFile);
return false; return false;
} }
scriptParameterM = parameterP; scriptParameter = Parameter;
// Update listen port // Update listen port
streamPortM = IptvConfig.GetProtocolBasePort() + indexP * 2; streamPort = IptvConfig.GetExtProtocolBasePort() + Index;
} }
return true; 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) cString cIptvProtocolExt::GetInformation(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvProtocolExt::GetInformation()");
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM); return cString::sprintf("ext://%s:%d", *scriptFile, scriptParameter);
} }

View File

@ -14,10 +14,10 @@
class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf { class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf {
private: private:
int pidM; int pid;
cString scriptFileM; cString scriptFile;
int scriptParameterM; int scriptParameter;
int streamPortM; int streamPort;
private: private:
void TerminateScript(void); void TerminateScript(void);
@ -26,9 +26,8 @@ private:
public: public:
cIptvProtocolExt(); cIptvProtocolExt();
virtual ~cIptvProtocolExt(); virtual ~cIptvProtocolExt();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool SetSource(const char* locationP, const int parameterP, const int indexP); bool Set(const char* Location, const int Parameter, const int Index);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void); cString GetInformation(void);

View File

@ -12,77 +12,76 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolfile.h" #include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile() cIptvProtocolFile::cIptvProtocolFile()
: fileLocationM(strdup("")), : fileDelay(0),
fileDelayM(0), fileStream(NULL),
fileStreamM(NULL), isActive(false)
isActiveM(false)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::cIptvProtocolFile()\n");
fileLocation = strdup("");
} }
cIptvProtocolFile::~cIptvProtocolFile() cIptvProtocolFile::~cIptvProtocolFile()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::~cIptvProtocolFile()\n");
// Drop open handles // Drop open handles
cIptvProtocolFile::Close(); cIptvProtocolFile::Close();
// Free allocated memory // Free allocated memory
free(fileLocationM); free(fileLocation);
} }
bool cIptvProtocolFile::OpenFile(void) bool cIptvProtocolFile::OpenFile(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::OpenFile()\n");
// Check that stream address is valid // Check that stream address is valid
if (!isActiveM && !isempty(fileLocationM)) { if (!isActive && !isempty(fileLocation)) {
fileStreamM = fopen(fileLocationM, "rb"); fileStream = fopen(fileLocation, "rb");
ERROR_IF_RET(!fileStreamM || ferror(fileStreamM), "fopen()", return false); ERROR_IF_RET(!fileStream || ferror(fileStream), "fopen()", return false);
// Update active flag // Update active flag
isActiveM = true; isActive = true;
} }
return true; return true;
} }
void cIptvProtocolFile::CloseFile(void) void cIptvProtocolFile::CloseFile(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::CloseFile()\n");
// Check that file stream is valid // Check that file stream is valid
if (isActiveM && !isempty(fileLocationM)) { if (isActive && !isempty(fileLocation)) {
fclose(fileStreamM); fclose(fileStream);
// Update active flag // Update active flag
isActiveM = false; isActive = false;
} }
} }
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) int cIptvProtocolFile::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP); //debug("cIptvProtocolFile::Read()\n");
// Check errors // Check errors
if (!fileStreamM || ferror(fileStreamM)) { if (ferror(fileStream)) {
debug1("%s (, %d) Stream error", __PRETTY_FUNCTION__, bufferLenP); debug("Read error\n");
return -1; return -1;
} }
// Rewind if EOF // Rewind if EOF
if (feof(fileStreamM)) if (feof(fileStream))
rewind(fileStreamM); rewind(fileStream);
// Sleep before reading the file stream to prevent aggressive busy looping // Sleep before reading the file stream to prevent aggressive busy looping
// and prevent transfer ringbuffer overflows // and prevent transfer ringbuffer overflows
if (fileDelayM) if (fileDelay)
cCondWait::SleepMs(fileDelayM); cCondWait::SleepMs(fileDelay);
// This check is to prevent a race condition where file may be switched off // This check is to prevent a race condition where file may be switched off
// during the sleep and buffers are disposed. Check here that the plugin is // during the sleep and buffers are disposed. Check here that the plugin is
// still active before accessing the buffers // still active before accessing the buffers
if (isActiveM) if (isActive)
return (int)fread(bufferAddrP, sizeof(unsigned char), bufferLenP, fileStreamM); return (int)fread(BufferAddr, sizeof(unsigned char), BufferLen, fileStream);
return -1; return -1;
} }
bool cIptvProtocolFile::Open(void) bool cIptvProtocolFile::Open(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::Open()\n");
// Open the file stream // Open the file stream
OpenFile(); OpenFile();
return true; return true;
@ -90,35 +89,29 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void) bool cIptvProtocolFile::Close(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolFile::Close()\n");
// Close the file stream // Close the file stream
CloseFile(); CloseFile();
return true; return true;
} }
bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolFile::Set(const char* Location, const int Parameter, const int Index)
{ {
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP); debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(locationP)) { if (!isempty(Location)) {
// Close the file stream // Close the file stream
CloseFile(); CloseFile();
// Update stream address and port // Update stream address and port
fileLocationM = strcpyrealloc(fileLocationM, locationP); fileLocation = strcpyrealloc(fileLocation, Location);
fileDelayM = parameterP; fileDelay = Parameter;
// Open the file for input // Open the file for input
OpenFile(); OpenFile();
} }
return true; 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) cString cIptvProtocolFile::GetInformation(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvProtocolFile::GetInformation()");
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM); return cString::sprintf("file://%s:%d", fileLocation, fileDelay);
} }

View File

@ -13,10 +13,10 @@
class cIptvProtocolFile : public cIptvProtocolIf { class cIptvProtocolFile : public cIptvProtocolIf {
private: private:
char* fileLocationM; char* fileLocation;
int fileDelayM; int fileDelay;
FILE* fileStreamM; FILE* fileStream;
bool isActiveM; bool isActive;
private: private:
bool OpenFile(void); bool OpenFile(void);
@ -25,9 +25,8 @@ private:
public: public:
cIptvProtocolFile(); cIptvProtocolFile();
virtual ~cIptvProtocolFile(); virtual ~cIptvProtocolFile();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool SetSource(const char* locationP, const int parameterP, const int indexP); bool Set(const char* Location, const int Parameter, const int Index);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void); cString GetInformation(void);

View File

@ -16,34 +16,33 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolhttp.h" #include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp() cIptvProtocolHttp::cIptvProtocolHttp()
: streamAddrM(strdup("")), : streamAddr(strdup("")),
streamPathM(strdup("/")), streamPath(strdup("/")),
streamPortM(0) streamPort(0)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
} }
cIptvProtocolHttp::~cIptvProtocolHttp() cIptvProtocolHttp::~cIptvProtocolHttp()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::~cIptvProtocolHttp()\n");
// Close the socket // Close the socket
cIptvProtocolHttp::Close(); cIptvProtocolHttp::Close();
// Free allocated memory // Free allocated memory
free(streamPathM); free(streamPath);
free(streamAddrM); free(streamAddr);
} }
bool cIptvProtocolHttp::Connect(void) bool cIptvProtocolHttp::Connect(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::Connect()\n");
// Check that stream address is valid // Check that stream address is valid
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) { if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
// Ensure that socket is valid and connect // Ensure that socket is valid and connect
OpenSocket(streamPortM, streamAddrM); OpenSocket(streamPort, streamAddr);
if (!ConnectSocket()) { if (!ConnectSocket()) {
CloseSocket(); CloseSocket();
return false; return false;
@ -54,11 +53,9 @@ bool cIptvProtocolHttp::Connect(void)
"User-Agent: vdr-%s/%s\r\n" "User-Agent: vdr-%s/%s\r\n"
"Range: bytes=0-\r\n" "Range: bytes=0-\r\n"
"Connection: Close\r\n" "Connection: Close\r\n"
"\r\n", streamPathM, streamAddrM, "\r\n", streamPath, streamAddr, PLUGIN_NAME_I18N, VERSION);
PLUGIN_NAME_I18N, VERSION); debug("Sending http request: %s\n", *buffer);
unsigned int len = strlen(*buffer); if (!Write(*buffer, (unsigned int)strlen(*buffer))) {
debug1("%s Requesting %d: %s", __PRETTY_FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) {
CloseSocket(); CloseSocket();
return false; return false;
} }
@ -68,33 +65,33 @@ bool cIptvProtocolHttp::Connect(void)
return false; return false;
} }
// Update active flag // Update active flag
isActiveM = true; isActive = true;
} }
return true; return true;
} }
bool cIptvProtocolHttp::Disconnect(void) bool cIptvProtocolHttp::Disconnect(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::Disconnect()\n");
if (isActiveM) { if (isActive) {
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
// Update active flag // Update active flag
isActiveM = false; isActive = false;
} }
return true; return true;
} }
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP, bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
unsigned int &recvLenP) unsigned int &recvLen)
{ {
debug1("%s (, %u, )", __PRETTY_FUNCTION__, destLenP); debug("cIptvProtocolHttp::GetHeaderLine()\n");
bool linefeed = false; bool linefeed = false;
bool newline = false; bool newline = false;
char *bufptr = destP; char *bufptr = dest;
recvLenP = 0; recvLen = 0;
if (!destP) if (!dest)
return false; return false;
while (!newline || !linefeed) { while (!newline || !linefeed) {
@ -109,18 +106,18 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
// Saw just data or \r without \n // Saw just data or \r without \n
else { else {
linefeed = false; linefeed = false;
++recvLenP; ++recvLen;
} }
++bufptr; ++bufptr;
// Check that buffer won't be exceeded // Check that buffer won't be exceeded
if (recvLenP >= destLenP) { if (recvLen >= destLen) {
error("Header wouldn't fit into buffer"); error("Header wouldn't fit into buffer\n");
recvLenP = 0; recvLen = 0;
return false; return false;
} }
} }
else { else {
error("No HTTP response received in 500ms"); error("No HTTP response received in 500ms\n");
return false; return false;
} }
} }
@ -129,29 +126,25 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
bool cIptvProtocolHttp::ProcessHeaders(void) bool cIptvProtocolHttp::ProcessHeaders(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::ProcessHeaders()\n");
unsigned int lineLength = 0; unsigned int lineLength = 0;
int version = 0, response = 0; int version = 0, response = 0;
bool responseFound = false; bool responseFound = false;
char fmt[32];
char buf[4096]; char buf[4096];
// Generate HTTP response format string with 2 arguments
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
while (!responseFound || lineLength != 0) { while (!responseFound || lineLength != 0) {
memset(buf, 0, sizeof(buf)); memset(buf, '\0', sizeof(buf));
if (!GetHeaderLine(buf, sizeof(buf), lineLength)) if (!GetHeaderLine(buf, sizeof(buf), lineLength))
return false; return false;
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) { if (!responseFound && sscanf(buf, "HTTP/1.%1i %3i ", &version, &response) != 1) {
error("Expected HTTP header not found"); error("Expected HTTP header not found\n");
continue; continue;
} }
else else
responseFound = true; responseFound = true;
// Allow only 'OK' and 'Partial Content' // Allow only 'OK' and 'Partial Content'
if ((response != 200) && (response != 206)) { if ((response != 200) && (response != 206)) {
error("Invalid HTTP response (%d): %s", response, buf); error("Invalid HTTP response (%d): %s\n", response, buf);
return false; return false;
} }
} }
@ -160,54 +153,49 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
bool cIptvProtocolHttp::Open(void) bool cIptvProtocolHttp::Open(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::Open()\n");
// Connect the socket // Connect the socket
return Connect(); return Connect();
} }
bool cIptvProtocolHttp::Close(void) bool cIptvProtocolHttp::Close(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolHttp::Close()\n");
// Disconnect the current stream // Disconnect the current stream
Disconnect(); Disconnect();
return true; return true;
} }
int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) int cIptvProtocolHttp::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
return cIptvTcpSocket::Read(bufferAddrP, bufferLenP); return cIptvTcpSocket::Read(BufferAddr, BufferLen);
} }
bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int Index)
{ {
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP); debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(locationP)) { if (!isempty(Location)) {
// Disconnect the current socket // Disconnect the current socket
Disconnect(); Disconnect();
// Update stream address, path and port // Update stream address, path and port
streamAddrM = strcpyrealloc(streamAddrM, locationP); streamAddr = strcpyrealloc(streamAddr, Location);
char *path = strstr(streamAddrM, "/"); char *path = strstr(streamAddr, "/");
if (path) { if (path) {
streamPathM = strcpyrealloc(streamPathM, path); streamPath = strcpyrealloc(streamPath, path);
*path = 0; *path = 0;
} }
else else
streamPathM = strcpyrealloc(streamPathM, "/"); streamPath = strcpyrealloc(streamPath, "/");
streamPortM = parameterP; streamPort = Parameter;
//debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
// Re-connect the socket // Re-connect the socket
Connect(); Connect();
} }
return true; 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) cString cIptvProtocolHttp::GetInformation(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvProtocolHttp::GetInformation()");
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM); return cString::sprintf("http://%s:%d%s", streamAddr, streamPort, streamPath);
} }

View File

@ -14,22 +14,21 @@
class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf { class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
private: private:
char* streamAddrM; char* streamAddr;
char* streamPathM; char* streamPath;
int streamPortM; int streamPort;
private: private:
bool Connect(void); bool Connect(void);
bool Disconnect(void); bool Disconnect(void);
bool GetHeaderLine(char* destP, unsigned int destLenP, unsigned int &recvLenP); bool GetHeaderLine(char* dest, unsigned int destLen, unsigned int &recvLen);
bool ProcessHeaders(void); bool ProcessHeaders(void);
public: public:
cIptvProtocolHttp(); cIptvProtocolHttp();
virtual ~cIptvProtocolHttp(); virtual ~cIptvProtocolHttp();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool SetSource(const char* locationP, const int parameterP, const int indexP); bool Set(const char* Location, const int Parameter, const int Index);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void); cString GetInformation(void);

View File

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

View File

@ -15,34 +15,30 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "socket.h"
#include "protocoludp.h" #include "protocoludp.h"
#include "socket.h"
cIptvProtocolUdp::cIptvProtocolUdp() cIptvProtocolUdp::cIptvProtocolUdp()
: isIGMPv3M(false), : streamAddr(strdup("")),
sourceAddrM(strdup("")), streamPort(0)
streamAddrM(strdup("")),
streamPortM(0)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
} }
cIptvProtocolUdp::~cIptvProtocolUdp() cIptvProtocolUdp::~cIptvProtocolUdp()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvProtocolUdp::~cIptvProtocolUdp()\n");
// Drop the multicast group and close the socket // Drop the multicast group and close the socket
cIptvProtocolUdp::Close(); cIptvProtocolUdp::Close();
// Free allocated memory // Free allocated memory
free(streamAddrM); free(streamAddr);
free(sourceAddrM);
} }
bool cIptvProtocolUdp::Open(void) bool cIptvProtocolUdp::Open(void)
{ {
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM); debug("cIptvProtocolUdp::Open(): streamAddr=%s\n", streamAddr);
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M); OpenSocket(streamPort, inet_addr(streamAddr));
if (!isempty(streamAddrM)) { if (!isempty(streamAddr)) {
// Join a new multicast group // Join a new multicast group
JoinMulticast(); JoinMulticast();
} }
@ -51,69 +47,48 @@ bool cIptvProtocolUdp::Open(void)
bool cIptvProtocolUdp::Close(void) bool cIptvProtocolUdp::Close(void)
{ {
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM); debug("cIptvProtocolUdp::Close(): streamAddr=%s\n", streamAddr);
if (!isempty(streamAddrM)) { if (!isempty(streamAddr)) {
// Drop the multicast group // Drop the multicast group
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M); OpenSocket(streamPort, inet_addr(streamAddr));
DropMulticast(); DropMulticast();
} }
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
// Do NOT reset stream and source addresses // Do NOT reset stream and source addresses
//sourceAddrM = strcpyrealloc(sourceAddrM, ""); //streamAddr = strcpyrealloc(streamAddr, "");
//streamAddrM = strcpyrealloc(streamAddrM, ""); //streamPort = 0;
//streamPortM = 0;
return true; return true;
} }
int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) int cIptvProtocolUdp::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP); return cIptvUdpSocket::Read(BufferAddr, BufferLen);
} }
bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int Index)
{ {
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP); debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(locationP)) { if (!isempty(Location)) {
// Drop the multicast group // Drop the multicast group
if (!isempty(streamAddrM)) { if (!isempty(streamAddr)) {
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M); OpenSocket(streamPort, inet_addr(streamAddr));
DropMulticast(); DropMulticast();
} }
// Update stream address and port // Update stream address and port
streamAddrM = strcpyrealloc(streamAddrM, locationP); streamAddr = strcpyrealloc(streamAddr, Location);
// <group address> or <source address>@<group address> streamPort = Parameter;
char *p = strstr(streamAddrM, "@");
if (p) {
*p = 0;
sourceAddrM = strcpyrealloc(sourceAddrM, streamAddrM);
streamAddrM = strcpyrealloc(streamAddrM, p + 1);
isIGMPv3M = true;
}
else {
sourceAddrM = strcpyrealloc(sourceAddrM, streamAddrM);
isIGMPv3M = false;
}
streamPortM = parameterP;
// Join a new multicast group // Join a new multicast group
if (!isempty(streamAddrM)) { if (!isempty(streamAddr)) {
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M); OpenSocket(streamPort, inet_addr(streamAddr));
JoinMulticast(); JoinMulticast();
} }
} }
return true; 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) cString cIptvProtocolUdp::GetInformation(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvProtocolUdp::GetInformation()");
if (isIGMPv3M) return cString::sprintf("udp://%s:%d", streamAddr, streamPort);
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);
} }

View File

@ -14,17 +14,14 @@
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf { class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
private: private:
bool isIGMPv3M; char* streamAddr;
char* sourceAddrM; int streamPort;
char* streamAddrM;
int streamPortM;
public: public:
cIptvProtocolUdp(); cIptvProtocolUdp();
virtual ~cIptvProtocolUdp(); virtual ~cIptvProtocolUdp();
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool SetSource(const char* locationP, const int parameterP, const int indexP); bool Set(const char* Location, const int Parameter, const int Index);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void); cString GetInformation(void);

View File

@ -5,105 +5,113 @@
* *
*/ */
#include "config.h"
#include "log.h"
#include "sectionfilter.h" #include "sectionfilter.h"
cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP) cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
: pusiSeenM(0), uint16_t Pid, uint8_t Tid, uint8_t Mask)
feedCcM(0), : pusi_seen(0),
doneqM(0), feedcc(0),
secBufM(NULL), doneq(0),
secBufpM(0), secbuf(NULL),
secLenM(0), secbufp(0),
tsFeedpM(0), seclen(0),
pidM(pidP), tsfeedp(0),
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)), pid(Pid),
deviceIndexM(deviceIndexP) devid(DeviceIndex),
id(Index)
{ {
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM); //debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, id);
int i; int i;
memset(secBufBaseM, 0, sizeof(secBufBaseM)); memset(secbuf_base, '\0', sizeof(secbuf_base));
memset(filterValueM, 0, sizeof(filterValueM)); memset(filter_value, '\0', sizeof(filter_value));
memset(filterMaskM, 0, sizeof(filterMaskM)); memset(filter_mask, '\0', sizeof(filter_mask));
memset(filterModeM, 0, sizeof(filterModeM)); memset(filter_mode, '\0', sizeof(filter_mode));
memset(maskAndModeM, 0, sizeof(maskAndModeM)); memset(maskandmode, '\0', sizeof(maskandmode));
memset(maskAndNotModeM, 0, sizeof(maskAndNotModeM)); memset(maskandnotmode, '\0', sizeof(maskandnotmode));
filterValueM[0] = tidP; filter_value[0] = Tid;
filterMaskM[0] = maskP; filter_mask[0] = Mask;
// Invert the filter // Invert the filter
for (i = 0; i < eDmxMaxFilterSize; ++i) for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i)
filterValueM[i] ^= 0xFF; filter_value[i] ^= 0xff;
uint8_t mask, mode, doneq = 0; uint8_t mask, mode, local_doneq = 0;
for (i = 0; i < eDmxMaxFilterSize; ++i) { for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
mode = filterModeM[i]; mode = filter_mode[i];
mask = filterMaskM[i]; mask = filter_mask[i];
maskAndModeM[i] = (uint8_t)(mask & mode); maskandmode[i] = (uint8_t)(mask & mode);
maskAndNotModeM[i] = (uint8_t)(mask & ~mode); maskandnotmode[i] = (uint8_t)(mask & ~mode);
doneq |= maskAndNotModeM[i]; local_doneq |= maskandnotmode[i];
} }
doneqM = doneq ? 1 : 0; doneq = local_doneq ? 1 : 0;
// Create sockets // Create sockets
socketM[0] = socketM[1] = -1; socket[0] = socket[1] = -1;
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketM) != 0) { if (socketpair(AF_UNIX, SOCK_DGRAM, 0, socket) != 0) {
char tmp[64]; char tmp[64];
error("Opening section filter sockets failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp))); error("Opening section filter sockets failed (device=%d id=%d): %s\n", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
} }
else if ((fcntl(socketM[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socketM[1], F_SETFL, O_NONBLOCK) != 0)) { else if ((fcntl(socket[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socket[1], F_SETFL, O_NONBLOCK) != 0)) {
char tmp[64]; 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))); error("Setting section filter socket to non-blocking mode failed (device=%d id=%d): %s", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
} }
} }
cIptvSectionFilter::~cIptvSectionFilter() cIptvSectionFilter::~cIptvSectionFilter()
{ {
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM); //debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, id);
int tmp = socketM[1]; int tmp = socket[1];
socketM[1] = -1; socket[1] = -1;
if (tmp >= 0) if (tmp >= 0)
close(tmp); close(tmp);
tmp = socketM[0]; tmp = socket[0];
socketM[0] = -1; socket[0] = -1;
if (tmp >= 0) if (tmp >= 0)
close(tmp); close(tmp);
secBufM = NULL; secbuf = NULL;
DELETENULL(ringBufferM);
} }
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *dataP) int cIptvSectionFilter::GetReadDesc(void)
{ {
return (uint16_t)(3 + ((dataP[1] & 0x0f) << 8) + dataP[2]); return socket[0];
}
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *Data)
{
return (uint16_t)(3 + ((Data[1] & 0x0f) << 8) + Data[2]);
} }
void cIptvSectionFilter::New(void) void cIptvSectionFilter::New(void)
{ {
tsFeedpM = secBufpM = secLenM = 0; tsfeedp = secbufp = seclen = 0;
secBufM = secBufBaseM; secbuf = secbuf_base;
} }
int cIptvSectionFilter::Filter(void) int cIptvSectionFilter::Filter(void)
{ {
if (secBufM) { if (secbuf) {
int i; int i;
uint8_t neq = 0; uint8_t neq = 0;
for (i = 0; i < eDmxMaxFilterSize; ++i) { for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
uint8_t calcxor = (uint8_t)(filterValueM[i] ^ secBufM[i]); uint8_t local_xor = (uint8_t)(filter_value[i] ^ secbuf[i]);
if (maskAndModeM[i] & calcxor) if (maskandmode[i] & local_xor)
return 0; return 0;
neq |= (maskAndNotModeM[i] & calcxor); neq |= (maskandnotmode[i] & local_xor);
} }
if (doneqM && !neq) if (doneq && !neq)
return 0; return 0;
if (ringBufferM && (secLenM > 0)) // There is no data in the read socket, more can be written
ringBufferM->Put(new cFrame(secBufM, secLenM)); if ((socket[0] >= 0) && (socket[1] >= 0) /*&& !select_single_desc(socket[0], 0, false)*/) {
ssize_t len = write(socket[1], secbuf, seclen);
ERROR_IF(len < 0, "write()");
// Update statistics
AddSectionStatistic(len, 1);
}
} }
return 0; return 0;
} }
@ -112,56 +120,56 @@ inline int cIptvSectionFilter::Feed(void)
{ {
if (Filter() < 0) if (Filter() < 0)
return -1; return -1;
secLenM = 0; seclen = 0;
return 0; return 0;
} }
int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP) int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
{ {
uint16_t limit, seclen, n; uint16_t limit, seclen_local, n;
if (tsFeedpM >= eDmxMaxSectionFeedSize) if (tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0; return 0;
if (tsFeedpM + lenP > eDmxMaxSectionFeedSize) if (tsfeedp + len > DMX_MAX_SECFEED_SIZE)
lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM); len = (uint8_t)(DMX_MAX_SECFEED_SIZE - tsfeedp);
if (lenP <= 0) if (len <= 0)
return 0; return 0;
memcpy(secBufBaseM + tsFeedpM, bufP, lenP); memcpy(secbuf_base + tsfeedp, buf, len);
tsFeedpM = uint16_t(tsFeedpM + lenP); tsfeedp = uint16_t(tsfeedp + len);
limit = tsFeedpM; limit = tsfeedp;
if (limit > eDmxMaxSectionFeedSize) if (limit > DMX_MAX_SECFEED_SIZE)
return -1; // internal error should never happen return -1; // internal error should never happen
// Always set secbuf // Always set secbuf
secBufM = secBufBaseM + secBufpM; secbuf = secbuf_base + secbufp;
for (n = 0; secBufpM + 2 < limit; ++n) { for (n = 0; secbufp + 2 < limit; ++n) {
seclen = GetLength(secBufM); seclen_local = GetLength(secbuf);
if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit)) if ((seclen_local <= 0) || (seclen_local > DMX_MAX_SECTION_SIZE) || ((seclen_local + secbufp) > limit))
return 0; return 0;
secLenM = seclen; seclen = seclen_local;
if (pusiSeenM) if (pusi_seen)
Feed(); Feed();
secBufpM = uint16_t(secBufpM + seclen); secbufp = uint16_t(secbufp + seclen_local);
secBufM += seclen; secbuf += seclen_local;
} }
return 0; return 0;
} }
void cIptvSectionFilter::Process(const uint8_t* dataP) void cIptvSectionFilter::Process(const uint8_t* Data)
{ {
if (dataP[0] != TS_SYNC_BYTE) if (Data[0] != TS_SYNC_BYTE)
return; return;
// Stop if not the PID this filter is looking for // Stop if not the PID this filter is looking for
if (ts_pid(dataP) != pidM) if (ts_pid(Data) != pid)
return; return;
uint8_t count = payload(dataP); uint8_t count = payload(Data);
// Check if no payload or out of range // Check if no payload or out of range
if (count == 0) if (count == 0)
@ -170,258 +178,41 @@ void cIptvSectionFilter::Process(const uint8_t* dataP)
// Payload start // Payload start
uint8_t p = (uint8_t)(TS_SIZE - count); uint8_t p = (uint8_t)(TS_SIZE - count);
uint8_t cc = (uint8_t)(dataP[3] & 0x0f); uint8_t cc = (uint8_t)(Data[3] & 0x0f);
int ccok = ((feedCcM + 1) & 0x0f) == cc; int ccok = ((feedcc + 1) & 0x0f) == cc;
feedCcM = cc; feedcc = cc;
int dc_i = 0; int dc_i = 0;
if (dataP[3] & 0x20) { if (Data[3] & 0x20) {
// Adaption field present, check for discontinuity_indicator // Adaption field present, check for discontinuity_indicator
if ((dataP[4] > 0) && (dataP[5] & 0x80)) if ((Data[4] > 0) && (Data[5] & 0x80))
dc_i = 1; dc_i = 1;
} }
if (!ccok || dc_i) { if (!ccok || dc_i) {
// Discontinuity detected. Reset pusiSeenM = 0 to // Discontinuity detected. Reset pusi_seen = 0 to
// stop feeding of suspicious data until next PUSI=1 arrives // stop feeding of suspicious data until next PUSI=1 arrives
pusiSeenM = 0; pusi_seen = 0;
New(); New();
} }
if (dataP[1] & 0x40) { if (Data[1] & 0x40) {
// PUSI=1 (is set), section boundary is here // PUSI=1 (is set), section boundary is here
if (count > 1 && dataP[p] < count) { if (count > 1 && Data[p] < count) {
const uint8_t *before = &dataP[p + 1]; const uint8_t *before = &Data[p + 1];
uint8_t before_len = dataP[p]; uint8_t before_len = Data[p];
const uint8_t *after = &before[before_len]; const uint8_t *after = &before[before_len];
uint8_t after_len = (uint8_t)(count - 1 - before_len); uint8_t after_len = (uint8_t)(count - 1 - before_len);
CopyDump(before, before_len); CopyDump(before, before_len);
// Before start of new section, set pusiSeenM = 1 // Before start of new section, set pusi_seen = 1
pusiSeenM = 1; pusi_seen = 1;
New(); New();
CopyDump(after, after_len); CopyDump(after, after_len);
} }
} }
else { else {
// PUSI=0 (is not set), no section boundary // PUSI=0 (is not set), no section boundary
CopyDump(&dataP[p], count); CopyDump(&Data[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

@ -8,9 +8,6 @@
#ifndef __IPTV_SECTIONFILTER_H #ifndef __IPTV_SECTIONFILTER_H
#define __IPTV_SECTIONFILTER_H #define __IPTV_SECTIONFILTER_H
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif // __FreeBSD__
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
@ -18,75 +15,48 @@
class cIptvSectionFilter : public cIptvSectionStatistics { class cIptvSectionFilter : public cIptvSectionStatistics {
private: private:
enum { enum dmx_limits {
eDmxMaxFilterSize = 18, DMX_MAX_FILTER_SIZE = 18,
eDmxMaxSectionCount = 64, DMX_MAX_SECTION_SIZE = 4096,
eDmxMaxSectionSize = 4096, DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE)
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
}; };
int pusiSeenM; int pusi_seen;
int feedCcM; int feedcc;
int doneqM; int doneq;
uint8_t *secBufM; uint8_t *secbuf;
uint8_t secBufBaseM[eDmxMaxSectionFeedSize]; uint8_t secbuf_base[DMX_MAX_SECFEED_SIZE];
uint16_t secBufpM; uint16_t secbufp;
uint16_t secLenM; uint16_t seclen;
uint16_t tsFeedpM; uint16_t tsfeedp;
uint16_t pidM; uint16_t pid;
cRingBufferFrame *ringBufferM; int devid;
int deviceIndexM; int id;
int socketM[2]; int socket[2];
uint8_t filterValueM[eDmxMaxFilterSize]; uint8_t filter_value[DMX_MAX_FILTER_SIZE];
uint8_t filterMaskM[eDmxMaxFilterSize]; uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
uint8_t filterModeM[eDmxMaxFilterSize]; uint8_t filter_mode[DMX_MAX_FILTER_SIZE];
uint8_t maskAndModeM[eDmxMaxFilterSize]; uint8_t maskandmode[DMX_MAX_FILTER_SIZE];
uint8_t maskAndNotModeM[eDmxMaxFilterSize]; uint8_t maskandnotmode[DMX_MAX_FILTER_SIZE];
inline uint16_t GetLength(const uint8_t *dataP); inline uint16_t GetLength(const uint8_t *Data);
void New(void); void New(void);
int Filter(void); int Filter(void);
inline int Feed(void); inline int Feed(void);
int CopyDump(const uint8_t *bufP, uint8_t lenP); int CopyDump(const uint8_t *buf, uint8_t len);
public: public:
// constructor & destructor // constructor & destructor
cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP); cIptvSectionFilter(int Index, int DeviceIndex, uint16_t Pid,
uint8_t Tid, uint8_t Mask);
virtual ~cIptvSectionFilter(); virtual ~cIptvSectionFilter();
void Process(const uint8_t* dataP); void Process(const uint8_t* Data);
bool Send(void); int GetReadDesc(void);
int GetFd(void) { return socketM[0]; } uint16_t GetPid(void) const { return pid; }
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 #endif // __IPTV_SECTIONFILTER_H

141
setup.c
View File

@ -21,23 +21,22 @@ private:
enum { enum {
INFO_TIMEOUT_MS = 2000 INFO_TIMEOUT_MS = 2000
}; };
cString textM; cString text;
cTimeMs timeoutM; cTimeMs timeout;
unsigned int pageM; unsigned int page;
void UpdateInfo(); void UpdateInfo();
public: public:
cIptvMenuInfo(); cIptvMenuInfo();
virtual ~cIptvMenuInfo(); virtual ~cIptvMenuInfo();
virtual void Display(void); virtual void Display(void);
virtual eOSState ProcessKey(eKeys keyP); virtual eOSState ProcessKey(eKeys Key);
}; };
cIptvMenuInfo::cIptvMenuInfo() cIptvMenuInfo::cIptvMenuInfo()
:cOsdMenu(tr("IPTV Information")), textM(""), timeoutM(), pageM(IPTV_DEVICE_INFO_GENERAL) :cOsdMenu(tr("IPTV Information")), text(""), timeout(), page(IPTV_DEVICE_INFO_GENERAL)
{ {
SetMenuCategory(mcText); timeout.Set(INFO_TIMEOUT_MS);
timeoutM.Set(INFO_TIMEOUT_MS);
UpdateInfo(); UpdateInfo();
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes")); SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes"));
} }
@ -50,24 +49,24 @@ void cIptvMenuInfo::UpdateInfo()
{ {
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex()); cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
if (device) if (device)
textM = device->GetInformation(pageM); text = device->GetInformation(page);
else else
textM = cString(tr("IPTV information not available!")); text = cString(tr("IPTV information not available!"));
Display(); Display();
timeoutM.Set(INFO_TIMEOUT_MS); timeout.Set(INFO_TIMEOUT_MS);
} }
void cIptvMenuInfo::Display(void) void cIptvMenuInfo::Display(void)
{ {
cOsdMenu::Display(); cOsdMenu::Display();
DisplayMenu()->SetText(textM, true); DisplayMenu()->SetText(text, true);
if (*textM) if (*text)
cStatus::MsgOsdTextItem(textM); cStatus::MsgOsdTextItem(text);
} }
eOSState cIptvMenuInfo::ProcessKey(eKeys keyP) eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
{ {
switch (int(keyP)) { switch (int(Key)) {
case kUp|k_Repeat: case kUp|k_Repeat:
case kUp: case kUp:
case kDown|k_Repeat: case kDown|k_Repeat:
@ -76,30 +75,30 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
case kLeft: case kLeft:
case kRight|k_Repeat: case kRight|k_Repeat:
case kRight: case kRight:
DisplayMenu()->Scroll(NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft, NORMALKEY(keyP) == kLeft || NORMALKEY(keyP) == kRight); DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
cStatus::MsgOsdTextItem(NULL, NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft); cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft);
return osContinue; return osContinue;
default: break; default: break;
} }
eOSState state = cOsdMenu::ProcessKey(keyP); eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) { if (state == osUnknown) {
switch (keyP) { switch (Key) {
case kOk: return osBack; case kOk: return osBack;
case kRed: pageM = IPTV_DEVICE_INFO_GENERAL; case kRed: page = IPTV_DEVICE_INFO_GENERAL;
UpdateInfo(); UpdateInfo();
break; break;
case kGreen: pageM = IPTV_DEVICE_INFO_PIDS; case kGreen: page = IPTV_DEVICE_INFO_PIDS;
UpdateInfo(); UpdateInfo();
break; break;
case kYellow: pageM = IPTV_DEVICE_INFO_FILTERS; case kYellow: page = IPTV_DEVICE_INFO_FILTERS;
UpdateInfo(); UpdateInfo();
break; break;
case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1); case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1);
UpdateInfo(); UpdateInfo();
break; break;
default: if (timeoutM.TimedOut()) default: if (timeout.TimedOut())
UpdateInfo(); UpdateInfo();
state = osContinue; state = osContinue;
break; break;
@ -112,17 +111,18 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
cIptvPluginSetup::cIptvPluginSetup() cIptvPluginSetup::cIptvPluginSetup()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvPluginSetup::cIptvPluginSetup()\n");
protocolBasePortM = IptvConfig.GetProtocolBasePort(); tsBufferSize = IptvConfig.GetTsBufferSize();
sectionFilteringM = IptvConfig.GetSectionFiltering(); tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount(); extProtocolBasePort = IptvConfig.GetExtProtocolBasePort();
if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE) sectionFiltering = IptvConfig.GetSectionFiltering();
numDisabledFiltersM = SECTION_FILTER_TABLE_SIZE; numDisabledFilters = IptvConfig.GetDisabledFiltersCount();
if (numDisabledFilters > SECTION_FILTER_TABLE_SIZE)
numDisabledFilters = SECTION_FILTER_TABLE_SIZE;
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) { for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
disabledFilterIndexesM[i] = IptvConfig.GetDisabledFilters(i); disabledFilterIndexes[i] = IptvConfig.GetDisabledFilters(i);
disabledFilterNamesM[i] = tr(section_filter_table[i].description); disabledFilterNames[i] = tr(section_filter_table[i].description);
} }
SetMenuCategory(mcSetupPlugins);
Setup(); Setup();
SetHelp(NULL, NULL, NULL, trVDR("Button$Info")); SetHelp(NULL, NULL, NULL, trVDR("Button$Info"));
} }
@ -132,21 +132,28 @@ void cIptvPluginSetup::Setup(void)
int current = Current(); int current = Current();
Clear(); Clear();
helpM.Clear(); help.Clear();
Add(new cMenuEditIntItem(tr("Protocol base port"), &protocolBasePortM, 0, 0xFFFF - MAXDEVICES * 2)); Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 1, 4));
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.")); help.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 cMenuEditBoolItem(tr("Use section filtering"), &sectionFilteringM)); Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
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.")); help.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."));
if (sectionFilteringM) { Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePort, 0, 0xFFF7));
Add(new cMenuEditIntItem(tr("Disabled filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE)); help.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."));
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) { Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFiltering));
Add(new cMenuEditStraItem(*cString::sprintf(" %s %d", tr("Filter"), i + 1), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM)); help.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."));
helpM.Append(tr("Define an ill-behaving filter to be blacklisted."));
if (sectionFiltering) {
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFilters, 0, SECTION_FILTER_TABLE_SIZE));
help.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 < numDisabledFilters; ++i) {
// TRANSLATORS: note the singular!
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexes[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNames));
help.Append(tr("Define an ill-behaving filter to be blacklisted."));
} }
} }
@ -156,64 +163,68 @@ void cIptvPluginSetup::Setup(void)
eOSState cIptvPluginSetup::ShowInfo(void) eOSState cIptvPluginSetup::ShowInfo(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvPluginSetup::ShowInfo()\n");
if (HasSubMenu()) if (HasSubMenu())
return osContinue; return osContinue;
return AddSubMenu(new cIptvMenuInfo()); return AddSubMenu(new cIptvMenuInfo());
} }
eOSState cIptvPluginSetup::ProcessKey(eKeys keyP) eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
{ {
int oldsectionFiltering = sectionFilteringM; int oldsectionFiltering = sectionFiltering;
int oldNumDisabledFilters = numDisabledFiltersM; int oldNumDisabledFilters = numDisabledFilters;
eOSState state = cMenuSetupPage::ProcessKey(keyP); eOSState state = cMenuSetupPage::ProcessKey(Key);
if (state == osUnknown) { if (state == osUnknown) {
switch (keyP) { switch (Key) {
case kBlue: return ShowInfo(); case kBlue: return ShowInfo();
case kInfo: if (Current() < helpM.Size()) case kInfo: if (Current() < help.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()])); return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()]));
default: state = osContinue; break; default: state = osContinue; break;
} }
} }
if ((keyP != kNone) && ((numDisabledFiltersM != oldNumDisabledFilters) || (sectionFilteringM != oldsectionFiltering))) { if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) {
while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0)) while ((numDisabledFilters < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
disabledFilterIndexesM[--oldNumDisabledFilters] = -1; disabledFilterIndexes[--oldNumDisabledFilters] = -1;
Setup(); Setup();
} }
return state; return state;
} }
void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP) void cIptvPluginSetup::StoreFilters(const char *Name, int *Values)
{ {
char buffer[SECTION_FILTER_TABLE_SIZE * 4]; char buffer[SECTION_FILTER_TABLE_SIZE * 4];
char *q = buffer; char *q = buffer;
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) { for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
char s[3]; char s[3];
if ((valuesP[i] < 0) || (valuesP[i] >= SECTION_FILTER_TABLE_SIZE)) if (Values[i] < 0)
break; break;
if (q > buffer) if (q > buffer)
*q++ = ' '; *q++ = ' ';
snprintf(s, sizeof(s), "%d", valuesP[i]); snprintf(s, sizeof(s), "%d", Values[i]);
strncpy(q, s, strlen(s)); strncpy(q, s, strlen(s));
q += strlen(s); q += strlen(s);
} }
*q = 0; *q = 0;
debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, buffer); debug("cIptvPluginSetup::StoreFilters(): %s=%s\n", Name, buffer);
SetupStore(nameP, buffer); SetupStore(Name, buffer);
} }
void cIptvPluginSetup::Store(void) void cIptvPluginSetup::Store(void)
{ {
// Store values into setup.conf // Store values into setup.conf
SetupStore("ExtProtocolBasePort", protocolBasePortM); SetupStore("TsBufferSize", tsBufferSize);
SetupStore("SectionFiltering", sectionFilteringM); SetupStore("TsBufferPrefill", tsBufferPrefill);
StoreFilters("DisabledFilters", disabledFilterIndexesM); SetupStore("ExtProtocolBasePort", extProtocolBasePort);
SetupStore("SectionFiltering", sectionFiltering);
StoreFilters("DisabledFilters", disabledFilterIndexes);
// Update global config // Update global config
IptvConfig.SetProtocolBasePort(protocolBasePortM); IptvConfig.SetTsBufferSize(tsBufferSize);
IptvConfig.SetSectionFiltering(sectionFilteringM); IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
IptvConfig.SetExtProtocolBasePort(extProtocolBasePort);
IptvConfig.SetSectionFiltering(sectionFiltering);
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
IptvConfig.SetDisabledFilters(i, disabledFilterIndexesM[i]); IptvConfig.SetDisabledFilters(i, disabledFilterIndexes[i]);
} }

64
setup.h
View File

@ -12,22 +12,70 @@
#include <vdr/sourceparams.h> #include <vdr/sourceparams.h>
#include "common.h" #include "common.h"
class cIptvTransponderParameters
{
friend class cIptvSourceParam;
private:
int sidscan;
int pidscan;
int protocol;
char address[MaxFileName];
int parameter;
public:
cIptvTransponderParameters(const char *Parameters = NULL);
int SidScan(void) const { return sidscan; }
int PidScan(void) const { return pidscan; }
int Protocol(void) const { return protocol; }
const char *Address(void) const { return address; }
int Parameter(void) const { return parameter; }
void SetSidScan(int SidScan) { sidscan = SidScan; }
void SetPidScan(int PidScan) { pidscan = PidScan; }
void SetProtocol(int Protocol) { protocol = Protocol; }
void SetAddress(const char *Address) { strncpy(address, Address, sizeof(address)); }
void SetParameter(int Parameter) { parameter = Parameter; }
cString ToString(char Type) const;
bool Parse(const char *s);
};
class cIptvSourceParam : public cSourceParam
{
private:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
int param;
cChannel data;
cIptvTransponderParameters itp;
const char *protocols[eProtocolCount];
public:
cIptvSourceParam(char Source, const char *Description);
virtual void SetData(cChannel *Channel);
virtual void GetData(cChannel *Channel);
virtual cOsdItem *GetOsdItem(void);
};
class cIptvPluginSetup : public cMenuSetupPage class cIptvPluginSetup : public cMenuSetupPage
{ {
private: private:
int protocolBasePortM; int tsBufferSize;
int sectionFilteringM; int tsBufferPrefill;
int numDisabledFiltersM; int extProtocolBasePort;
int disabledFilterIndexesM[SECTION_FILTER_TABLE_SIZE]; int sectionFiltering;
const char *disabledFilterNamesM[SECTION_FILTER_TABLE_SIZE]; int numDisabledFilters;
cVector<const char*> helpM; int disabledFilterIndexes[SECTION_FILTER_TABLE_SIZE];
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
cVector<const char*> help;
eOSState ShowInfo(void); eOSState ShowInfo(void);
void Setup(void); void Setup(void);
void StoreFilters(const char *nameP, int *valuesP); void StoreFilters(const char *Name, int *Values);
protected: protected:
virtual eOSState ProcessKey(eKeys keyP); virtual eOSState ProcessKey(eKeys Key);
virtual void Store(void); virtual void Store(void);
public: public:

View File

@ -11,97 +11,90 @@
#include "sidscanner.h" #include "sidscanner.h"
cSidScanner::cSidScanner(void) cSidScanner::cSidScanner(void)
: channelIdM(tChannelID::InvalidID), : channelId(tChannelID::InvalidID),
sidFoundM(false), sidFound(false),
nidFoundM(false), nidFound(false),
tidFoundM(false), tidFound(false)
isActiveM(false)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cSidScanner::cSidScanner()\n");
Set(0x00, 0x00); // PAT Set(0x00, 0x00); // PAT
Set(0x10, 0x40); // NIT Set(0x10, 0x40); // NIT
} }
cSidScanner::~cSidScanner() cSidScanner::~cSidScanner()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cSidScanner::~cSidScanner()\n");
} }
void cSidScanner::SetChannel(const tChannelID &channelIdP) void cSidScanner::SetStatus(bool On)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString()); debug("cSidScanner::SetStatus(): %d\n", On);
channelIdM = channelIdP; cFilter::SetStatus(On);
sidFoundM = false;
nidFoundM = false;
tidFoundM = false;
} }
void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP) void cSidScanner::SetChannel(const tChannelID &ChannelId)
{
debug("cSidScanner::SetChannel(): %s\n", *ChannelId.ToString());
channelId = ChannelId;
sidFound = false;
nidFound = false;
tidFound = false;
}
void cSidScanner::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
{ {
int newSid = -1, newNid = -1, newTid = -1; int newSid = -1, newNid = -1, newTid = -1;
debug16("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP); //debug("cSidScanner::Process()\n");
if (!isActiveM) if (channelId.Valid()) {
return; if ((Pid == 0x00) && (Tid == 0x00)) {
if (channelIdM.Valid()) { debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
if ((pidP == 0x00) && (tidP == 0x00)) { SI::PAT pat(Data, false);
debug16("%s (%d, %02X, , %d) pat", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::PAT pat(dataP, false);
if (!pat.CheckCRCAndParse()) if (!pat.CheckCRCAndParse())
return; return;
SI::PAT::Association assoc; SI::PAT::Association assoc;
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) { for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) { if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channelIdM.Sid()) { if (assoc.getServiceId() != channelId.Sid()) {
debug1("%s (%d, %02X, , %d) sid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, assoc.getServiceId()); debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
newSid = assoc.getServiceId(); newSid = assoc.getServiceId();
} }
sidFoundM = true; sidFound = true;
break; break;
} }
} }
} }
else if ((pidP == 0x10) && (tidP == 0x40)) { else if ((Pid == 0x10) && (Tid == 0x40)) {
debug1("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP); debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
SI::NIT nit(dataP, false); SI::NIT nit(Data, false);
if (!nit.CheckCRCAndParse()) if (!nit.CheckCRCAndParse())
return; return;
SI::NIT::TransportStream ts; SI::NIT::TransportStream ts;
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) { for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
if (ts.getTransportStreamId() != channelIdM.Tid()) { if (ts.getTransportStreamId() != channelId.Tid()) {
debug1("%s (%d, %02X, , %d) tsid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getTransportStreamId()); debug("cSidScanner::Process(): TSid=%d\n", ts.getTransportStreamId());
newTid = 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;
} }
tidFound = true;
break; // default to the first one break; // default to the first one
} }
// fallback for network id if not found already if (nit.getNetworkId() != channelId.Nid()) {
if (!nidFoundM && (nit.getNetworkId() != channelIdM.Nid())) { debug("cSidScanner::Process(): Nid=%d\n", ts.getTransportStreamId());
debug1("%s (%d, %02X, , %d) nid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, nit.getNetworkId());
newNid = nit.getNetworkId(); newNid = nit.getNetworkId();
nidFoundM = true;
} }
nidFound = true;
} }
} }
if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) { if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) {
cStateKey StateKey; if (!Channels.Lock(true, 10))
cChannels *Channels = cChannels::GetChannelsWrite(StateKey, 10);
if (!Channels)
return; return;
bool ChannelsModified = false; cChannel *IptvChannel = Channels.GetByChannelID(channelId);
cChannel *IptvChannel = Channels->GetByChannelID(channelIdM);
if (IptvChannel) if (IptvChannel)
ChannelsModified |= IptvChannel->SetId(Channels, (newNid < 0) ? IptvChannel->Nid() : newNid, IptvChannel->SetId((newNid < 0) ? IptvChannel->Nid() : newNid, (newTid < 0) ? IptvChannel->Tid() : newTid,
(newTid < 0) ? IptvChannel->Tid() : newTid, (newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid()); Channels.Unlock();
StateKey.Remove(ChannelsModified);
} }
if (sidFoundM && nidFoundM && tidFoundM) { if (sidFound && nidFound && tidFound) {
SetChannel(tChannelID::InvalidID); SetChannel(tChannelID::InvalidID);
SetStatus(false); SetStatus(false);
} }

View File

@ -11,25 +11,23 @@
#include <vdr/channels.h> #include <vdr/channels.h>
#include <vdr/filter.h> #include <vdr/filter.h>
#include "log.h"
class cSidScanner : public cFilter { class cSidScanner : public cFilter {
private: private:
tChannelID channelIdM; tChannelID channelId;
bool sidFoundM; bool sidFound;
bool nidFoundM; bool nidFound;
bool tidFoundM; bool tidFound;
bool isActiveM;
protected: protected:
virtual void Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP); virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
virtual void SetStatus(bool On);
public: public:
cSidScanner(void); cSidScanner(void);
~cSidScanner(); ~cSidScanner();
void SetChannel(const tChannelID &channelIdP); void SetChannel(const tChannelID &ChannelId);
void Open() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = true; } void Open() { SetStatus(true); }
void Close() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = false; } void Close() { SetStatus(false); }
}; };
#endif // __SIDSCANNER_H #endif // __SIDSCANNER_H

441
socket.c
View File

@ -7,7 +7,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <net/if.h>
#include <netdb.h> #include <netdb.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -16,357 +15,271 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "socket.h" #include "socket.h"
cIptvSocket::cIptvSocket() cIptvSocket::cIptvSocket()
: socketPortM(0), : socketPort(0),
socketDescM(-1), socketDesc(-1),
lastErrorReportM(0), isActive(false)
packetErrorsM(0),
sequenceNumberM(-1),
isActiveM(false)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvSocket::cIptvSocket()\n");
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddr, '\0', sizeof(sockAddr));
} }
cIptvSocket::~cIptvSocket() cIptvSocket::~cIptvSocket()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvSocket::~cIptvSocket()\n");
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
} }
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP) bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
{ {
debug1("%s (%d, %d)", __PRETTY_FUNCTION__, portP, isUdpP); debug("cIptvSocket::OpenSocket()\n");
// If socket is there already and it is bound to a different port, it must // If socket is there already and it is bound to a different port, it must
// be closed first // be closed first
if (portP != socketPortM) { if (Port != socketPort) {
debug1("%s (%d, %d) Socket tear-down", __PRETTY_FUNCTION__, portP, isUdpP); debug("cIptvSocket::OpenSocket(): Socket tear-down\n");
CloseSocket(); CloseSocket();
} }
// Bind to the socket if it is not active already // Bind to the socket if it is not active already
if (socketDescM < 0) { if (socketDesc < 0) {
int yes = 1; int yes = 1;
// Create socket // Create socket
if (isUdpP) if (isUdp)
socketDescM = socket(PF_INET, SOCK_DGRAM, 0); socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
else else
socketDescM = socket(PF_INET, SOCK_STREAM, 0); socketDesc = socket(PF_INET, SOCK_STREAM, 0);
ERROR_IF_RET(socketDescM < 0, "socket()", return false); ERROR_IF_RET(socketDesc < 0, "socket()", return false);
// Make it use non-blocking I/O to avoid stuck read calls // Make it use non-blocking I/O to avoid stuck read calls
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)", ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
CloseSocket(), return false); CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number // Allow multiple sockets to use the same PORT number
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)",
"setsockopt(SO_REUSEADDR)", CloseSocket(), return false); CloseSocket(), return false);
#ifndef __FreeBSD__
// Allow packet information to be fetched // Allow packet information to be fetched
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, ERROR_IF_FUNC(setsockopt(socketDesc, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)",
"setsockopt(IP_PKTINFO)", CloseSocket(), return false); CloseSocket(), return false);
#endif // __FreeBSD__
// Bind socket // Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddrM.sin_family = AF_INET; sockAddr.sin_family = AF_INET;
sockAddrM.sin_port = htons((uint16_t)(portP & 0xFFFF)); sockAddr.sin_port = htons((uint16_t)(Port & 0xFFFF));
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY); sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdpP) if (isUdp) {
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0, int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
"bind()", CloseSocket(), return false); ERROR_IF_FUNC(err < 0, "bind()", CloseSocket(), return false);
}
// Update socket port // Update socket port
socketPortM = portP; socketPort = Port;
} }
return true; return true;
} }
void cIptvSocket::CloseSocket(void) void cIptvSocket::CloseSocket(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvSocket::CloseSocket()\n");
// Check if socket exists // Check if socket exists
if (socketDescM >= 0) { if (socketDesc >= 0) {
close(socketDescM); close(socketDesc);
socketDescM = -1; socketDesc = -1;
socketPortM = 0; socketPort = 0;
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddr, 0, sizeof(sockAddr));
} }
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 = inet_addr(addrP);
if (*inAddrP == htonl(INADDR_NONE)) {
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) {
char tmp[64];
error("gethostbyname() failed: %s is not valid address: %s", addrP,
strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
*inAddrP = inet_addr(*host->h_addr_list);
}
return true;
}
return false;
} }
// UDP socket class // UDP socket class
cIptvUdpSocket::cIptvUdpSocket() cIptvUdpSocket::cIptvUdpSocket()
: streamAddrM(htonl(INADDR_ANY)), : streamAddr(INADDR_ANY)
sourceAddrM(htonl(INADDR_ANY)),
useIGMPv3M(false)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvUdpSocket::cIptvUdpSocket()\n");
} }
cIptvUdpSocket::~cIptvUdpSocket() cIptvUdpSocket::~cIptvUdpSocket()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
} }
bool cIptvUdpSocket::OpenSocket(const int portP) bool cIptvUdpSocket::OpenSocket(const int Port, const in_addr_t StreamAddr)
{ {
debug1("%s (%d)", __PRETTY_FUNCTION__, portP); debug("cIptvUdpSocket::OpenSocket()\n");
streamAddrM = htonl(INADDR_ANY); streamAddr = StreamAddr;
sourceAddrM = htonl(INADDR_ANY); return cIptvSocket::OpenSocket(Port, true);
useIGMPv3M = false;
return cIptvSocket::OpenSocket(portP, true);
}
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
{
debug1("%s (%d, %s, %s, %d)", __PRETTY_FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
CheckAddress(streamAddrP, &streamAddrM);
CheckAddress(sourceAddrP, &sourceAddrM);
useIGMPv3M = useIGMPv3P;
return cIptvSocket::OpenSocket(portP, true);
} }
void cIptvUdpSocket::CloseSocket(void) void cIptvUdpSocket::CloseSocket(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvUdpSocket::CloseSocket()\n");
streamAddrM = htonl(INADDR_ANY); streamAddr = INADDR_ANY;
sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false;
cIptvSocket::CloseSocket(); cIptvSocket::CloseSocket();
} }
bool cIptvUdpSocket::JoinMulticast(void) bool cIptvUdpSocket::JoinMulticast(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvUdpSocket::JoinMulticast()\n");
// Check if socket exists // Check if socket exists
if (!isActiveM && (socketDescM >= 0)) { if (!isActive && (socketDesc >= 0)) {
// Join a new multicast group // Join a new multicast group
if (useIGMPv3M) { struct ip_mreq mreq;
// Source-specific multicast (SSM) is used mreq.imr_multiaddr.s_addr = streamAddr;
struct group_source_req gsr; mreq.imr_interface.s_addr = htonl(INADDR_ANY);
struct sockaddr_in *grp; ERROR_IF_RET(setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = streamAddrM;
grp->sin_port = 0;
src = (struct sockaddr_in*)&gsr.gsr_source;
src->sin_family = AF_INET;
src->sin_addr.s_addr = sourceAddrM;
src->sin_port = 0;
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_JOIN_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
}
// Update multicasting flag // Update multicasting flag
isActiveM = true; isActive = true;
} }
return true; return true;
} }
bool cIptvUdpSocket::DropMulticast(void) bool cIptvUdpSocket::DropMulticast(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvUdpSocket::DropMulticast()\n");
// Check if socket exists // Check if socket exists
if (isActiveM && (socketDescM >= 0)) { if (isActive && (socketDesc >= 0)) {
// Drop the existing multicast group // Drop the existing multicast group
if (useIGMPv3M) { struct ip_mreq mreq;
// Source-specific multicast (SSM) is used mreq.imr_multiaddr.s_addr = streamAddr;
struct group_source_req gsr; mreq.imr_interface.s_addr = htonl(INADDR_ANY);
struct sockaddr_in *grp; ERROR_IF_RET(setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = streamAddrM;
grp->sin_port = 0;
src = (struct sockaddr_in*)&gsr.gsr_source;
src->sin_family = AF_INET;
src->sin_addr.s_addr = sourceAddrM;
src->sin_port = 0;
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_LEAVE_SOURCE_GROUP)", return false);
}
else {
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = streamAddrM;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
}
// Update multicasting flag // Update multicasting flag
isActiveM = false; isActive = false;
} }
return true; return true;
} }
int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvUdpSocket::Read()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDesc <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return -1; return -1;
} }
socklen_t addrlen = sizeof(sockAddr);
int len = 0; int len = 0;
// Read data from socket in a loop struct msghdr msgh;
do { struct cmsghdr *cmsg;
socklen_t addrlen = sizeof(sockAddrM); struct iovec iov;
struct msghdr msgh; char cbuf[256];
struct iovec iov; // Initialize iov and msgh structures
char cbuf[256]; memset(&msgh, 0, sizeof(struct msghdr));
len = 0; iov.iov_base = BufferAddr;
// Initialize iov and msgh structures iov.iov_len = BufferLen;
memset(&msgh, 0, sizeof(struct msghdr)); msgh.msg_control = cbuf;
iov.iov_base = bufferAddrP; msgh.msg_controllen = sizeof(cbuf);
iov.iov_len = bufferLenP; msgh.msg_name = &sockAddr;
msgh.msg_control = cbuf; msgh.msg_namelen = addrlen;
msgh.msg_controllen = sizeof(cbuf); msgh.msg_iov = &iov;
msgh.msg_name = &sockAddrM; msgh.msg_iovlen = 1;
msgh.msg_namelen = addrlen; msgh.msg_flags = 0;
msgh.msg_iov = &iov; // Read data from socket
msgh.msg_iovlen = 1; if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
msgh.msg_flags = 0; len = (int)recvmsg(socketDesc, &msgh, MSG_DONTWAIT);
if (len < 0) {
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0)) ERROR_IF(errno != EAGAIN, "recvmsg()");
len = (int)recvmsg(socketDescM, &msgh, MSG_DONTWAIT); return -1;
else }
break; else if (len > 0) {
if (len > 0) { // Process auxiliary received data and validate source address
#ifndef __FreeBSD__ for (cmsg = CMSG_FIRSTHDR(&msgh); (streamAddr != INADDR_ANY) && (cmsg != NULL); cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
// Process auxiliary received data and validate source address if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) { struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) { if (i->ipi_addr.s_addr != streamAddr) {
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg); //debug("Discard packet due to invalid source address: %s", inet_ntoa(i->ipi_addr));
if ((i->ipi_addr.s_addr == streamAddrM) || (htonl(INADDR_ANY) == streamAddrM)) { return 0;
#endif // __FreeBSD__ }
if (bufferAddrP[0] == TS_SYNC_BYTE) }
return len; }
else if (len > 3) { if (BufferAddr[0] == TS_SYNC_BYTE)
// http://tools.ietf.org/html/rfc3550 return len;
// http://tools.ietf.org/html/rfc2250 else if (len > 3) {
// Version // http://www.networksorcery.com/enp/rfc/rfc2250.txt
unsigned int v = (bufferAddrP[0] >> 6) & 0x03; // version
// Extension bit unsigned int v = (BufferAddr[0] >> 6) & 0x03;
unsigned int x = (bufferAddrP[0] >> 4) & 0x01; // extension bit
// CSCR count unsigned int x = (BufferAddr[0] >> 4) & 0x01;
unsigned int cc = bufferAddrP[0] & 0x0F; // cscr count
// Payload type: MPEG2 TS = 33 unsigned int cc = BufferAddr[0] & 0x0F;
//unsigned int pt = bufferAddrP[1] & 0x7F; // payload type: MPEG2 TS = 33
// Sequence number //unsigned int pt = readBuffer[1] & 0x7F;
int seq = ((bufferAddrP[2] & 0xFF) << 8) | (bufferAddrP[3] & 0xFF); // header lenght
if ((((sequenceNumberM + 1) % 0xFFFF) == 0) && (seq == 0xFFFF)) unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
sequenceNumberM = -1; // check if extension
else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) { if (x) {
packetErrorsM++; // extension header length
if (time(NULL) - lastErrorReportM > eReportIntervalS) { unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
info("Detected %d RTP packet errors", packetErrorsM); (BufferAddr[headerlen + 3] & 0xFF));
packetErrorsM = 0; // update header length
lastErrorReportM = time(NULL); headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
}
sequenceNumberM = seq;
}
else
sequenceNumberM = seq;
// Header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// Check if extension
if (x) {
// Extension header length
unsigned int ehl = (((bufferAddrP[headerlen + 2] & 0xFF) << 8) |
(bufferAddrP[headerlen + 3] & 0xFF));
// Update header length
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
}
// Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
(bufferAddrP[headerlen] == TS_SYNC_BYTE)) {
// Set argument point to payload in read buffer
memmove(bufferAddrP, &bufferAddrP[headerlen], (len - headerlen));
return (len - headerlen);
}
}
#ifndef __FreeBSD__
}
}
} }
#endif // __FreeBSD__ // Check that rtp is version 2 and payload contains multiple of TS packet data
} if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
} while (len > 0); (BufferAddr[headerlen] == TS_SYNC_BYTE)) {
ERROR_IF_RET(len < 0 && errno != EAGAIN, "recvmsg()", return -1); // Set argument point to payload in read buffer
memmove(BufferAddr, &BufferAddr[headerlen], (len - headerlen));
return (len - headerlen);
}
}
}
return 0; return 0;
} }
// TCP socket class // TCP socket class
cIptvTcpSocket::cIptvTcpSocket() cIptvTcpSocket::cIptvTcpSocket()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvTcpSocket::cIptvTcpSocket()\n");
} }
cIptvTcpSocket::~cIptvTcpSocket() cIptvTcpSocket::~cIptvTcpSocket()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
} }
bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP) bool cIptvTcpSocket::OpenSocket(const int Port, const char *StreamAddr)
{ {
debug1("%s (%d, %s)", __PRETTY_FUNCTION__, portP, streamAddrP); debug("cIptvTcpSocket::OpenSocket()\n");
// Socket must be opened before setting the host address
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.sin_addr.s_addr)); // First try only the IP address
sockAddr.sin_addr.s_addr = inet_addr(StreamAddr);
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
debug("Cannot convert %s directly to internet address\n", StreamAddr);
// It may be a host name, get the name
struct hostent *host;
host = gethostbyname(StreamAddr);
if (!host) {
char tmp[64];
error("gethostbyname() failed: %s is not valid address: %s", StreamAddr, strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list);
}
return cIptvSocket::OpenSocket(Port, false);
} }
void cIptvTcpSocket::CloseSocket(void) void cIptvTcpSocket::CloseSocket(void)
{ {
debug1("%s()", __PRETTY_FUNCTION__); debug("cIptvTcpSocket::CloseSocket()\n");
cIptvSocket::CloseSocket(); cIptvSocket::CloseSocket();
} }
bool cIptvTcpSocket::ConnectSocket(void) bool cIptvTcpSocket::ConnectSocket(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvTcpSocket::ConnectSocket()\n");
if (!isActiveM && (socketDescM >= 0)) { if (!isActive && (socketDesc >= 0)) {
int retval = connect(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)); int retval = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected // Non-blocking sockets always report in-progress error when connected
ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false); ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false);
// Select with 800ms timeout on the socket completion, check if it is writable // Select with 800ms timeout on the socket completion, check if it is writable
retval = select_single_desc(socketDescM, 800000, true); retval = select_single_desc(socketDesc, 800000, true);
if (retval < 0) if (retval < 0)
return retval; return retval;
// Select has returned. Get socket errors if there are any // Select has returned. Get socket errors if there are any
retval = 0; retval = 0;
socklen_t len = sizeof(retval); socklen_t len = sizeof(retval);
getsockopt(socketDescM, SOL_SOCKET, SO_ERROR, &retval, &len); getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &retval, &len);
// If not any errors, then socket must be ready and connected // If not any errors, then socket must be ready and connected
if (retval != 0) { if (retval != 0) {
char tmp[64]; char tmp[64];
@ -378,41 +291,41 @@ bool cIptvTcpSocket::ConnectSocket(void)
return true; return true;
} }
int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvTcpSocket::Read()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDesc <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return -1; return -1;
} }
int len = 0; int len = 0;
socklen_t addrlen = sizeof(sockAddrM); socklen_t addrlen = sizeof(sockAddr);
// Read data from socket // Read data from socket
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0)) if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
len = (int)recvfrom(socketDescM, bufferAddrP, bufferLenP, MSG_DONTWAIT, len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddrM, &addrlen); (struct sockaddr *)&sockAddr, &addrlen);
return len; return len;
} }
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP) bool cIptvTcpSocket::ReadChar(char* BufferAddr, unsigned int TimeoutMs)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvTcpSocket::ReadChar()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDesc <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return false; return false;
} }
socklen_t addrlen = sizeof(sockAddrM); socklen_t addrlen = sizeof(sockAddr);
// Wait 500ms for data // Wait 500ms for data
int retval = select_single_desc(socketDescM, 1000 * timeoutMsP, false); int retval = select_single_desc(socketDesc, 1000 * TimeoutMs, false);
// Check if error // Check if error
if (retval < 0) if (retval < 0)
return false; return false;
// Check if data available // Check if data available
else if (retval) { else if (retval) {
retval = (int)recvfrom(socketDescM, bufferAddrP, 1, MSG_DONTWAIT, retval = (int)recvfrom(socketDesc, BufferAddr, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddrM, &addrlen); (struct sockaddr *)&sockAddr, &addrlen);
if (retval <= 0) if (retval <= 0)
return false; return false;
} }
@ -420,15 +333,15 @@ bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
return true; return true;
} }
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP) bool cIptvTcpSocket::Write(const char* BufferAddr, unsigned int BufferLen)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvTcpSocket::Write()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDesc <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return false; return false;
} }
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false); ERROR_IF_RET(send(socketDesc, BufferAddr, BufferLen, 0) < 0, "send()", return false);
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/* /*
* socket.h: IPTV plugin for the Video Disk Recorder * protocoludp.h: IPTV plugin for the Video Disk Recorder
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
@ -9,29 +9,19 @@
#define __IPTV_SOCKET_H #define __IPTV_SOCKET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif // __FreeBSD__
class cIptvSocket { class cIptvSocket {
private: private:
int socketPortM; int socketPort;
protected: protected:
enum { int socketDesc;
eReportIntervalS = 300 // in seconds struct sockaddr_in sockAddr;
}; bool isActive;
int socketDescM;
struct sockaddr_in sockAddrM;
time_t lastErrorReportM;
int packetErrorsM;
int sequenceNumberM;
bool isActiveM;
protected: protected:
bool OpenSocket(const int portP, const bool isUdpP); bool OpenSocket(const int Port, const bool isUdp);
void CloseSocket(void); void CloseSocket(void);
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
public: public:
cIptvSocket(); cIptvSocket();
@ -40,16 +30,13 @@ public:
class cIptvUdpSocket : public cIptvSocket { class cIptvUdpSocket : public cIptvSocket {
private: private:
in_addr_t streamAddrM; in_addr_t streamAddr;
in_addr_t sourceAddrM;
bool useIGMPv3M;
public: public:
cIptvUdpSocket(); cIptvUdpSocket();
virtual ~cIptvUdpSocket(); virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool OpenSocket(const int Port); bool OpenSocket(const int Port, const in_addr_t StreamAddr = INADDR_ANY);
bool OpenSocket(const int Port, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P);
void CloseSocket(void); void CloseSocket(void);
bool JoinMulticast(void); bool JoinMulticast(void);
bool DropMulticast(void); bool DropMulticast(void);
@ -59,12 +46,12 @@ class cIptvTcpSocket : public cIptvSocket {
public: public:
cIptvTcpSocket(); cIptvTcpSocket();
virtual ~cIptvTcpSocket(); virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP); virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
bool OpenSocket(const int portP, const char *streamAddrP); bool OpenSocket(const int Port, const char *StreamAddr);
void CloseSocket(void); void CloseSocket(void);
bool ConnectSocket(void); bool ConnectSocket(void);
bool ReadChar(char* bufferAddrP, unsigned int timeoutMsP); bool ReadChar(char* BufferAddr, unsigned int TimeoutMs);
bool Write(const char* bufferAddrP, unsigned int bufferLenP); bool Write(const char* BufferAddr, unsigned int BufferLen);
}; };
#endif // __IPTV_SOCKET_H #endif // __IPTV_SOCKET_H

133
source.c
View File

@ -5,39 +5,33 @@
* *
*/ */
#include <ctype.h>
#include "common.h" #include "common.h"
#include "log.h"
#include "source.h" #include "source.h"
// --- cIptvTransponderParameters -------------------------------------------- // --- cIptvTransponderParameters --------------------------------------------
cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP) cIptvTransponderParameters::cIptvTransponderParameters(const char *Parameters)
: sidScanM(0), : sidscan(0),
pidScanM(0), pidscan(0),
protocolM(eProtocolUDP), protocol(eProtocolUDP),
parameterM(0) parameter(0)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, parametersP); debug("cIptvTransponderParameters::cIptvTransponderParameters(): Parameters=%s\n", Parameters);
memset(&addressM, 0, sizeof(addressM)); memset(&address, 0, sizeof(address));
Parse(parametersP); Parse(Parameters);
} }
cString cIptvTransponderParameters::ToString(char typeP) const cString cIptvTransponderParameters::ToString(char Type) const
{ {
debug1("%s (%c)", __PRETTY_FUNCTION__, typeP); debug("cIptvTransponderParameters::ToString() Type=%c\n", Type);
const char *protocolstr; const char *protocolstr;
switch (protocolM) { switch (protocol) {
case eProtocolEXT: case eProtocolEXT:
protocolstr = "EXT"; protocolstr = "EXT";
break; break;
case eProtocolCURL:
protocolstr = "CURL";
break;
case eProtocolHTTP: case eProtocolHTTP:
protocolstr = "HTTP"; protocolstr = "HTTP";
break; break;
@ -49,18 +43,17 @@ cString cIptvTransponderParameters::ToString(char typeP) const
protocolstr = "UDP"; protocolstr = "UDP";
break; break;
} }
return cString::sprintf("S=%d|P=%d|F=%s|U=%s|A=%d", sidScanM, pidScanM, protocolstr, addressM, parameterM); return cString::sprintf("S=%d|P=%d|F=%s|U=%s|A=%d", sidscan, pidscan, protocolstr, address, parameter);
} }
bool cIptvTransponderParameters::Parse(const char *strP) bool cIptvTransponderParameters::Parse(const char *s)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, strP); debug("cIptvTransponderParameters::Parse(): s=%s\n", s);
bool result = false; bool result = false;
if (strP && *strP) { if (s && *s) {
const char *delim = "|"; const char *delim = "|";
char *str = strdup(strP); char *str = strdup(s);
char *p = str;
char *saveptr = NULL; char *saveptr = NULL;
char *token = NULL; char *token = NULL;
bool found_s = false; bool found_s = false;
@ -74,43 +67,39 @@ bool cIptvTransponderParameters::Parse(const char *strP)
++data; ++data;
if (data && (*data == '=')) { if (data && (*data == '=')) {
++data; ++data;
switch (toupper(*token)) { switch (*token) {
case 'S': case 'S':
sidScanM = (int)strtol(data, (char **)NULL, 10); sidscan = (int)strtol(data, (char **)NULL, 10);
found_s = true; found_s = true;
break; break;
case 'P': case 'P':
pidScanM = (int)strtol(data, (char **)NULL, 10); pidscan = (int)strtol(data, (char **)NULL, 10);
found_p = true; found_p = true;
break; break;
case 'F': case 'F':
if (strstr(data, "UDP")) { if (strstr(data, "UDP")) {
protocolM = eProtocolUDP; protocol = eProtocolUDP;
found_f = true;
}
else if (strstr(data, "CURL")) {
protocolM = eProtocolCURL;
found_f = true; found_f = true;
} }
else if (strstr(data, "HTTP")) { else if (strstr(data, "HTTP")) {
protocolM = eProtocolHTTP; protocol = eProtocolHTTP;
found_f = true; found_f = true;
} }
else if (strstr(data, "FILE")) { else if (strstr(data, "FILE")) {
protocolM = eProtocolFILE; protocol = eProtocolFILE;
found_f = true; found_f = true;
} }
else if (strstr(data, "EXT")) { else if (strstr(data, "EXT")) {
protocolM = eProtocolEXT; protocol = eProtocolEXT;
found_f = true; found_f = true;
} }
break; break;
case 'U': case 'U':
strn0cpy(addressM, data, sizeof(addressM)); strn0cpy(address, data, sizeof(address));
found_u = true; found_u = true;
break; break;
case 'A': case 'A':
parameterM = (int)strtol(data, (char **)NULL, 10); parameter = (int)strtol(data, (char **)NULL, 10);
found_a = true; found_a = true;
break; break;
default: default:
@ -123,9 +112,9 @@ bool cIptvTransponderParameters::Parse(const char *strP)
if (found_s && found_p && found_f && found_u && found_a) if (found_s && found_p && found_f && found_u && found_a)
result = true; result = true;
else else
error("Invalid channel parameters: %s", p); error("Invalid channel parameters: %s\n", str);
free(p); free(str);
} }
return (result); return (result);
@ -133,50 +122,54 @@ bool cIptvTransponderParameters::Parse(const char *strP)
// --- cIptvSourceParam ------------------------------------------------------ // --- cIptvSourceParam ------------------------------------------------------
const char *cIptvSourceParam::allowedProtocolCharsS = " abcdefghijklmnopqrstuvwxyz0123456789-.,#~\\^$[]()*+?{}/%@&="; cIptvSourceParam::cIptvSourceParam(char Source, const char *Description)
: cSourceParam(Source, Description),
cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP) param(0),
: cSourceParam(sourceP, descriptionP), nid(0),
paramM(0), tid(0),
ridM(0), rid(0),
dataM(), data(),
itpM() itp()
{ {
debug1("%s (%c, %s)", __PRETTY_FUNCTION__, sourceP, descriptionP); debug("cIptvSourceParam::cIptvSourceParam(): Source=%c Description=%s\n", Source, Description);
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP"); protocols[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL"); protocols[cIptvTransponderParameters::eProtocolHTTP] = tr("HTTP");
protocolsM[cIptvTransponderParameters::eProtocolHTTP] = tr("HTTP"); protocols[cIptvTransponderParameters::eProtocolFILE] = tr("FILE");
protocolsM[cIptvTransponderParameters::eProtocolFILE] = tr("FILE"); protocols[cIptvTransponderParameters::eProtocolEXT] = tr("EXT");
protocolsM[cIptvTransponderParameters::eProtocolEXT] = tr("EXT");
} }
void cIptvSourceParam::SetData(cChannel *channelP) void cIptvSourceParam::SetData(cChannel *Channel)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters()); debug("cIptvSourceParam::SetData(): Channel=%s)\n", Channel->Parameters());
dataM = *channelP; data = *Channel;
ridM = dataM.Rid(); nid = data.Nid();
itpM.Parse(dataM.Parameters()); tid = data.Tid();
paramM = 0; rid = data.Rid();
itp.Parse(data.Parameters());
param = 0;
} }
void cIptvSourceParam::GetData(cChannel *channelP) void cIptvSourceParam::GetData(cChannel *Channel)
{ {
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters()); debug("cIptvSourceParam::GetData(): Channel=%s\n", Channel->Parameters());
channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true); data.SetTransponderData(Channel->Source(), Channel->Frequency(), data.Srate(), itp.ToString(Source()), true);
channelP->SetId(NULL, channelP->Nid(), channelP->Tid(), channelP->Sid(), ridM); data.SetId(nid, tid, Channel->Sid(), rid);
*Channel = data;
} }
cOsdItem *cIptvSourceParam::GetOsdItem(void) cOsdItem *cIptvSourceParam::GetOsdItem(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvSourceParam::GetOsdItem()\n");
switch (paramM++) { switch (param++) {
case 0: return new cMenuEditIntItem( tr("Rid"), &ridM, 0); case 0: return new cMenuEditIntItem( tr("Nid"), &nid, 0);
case 1: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM); case 1: return new cMenuEditIntItem( tr("Tid"), &tid, 0);
case 2: return new cMenuEditBoolItem(tr("Scan pids"), &itpM.pidScanM); case 2: return new cMenuEditIntItem( tr("Rid"), &rid, 0);
case 3: return new cMenuEditStraItem(tr("Protocol"), &itpM.protocolM, ELEMENTS(protocolsM), protocolsM); case 3: return new cMenuEditBoolItem(tr("Scan section ids"), &itp.sidscan);
case 4: return new cMenuEditStrItem( tr("Address"), itpM.addressM, sizeof(itpM.addressM), allowedProtocolCharsS); case 4: return new cMenuEditBoolItem(tr("Scan pids"), &itp.pidscan);
case 5: return new cMenuEditIntItem( tr("Parameter"), &itpM.parameterM, 0, 0xFFFF); case 5: return new cMenuEditStraItem(tr("Protocol"), &itp.protocol, ELEMENTS(protocols), protocols);
case 6: return new cMenuEditStrItem( tr("Address"), itp.address, sizeof(itp.address));
case 7: return new cMenuEditIntItem( tr("Parameter"), &itp.parameter, 0, 0xFFFF);
default: return NULL; default: return NULL;
} }
return NULL; return NULL;

View File

@ -17,52 +17,50 @@ class cIptvTransponderParameters
friend class cIptvSourceParam; friend class cIptvSourceParam;
private: private:
int sidScanM; int sidscan;
int pidScanM; int pidscan;
int protocolM; int protocol;
char addressM[NAME_MAX + 1]; char address[MaxFileName];
int parameterM; int parameter;
public: public:
enum { enum {
eProtocolUDP, eProtocolUDP,
eProtocolCURL,
eProtocolHTTP, eProtocolHTTP,
eProtocolFILE, eProtocolFILE,
eProtocolEXT, eProtocolEXT,
eProtocolCount eProtocolCount
}; };
cIptvTransponderParameters(const char *parametersP = NULL); cIptvTransponderParameters(const char *Parameters = NULL);
int SidScan(void) const { return sidScanM; } int SidScan(void) const { return sidscan; }
int PidScan(void) const { return pidScanM; } int PidScan(void) const { return pidscan; }
int Protocol(void) const { return protocolM; } int Protocol(void) const { return protocol; }
const char *Address(void) const { return addressM; } const char *Address(void) const { return address; }
int Parameter(void) const { return parameterM; } int Parameter(void) const { return parameter; }
void SetSidScan(int sidScanP) { sidScanM = sidScanP; } void SetSidScan(int SidScan) { sidscan = SidScan; }
void SetPidScan(int pidScanP) { pidScanM = pidScanP; } void SetPidScan(int PidScan) { pidscan = PidScan; }
void SetProtocol(int protocolP) { protocolM = protocolP; } void SetProtocol(int Protocol) { protocol = Protocol; }
void SetAddress(const char *addressP) { strncpy(addressM, addressP, sizeof(addressM)); } void SetAddress(const char *Address) { strncpy(address, Address, sizeof(address)); }
void SetParameter(int parameterP) { parameterM = parameterP; } void SetParameter(int Parameter) { parameter = Parameter; }
cString ToString(char typeP) const; cString ToString(char Type) const;
bool Parse(const char *strP); bool Parse(const char *s);
}; };
class cIptvSourceParam : public cSourceParam class cIptvSourceParam : public cSourceParam
{ {
private: private:
int paramM; int param;
int ridM; int nid;
cChannel dataM; int tid;
cIptvTransponderParameters itpM; int rid;
const char *protocolsM[cIptvTransponderParameters::eProtocolCount]; cChannel data;
cIptvTransponderParameters itp;
private: const char *protocols[cIptvTransponderParameters::eProtocolCount];
static const char *allowedProtocolCharsS;
public: public:
cIptvSourceParam(char sourceP, const char *descriptionP); cIptvSourceParam(char Source, const char *Description);
virtual void SetData(cChannel *channelP); virtual void SetData(cChannel *Channel);
virtual void GetData(cChannel *channelP); virtual void GetData(cChannel *Channel);
virtual cOsdItem *GetOsdItem(void); virtual cOsdItem *GetOsdItem(void);
}; };

View File

@ -8,213 +8,204 @@
#include <limits.h> #include <limits.h>
#include "common.h" #include "common.h"
#include "config.h"
#include "log.h"
#include "statistics.h" #include "statistics.h"
#include "config.h"
// Section statistics class // Section statistic class
cIptvSectionStatistics::cIptvSectionStatistics() cIptvSectionStatistics::cIptvSectionStatistics()
: filteredDataM(0), : filteredData(0),
numberOfCallsM(0), numberOfCalls(0),
timerM(), timer(),
mutexM() mutex()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvSectionStatistics::cIptvSectionStatistics()\n");
} }
cIptvSectionStatistics::~cIptvSectionStatistics() cIptvSectionStatistics::~cIptvSectionStatistics()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
} }
cString cIptvSectionStatistics::GetSectionStatistic() cString cIptvSectionStatistics::GetSectionStatistic()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvSectionStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timerM.Set(); timer.Set();
long bitrate = elapsed ? (long)(1000.0L * filteredDataM / KILOBYTE(1) / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * filteredData / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
// no trailing linefeed here! // no trailing linefeed here!
cString s = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCallsM, bitrate, cString info = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCalls, bitrate,
IptvConfig.GetUseBytes() ? "B" : "bit"); IptvConfig.GetUseBytes() ? "B" : "bit");
filteredDataM = numberOfCallsM = 0; filteredData = numberOfCalls = 0;
return s; return info;
} }
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP) void cIptvSectionStatistics::AddSectionStatistic(long Bytes, long Calls)
{ {
debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, callsP); //debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
filteredDataM += bytesP; filteredData += Bytes;
numberOfCallsM += callsP; numberOfCalls += Calls;
} }
// --- cIptvPidStatistics ---------------------------------------------------- // --- cIptvPidStatistics ----------------------------------------------------
// Device statistics class // Device statistic class
cIptvPidStatistics::cIptvPidStatistics() cIptvPidStatistics::cIptvPidStatistics()
: timerM(), : timer(),
mutexM() mutex()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvPidStatistics::cIptvPidStatistics()\n");
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct); memset(mostActivePids, '\0', sizeof(mostActivePids));
for (int i = 0; i < numberOfElements; ++i) {
mostActivePidsM[i].pid = -1;
mostActivePidsM[i].dataAmount = 0L;
}
} }
cIptvPidStatistics::~cIptvPidStatistics() cIptvPidStatistics::~cIptvPidStatistics()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
} }
cString cIptvPidStatistics::GetPidStatistic() cString cIptvPidStatistics::GetPidStatistic()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvPidStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct); uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ timer.Set();
timerM.Set(); cString info("Active pids:\n");
cString s("Active pids:\n"); for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
for (int i = 0; i < numberOfElements; ++i) { if (mostActivePids[i].pid) {
if (mostActivePidsM[i].pid >= 0) { long bitrate = elapsed ? (long)(1000.0L * mostActivePids[i].DataAmount / KILOBYTE(1) / elapsed) : 0L;
long bitrate = elapsed ? (long)(1000.0L * mostActivePidsM[i].dataAmount / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
s = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *s, i, info = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *info, i,
mostActivePidsM[i].pid, bitrate, mostActivePids[i].pid, bitrate,
IptvConfig.GetUseBytes() ? "B" : "bit"); IptvConfig.GetUseBytes() ? "B" : "bit");
} }
} }
for (int i = 0; i < numberOfElements; ++i) { memset(mostActivePids, '\0', sizeof(mostActivePids));
mostActivePidsM[i].pid = -1; return info;
mostActivePidsM[i].dataAmount = 0L;
}
return s;
} }
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P) int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvPidStatistics::SortPids()\n");
const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P); pidStruct *comp1 = (pidStruct*)data1;
const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P); pidStruct *comp2 = (pidStruct*)data2;
if (comp1->dataAmount > comp2->dataAmount) if (comp1->DataAmount > comp2->DataAmount)
return -1; return -1;
if (comp1->dataAmount < comp2->dataAmount) if (comp1->DataAmount < comp2->DataAmount)
return 1; return 1;
return 0; return 0;
} }
void cIptvPidStatistics::AddPidStatistic(int pidP, long payloadP) void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload)
{ {
debug16("%s (%d, %ld)", __PRETTY_FUNCTION__, pidP, payloadP); //debug("cIptvPidStatistics::AddStatistic(pid=%ld, payload=%ld)\n", Pid, Payload);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct); const int numberOfElements = sizeof(mostActivePids) / sizeof(pidStruct);
// If our statistic already is in the array, update it and quit // If our statistic already is in the array, update it and quit
for (int i = 0; i < numberOfElements; ++i) { for (int i = 0; i < numberOfElements; ++i) {
if (mostActivePidsM[i].pid == pidP) { if (mostActivePids[i].pid == Pid) {
mostActivePidsM[i].dataAmount += payloadP; mostActivePids[i].DataAmount += Payload;
// Now re-sort the array and quit // Now re-sort the array and quit
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids); qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
return; return;
} }
} }
// Apparently our pid isn't in the array. Replace the last element with this // Apparently our pid isn't in the array. Replace the last element with this
// one if new payload is greater // one if new payload is greater
if (mostActivePidsM[numberOfElements - 1].dataAmount < payloadP) { if (mostActivePids[numberOfElements - 1].DataAmount < Payload) {
mostActivePidsM[numberOfElements - 1].pid = pidP; mostActivePids[numberOfElements - 1].pid = Pid;
mostActivePidsM[numberOfElements - 1].dataAmount = payloadP; mostActivePids[numberOfElements - 1].DataAmount = Payload;
// Re-sort // Re-sort
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids); qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
} }
} }
// --- cIptvStreamerStatistics ----------------------------------------------- // --- cIptvStreamerStatistics -----------------------------------------------
// Streamer statistics class // Streamer statistic class
cIptvStreamerStatistics::cIptvStreamerStatistics() cIptvStreamerStatistics::cIptvStreamerStatistics()
: dataBytesM(0), : dataBytes(0),
timerM(), timer(),
mutexM() mutex()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvStreamerStatistics::cIptvStreamerStatistics()\n");
} }
cIptvStreamerStatistics::~cIptvStreamerStatistics() cIptvStreamerStatistics::~cIptvStreamerStatistics()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
} }
cString cIptvStreamerStatistics::GetStreamerStatistic() cString cIptvStreamerStatistics::GetStreamerStatistic()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvStreamerStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timerM.Set(); timer.Set();
long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
cString s = cString::sprintf("%ld k%s/s", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit"); cString info = cString::sprintf("%ld k%s/s", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
dataBytesM = 0; dataBytes = 0;
return s; return info;
} }
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP) void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
{ {
debug16("%s (%ld)", __PRETTY_FUNCTION__, bytesP); //debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
dataBytesM += bytesP; dataBytes += Bytes;
} }
// Buffer statistics class // Buffer statistic class
cIptvBufferStatistics::cIptvBufferStatistics() cIptvBufferStatistics::cIptvBufferStatistics()
: dataBytesM(0), : dataBytes(0),
freeSpaceM(0), freeSpace(0),
usedSpaceM(0), usedSpace(0),
timerM(), timer(),
mutexM() mutex()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvBufferStatistics::cIptvBufferStatistics()\n");
} }
cIptvBufferStatistics::~cIptvBufferStatistics() cIptvBufferStatistics::~cIptvBufferStatistics()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
} }
cString cIptvBufferStatistics::GetBufferStatistic() cString cIptvBufferStatistics::GetBufferStatistic()
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvBufferStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timerM.Set(); timer.Set();
long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
long totalSpace = IPTV_BUFFER_SIZE; long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
float percentage = (float)((float)usedSpaceM / (float)totalSpace * 100.0); float percentage = (float)((float)usedSpace / (float)totalSpace * 100.0);
long totalKilos = totalSpace / KILOBYTE(1); long totalKilos = totalSpace / KILOBYTE(1);
long usedKilos = usedSpaceM / KILOBYTE(1); long usedKilos = usedSpace / KILOBYTE(1);
if (!IptvConfig.GetUseBytes()) { if (!IptvConfig.GetUseBytes()) {
bitrate *= 8; bitrate *= 8;
totalKilos *= 8; totalKilos *= 8;
usedKilos *= 8; usedKilos *= 8;
} }
cString s = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate, cString info = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate,
IptvConfig.GetUseBytes() ? "B" : "bit", usedKilos, totalKilos, IptvConfig.GetUseBytes() ? "B" : "bit", usedKilos, totalKilos,
IptvConfig.GetUseBytes() ? "B" : "bit", percentage); IptvConfig.GetUseBytes() ? "B" : "bit", percentage);
dataBytesM = 0; dataBytes = 0;
usedSpaceM = 0; usedSpace = 0;
return s; return info;
} }
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP) void cIptvBufferStatistics::AddBufferStatistic(long Bytes, long Used)
{ {
debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, usedP); //debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutex);
dataBytesM += bytesP; dataBytes += Bytes;
if (usedP > usedSpaceM) if (Used > usedSpace)
usedSpaceM = usedP; usedSpace = Used;
} }

View File

@ -18,13 +18,13 @@ public:
cString GetSectionStatistic(); cString GetSectionStatistic();
protected: protected:
void AddSectionStatistic(long bytesP, long callsP); void AddSectionStatistic(long Bytes, long Calls);
private: private:
long filteredDataM; long filteredData;
long numberOfCallsM; long numberOfCalls;
cTimeMs timerM; cTimeMs timer;
cMutex mutexM; cMutex mutex;
}; };
// Pid statistics // Pid statistics
@ -35,19 +35,19 @@ public:
cString GetPidStatistic(); cString GetPidStatistic();
protected: protected:
void AddPidStatistic(int pidP, long payloadP); void AddPidStatistic(u_short Pid, long Payload);
private: private:
struct pidStruct { struct pidStruct {
int pid; u_short pid;
long dataAmount; long DataAmount;
}; };
pidStruct mostActivePidsM[IPTV_STATS_ACTIVE_PIDS_COUNT]; pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timerM; cTimeMs timer;
cMutex mutexM; cMutex mutex;
private: private:
static int SortPids(const void* data1P, const void* data2P); static int SortPids(const void* data1, const void* data2);
}; };
// Streamer statistics // Streamer statistics
@ -58,12 +58,12 @@ public:
cString GetStreamerStatistic(); cString GetStreamerStatistic();
protected: protected:
void AddStreamerStatistic(long bytesP); void AddStreamerStatistic(long Bytes);
private: private:
long dataBytesM; long dataBytes;
cTimeMs timerM; cTimeMs timer;
cMutex mutexM; cMutex mutex;
}; };
// Buffer statistics // Buffer statistics
@ -74,14 +74,14 @@ public:
cString GetBufferStatistic(); cString GetBufferStatistic();
protected: protected:
void AddBufferStatistic(long bytesP, long usedP); void AddBufferStatistic(long Bytes, long Used);
private: private:
long dataBytesM; long dataBytes;
long freeSpaceM; long freeSpace;
long usedSpaceM; long usedSpace;
cTimeMs timerM; cTimeMs timer;
cMutex mutexM; cMutex mutex;
}; };
#endif // __IPTV_STATISTICS_H #endif // __IPTV_STATISTICS_H

View File

@ -5,62 +5,67 @@
* *
*/ */
#include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "common.h" #include "common.h"
#include "log.h"
#include "streamer.h" #include "streamer.h"
cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP) cIptvStreamer::cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen)
: cThread("IPTV streamer"), : cThread("IPTV streamer"),
sleepM(), ringBuffer(RingBuffer),
deviceM(&deviceP), packetBufferLen(PacketLen),
packetBufferLenM(packetLenP), protocol(NULL)
protocolM(NULL)
{ {
debug1("%s (, %d)", __PRETTY_FUNCTION__, packetBufferLenM); debug("cIptvStreamer::cIptvStreamer(%d)\n", packetBufferLen);
// Allocate packet buffer // Allocate packet buffer
packetBufferM = MALLOC(unsigned char, packetBufferLenM); packetBuffer = MALLOC(unsigned char, packetBufferLen);
if (packetBufferM) if (packetBuffer)
memset(packetBufferM, 0, packetBufferLenM); memset(packetBuffer, 0, packetBufferLen);
else else
error("MALLOC() failed for packet buffer"); error("MALLOC() failed for packet buffer");
} }
cIptvStreamer::~cIptvStreamer() cIptvStreamer::~cIptvStreamer()
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvStreamer::~cIptvStreamer()\n");
// Close the protocol // Close the protocol
Close(); Close();
protocolM = NULL; protocol = NULL;
ringBuffer = NULL;
// Free allocated memory // Free allocated memory
free(packetBufferM); free(packetBuffer);
} }
void cIptvStreamer::Action(void) void cIptvStreamer::Action(void)
{ {
debug1("%s() Entering", __PRETTY_FUNCTION__); debug("cIptvStreamer::Action(): Entering\n");
// Increase priority // Increase priority
//SetPriority(-1); //SetPriority(-1);
// Do the thread loop // Do the thread loop
while (packetBufferM && Running()) { while (packetBuffer && Running()) {
int length = -1; int length = -1;
unsigned int size = min(deviceM->CheckData(), packetBufferLenM); if (protocol)
if (protocolM && (size > 0)) length = protocol->Read(packetBuffer, packetBufferLen);
length = protocolM->Read(packetBufferM, size);
if (length > 0) { if (length > 0) {
AddStreamerStatistic(length); AddStreamerStatistic(length);
deviceM->WriteData(packetBufferM, length); if (ringBuffer) {
int p = ringBuffer->Put(packetBuffer, length);
if (p != length)
ringBuffer->ReportOverflow(length - p);
}
} }
else else
sleepM.Wait(10); // to avoid busy loop and reduce cpu load sleep.Wait(10); // to avoid busy loop and reduce cpu load
} }
debug1("%s Exiting", __PRETTY_FUNCTION__); debug("cIptvStreamer::Action(): Exiting\n");
} }
bool cIptvStreamer::Open(void) bool cIptvStreamer::Open(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvStreamer::Open()\n");
// Open the protocol // Open the protocol
if (protocolM && !protocolM->Open()) if (protocol && !protocol->Open())
return false; return false;
// Start thread // Start thread
Start(); Start();
@ -69,50 +74,42 @@ bool cIptvStreamer::Open(void)
bool cIptvStreamer::Close(void) bool cIptvStreamer::Close(void)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug("cIptvStreamer::Close()\n");
// Stop thread // Stop thread
sleepM.Signal(); sleep.Signal();
if (Running()) if (Running())
Cancel(3); Cancel(3);
// Close the protocol // Close the protocol
if (protocolM) if (protocol)
protocolM->Close(); protocol->Close();
return true; return true;
} }
bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP) bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol)
{ {
debug1("%s (%s, %d, %d, )", __PRETTY_FUNCTION__, locationP, parameterP, indexP); debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter);
if (!isempty(locationP)) { if (!isempty(Location)) {
// Update protocol and set location and parameter; Close the existing one if changed // Update protocol and set location and parameter; Close the existing one if changed
if (protocolM != protocolP) { if (protocol != Protocol) {
if (protocolM) if (protocol)
protocolM->Close(); protocol->Close();
protocolM = protocolP; protocol = Protocol;
if (protocolM) { if (protocol) {
protocolM->SetSource(locationP, parameterP, indexP); protocol->Set(Location, Parameter, Index);
protocolM->Open(); protocol->Open();
} }
} }
else if (protocolM) else if (protocol)
protocolM->SetSource(locationP, parameterP, indexP); protocol->Set(Location, Parameter, Index);
} }
return true; 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) cString cIptvStreamer::GetInformation(void)
{ {
debug16("%s", __PRETTY_FUNCTION__); //debug("cIptvStreamer::GetInformation()");
cString s; cString info;
if (protocolM) if (protocol)
s = protocolM->GetInformation(); info = protocol->GetInformation();
return s; return info;
} }

View File

@ -11,27 +11,26 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <vdr/thread.h> #include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "deviceif.h"
#include "protocolif.h" #include "protocolif.h"
#include "statistics.h" #include "statistics.h"
class cIptvStreamer : public cThread, public cIptvStreamerStatistics { class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
private: private:
cCondWait sleepM; cRingBufferLinear* ringBuffer;
cIptvDeviceIf* deviceM; cCondWait sleep;
unsigned char* packetBufferM; unsigned char* packetBuffer;
unsigned int packetBufferLenM; unsigned int packetBufferLen;
cIptvProtocolIf* protocolM; cIptvProtocolIf* protocol;
protected: protected:
virtual void Action(void); virtual void Action(void);
public: public:
cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP); cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen);
virtual ~cIptvStreamer(); virtual ~cIptvStreamer();
bool SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP); bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol);
bool SetPid(int pidP, int typeP, bool onP);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);
cString GetInformation(void); cString GetInformation(void);