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.0.2" have entirely different histories.

60 changed files with 2645 additions and 5752 deletions

6
.gitignore vendored
View File

@ -1,6 +0,0 @@
.dependencies
*.o
*.so
*~
po/*.pot
po/*.mo

283
HISTORY
View File

@ -1,6 +1,5 @@
==================================
VDR Plugin 'iptv' Revision History
==================================
----------------------------------
2007-10-14: Version 0.0.1
@ -12,283 +11,3 @@ VDR Plugin 'iptv' Revision History
- Added Spids to channel editor.
- Fixed shutdown logic.
- Improved error checking in protocols.
2007-10-28: Version 0.0.3
- Fixed shutdown crash.
- Added some minor tweaks.
- RTP payload now restricted to TS only.
- Added preliminary support for vdr-1.4.7.
2007-11-04: Version 0.0.4
- Added German translation (Thanks to Tobias Grimm).
- Added pluginparam patch for vdr-1.5.11.
- Updated Makefile 'i18n' targets.
2007-11-27: Version 0.0.5
- Added French translation (Thanks to Bruno Roussel).
- Added a more sophisticated example script (Thanks to Tobias Grimm).
- Improved iptvstream.sh compatibility under non-bash shells.
2008-01-20: Version 0.0.6
- Fixed some lint warnings.
- Added Italian translation (Thanks to Diego Pierotto).
- Added '-Wno-parentheses' to the compiler options.
- Mapped 'kInfo' as help key in setup menu.
- Refactored statistic collecting code.
2008-02-18: Version 0.0.7
- Updated for vdr-1.5.15.
- Replaced asprintf with cString.
- Updated French translation (Thanks to Michaël Nival).
- Modified VDR locale support detection.
- Added preliminary automatic Pid scanning functionality.
- Modified channels.conf format to enable/disable channel
specific pid and sid scanning functionality.
- Removed the general sid scanning setup option.
2008-03-27: Version 0.2.0
- Updated for vdr-1.6.0.
- Updated Italian translation (Thanks to Diego Pierotto).
- Added Russian translation (Thanks to Alexander Gross).
2008-06-20: Version 0.2.1
- Updated Italian translation (Thanks to Diego Pierotto).
- Removed compatibility mode for old channels.conf format.
- Updated vlc2iptv script for new channels.conf format.
- Added pluginparam patch for vdr-1.7.0.
- Added new example scripts from VDR-WIKI.
2008-10-12: Version 0.2.2
- Converted HISTORY and fi_FI.po to UTF-8.
- Updated Italian translation (Thanks to Diego Pierotto).
- Tweaked pid scanner parameters for HD broadcasts.
- Fixed opening of fifo tap.
- Updated iptvstream.sh script to support optional video resolution
settings.
- Optimized streamer thread termination.
2008-12-16: Version 0.2.3
- Updated for vdr-1.7.2.
- Silenced a compilation warning.
2009-02-25: Version 0.2.4
- Updated for vdr-1.7.4.
- Fixed blacklisting of PAT section filter.
- Set max IPTV device count to VDR's max devices.
- Fixed a possible crash in sid and pid scanners.
2009-03-08: Version 0.2.5
- Optimized TS packet data flow.
- Refactored section filter class.
- Cleaned up example scripts.
- Fixed pid scanner to set the existing video stream type
(Thanks to ua0lnj for reporting this one).
- Added optional patches to disable CA updates.
2009-03-22: Version 0.2.6
- Added a note about recommended frequencies into README.
- Fixed a locking bug with section filters.
- Fixed some lint warnings.
2009-06-01: Version 0.3.0
- Added iptvstream-notrap.sh script.
- Fixed setting parameters when protocol changes
(Thanks to Peter Holik for reporting this one).
- Updated example scripts to use ffmpeg's direct UDP output
and added a new "image.sh" script (Thanks to Peter Holik).
2009-10-01: Version 0.3.1
- Updated patches.
- Added optional patches to disable EIT scanning.
- Fixed handling of HTTP protocol headers.
- Modified sectionfilters to use socket pair instead of
filesystem fifos.
2010-03-05: Version 0.3.2
- Updated patches.
- Fixed argument corruption.
==================================
VDR Plugin 'iptv' Revision History
==================================
2010-03-05: Version 0.4.0
- Updated for vdr-1.7.13.
- Fixed argument corruption.
2010-03-09: Version 0.4.1
- Fixed channel parameter corruption.
- Added Dutch translation (Thanks to Carel).
2010-06-06: Version 0.4.2
- Updated for vdr-1.7.15.
2012-02-02: Version 0.5.0
- Updated for vdr-1.7.23.
- Renamed Sid scanner to section id scanner and added
experimental Tid/Nid support into it.
- Added optional source address validation for UDP protocol.
- Fixed audio pid detection in pid scanner.
- Changed ProvidesChannel() to set the need of detaching
receivers due to VDR's channel selection mechanism.
- Enabled partial content responses for HTTP protocol.
- Fixed EXT protocol execution (Thanks to Peter Holik).
- Disable detaching of receivers if retuned to an existing
channel (Thanks to Zdeněk Kopřivík).
- Canonicalized the configuration directory.
- Added support for LDFLAGS.
- Added cppcheck target into Makefile.
2012-04-02: Version 0.5.1
- Updated for vdr-1.7.27.
- Updated Makefile.
- Silenced compilation warnings.
- Fixed channel switching bugs.
- Added support for a service interface.
- Changed UDP protocol to always utilize the source address
validation.
2012-04-26: Version 0.5.2
- Fixed connection problems in HTTP protocol.
2012-06-03: Version 1.0.0
- Optimized reading from UDP sockets.
- Fixed ProvidesChannel method.
2012-07-10: Version 1.0.1
- Added FreeBSD support (Thanks to Jürgen Lock).
2012-09-30: Version 1.1.0
- Updated for vdr-1.7.30.
- Added support for source-specific multicasts (SSM).
- Changed default external script directory from the
configuration to the resource.
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.

149
Makefile
View File

@ -1,164 +1,125 @@
#
# Makefile for IPTV plugin
# Makefile for a Video Disk Recorder plugin
#
# $Id: Makefile,v 1.20 2007/10/21 13:31:21 ajhseppa Exp $
# 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.
# 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.
# 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
### The version number of this plugin (taken from the main source file):
VERSION = $(shell grep 'const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g')
GITTAG = $(shell git describe --always 2>/dev/null)
VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual
### The directory environment:
# Use package data if installed...otherwise assume we're under the VDR source directory:
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr))
LIBDIR = $(call PKGCFG,libdir)
LOCDIR = $(call PKGCFG,locdir)
PLGCFG = $(call PKGCFG,plgcfg)
RESDIR = $(call PKGCFG,resdir)
CFGDIR = $(call PKGCFG,configdir)
#
TMPDIR ?= /tmp
### The compiler options:
export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags)
STRIP ?= /bin/true
### The version number of VDR's plugin API:
APIVERSION = $(call PKGCFG,apiversion)
VDRDIR = ../../..
LIBDIR = ../../lib
TMPDIR = /tmp
### 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:
ARCHIVE = $(PLUGIN)-$(VERSION)
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 +=
INCLUDES += -I$(VDRDIR)/include
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
ifdef IPTV_EXTSHELL
DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"'
ifdef IPTV_DEBUG
DEFINES += -DDEBUG
endif
ifneq ($(strip $(GITTAG)),)
DEFINES += -DGITVERSION='"-GIT-$(GITTAG)"'
endif
.PHONY: all all-redirect
all-redirect: all
### The object files (add further files here):
OBJS = $(PLUGIN).o common.o config.o device.o pidscanner.o \
protocolcurl.o protocolext.o protocolfile.o protocolhttp.o \
protocoludp.o sectionfilter.o setup.o sidscanner.o socket.o \
source.o statistics.o streamer.o
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \
protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \
sidscanner.o statistics.o common.o socket.o
### The main target:
all: $(SOFILE) i18n
all: libvdr-$(PLUGIN).so i18n
### Implicit rules:
%.o: %.c Makefile
@echo CC $@
$(Q)$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
### Dependencies:
MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
$(Q)$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
-include $(DEPFILE)
### Internationalization (I18N):
PODIR = po
LOCALEDIR = $(VDRDIR)/locale
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Ndirs = $(notdir $(foreach file, $(I18Npo), $(basename $(file))))
I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po
@echo MO $@
$(Q)msgfmt -c -o $@ $<
msgfmt -c -o $@ $<
$(I18Npot): $(wildcard *.c)
@echo GT $@
$(Q)xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ `ls $^`
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $(wildcard *.c)
%.po: $(I18Npot)
@echo PO $@
$(Q)msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
@touch $@
$(I18Npo): $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
@echo IN $@
$(Q)install -D -m644 $< $@
.PHONY: i18n
i18n: $(I18Nmo) $(I18Npot)
install-i18n: $(I18Nmsgs)
i18n: $(I18Npot) $(I18Nmo)
@mkdir -p $(LOCALEDIR)
for i in $(I18Ndirs); do\
mkdir -p $(LOCALEDIR)/$$i/LC_MESSAGES;\
cp $(PODIR)/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/vdr-$(PLUGIN).mo;\
done
### Targets:
$(SOFILE): $(OBJS)
@echo LD $@
$(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
$(Q)$(STRIP) $@
libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
ifndef IPTV_DEBUG
@$(STRIP) $@
endif
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
install-lib: $(SOFILE)
@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: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
@tar czf $(PACKAGE).tgz -C $(TMPDIR) --exclude CVS $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(PACKAGE).tgz
clean:
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
.PHONY: cppcheck
cppcheck:
$(Q)cppcheck --language=c++ --enable=all -v -f $(OBJS:%.o=%.c)
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot

154
README
View File

@ -3,8 +3,8 @@ This is an IPTV plugin for the Video Disk Recorder (VDR).
Written by: Rolf Ahrenberg
< R o l f . A h r e n b e r g @ s c i . f i >
Antti Seppälä
< a . s e p p a l a @ g m a i l . c o m >
Antti Seppälä
<a j h s e p p a @ n i k s u l a . h u t . f i >
Project's homepage: http://www.saunalahti.fi/~rahrenbe/vdr/iptv/
@ -17,8 +17,8 @@ See the file COPYING for more information.
Requirements:
- Libcurl - the multiprotocol file transfer library
http://curl.haxx.se/libcurl/
An IPTV patched VDR-1.5.10 (or later) setup and DVB compatible MPEG1/2
network video streams.
Description:
@ -29,32 +29,49 @@ filtering capabilities which allow for example EIT information to be
extracted from the incoming stream.
Currently the IPTV plugin has direct support for both multicast UDP/RTP
and unicast HTTP MPEG1/2, H.264 and H.265 transport streams. Also a file
input method is supported, but a file delay must be selected individually
to prevent VDR's transfer buffer over/underflow. Therefore the file input
should be considered as a testing feature only.
and unicast HTTP MPEG1/2 transport streams. Also a file input method is
supported, but a file delay must be selected individually to prevent
VDR's transfer buffer over/underflow. Therefore the file input should be
considered as a testing feature only.
IPTV plugin also features a support for external streaming applications.
With proper helper applications and configuration IPTV plugin is able to
display not only MPEG1/2, H.264 and H.265 transport streams but also other
formats like MP3 radio streams, mms video streams and so on.
display not only MPEG1/2 transport streams but also other formats like
MP3 radio streams, mms video streams and so on.
Installation:
cd /put/your/path/here/VDR/PLUGINS/src
tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz
make -C iptv-X.Y.Z install
ln -s iptv-X.Y.Z iptv
cd /put/your/path/here/VDR
patch -p1 < PLUGINS/src/iptv/patches/vdr-X.Y.Z-pluginparam.patch
cp sources.conf /path/to/vdrconf/
cp -R PLUGINS/src/iptv/iptv /path/to/vdrconf/plugins/
make
make plugins
./vdr -P iptv
Setup menu:
- Protocol base port = 4321 Defines base port used in CURL/EXT
protocol. Two ports are defined for
each device.
- TS buffer size [MB] = 2 Defines ringbuffer size for transport
stream in MB.
Valid range: 1...4
- TS buffer prefill ratio [%] = 0 Defines prefill ratio for transport
stream ringbuffer before data is
transferred to VDR.
Valid range: 0...40
- EXT protocol base port = 4321 Defines base port used in EXT protocol.
The port range is defined by the number
of IPTV devices times two (max. 32).
Valid range: 0...65503
of IPTV devices (max. 8).
Valid range: 0...65527
- Use section filtering = 1 Defines whether section filtering shall
be used.
Valid range: 0...1
- Scan Sid automatically = 1 Defines whether service id shall be
scanned automatically. Requires section
filtering.
Valid range: 0...1
- Disable filters = 0 Certain section filters might cause some
unwanted behaviour to VDR such as time
being falsely synchronized etc. This
@ -65,8 +82,18 @@ Setup menu:
options which allow you to disable the
individual section filters.
Valid range: 0...7
- [Red:Channels] Opens IPTV channel editor.
- [Blue:Info] Opens IPTV information/statistics menu.
Channel editor menu:
- Because of the different nature and content the VDR channel editor is not
best suited for editing of IPTV channels. Therefore an alternative editor
is provided which allows more IPTV centric editing of channel information.
An IPTV channel editor is accessible via "Setup -> Plugins -> IPTV" and
pressing the Red button. The channel editor is functionally similar to
VDR's built-in channel editor.
Information menu:
- [Red:General] Opens the general information page.
@ -78,62 +105,47 @@ Configuration:
- 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
TV5;IPTV:50:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:5:0:0:0
TV4;IPTV:40:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:4:0:0:0
TV3;IPTV:30:S=1|P=0|F=CURL|U=http%3A//foo%3Abar@127.0.0.1%3A3000/TS/2|A=0:I:0:512:650:2321:0:3:0:0:0
TV2;IPTV:20:S=1|P=0|F=UDP|U=127.0.0.1@127.0.0.1|A=1234:I:0:512:650:2321:0:2:0:0:0
TV1;IPTV:10:S=1|P=0|F=UDP|U=127.0.0.1|A=1234:I:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^ ^
| | | | | | Source type ("I")
| | | | | Stream parameter
| | | | | UDP: multicast port
| | | | | CURL: <<to be defined>>
| | | | | HTTP: HTTP port number
| | | | | FILE: file delay (ms)
| | | | | EXT: script parameter
| | | | 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)
| Section id (Sid/Nid/Tid) scanner ("0" disable, "1" enable)
TV4;IPTV:4:IPTV|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0
TV3;IPTV:3:IPTV|FILE|/video/stream.ts|5:P:0:514:670:2321:0:3:0:0:0
TV2;IPTV:2:IPTV|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0
TV1;IPTV:1:IPTV|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^
| | | | | Source type ("P")
| | | | IP Port Number, File delay (ms), Script parameter
| | | IP Address, File location, Script location
| | Protocol ("UDP", "HTTP", "FILE", "EXT")
| Plugin ID ("IPTV")
Unique enumeration
- UDP multicast rules for iptables firewall
# Multicast UDP packets
# Multicast UDP -packets
iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT
# IGMP required by multicasts
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
# Default routing for multicast
route add -net 224.0.0.0 netmask 224.0.0.0 eth0
External streaming:
- To watch an externally received channel add an EXT entry to channels.conf
and specify a script name and parameter. The specified script is executed
from plugin resource directory when VDR tunes to the channel. The specified
script parameter is passed to the script and it can be used to select for
example between different URLs.
from plugin configuration directory when VDR tunes to the channel. The
specified script parameter is passed to the script and it can be used to
select for example between different URLs.
- When an EXT or CURL/RTSP channel is opened the IPTV plugin opens an UDP
listening port on the localhost. The external script is responsible for
supplying IPTV plugin with MPEG2 TS data in UDP/RTP format to the listening
port. The data will be processed in VDR like a normal DVB broadcast. The
listening base port can be specified in the plugin configuration menu.
- When an EXT channel is opened the IPTV plugin opens an UDP listening port
on the localhost. The external script is responsible for supplying IPTV
plugin with MPEG2 TS data in UDP/RTP format to the listening port. The
data will be processed in VDR like a normal DVB broadcast. The listening
base port can be specified in the plugin configuration menu.
- 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
devices can be used simultaneously.
- IPTV plugin includes an example script which uses VLC media player for
receiving streams, transcoding and handing the result to IPTV plugin.
receiving streams, transcoding and handing the result to IPTV plugin. The
plugin was tested with VLC version 0.8.6c.
Notes:
@ -144,44 +156,6 @@ Notes:
- The following section filters are recommended to be disabled:
"NIT (0x40)", "SDT (0x42)", "TDT (0x70)"
- The IPTV devices look for a "/tmp/vdr-iptv<devicenumber>.dvr" fifo at
startup. If the fifo is found and succesfully opened, the device writes
the current data stream into it. This can be used for debugging purposes.
- Multiple channels with identical service id should have frequency
difference of 4 or greater. It's recommended to use frequencies in decades
(10, 20, 30, 40, ...) for all IPTV channel entries.
- VLC processes won't get killed on some setups with the provided iptvstream.sh
script and the iptvstream-notrap.sh script should be used instead in these
cases.
- If received MPEG-2 TS streams carry CA descriptors, you'll have to apply
"disable_ca_updates" patch to the VDR in order to get rid of "Channel not
available" messages.
- EIT scanning functionality is disabled by default.
- Section id and pid scanners should be disabled after the correct data is
found. This can be made via VDR's channel editor.
- 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:
- The IPTV section filtering code is derived from Linux kernel.
- The pid scanning code is derived from Udo Richter's streamplayer plugin.

View File

@ -3,82 +3,71 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: common.c,v 1.7 2007/10/20 23:25:14 ajhseppa Exp $
*/
#include <ctype.h>
#include <vdr/i18n.h>
#include <vdr/tools.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 ((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;
if (bufP[3] & 0x20) { // adaptation field?
if (bufP[4] > 183) // corrupted data?
if (tsp[3] & 0x20) { // adaptation field?
if (tsp[4] > 183) // corrupted data?
return 0;
else
return (uint8_t)((184 - 1) - bufP[4]);
return 184 - 1 - tsp[4];
}
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) {
if (pidP == section_filter_table[i].pid)
if (Pid == section_filter_table[i].pid)
return section_filter_table[i].tag;
}
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
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = usecsP;
tv.tv_usec = usecs;
// Use select
fd_set infd;
fd_set outfd;
fd_set errfd;
FD_ZERO(&infd);
FD_ZERO(&outfd);
FD_ZERO(&errfd);
FD_SET(descriptorP, &errfd);
if (selectWriteP)
FD_SET(descriptorP, &outfd);
fd_set fds;
FD_ZERO(&fds);
FD_SET(descriptor, &fds);
int retval = 0;
if (selectWrite)
retval = select(descriptor + 1, NULL, &fds, NULL, &tv);
else
FD_SET(descriptorP, &infd);
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
// Check if error
ERROR_IF_RET(retval < 0, "select()", 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] =
{
/* description tag pid tid mask */
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
{trNOOP("EIT (0x4E/0x4F/0x5X/0x6X)"), "EIT", 0x12, 0x40, 0xC0},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
/* description tag pid tid mask */
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
{trNOOP("EIT (0x4E/0x4F)"), "EIT", 0x12, 0x4E, 0xFE},
{trNOOP("EIT (0x5X)"), "EIT", 0x12, 0x50, 0xF0},
{trNOOP("EIT (0x6X)"), "EIT", 0x12, 0x60, 0xF0},
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
};

View File

@ -3,66 +3,51 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: common.h,v 1.13 2007/10/20 23:25:14 ajhseppa Exp $
*/
#ifndef __IPTV_COMMON_H
#define __IPTV_COMMON_H
#include <vdr/tools.h>
#include <vdr/config.h>
#include <vdr/i18n.h>
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define IPTV_BUFFER_SIZE KILOBYTE(2048)
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
#define IPTV_SOURCE_CHARACTER 'I'
#ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x);
#define error(x...) esyslog("IPTV: " x);
#else
#define debug(x...) ;
#define error(x...) esyslog("IPTV: " x);
#endif
#define IPTV_DEVICE_INFO_ALL 0
#define IPTV_DEVICE_INFO_GENERAL 1
#define IPTV_DEVICE_INFO_PIDS 2
#define IPTV_DEVICE_INFO_FILTERS 3
#define IPTV_DEVICE_INFO_PROTOCOL 4
#define IPTV_DEVICE_INFO_BITRATE 5
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
#define SECTION_FILTER_TABLE_SIZE 5
#define SECTION_FILTER_TABLE_SIZE 7
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
esyslog("[%s,%d]: " errstr ": %s", __FILE__, __LINE__, \
strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
error("ERROR: "errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
} while (0)
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );
#define DELETE_POINTER(ptr) \
do { \
if (ptr) { \
typeof(*ptr) *tmp = ptr; \
ptr = NULL; \
delete(tmp); \
} \
} while (0)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
uint16_t ts_pid(const uint8_t *bufP);
uint8_t payload(const uint8_t *bufP);
const char *id_pid(const u_short pidP);
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP);
cString ChangeCase(const cString &strP, bool upperP);
uint16_t ts_pid(const uint8_t *buf);
uint8_t payload(const uint8_t *tsp);
const char *id_pid(const u_short Pid);
int select_single_desc(int descriptor, const int usecs, const bool selectWrite);
struct section_filter_table_type {
const char *description;
@ -74,7 +59,5 @@ struct section_filter_table_type {
extern const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE];
extern const char VERSION[];
#endif // __IPTV_COMMON_H

View File

@ -3,52 +3,48 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: config.c,v 1.18 2007/10/20 17:26:46 rahrenbe Exp $
*/
#include "log.h"
#include "config.h"
cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void)
: traceModeM(eTraceModeNormal),
protocolBasePortM(4321),
useBytesM(1),
sectionFilteringM(1)
: readBufferTsCount(48),
tsBufferSize(2),
tsBufferPrefillRatio(0),
extProtocolBasePort(4321),
useBytes(1),
sectionFiltering(1),
sidScanning(1)
{
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
disabledFiltersM[i] = -1;
memset(configDirectoryM, 0, sizeof(configDirectoryM));
memset(resourceDirectoryM, 0, sizeof(resourceDirectoryM));
for (unsigned int i = 0; i < sizeof(disabledFilters); ++i)
disabledFilters[i] = -1;
memset(configDirectory, '\0', sizeof(configDirectory));
}
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
unsigned int cIptvConfig::GetDisabledFiltersCount(void)
{
unsigned int n = 0;
while ((n < ARRAY_SIZE(disabledFiltersM) && (disabledFiltersM[n] != -1)))
n++;
while ((disabledFilters[n] != -1) && (n < sizeof(disabledFilters)))
n++;
return n;
}
int cIptvConfig::GetDisabledFilters(unsigned int indexP) const
int cIptvConfig::GetDisabledFilters(unsigned int Index)
{
return (indexP < ARRAY_SIZE(disabledFiltersM)) ? disabledFiltersM[indexP] : -1;
return (Index < sizeof(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))
disabledFiltersM[indexP] = numberP;
if (Index < sizeof(disabledFilters))
disabledFilters[Index] = Number;
}
void cIptvConfig::SetConfigDirectory(const char *directoryP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
}
void cIptvConfig::SetResourceDirectory(const char *directoryP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory");
debug("cIptvConfig::SetConfigDirectory(%s)", directoryP);
strn0cpy(configDirectory, directoryP, sizeof(configDirectory));
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: config.h,v 1.16 2007/10/20 17:26:46 rahrenbe Exp $
*/
#ifndef __IPTV_CONFIG_H
@ -10,56 +11,41 @@
#include <vdr/menuitems.h>
#include "common.h"
#include "config.h"
class cIptvConfig
{
private:
unsigned int traceModeM;
unsigned int protocolBasePortM;
unsigned int useBytesM;
unsigned int sectionFilteringM;
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE];
char configDirectoryM[PATH_MAX];
char resourceDirectoryM[PATH_MAX];
unsigned int readBufferTsCount;
unsigned int tsBufferSize;
unsigned int tsBufferPrefillRatio;
unsigned int extProtocolBasePort;
unsigned int useBytes;
unsigned int sectionFiltering;
unsigned int sidScanning;
int disabledFilters[SECTION_FILTER_TABLE_SIZE];
char configDirectory[255];
public:
enum eTraceMode {
eTraceModeNormal = 0x0000,
eTraceModeDebug1 = 0x0001,
eTraceModeDebug2 = 0x0002,
eTraceModeDebug3 = 0x0004,
eTraceModeDebug4 = 0x0008,
eTraceModeDebug5 = 0x0010,
eTraceModeDebug6 = 0x0020,
eTraceModeDebug7 = 0x0040,
eTraceModeDebug8 = 0x0080,
eTraceModeDebug9 = 0x0100,
eTraceModeDebug10 = 0x0200,
eTraceModeDebug11 = 0x0400,
eTraceModeDebug12 = 0x0800,
eTraceModeDebug13 = 0x1000,
eTraceModeDebug14 = 0x2000,
eTraceModeDebug15 = 0x4000,
eTraceModeDebug16 = 0x8000,
eTraceModeMask = 0xFFFF
};
cIptvConfig();
unsigned int GetTraceMode(void) const { return traceModeM; }
bool IsTraceMode(eTraceMode modeP) const { return (traceModeM & modeP); }
unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; }
unsigned int GetUseBytes(void) const { return useBytesM; }
unsigned int GetSectionFiltering(void) const { return sectionFilteringM; }
const char *GetConfigDirectory(void) const { return configDirectoryM; }
const char *GetResourceDirectory(void) const { return resourceDirectoryM; }
unsigned int GetDisabledFiltersCount(void) const;
int GetDisabledFilters(unsigned int indexP) const;
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); }
void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; }
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; }
void SetDisabledFilters(unsigned int indexP, int numberP);
unsigned int GetReadBufferTsCount(void) { return readBufferTsCount; }
unsigned int GetTsBufferSize(void) { return tsBufferSize; }
unsigned int GetTsBufferPrefillRatio(void) { return tsBufferPrefillRatio; }
unsigned int GetExtProtocolBasePort(void) { return extProtocolBasePort; }
unsigned int GetUseBytes(void) { return useBytes; }
unsigned int GetSectionFiltering(void) { return sectionFiltering; }
unsigned int GetSidScanning(void) { return sidScanning; }
const char *GetConfigDirectory(void) { return configDirectory; }
unsigned int GetDisabledFiltersCount(void);
int GetDisabledFilters(unsigned int Index);
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
void SetExtProtocolBasePort(unsigned int PortNumber) { extProtocolBasePort = PortNumber; }
void SetUseBytes(unsigned int On) { useBytes = On; }
void SetSectionFiltering(unsigned int On) { sectionFiltering = On; }
void SetSidScanning(unsigned int On) { sidScanning = On; }
void SetDisabledFilters(unsigned int Index, int Number);
void SetConfigDirectory(const char *directoryP);
void SetResourceDirectory(const char *directoryP);
};
extern cIptvConfig IptvConfig;

686
device.c
View File

@ -3,120 +3,94 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.72 2007/10/20 20:35:06 rahrenbe Exp $
*/
#include "config.h"
#include "source.h"
#include "device.h"
#define IPTV_MAX_DEVICES MAXDEVICES
#define IPTV_MAX_DEVICES 8
static cIptvDevice * IptvDevicesS[IPTV_MAX_DEVICES] = { NULL };
cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL };
cIptvDevice::cIptvDevice(unsigned int indexP)
: deviceIndexM(indexP),
dvrFdM(-1),
isPacketDeliveredM(false),
isOpenDvrM(false),
sidScanEnabledM(false),
pidScanEnabledM(false),
channelM()
unsigned int cIptvDevice::deviceCount = 0;
cIptvDevice::cIptvDevice(unsigned int Index)
: deviceIndex(Index),
isPacketDelivered(false),
isOpenDvr(false),
mutex()
{
unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE;
bufsize -= (bufsize % TS_SIZE);
info("Creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex());
tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
*cString::sprintf("IPTV TS %d", deviceIndexM));
if (tsBufferM) {
tsBufferM->SetTimeouts(100, 100);
tsBufferM->SetIoThrottle();
pIptvStreamerM = new cIptvStreamer(*this, tsBufferM->Free());
}
pUdpProtocolM = new cIptvProtocolUdp();
pCurlProtocolM = new cIptvProtocolCurl();
pHttpProtocolM = new cIptvProtocolHttp();
pFileProtocolM = new cIptvProtocolFile();
pExtProtocolM = new cIptvProtocolExt();
pPidScannerM = new cPidScanner();
debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex);
tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
false, "IPTV");
tsBuffer->SetTimeouts(100, 100);
ResetBuffering();
pUdpProtocol = new cIptvProtocolUdp();
pHttpProtocol = new cIptvProtocolHttp();
pFileProtocol = new cIptvProtocolFile();
pExtProtocol = new cIptvProtocolExt();
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
// Initialize filter pointers
memset(&secfilters, '\0', sizeof(secfilters));
// Start section handler for iptv device
pIptvSectionM = new cIptvSectionFilterHandler(deviceIndexM, bufsize + 1);
StartSectionHandler();
// Sid scanner must be created after the section handler
AttachFilter(pSidScannerM = new cSidScanner());
// Check if dvr fifo exists
struct stat sb;
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndexM);
stat(filename, &sb);
if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0)
info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
}
pSidScanner = new cSidScanner;
if (pSidScanner)
AttachFilter(pSidScanner);
}
cIptvDevice::~cIptvDevice()
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop section handler of iptv device
StopSectionHandler();
DELETE_POINTER(pIptvSectionM);
DELETE_POINTER(pSidScannerM);
DELETE_POINTER(pPidScannerM);
DELETE_POINTER(pIptvStreamerM);
DELETE_POINTER(pExtProtocolM);
DELETE_POINTER(pFileProtocolM);
DELETE_POINTER(pHttpProtocolM);
DELETE_POINTER(pCurlProtocolM);
DELETE_POINTER(pUdpProtocolM);
DELETE_POINTER(tsBufferM);
// Close dvr fifo
if (dvrFdM >= 0) {
int fd = dvrFdM;
dvrFdM = -1;
close(fd);
debug("cIptvDevice::~cIptvDevice(%d)\n", deviceIndex);
DELETENULL(pIptvStreamer);
DELETENULL(pUdpProtocol);
DELETENULL(pHttpProtocol);
DELETENULL(pFileProtocol);
DELETENULL(pExtProtocol);
DELETENULL(tsBuffer);
// Detach and destroy sid filter
if (pSidScanner) {
Detach(pSidScanner);
DELETENULL(pSidScanner);
}
// Destroy all filters
for (int i = 0; i < eMaxSecFilterCount; ++i)
DeleteFilter(i);
}
bool cIptvDevice::Initialize(unsigned int deviceCountP)
bool cIptvDevice::Initialize(unsigned int DeviceCount)
{
debug1("%s (%u)", __PRETTY_FUNCTION__, deviceCountP);
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
if (deviceCountP > IPTV_MAX_DEVICES)
deviceCountP = IPTV_MAX_DEVICES;
for (unsigned int i = 0; i < deviceCountP; ++i)
IptvDevicesS[i] = new cIptvDevice(i);
for (unsigned int i = deviceCountP; i < IPTV_MAX_DEVICES; ++i)
IptvDevicesS[i] = NULL;
debug("cIptvDevice::Initialize(): DeviceCount=%d\n", DeviceCount);
if (DeviceCount > IPTV_MAX_DEVICES)
DeviceCount = IPTV_MAX_DEVICES;
for (unsigned int i = 0; i < DeviceCount; ++i)
IptvDevices[i] = new cIptvDevice(i);
for (unsigned int i = DeviceCount; i < IPTV_MAX_DEVICES; ++i)
IptvDevices[i] = NULL;
return true;
}
void cIptvDevice::Shutdown(void)
{
debug1("%s", __PRETTY_FUNCTION__);
for (int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i])
IptvDevicesS[i]->CloseDvr();
}
}
unsigned int cIptvDevice::Count(void)
{
unsigned int count = 0;
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvDevice::Count()\n");
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i] != NULL)
if (IptvDevices[i] != NULL)
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) {
if (IptvDevicesS[i] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
debug16("%s (%d) Found", __PRETTY_FUNCTION__, cardIndexP);
return IptvDevicesS[i];
if ((IptvDevices[i] != NULL) && (IptvDevices[i]->CardIndex() == CardIndex)) {
//debug("cIptvDevice::GetIptvDevice(%d): FOUND!\n", CardIndex);
return IptvDevices[i];
}
}
return NULL;
@ -124,339 +98,293 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
cString cIptvDevice::GetGeneralInformation(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
LOCK_CHANNELS_READ;
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
deviceIndexM, CardIndex(),
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "",
pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "",
*GetBufferStatistic(),
*Channels->GetByNumber(cDevice::CurrentChannel())->ToText());
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
deviceIndex, CardIndex(),
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
*cIptvBufferStatistics::GetStatistic(),
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
}
cString cIptvDevice::GetPidsInformation(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return GetPidStatistic();
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
return cIptvPidStatistics::GetStatistic();
}
cString cIptvDevice::GetFiltersInformation(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return cString::sprintf("Active section filters:\n%s", pIptvSectionM ? *pIptvSectionM->GetInformation() : "");
//debug("cIptvDevice::GetFiltersInformation(%d)\n", deviceIndex);
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]->GetStatistic(), 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
cString s;
switch (pageP) {
cString info;
switch (Page) {
case IPTV_DEVICE_INFO_GENERAL:
s = GetGeneralInformation();
info = GetGeneralInformation();
break;
case IPTV_DEVICE_INFO_PIDS:
s = GetPidsInformation();
info = GetPidsInformation();
break;
case IPTV_DEVICE_INFO_FILTERS:
s = GetFiltersInformation();
break;
case IPTV_DEVICE_INFO_PROTOCOL:
s = pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "";
break;
case IPTV_DEVICE_INFO_BITRATE:
s = pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "";
info = GetFiltersInformation();
break;
default:
s = cString::sprintf("%s%s%s",
*GetGeneralInformation(),
*GetPidsInformation(),
*GetFiltersInformation());
info = cString::sprintf("%s%s%s",
*GetGeneralInformation(),
*GetPidsInformation(),
*GetFiltersInformation());
break;
}
return s;
return info;
}
cString cIptvDevice::DeviceType(void) const
cString cIptvDevice::GetChannelSettings(const char *IptvParam, int *Parameter, cIptvProtocolIf* *Protocol)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return "IPTV";
}
cString cIptvDevice::DeviceName(void) const
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return cString::sprintf("IPTV %d", deviceIndexM);
}
int cIptvDevice::SignalStrength(void) const
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100);
}
int cIptvDevice::SignalQuality(void) const
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100);
}
bool cIptvDevice::ProvidesSource(int sourceP) const
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER));
}
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (ProvidesSource(channelP->Source()));
}
bool cIptvDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool *needsDetachReceiversP) const
{
bool result = false;
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
bool needsDetachReceivers = false;
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (channelP && ProvidesTransponder(channelP)) {
result = hasPriority;
if (Receiving()) {
if (channelP->GetChannelID() == channelM.GetChannelID())
result = true;
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
char *tag = NULL;
char *proto = NULL;
char *loc = NULL;
if (sscanf(IptvParam, "%a[^|]|%a[^|]|%a[^|]|%u", &tag, &proto, &loc, Parameter) == 4) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = pUdpProtocol;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = pHttpProtocol;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = pFileProtocol;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = pExtProtocol;
else
needsDetachReceivers = Receiving();
}
}
if (needsDetachReceiversP)
*needsDetachReceiversP = needsDetachReceivers;
return result;
}
bool cIptvDevice::ProvidesEIT(void) const
{
return false;
}
int cIptvDevice::NumProvidedSystems(void) const
{
return 1;
}
const cChannel *cIptvDevice::GetCurrentlyTunedTransponder(void) const
{
return &channelM;
}
bool cIptvDevice::IsTunedToTransponder(const cChannel *channelP) const
{
return channelP ? (channelP->GetChannelID() == channelM.GetChannelID()) : false;
}
bool cIptvDevice::MaySwitchTransponder(const cChannel *channelP) const
{
return cDevice::MaySwitchTransponder(channelP);
}
bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
{
cIptvProtocolIf *protocol;
cIptvTransponderParameters itp(channelP->Parameters());
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isempty(itp.Address())) {
error("Unrecognized IPTV address: %s", channelP->Parameters());
return false;
}
switch (itp.Protocol()) {
case cIptvTransponderParameters::eProtocolUDP:
protocol = pUdpProtocolM;
break;
case cIptvTransponderParameters::eProtocolCURL:
protocol = pCurlProtocolM;
break;
case cIptvTransponderParameters::eProtocolHTTP:
protocol = pHttpProtocolM;
break;
case cIptvTransponderParameters::eProtocolFILE:
protocol = pFileProtocolM;
break;
case cIptvTransponderParameters::eProtocolEXT:
protocol = pExtProtocolM;
break;
default:
error("Unrecognized IPTV protocol: %s", channelP->Parameters());
return false;
break;
}
sidScanEnabledM = itp.SidScan() ? true : false;
pidScanEnabledM = itp.PidScan() ? true : false;
if (pIptvStreamerM && pIptvStreamerM->SetSource(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) {
channelM = *channelP;
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
pSidScannerM->SetChannel(channelM.GetChannelID());
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->SetChannel(channelM.GetChannelID());
}
return true;
}
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
{
debug1("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM);
if (pIptvStreamerM && handleP)
return pIptvStreamerM->SetPid(handleP->pid, typeP, onP);
return true;
}
int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
{
debug16("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
if (pIptvSectionM && IptvConfig.GetSectionFiltering()) {
if (pIptvStreamerM)
pIptvStreamerM->SetPid(pidP, ptOther, true);
return pIptvSectionM->Open(pidP, tidP, maskP);
}
return -1;
}
void cIptvDevice::CloseFilter(int handleP)
{
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, handleP, deviceIndexM);
if (pIptvSectionM) {
if (pIptvStreamerM)
pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false);
pIptvSectionM->Close(handleP);
}
}
bool cIptvDevice::OpenDvr(void)
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
isPacketDeliveredM = false;
tsBufferM->Clear();
if (pIptvStreamerM)
pIptvStreamerM->Open();
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
pSidScannerM->Open();
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Open();
isOpenDvrM = true;
return true;
}
void cIptvDevice::CloseDvr(void)
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Close();
if (sidScanEnabledM && pSidScannerM)
pSidScannerM->Close();
if (pIptvStreamerM)
pIptvStreamerM->Close();
isOpenDvrM = false;
}
bool cIptvDevice::HasLock(int timeoutMsP) const
{
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, timeoutMsP, deviceIndexM);
return (pIptvStreamerM && pIptvStreamerM->Active());
}
bool cIptvDevice::HasInternalCam(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return false;
}
void cIptvDevice::WriteData(uchar *bufferP, int lengthP)
{
debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
int len;
// Send data to dvr fifo
if (dvrFdM >= 0)
len = write(dvrFdM, bufferP, lengthP);
// Fill up TS buffer
if (tsBufferM) {
len = tsBufferM->Put(bufferP, lengthP);
if (len != lengthP)
tsBufferM->ReportOverflow(lengthP - len);
}
// Filter the sections
if (pIptvSectionM && IptvConfig.GetSectionFiltering())
pIptvSectionM->Write(bufferP, lengthP);
}
unsigned int cIptvDevice::CheckData(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (tsBufferM)
return (unsigned int)tsBufferM->Free();
return 0;
}
uchar *cIptvDevice::GetData(int *availableP)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isOpenDvrM && tsBufferM) {
int count = 0;
if (isPacketDeliveredM)
SkipData(TS_SIZE);
uchar *p = tsBufferM->Get(count);
if (p && count >= TS_SIZE) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < count; i++) {
if (p[i] == TS_SYNC_BYTE) {
count = i;
break;
}
}
tsBufferM->Del(count);
info("Skipped %d bytes to sync on TS packet", count);
return NULL;
}
isPacketDeliveredM = true;
if (availableP)
*availableP = count;
// Update pid statistics
AddPidStatistic(ts_pid(p), payload(p));
return p;
// return location
return locstr;
}
}
return NULL;
}
void cIptvDevice::SkipData(int countP)
bool cIptvDevice::ProvidesIptv(const char *Param) const
{
debug16("%s (%d) [device %d]]", __PRETTY_FUNCTION__, countP, deviceIndexM);
tsBufferM->Del(countP);
isPacketDeliveredM = false;
// Update buffer statistics
AddBufferStatistic(countP, tsBufferM->Available());
debug("cIptvDevice::ProvidesIptv(%d)\n", deviceIndex);
return (strncasecmp(Param, "IPTV", 4) == 0);
}
bool cIptvDevice::GetTSPacket(uchar *&dataP)
bool cIptvDevice::ProvidesSource(int Source) const
{
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;
debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex);
return (cSource::IsPlug(Source));
}
bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const
{
debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex);
return (ProvidesSource(Channel->Source()) && ProvidesIptv(Channel->PluginParam()));
}
bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
{
bool result = false;
bool needsDetachReceivers = false;
debug("cIptvDevice::ProvidesChannel(%d)\n", deviceIndex);
if (ProvidesTransponder(Channel))
result = true;
if (NeedsDetachReceivers)
*NeedsDetachReceivers = needsDetachReceivers;
return result;
}
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
int parameter;
cString location;
cIptvProtocolIf *protocol;
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
location = GetChannelSettings(Channel->PluginParam(), &parameter, &protocol);
if (isempty(location)) {
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false;
}
// Reduce cpu load by preventing busylooping
cCondWait::SleepMs(10);
dataP = NULL;
pIptvStreamer->Set(location, parameter, deviceIndex, protocol);
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
pSidScanner->SetChannel(Channel);
return true;
}
bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
{
debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndex, Handle->pid, Type, On);
return true;
}
bool cIptvDevice::DeleteFilter(unsigned int Index)
{
if ((Index < eMaxSecFilterCount) && secfilters[Index]) {
//debug("cIptvDevice::DeleteFilter(%d) Index=%d\n", deviceIndex, Index);
cIptvSectionFilter *tmp = secfilters[Index];
secfilters[Index] = NULL;
delete tmp;
return true;
}
return false;
}
bool cIptvDevice::IsBlackListed(u_short Pid, u_char Tid, u_char Mask)
{
//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;
// 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(i, deviceIndex, Pid, Tid, Mask);
return secfilters[i]->GetReadDesc();
}
}
// No free filter slot found
return -1;
}
void cIptvDevice::CloseFilter(int Handle)
{
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) {
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
DeleteFilter(i);
break;
}
}
}
bool cIptvDevice::OpenDvr(void)
{
debug("cIptvDevice::OpenDvr(%d)\n", deviceIndex);
mutex.Lock();
isPacketDelivered = false;
tsBuffer->Clear();
mutex.Unlock();
ResetBuffering();
pIptvStreamer->Open();
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
pSidScanner->SetStatus(true);
isOpenDvr = true;
return true;
}
void cIptvDevice::CloseDvr(void)
{
debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex);
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
pSidScanner->SetStatus(false);
pIptvStreamer->Close();
isOpenDvr = false;
}
bool cIptvDevice::HasLock(int TimeoutMs)
{
//debug("cIptvDevice::HasLock(%d): %d\n", deviceIndex, TimeoutMs);
return (!IsBuffering());
}
void cIptvDevice::ResetBuffering(void)
{
debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndex);
// pad prefill to multiple of TS_SIZE
tsBufferPrefill = 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;
}
bool cIptvDevice::GetTSPacket(uchar *&Data)
{
int Count = 0;
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
if (!IsBuffering()) {
if (isPacketDelivered) {
tsBuffer->Del(TS_SIZE);
isPacketDelivered = false;
// Update buffer statistics
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
}
uchar *p = tsBuffer->Get(Count);
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;
}
}
tsBuffer->Del(Count);
error("ERROR: skipped %d bytes to sync on TS packet\n", Count);
return false;
}
isPacketDelivered = true;
Data = p;
// Update pid statistics
cIptvPidStatistics::AddStatistic(ts_pid(p), payload(p));
// Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i])
secfilters[i]->ProcessData(p);
}
return true;
}
}
Data = NULL;
return true;
}

102
device.h
View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.h,v 1.34 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_DEVICE_H
@ -10,113 +11,86 @@
#include <vdr/device.h>
#include "common.h"
#include "deviceif.h"
#include "protocoludp.h"
#include "protocolcurl.h"
#include "protocolhttp.h"
#include "protocolfile.h"
#include "protocolext.h"
#include "streamer.h"
#include "sectionfilter.h"
#include "pidscanner.h"
#include "sidscanner.h"
#include "statistics.h"
class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics, public cIptvDeviceIf {
class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBufferStatistics {
// static ones
public:
static unsigned int deviceCount;
static bool Initialize(unsigned int DeviceCount);
static void Shutdown(void);
static unsigned int Count(void);
static cIptvDevice *GetIptvDevice(int CardIndex);
// private parts
private:
unsigned int deviceIndexM;
int dvrFdM;
bool isPacketDeliveredM;
bool isOpenDvrM;
bool sidScanEnabledM;
bool pidScanEnabledM;
cRingBufferLinear *tsBufferM;
cChannel channelM;
cIptvProtocolUdp *pUdpProtocolM;
cIptvProtocolCurl *pCurlProtocolM;
cIptvProtocolHttp *pHttpProtocolM;
cIptvProtocolFile *pFileProtocolM;
cIptvProtocolExt *pExtProtocolM;
cIptvStreamer *pIptvStreamerM;
cIptvSectionFilterHandler *pIptvSectionM;
cPidScanner *pPidScannerM;
cSidScanner *pSidScannerM;
cMutex mutexM;
enum {
eMaxSecFilterCount = 32
};
unsigned int deviceIndex;
bool isPacketDelivered;
bool isOpenDvr;
cRingBufferLinear *tsBuffer;
int tsBufferPrefill;
cIptvProtocolUdp *pUdpProtocol;
cIptvProtocolHttp *pHttpProtocol;
cIptvProtocolFile *pFileProtocol;
cIptvProtocolExt *pExtProtocol;
cIptvStreamer *pIptvStreamer;
cSidScanner *pSidScanner;
cMutex mutex;
cIptvSectionFilter* secfilters[eMaxSecFilterCount];
// constructor & destructor
public:
cIptvDevice(unsigned int deviceIndexP);
cIptvDevice(unsigned int DeviceIndex);
virtual ~cIptvDevice();
cString GetInformation(unsigned int pageP = IPTV_DEVICE_INFO_ALL);
// copy and assignment constructors
private:
cIptvDevice(const cIptvDevice&);
cIptvDevice& operator=(const cIptvDevice&);
cString GetInformation(unsigned int Page = IPTV_DEVICE_INFO_ALL);
// for statistics and general information
private:
cString GetGeneralInformation(void);
cString GetPidsInformation(void);
cString GetFiltersInformation(void);
// for channel info
public:
virtual cString DeviceType(void) const;
virtual cString DeviceName(void) const;
virtual int SignalStrength(void) const;
virtual int SignalQuality(void) const;
// for channel parsing & buffering
private:
cString GetChannelSettings(const char *IptvParam, int *Parameter, cIptvProtocolIf* *Protocol);
bool ProvidesIptv(const char *Param) const;
void ResetBuffering(void);
bool IsBuffering(void);
bool DeleteFilter(unsigned int Index);
bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask);
// for channel selection
public:
virtual bool ProvidesSource(int sourceP) const;
virtual bool ProvidesTransponder(const cChannel *channelP) const;
virtual bool ProvidesChannel(const cChannel *channelP, int priorityP = -1, bool *needsDetachReceiversP = NULL) const;
virtual bool ProvidesEIT(void) const;
virtual int NumProvidedSystems(void) const;
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
virtual bool IsTunedToTransponder(const cChannel *channelP) const;
virtual bool MaySwitchTransponder(const cChannel *channelP) const;
virtual bool ProvidesSource(int Source) const;
virtual bool ProvidesTransponder(const cChannel *Channel) const;
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
protected:
virtual bool SetChannelDevice(const cChannel *channelP, bool liveViewP);
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
// for recording
private:
uchar *GetData(int *availableP = NULL);
void SkipData(int countP);
protected:
virtual bool SetPid(cPidHandle *handleP, int typeP, bool onP);
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
virtual bool OpenDvr(void);
virtual void CloseDvr(void);
virtual bool GetTSPacket(uchar *&dataP);
virtual bool GetTSPacket(uchar *&Data);
// for section filtering
public:
virtual int OpenFilter(u_short pidP, u_char tidP, u_char maskP);
virtual void CloseFilter(int handleP);
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
virtual void CloseFilter(int Handle);
// for transponder lock
public:
virtual bool HasLock(int timeoutMsP) const;
// 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);
virtual bool HasLock(int);
};
#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

181
iptv.c
View File

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

View File

@ -1,84 +0,0 @@
#!/bin/sh
set -e
# image.sh is used by the VDR iptv plugin to transcode images from
# a web server to provide a video stream.
#
# The script originates from Peter Holik
#
# Example channels.conf entries:
# Energy;IPTV:50:S=0|P=0|F=EXT|U=png.sh|A=1:I:0:256:257:0:0:3:0:0:0
# Temperature;IPTV:60:S=0|P=0|EXT|U=png.sh|A=2:I:0:256:257:0:0:3:0:0:0
# Temperature Week;IPTV:70:S=0|P=0|EXT|U=png.sh|A=3:I:0:256:257:0:0:3:0:0:0
# Server Temperature;IPTV:80:S=0|P=0|EXT|U=png.sh|A=4:I:0:256:257:0:0:3:0:0:0
# Server Temperature Week;IPTV:90:S=0|P=0|EXT|U=png.sh|A=5:I:0:256:257:0:0:3:0:0:0
# Traffic;IPTV:100:S=0|P=0|EXT|U=png.sh|A=6:I:0:256:257:0:0:3:0:0:0
#
# webcam.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
# Channels.conf parameter
case ${1} in
1)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=energy;type=electricity"
;;
2)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Outdoor"
;;
3)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Outdoor;begin=-604800"
;;
4)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Server"
;;
5)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Server;begin=-604800"
;;
6)
URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=interface;type=if_octets;type_instance=ppp0"
;;
*)
URL="" # Default URL - TODO get dummy picture
;;
esac
# Iptv plugin listens this port
PORT=${2}
# Stream temporary files
IMAGE=/tmp/image.png
LOG=/dev/null
{
# Using wget because ffmpeg cannot handle http/1.1 "Transfer-Encoding: chunked"
wget -q -O "${IMAGE}" "${URL}"
# Build stream from audiodump with cycle image as video
# PID 0x100/256 = Video 0x101/257 = Audio
exec ffmpeg -v 10 \
-analyzeduration 0 \
-loop_input \
-i "${IMAGE}" \
-f mpegts -r 25 -vcodec mpeg2video -b 4000k -s 664x540 -padleft 20 -padright 20 -padtop 16 -padbottom 20 \
-an \
"udp://127.0.0.1:${PORT}?pkt_size=16356"
} > ${LOG} 2>&1

View File

@ -1,67 +0,0 @@
#!/bin/sh
# internetradio.sh is used by the VDR iptv plugin to transcode an internet
# radio stream.
#
# The script originates from:
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# internetradio;IPTV:2:S=0|P=0|F=EXT|U=internetradio.sh|A=0:P:0:0:256:0:0:2:0:0:0
#
# internetradio.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
# Channels.conf parameter
PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Stream configuration
URL="mms://stream"
TITLE="internetradio"
# Stream temporary files
FIFO=/tmp/internetradio.fifo
LOG=/dev/null
{
rm -f "${FIFO}"
mkfifo "${FIFO}"
mplayer -dumpstream "${URL}" \
-quiet -nolirc -noautosub -noconsolecontrols -novideo -nojoystick \
-dumpfile "$FIFO" &
# Time to connect and fill pipe
sleep 3
# Build audio only stream
# PID 0x100/256 = Audio
ffmpeg -v -1 \
-i "${FIFO}" \
-title "${TITLE}" \
-f mpegts -acodec mp2 -ac 2 -ab 96k -ar 48000 \
"udp://127.0.0.1:${PORT}?pkt_size=16356"
rm -f "${FIFO}"
} > ${LOG} 2>&1

View File

@ -1,76 +0,0 @@
#!/bin/sh
#
# iptvstream.sh can be used by the VDR iptv plugin to transcode external
# sources
#
# (C) 2007 Rolf Ahrenberg, Antti Seppälä
#
# iptvstream.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
# Channels.conf parameter
PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Default settings for stream transcoding
VCODEC=mp2v
VBITRATE=2400
ACODEC=mpga
ABITRATE=320
# There is a way to specify multiple URLs in the same script. The selection is
# then controlled by the extra parameter passed by IPTV plugin to the script
case ${PARAMETER} in
1)
URL=""
WIDTH=720
HEIGHT=576
;;
2)
URL=""
;;
3)
URL=""
;;
*)
URL="" # Default URL
;;
esac
if [ -z "${URL}" ]; then
logger "$0: error: URL not defined!"
exit 1
fi
# Create transcoding options
TRANSCODE_OPTS="vcodec=${VCODEC},acodec=${ACODEC},vb=${VBITRATE},ab=${ABITRATE}"
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
fi
# Create unique pids for the stream
let VPID=${PARAMETER}+1
let APID=${PARAMETER}+2
let SPID=${PARAMETER}+3
# Execute VLC
exec vlc "${URL}" --sout "#transcode{${TRANSCODE_OPTS}}:standard{access=udp,mux=ts{pid-video=${VPID},pid-audio=${APID},pid-spu=${SPID}},dst=127.0.0.1:${PORT}}" --intf dummy

View File

@ -1,28 +1,8 @@
#!/bin/sh
#
# iptvstream.sh can be used by the VDR iptv plugin to transcode external
# sources
#
# (C) 2007 Rolf Ahrenberg, Antti Seppälä
#
# iptvstream.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
exit 1;
fi
# Channels.conf parameter
@ -31,44 +11,30 @@ PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Default settings for stream transcoding
VCODEC=mp2v
# Default bitrates for stream transcoding
VBITRATE=2400
ACODEC=mpga
ABITRATE=320
# There is a way to specify multiple URLs in the same script. The selection is
# then controlled by the extra parameter passed by IPTV plugin to the script
case ${PARAMETER} in
case $PARAMETER in
1)
URL=""
WIDTH=720
HEIGHT=576
FPS=25
;;
URL=""
;;
2)
URL=""
;;
URL=""
;;
3)
URL=""
;;
URL=""
;;
*)
URL="" # Default URL
;;
URL="" # Default URL
;;
esac
if [ -z "${URL}" ]; then
logger "$0: error: URL not defined!"
exit 1
fi
# Create transcoding options
TRANSCODE_OPTS="vcodec=${VCODEC},acodec=${ACODEC},vb=${VBITRATE},ab=${ABITRATE}"
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
fi
if [ -n "${FPS}" ] ; then
TRANSCODE_OPTS="${TRANSCODE_OPTS},fps=${FPS}"
exit 1;
fi
# Create unique pids for the stream
@ -76,12 +42,5 @@ let VPID=${PARAMETER}+1
let APID=${PARAMETER}+2
let SPID=${PARAMETER}+3
# Capture VLC pid for further management in IPTV plugin
vlc "${URL}" --sout "#transcode{${TRANSCODE_OPTS}}:standard{access=udp,mux=ts{pid-video=${VPID},pid-audio=${APID},pid-spu=${SPID}},dst=127.0.0.1:${PORT}}" --intf dummy &
PID=${!}
trap 'kill -INT ${PID} 2> /dev/null' INT EXIT QUIT TERM
# Waiting for the given PID to terminate
wait ${PID}
# Use 'exec' for capturing program pid for further management in IPTV plugin
exec vlc "${URL}" --sout "#transcode{vcodec=mp2v,acodec=mpga,vb=${VBITRATE},ab=${ABITRATE}}:standard{access=udp,mux=ts{pid-video=${VPID},pid-audio=${APID},pid-spu=${SPID}},dst=127.0.0.1:${PORT}}" --intf dummy

View File

@ -1,54 +0,0 @@
#!/bin/sh
# linein.sh is used by the VDR iptv plugin to transcode line-in of
# a soundcard.
#
# The script originates from:
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# linein;IPTV:5:S=0|P=0|F=EXT|U=linein.sh|A=0:I:27500:0:256:0:0:5:5:5:0
#
# linein.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
# Channels.conf parameter
PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Stream configuration
TITLE="linein"
# Stream temporary files
LOG=/dev/null
{
# PID 0x100/256 = Audio
arecord -q -D hw:0,0 -f dat | \
ffmpeg -v -1 \
-f wav \
-i - \
-title "${TITLE}" \
-f mpegts -acodec mp2 -ac 2 -ab 128k -ar 48000 \
"udp://127.0.0.1:${PORT}?pkt_size=16356"
} > ${LOG} 2>&1

View File

@ -1,100 +0,0 @@
#!/bin/sh
#
# vlc2iptv is used by the VDR iptv plugin to transcode external sources
#
# (C) 2007 Rolf Ahrenberg, Antti Seppälä
# (C) 2007 Tobias Grimm
#
# vlc2iptv is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
# <Global Settings>
#
CHANNELS_CONF=/var/lib/vdr/channels.conf
CHANNEL_SETTINGS_DIR=/etc/vdr/plugins/iptv/vlcinput/
VIDEO_BITRATE=2400
AUDIO_BITRATE=320
#
# </Global Settings>
#
exit_with_error()
{
logger "vlc2iptv: error: $*"
exit 1
}
read_arguments()
{
[ $# -ne 2 ] && exit_with_error "Invalid parameter count '$#' $*"
PARAMETER=$1
PORT=$2
}
lookup_channel_and_pids()
{
[ ! -e "$CHANNELS_CONF" ] && \
exit_with_error "channels.conf not found ($CHANNELS_CONF)"
local CHANNEL_RECORD=`grep "[:]S=[10][|]P=[10][|]F=EXT[|]U=vlc2iptv[|]A=$PARAMETER[:]I" $CHANNELS_CONF`
[ -z "$CHANNEL_RECORD" ] && \
exit_with_error "no iptv channel with parameter $PARAMETER found"
CHANNEL_NAME=`echo $CHANNEL_RECORD | awk "-F[;,:]" '{print $1}'`
VPID=`echo $CHANNEL_RECORD | awk -F: '{print $6}'`
APID=`echo $CHANNEL_RECORD | awk -F: '{print $7}'`
SPID=0
}
load_channel_configuration()
{
local CHANNEL_SETTINGS_FILE="$CHANNEL_SETTINGS_DIR/$CHANNEL_NAME.conf"
[ ! -e $CHANNEL_SETTINGS_FILE ] && \
exit_with_error "No vlc input configuration for channel '$CHANNEL_NAME'"
. $CHANNEL_SETTINGS_FILE
[ -z "$URL" ] && \
exit_with_error "No URL specified for channel '$CHANNEL_NAME'"
}
read_arguments $*
lookup_channel_and_pids
load_channel_configuration
#
# Start VLC
#
if [ -n "$WIDTH" -a -n "$HEIGHT" ] ; then
RESIZE_OPTIONS=",width=${WIDTH},height=${HEIGHT}"
else
RESIZE_OPTIONS=""
fi
vlc "${URL}" \
--sout "#transcode{vcodec=mp2v$RESIZE_OPTIONS,acodec=mpga,vb=${VIDEO_BITRATE},ab=${AUDIO_BITRATE}}:standard{access=udp,mux=ts{pid-video=${VPID},pid-audio=${APID},pid-spu=${SPID}},dst=127.0.0.1:${PORT}}" \
--intf dummy &
PID=${!}
trap 'kill -INT ${PID} 2> /dev/null' INT EXIT QUIT TERM
# Waiting for the given PID to terminate
wait ${PID}

View File

@ -1,69 +0,0 @@
#!/bin/sh
# webcam.sh is used by the VDR iptv plugin to transcode an internet radio
# stream remuxed with images (e.g. webcam) to provide a video stream.
#
# The script originates from:
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
#
# An example channels.conf entry:
# webcam;IPTV:3:S=0|P=0|F=EXT|U=webcam.sh|A=0:I:0:256:257:0:0:3:0:0:0
#
# webcam.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
# Channels.conf parameter
PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Stream configuration
URL="http://stream.address"
IMAGE="image.jpg"
TITLE="webcam"
# Stream temporary files
FIFO=/tmp/webcam.fifo
LOG=/dev/null
{
rm -f "${FIFO}"
mkfifo "${FIFO}"
mplayer -dumpstream "${URL}" \
-quiet -nolirc -noautosub -noconsolecontrols -novideo -nojoystick \
-dumpfile "${FIFO}" &
# Time to connect and fill pipe
sleep 3
# Build stream from audiodump with cycle image as video
# PID 0x100/256 = Video 0x101/257 = Audio
ffmpeg -v -1 \
-i "${FIFO}" -r 0.5 -loop_input -i '${IMAGE}' \
-title "${TITLE}" \
-f mpegts -intra -r 24 -vcodec mpeg2video -b 500k -s 352x288 \
-acodec mp2 -ac 2 -ab 96k -ar 48000 \
"udp://127.0.0.1:${PORT}?pkt_size=16356"
rm -f "${FIFO}"
} > ${LOG} 2>&1

View File

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

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,265 @@
diff -Nru vdr-1.5.10-vanilla/channels.c vdr-1.5.10-pluginparam/channels.c
--- vdr-1.5.10-vanilla/channels.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/channels.c 2007-10-14 20:31:12.000000000 +0300
@@ -166,6 +166,7 @@
shortName = strdup("");
provider = strdup("");
portalName = strdup("");
+ pluginParam = strdup("");
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
inversion = INVERSION_AUTO;
bandwidth = BANDWIDTH_AUTO;
@@ -187,6 +188,7 @@
shortName = NULL;
provider = NULL;
portalName = NULL;
+ pluginParam = NULL;
schedule = NULL;
linkChannels = NULL;
refChannel = NULL;
@@ -215,6 +217,7 @@
free(shortName);
free(provider);
free(portalName);
+ free(pluginParam);
}
cChannel& cChannel::operator= (const cChannel &Channel)
@@ -223,6 +226,7 @@
shortName = strcpyrealloc(shortName, Channel.shortName);
provider = strcpyrealloc(provider, Channel.provider);
portalName = strcpyrealloc(portalName, Channel.portalName);
+ pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
return *this;
}
@@ -280,9 +284,26 @@
transmission = Channel->transmission;
guard = Channel->guard;
hierarchy = Channel->hierarchy;
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
}
}
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
+{
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
+ if (Number()) {
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ source = Source;
+ frequency = Frequency;
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ schedule = NULL;
+ }
+ return true;
+}
+
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH)
{
// Workarounds for broadcaster stupidity:
@@ -407,6 +428,18 @@
}
}
+void cChannel::SetPluginParam(const char *PluginParam)
+{
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
+ if (Number()) {
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ }
+}
+
#define STRDIFF 0x01
#define VALDIFF 0x02
@@ -593,7 +626,7 @@
if (isdigit(type))
type = 'S';
#define ST(s) if (strchr(s, type))
- char buffer[64];
+ char buffer[256];
char *q = buffer;
*q = 0;
ST(" S ") q += sprintf(q, "%c", polarization);
@@ -605,6 +638,7 @@
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
+ ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
return buffer;
}
@@ -626,7 +660,7 @@
bool cChannel::StringToParameters(const char *s)
{
- while (s && *s) {
+ while (s && *s && !IsPlug()) {
switch (toupper(*s)) {
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
case 'C': s = ParseParameter(s, coderateH, CoderateValues); break;
@@ -736,7 +770,7 @@
dpids[0] = 0;
ok = false;
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
+ ok = ((source = cSource::FromString(sourcebuf)) >= 0) && StringToParameters(parambuf);
char *p = strchr(vpidbuf, '+');
if (p)
@@ -827,6 +861,7 @@
shortName = strcpyrealloc(shortName, p);
}
name = strcpyrealloc(name, namebuf);
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
free(parambuf);
free(sourcebuf);
diff -Nru vdr-1.5.10-vanilla/channels.h vdr-1.5.10-pluginparam/channels.h
--- vdr-1.5.10-vanilla/channels.h 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/channels.h 2007-10-14 20:32:16.000000000 +0300
@@ -114,6 +114,7 @@
char *shortName;
char *provider;
char *portalName;
+ char *pluginParam;
int __BeginData__;
int frequency; // MHz
int source;
@@ -165,6 +166,7 @@
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
+ const char *PluginParam(void) const { return pluginParam; }
int Source(void) const { return source; }
int Srate(void) const { return srate; }
int Vpid(void) const { return vpid; }
@@ -199,6 +201,7 @@
int Hierarchy(void) const { return hierarchy; }
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
const cChannel *RefChannel(void) const { return refChannel; }
+ bool IsPlug(void) const { return cSource::IsPlug(source); }
bool IsCable(void) const { return cSource::IsCable(source); }
bool IsSat(void) const { return cSource::IsSat(source); }
bool IsTerr(void) const { return cSource::IsTerr(source); }
@@ -206,12 +209,14 @@
bool HasTimer(void) const;
int Modification(int Mask = CHANNELMOD_ALL);
void CopyTransponderData(const cChannel *Channel);
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
void SetName(const char *Name, const char *ShortName, const char *Provider);
void SetPortalName(const char *PortalName);
+ void SetPluginParam(const char *PluginParam);
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
void SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level);
diff -Nru vdr-1.5.10-vanilla/menu.c vdr-1.5.10-pluginparam/menu.c
--- vdr-1.5.10-vanilla/menu.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/menu.c 2007-10-14 20:31:12.000000000 +0300
@@ -219,6 +219,7 @@
cChannel *channel;
cChannel data;
char name[256];
+ char pluginParam[256];
void Setup(void);
public:
cMenuEditChannel(cChannel *Channel, bool New = false);
@@ -251,6 +252,7 @@
// Parameters for all types of sources:
strn0cpy(name, data.name, sizeof(name));
+ strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name), tr(FileNameChars)));
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
@@ -281,6 +283,7 @@
ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
SetCurrent(Get(current));
Display();
@@ -295,6 +298,7 @@
if (Key == kOk) {
if (Channels.HasUniqueChannelID(&data, channel)) {
data.name = strcpyrealloc(data.name, name);
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
if (channel) {
*channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.5.10-vanilla/po/fi_FI.po vdr-1.5.10-pluginparam/po/fi_FI.po
--- vdr-1.5.10-vanilla/po/fi_FI.po 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/po/fi_FI.po 2007-10-14 20:34:41.000000000 +0300
@@ -998,3 +998,6 @@
#, c-format
msgid "VDR will shut down in %s minutes"
msgstr "VDR sammuu %s minuutin kuluttua"
+
+msgid "Parameters"
+msgstr "Parametrit"
diff -Nru vdr-1.5.10-vanilla/sources.c vdr-1.5.10-pluginparam/sources.c
--- vdr-1.5.10-vanilla/sources.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.c 2007-10-14 20:31:12.000000000 +0300
@@ -37,6 +37,7 @@
char buffer[16];
char *q = buffer;
switch (Code & st_Mask) {
+ case stPlug: *q++ = 'P'; break;
case stCable: *q++ = 'C'; break;
case stSat: *q++ = 'S';
{
@@ -56,6 +57,7 @@
{
int type = stNone;
switch (toupper(*s)) {
+ case 'P': type = stPlug; break;
case 'C': type = stCable; break;
case 'S': type = stSat; break;
case 'T': type = stTerr; break;
diff -Nru vdr-1.5.10-vanilla/sources.conf vdr-1.5.10-pluginparam/sources.conf
--- vdr-1.5.10-vanilla/sources.conf 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.conf 2007-10-14 20:31:12.000000000 +0300
@@ -188,3 +188,7 @@
# Terrestrial
T Terrestrial
+
+# Plugin
+
+P Plugin
diff -Nru vdr-1.5.10-vanilla/sources.h vdr-1.5.10-pluginparam/sources.h
--- vdr-1.5.10-vanilla/sources.h 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.h 2007-10-14 20:31:12.000000000 +0300
@@ -16,10 +16,11 @@
public:
enum eSourceType {
stNone = 0x0000,
+ stPlug = 0x2000,
stCable = 0x4000,
stSat = 0x8000,
stTerr = 0xC000,
- st_Mask = 0xC000,
+ st_Mask = 0xE000,
st_Neg = 0x0800,
st_Pos = 0x07FF,
};
@@ -35,6 +36,7 @@
static cString ToString(int Code);
static int FromString(const char *s);
static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
+ static bool IsPlug(int Code) { return (Code & st_Mask) == stPlug; }
static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }

View File

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

View File

@ -1,41 +0,0 @@
/*
* pidscanner.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __PIDSCANNER_H
#define __PIDSCANNER_H
#include <vdr/tools.h>
#include <vdr/channels.h>
#include "log.h"
class cPidScanner {
private:
enum {
PIDSCANNER_APID_COUNT = 5, /* minimum count of audio pid samples for pid detection */
PIDSCANNER_VPID_COUNT = 5, /* minimum count of video pid samples for pid detection */
PIDSCANNER_PID_DELTA_COUNT = 100, /* minimum count of pid samples for audio/video only pid detection */
PIDSCANNER_TIMEOUT_IN_MS = 15000 /* 15s timeout for detection */
};
cTimeMs timeoutM;
tChannelID channelIdM;
bool processM;
int vPidM;
int aPidM;
int numVpidsM;
int numApidsM;
public:
cPidScanner(void);
~cPidScanner();
void SetChannel(const tChannelID &channelIdP);
void Process(const uint8_t* bufP);
void Open() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); }
void Close() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(0); }
};
#endif // __PIDSCANNER_H

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,135 +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.
# Tobias <vdr@e-tobi.net>, 2007.
# Frank Neumann, 2015.
#
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: Frank Neumann <fnu@yavdr.org>\n"
"Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\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 "Erlebe IPTV"
msgid "IPTV Information"
msgstr "IPTV Informationen"
msgid "General"
msgstr "Allgemein"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filter"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Keine IPTV Informationen verfügbar!"
msgid "Protocol base port"
msgstr "Basis Port Protokoll"
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 ""
"Bestimme einen Basis Port für das CURL/EXT Protokoll.\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."
msgid "Use section filtering"
msgstr "Benutze Abschnittsfilter"
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 ""
"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"
msgstr "Deaktivierte Filter"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Bestimme die Anzahl der Abschnittsfilter die deaktiviert werden sollen.\n"
"\n"
"Bestimmte Abschnittsfilter können unerwünschtes Verhalten mit VDR, z.B. falsche Zeit-Synchronisation, verursachen. Durch das Ausblenden einzelner Filter können nützliche Daten dieser Abschnitte für den VDR erhalten werden."
msgid "Filter"
msgstr "Filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Bestimme einen fehlerhaften Filter der ausgeblendet werden soll."
msgid "Help"
msgstr "Hilfe"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "DATEI"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Suche Abschnitt IDs"
msgid "Scan pids"
msgstr "Suche PIDs"
msgid "Protocol"
msgstr "Protokoll"
msgid "Address"
msgstr "Adresse"
msgid "Parameter"
msgstr "Parameter"

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,19 +1,18 @@
# 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.
# Copyright (C) 2007 Klaus Schmidinger <kls@cadsoft.de>
# This file is distributed under the same license as the VDR package.
# Rolf Ahrenberg
#
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"
"Project-Id-Version: VDR 1.5.7\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2007-10-20 19:43+0300\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n"
"Language-Team: <vdr@linuxtv.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "PAT (0x00)"
@ -25,8 +24,14 @@ msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "EIT (0x4E/0x4F)"
msgstr "EIT (0x4E/0x4F)"
msgid "EIT (0x5X)"
msgstr "EIT (0x5X)"
msgid "EIT (0x6X)"
msgstr "EIT (0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
@ -34,6 +39,51 @@ msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma"
msgid "UDP"
msgstr "UDP"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Protocol"
msgstr "Protokolla"
msgid "Delay (ms)"
msgstr "Viive (ms)"
msgid "Script"
msgstr "Skripti"
msgid "Parameter"
msgstr "Parametri"
msgid "Address"
msgstr "Osoite"
msgid "Port"
msgstr "Portti"
msgid "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "Lähete-ID"
msgid "Rid"
msgstr "Radio-ID"
msgid "Cannot find unique channel settings!"
msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!"
msgid "IPTV Channels"
msgstr "IPTV-kanavat"
msgid "IPTV Information"
msgstr "IPTV-tiedot"
@ -52,82 +102,24 @@ msgstr "Bitit/tavut"
msgid "IPTV information not available!"
msgstr "IPTV-tietoja ei saatavilla!"
msgid "Protocol base port"
msgstr "Protokollan perusportti"
msgid "TS buffer size [MB]"
msgstr "TS-puskurin koko [MB]"
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 ""
"Määrittele protokollan käyttämä perusportti.\n"
"\n"
"Porttiavaruuden koko määräytyy käytettyjen IPTV-laitteiden mukaan. Laajennos lukee CURL/EXT-protokollan yhteydessä perusportista dataa, jota ulkoiset ohjelmistot tarjoavat."
msgid "TS buffer prefill ratio [%]"
msgstr "TS-puskurin esitäyttöaste [%]"
msgid "EXT protocol base port"
msgstr "EXT-protokollan perusportti"
msgid "Use section filtering"
msgstr "Käytä sektioiden suodatusta"
msgstr "Käytä sektioiden suodatusta"
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 ""
"Määrittele suodatuksen käyttö sektioille.\n"
"\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."
msgid "Scan Sid automatically"
msgstr "Etsi palvelu-ID automaattisesti"
msgid "Disabled filters"
msgstr "Poista suodattimia käytöstä"
msgid "Disable filters"
msgstr "Poista suodattimia käytöstä"
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 ""
"Määrittele käytöstä poistettavien suodattimien lukumäärä sektioille.\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."
msgid "Filter"
msgstr "Suodatin"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle listalle."
msgid "Help"
msgstr "Opaste"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Radio-ID"
msgid "Scan section ids"
msgstr "Etsi sektiotunnisteet"
msgid "Scan pids"
msgstr "Etsi pidit"
msgid "Protocol"
msgstr "Protokolla"
msgid "Address"
msgstr "Osoite"
msgid "Parameter"
msgstr "Parametri"
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Poista suodatin käytöstä"

View File

@ -1,135 +0,0 @@
# French translations for iptv package.
# Copyright (C) 2007-2018 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Bruno ROUSSEL <bruno.roussel@free.fr>, 2007.
# NIVAL Michaël <mnival@club-internet.fr>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-iptv 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: NIVAL Michaël <mnival@club-internet.fr>\n"
"Language-Team: French <vdr@linuxtv.org>\n"
"Language: fr\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 "L'expérience IPTV"
msgid "IPTV Information"
msgstr "Information sur IPTV"
msgid "General"
msgstr "Général"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtres"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Information sur IPTV non disponible !"
msgid "Protocol base port"
msgstr "Port de base du protocole"
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 ""
"Définit le port de base utilisé par le protocole CURL/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 CURL/EXT."
msgid "Use section filtering"
msgstr "Utiliser le filtrage de section"
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 ""
"Définit si la section de filtrage doit être utilisé.\n"
"\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."
msgid "Disabled filters"
msgstr "Désactiver les 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 ""
"Définit le numéro de section de filtrage qui sont désactivé.\n"
"\n"
"Certains filtrage de section peux engendrer des comportement indésirables. Blacklist les filtres qui seront laissé intact pour VDR."
msgid "Filter"
msgstr "Filtre"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Définit les mauvais comportement qui doivent être désactivé."
msgid "Help"
msgstr "Aide"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FICHIER"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scanne les section ID"
msgid "Scan pids"
msgstr "Scanne les PID"
msgid "Protocol"
msgstr "Protocole"
msgid "Address"
msgstr "Adresse"
msgid "Parameter"
msgstr "Paramètre"

View File

@ -1,134 +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.
# Diego Pierotto <vdr-italian@tiscali.it>, 2008.
#
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: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: Italian <vdr@linuxtv.org>\n"
"Language: it\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 "Scopri la IPTV"
msgid "IPTV Information"
msgstr "Informazione IPTV"
msgid "General"
msgstr "Generale"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtri"
msgid "Bits/bytes"
msgstr "Bits/bytes"
msgid "IPTV information not available!"
msgstr "Informazione IPTV non disponibile!"
msgid "Protocol base port"
msgstr "Porta base protocollo"
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 ""
"Definisci una porta base usata dal protocollo CURL/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 CURL/EXT."
msgid "Use section filtering"
msgstr "Utilizza sezione filtri"
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 ""
"Definisci se la sezione filtri sarà utilizzata.\n"
"\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."
msgid "Disabled filters"
msgstr "Disabilita filtri"
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 ""
"Definisci il numero di sezione filtri che sarà disabilitato.\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."
msgid "Filter"
msgstr "Filtro"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
msgid "Help"
msgstr "Aiuto"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "FILE"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scansione Section Ids"
msgid "Scan pids"
msgstr "Scansione Pids"
msgid "Protocol"
msgstr "Protocollo"
msgid "Address"
msgstr "Indirizzo"
msgid "Parameter"
msgstr "Parametro"

View File

@ -1,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,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.
# Carel, 2010.
#
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: Carel\n"
"Language-Team: Dutch <vdr@linuxtv.org>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "Experience the IPTV"
msgstr "TV programma's via IP"
msgid "IPTV Information"
msgstr "IPTV informatie"
msgid "General"
msgstr "Algemeen"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filter"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "IPTV informatie niet beschikbaar!"
msgid "Protocol base port"
msgstr "Protocol basispoort"
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 ""
"Bepaal de basispoort voor het CURL/EXT protocol.\n"
"\n"
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het CURL/EXT protocol wordt gebruikt."
msgid "Use section filtering"
msgstr "Benutze Abschnittsfilterung"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
"Bepaal of er sectionfilterimg moet worden gebrukt.\n"
"\n"
"Bij sectiefiltering zal de IPTV plugin VDR van extra informatie over de stream voorzien. VDR kan dan bijvoorbeeld automatisch de PIDs wijzigen of de EPG tonen.Het gebruik van deze mogelijkheid heeft geen effect op streams die geen sectiedata bevatten."
msgid "Disabled filters"
msgstr "Deactiveer filter"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Bepaal het aantal de de-activeren sectiefilters.\n"
"\n"
"Sommige sctiefilters kunnen ongewenste effecten veroorzaken. Door ze hier op te nemen blijft de data intact zodat VDR het kan blijven gebruiken."
msgid "Filter"
msgstr "Filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Blacklist een probleem veroorzakend filter "
msgid "Help"
msgstr "Help"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "BESTAND"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Scan section IDS"
msgid "Scan pids"
msgstr "Scan PIDS"
msgid "Protocol"
msgstr "Protocol"
msgid "Address"
msgstr "Adres"
msgid "Parameter"
msgstr "Parameter"

View File

@ -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,125 +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.
# Alexander Gross <Bikalexander@gmail.com>, 2008.
#
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: Alexander Gross <Bikalexander@gmail.com>\n"
"Language-Team: Russian <vdr@linuxtv.org>\n"
"Language: ru\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"
"X-Generator: KBabel 1.11.4\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 "Попробуй IPTV"
msgid "IPTV Information"
msgstr "IPTV информация"
msgid "General"
msgstr "Общее"
msgid "Pids"
msgstr "Пиды"
msgid "Filters"
msgstr "Фильтры"
msgid "Bits/bytes"
msgstr "Биты / байт"
msgid "IPTV information not available!"
msgstr "IPTV информация отсутствует!"
msgid "Protocol base port"
msgstr "Базисный порт протокола"
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 ""
msgid "Use section filtering"
msgstr "Использовать область фильтрации"
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 ""
msgid "Disabled filters"
msgstr "Деактивировать фильтры"
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 ""
msgid "Filter"
msgstr "фильтр"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Неправильно работающий фильтр, занести в черный список."
msgid "Help"
msgstr "Справка"
msgid "UDP"
msgstr "UDP"
msgid "CURL"
msgstr "CURL"
msgid "HTTP"
msgstr "HTTP"
msgid "FILE"
msgstr "ФАЙЛ"
msgid "EXT"
msgstr "EXT"
msgid "Rid"
msgstr "Rid"
msgid "Scan section ids"
msgstr "Сканировать section ids"
msgid "Scan pids"
msgstr "Сканировать пиды"
msgid "Protocol"
msgstr "Протокол"
msgid "Address"
msgstr "Адрес"
msgid "Parameter"
msgstr "Параметр"

View File

@ -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

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

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolext.h,v 1.8 2007/10/21 17:32:43 ajhseppa Exp $
*/
#ifndef __IPTV_PROTOCOLEXT_H
@ -14,10 +15,10 @@
class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf {
private:
int pidM;
cString scriptFileM;
int scriptParameterM;
int streamPortM;
int pid;
char* listenAddr;
char* scriptFile;
int scriptParameter;
private:
void TerminateScript(void);
@ -26,12 +27,11 @@ private:
public:
cIptvProtocolExt();
virtual ~cIptvProtocolExt();
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);
int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Location, const int Parameter, const int Index);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLEXT_H

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolfile.c,v 1.14 2007/10/20 23:25:14 ajhseppa Exp $
*/
#include <fcntl.h>
@ -12,77 +13,82 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile()
: fileLocationM(strdup("")),
fileDelayM(0),
fileStreamM(NULL),
isActiveM(false)
: fileDelay(0),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::cIptvProtocolFile()\n");
fileLocation = strdup("");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
error("ERROR: MALLOC() failed in ProtocolFile()");
}
cIptvProtocolFile::~cIptvProtocolFile()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::~cIptvProtocolFile()\n");
// Drop open handles
cIptvProtocolFile::Close();
Close();
// Free allocated memory
free(fileLocationM);
free(fileLocation);
free(readBuffer);
}
bool cIptvProtocolFile::OpenFile(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::OpenFile()\n");
// Check that stream address is valid
if (!isActiveM && !isempty(fileLocationM)) {
fileStreamM = fopen(fileLocationM, "rb");
ERROR_IF_RET(!fileStreamM || ferror(fileStreamM), "fopen()", return false);
if (!isActive && !isempty(fileLocation)) {
fileStream = fopen(fileLocation, "rb");
ERROR_IF_RET(!fileStream || ferror(fileStream), "fopen()", return false);
// Update active flag
isActiveM = true;
isActive = true;
}
return true;
}
void cIptvProtocolFile::CloseFile(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::CloseFile()\n");
// Check that file stream is valid
if (isActiveM && !isempty(fileLocationM)) {
fclose(fileStreamM);
if (isActive && !isempty(fileLocation)) {
fclose(fileStream);
// Update active flag
isActiveM = false;
isActive = false;
}
}
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
int cIptvProtocolFile::Read(unsigned char* *BufferAddr)
{
debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
//debug("cIptvProtocolFile::Read()\n");
*BufferAddr = readBuffer;
// Check errors
if (!fileStreamM || ferror(fileStreamM)) {
debug1("%s (, %d) Stream error", __PRETTY_FUNCTION__, bufferLenP);
if (ferror(fileStream)) {
debug("Read error\n");
return -1;
}
// Rewind if EOF
if (feof(fileStreamM))
rewind(fileStreamM);
if (feof(fileStream))
rewind(fileStream);
// Sleep before reading the file stream to prevent aggressive busy looping
// and prevent transfer ringbuffer overflows
if (fileDelayM)
cCondWait::SleepMs(fileDelayM);
if (fileDelay)
cCondWait::SleepMs(fileDelay);
// 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
// still active before accessing the buffers
if (isActiveM)
return (int)fread(bufferAddrP, sizeof(unsigned char), bufferLenP, fileStreamM);
if (isActive)
return fread(readBuffer, sizeof(unsigned char), readBufferLen, fileStream);
return -1;
}
bool cIptvProtocolFile::Open(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::Open()\n");
// Open the file stream
OpenFile();
return true;
@ -90,35 +96,29 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolFile::Close()\n");
// Close the file stream
CloseFile();
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);
if (!isempty(locationP)) {
debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Close the file stream
CloseFile();
// Update stream address and port
fileLocationM = strcpyrealloc(fileLocationM, locationP);
fileDelayM = parameterP;
fileLocation = strcpyrealloc(fileLocation, Location);
fileDelay = Parameter;
// Open the file for input
OpenFile();
}
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)
{
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
//debug("cIptvProtocolFile::GetInformation()");
return cString::sprintf("file://%s:%d", fileLocation, fileDelay);
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolfile.h,v 1.7 2007/10/19 22:18:55 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLFILE_H
@ -13,10 +14,12 @@
class cIptvProtocolFile : public cIptvProtocolIf {
private:
char* fileLocationM;
int fileDelayM;
FILE* fileStreamM;
bool isActiveM;
char* fileLocation;
int fileDelay;
FILE* fileStream;
unsigned char* readBuffer;
unsigned int readBufferLen;
bool isActive;
private:
bool OpenFile(void);
@ -25,12 +28,11 @@ private:
public:
cIptvProtocolFile();
virtual ~cIptvProtocolFile();
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);
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Location, const int Parameter, const int Index);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLFILE_H

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolhttp.c,v 1.21 2007/10/21 19:46:03 rahrenbe Exp $
*/
#include <sys/types.h>
@ -16,90 +17,140 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp()
: streamAddrM(strdup("")),
streamPathM(strdup("/")),
streamPortM(0)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
streamAddr = strdup("");
streamPath = strdup("/");
}
cIptvProtocolHttp::~cIptvProtocolHttp()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::~cIptvProtocolHttp()\n");
// Close the socket
cIptvProtocolHttp::Close();
Close();
// Free allocated memory
free(streamPathM);
free(streamAddrM);
free(streamPath);
free(streamAddr);
}
bool cIptvProtocolHttp::Connect(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::Connect()\n");
// Check that stream address is valid
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) {
// Ensure that socket is valid and connect
OpenSocket(streamPortM, streamAddrM);
if (!ConnectSocket()) {
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
// Ensure that socket is valid
OpenSocket(socketPort);
// First try only the IP address
sockAddr.sin_addr.s_addr = inet_addr(streamAddr);
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
debug("Cannot convert %s directly to internet address\n", streamAddr);
// It may be a host name, get the name
struct hostent *host;
host = gethostbyname(streamAddr);
if (!host) {
error("%s is not valid address\n", streamAddr);
char tmp[64];
error("ERROR: %s", strerror_r(h_errno, tmp, sizeof(tmp)));
return false;
}
sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list);
}
int err = connect(socketDesc, (struct sockaddr*)&sockAddr,
sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected
ERROR_IF_FUNC(err < 0 && errno != EINPROGRESS, "connect()", CloseSocket(), return false);
// Select with 800ms timeout on the socket completion, check if it is writable
int retval = select_single_desc(socketDesc, 800000, true);
if (retval < 0)
return retval;
// Select has returned. Get socket errors if there are any
int socketStatus = 0;
socklen_t len = sizeof(socketStatus);
getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &socketStatus, &len);
// If not any errors, then socket must be ready and connected
if (socketStatus != 0) {
error("Cannot connect to %s\n", streamAddr);
char tmp[64];
error("ERROR: %s", strerror_r(socketStatus, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Formulate and send HTTP request
cString buffer = cString::sprintf("GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: vdr-%s/%s\r\n"
"Range: bytes=0-\r\n"
"Connection: Close\r\n"
"\r\n", streamPathM, streamAddrM,
PLUGIN_NAME_I18N, VERSION);
unsigned int len = strlen(*buffer);
debug1("%s Requesting %d: %s", __PRETTY_FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) {
CloseSocket();
return false;
}
char buffer[256];
memset(buffer, '\0', sizeof(buffer));
snprintf(buffer, sizeof(buffer),
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: vdr-iptv\r\n"
"Range: bytes=0-\r\n"
"Connection: Close\r\n"
"\r\n", streamPath, streamAddr);
//debug("Sending http request: %s\n", buffer);
err = send(socketDesc, buffer, strlen(buffer), 0);
ERROR_IF_FUNC(err < 0, "send()", CloseSocket(), return false);
// Now process headers
if (!ProcessHeaders()) {
CloseSocket();
return false;
}
// Update active flag
isActiveM = true;
isActive = true;
}
return true;
}
bool cIptvProtocolHttp::Disconnect(void)
{
debug1("%s", __PRETTY_FUNCTION__);
if (isActiveM) {
// Close the socket
CloseSocket();
// Update active flag
isActiveM = false;
debug("cIptvProtocolHttp::Disconnect()\n");
// Check that stream address is valid
if (isActive) {
// Close the socket
CloseSocket();
// Update active flag
isActive = false;
}
return true;
}
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
unsigned int &recvLenP)
bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
unsigned int &recvLen)
{
debug1("%s (, %u, )", __PRETTY_FUNCTION__, destLenP);
debug("cIptvProtocolHttp::GetHeaderLine()\n");
bool linefeed = false;
bool newline = false;
char *bufptr = destP;
recvLenP = 0;
if (!destP)
return false;
char buf[256];
char *bufptr = buf;
memset(buf, '\0', sizeof(buf));
recvLen = 0;
while (!newline || !linefeed) {
socklen_t addrlen = sizeof(sockAddr);
// Wait 500ms for data
if (ReadChar(bufptr, 500)) {
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return false;
// Check if data available
else if (retval) {
int retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
if (retval <= 0)
return false;
// Parsing end conditions, if line ends with \r\n
if (linefeed && *bufptr == '\n')
newline = true;
@ -109,49 +160,44 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
// Saw just data or \r without \n
else {
linefeed = false;
++recvLenP;
++recvLen;
}
++bufptr;
// Check that buffer won't be exceeded
if (recvLenP >= destLenP) {
error("Header wouldn't fit into buffer");
recvLenP = 0;
// Check that buffers won't be exceeded
if (recvLen >= sizeof(buf) || recvLen >= destLen) {
error("Header wouldn't fit into buffer\n");
return false;
}
}
else {
error("No HTTP response received in 500ms");
error("No HTTP response received\n");
return false;
}
}
memcpy(dest, buf, recvLen);
return true;
}
bool cIptvProtocolHttp::ProcessHeaders(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::ProcessHeaders()\n");
unsigned int lineLength = 0;
int version = 0, response = 0;
int response = 0;
bool responseFound = false;
char fmt[32];
char buf[4096];
// Generate HTTP response format string with 2 arguments
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
char buf[256];
while (!responseFound || lineLength != 0) {
memset(buf, 0, sizeof(buf));
memset(buf, '\0', sizeof(buf));
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
return false;
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
error("Expected HTTP header not found");
if (!responseFound && sscanf(buf, "HTTP/1.%*i %i ",&response) != 1) {
error("Expected HTTP header not found\n");
continue;
}
else
responseFound = true;
// Allow only 'OK' and 'Partial Content'
if ((response != 200) && (response != 206)) {
error("Invalid HTTP response (%d): %s", response, buf);
if (response != 200) {
error("ERROR: %s\n", buf);
return false;
}
}
@ -160,54 +206,49 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
bool cIptvProtocolHttp::Open(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::Open()\n");
// Connect the socket
return Connect();
}
bool cIptvProtocolHttp::Close(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolHttp::Close()\n");
// Disconnect the current stream
Disconnect();
return true;
}
int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
int cIptvProtocolHttp::Read(unsigned char* *BufferAddr)
{
return cIptvTcpSocket::Read(bufferAddrP, bufferLenP);
return cIptvTcpSocket::Read(BufferAddr);
}
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);
if (!isempty(locationP)) {
// Disconnect the current socket
Disconnect();
// Update stream address, path and port
streamAddrM = strcpyrealloc(streamAddrM, locationP);
char *path = strstr(streamAddrM, "/");
if (path) {
streamPathM = strcpyrealloc(streamPathM, path);
*path = 0;
}
else
streamPathM = strcpyrealloc(streamPathM, "/");
streamPortM = parameterP;
// Re-connect the socket
Connect();
}
return true;
}
bool cIptvProtocolHttp::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Disconnect the current socket
Disconnect();
// Update stream address, path and port
streamAddr = strcpyrealloc(streamAddr, Location);
char *path = strstr(streamAddr, "/");
if (path) {
streamPath = strcpyrealloc(streamPath, path);
*path = 0;
}
else
streamPath = strcpyrealloc(streamPath, "/");
socketPort = Parameter;
debug("http://%s:%d%s\n", streamAddr, socketPort, streamPath);
// Re-connect the socket
Connect();
}
return true;
}
cString cIptvProtocolHttp::GetInformation(void)
{
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
//debug("cIptvProtocolHttp::GetInformation()");
return cString::sprintf("http://%s:%d%s", streamAddr, socketPort, streamPath);
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolhttp.h,v 1.11 2007/10/21 17:32:43 ajhseppa Exp $
*/
#ifndef __IPTV_PROTOCOLHTTP_H
@ -14,25 +15,24 @@
class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
private:
char* streamAddrM;
char* streamPathM;
int streamPortM;
char* streamAddr;
char* streamPath;
private:
bool Connect(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);
public:
cIptvProtocolHttp();
virtual ~cIptvProtocolHttp();
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);
int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Location, const int Parameter, const int Index);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLHTTP_H

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolif.h,v 1.7 2007/10/19 22:18:55 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLIF_H
@ -12,16 +13,15 @@ class cIptvProtocolIf {
public:
cIptvProtocolIf() {}
virtual ~cIptvProtocolIf() {}
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP) = 0;
virtual bool SetSource(const char* locationP, const int parameterP, const int indexP) = 0;
virtual bool SetPid(int pidP, int typeP, bool onP) = 0;
virtual int Read(unsigned char* *BufferAddr) = 0;
virtual bool Set(const char* Location, const int Parameter, const int Index) = 0;
virtual bool Open(void) = 0;
virtual bool Close(void) = 0;
virtual cString GetInformation(void) = 0;
private:
cIptvProtocolIf(const cIptvProtocolIf&);
cIptvProtocolIf& operator=(const cIptvProtocolIf&);
cIptvProtocolIf(const cIptvProtocolIf&);
cIptvProtocolIf& operator=(const cIptvProtocolIf&);
};
#endif // __IPTV_PROTOCOLIF_H

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocoludp.c,v 1.21 2007/10/21 19:32:15 ajhseppa Exp $
*/
#include <sys/types.h>
@ -15,105 +16,104 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "socket.h"
#include "protocoludp.h"
#include "socket.h"
cIptvProtocolUdp::cIptvProtocolUdp()
: isIGMPv3M(false),
sourceAddrM(strdup("")),
streamAddrM(strdup("")),
streamPortM(0)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
streamAddr = strdup("");
}
cIptvProtocolUdp::~cIptvProtocolUdp()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvProtocolUdp::~cIptvProtocolUdp()\n");
// Drop the multicast group and close the socket
cIptvProtocolUdp::Close();
Close();
// Free allocated memory
free(streamAddrM);
free(sourceAddrM);
free(streamAddr);
}
bool cIptvProtocolUdp::JoinMulticast(void)
{
debug("cIptvProtocolUdp::JoinMulticast()\n");
// Check that stream address is valid
if (!isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(socketPort);
// Join a new multicast group
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
int err = setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq));
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = true;
}
return true;
}
bool cIptvProtocolUdp::DropMulticast(void)
{
debug("cIptvProtocolUdp::DropMulticast()\n");
// Check that stream address is valid
if (isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(socketPort);
// Drop the multicast group
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
int err = setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq,
sizeof(mreq));
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = false;
}
return true;
}
bool cIptvProtocolUdp::Open(void)
{
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
if (!isempty(streamAddrM)) {
// Join a new multicast group
JoinMulticast();
}
debug("cIptvProtocolUdp::Open()\n");
// Join a new multicast group
JoinMulticast();
return true;
}
bool cIptvProtocolUdp::Close(void)
{
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
if (!isempty(streamAddrM)) {
// Drop the multicast group
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
DropMulticast();
}
debug("cIptvProtocolUdp::Close()\n");
// Drop the multicast group
DropMulticast();
// Close the socket
CloseSocket();
// Do NOT reset stream and source addresses
//sourceAddrM = strcpyrealloc(sourceAddrM, "");
//streamAddrM = strcpyrealloc(streamAddrM, "");
//streamPortM = 0;
return true;
}
int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
{
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
return cIptvUdpSocket::Read(BufferAddr);
}
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);
if (!isempty(locationP)) {
// Drop the multicast group
if (!isempty(streamAddrM)) {
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
DropMulticast();
}
// Update stream address and port
streamAddrM = strcpyrealloc(streamAddrM, locationP);
// <group address> or <source address>@<group address>
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
if (!isempty(streamAddrM)) {
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
JoinMulticast();
}
}
return true;
}
bool cIptvProtocolUdp::SetPid(int pidP, int typeP, bool onP)
{
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Drop the multicast group
DropMulticast();
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Location);
socketPort = Parameter;
// Join a new multicast group
JoinMulticast();
}
return true;
}
cString cIptvProtocolUdp::GetInformation(void)
{
debug16("%s", __PRETTY_FUNCTION__);
if (isIGMPv3M)
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);
//debug("cIptvProtocolUdp::GetInformation()");
return cString::sprintf("udp://%s:%d", streamAddr, socketPort);
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocoludp.h,v 1.12 2007/10/21 17:32:43 ajhseppa Exp $
*/
#ifndef __IPTV_PROTOCOLUDP_H
@ -14,20 +15,20 @@
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
private:
bool isIGMPv3M;
char* sourceAddrM;
char* streamAddrM;
int streamPortM;
char* streamAddr;
private:
bool JoinMulticast(void);
bool DropMulticast(void);
public:
cIptvProtocolUdp();
virtual ~cIptvProtocolUdp();
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);
int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Location, const int Parameter, const int Index);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLUDP_H

View File

@ -3,425 +3,301 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.c,v 1.15 2007/10/20 23:25:14 ajhseppa Exp $
*/
#include "config.h"
#include "log.h"
#include "sectionfilter.h"
#include "statistics.h"
cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP)
: pusiSeenM(0),
feedCcM(0),
doneqM(0),
secBufM(NULL),
secBufpM(0),
secLenM(0),
tsFeedpM(0),
pidM(pidP),
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)),
deviceIndexM(deviceIndexP)
#define IPTV_FILTER_FILENAME "/tmp/vdr-iptv%d.filter%d"
cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
u_short Pid, u_char Tid, u_char Mask)
: pusi_seen(0),
feedcc(0),
doneq(0),
secbuf(NULL),
secbufp(0),
seclen(0),
tsfeedp(0),
pid(Pid),
id(Index)
{
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int i;
//debug("cIptvSectionFilter::cIptvSectionFilter(%d)\n", Index);
memset(secbuf_base, '\0', sizeof(secbuf_base));
memset(filter_value, '\0', sizeof(filter_value));
memset(filter_mask, '\0', sizeof(filter_mask));
memset(filter_mode, '\0', sizeof(filter_mode));
memset(maskandmode, '\0', sizeof(maskandmode));
memset(maskandnotmode, '\0', sizeof(maskandnotmode));
memset(pipeName, '\0', sizeof(pipeName));
memset(secBufBaseM, 0, sizeof(secBufBaseM));
memset(filterValueM, 0, sizeof(filterValueM));
memset(filterMaskM, 0, sizeof(filterMaskM));
memset(filterModeM, 0, sizeof(filterModeM));
memset(maskAndModeM, 0, sizeof(maskAndModeM));
memset(maskAndNotModeM, 0, sizeof(maskAndNotModeM));
SetPipeName(devInd);
filterValueM[0] = tidP;
filterMaskM[0] = maskP;
filter_value[0] = Tid;
filter_mask[0] = Mask;
// Invert the filter
for (i = 0; i < eDmxMaxFilterSize; ++i)
filterValueM[i] ^= 0xFF;
for (int i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
filter_value[i] ^= 0xff;
}
uint8_t mask, mode, doneq = 0;
for (i = 0; i < eDmxMaxFilterSize; ++i) {
mode = filterModeM[i];
mask = filterMaskM[i];
maskAndModeM[i] = (uint8_t)(mask & mode);
maskAndNotModeM[i] = (uint8_t)(mask & ~mode);
doneq |= maskAndNotModeM[i];
}
doneqM = doneq ? 1 : 0;
uint8_t mask, mode, local_doneq = 0;
for (int i = 0; i < DMX_MAX_FILTER_SIZE; i++) {
mode = filter_mode[i];
mask = filter_mask[i];
maskandmode[i] = mask & mode;
local_doneq |= maskandnotmode[i] = mask & ~mode;
}
doneq = local_doneq ? 1 : 0;
// Create sockets
socketM[0] = socketM[1] = -1;
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketM) != 0) {
char tmp[64];
error("Opening section filter sockets failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp)));
}
else if ((fcntl(socketM[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socketM[1], F_SETFL, O_NONBLOCK) != 0)) {
char tmp[64];
error("Setting section filter socket to non-blocking mode failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp)));
}
struct stat sb;
stat(pipeName, &sb);
if (S_ISFIFO(sb.st_mode))
unlink(pipeName);
int err = mknod(pipeName, 0644 | S_IFIFO, 0);
ERROR_IF_RET(err < 0, "mknod()", return);
// Create descriptors
fifoDescriptor = open(pipeName, O_RDWR | O_NONBLOCK);
readDescriptor = open(pipeName, O_RDONLY | O_NONBLOCK);
}
cIptvSectionFilter::~cIptvSectionFilter()
{
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int tmp = socketM[1];
socketM[1] = -1;
if (tmp >= 0)
close(tmp);
tmp = socketM[0];
socketM[0] = -1;
if (tmp >= 0)
close(tmp);
secBufM = NULL;
DELETENULL(ringBufferM);
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d)\n", id);
close(fifoDescriptor);
close(readDescriptor);
unlink(pipeName);
memset(pipeName, '\0', sizeof(pipeName));
fifoDescriptor = -1;
readDescriptor = -1;
}
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *dataP)
void cIptvSectionFilter::SetPipeName(int deviceIndex)
{
return (uint16_t)(3 + ((dataP[1] & 0x0f) << 8) + dataP[2]);
snprintf(pipeName, sizeof(pipeName), IPTV_FILTER_FILENAME, deviceIndex, id);
}
void cIptvSectionFilter::New(void)
int cIptvSectionFilter::GetReadDesc()
{
tsFeedpM = secBufpM = secLenM = 0;
secBufM = secBufBaseM;
return readDescriptor;
}
int cIptvSectionFilter::Filter(void)
inline uint16_t cIptvSectionFilter::section_length(const uint8_t *buf)
{
if (secBufM) {
int i;
uint8_t neq = 0;
return 3 + ((buf[1] & 0x0f) << 8) + buf[2];
}
for (i = 0; i < eDmxMaxFilterSize; ++i) {
uint8_t calcxor = (uint8_t)(filterValueM[i] ^ secBufM[i]);
if (maskAndModeM[i] & calcxor)
return 0;
neq |= (maskAndNotModeM[i] & calcxor);
}
if (doneqM && !neq)
return 0;
if (ringBufferM && (secLenM > 0))
ringBufferM->Put(new cFrame(secBufM, secLenM));
int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t buffer1_len,
const uint8_t *buffer2, size_t buffer2_len,
enum dmx_success success)
{
// See if there is data in the fifo
int retval = select_single_desc(fifoDescriptor, 0, false);
// There is no data in the fifo, more can be written
if (!retval) {
#ifdef DEBUG_PRINTF
printf("id = %d, pid %d would now write %d data to buffer\n", id, pid, buffer1_len);
for (unsigned int i = 0; i < buffer1_len; ++i)
printf("0x%X ", buffer1[i]);
printf("\n");
#endif
retval = write(fifoDescriptor, buffer1, buffer1_len);
ERROR_IF(retval < 0, "write()");
// Update statistics
AddStatistic(retval, 1);
}
#ifdef DEBUG_PRINTF
else if (retval)
printf("id %d pid %d data is already present\n", id, pid);
#endif
return 0;
}
inline int cIptvSectionFilter::Feed(void)
void cIptvSectionFilter::demux_swfilter_section_new()
{
if (Filter() < 0)
return -1;
secLenM = 0;
return 0;
#ifdef DEMUX_SECTION_LOSS_LOG
if (secbufp < tsfeedp) {
int i, n = tsfeedp - secbufp;
/*
* Section padding is done with 0xff bytes entirely.
* Due to speed reasons, we won't check all of them
* but just first and last.
*/
if (secbuf[0] != 0xff || secbuf[n - 1] != 0xff) {
printf("sectionfilter.c section ts padding loss: %d/%d\n",
n, tsfeedp);
printf("sectionfilter.c pad data:");
for (i = 0; i < n; i++)
printf(" %02x", secbuf[i]);
printf("\n");
}
}
#endif
tsfeedp = secbufp = seclen = 0;
secbuf = secbuf_base;
}
int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
int cIptvSectionFilter::demux_swfilter_sectionfilter()
{
uint16_t limit, seclen, n;
uint8_t neq = 0;
int i;
if (tsFeedpM >= eDmxMaxSectionFeedSize)
return 0;
if (tsFeedpM + lenP > eDmxMaxSectionFeedSize)
lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM);
if (lenP <= 0)
return 0;
memcpy(secBufBaseM + tsFeedpM, bufP, lenP);
tsFeedpM = uint16_t(tsFeedpM + lenP);
limit = tsFeedpM;
if (limit > eDmxMaxSectionFeedSize)
return -1; // internal error should never happen
// Always set secbuf
secBufM = secBufBaseM + secBufpM;
for (n = 0; secBufpM + 2 < limit; ++n) {
seclen = GetLength(secBufM);
if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit))
for (i = 0; i < DMX_MAX_FILTER_SIZE; i++) {
uint8_t local_xor = filter_value[i] ^ secbuf[i];
if (maskandmode[i] & local_xor) {
#ifdef DEBUG_PRINTF
printf("maskandmode discard\n");
#endif
return 0;
secLenM = seclen;
if (pusiSeenM)
Feed();
secBufpM = uint16_t(secBufpM + seclen);
secBufM += seclen;
}
neq |= maskandnotmode[i] & local_xor;
}
if (doneq && !neq) {
#ifdef DEBUG_PRINTF
printf("doneq discard, doneq = 0x%X, neq = 0x%X\n", doneq, !neq);
#endif
return 0;
}
return dmxdev_section_callback(secbuf, seclen, NULL, 0, DMX_OK);
}
inline int cIptvSectionFilter::demux_swfilter_section_feed()
{
if (demux_swfilter_sectionfilter() < 0)
return -1;
seclen = 0;
return 0;
}
int cIptvSectionFilter::demux_swfilter_section_copy_dump(const uint8_t *buf, uint8_t len)
{
uint16_t limit, seclen_local, n;
if (tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0;
if (tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
#ifdef DEMUX_SECTION_LOSS_LOG
printf("sectionfilter.c section buffer full loss: %d/%d\n",
tsfeedp + len - DMX_MAX_SECFEED_SIZE,
DMX_MAX_SECFEED_SIZE);
#endif
len = DMX_MAX_SECFEED_SIZE - tsfeedp;
}
if (len <= 0)
return 0;
memcpy(secbuf_base + tsfeedp, buf, len);
tsfeedp += len;
/*
* Dump all the sections we can find in the data (Emard)
*/
limit = tsfeedp;
if (limit > DMX_MAX_SECFEED_SIZE)
return -1; /* internal error should never happen */
/* to be sure always set secbuf */
secbuf = secbuf_base + secbufp;
for (n = 0; secbufp + 2 < limit; n++) {
seclen_local = section_length(secbuf);
if (seclen_local <= 0 || seclen_local > DMX_MAX_SECTION_SIZE ||
seclen_local + secbufp > limit)
return 0;
#ifdef DEBUG_PRINTF
printf("Non-mismatching seclen! %d, limit = %d\n", seclen_local, limit);
#endif
seclen = seclen_local;
/* dump [secbuf .. secbuf+seclen) */
if (pusi_seen)
demux_swfilter_section_feed();
#ifdef DEMUX_SECTION_LOSS_LOG
else
printf("sectionfilter.c pusi not seen, discarding section data\n");
#endif
secbufp += seclen_local; /* secbufp and secbuf moving together is */
secbuf += seclen_local; /* redundant but saves pointer arithmetic */
}
return 0;
}
void cIptvSectionFilter::Process(const uint8_t* dataP)
void cIptvSectionFilter::ProcessData(const uint8_t* buf)
{
if (dataP[0] != TS_SYNC_BYTE)
if (buf[0] != 0x47) {
error("Not TS packet: 0x%X\n", buf[0]);
return;
}
// Stop if not the PID this filter is looking for
if (ts_pid(dataP) != pidM)
if (ts_pid(buf) != pid)
return;
uint8_t count = payload(dataP);
uint8_t count = payload(buf);
// Check if no payload or out of range
if (count == 0)
if (count == 0) /* count == 0 if no payload or out of range */
return;
// Payload start
uint8_t p = (uint8_t)(TS_SIZE - count);
uint8_t p = 188 - count; /* payload start */
uint8_t cc = (uint8_t)(dataP[3] & 0x0f);
int ccok = ((feedCcM + 1) & 0x0f) == cc;
feedCcM = cc;
uint8_t cc = buf[3] & 0x0f;
int ccok = ((feedcc + 1) & 0x0f) == cc;
feedcc = cc;
int dc_i = 0;
if (dataP[3] & 0x20) {
// Adaption field present, check for discontinuity_indicator
if ((dataP[4] > 0) && (dataP[5] & 0x80))
if (buf[3] & 0x20) {
/* adaption field present, check for discontinuity_indicator */
if ((buf[4] > 0) && (buf[5] & 0x80))
dc_i = 1;
}
if (!ccok || dc_i) {
// Discontinuity detected. Reset pusiSeenM = 0 to
// stop feeding of suspicious data until next PUSI=1 arrives
pusiSeenM = 0;
New();
#ifdef DEMUX_SECTION_LOSS_LOG
printf("sectionfilter.c discontinuity detected %d bytes lost\n",
count);
/*
* those bytes under sume circumstances will again be reported
* in the following demux_swfilter_section_new
*/
#endif
/*
* Discontinuity detected. Reset pusi_seen = 0 to
* stop feeding of suspicious data until next PUSI=1 arrives
*/
pusi_seen = 0;
demux_swfilter_section_new();
}
if (dataP[1] & 0x40) {
// PUSI=1 (is set), section boundary is here
if (count > 1 && dataP[p] < count) {
const uint8_t *before = &dataP[p + 1];
uint8_t before_len = dataP[p];
if (buf[1] & 0x40) {
/* PUSI=1 (is set), section boundary is here */
if (count > 1 && buf[p] < count) {
#ifdef DEBUG_PRINTF
printf("Valid section\n");
#endif
const uint8_t *before = &buf[p + 1];
uint8_t before_len = buf[p];
const uint8_t *after = &before[before_len];
uint8_t after_len = (uint8_t)(count - 1 - before_len);
CopyDump(before, before_len);
uint8_t after_len = count - 1 - before_len;
// Before start of new section, set pusiSeenM = 1
pusiSeenM = 1;
New();
CopyDump(after, after_len);
demux_swfilter_section_copy_dump(before, before_len);
/* before start of new section, set pusi_seen = 1 */
pusi_seen = 1;
demux_swfilter_section_new();
demux_swfilter_section_copy_dump(after, after_len);
}
#ifdef DEMUX_SECTION_LOSS_LOG
else if (count > 0)
printf("sectionfilter.c PUSI=1 but %d bytes lost\n", count);
#endif
}
else {
// PUSI=0 (is not set), no section boundary
CopyDump(&dataP[p], count);
}
}
bool cIptvSectionFilter::Send(void)
{
bool result = false;
cFrame *section = ringBufferM->Get();
if (section) {
uchar *data = section->Data();
int count = section->Count();
if (data && (count > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) {
ssize_t len = send(socketM[1], data, count, MSG_EOR);
ERROR_IF(len < 0 && errno != EAGAIN, "send()");
if (len > 0) {
ringBufferM->Drop(section);
result = !!ringBufferM->Available();
// Update statistics
AddSectionStatistic(len, 1);
}
}
}
return result;
}
cIptvSectionFilterHandler::cIptvSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP)
: cThread("IPTV section handler"),
ringBufferM(new cRingBufferLinear(bufferLenP, TS_SIZE, false, *cString::sprintf("IPTV SECTION HANDLER %d", deviceIndexP))),
mutexM(),
deviceIndexM(deviceIndexP)
{
debug1("%s (%d, %d) [device %d]", __PRETTY_FUNCTION__, deviceIndexP, bufferLenP, deviceIndexM);
// Initialize filter pointers
memset(filtersM, 0, sizeof(filtersM));
// Create input buffer
if (ringBufferM) {
ringBufferM->SetTimeouts(100, 100);
ringBufferM->SetIoThrottle();
}
else
error("Failed to allocate buffer for section filter handler (device=%d): ", deviceIndexM);
Start();
}
cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
{
debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop thread
if (Running())
Cancel(3);
DELETE_POINTER(ringBufferM);
// Destroy all filters
cMutexLock MutexLock(&mutexM);
for (int i = 0; i < eMaxSecFilterCount; ++i)
Delete(i);
}
void cIptvSectionFilterHandler::Action(void)
{
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
bool processed = false;
// Do the thread loop
while (Running()) {
// Send demuxed section packets through all filters
bool retry = false;
mutexM.Lock();
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && filtersM[i]->Send())
retry = true;
}
mutexM.Unlock();
if (retry)
continue;
// Read one TS packet
if (ringBufferM) {
int len = 0;
if (processed) {
ringBufferM->Del(TS_SIZE);
processed = false;
}
uchar *p = ringBufferM->Get(len);
if (p && (len >= TS_SIZE)) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < len; ++i) {
if (p[i] == TS_SYNC_BYTE) {
len = i;
break;
}
}
ringBufferM->Del(len);
debug1("%s Skipped %d bytes to sync on TS packet [device %d]]", __PRETTY_FUNCTION__, len, deviceIndexM);
continue;
}
// Process TS packet through all filters
mutexM.Lock();
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i])
filtersM[i]->Process(p);
}
mutexM.Unlock();
processed = true;
continue;
}
}
cCondWait::SleepMs(10); // to avoid busy loop and reduce cpu load
}
debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
}
cString cIptvSectionFilterHandler::GetInformation(void)
{
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// loop through active section filters
cMutexLock MutexLock(&mutexM);
cString s = "";
unsigned int count = 0;
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i]) {
s = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *s, i,
*filtersM[i]->GetSectionStatistic(), filtersM[i]->GetPid(),
id_pid(filtersM[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
}
}
return s;
}
bool cIptvSectionFilterHandler::Delete(unsigned int indexP)
{
debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
if ((indexP < eMaxSecFilterCount) && filtersM[indexP]) {
debug16("%s (%d) Found [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
cIptvSectionFilter *tmp = filtersM[indexP];
filtersM[indexP] = NULL;
delete tmp;
return true;
}
return false;
}
bool cIptvSectionFilterHandler::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
{
debug16("%s (%d, %02X, %02X) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
// loop through section filter table
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
int index = IptvConfig.GetDisabledFilters(i);
// Check if matches
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
(section_filter_table[index].mask == maskP)) {
debug16("%s (%d, %02X, %02X) Found %s [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, section_filter_table[index].description, deviceIndexM);
return true;
}
}
return false;
}
int cIptvSectionFilterHandler::Open(u_short pidP, u_char tidP, u_char maskP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Blacklist check, refuse certain filters
if (IsBlackListed(pidP, tidP, maskP))
return -1;
// Search the next free filter slot
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!filtersM[i]) {
filtersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
debug16("%s (%d, %02X, %02X) handle=%d index=%u [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetFd();
}
}
// No free filter slot found
return -1;
}
void cIptvSectionFilterHandler::Close(int handleP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Search the filter for deletion
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
Delete(i);
break;
}
}
}
int cIptvSectionFilterHandler::GetPid(int handleP)
{
// Lock
cMutexLock MutexLock(&mutexM);
// Search the filter for data
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetPid();
}
}
return -1;
}
void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP)
{
debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
// Fill up the buffer
if (ringBufferM) {
int len = ringBufferM->Put(bufferP, lengthP);
if (len != lengthP)
ringBufferM->ReportOverflow(lengthP - len);
/* PUSI=0 (is not set), no section boundary */
demux_swfilter_section_copy_dump(&buf[p], count);
}
}

View File

@ -3,90 +3,102 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.h,v 1.7 2007/10/08 23:51:58 rahrenbe Exp $
*/
#ifndef __IPTV_SECTIONFILTER_H
#define __IPTV_SECTIONFILTER_H
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif // __FreeBSD__
#include <vdr/device.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <libgen.h>
#include <stdint.h>
#include <sys/param.h>
#include "common.h"
#include "statistics.h"
class cIptvSectionFilter : public cIptvSectionStatistics {
private:
enum {
eDmxMaxFilterSize = 18,
eDmxMaxSectionCount = 64,
eDmxMaxSectionSize = 4096,
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
enum dmx_success {
DMX_OK = 0, /* Received Ok */
DMX_LENGTH_ERROR, /* Incorrect length */
DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */
DMX_CRC_ERROR, /* Incorrect CRC */
DMX_FRAME_ERROR, /* Frame alignment error */
DMX_FIFO_ERROR, /* Receiver FIFO overrun */
DMX_MISSED_ERROR /* Receiver missed packet */
};
int pusiSeenM;
int feedCcM;
int doneqM;
enum dmx_limits {
DMX_MAX_FILTER_SIZE = 18,
DMX_MAX_SECTION_SIZE = 4096,
DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + 188)
};
uint8_t *secBufM;
uint8_t secBufBaseM[eDmxMaxSectionFeedSize];
uint16_t secBufpM;
uint16_t secLenM;
uint16_t tsFeedpM;
uint16_t pidM;
int fifoDescriptor;
int readDescriptor;
cRingBufferFrame *ringBufferM;
int deviceIndexM;
int socketM[2];
int pusi_seen;
int feedcc;
int doneq;
uint8_t filterValueM[eDmxMaxFilterSize];
uint8_t filterMaskM[eDmxMaxFilterSize];
uint8_t filterModeM[eDmxMaxFilterSize];
uint8_t *secbuf;
uint8_t secbuf_base[DMX_MAX_SECFEED_SIZE];
uint16_t secbufp;
uint16_t seclen;
uint16_t tsfeedp;
uint16_t pid;
int id;
uint8_t maskAndModeM[eDmxMaxFilterSize];
uint8_t maskAndNotModeM[eDmxMaxFilterSize];
uint8_t filter_value[DMX_MAX_FILTER_SIZE];
uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
uint8_t filter_mode[DMX_MAX_FILTER_SIZE];
uint8_t maskandmode[DMX_MAX_FILTER_SIZE];
uint8_t maskandnotmode[DMX_MAX_FILTER_SIZE];
inline uint16_t GetLength(const uint8_t *dataP);
void New(void);
int Filter(void);
inline int Feed(void);
int CopyDump(const uint8_t *bufP, uint8_t lenP);
char pipeName[128];
inline uint16_t section_length(const uint8_t *buf);
int dmxdev_section_callback(const uint8_t *buffer1,
size_t buffer1_len,
const uint8_t *buffer2,
size_t buffer2_len,
enum dmx_success success);
void demux_swfilter_section_new();
int demux_swfilter_sectionfilter();
inline int demux_swfilter_section_feed();
int demux_swfilter_section_copy_dump(const uint8_t *buf,
uint8_t len);
int GetFifoDesc();
void ClearPipeName();
void SetPipeName(int deviceIndex);
public:
// constructor & destructor
cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
cIptvSectionFilter(int Index, int devInd, u_short Pid, u_char Tid,
u_char Mask);
virtual ~cIptvSectionFilter();
void Process(const uint8_t* dataP);
bool Send(void);
int GetFd(void) { return socketM[0]; }
uint16_t GetPid(void) const { return pidM; }
};
class cIptvSectionFilterHandler : public cThread {
private:
enum {
eMaxSecFilterCount = 32
};
cRingBufferLinear *ringBufferM;
cMutex mutexM;
int deviceIndexM;
cIptvSectionFilter *filtersM[eMaxSecFilterCount];
void ProcessData(const uint8_t* buf);
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);
int GetReadDesc();
uint16_t GetPid() { return pid; }
};
#endif // __IPTV_SECTIONFILTER_H

642
setup.c
View File

@ -3,16 +3,499 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: setup.c,v 1.41 2007/10/20 20:35:06 rahrenbe Exp $
*/
#include <string.h>
#include <vdr/device.h>
#include <vdr/interface.h>
#include <vdr/status.h>
#include <vdr/menu.h>
#include "common.h"
#include "config.h"
#include "device.h"
#include "setup.h"
#ifndef trVDR
#define trVDR(s) tr(s)
#endif
// --- cIptvMenuEditChannel --------------------------------------------------
class cIptvMenuEditChannel : public cOsdMenu
{
private:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
struct tIptvChannel {
int frequency, source, protocol, parameter, vpid, ppid, tpid, sid, nid, tid, rid;
int apid[MAXAPIDS + 1], dpid[MAXDPIDS + 1], spid[MAXSPIDS + 1], caids[MAXCAIDS + 1];
char name[256], location[256];
} data;
cChannel *channel;
const char *protocols[eProtocolCount];
void Setup(void);
cString GetIptvSettings(const char *Param, int *Parameter, int *Protocol);
void GetChannelData(cChannel *Channel);
void SetChannelData(cChannel *Channel);
public:
cIptvMenuEditChannel(cChannel *Channel, bool New = false);
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
:cOsdMenu(trVDR("Edit channel"), 16)
{
protocols[eProtocolUDP] = tr("UDP");
protocols[eProtocolHTTP] = tr("HTTP");
protocols[eProtocolFILE] = tr("FILE");
protocols[eProtocolEXT] = tr("EXT");
channel = Channel;
GetChannelData(channel);
if (New) {
channel = NULL;
data.nid = 0;
data.tid = 0;
data.rid = 0;
}
Setup();
}
cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Parameter, int *Protocol)
{
char *tag = NULL;
char *proto = NULL;
char *loc = NULL;
if (sscanf(Param, "%a[^|]|%a[^|]|%a[^|]|%u", &tag, &proto, &loc, Parameter) == 4) {
cString tagstr(tag, true);
cString protostr(proto, true);
cString locstr(loc, true);
// check if IPTV tag
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
// check if protocol is supported and update the pointer
if (strncasecmp(*protostr, "UDP", 3) == 0)
*Protocol = eProtocolUDP;
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
*Protocol = eProtocolHTTP;
else if (strncasecmp(*protostr, "FILE", 4) == 0)
*Protocol = eProtocolFILE;
else if (strncasecmp(*protostr, "EXT", 3) == 0)
*Protocol = eProtocolEXT;
else
return NULL;
// return location
return locstr;
}
}
return NULL;
}
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
{
if (Channel) {
int parameter, protocol;
data.frequency = Channel->Frequency();
data.source = Channel->Source();
data.vpid = Channel->Vpid();
data.ppid = Channel->Ppid();
data.tpid = Channel->Tpid();
for (unsigned int i = 0; i < sizeof(data.apid); ++i)
data.apid[i] = Channel->Apid(i);
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
data.dpid[i] = Channel->Dpid(i);
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
data.spid[i] = Channel->Spid(i);
for (unsigned int i = 0; i < sizeof(data.caids); ++i)
data.caids[i] = Channel->Ca(i);
data.sid = Channel->Sid();
data.nid = Channel->Nid();
data.tid = Channel->Tid();
data.rid = Channel->Rid();
strn0cpy(data.name, Channel->Name(), sizeof(data.name));
strn0cpy(data.location, *GetIptvSettings(Channel->PluginParam(), &parameter, &protocol), sizeof(data.location));
data.protocol = protocol;
data.parameter = parameter;
}
else {
data.frequency = 1;
data.source = cSource::FromData(cSource::stPlug);
data.vpid = 0;
data.ppid = 0;
data.tpid = 0;
for (unsigned int i = 0; i < sizeof(data.apid); ++i)
data.apid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
data.dpid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
data.spid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.caids); ++i)
data.caids[i] = 0;
data.sid = 1;
data.nid = 0;
data.tid = 0;
data.rid = 0;
strn0cpy(data.name, "IPTV", sizeof(data.name));
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.protocol = eProtocolUDP;
data.parameter = 1234;
}
}
void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
{
if (Channel) {
cString param;
char alangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char dlangs[MAXDPIDS][MAXLANGCODE2] = { "" };
char slangs[MAXSPIDS][MAXLANGCODE2] = { "" };
switch (data.protocol) {
case eProtocolEXT:
param = cString::sprintf("IPTV|EXT|%s|%d", data.location, data.parameter);
break;
case eProtocolFILE:
param = cString::sprintf("IPTV|FILE|%s|%d", data.location, data.parameter);
break;
case eProtocolHTTP:
param = cString::sprintf("IPTV|HTTP|%s|%d", data.location, data.parameter);
break;
default:
case eProtocolUDP:
param = cString::sprintf("IPTV|UDP|%s|%d", data.location, data.parameter);
break;
}
Channel->SetPids(data.vpid, data.ppid, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
Channel->SetCaIds(data.caids);
Channel->SetId(data.nid, data.tid, data.sid, data.rid);
Channel->SetName(data.name, "", "IPTV");
Channel->SetPlugTransponderData(cSource::stPlug, data.frequency, param);
}
}
void cIptvMenuEditChannel::Setup(void)
{
int current = Current();
Clear();
// IPTV specific settings
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol,
eProtocolCount, protocols));
switch (data.protocol) {
case eProtocolFILE:
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Delay (ms)"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolEXT:
Add(new cMenuEditStrItem(tr("Script"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Parameter"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolHTTP:
case eProtocolUDP:
default:
Add(new cMenuEditStrItem(tr("Address"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Port"), &data.parameter, 0, 0xFFFF));
break;
}
// Normal settings
Add(new cMenuEditStrItem(trVDR("Name"), data.name, sizeof(data.name), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(trVDR("Frequency"), &data.frequency));
Add(new cMenuEditIntItem(trVDR("Vpid"), &data.vpid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Ppid"), &data.ppid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid1"), &data.apid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid2"), &data.apid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid1"), &data.dpid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid2"), &data.dpid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Spid1"), &data.spid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Spid2"), &data.spid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Tpid"), &data.tpid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("CA"), &data.caids[0], 0, 0xFFFF));
Add(new cMenuEditIntItem(trVDR("Sid"), &data.sid, 1, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Nid"), &data.nid, 0, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Tid"), &data.tid, 0, 0xFFFF));
Add(new cMenuEditIntItem(tr ("Rid"), &data.rid, 0, 0x1FFF));
SetCurrent(Get(current));
Display();
}
eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
{
int oldProtocol = data.protocol;
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
if (Key == kOk) {
cChannel newchannel;
SetChannelData(&newchannel);
bool uniquityFailed = false;
bool firstIncrement = true;
// Search for identical channels as these will be ignored by vdr
for (cChannel *iteratorChannel = Channels.First(); iteratorChannel;
iteratorChannel = Channels.Next(iteratorChannel)) {
// This is one of the channels cause the uniquity check to fail
if (!iteratorChannel->GroupSep() && iteratorChannel != channel
&& iteratorChannel->GetChannelID() == newchannel.GetChannelID()) {
// See if it has unique Plugin param. If yes then increment
// the corresponding Rid until it is unique
if (strcmp(iteratorChannel->PluginParam(),
newchannel.PluginParam())) {
// If the channel RID is already at maximum, then fail the
// channel modification
if (iteratorChannel->Rid() >= 0x1FFF) {
debug("Cannot increment RID over maximum value\n");
uniquityFailed = true;
break;
}
debug("Incrementing conflicting channel RID\n");
iteratorChannel->SetId(iteratorChannel->Nid(),
iteratorChannel->Tid(),
iteratorChannel->Sid(),
firstIncrement ?
0 : iteratorChannel->Rid() + 1);
// Try zero Rid:s at first increment. Prevents them from
// creeping slowly towards their maximum value
firstIncrement = false;
// Re-set the search and start again
iteratorChannel = Channels.First();
continue;
// Cannot work around by incrementing rid because channels
// are actually copies of each other
}
else {
uniquityFailed = true;
break;
}
}
}
if (!uniquityFailed) {
if (channel) {
SetChannelData(channel);
isyslog("edited channel %d %s", channel->Number(), *channel->ToText());
state = osBack;
}
else {
channel = new cChannel;
SetChannelData(channel);
Channels.Add(channel);
Channels.ReNumber();
isyslog("added channel %d %s", channel->Number(), *channel->ToText());
state = osUser1;
}
Channels.SetModified(true);
}
else {
Skins.Message(mtError, tr("Cannot find unique channel settings!"));
state = osContinue;
}
}
}
if ((Key != kNone) && (data.protocol != oldProtocol)) {
switch (data.protocol) {
case eProtocolEXT:
strn0cpy(data.location, "iptvstream.sh", sizeof(data.location));
data.parameter = 0;
break;
case eProtocolFILE:
strn0cpy(data.location, "/video/stream.ts", sizeof(data.location));
data.parameter = 0;
break;
case eProtocolHTTP:
strn0cpy(data.location, "127.0.0.1/TS/1", sizeof(data.location));
data.parameter = 3000;
break;
default:
case eProtocolUDP:
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.parameter = 1234;
break;
}
Setup();
}
return state;
}
// --- cIptvMenuChannelItem --------------------------------------------------
class cIptvMenuChannelItem : public cOsdItem
{
private:
cChannel *channel;
public:
cIptvMenuChannelItem(cChannel *Channel);
virtual void Set(void);
cChannel *Channel(void) { return channel; }
};
cIptvMenuChannelItem::cIptvMenuChannelItem(cChannel *Channel)
{
channel = Channel;
Set();
}
void cIptvMenuChannelItem::Set(void)
{
char *buffer = NULL;
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
SetText(buffer, false);
}
// --- cIptvMenuChannels -----------------------------------------------------
class cIptvMenuChannels : public cOsdMenu
{
private:
void Setup(void);
cChannel *GetChannel(int Index);
void Propagate(void);
protected:
eOSState Edit(void);
eOSState New(void);
eOSState Delete(void);
eOSState Switch(void);
public:
cIptvMenuChannels();
~cIptvMenuChannels();
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuChannels::cIptvMenuChannels(void)
:cOsdMenu(tr("IPTV Channels"), numdigits(Channels.MaxNumber()) + 1)
{
Setup();
Channels.IncBeingEdited();
}
cIptvMenuChannels::~cIptvMenuChannels()
{
Channels.DecBeingEdited();
}
void cIptvMenuChannels::Setup(void)
{
Clear();
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() && channel->IsPlug() && !strncasecmp(channel->PluginParam(), "IPTV", 4)) {
cIptvMenuChannelItem *item = new cIptvMenuChannelItem(channel);
Add(item);
}
}
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
Display();
}
cChannel *cIptvMenuChannels::GetChannel(int Index)
{
cIptvMenuChannelItem *p = (cIptvMenuChannelItem *)Get(Index);
return p ? (cChannel *)p->Channel() : NULL;
}
void cIptvMenuChannels::Propagate(void)
{
Channels.ReNumber();
for (cIptvMenuChannelItem *ci = (cIptvMenuChannelItem *)First(); ci; ci = (cIptvMenuChannelItem *)ci->Next())
ci->Set();
Display();
Channels.SetModified(true);
}
eOSState cIptvMenuChannels::Switch(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cChannel *ch = GetChannel(Current());
if (ch)
return cDevice::PrimaryDevice()->SwitchChannel(ch, true) ? osEnd : osContinue;
return osEnd;
}
eOSState cIptvMenuChannels::Edit(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cChannel *ch = GetChannel(Current());
if (ch)
return AddSubMenu(new cIptvMenuEditChannel(ch));
return osContinue;
}
eOSState cIptvMenuChannels::New(void)
{
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuEditChannel(GetChannel(Current()), true));
}
eOSState cIptvMenuChannels::Delete(void)
{
if (!HasSubMenu() && Count() > 0) {
int CurrentChannelNr = cDevice::CurrentChannel();
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
int Index = Current();
cChannel *channel = GetChannel(Current());
int DeletedChannel = channel->Number();
// Check if there is a timer using this channel:
if (channel->HasTimer()) {
Skins.Message(mtError, trVDR("Channel is being used by a timer!"));
return osContinue;
}
if (Interface->Confirm(trVDR("Delete channel?"))) {
if (CurrentChannel && channel == CurrentChannel) {
int n = Channels.GetNextNormal(CurrentChannel->Index());
if (n < 0)
n = Channels.GetPrevNormal(CurrentChannel->Index());
CurrentChannel = Channels.Get(n);
CurrentChannelNr = 0; // triggers channel switch below
}
Channels.Del(channel);
cOsdMenu::Del(Index);
Propagate();
isyslog("channel %d deleted", DeletedChannel);
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
Channels.SwitchTo(CurrentChannel->Number());
else
cDevice::SetCurrentChannel(CurrentChannel);
}
}
}
return osContinue;
}
eOSState cIptvMenuChannels::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
switch (state) {
case osUser1: {
cChannel *channel = Channels.Last();
if (channel) {
Add(new cIptvMenuChannelItem(channel), true);
return CloseSubMenu();
}
}
break;
default:
if (state == osUnknown) {
switch (Key) {
case kOk: return Switch();
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Delete();
default: break;
}
}
}
return state;
}
// --- cIptvMenuInfo ---------------------------------------------------------
class cIptvMenuInfo : public cOsdMenu
@ -21,23 +504,21 @@ private:
enum {
INFO_TIMEOUT_MS = 2000
};
cString textM;
cTimeMs timeoutM;
unsigned int pageM;
cString text;
cTimeMs timeout;
unsigned int page;
void UpdateInfo();
public:
cIptvMenuInfo();
virtual ~cIptvMenuInfo();
virtual void Display(void);
virtual eOSState ProcessKey(eKeys keyP);
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuInfo::cIptvMenuInfo()
:cOsdMenu(tr("IPTV Information")), textM(""), timeoutM(), pageM(IPTV_DEVICE_INFO_GENERAL)
:cOsdMenu(tr("IPTV Information")), text(""), timeout(INFO_TIMEOUT_MS), page(IPTV_DEVICE_INFO_GENERAL)
{
SetMenuCategory(mcText);
timeoutM.Set(INFO_TIMEOUT_MS);
UpdateInfo();
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes"));
}
@ -50,24 +531,24 @@ void cIptvMenuInfo::UpdateInfo()
{
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
if (device)
textM = device->GetInformation(pageM);
text = device->GetInformation(page);
else
textM = cString(tr("IPTV information not available!"));
text = cString(tr("IPTV information not available!"));
Display();
timeoutM.Set(INFO_TIMEOUT_MS);
timeout.Set(INFO_TIMEOUT_MS);
}
void cIptvMenuInfo::Display(void)
{
cOsdMenu::Display();
DisplayMenu()->SetText(textM, true);
if (*textM)
cStatus::MsgOsdTextItem(textM);
DisplayMenu()->SetText(text, true);
if (text)
cStatus::MsgOsdTextItem(text);
}
eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
{
switch (int(keyP)) {
switch (Key) {
case kUp|k_Repeat:
case kUp:
case kDown|k_Repeat:
@ -76,30 +557,30 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
case kLeft:
case kRight|k_Repeat:
case kRight:
DisplayMenu()->Scroll(NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft, NORMALKEY(keyP) == kLeft || NORMALKEY(keyP) == kRight);
cStatus::MsgOsdTextItem(NULL, NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft);
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft);
return osContinue;
default: break;
}
eOSState state = cOsdMenu::ProcessKey(keyP);
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (keyP) {
switch (Key) {
case kOk: return osBack;
case kRed: pageM = IPTV_DEVICE_INFO_GENERAL;
case kRed: page = IPTV_DEVICE_INFO_GENERAL;
UpdateInfo();
break;
case kGreen: pageM = IPTV_DEVICE_INFO_PIDS;
case kGreen: page = IPTV_DEVICE_INFO_PIDS;
UpdateInfo();
break;
case kYellow: pageM = IPTV_DEVICE_INFO_FILTERS;
case kYellow: page = IPTV_DEVICE_INFO_FILTERS;
UpdateInfo();
break;
case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1);
case kBlue: IptvConfig.SetUseBytes(!IptvConfig.GetUseBytes());
UpdateInfo();
break;
default: if (timeoutM.TimedOut())
default: if (timeout.TimedOut())
UpdateInfo();
state = osContinue;
break;
@ -112,108 +593,113 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
cIptvPluginSetup::cIptvPluginSetup()
{
debug1("%s", __PRETTY_FUNCTION__);
protocolBasePortM = IptvConfig.GetProtocolBasePort();
sectionFilteringM = IptvConfig.GetSectionFiltering();
numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount();
if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE)
numDisabledFiltersM = SECTION_FILTER_TABLE_SIZE;
debug("cIptvPluginSetup::cIptvPluginSetup()\n");
tsBufferSize = IptvConfig.GetTsBufferSize();
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
extProtocolBasePort = IptvConfig.GetExtProtocolBasePort();
sectionFiltering = IptvConfig.GetSectionFiltering();
sidScanning = IptvConfig.GetSidScanning();
numDisabledFilters = IptvConfig.GetDisabledFiltersCount();
if (numDisabledFilters > SECTION_FILTER_TABLE_SIZE)
numDisabledFilters = SECTION_FILTER_TABLE_SIZE;
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
disabledFilterIndexesM[i] = IptvConfig.GetDisabledFilters(i);
disabledFilterNamesM[i] = tr(section_filter_table[i].description);
disabledFilterIndexes[i] = IptvConfig.GetDisabledFilters(i);
disabledFilterNames[i] = tr(section_filter_table[i].description);
}
SetMenuCategory(mcSetupPlugins);
Setup();
SetHelp(NULL, NULL, NULL, trVDR("Button$Info"));
SetHelp(trVDR("Channels"), NULL, NULL, trVDR("Button$Info"));
}
void cIptvPluginSetup::Setup(void)
{
int current = Current();
Clear();
helpM.Clear();
Add(new cMenuEditIntItem(tr("Protocol base port"), &protocolBasePortM, 0, 0xFFFF - MAXDEVICES * 2));
helpM.Append(tr("Define a base port used by CURL/EXT protocol.\n\nThe port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the CURL/EXT protocol."));
Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFilteringM));
helpM.Append(tr("Define whether the section filtering shall be used.\n\nSection filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\nEnabling this feature does not affect streams that do not contain section data."));
if (sectionFilteringM) {
Add(new cMenuEditIntItem(tr("Disabled filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE));
helpM.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."));
for (int i = 0; i < numDisabledFiltersM; ++i) {
Add(new cMenuEditStraItem(*cString::sprintf(" %s %d", tr("Filter"), i + 1), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM));
helpM.Append(tr("Define an ill-behaving filter to be blacklisted."));
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 1, 4));
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePort, 0, 0xFFF7));
Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFiltering));
if (sectionFiltering) {
Add(new cMenuEditBoolItem(tr("Scan Sid automatically"), &sidScanning));
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFilters, 0, SECTION_FILTER_TABLE_SIZE));
for (int i = 0; i < numDisabledFilters; ++i) {
// TRANSLATORS: note the singular!
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexes[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNames));
}
}
SetCurrent(Get(current));
Display();
}
eOSState cIptvPluginSetup::EditChannel(void)
{
debug("cIptvPluginSetup::EditChannel()\n");
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuChannels());
}
eOSState cIptvPluginSetup::ShowInfo(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvPluginSetup::ShowInfo()\n");
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuInfo());
}
eOSState cIptvPluginSetup::ProcessKey(eKeys keyP)
eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
{
int oldsectionFiltering = sectionFilteringM;
int oldNumDisabledFilters = numDisabledFiltersM;
eOSState state = cMenuSetupPage::ProcessKey(keyP);
int oldsectionFiltering = sectionFiltering;
int oldNumDisabledFilters = numDisabledFilters;
eOSState state = cMenuSetupPage::ProcessKey(Key);
if (state == osUnknown) {
switch (keyP) {
switch (Key) {
case kRed: return EditChannel();
case kBlue: return ShowInfo();
case kInfo: if (Current() < helpM.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()]));
default: state = osContinue; break;
default: state = osContinue;
}
}
if ((keyP != kNone) && ((numDisabledFiltersM != oldNumDisabledFilters) || (sectionFilteringM != oldsectionFiltering))) {
while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
disabledFilterIndexesM[--oldNumDisabledFilters] = -1;
if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) {
while ((numDisabledFilters < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
disabledFilterIndexes[--oldNumDisabledFilters] = -1;
Setup();
}
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 *q = buffer;
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
char s[3];
if ((valuesP[i] < 0) || (valuesP[i] >= SECTION_FILTER_TABLE_SIZE))
if (Values[i] < 0)
break;
if (q > buffer)
*q++ = ' ';
snprintf(s, sizeof(s), "%d", valuesP[i]);
snprintf(s, sizeof(s), "%d", Values[i]);
strncpy(q, s, strlen(s));
q += strlen(s);
}
*q = 0;
debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, buffer);
SetupStore(nameP, buffer);
debug("cIptvPluginSetup::StoreFilters(): %s=%s\n", Name, buffer);
SetupStore(Name, buffer);
}
void cIptvPluginSetup::Store(void)
{
// Store values into setup.conf
SetupStore("ExtProtocolBasePort", protocolBasePortM);
SetupStore("SectionFiltering", sectionFilteringM);
StoreFilters("DisabledFilters", disabledFilterIndexesM);
SetupStore("TsBufferSize", tsBufferSize);
SetupStore("TsBufferPrefill", tsBufferPrefill);
SetupStore("ExtProtocolBasePort", extProtocolBasePort);
SetupStore("SectionFiltering", sectionFiltering);
SetupStore("SidScanning", sidScanning);
StoreFilters("DisabledFilters", disabledFilterIndexes);
// Update global config
IptvConfig.SetProtocolBasePort(protocolBasePortM);
IptvConfig.SetSectionFiltering(sectionFilteringM);
IptvConfig.SetTsBufferSize(tsBufferSize);
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
IptvConfig.SetExtProtocolBasePort(extProtocolBasePort);
IptvConfig.SetSectionFiltering(sectionFiltering);
IptvConfig.SetSidScanning(sidScanning);
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
IptvConfig.SetDisabledFilters(i, disabledFilterIndexesM[i]);
IptvConfig.SetDisabledFilters(i, disabledFilterIndexes[i]);
}

23
setup.h
View File

@ -3,31 +3,34 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: setup.h,v 1.16 2007/10/20 17:26:46 rahrenbe Exp $
*/
#ifndef __IPTV_SETUP_H
#define __IPTV_SETUP_H
#include <vdr/menuitems.h>
#include <vdr/sourceparams.h>
#include "common.h"
class cIptvPluginSetup : public cMenuSetupPage
{
private:
int protocolBasePortM;
int sectionFilteringM;
int numDisabledFiltersM;
int disabledFilterIndexesM[SECTION_FILTER_TABLE_SIZE];
const char *disabledFilterNamesM[SECTION_FILTER_TABLE_SIZE];
cVector<const char*> helpM;
int tsBufferSize;
int tsBufferPrefill;
int extProtocolBasePort;
int sectionFiltering;
int sidScanning;
int numDisabledFilters;
int disabledFilterIndexes[SECTION_FILTER_TABLE_SIZE];
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
eOSState EditChannel(void);
eOSState ShowInfo(void);
void Setup(void);
void StoreFilters(const char *nameP, int *valuesP);
virtual void Setup(void);
void StoreFilters(const char *Name, int *Values);
protected:
virtual eOSState ProcessKey(eKeys keyP);
virtual eOSState ProcessKey(eKeys Key);
virtual void Store(void);
public:

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sidscanner.c,v 1.1 2007/10/01 18:14:57 rahrenbe Exp $
*/
#include <libsi/section.h>
@ -11,98 +12,54 @@
#include "sidscanner.h"
cSidScanner::cSidScanner(void)
: channelIdM(tChannelID::InvalidID),
sidFoundM(false),
nidFoundM(false),
tidFoundM(false),
isActiveM(false)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cSidScanner::cSidScanner()\n");
channel = cChannel();
Set(0x00, 0x00); // PAT
Set(0x10, 0x40); // NIT
}
cSidScanner::~cSidScanner()
void cSidScanner::SetStatus(bool On)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cSidScanner::SetStatus(): %d\n", On);
cFilter::SetStatus(On);
}
void cSidScanner::SetChannel(const tChannelID &channelIdP)
void cSidScanner::SetChannel(const cChannel *Channel)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString());
channelIdM = channelIdP;
sidFoundM = false;
nidFoundM = false;
tidFoundM = false;
}
void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP)
{
int newSid = -1, newNid = -1, newTid = -1;
debug16("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
if (!isActiveM)
return;
if (channelIdM.Valid()) {
if ((pidP == 0x00) && (tidP == 0x00)) {
debug16("%s (%d, %02X, , %d) pat", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::PAT pat(dataP, false);
if (!pat.CheckCRCAndParse())
return;
SI::PAT::Association assoc;
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channelIdM.Sid()) {
debug1("%s (%d, %02X, , %d) sid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, assoc.getServiceId());
newSid = assoc.getServiceId();
}
sidFoundM = true;
break;
}
}
}
else if ((pidP == 0x10) && (tidP == 0x40)) {
debug1("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::NIT nit(dataP, false);
if (!nit.CheckCRCAndParse())
return;
SI::NIT::TransportStream ts;
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
if (ts.getTransportStreamId() != channelIdM.Tid()) {
debug1("%s (%d, %02X, , %d) tsid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getTransportStreamId());
newTid = ts.getTransportStreamId();
tidFoundM = true;
}
if (ts.getOriginalNetworkId() != channelIdM.Nid()) {
debug1("%s (%d, %02X, , %d) onid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getOriginalNetworkId());
newNid = ts.getOriginalNetworkId();
nidFoundM = true;
}
break; // default to the first one
}
// fallback for network id if not found already
if (!nidFoundM && (nit.getNetworkId() != channelIdM.Nid())) {
debug1("%s (%d, %02X, , %d) nid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, nit.getNetworkId());
newNid = nit.getNetworkId();
nidFoundM = true;
}
}
if (Channel) {
debug("cSidScanner::SetChannel(): %s\n", Channel->PluginParam());
channel = *Channel;
}
if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) {
cStateKey StateKey;
cChannels *Channels = cChannels::GetChannelsWrite(StateKey, 10);
if (!Channels)
else {
debug("cSidScanner::SetChannel()\n");
channel = cChannel();
}
}
void cSidScanner::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
{
//debug("cSidScanner::Process()\n");
if ((Pid == 0x00) && (Tid == 0x00) && channel.GetChannelID().Valid()) {
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
SI::PAT pat(Data, false);
if (!pat.CheckCRCAndParse())
return;
bool ChannelsModified = false;
cChannel *IptvChannel = Channels->GetByChannelID(channelIdM);
if (IptvChannel)
ChannelsModified |= IptvChannel->SetId(Channels, (newNid < 0) ? IptvChannel->Nid() : newNid,
(newTid < 0) ? IptvChannel->Tid() : newTid,
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
StateKey.Remove(ChannelsModified);
}
if (sidFoundM && nidFoundM && tidFoundM) {
SetChannel(tChannelID::InvalidID);
SetStatus(false);
SI::PAT::Association assoc;
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
if (!assoc.isNITPid()) {
if (assoc.getServiceId() != channel.Sid()) {
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
if (!Channels.Lock(true, 10))
return;
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
IptvChannel->SetId(IptvChannel->Nid(), IptvChannel->Tid(),
assoc.getServiceId(), IptvChannel->Rid());
Channels.Unlock();
}
SetChannel(NULL);
SetStatus(false);
return;
}
}
}
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sidscanner.h,v 1.1 2007/10/01 18:14:57 rahrenbe Exp $
*/
#ifndef __SIDSCANNER_H
@ -11,25 +12,17 @@
#include <vdr/channels.h>
#include <vdr/filter.h>
#include "log.h"
class cSidScanner : public cFilter {
private:
tChannelID channelIdM;
bool sidFoundM;
bool nidFoundM;
bool tidFoundM;
bool isActiveM;
cChannel channel;
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);
public:
cSidScanner(void);
~cSidScanner();
void SetChannel(const tChannelID &channelIdP);
void Open() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = true; }
void Close() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = false; }
virtual void SetStatus(bool On);
void SetChannel(const cChannel *Channel);
};
#endif // __SIDSCANNER_H

463
socket.c
View File

@ -3,11 +3,11 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: socket.c,v 1.5 2007/10/21 19:46:03 rahrenbe Exp $
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
@ -16,419 +16,194 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "socket.h"
cIptvSocket::cIptvSocket()
: socketPortM(0),
socketDescM(-1),
lastErrorReportM(0),
packetErrorsM(0),
sequenceNumberM(-1),
isActiveM(false)
: socketPort(0),
socketDesc(-1),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug1("%s", __PRETTY_FUNCTION__);
memset(&sockAddrM, 0, sizeof(sockAddrM));
debug("cIptvSocket::cIptvSocket()\n");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
error("ERROR: MALLOC() failed in socket()");
}
cIptvSocket::~cIptvSocket()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvSocket::~cIptvSocket()\n");
// Close the socket
CloseSocket();
// Free allocated memory
free(readBuffer);
}
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
// be closed first
if (portP != socketPortM) {
debug1("%s (%d, %d) Socket tear-down", __PRETTY_FUNCTION__, portP, isUdpP);
if (Port != socketPort) {
debug("cIptvSocket::OpenSocket(): Socket tear-down\n");
CloseSocket();
}
// Bind to the socket if it is not active already
if (socketDescM < 0) {
int yes = 1;
if (socketDesc < 0) {
int yes = 1;
// Create socket
if (isUdpP)
socketDescM = socket(PF_INET, SOCK_DGRAM, 0);
if (isUdp)
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
else
socketDescM = socket(PF_INET, SOCK_STREAM, 0);
ERROR_IF_RET(socketDescM < 0, "socket()", return false);
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
// Make it use non-blocking I/O to avoid stuck read calls
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
CloseSocket(), return false);
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0,
"setsockopt(SO_REUSEADDR)", CloseSocket(), return false);
#ifndef __FreeBSD__
// Allow packet information to be fetched
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0,
"setsockopt(IP_PKTINFO)", CloseSocket(), return false);
#endif // __FreeBSD__
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0, "setsockopt()", CloseSocket(), return false);
// Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM));
sockAddrM.sin_family = AF_INET;
sockAddrM.sin_port = htons((uint16_t)(portP & 0xFFFF));
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdpP)
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0,
"bind()", CloseSocket(), return false);
memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(Port);
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdp) {
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
ERROR_IF_FUNC(err < 0, "bind()", CloseSocket(), return false);
}
// Update socket port
socketPortM = portP;
socketPort = Port;
}
return true;
}
void cIptvSocket::CloseSocket(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvSocket::CloseSocket()\n");
// Check if socket exists
if (socketDescM >= 0) {
close(socketDescM);
socketDescM = -1;
socketPortM = 0;
memset(&sockAddrM, 0, sizeof(sockAddrM));
if (socketDesc >= 0) {
close(socketDesc);
socketDesc = -1;
}
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
cIptvUdpSocket::cIptvUdpSocket()
: streamAddrM(htonl(INADDR_ANY)),
sourceAddrM(htonl(INADDR_ANY)),
useIGMPv3M(false)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvUdpSocket::cIptvUdpSocket()\n");
}
cIptvUdpSocket::~cIptvUdpSocket()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
}
bool cIptvUdpSocket::OpenSocket(const int portP)
bool cIptvUdpSocket::OpenSocket(const int Port)
{
debug1("%s (%d)", __PRETTY_FUNCTION__, portP);
streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false;
return cIptvSocket::OpenSocket(portP, true);
debug("cIptvUdpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, true);
}
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
int cIptvUdpSocket::Read(unsigned char* *BufferAddr)
{
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)
{
debug1("%s", __PRETTY_FUNCTION__);
streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false;
cIptvSocket::CloseSocket();
}
bool cIptvUdpSocket::JoinMulticast(void)
{
debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists
if (!isActiveM && (socketDescM >= 0)) {
// Join a new multicast group
if (useIGMPv3M) {
// Source-specific multicast (SSM) is used
struct group_source_req gsr;
struct sockaddr_in *grp;
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = 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
isActiveM = true;
}
return true;
}
bool cIptvUdpSocket::DropMulticast(void)
{
debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists
if (isActiveM && (socketDescM >= 0)) {
// Drop the existing multicast group
if (useIGMPv3M) {
// Source-specific multicast (SSM) is used
struct group_source_req gsr;
struct sockaddr_in *grp;
struct sockaddr_in *src;
gsr.gsr_interface = 0; // if_nametoindex("any") ?
grp = (struct sockaddr_in*)&gsr.gsr_group;
grp->sin_family = AF_INET;
grp->sin_addr.s_addr = 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
isActiveM = false;
}
return true;
}
int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{
debug16("%s", __PRETTY_FUNCTION__);
//debug("cIptvUdpSocket::Read()\n");
// Error out if socket not initialized
if (socketDescM <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1;
}
int len = 0;
// Read data from socket in a loop
do {
socklen_t addrlen = sizeof(sockAddrM);
struct msghdr msgh;
struct iovec iov;
char cbuf[256];
len = 0;
// Initialize iov and msgh structures
memset(&msgh, 0, sizeof(struct msghdr));
iov.iov_base = bufferAddrP;
iov.iov_len = bufferLenP;
msgh.msg_control = cbuf;
msgh.msg_controllen = sizeof(cbuf);
msgh.msg_name = &sockAddrM;
msgh.msg_namelen = addrlen;
msgh.msg_iov = &iov;
msgh.msg_iovlen = 1;
msgh.msg_flags = 0;
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
len = (int)recvmsg(socketDescM, &msgh, MSG_DONTWAIT);
else
break;
if (len > 0) {
#ifndef __FreeBSD__
// Process auxiliary received data and validate source address
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
if ((i->ipi_addr.s_addr == streamAddrM) || (htonl(INADDR_ANY) == streamAddrM)) {
#endif // __FreeBSD__
if (bufferAddrP[0] == TS_SYNC_BYTE)
return len;
else if (len > 3) {
// http://tools.ietf.org/html/rfc3550
// http://tools.ietf.org/html/rfc2250
// Version
unsigned int v = (bufferAddrP[0] >> 6) & 0x03;
// Extension bit
unsigned int x = (bufferAddrP[0] >> 4) & 0x01;
// CSCR count
unsigned int cc = bufferAddrP[0] & 0x0F;
// Payload type: MPEG2 TS = 33
//unsigned int pt = bufferAddrP[1] & 0x7F;
// Sequence number
int seq = ((bufferAddrP[2] & 0xFF) << 8) | (bufferAddrP[3] & 0xFF);
if ((((sequenceNumberM + 1) % 0xFFFF) == 0) && (seq == 0xFFFF))
sequenceNumberM = -1;
else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) {
packetErrorsM++;
if (time(NULL) - lastErrorReportM > eReportIntervalS) {
info("Detected %d RTP packet errors", packetErrorsM);
packetErrorsM = 0;
lastErrorReportM = time(NULL);
}
sequenceNumberM = seq;
}
else
sequenceNumberM = seq;
// Header lenght
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// Check if extension
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__
}
}
if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__);
return -1;
}
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait 500ms for data
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return retval;
// Check if data available
else if (retval) {
int len = 0;
// Read data from socket
if (isActive)
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
ERROR_IF_RET(len < 0, "recvfrom()", return len);
if ((len > 0) && (readBuffer[0] == 0x47)) {
// Set argument point to read buffer
*BufferAddr = &readBuffer[0];
return len;
}
else if (len > 3) {
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
// version
unsigned int v = (readBuffer[0] >> 6) & 0x03;
// extension bit
unsigned int x = (readBuffer[0] >> 4) & 0x01;
// cscr count
unsigned int cc = readBuffer[0] & 0x0F;
// payload type
unsigned int pt = readBuffer[1] & 0x7F;
// header lenght
unsigned int headerlen = (3 + cc) * sizeof(uint32_t);
// check if extension
if (x) {
// extension header length
unsigned int ehl = (((readBuffer[headerlen + 2] & 0xFF) << 8) | (readBuffer[headerlen + 3] & 0xFF));
// update header length
headerlen += (ehl + 1) * sizeof(uint32_t);
}
#endif // __FreeBSD__
}
} while (len > 0);
ERROR_IF_RET(len < 0 && errno != EAGAIN, "recvmsg()", return -1);
// Check that rtp is version 2, payload type is MPEG2 TS
// and payload contains multiple of TS packet data
if ((v == 2) && (pt == 33) && (((len - headerlen) % TS_SIZE) == 0)) {
// Set argument point to payload in read buffer
*BufferAddr = &readBuffer[headerlen];
return (len - headerlen);
}
}
}
return 0;
}
// TCP socket class
cIptvTcpSocket::cIptvTcpSocket()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvTcpSocket::cIptvTcpSocket()\n");
}
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)
{
debug1("%s (%d, %s)", __PRETTY_FUNCTION__, portP, streamAddrP);
// Socket must be opened before setting the host address
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.sin_addr.s_addr));
debug("cIptvTcpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, false);
}
void cIptvTcpSocket::CloseSocket(void)
int cIptvTcpSocket::Read(unsigned char* *BufferAddr)
{
debug1("%s()", __PRETTY_FUNCTION__);
cIptvSocket::CloseSocket();
}
bool cIptvTcpSocket::ConnectSocket(void)
{
debug1("%s", __PRETTY_FUNCTION__);
if (!isActiveM && (socketDescM >= 0)) {
int retval = connect(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM));
// Non-blocking sockets always report in-progress error when connected
ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false);
// Select with 800ms timeout on the socket completion, check if it is writable
retval = select_single_desc(socketDescM, 800000, true);
if (retval < 0)
return retval;
// Select has returned. Get socket errors if there are any
retval = 0;
socklen_t len = sizeof(retval);
getsockopt(socketDescM, SOL_SOCKET, SO_ERROR, &retval, &len);
// If not any errors, then socket must be ready and connected
if (retval != 0) {
char tmp[64];
error("Connect() failed: %s", strerror_r(retval, tmp, sizeof(tmp)));
return false;
}
}
return true;
}
int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{
debug16("%s", __PRETTY_FUNCTION__);
//debug("cIptvTcpSocket::Read()\n");
// Error out if socket not initialized
if (socketDescM <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1;
}
int len = 0;
socklen_t addrlen = sizeof(sockAddrM);
// Read data from socket
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
len = (int)recvfrom(socketDescM, bufferAddrP, bufferLenP, MSG_DONTWAIT,
(struct sockaddr *)&sockAddrM, &addrlen);
return len;
}
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
{
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__);
return false;
}
socklen_t addrlen = sizeof(sockAddrM);
if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__);
return -1;
}
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait 500ms for data
int retval = select_single_desc(socketDescM, 1000 * timeoutMsP, false);
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return false;
return retval;
// Check if data available
else if (retval) {
retval = (int)recvfrom(socketDescM, bufferAddrP, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddrM, &addrlen);
if (retval <= 0)
return false;
// Read data from socket
if (isActive)
return recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
}
return true;
}
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP)
{
debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized
if (socketDescM <= 0) {
error("%s Invalid socket", __PRETTY_FUNCTION__);
return false;
}
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false);
return true;
return 0;
}

View File

@ -1,37 +1,28 @@
/*
* 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.
*
* $Id: socket.h,v 1.3 2007/10/21 19:32:15 ajhseppa Exp $
*/
#ifndef __IPTV_SOCKET_H
#define __IPTV_SOCKET_H
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif // __FreeBSD__
class cIptvSocket {
private:
int socketPortM;
protected:
int socketPort;
int socketDesc;
unsigned char* readBuffer;
unsigned int readBufferLen;
struct sockaddr_in sockAddr;
bool isActive;
protected:
enum {
eReportIntervalS = 300 // in seconds
};
int socketDescM;
struct sockaddr_in sockAddrM;
time_t lastErrorReportM;
int packetErrorsM;
int sequenceNumberM;
bool isActiveM;
protected:
bool OpenSocket(const int portP, const bool isUdpP);
bool OpenSocket(const int Port, const bool isUdp);
void CloseSocket(void);
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
public:
cIptvSocket();
@ -39,32 +30,19 @@ public:
};
class cIptvUdpSocket : public cIptvSocket {
private:
in_addr_t streamAddrM;
in_addr_t sourceAddrM;
bool useIGMPv3M;
public:
cIptvUdpSocket();
virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
bool OpenSocket(const int Port, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P);
void CloseSocket(void);
bool JoinMulticast(void);
bool DropMulticast(void);
};
class cIptvTcpSocket : public cIptvSocket {
public:
cIptvTcpSocket();
virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool OpenSocket(const int portP, const char *streamAddrP);
void CloseSocket(void);
bool ConnectSocket(void);
bool ReadChar(char* bufferAddrP, unsigned int timeoutMsP);
bool Write(const char* bufferAddrP, unsigned int bufferLenP);
virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
};
#endif // __IPTV_SOCKET_H

183
source.c
View File

@ -1,183 +0,0 @@
/*
* source.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include <ctype.h>
#include "common.h"
#include "log.h"
#include "source.h"
// --- cIptvTransponderParameters --------------------------------------------
cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
: sidScanM(0),
pidScanM(0),
protocolM(eProtocolUDP),
parameterM(0)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, parametersP);
memset(&addressM, 0, sizeof(addressM));
Parse(parametersP);
}
cString cIptvTransponderParameters::ToString(char typeP) const
{
debug1("%s (%c)", __PRETTY_FUNCTION__, typeP);
const char *protocolstr;
switch (protocolM) {
case eProtocolEXT:
protocolstr = "EXT";
break;
case eProtocolCURL:
protocolstr = "CURL";
break;
case eProtocolHTTP:
protocolstr = "HTTP";
break;
case eProtocolFILE:
protocolstr = "FILE";
break;
default:
case eProtocolUDP:
protocolstr = "UDP";
break;
}
return cString::sprintf("S=%d|P=%d|F=%s|U=%s|A=%d", sidScanM, pidScanM, protocolstr, addressM, parameterM);
}
bool cIptvTransponderParameters::Parse(const char *strP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, strP);
bool result = false;
if (strP && *strP) {
const char *delim = "|";
char *str = strdup(strP);
char *p = str;
char *saveptr = NULL;
char *token = NULL;
bool found_s = false;
bool found_p = false;
bool found_f = false;
bool found_u = false;
bool found_a = false;
while ((token = strtok_r(str, delim, &saveptr)) != NULL) {
char *data = token;
++data;
if (data && (*data == '=')) {
++data;
switch (toupper(*token)) {
case 'S':
sidScanM = (int)strtol(data, (char **)NULL, 10);
found_s = true;
break;
case 'P':
pidScanM = (int)strtol(data, (char **)NULL, 10);
found_p = true;
break;
case 'F':
if (strstr(data, "UDP")) {
protocolM = eProtocolUDP;
found_f = true;
}
else if (strstr(data, "CURL")) {
protocolM = eProtocolCURL;
found_f = true;
}
else if (strstr(data, "HTTP")) {
protocolM = eProtocolHTTP;
found_f = true;
}
else if (strstr(data, "FILE")) {
protocolM = eProtocolFILE;
found_f = true;
}
else if (strstr(data, "EXT")) {
protocolM = eProtocolEXT;
found_f = true;
}
break;
case 'U':
strn0cpy(addressM, data, sizeof(addressM));
found_u = true;
break;
case 'A':
parameterM = (int)strtol(data, (char **)NULL, 10);
found_a = true;
break;
default:
break;
}
}
str = NULL;
}
if (found_s && found_p && found_f && found_u && found_a)
result = true;
else
error("Invalid channel parameters: %s", p);
free(p);
}
return (result);
}
// --- cIptvSourceParam ------------------------------------------------------
const char *cIptvSourceParam::allowedProtocolCharsS = " abcdefghijklmnopqrstuvwxyz0123456789-.,#~\\^$[]()*+?{}/%@&=";
cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
: cSourceParam(sourceP, descriptionP),
paramM(0),
ridM(0),
dataM(),
itpM()
{
debug1("%s (%c, %s)", __PRETTY_FUNCTION__, sourceP, descriptionP);
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL");
protocolsM[cIptvTransponderParameters::eProtocolHTTP] = tr("HTTP");
protocolsM[cIptvTransponderParameters::eProtocolFILE] = tr("FILE");
protocolsM[cIptvTransponderParameters::eProtocolEXT] = tr("EXT");
}
void cIptvSourceParam::SetData(cChannel *channelP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
dataM = *channelP;
ridM = dataM.Rid();
itpM.Parse(dataM.Parameters());
paramM = 0;
}
void cIptvSourceParam::GetData(cChannel *channelP)
{
debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
channelP->SetId(NULL, channelP->Nid(), channelP->Tid(), channelP->Sid(), ridM);
}
cOsdItem *cIptvSourceParam::GetOsdItem(void)
{
debug1("%s", __PRETTY_FUNCTION__);
switch (paramM++) {
case 0: return new cMenuEditIntItem( tr("Rid"), &ridM, 0);
case 1: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM);
case 2: return new cMenuEditBoolItem(tr("Scan pids"), &itpM.pidScanM);
case 3: return new cMenuEditStraItem(tr("Protocol"), &itpM.protocolM, ELEMENTS(protocolsM), protocolsM);
case 4: return new cMenuEditStrItem( tr("Address"), itpM.addressM, sizeof(itpM.addressM), allowedProtocolCharsS);
case 5: return new cMenuEditIntItem( tr("Parameter"), &itpM.parameterM, 0, 0xFFFF);
default: return NULL;
}
return NULL;
}

View File

@ -1,69 +0,0 @@
/*
* source.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_SOURCE_H
#define __IPTV_SOURCE_H
#include <vdr/menuitems.h>
#include <vdr/sourceparams.h>
#include "common.h"
class cIptvTransponderParameters
{
friend class cIptvSourceParam;
private:
int sidScanM;
int pidScanM;
int protocolM;
char addressM[NAME_MAX + 1];
int parameterM;
public:
enum {
eProtocolUDP,
eProtocolCURL,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
cIptvTransponderParameters(const char *parametersP = NULL);
int SidScan(void) const { return sidScanM; }
int PidScan(void) const { return pidScanM; }
int Protocol(void) const { return protocolM; }
const char *Address(void) const { return addressM; }
int Parameter(void) const { return parameterM; }
void SetSidScan(int sidScanP) { sidScanM = sidScanP; }
void SetPidScan(int pidScanP) { pidScanM = pidScanP; }
void SetProtocol(int protocolP) { protocolM = protocolP; }
void SetAddress(const char *addressP) { strncpy(addressM, addressP, sizeof(addressM)); }
void SetParameter(int parameterP) { parameterM = parameterP; }
cString ToString(char typeP) const;
bool Parse(const char *strP);
};
class cIptvSourceParam : public cSourceParam
{
private:
int paramM;
int ridM;
cChannel dataM;
cIptvTransponderParameters itpM;
const char *protocolsM[cIptvTransponderParameters::eProtocolCount];
private:
static const char *allowedProtocolCharsS;
public:
cIptvSourceParam(char sourceP, const char *descriptionP);
virtual void SetData(cChannel *channelP);
virtual void GetData(cChannel *channelP);
virtual cOsdItem *GetOsdItem(void);
};
#endif // __IPTV_SOURCE_H

25
statisticif.h Normal file
View File

@ -0,0 +1,25 @@
/*
* statisticif.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statisticif.h,v 1.4 2007/10/07 19:06:33 ajhseppa Exp $
*/
#ifndef __IPTV_STATISTICIF_H
#define __IPTV_STATISTICIF_H
#include <vdr/tools.h>
class cIptvStatisticIf {
public:
cIptvStatisticIf() {}
virtual ~cIptvStatisticIf() {}
virtual cString GetStatistic() = 0;
private:
cIptvStatisticIf(const cIptvStatisticIf&);
cIptvStatisticIf& operator=(const cIptvStatisticIf&);
};
#endif // __IPTV_STATISTICIF_H

View File

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

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statistics.h,v 1.10 2007/10/11 23:06:49 rahrenbe Exp $
*/
#ifndef __IPTV_STATISTICS_H
@ -10,78 +11,80 @@
#include <vdr/thread.h>
#include "statisticif.h"
// Section statistics
class cIptvSectionStatistics {
class cIptvSectionStatistics : public cIptvStatisticIf {
public:
cIptvSectionStatistics();
virtual ~cIptvSectionStatistics();
cString GetSectionStatistic();
cString GetStatistic();
protected:
void AddSectionStatistic(long bytesP, long callsP);
void AddStatistic(long Bytes, long Calls);
private:
long filteredDataM;
long numberOfCallsM;
cTimeMs timerM;
cMutex mutexM;
long filteredData;
long numberOfCalls;
cTimeMs timer;
cMutex mutex;
};
// Pid statistics
class cIptvPidStatistics {
class cIptvPidStatistics : public cIptvStatisticIf {
public:
cIptvPidStatistics();
virtual ~cIptvPidStatistics();
cString GetPidStatistic();
cString GetStatistic();
protected:
void AddPidStatistic(int pidP, long payloadP);
void AddStatistic(u_short Pid, long Payload);
private:
struct pidStruct {
int pid;
long dataAmount;
u_short pid;
long DataAmount;
};
pidStruct mostActivePidsM[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timerM;
cMutex mutexM;
pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
cTimeMs timer;
cMutex mutex;
private:
static int SortPids(const void* data1P, const void* data2P);
static int SortPids(const void* data1, const void* data2);
};
// Streamer statistics
class cIptvStreamerStatistics {
class cIptvStreamerStatistics : public cIptvStatisticIf {
public:
cIptvStreamerStatistics();
virtual ~cIptvStreamerStatistics();
cString GetStreamerStatistic();
cString GetStatistic();
protected:
void AddStreamerStatistic(long bytesP);
void AddStatistic(long Bytes);
private:
long dataBytesM;
cTimeMs timerM;
cMutex mutexM;
long dataBytes;
cTimeMs timer;
cMutex mutex;
};
// Buffer statistics
class cIptvBufferStatistics {
class cIptvBufferStatistics : public cIptvStatisticIf {
public:
cIptvBufferStatistics();
virtual ~cIptvBufferStatistics();
cString GetBufferStatistic();
cString GetStatistic();
protected:
void AddBufferStatistic(long bytesP, long usedP);
void AddStatistic(long Bytes, long Used);
private:
long dataBytesM;
long freeSpaceM;
long usedSpaceM;
cTimeMs timerM;
cMutex mutexM;
long dataBytes;
long freeSpace;
long usedSpace;
cTimeMs timer;
cMutex mutex;
};
#endif // __IPTV_STATISTICS_H

View File

@ -3,65 +3,65 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.c,v 1.27 2007/10/20 08:58:15 ajhseppa Exp $
*/
#include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "common.h"
#include "log.h"
#include "streamer.h"
cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP)
cIptvStreamer::cIptvStreamer(cRingBufferLinear* RingBuffer, cMutex* Mutex)
: cThread("IPTV streamer"),
sleepM(),
deviceM(&deviceP),
packetBufferLenM(packetLenP),
protocolM(NULL)
ringBuffer(RingBuffer),
mutex(Mutex),
protocol(NULL)
{
debug1("%s (, %d)", __PRETTY_FUNCTION__, packetBufferLenM);
// Allocate packet buffer
packetBufferM = MALLOC(unsigned char, packetBufferLenM);
if (packetBufferM)
memset(packetBufferM, 0, packetBufferLenM);
else
error("MALLOC() failed for packet buffer");
debug("cIptvStreamer::cIptvStreamer()\n");
}
cIptvStreamer::~cIptvStreamer()
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvStreamer::~cIptvStreamer()\n");
// Close the protocol
Close();
protocolM = NULL;
// Free allocated memory
free(packetBufferM);
}
void cIptvStreamer::Action(void)
{
debug1("%s() Entering", __PRETTY_FUNCTION__);
// Increase priority
//SetPriority(-1);
debug("cIptvStreamer::Action(): Entering\n");
// Do the thread loop
while (packetBufferM && Running()) {
int length = -1;
unsigned int size = min(deviceM->CheckData(), packetBufferLenM);
if (protocolM && (size > 0))
length = protocolM->Read(packetBufferM, size);
if (length > 0) {
AddStreamerStatistic(length);
deviceM->WriteData(packetBufferM, length);
}
else
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
}
debug1("%s Exiting", __PRETTY_FUNCTION__);
while (Running()) {
if (ringBuffer && mutex && protocol && ringBuffer->Free()) {
unsigned char *buffer = NULL;
mutex->Lock();
int length = protocol->Read(&buffer);
if (length >= 0) {
AddStatistic(length);
int p = ringBuffer->Put(buffer, length);
if (p != length && Running())
ringBuffer->ReportOverflow(length - p);
mutex->Unlock();
}
else {
mutex->Unlock();
cCondWait::SleepMs(100); // to reduce cpu load
}
}
else
cCondWait::SleepMs(100); // and avoid busy loop
}
debug("cIptvStreamer::Action(): Exiting\n");
}
bool cIptvStreamer::Open(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvStreamer::Open()\n");
// Open the protocol
if (protocolM && !protocolM->Open())
return false;
if (protocol)
if(!protocol->Open())
return false;
// Start thread
Start();
return true;
@ -69,50 +69,45 @@ bool cIptvStreamer::Open(void)
bool cIptvStreamer::Close(void)
{
debug1("%s", __PRETTY_FUNCTION__);
debug("cIptvStreamer::Close()\n");
// Stop thread
sleepM.Signal();
if (Running())
Cancel(3);
// Close the protocol
if (protocolM)
protocolM->Close();
return true;
}
bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
{
debug1("%s (%s, %d, %d, )", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) {
// Update protocol and set location and parameter; Close the existing one if changed
if (protocolM != protocolP) {
if (protocolM)
protocolM->Close();
protocolM = protocolP;
if (protocolM) {
protocolM->SetSource(locationP, parameterP, indexP);
protocolM->Open();
}
}
else if (protocolM)
protocolM->SetSource(locationP, parameterP, indexP);
// Close the protocol. A mutex should be taken here to avoid a race condition
// where thread Action() may be in the process of accessing the protocol.
// Taking a mutex serializes the Close() and Action() -calls.
if (protocol) {
mutex->Lock();
protocol->Close();
mutex->Unlock();
}
return true;
}
bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP)
bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol)
{
debug1("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
if (protocolM)
return protocolM->SetPid(pidP, typeP, onP);
debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter);
if (!isempty(Location)) {
// Update protocol; Close the existing one if changed
if (protocol != Protocol) {
if (protocol)
protocol->Close();
protocol = Protocol;
if (protocol)
protocol->Open();
}
// Set protocol location and parameter
if (protocol)
protocol->Set(Location, Parameter, Index);
}
return true;
}
cString cIptvStreamer::GetInformation(void)
{
debug16("%s", __PRETTY_FUNCTION__);
cString s;
if (protocolM)
s = protocolM->GetInformation();
return s;
//debug("cIptvStreamer::GetInformation()");
cString info("Stream:");
if (protocol)
info = cString::sprintf("%s %s", *info, *protocol->GetInformation());
return cString::sprintf("%s\n", *info);
}

View File

@ -3,6 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.h,v 1.13 2007/10/19 22:18:55 rahrenbe Exp $
*/
#ifndef __IPTV_STREAMER_H
@ -11,30 +12,28 @@
#include <arpa/inet.h>
#include <vdr/thread.h>
#include <vdr/ringbuffer.h>
#include "deviceif.h"
#include "protocolif.h"
#include "statistics.h"
class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
private:
cCondWait sleepM;
cIptvDeviceIf* deviceM;
unsigned char* packetBufferM;
unsigned int packetBufferLenM;
cIptvProtocolIf* protocolM;
protected:
virtual void Action(void);
cRingBufferLinear* ringBuffer;
cMutex* mutex;
unsigned char* readBuffer;
unsigned int readBufferLen;
cIptvProtocolIf* protocol;
public:
cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP);
cIptvStreamer(cRingBufferLinear* RingBuffer, cMutex* Mutex);
virtual ~cIptvStreamer();
bool SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP);
bool SetPid(int pidP, int typeP, bool onP);
virtual void Action(void);
bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_STREAMER_H