mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 11:37:03 +00:00
Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41fe387018 | ||
|
|
2c287ef667 | ||
|
|
d7dfa0aad6 | ||
|
|
72a9f21006 | ||
|
|
d84fd79d14 | ||
|
|
f632650547 | ||
|
|
980aafb206 | ||
|
|
45192e924a | ||
|
|
e4657c1820 | ||
|
|
ed09963253 | ||
|
|
623991ace0 | ||
|
|
26a0adceb5 | ||
|
|
e75080b1a8 | ||
|
|
94461d6c08 | ||
|
|
29bc3d1493 | ||
|
|
c975d458f5 | ||
|
|
11d864c16b | ||
|
|
75d17b289b | ||
|
|
547306b67c | ||
|
|
763c83209d | ||
|
|
af85ef1703 | ||
|
|
24ecadf414 | ||
|
|
f4126b7e2c | ||
|
|
c7cbde301b | ||
|
|
06506c41f6 | ||
|
|
c33b05076a | ||
|
|
38bd9a21f6 | ||
|
|
4c7b2ea69b | ||
|
|
c475b26515 | ||
|
|
9145fb8bb8 | ||
|
|
7a8b2962b2 | ||
|
|
626d0402c2 | ||
|
|
b3b06e569f | ||
|
|
ff84c54d50 | ||
|
|
4c39d8cf72 | ||
|
|
0b790260fa | ||
|
|
79113bbe09 | ||
|
|
30de763a4b | ||
|
|
868865c47d | ||
|
|
a73921041f | ||
|
|
49e3a9e23a | ||
|
|
73311873bc | ||
|
|
816c357065 | ||
|
|
5838bda3f0 | ||
|
|
079b02d69e | ||
|
|
6582f137b9 | ||
|
|
2bd31e9eda | ||
|
|
c2f88fbbb3 | ||
|
|
52ae2bdf63 | ||
|
|
1898defeb6 | ||
|
|
21719d3397 | ||
|
|
bf3fc70d2d | ||
|
|
99d6c0f207 | ||
|
|
ca4fdc761f | ||
|
|
37c5ee26ae | ||
|
|
8ba0b3a417 | ||
|
|
cfb60a06ba | ||
|
|
6ed0ebd734 | ||
|
|
2081ab41a8 | ||
|
|
66ab92584b | ||
|
|
05e57802c3 | ||
|
|
55bb0e65df | ||
|
|
ea4f8fde31 | ||
|
|
ef615c4bc5 | ||
|
|
a6d4e850fc | ||
|
|
fd06641449 | ||
|
|
05e52079f8 | ||
|
|
f0469e24cc | ||
|
|
7629e34d2a | ||
|
|
ac458b0c36 | ||
|
|
2d583e8cfa | ||
|
|
b0dba49fbc | ||
|
|
a05766c90d | ||
|
|
d1fdc390c9 | ||
|
|
d126da8ed8 | ||
|
|
2567501b65 | ||
|
|
12b54fbbc2 | ||
|
|
a2d8c367f6 | ||
|
|
3f88e7a911 | ||
|
|
8a96e5b327 | ||
|
|
170cb56263 | ||
|
|
899db53845 | ||
|
|
6eb259e8fb | ||
|
|
204c6020c4 | ||
|
|
c207b5cf6e | ||
|
|
d8585ba0fc | ||
|
|
1a825f5636 | ||
|
|
0720489995 | ||
|
|
3b8cfd2323 | ||
|
|
d737278f78 | ||
|
|
906438e981 | ||
|
|
aa620a314c |
80
HISTORY
80
HISTORY
@@ -1,5 +1,6 @@
|
|||||||
|
==================================
|
||||||
VDR Plugin 'iptv' Revision History
|
VDR Plugin 'iptv' Revision History
|
||||||
----------------------------------
|
==================================
|
||||||
|
|
||||||
2007-10-14: Version 0.0.1
|
2007-10-14: Version 0.0.1
|
||||||
|
|
||||||
@@ -121,3 +122,80 @@ VDR Plugin 'iptv' Revision History
|
|||||||
|
|
||||||
- Updated patches.
|
- Updated patches.
|
||||||
- Fixed argument corruption.
|
- 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.
|
||||||
|
|||||||
114
Makefile
114
Makefile
@@ -2,120 +2,151 @@
|
|||||||
# Makefile for IPTV plugin
|
# Makefile for IPTV plugin
|
||||||
#
|
#
|
||||||
|
|
||||||
# Debugging on/off
|
# Debugging on/off
|
||||||
|
|
||||||
#IPTV_DEBUG = 1
|
#IPTV_DEBUG = 1
|
||||||
|
|
||||||
|
# Default shell for EXT protocol
|
||||||
|
|
||||||
|
#IPTV_EXTSHELL = /bin/bash
|
||||||
|
|
||||||
# Strip debug symbols? Set eg. to /bin/true if not
|
# Strip debug symbols? Set eg. to /bin/true if not
|
||||||
|
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
|
|
||||||
# The official name of this plugin.
|
# The official name of this plugin.
|
||||||
# This name will be used in the '-P...' option of VDR to load the plugin.
|
# This name will be used in the '-P...' option of VDR to load the plugin.
|
||||||
# By default the main source file also carries this name.
|
# By default the main source file also carries this name.
|
||||||
# IMPORTANT: the presence of this macro is important for the Make.config
|
|
||||||
# file. So it must be defined, even if it is not used here!
|
|
||||||
#
|
|
||||||
PLUGIN = iptv
|
PLUGIN = iptv
|
||||||
|
|
||||||
### The version number of this plugin (taken from the main source file):
|
### The version number of this plugin (taken from the main source file):
|
||||||
|
|
||||||
VERSION = $(shell grep 'static const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
|
VERSION = $(shell grep 'const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g')
|
||||||
|
GITTAG = $(shell git describe --always 2>/dev/null)
|
||||||
### The C++ compiler and options:
|
|
||||||
|
|
||||||
CXX ?= g++
|
|
||||||
CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -Wswitch-default -Wfloat-equal -Wundef -Wpointer-arith -Wconversion -Wcast-align -Wredundant-decls -Wno-unused-parameter -Woverloaded-virtual -Wno-parentheses
|
|
||||||
|
|
||||||
### The directory environment:
|
### The directory environment:
|
||||||
|
|
||||||
VDRDIR = ../../..
|
# Use package data if installed...otherwise assume we're under the VDR source directory:
|
||||||
LIBDIR = ../../lib
|
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --variable=$(1) vdr || pkg-config --variable=$(1) ../../../vdr.pc))
|
||||||
TMPDIR = /tmp
|
LIBDIR = $(call PKGCFG,libdir)
|
||||||
|
LOCDIR = $(call PKGCFG,locdir)
|
||||||
|
PLGCFG = $(call PKGCFG,plgcfg)
|
||||||
|
#
|
||||||
|
TMPDIR ?= /tmp
|
||||||
|
|
||||||
|
### The compiler options:
|
||||||
|
|
||||||
|
export CFLAGS = $(call PKGCFG,cflags)
|
||||||
|
export CXXFLAGS = $(call PKGCFG,cxxflags)
|
||||||
|
|
||||||
|
### The version number of VDR's plugin API:
|
||||||
|
|
||||||
|
APIVERSION = $(call PKGCFG,apiversion)
|
||||||
|
|
||||||
### Allow user defined options to overwrite defaults:
|
### Allow user defined options to overwrite defaults:
|
||||||
|
|
||||||
-include $(VDRDIR)/Make.config
|
-include $(PLGCFG)
|
||||||
|
|
||||||
### The version number of VDR's plugin API (taken from VDR's "config.h"):
|
|
||||||
|
|
||||||
APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
|
|
||||||
|
|
||||||
### The name of the distribution archive:
|
### The name of the distribution archive:
|
||||||
|
|
||||||
ARCHIVE = $(PLUGIN)-$(VERSION)
|
ARCHIVE = $(PLUGIN)-$(VERSION)
|
||||||
PACKAGE = vdr-$(ARCHIVE)
|
PACKAGE = vdr-$(ARCHIVE)
|
||||||
|
|
||||||
|
### The name of the shared object file:
|
||||||
|
|
||||||
|
SOFILE = libvdr-$(PLUGIN).so
|
||||||
|
|
||||||
|
### Libraries
|
||||||
|
|
||||||
|
LIBS = $(shell curl-config --libs)
|
||||||
|
|
||||||
### Includes and Defines (add further entries here):
|
### Includes and Defines (add further entries here):
|
||||||
|
|
||||||
INCLUDES += -I$(VDRDIR)/include
|
INCLUDES +=
|
||||||
|
|
||||||
DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
|
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
|
||||||
|
|
||||||
ifdef IPTV_DEBUG
|
ifdef IPTV_DEBUG
|
||||||
DEFINES += -DDEBUG
|
DEFINES += -DDEBUG
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef IPTV_EXTSHELL
|
||||||
|
DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"'
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(strip $(GITTAG)),)
|
||||||
|
DEFINES += -DGITVERSION='"-GIT-$(GITTAG)"'
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all all-redirect
|
.PHONY: all all-redirect
|
||||||
all-redirect: all
|
all-redirect: all
|
||||||
|
|
||||||
### The object files (add further files here):
|
### The object files (add further files here):
|
||||||
|
|
||||||
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \
|
OBJS = $(PLUGIN).o common.o config.o device.o pidscanner.o \
|
||||||
protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \
|
protocolcurl.o protocolext.o protocolfile.o protocolhttp.o \
|
||||||
sidscanner.o pidscanner.o statistics.o common.o socket.o
|
protocoludp.o sectionfilter.o setup.o sidscanner.o socket.o \
|
||||||
|
source.o statistics.o streamer.o
|
||||||
|
|
||||||
### The main target:
|
### The main target:
|
||||||
|
|
||||||
all: libvdr-$(PLUGIN).so i18n
|
all: $(SOFILE) i18n
|
||||||
|
|
||||||
### Implicit rules:
|
### Implicit rules:
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
|
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
|
||||||
|
|
||||||
### Dependencies:
|
### Dependencies:
|
||||||
|
|
||||||
MAKEDEP = $(CXX) -MM -MG
|
MAKEDEP = $(CXX) -MM -MG
|
||||||
DEPFILE = .dependencies
|
DEPFILE = .dependencies
|
||||||
$(DEPFILE): Makefile
|
$(DEPFILE): Makefile
|
||||||
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
|
@$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
|
||||||
|
|
||||||
-include $(DEPFILE)
|
-include $(DEPFILE)
|
||||||
|
|
||||||
### Internationalization (I18N):
|
### Internationalization (I18N):
|
||||||
|
|
||||||
PODIR = po
|
PODIR = po
|
||||||
LOCALEDIR = $(VDRDIR)/locale
|
|
||||||
I18Npo = $(wildcard $(PODIR)/*.po)
|
I18Npo = $(wildcard $(PODIR)/*.po)
|
||||||
I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
|
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
|
||||||
|
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
|
||||||
I18Npot = $(PODIR)/$(PLUGIN).pot
|
I18Npot = $(PODIR)/$(PLUGIN).pot
|
||||||
|
|
||||||
%.mo: %.po
|
%.mo: %.po
|
||||||
msgfmt -c -o $@ $<
|
msgfmt -c -o $@ $<
|
||||||
|
|
||||||
$(I18Npot): $(wildcard *.c)
|
$(I18Npot): $(wildcard *.c)
|
||||||
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $^
|
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ `ls $^`
|
||||||
|
|
||||||
%.po: $(I18Npot)
|
%.po: $(I18Npot)
|
||||||
msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
|
msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
|
$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
|
||||||
@mkdir -p $(dir $@)
|
install -D -m644 $< $@
|
||||||
cp $< $@
|
|
||||||
|
|
||||||
.PHONY: i18n
|
.PHONY: i18n
|
||||||
i18n: $(I18Nmsgs) $(I18Npot)
|
i18n: $(I18Nmo) $(I18Npot)
|
||||||
|
|
||||||
|
install-i18n: $(I18Nmsgs)
|
||||||
|
|
||||||
### Targets:
|
### Targets:
|
||||||
|
|
||||||
libvdr-$(PLUGIN).so: $(OBJS)
|
$(SOFILE): $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
|
||||||
ifndef IPTV_DEBUG
|
ifndef IPTV_DEBUG
|
||||||
@$(STRIP) $@
|
@$(STRIP) $@
|
||||||
endif
|
endif
|
||||||
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
|
|
||||||
|
|
||||||
dist: clean
|
install-lib: $(SOFILE)
|
||||||
|
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
|
||||||
|
|
||||||
|
install: install-lib install-i18n
|
||||||
|
|
||||||
|
dist: $(I18Npo) clean
|
||||||
@-rm -rf $(TMPDIR)/$(ARCHIVE)
|
@-rm -rf $(TMPDIR)/$(ARCHIVE)
|
||||||
@mkdir $(TMPDIR)/$(ARCHIVE)
|
@mkdir $(TMPDIR)/$(ARCHIVE)
|
||||||
@cp -a * $(TMPDIR)/$(ARCHIVE)
|
@cp -a * $(TMPDIR)/$(ARCHIVE)
|
||||||
@@ -124,4 +155,9 @@ dist: clean
|
|||||||
@echo Distribution package created as $(PACKAGE).tgz
|
@echo Distribution package created as $(PACKAGE).tgz
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ $(PODIR)/*.mo $(PODIR)/*.pot
|
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
|
||||||
|
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
|
||||||
|
|
||||||
|
.PHONY: cppcheck
|
||||||
|
cppcheck:
|
||||||
|
@cppcheck --language=c++ --enable=all -v -f $(OBJS:%.o=%.c)
|
||||||
|
|||||||
96
README
96
README
@@ -17,7 +17,8 @@ See the file COPYING for more information.
|
|||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
An IPTV patched VDR setup and DVB compatible MPEG1/2 network video streams.
|
- Libcurl - the multiprotocol file transfer library
|
||||||
|
http://curl.haxx.se/libcurl/
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
|
|
||||||
@@ -44,9 +45,7 @@ cd /put/your/path/here/VDR/PLUGINS/src
|
|||||||
tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz
|
tar -xzf /put/your/path/here/vdr-iptv-X.Y.Z.tgz
|
||||||
ln -s iptv-X.Y.Z iptv
|
ln -s iptv-X.Y.Z iptv
|
||||||
cd /put/your/path/here/VDR
|
cd /put/your/path/here/VDR
|
||||||
patch -p1 < PLUGINS/src/iptv/patches/vdr-X.Y.Z-pluginparam.patch
|
cp -R PLUGINS/src/iptv/iptv /path/to/vdrresource/plugins/
|
||||||
cp sources.conf /path/to/vdrconf/
|
|
||||||
cp -R PLUGINS/src/iptv/iptv /path/to/vdrconf/plugins/
|
|
||||||
make
|
make
|
||||||
make plugins
|
make plugins
|
||||||
./vdr -P iptv
|
./vdr -P iptv
|
||||||
@@ -77,29 +76,8 @@ Setup menu:
|
|||||||
options which allow you to disable the
|
options which allow you to disable the
|
||||||
individual section filters.
|
individual section filters.
|
||||||
Valid range: 0...7
|
Valid range: 0...7
|
||||||
- [Red:Channels] Opens IPTV channel editor.
|
|
||||||
- [Blue:Info] Opens IPTV information/statistics menu.
|
- [Blue:Info] Opens IPTV information/statistics menu.
|
||||||
|
|
||||||
Channel editor menu:
|
|
||||||
|
|
||||||
- Because of the different nature and content the VDR channel editor is not
|
|
||||||
best suited for editing of IPTV channels. Therefore an alternative editor
|
|
||||||
is provided which allows more IPTV centric editing of channel information.
|
|
||||||
An IPTV channel editor is accessible via "Setup -> Plugins -> IPTV" and
|
|
||||||
pressing the Red button. The channel editor is functionally similar to
|
|
||||||
VDR's built-in channel editor.
|
|
||||||
|
|
||||||
- Scan Sid: [yes|no] Defines whether service id shall be
|
|
||||||
scanned automatically. Service id is
|
|
||||||
used in channel identification and
|
|
||||||
EPG information is set according to it.
|
|
||||||
This option requires section filtering.
|
|
||||||
|
|
||||||
- Scan pids: [yes|no] Defines whether video and audio pids
|
|
||||||
shall be scanned automatically. This
|
|
||||||
option is useful with streams missing
|
|
||||||
correct PAT/PMT information.
|
|
||||||
|
|
||||||
Information menu:
|
Information menu:
|
||||||
|
|
||||||
- [Red:General] Opens the general information page.
|
- [Red:General] Opens the general information page.
|
||||||
@@ -111,34 +89,49 @@ Configuration:
|
|||||||
|
|
||||||
- channels.conf
|
- channels.conf
|
||||||
|
|
||||||
TV4;IPTV:40:IPTV|S1P0|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0
|
TV4;IPTV:60:S=1|P=0|F=EXT|U=iptvstream.sh|A=0:I:0:0:680:0:0:6:0:0:0
|
||||||
TV3;IPTV:30:IPTV|S0P1|FILE|/video/stream.ts|5:P:0:514:670:2321:0:3:0:0:0
|
TV3;IPTV:50:S=0|P=1|F=FILE|U=/video/stream.ts|A=5:I:0:514:670:2321:0:5:0:0:0
|
||||||
TV2;IPTV:20:IPTV|S0P1|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0
|
TV2;IPTV:40:S=0|P=1|F=HTTP|U=127.0.0.1/TS/2|A=3000:I:0:513:660:2321:0:4:0:0:0
|
||||||
TV1;IPTV:10:IPTV|S1P0|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
|
TV1;IPTV:30:S=1|P=0|F=CURL|U=http%3A//foo%3Abar@127.0.0.1%3A3000/TS/2|A=0:I:0:512:650:2321:0:3:0:0:0
|
||||||
^ ^ ^ ^ ^ ^ ^
|
TV1;IPTV:20:S=1|P=0|F=UDP|U=127.0.0.1@127.0.0.1|A=1234:I:0:512:650:2321:0:2:0:0:0
|
||||||
| | | | | | Source type ("P")
|
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
|
||||||
| | | | | IP Port Number, File delay (ms), Script parameter
|
^ ^ ^ ^ ^ ^ ^
|
||||||
| | | | IP Address, File location, Script location
|
| | | | | | Source type ("I")
|
||||||
| | | Protocol ("UDP", "HTTP", "FILE", "EXT")
|
| | | | | Stream parameter
|
||||||
| | Parameters ("S" Sid scan, "P" Pid scan, "0" disable, "1" enable)
|
| | | | | UDP: multicast port
|
||||||
| Plugin ID ("IPTV")
|
| | | | | 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)
|
||||||
Unique enumeration
|
Unique enumeration
|
||||||
|
|
||||||
- UDP multicast rules for iptables firewall
|
- UDP multicast rules for iptables firewall
|
||||||
|
|
||||||
# Multicast UDP -packets
|
# Multicast UDP packets
|
||||||
iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT
|
iptables -A INPUT -i eth0 -p udp -d 224.0.0.0/4 --dport 1234 -j ACCEPT
|
||||||
|
|
||||||
# IGMP required by multicasts
|
# IGMP required by multicasts
|
||||||
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
|
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
|
||||||
|
|
||||||
|
# Default routing for multicast
|
||||||
|
route add -net 224.0.0.0 netmask 224.0.0.0 eth0
|
||||||
|
|
||||||
External streaming:
|
External streaming:
|
||||||
|
|
||||||
- To watch an externally received channel add an EXT entry to channels.conf
|
- To watch an externally received channel add an EXT entry to channels.conf
|
||||||
and specify a script name and parameter. The specified script is executed
|
and specify a script name and parameter. The specified script is executed
|
||||||
from plugin configuration directory when VDR tunes to the channel. The
|
from plugin resource directory when VDR tunes to the channel. The specified
|
||||||
specified script parameter is passed to the script and it can be used to
|
script parameter is passed to the script and it can be used to select for
|
||||||
select for example between different URLs.
|
example between different URLs.
|
||||||
|
|
||||||
- When an EXT channel is opened the IPTV plugin opens an UDP listening port
|
- 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
|
on the localhost. The external script is responsible for supplying IPTV
|
||||||
@@ -151,8 +144,7 @@ External streaming:
|
|||||||
devices can be used simultaneously.
|
devices can be used simultaneously.
|
||||||
|
|
||||||
- IPTV plugin includes an example script which uses VLC media player for
|
- IPTV plugin includes an example script which uses VLC media player for
|
||||||
receiving streams, transcoding and handing the result to IPTV plugin. The
|
receiving streams, transcoding and handing the result to IPTV plugin.
|
||||||
plugin was tested with VLC version 0.8.6c.
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
@@ -175,6 +167,26 @@ Notes:
|
|||||||
script and the iptvstream-notrap.sh script should be used instead in these
|
script and the iptvstream-notrap.sh script should be used instead in these
|
||||||
cases.
|
cases.
|
||||||
|
|
||||||
|
- If received MPEG-2 TS streams carry CA descriptors, you'll have to apply
|
||||||
|
"disable_ca_updates" patch to the VDR in order to get rid of "Channel not
|
||||||
|
available" messages.
|
||||||
|
|
||||||
|
- EIT scanning functionality can be disabled for all IPTV channels by applying
|
||||||
|
the "disable_eitscan" patch to the VDR.
|
||||||
|
|
||||||
|
- Section id and pid scanners should be disabled after the correct data is
|
||||||
|
found. This can be made via VDR's channel editor.
|
||||||
|
|
||||||
|
- Source-specific multicast (SSM) can be enabled by defining both the source
|
||||||
|
address and the group address separated by a '@' character. This will use
|
||||||
|
IGMP v3 protocol:
|
||||||
|
"U=<source address>@<group address>"
|
||||||
|
|
||||||
|
- The CURL implementation supports only HTTP/HTTPS protocols and an optional
|
||||||
|
netrc configuration file for authentication:
|
||||||
|
$(CONFDIR)/iptv/netrc
|
||||||
|
|
||||||
|
- CURL implementation
|
||||||
Acknowledgements:
|
Acknowledgements:
|
||||||
|
|
||||||
- The IPTV section filtering code is derived from Linux kernel.
|
- The IPTV section filtering code is derived from Linux kernel.
|
||||||
|
|||||||
53
common.c
53
common.c
@@ -5,58 +5,74 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <vdr/tools.h>
|
#include <vdr/tools.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
uint16_t ts_pid(const uint8_t *buf)
|
uint16_t ts_pid(const uint8_t *bufP)
|
||||||
{
|
{
|
||||||
return (uint16_t)(((buf[1] & 0x1f) << 8) + buf[2]);
|
return (uint16_t)(((bufP[1] & 0x1f) << 8) + bufP[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t payload(const uint8_t *tsp)
|
uint8_t payload(const uint8_t *bufP)
|
||||||
{
|
{
|
||||||
if (!(tsp[3] & 0x10)) // no payload?
|
if (!(bufP[3] & 0x10)) // no payload?
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (tsp[3] & 0x20) { // adaptation field?
|
if (bufP[3] & 0x20) { // adaptation field?
|
||||||
if (tsp[4] > 183) // corrupted data?
|
if (bufP[4] > 183) // corrupted data?
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return (uint8_t)((184 - 1) - tsp[4]);
|
return (uint8_t)((184 - 1) - bufP[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 184;
|
return 184;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *id_pid(const u_short Pid)
|
const char *id_pid(const u_short pidP)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
||||||
if (Pid == section_filter_table[i].pid)
|
if (pidP == section_filter_table[i].pid)
|
||||||
return section_filter_table[i].tag;
|
return section_filter_table[i].tag;
|
||||||
}
|
}
|
||||||
return "---";
|
return "---";
|
||||||
}
|
}
|
||||||
|
|
||||||
int select_single_desc(int descriptor, const int usecs, const bool selectWrite)
|
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP)
|
||||||
{
|
{
|
||||||
// Wait for data
|
// Wait for data
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = usecs;
|
tv.tv_usec = usecsP;
|
||||||
// Use select
|
// Use select
|
||||||
fd_set fds;
|
fd_set infd;
|
||||||
FD_ZERO(&fds);
|
fd_set outfd;
|
||||||
FD_SET(descriptor, &fds);
|
fd_set errfd;
|
||||||
int retval = 0;
|
FD_ZERO(&infd);
|
||||||
if (selectWrite)
|
FD_ZERO(&outfd);
|
||||||
retval = select(descriptor + 1, NULL, &fds, NULL, &tv);
|
FD_ZERO(&errfd);
|
||||||
|
FD_SET(descriptorP, &errfd);
|
||||||
|
if (selectWriteP)
|
||||||
|
FD_SET(descriptorP, &outfd);
|
||||||
else
|
else
|
||||||
retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
|
FD_SET(descriptorP, &infd);
|
||||||
|
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
|
||||||
// Check if error
|
// Check if error
|
||||||
ERROR_IF_RET(retval < 0, "select()", return retval);
|
ERROR_IF_RET(retval < 0, "select()", return retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cString ChangeCase(const cString &strP, bool upperP)
|
||||||
|
{
|
||||||
|
cString res(strP);
|
||||||
|
char *p = (char *)*res;
|
||||||
|
while (p && *p) {
|
||||||
|
*p = upperP ? toupper(*p) : tolower(*p);
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
|
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
|
||||||
{
|
{
|
||||||
/* description tag pid tid mask */
|
/* description tag pid tid mask */
|
||||||
@@ -68,4 +84,3 @@ const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE]
|
|||||||
{trNOOP("EIT (0x6X)"), "EIT", 0x12, 0x60, 0xF0},
|
{trNOOP("EIT (0x6X)"), "EIT", 0x12, 0x60, 0xF0},
|
||||||
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
|
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
27
common.h
27
common.h
@@ -14,33 +14,33 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define debug(x...) dsyslog("IPTV: " x);
|
#define debug(x...) dsyslog("IPTV: " x);
|
||||||
|
#define info(x...) isyslog("IPTV: " x);
|
||||||
#define error(x...) esyslog("ERROR: " x);
|
#define error(x...) esyslog("ERROR: " x);
|
||||||
#else
|
#else
|
||||||
#define debug(x...) ;
|
#define debug(x...) ;
|
||||||
|
#define info(x...) isyslog("IPTV: " x);
|
||||||
#define error(x...) esyslog("ERROR: " x);
|
#define error(x...) esyslog("ERROR: " x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef trNOOP
|
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#define trNOOP(s) (s)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef trVDR
|
|
||||||
#define trVDR(s) tr(s)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
|
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
|
||||||
|
|
||||||
|
#define IPTV_SOURCE_CHARACTER 'I'
|
||||||
|
|
||||||
#define IPTV_DEVICE_INFO_ALL 0
|
#define IPTV_DEVICE_INFO_ALL 0
|
||||||
#define IPTV_DEVICE_INFO_GENERAL 1
|
#define IPTV_DEVICE_INFO_GENERAL 1
|
||||||
#define IPTV_DEVICE_INFO_PIDS 2
|
#define IPTV_DEVICE_INFO_PIDS 2
|
||||||
#define IPTV_DEVICE_INFO_FILTERS 3
|
#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_PIDS_COUNT 10
|
||||||
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
|
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
|
||||||
|
|
||||||
#define SECTION_FILTER_TABLE_SIZE 7
|
#define SECTION_FILTER_TABLE_SIZE 7
|
||||||
|
|
||||||
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
|
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
|
||||||
do { \
|
do { \
|
||||||
if (exp) { \
|
if (exp) { \
|
||||||
char tmp[64]; \
|
char tmp[64]; \
|
||||||
@@ -66,10 +66,11 @@
|
|||||||
|
|
||||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
|
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||||
|
|
||||||
uint16_t ts_pid(const uint8_t *buf);
|
uint16_t ts_pid(const uint8_t *bufP);
|
||||||
uint8_t payload(const uint8_t *tsp);
|
uint8_t payload(const uint8_t *bufP);
|
||||||
const char *id_pid(const u_short Pid);
|
const char *id_pid(const u_short pidP);
|
||||||
int select_single_desc(int descriptor, const int usecs, const bool selectWrite);
|
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP);
|
||||||
|
cString ChangeCase(const cString &strP, bool upperP);
|
||||||
|
|
||||||
struct section_filter_table_type {
|
struct section_filter_table_type {
|
||||||
const char *description;
|
const char *description;
|
||||||
@@ -81,5 +82,7 @@ struct section_filter_table_type {
|
|||||||
|
|
||||||
extern const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE];
|
extern const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE];
|
||||||
|
|
||||||
|
extern const char VERSION[];
|
||||||
|
|
||||||
#endif // __IPTV_COMMON_H
|
#endif // __IPTV_COMMON_H
|
||||||
|
|
||||||
|
|||||||
32
config.c
32
config.c
@@ -10,38 +10,38 @@
|
|||||||
cIptvConfig IptvConfig;
|
cIptvConfig IptvConfig;
|
||||||
|
|
||||||
cIptvConfig::cIptvConfig(void)
|
cIptvConfig::cIptvConfig(void)
|
||||||
: tsBufferSize(2),
|
: tsBufferSizeM(2),
|
||||||
tsBufferPrefillRatio(0),
|
tsBufferPrefillRatioM(0),
|
||||||
extProtocolBasePort(4321),
|
extProtocolBasePortM(4321),
|
||||||
useBytes(1),
|
useBytesM(1),
|
||||||
sectionFiltering(1)
|
sectionFilteringM(1)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFilters); ++i)
|
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
|
||||||
disabledFilters[i] = -1;
|
disabledFiltersM[i] = -1;
|
||||||
memset(configDirectory, '\0', sizeof(configDirectory));
|
memset(configDirectoryM, 0, sizeof(configDirectoryM));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
|
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
|
||||||
{
|
{
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
while ((n < ARRAY_SIZE(disabledFilters) && (disabledFilters[n] != -1)))
|
while ((n < ARRAY_SIZE(disabledFiltersM) && (disabledFiltersM[n] != -1)))
|
||||||
n++;
|
n++;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvConfig::GetDisabledFilters(unsigned int Index) const
|
int cIptvConfig::GetDisabledFilters(unsigned int indexP) const
|
||||||
{
|
{
|
||||||
return (Index < ARRAY_SIZE(disabledFilters)) ? disabledFilters[Index] : -1;
|
return (indexP < ARRAY_SIZE(disabledFiltersM)) ? disabledFiltersM[indexP] : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvConfig::SetDisabledFilters(unsigned int Index, int Number)
|
void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP)
|
||||||
{
|
{
|
||||||
if (Index < ARRAY_SIZE(disabledFilters))
|
if (indexP < ARRAY_SIZE(disabledFiltersM))
|
||||||
disabledFilters[Index] = Number;
|
disabledFiltersM[indexP] = numberP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvConfig::SetConfigDirectory(const char *directoryP)
|
void cIptvConfig::SetConfigDirectory(const char *directoryP)
|
||||||
{
|
{
|
||||||
debug("cIptvConfig::SetConfigDirectory(%s)", directoryP);
|
debug("cIptvConfig::%s(%s)", __FUNCTION__, directoryP);
|
||||||
strn0cpy(configDirectory, directoryP, sizeof(configDirectory));
|
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
|
||||||
}
|
}
|
||||||
|
|||||||
40
config.h
40
config.h
@@ -14,30 +14,30 @@
|
|||||||
class cIptvConfig
|
class cIptvConfig
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
unsigned int tsBufferSize;
|
unsigned int tsBufferSizeM;
|
||||||
unsigned int tsBufferPrefillRatio;
|
unsigned int tsBufferPrefillRatioM;
|
||||||
unsigned int extProtocolBasePort;
|
unsigned int extProtocolBasePortM;
|
||||||
unsigned int useBytes;
|
unsigned int useBytesM;
|
||||||
unsigned int sectionFiltering;
|
unsigned int sectionFilteringM;
|
||||||
int disabledFilters[SECTION_FILTER_TABLE_SIZE];
|
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE];
|
||||||
char configDirectory[255];
|
char configDirectoryM[PATH_MAX];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvConfig();
|
cIptvConfig();
|
||||||
unsigned int GetTsBufferSize(void) const { return tsBufferSize; }
|
unsigned int GetTsBufferSize(void) const { return tsBufferSizeM; }
|
||||||
unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatio; }
|
unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatioM; }
|
||||||
unsigned int GetExtProtocolBasePort(void) const { return extProtocolBasePort; }
|
unsigned int GetExtProtocolBasePort(void) const { return extProtocolBasePortM; }
|
||||||
unsigned int GetUseBytes(void) const { return useBytes; }
|
unsigned int GetUseBytes(void) const { return useBytesM; }
|
||||||
unsigned int GetSectionFiltering(void) const { return sectionFiltering; }
|
unsigned int GetSectionFiltering(void) const { return sectionFilteringM; }
|
||||||
const char *GetConfigDirectory(void) const { return configDirectory; }
|
const char *GetConfigDirectory(void) const { return configDirectoryM; }
|
||||||
unsigned int GetDisabledFiltersCount(void) const;
|
unsigned int GetDisabledFiltersCount(void) const;
|
||||||
int GetDisabledFilters(unsigned int Index) const;
|
int GetDisabledFilters(unsigned int indexP) const;
|
||||||
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
|
void SetTsBufferSize(unsigned int sizeP) { tsBufferSizeM = sizeP; }
|
||||||
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
|
void SetTsBufferPrefillRatio(unsigned int ratioP) { tsBufferPrefillRatioM = ratioP; }
|
||||||
void SetExtProtocolBasePort(unsigned int PortNumber) { extProtocolBasePort = PortNumber; }
|
void SetExtProtocolBasePort(unsigned int portNumberP) { extProtocolBasePortM = portNumberP; }
|
||||||
void SetUseBytes(unsigned int On) { useBytes = On; }
|
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
|
||||||
void SetSectionFiltering(unsigned int On) { sectionFiltering = On; }
|
void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; }
|
||||||
void SetDisabledFilters(unsigned int Index, int Number);
|
void SetDisabledFilters(unsigned int indexP, int numberP);
|
||||||
void SetConfigDirectory(const char *directoryP);
|
void SetConfigDirectory(const char *directoryP);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
492
device.c
492
device.c
@@ -6,112 +6,110 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "source.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
#define IPTV_MAX_DEVICES MAXDEVICES
|
#define IPTV_MAX_DEVICES MAXDEVICES
|
||||||
|
|
||||||
static cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL };
|
static cIptvDevice * IptvDevicesS[IPTV_MAX_DEVICES] = { NULL };
|
||||||
|
|
||||||
unsigned int cIptvDevice::deviceCount = 0;
|
cIptvDevice::cIptvDevice(unsigned int indexP)
|
||||||
|
: deviceIndexM(indexP),
|
||||||
cIptvDevice::cIptvDevice(unsigned int Index)
|
dvrFdM(-1),
|
||||||
: deviceIndex(Index),
|
isPacketDeliveredM(false),
|
||||||
dvrFd(-1),
|
isOpenDvrM(false),
|
||||||
isPacketDelivered(false),
|
sidScanEnabledM(false),
|
||||||
isOpenDvr(false),
|
pidScanEnabledM(false),
|
||||||
sidScanEnabled(false),
|
channelIdM(tChannelID::InvalidID)
|
||||||
pidScanEnabled(false)
|
|
||||||
{
|
{
|
||||||
unsigned int bufsize = MEGABYTE(IptvConfig.GetTsBufferSize());
|
unsigned int bufsize = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize());
|
||||||
bufsize -= (bufsize % TS_SIZE);
|
bufsize -= (bufsize % TS_SIZE);
|
||||||
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndex, CardIndex());
|
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex());
|
||||||
tsBuffer = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
|
tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
|
||||||
*cString::sprintf("IPTV %d", deviceIndex));
|
*cString::sprintf("IPTV %d", deviceIndexM));
|
||||||
tsBuffer->SetTimeouts(10, 10);
|
tsBufferM->SetTimeouts(10, 10);
|
||||||
ResetBuffering();
|
ResetBuffering();
|
||||||
pUdpProtocol = new cIptvProtocolUdp();
|
pUdpProtocolM = new cIptvProtocolUdp();
|
||||||
pHttpProtocol = new cIptvProtocolHttp();
|
pCurlProtocolM = new cIptvProtocolCurl();
|
||||||
pFileProtocol = new cIptvProtocolFile();
|
pHttpProtocolM = new cIptvProtocolHttp();
|
||||||
pExtProtocol = new cIptvProtocolExt();
|
pFileProtocolM = new cIptvProtocolFile();
|
||||||
pIptvStreamer = new cIptvStreamer(tsBuffer, (100 * TS_SIZE));
|
pExtProtocolM = new cIptvProtocolExt();
|
||||||
pPidScanner = new cPidScanner;
|
pIptvStreamerM = new cIptvStreamer(tsBufferM, (100 * TS_SIZE));
|
||||||
|
pPidScannerM = new cPidScanner();
|
||||||
// Initialize filter pointers
|
// Initialize filter pointers
|
||||||
memset(secfilters, '\0', sizeof(secfilters));
|
memset(secFiltersM, 0, sizeof(secFiltersM));
|
||||||
// Start section handler for iptv device
|
// Start section handler for iptv device
|
||||||
StartSectionHandler();
|
StartSectionHandler();
|
||||||
// Sid scanner must be created after the section handler
|
// Sid scanner must be created after the section handler
|
||||||
pSidScanner = new cSidScanner;
|
AttachFilter(pSidScannerM = new cSidScanner());
|
||||||
if (pSidScanner)
|
|
||||||
AttachFilter(pSidScanner);
|
|
||||||
// Check if dvr fifo exists
|
// Check if dvr fifo exists
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndex);
|
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndexM);
|
||||||
stat(filename, &sb);
|
stat(filename, &sb);
|
||||||
if (S_ISFIFO(sb.st_mode)) {
|
if (S_ISFIFO(sb.st_mode)) {
|
||||||
dvrFd = open(filename, O_RDWR | O_NONBLOCK);
|
dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
|
||||||
if (dvrFd >= 0)
|
if (dvrFdM >= 0)
|
||||||
dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndex, *filename);
|
dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvDevice::~cIptvDevice()
|
cIptvDevice::~cIptvDevice()
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::~cIptvDevice(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
DELETE_POINTER(pIptvStreamerM);
|
||||||
|
DELETE_POINTER(pUdpProtocolM);
|
||||||
|
DELETE_POINTER(pCurlProtocolM);
|
||||||
|
DELETE_POINTER(pHttpProtocolM);
|
||||||
|
DELETE_POINTER(pFileProtocolM);
|
||||||
|
DELETE_POINTER(pExtProtocolM);
|
||||||
|
DELETE_POINTER(tsBufferM);
|
||||||
|
DELETE_POINTER(pPidScannerM);
|
||||||
|
DELETE_POINTER(pSidScannerM);
|
||||||
// Stop section handler of iptv device
|
// Stop section handler of iptv device
|
||||||
StopSectionHandler();
|
StopSectionHandler();
|
||||||
DELETE_POINTER(pIptvStreamer);
|
|
||||||
DELETE_POINTER(pUdpProtocol);
|
|
||||||
DELETE_POINTER(pHttpProtocol);
|
|
||||||
DELETE_POINTER(pFileProtocol);
|
|
||||||
DELETE_POINTER(pExtProtocol);
|
|
||||||
DELETE_POINTER(tsBuffer);
|
|
||||||
DELETE_POINTER(pPidScanner);
|
|
||||||
// Detach and destroy sid filter
|
|
||||||
if (pSidScanner) {
|
|
||||||
Detach(pSidScanner);
|
|
||||||
DELETE_POINTER(pSidScanner);
|
|
||||||
}
|
|
||||||
// Destroy all filters
|
// Destroy all filters
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
for (int i = 0; i < eMaxSecFilterCount; ++i)
|
for (int i = 0; i < eMaxSecFilterCount; ++i)
|
||||||
DeleteFilter(i);
|
DeleteFilter(i);
|
||||||
// Close dvr fifo
|
// Close dvr fifo
|
||||||
if (dvrFd >= 0) {
|
if (dvrFdM >= 0) {
|
||||||
int fd = dvrFd;
|
int fd = dvrFdM;
|
||||||
dvrFd = -1;
|
dvrFdM = -1;
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::Initialize(unsigned int DeviceCount)
|
bool cIptvDevice::Initialize(unsigned int deviceCountP)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::Initialize(): DeviceCount=%d\n", DeviceCount);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceCountP);
|
||||||
if (DeviceCount > IPTV_MAX_DEVICES)
|
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
|
||||||
DeviceCount = IPTV_MAX_DEVICES;
|
if (deviceCountP > IPTV_MAX_DEVICES)
|
||||||
for (unsigned int i = 0; i < DeviceCount; ++i)
|
deviceCountP = IPTV_MAX_DEVICES;
|
||||||
IptvDevices[i] = new cIptvDevice(i);
|
for (unsigned int i = 0; i < deviceCountP; ++i)
|
||||||
for (unsigned int i = DeviceCount; i < IPTV_MAX_DEVICES; ++i)
|
IptvDevicesS[i] = new cIptvDevice(i);
|
||||||
IptvDevices[i] = NULL;
|
for (unsigned int i = deviceCountP; i < IPTV_MAX_DEVICES; ++i)
|
||||||
|
IptvDevicesS[i] = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cIptvDevice::Count(void)
|
unsigned int cIptvDevice::Count(void)
|
||||||
{
|
{
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
debug("cIptvDevice::Count()\n");
|
debug("cIptvDevice::%s()", __FUNCTION__);
|
||||||
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
||||||
if (IptvDevices[i] != NULL)
|
if (IptvDevicesS[i] != NULL)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
|
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetIptvDevice(%d)\n", CardIndex);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, cardIndexP);
|
||||||
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
||||||
if ((IptvDevices[i] != NULL) && (IptvDevices[i]->CardIndex() == CardIndex)) {
|
if ((IptvDevicesS[i] != NULL) && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
|
||||||
//debug("cIptvDevice::GetIptvDevice(%d): FOUND!\n", CardIndex);
|
//debug("cIptvDevice::%s(%d): found!", __FUNCTION__, cardIndexP);
|
||||||
return IptvDevices[i];
|
return IptvDevicesS[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -119,305 +117,331 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
|
|||||||
|
|
||||||
cString cIptvDevice::GetGeneralInformation(void)
|
cString cIptvDevice::GetGeneralInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
|
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
|
||||||
deviceIndex, CardIndex(),
|
deviceIndexM, CardIndex(),
|
||||||
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
|
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "",
|
||||||
pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
|
pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "",
|
||||||
*GetBufferStatistic(),
|
*GetBufferStatistic(),
|
||||||
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
|
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetPidsInformation(void)
|
cString cIptvDevice::GetPidsInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return GetPidStatistic();
|
return GetPidStatistic();
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetFiltersInformation(void)
|
cString cIptvDevice::GetFiltersInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetFiltersInformation(%d)\n", deviceIndex);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
cString info("Active section filters:\n");
|
cString s("Active section filters:\n");
|
||||||
// loop through active section filters
|
// loop through active section filters
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (secfilters[i]) {
|
if (secFiltersM[i]) {
|
||||||
info = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *info, i,
|
s = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *s, i,
|
||||||
*secfilters[i]->GetSectionStatistic(), secfilters[i]->GetPid(),
|
*secFiltersM[i]->GetSectionStatistic(), secFiltersM[i]->GetPid(),
|
||||||
id_pid(secfilters[i]->GetPid()));
|
id_pid(secFiltersM[i]->GetPid()));
|
||||||
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
|
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetInformation(unsigned int Page)
|
cString cIptvDevice::GetInformation(unsigned int pageP)
|
||||||
{
|
{
|
||||||
// generate information string
|
// generate information string
|
||||||
cString info;
|
cString s;
|
||||||
switch (Page) {
|
switch (pageP) {
|
||||||
case IPTV_DEVICE_INFO_GENERAL:
|
case IPTV_DEVICE_INFO_GENERAL:
|
||||||
info = GetGeneralInformation();
|
s = GetGeneralInformation();
|
||||||
break;
|
break;
|
||||||
case IPTV_DEVICE_INFO_PIDS:
|
case IPTV_DEVICE_INFO_PIDS:
|
||||||
info = GetPidsInformation();
|
s = GetPidsInformation();
|
||||||
break;
|
break;
|
||||||
case IPTV_DEVICE_INFO_FILTERS:
|
case IPTV_DEVICE_INFO_FILTERS:
|
||||||
info = GetFiltersInformation();
|
s = GetFiltersInformation();
|
||||||
|
break;
|
||||||
|
case IPTV_DEVICE_INFO_PROTOCOL:
|
||||||
|
s = pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "";
|
||||||
|
break;
|
||||||
|
case IPTV_DEVICE_INFO_BITRATE:
|
||||||
|
s = pIptvStreamerM ? *pIptvStreamerM->GetStreamerStatistic() : "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
info = cString::sprintf("%s%s%s",
|
s = cString::sprintf("%s%s%s",
|
||||||
*GetGeneralInformation(),
|
*GetGeneralInformation(),
|
||||||
*GetPidsInformation(),
|
*GetPidsInformation(),
|
||||||
*GetFiltersInformation());
|
*GetFiltersInformation());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol)
|
cString cIptvDevice::DeviceType(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
char *tag = NULL;
|
return "IPTV";
|
||||||
char *proto = NULL;
|
|
||||||
char *loc = NULL;
|
|
||||||
if (sscanf(IptvParam, "%a[^|]|S%dP%d|%a[^|]|%a[^|]|%u", &tag, SidScan, PidScan, &proto, &loc, Parameter) == 6) {
|
|
||||||
cString tagstr(tag, true);
|
|
||||||
cString protostr(proto, true);
|
|
||||||
cString locstr(loc, true);
|
|
||||||
// check if IPTV tag
|
|
||||||
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
|
|
||||||
// check if protocol is supported and update the pointer
|
|
||||||
if (strncasecmp(*protostr, "UDP", 3) == 0)
|
|
||||||
*Protocol = pUdpProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
|
|
||||||
*Protocol = pHttpProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "FILE", 4) == 0)
|
|
||||||
*Protocol = pFileProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "EXT", 3) == 0)
|
|
||||||
*Protocol = pExtProtocol;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
// return location
|
|
||||||
return locstr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sscanf(IptvParam, "%a[^|]|P%dS%d|%a[^|]|%a[^|]|%u", &tag, PidScan, SidScan, &proto, &loc, Parameter) == 6) {
|
|
||||||
cString tagstr(tag, true);
|
|
||||||
cString protostr(proto, true);
|
|
||||||
cString locstr(loc, true);
|
|
||||||
// check if IPTV tag
|
|
||||||
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
|
|
||||||
// check if protocol is supported and update the pointer
|
|
||||||
if (strncasecmp(*protostr, "UDP", 3) == 0)
|
|
||||||
*Protocol = pUdpProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
|
|
||||||
*Protocol = pHttpProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "FILE", 4) == 0)
|
|
||||||
*Protocol = pFileProtocol;
|
|
||||||
else if (strncasecmp(*protostr, "EXT", 3) == 0)
|
|
||||||
*Protocol = pExtProtocol;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
// return location
|
|
||||||
return locstr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesIptv(const char *Param) const
|
cString cIptvDevice::DeviceName(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ProvidesIptv(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (strncasecmp(Param, "IPTV", 4) == 0);
|
return cString::sprintf("IPTV %d", deviceIndexM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesSource(int Source) const
|
int cIptvDevice::SignalStrength(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (cSource::IsPlug(Source));
|
return (100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const
|
int cIptvDevice::SignalQuality(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (ProvidesSource(Channel->Source()) && ProvidesIptv(Channel->PluginParam()));
|
return (100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
|
bool cIptvDevice::ProvidesSource(int sourceP) const
|
||||||
|
{
|
||||||
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const
|
||||||
|
{
|
||||||
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
return (ProvidesSource(channelP->Source()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool *needsDetachReceiversP) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
|
||||||
bool needsDetachReceivers = false;
|
bool needsDetachReceivers = false;
|
||||||
|
|
||||||
debug("cIptvDevice::ProvidesChannel(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (ProvidesTransponder(Channel))
|
|
||||||
result = true;
|
if (channelP && ProvidesTransponder(channelP)) {
|
||||||
if (NeedsDetachReceivers)
|
result = hasPriority;
|
||||||
*NeedsDetachReceivers = needsDetachReceivers;
|
if (Receiving()) {
|
||||||
|
if (channelP->GetChannelID() == channelIdM)
|
||||||
|
result = true;
|
||||||
|
else
|
||||||
|
needsDetachReceivers = Receiving();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needsDetachReceiversP)
|
||||||
|
*needsDetachReceiversP = needsDetachReceivers;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cIptvDevice::ProvidesEIT(void) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int cIptvDevice::NumProvidedSystems(void) const
|
int cIptvDevice::NumProvidedSystems(void) const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
|
bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
|
||||||
{
|
{
|
||||||
int parameter, sidscan, pidscan;
|
|
||||||
cString location;
|
|
||||||
cIptvProtocolIf *protocol;
|
cIptvProtocolIf *protocol;
|
||||||
|
cIptvTransponderParameters itp(channelP->Parameters());
|
||||||
|
|
||||||
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
location = GetChannelSettings(Channel->PluginParam(), ¶meter, &sidscan, &pidscan, &protocol);
|
|
||||||
if (isempty(location)) {
|
if (isempty(itp.Address())) {
|
||||||
error("Unrecognized IPTV channel settings: %s", Channel->PluginParam());
|
error("Unrecognized IPTV address: %s", channelP->Parameters());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sidScanEnabled = sidscan ? true : false;
|
switch (itp.Protocol()) {
|
||||||
pidScanEnabled = pidscan ? true : false;
|
case cIptvTransponderParameters::eProtocolUDP:
|
||||||
if (pIptvStreamer->Set(location, parameter, deviceIndex, protocol)) {
|
protocol = pUdpProtocolM;
|
||||||
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
|
break;
|
||||||
pSidScanner->SetChannel(Channel);
|
case cIptvTransponderParameters::eProtocolCURL:
|
||||||
if (pidScanEnabled && pPidScanner)
|
protocol = pCurlProtocolM;
|
||||||
pPidScanner->SetChannel(Channel);
|
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->Set(itp.Address(), itp.Parameter(), deviceIndexM, protocol)) {
|
||||||
|
channelIdM = channelP->GetChannelID();
|
||||||
|
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
|
||||||
|
pSidScannerM->SetChannel(channelIdM);
|
||||||
|
if (pidScanEnabledM && pPidScannerM)
|
||||||
|
pPidScannerM->SetChannel(channelIdM);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
|
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndex, Handle->pid, Type, On);
|
debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP->pid, typeP, onP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::DeleteFilter(unsigned int Index)
|
bool cIptvDevice::DeleteFilter(unsigned int indexP)
|
||||||
{
|
{
|
||||||
if ((Index < eMaxSecFilterCount) && secfilters[Index]) {
|
if ((indexP < eMaxSecFilterCount) && secFiltersM[indexP]) {
|
||||||
//debug("cIptvDevice::DeleteFilter(%d) Index=%d\n", deviceIndex, Index);
|
//debug("cIptvDevice::%s(%d): index=%d", __FUNCTION__, deviceIndexM, indexP);
|
||||||
cIptvSectionFilter *tmp = secfilters[Index];
|
cIptvSectionFilter *tmp = secFiltersM[indexP];
|
||||||
secfilters[Index] = NULL;
|
secFiltersM[indexP] = NULL;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const
|
bool cIptvDevice::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::IsBlackListed(%d) Pid=%d Tid=%02X Mask=%02X\n", deviceIndex, Pid, Tid, Mask);
|
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X", __FUNCTION__, deviceIndexM, pidP, tidP, maskP);
|
||||||
// loop through section filter table
|
// loop through section filter table
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
||||||
int index = IptvConfig.GetDisabledFilters(i);
|
int index = IptvConfig.GetDisabledFilters(i);
|
||||||
// check if matches
|
// Check if matches
|
||||||
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
|
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
|
||||||
(section_filter_table[index].pid == Pid) && (section_filter_table[index].tid == Tid) &&
|
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
|
||||||
(section_filter_table[index].mask == Mask)) {
|
(section_filter_table[index].mask == maskP)) {
|
||||||
//debug("cIptvDevice::IsBlackListed(%d) Found=%s\n", deviceIndex, section_filter_table[index].description);
|
//debug("cIptvDevice::%s(%d): found %s", __FUNCTION__, deviceIndexM, section_filter_table[index].description);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
|
int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
|
||||||
{
|
{
|
||||||
// Check if disabled by user
|
// Check if disabled by user
|
||||||
if (!IptvConfig.GetSectionFiltering())
|
if (!IptvConfig.GetSectionFiltering())
|
||||||
return -1;
|
return -1;
|
||||||
// Blacklist check, refuse certain filters
|
|
||||||
if (IsBlackListed(Pid, Tid, Mask))
|
|
||||||
return -1;
|
|
||||||
// Lock
|
// Lock
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
// Blacklist check, refuse certain filters
|
||||||
|
if (IsBlackListed(pidP, tidP, maskP))
|
||||||
|
return -1;
|
||||||
// Search the next free filter slot
|
// Search the next free filter slot
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (!secfilters[i]) {
|
if (!secFiltersM[i]) {
|
||||||
//debug("cIptvDevice::OpenFilter(%d): Pid=%d Tid=%02X Mask=%02X Index=%d\n", deviceIndex, Pid, Tid, Mask, i);
|
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X index=%d", __FUNCTION__, deviceIndexM, pidP, tidP, maskP, i);
|
||||||
secfilters[i] = new cIptvSectionFilter(deviceIndex, i, Pid, Tid, Mask);
|
secFiltersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
|
||||||
return secfilters[i]->GetReadDesc();
|
if (secFiltersM[i])
|
||||||
|
return i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No free filter slot found
|
// No free filter slot found
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvDevice::CloseFilter(int Handle)
|
int cIptvDevice::ReadFilter(int handleP, void *bufferP, size_t lengthP)
|
||||||
{
|
{
|
||||||
// Lock
|
// Lock
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
// Search the filter for deletion
|
// ... and load
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
if (secFiltersM[handleP]) {
|
||||||
if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) {
|
return secFiltersM[handleP]->Read(bufferP, lengthP);
|
||||||
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
|
//debug("cIptvDevice::%s(%d): handle=%d length=%d", __FUNCTION__, deviceIndexM, handleP, lengthP);
|
||||||
DeleteFilter(i);
|
}
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void cIptvDevice::CloseFilter(int handleP)
|
||||||
|
{
|
||||||
|
// Lock
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
// ... and load
|
||||||
|
if (secFiltersM[handleP]) {
|
||||||
|
//debug("cIptvDevice::%s(%d): handle=%d", __FUNCTION__, deviceIndexM, handleP);
|
||||||
|
DeleteFilter(handleP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::OpenDvr(void)
|
bool cIptvDevice::OpenDvr(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::OpenDvr(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
isPacketDelivered = false;
|
isPacketDeliveredM = false;
|
||||||
tsBuffer->Clear();
|
tsBufferM->Clear();
|
||||||
ResetBuffering();
|
ResetBuffering();
|
||||||
if (pIptvStreamer)
|
if (pIptvStreamerM)
|
||||||
pIptvStreamer->Open();
|
pIptvStreamerM->Open();
|
||||||
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
|
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
|
||||||
pSidScanner->Open();
|
pSidScannerM->Open();
|
||||||
isOpenDvr = true;
|
isOpenDvrM = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvDevice::CloseDvr(void)
|
void cIptvDevice::CloseDvr(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
|
if (sidScanEnabledM && pSidScannerM )
|
||||||
pSidScanner->Close();
|
pSidScannerM->Close();
|
||||||
if (pIptvStreamer)
|
if (pIptvStreamerM)
|
||||||
pIptvStreamer->Close();
|
pIptvStreamerM->Close();
|
||||||
isOpenDvr = false;
|
isOpenDvrM = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::HasLock(int TimeoutMs)
|
bool cIptvDevice::HasLock(int timeoutMsP) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::HasLock(%d): %d\n", deviceIndex, TimeoutMs);
|
//debug("cIptvDevice::%s(%d): timeoutMs=%d", __FUNCTION__, deviceIndexM, timeoutMsP);
|
||||||
return (!IsBuffering());
|
return (!IsBuffering());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cIptvDevice::HasInternalCam(void)
|
||||||
|
{
|
||||||
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void cIptvDevice::ResetBuffering(void)
|
void cIptvDevice::ResetBuffering(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndex);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
// pad prefill to multiple of TS_SIZE
|
// Pad prefill to multiple of TS_SIZE
|
||||||
tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
tsBufferPrefillM = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
||||||
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
||||||
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
|
tsBufferPrefillM -= (tsBufferPrefillM % TS_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::IsBuffering(void)
|
bool cIptvDevice::IsBuffering(void) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::IsBuffering(%d): %d\n", deviceIndex);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (tsBufferPrefill && tsBuffer->Available() < tsBufferPrefill)
|
if (tsBufferPrefillM && tsBufferM && tsBufferM->Available() < tsBufferPrefillM)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
tsBufferPrefill = 0;
|
tsBufferPrefillM = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::GetTSPacket(uchar *&Data)
|
bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||||
{
|
{
|
||||||
int Count = 0;
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
|
if (tsBufferM && !IsBuffering()) {
|
||||||
if (tsBuffer && !IsBuffering()) {
|
if (isPacketDeliveredM) {
|
||||||
if (isPacketDelivered) {
|
tsBufferM->Del(TS_SIZE);
|
||||||
tsBuffer->Del(TS_SIZE);
|
isPacketDeliveredM = false;
|
||||||
isPacketDelivered = false;
|
|
||||||
// Update buffer statistics
|
// Update buffer statistics
|
||||||
AddBufferStatistic(TS_SIZE, tsBuffer->Available());
|
AddBufferStatistic(TS_SIZE, tsBufferM->Available());
|
||||||
}
|
}
|
||||||
uchar *p = tsBuffer->Get(Count);
|
int Count = 0;
|
||||||
|
uchar *p = tsBufferM->Get(Count);
|
||||||
if (p && Count >= TS_SIZE) {
|
if (p && Count >= TS_SIZE) {
|
||||||
if (*p != TS_SYNC_BYTE) {
|
if (*p != TS_SYNC_BYTE) {
|
||||||
for (int i = 1; i < Count; i++) {
|
for (int i = 1; i < Count; i++) {
|
||||||
@@ -426,26 +450,26 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tsBuffer->Del(Count);
|
tsBufferM->Del(Count);
|
||||||
error("Skipped %d bytes to sync on TS packet\n", Count);
|
error("Skipped %d bytes to sync on TS packet\n", Count);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
isPacketDelivered = true;
|
isPacketDeliveredM = true;
|
||||||
Data = p;
|
Data = p;
|
||||||
// Update pid statistics
|
// Update pid statistics
|
||||||
AddPidStatistic(ts_pid(p), payload(p));
|
AddPidStatistic(ts_pid(p), payload(p));
|
||||||
// Send data also to dvr fifo
|
// Send data also to dvr fifo
|
||||||
if (dvrFd >= 0)
|
if (dvrFdM >= 0)
|
||||||
Count = (int)write(dvrFd, p, TS_SIZE);
|
Count = (int)write(dvrFdM, p, TS_SIZE);
|
||||||
// Analyze incomplete streams with built-in pid analyzer
|
// Analyze incomplete streams with built-in pid analyzer
|
||||||
if (pidScanEnabled && pPidScanner)
|
if (pidScanEnabledM && pPidScannerM)
|
||||||
pPidScanner->Process(p);
|
pPidScannerM->Process(p);
|
||||||
// Lock
|
// Lock
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
// Run the data through all filters
|
// Run the data through all filters
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (secfilters[i])
|
if (secFiltersM[i])
|
||||||
secfilters[i]->Process(p);
|
secFiltersM[i]->Process(p);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
80
device.h
80
device.h
@@ -11,6 +11,7 @@
|
|||||||
#include <vdr/device.h>
|
#include <vdr/device.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "protocoludp.h"
|
#include "protocoludp.h"
|
||||||
|
#include "protocolcurl.h"
|
||||||
#include "protocolhttp.h"
|
#include "protocolhttp.h"
|
||||||
#include "protocolfile.h"
|
#include "protocolfile.h"
|
||||||
#include "protocolext.h"
|
#include "protocolext.h"
|
||||||
@@ -33,29 +34,31 @@ private:
|
|||||||
enum {
|
enum {
|
||||||
eMaxSecFilterCount = 32
|
eMaxSecFilterCount = 32
|
||||||
};
|
};
|
||||||
unsigned int deviceIndex;
|
unsigned int deviceIndexM;
|
||||||
int dvrFd;
|
int dvrFdM;
|
||||||
bool isPacketDelivered;
|
bool isPacketDeliveredM;
|
||||||
bool isOpenDvr;
|
bool isOpenDvrM;
|
||||||
bool sidScanEnabled;
|
bool sidScanEnabledM;
|
||||||
bool pidScanEnabled;
|
bool pidScanEnabledM;
|
||||||
cRingBufferLinear *tsBuffer;
|
cRingBufferLinear *tsBufferM;
|
||||||
int tsBufferPrefill;
|
mutable int tsBufferPrefillM;
|
||||||
cIptvProtocolUdp *pUdpProtocol;
|
tChannelID channelIdM;
|
||||||
cIptvProtocolHttp *pHttpProtocol;
|
cIptvProtocolUdp *pUdpProtocolM;
|
||||||
cIptvProtocolFile *pFileProtocol;
|
cIptvProtocolCurl *pCurlProtocolM;
|
||||||
cIptvProtocolExt *pExtProtocol;
|
cIptvProtocolHttp *pHttpProtocolM;
|
||||||
cIptvStreamer *pIptvStreamer;
|
cIptvProtocolFile *pFileProtocolM;
|
||||||
cPidScanner *pPidScanner;
|
cIptvProtocolExt *pExtProtocolM;
|
||||||
cSidScanner *pSidScanner;
|
cIptvStreamer *pIptvStreamerM;
|
||||||
cMutex mutex;
|
cPidScanner *pPidScannerM;
|
||||||
cIptvSectionFilter* secfilters[eMaxSecFilterCount];
|
cSidScanner *pSidScannerM;
|
||||||
|
cMutex mutexM;
|
||||||
|
cIptvSectionFilter *secFiltersM[eMaxSecFilterCount];
|
||||||
|
|
||||||
// constructor & destructor
|
// constructor & destructor
|
||||||
public:
|
public:
|
||||||
cIptvDevice(unsigned int DeviceIndex);
|
cIptvDevice(unsigned int deviceIndexP);
|
||||||
virtual ~cIptvDevice();
|
virtual ~cIptvDevice();
|
||||||
cString GetInformation(unsigned int Page = IPTV_DEVICE_INFO_ALL);
|
cString GetInformation(unsigned int pageP = IPTV_DEVICE_INFO_ALL);
|
||||||
|
|
||||||
// copy and assignment constructors
|
// copy and assignment constructors
|
||||||
private:
|
private:
|
||||||
@@ -69,37 +72,48 @@ private:
|
|||||||
|
|
||||||
// for channel parsing & buffering
|
// for channel parsing & buffering
|
||||||
private:
|
private:
|
||||||
cString GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol);
|
|
||||||
bool ProvidesIptv(const char *Param) const;
|
|
||||||
void ResetBuffering(void);
|
void ResetBuffering(void);
|
||||||
bool IsBuffering(void);
|
bool IsBuffering(void) const;
|
||||||
bool DeleteFilter(unsigned int Index);
|
bool DeleteFilter(unsigned int indexP);
|
||||||
bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const;
|
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
|
||||||
|
|
||||||
|
// for channel info
|
||||||
|
public:
|
||||||
|
virtual cString DeviceType(void) const;
|
||||||
|
virtual cString DeviceName(void) const;
|
||||||
|
virtual int SignalStrength(void) const;
|
||||||
|
virtual int SignalQuality(void) const;
|
||||||
|
|
||||||
// for channel selection
|
// for channel selection
|
||||||
public:
|
public:
|
||||||
virtual bool ProvidesSource(int Source) const;
|
virtual bool ProvidesSource(int sourceP) const;
|
||||||
virtual bool ProvidesTransponder(const cChannel *Channel) const;
|
virtual bool ProvidesTransponder(const cChannel *channelP) const;
|
||||||
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) 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 int NumProvidedSystems(void) const;
|
||||||
protected:
|
protected:
|
||||||
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
|
virtual bool SetChannelDevice(const cChannel *channelP, bool liveViewP);
|
||||||
|
|
||||||
// for recording
|
// for recording
|
||||||
protected:
|
protected:
|
||||||
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
|
virtual bool SetPid(cPidHandle *handleP, int typeP, bool onP);
|
||||||
virtual bool OpenDvr(void);
|
virtual bool OpenDvr(void);
|
||||||
virtual void CloseDvr(void);
|
virtual void CloseDvr(void);
|
||||||
virtual bool GetTSPacket(uchar *&Data);
|
virtual bool GetTSPacket(uchar *&dataP);
|
||||||
|
|
||||||
// for section filtering
|
// for section filtering
|
||||||
public:
|
public:
|
||||||
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
|
virtual int OpenFilter(u_short pidP, u_char tidP, u_char maskP);
|
||||||
virtual void CloseFilter(int Handle);
|
virtual int ReadFilter(int handleP, void *bufferP, size_t lengthP);
|
||||||
|
virtual void CloseFilter(int handleP);
|
||||||
|
|
||||||
// for transponder lock
|
// for transponder lock
|
||||||
public:
|
public:
|
||||||
virtual bool HasLock(int);
|
virtual bool HasLock(int timeoutMsP) const;
|
||||||
|
|
||||||
|
// for common interface
|
||||||
|
public:
|
||||||
|
virtual bool HasInternalCam(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __IPTV_DEVICE_H
|
#endif // __IPTV_DEVICE_H
|
||||||
|
|||||||
126
iptv.c
126
iptv.c
@@ -11,22 +11,23 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
#include "iptvservice.h"
|
||||||
|
|
||||||
#ifndef PLUGINPARAMPATCHVERSNUM
|
#if defined(APIVERSNUM) && APIVERSNUM < 10738
|
||||||
#error "You must apply the pluginparam patch for VDR!"
|
#error "VDR-1.7.38 API version or greater is required!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM < 10600
|
#ifndef GITVERSION
|
||||||
#error "VDR-1.6.0 API version or greater is required!"
|
#define GITVERSION ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char VERSION[] = "0.3.2";
|
const char VERSION[] = "1.2.1" GITVERSION;
|
||||||
static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
|
static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
|
||||||
|
|
||||||
class cPluginIptv : public cPlugin {
|
class cPluginIptv : public cPlugin {
|
||||||
private:
|
private:
|
||||||
unsigned int deviceCount;
|
unsigned int deviceCountM;
|
||||||
int ParseFilters(const char *Value, int *Values);
|
int ParseFilters(const char *valueP, int *filtersP);
|
||||||
public:
|
public:
|
||||||
cPluginIptv(void);
|
cPluginIptv(void);
|
||||||
virtual ~cPluginIptv();
|
virtual ~cPluginIptv();
|
||||||
@@ -51,9 +52,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
cPluginIptv::cPluginIptv(void)
|
cPluginIptv::cPluginIptv(void)
|
||||||
: deviceCount(1)
|
: deviceCountM(1)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::cPluginIptv()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Initialize any member variables here.
|
// Initialize any member variables here.
|
||||||
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
|
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
|
||||||
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
|
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
|
||||||
@@ -61,20 +62,20 @@ cPluginIptv::cPluginIptv(void)
|
|||||||
|
|
||||||
cPluginIptv::~cPluginIptv()
|
cPluginIptv::~cPluginIptv()
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::~cPluginIptv()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Clean up after yourself!
|
// Clean up after yourself!
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cPluginIptv::CommandLineHelp(void)
|
const char *cPluginIptv::CommandLineHelp(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::CommandLineHelp()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a string that describes all known command line options.
|
// Return a string that describes all known command line options.
|
||||||
return " -d <num>, --devices=<number> number of devices to be created\n";
|
return " -d <num>, --devices=<number> number of devices to be created\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::ProcessArgs()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Implement command line argument processing here if applicable.
|
// Implement command line argument processing here if applicable.
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "devices", required_argument, NULL, 'd' },
|
{ "devices", required_argument, NULL, 'd' },
|
||||||
@@ -85,7 +86,7 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
|||||||
while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
deviceCount = atoi(optarg);
|
deviceCountM = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -96,100 +97,105 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
|||||||
|
|
||||||
bool cPluginIptv::Initialize(void)
|
bool cPluginIptv::Initialize(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Initialize()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Initialize any background activities the plugin shall perform.
|
// Initialize any background activities the plugin shall perform.
|
||||||
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
|
IptvConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
|
||||||
return cIptvDevice::Initialize(deviceCount);
|
return cIptvDevice::Initialize(deviceCountM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPluginIptv::Start(void)
|
bool cPluginIptv::Start(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Start()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Start any background activities the plugin shall perform.
|
// Start any background activities the plugin shall perform.
|
||||||
|
if (curl_global_init(CURL_GLOBAL_ALL) == CURLE_OK) {
|
||||||
|
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
||||||
|
info("Using CURL %s", data->version);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPluginIptv::Stop(void)
|
void cPluginIptv::Stop(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Stop()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Stop any background activities the plugin is performing.
|
// Stop any background activities the plugin is performing.
|
||||||
|
curl_global_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPluginIptv::Housekeeping(void)
|
void cPluginIptv::Housekeeping(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::Housekeeping()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform any cleanup or other regular tasks.
|
// Perform any cleanup or other regular tasks.
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPluginIptv::MainThreadHook(void)
|
void cPluginIptv::MainThreadHook(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::MainThreadHook()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform actions in the context of the main program thread.
|
// Perform actions in the context of the main program thread.
|
||||||
// WARNING: Use with great care - see PLUGINS.html!
|
// WARNING: Use with great care - see PLUGINS.html!
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cPluginIptv::Active(void)
|
cString cPluginIptv::Active(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::Active()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a message string if shutdown should be postponed
|
// Return a message string if shutdown should be postponed
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t cPluginIptv::WakeupTime(void)
|
time_t cPluginIptv::WakeupTime(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::WakeupTime()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return custom wakeup time for shutdown script
|
// Return custom wakeup time for shutdown script
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cOsdObject *cPluginIptv::MainMenuAction(void)
|
cOsdObject *cPluginIptv::MainMenuAction(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::MainMenuAction()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform the action when selected from the main VDR menu.
|
// Perform the action when selected from the main VDR menu.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMenuSetupPage *cPluginIptv::SetupMenu(void)
|
cMenuSetupPage *cPluginIptv::SetupMenu(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SetupMenu()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a setup menu in case the plugin supports one.
|
// Return a setup menu in case the plugin supports one.
|
||||||
return new cIptvPluginSetup();
|
return new cIptvPluginSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
int cPluginIptv::ParseFilters(const char *Value, int *Filters)
|
int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::ParseFilters(): Value=%s\n", Value);
|
debug("cPluginIptv::%s(%s)", __FUNCTION__, valueP);
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (Value && *Value && (n < SECTION_FILTER_TABLE_SIZE)) {
|
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) {
|
||||||
strn0cpy(buffer, Value, sizeof(buffer));
|
strn0cpy(buffer, valueP, sizeof(buffer));
|
||||||
int i = atoi(buffer);
|
int i = atoi(buffer);
|
||||||
//debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
|
//debug("cPluginIptv::%s(): filters[%d]=%d", __FUNCTION__, n, i);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
Filters[n++] = i;
|
filtersP[n++] = i;
|
||||||
if ((Value = strchr(Value, ' ')) != NULL)
|
if ((valueP = strchr(valueP, ' ')) != NULL)
|
||||||
Value++;
|
valueP++;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPluginIptv::SetupParse(const char *Name, const char *Value)
|
bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SetupParse()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Parse your own setup parameters and store their values.
|
// Parse your own setup parameters and store their values.
|
||||||
if (!strcasecmp(Name, "TsBufferSize"))
|
if (!strcasecmp(nameP, "TsBufferSize"))
|
||||||
IptvConfig.SetTsBufferSize(atoi(Value));
|
IptvConfig.SetTsBufferSize(atoi(valueP));
|
||||||
else if (!strcasecmp(Name, "TsBufferPrefill"))
|
else if (!strcasecmp(nameP, "TsBufferPrefill"))
|
||||||
IptvConfig.SetTsBufferPrefillRatio(atoi(Value));
|
IptvConfig.SetTsBufferPrefillRatio(atoi(valueP));
|
||||||
else if (!strcasecmp(Name, "ExtProtocolBasePort"))
|
else if (!strcasecmp(nameP, "ExtProtocolBasePort"))
|
||||||
IptvConfig.SetExtProtocolBasePort(atoi(Value));
|
IptvConfig.SetExtProtocolBasePort(atoi(valueP));
|
||||||
else if (!strcasecmp(Name, "SectionFiltering"))
|
else if (!strcasecmp(nameP, "SectionFiltering"))
|
||||||
IptvConfig.SetSectionFiltering(atoi(Value));
|
IptvConfig.SetSectionFiltering(atoi(valueP));
|
||||||
else if (!strcasecmp(Name, "DisabledFilters")) {
|
else if (!strcasecmp(nameP, "DisabledFilters")) {
|
||||||
int DisabledFilters[SECTION_FILTER_TABLE_SIZE];
|
int DisabledFilters[SECTION_FILTER_TABLE_SIZE];
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i)
|
for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i)
|
||||||
DisabledFilters[i] = -1;
|
DisabledFilters[i] = -1;
|
||||||
unsigned int DisabledFiltersCount = ParseFilters(Value, DisabledFilters);
|
unsigned int DisabledFiltersCount = ParseFilters(valueP, DisabledFilters);
|
||||||
for (unsigned int i = 0; i < DisabledFiltersCount; ++i)
|
for (unsigned int i = 0; i < DisabledFiltersCount; ++i)
|
||||||
IptvConfig.SetDisabledFilters(i, DisabledFilters[i]);
|
IptvConfig.SetDisabledFilters(i, DisabledFilters[i]);
|
||||||
}
|
}
|
||||||
@@ -198,16 +204,26 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPluginIptv::Service(const char *Id, void *Data)
|
bool cPluginIptv::Service(const char *idP, void *dataP)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::Service()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Handle custom service requests from other plugins
|
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;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **cPluginIptv::SVDRPHelpPages(void)
|
const char **cPluginIptv::SVDRPHelpPages(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SVDRPHelpPages()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
static const char *HelpPages[] = {
|
static const char *HelpPages[] = {
|
||||||
"INFO [ <page> ]\n"
|
"INFO [ <page> ]\n"
|
||||||
" Print IPTV device information and statistics.\n"
|
" Print IPTV device information and statistics.\n"
|
||||||
@@ -220,26 +236,26 @@ const char **cPluginIptv::SVDRPHelpPages(void)
|
|||||||
return HelpPages;
|
return HelpPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cPluginIptv::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
|
cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SVDRPCommand(): Command=%s Option=%s\n", Command, Option);
|
debug("cPluginIptv::%s(%s, %s)", __FUNCTION__, commandP, optionP);
|
||||||
if (strcasecmp(Command, "INFO") == 0) {
|
if (strcasecmp(commandP, "INFO") == 0) {
|
||||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||||
if (device) {
|
if (device) {
|
||||||
int page = IPTV_DEVICE_INFO_ALL;
|
int page = IPTV_DEVICE_INFO_ALL;
|
||||||
if (Option) {
|
if (optionP) {
|
||||||
page = atoi(Option);
|
page = atoi(optionP);
|
||||||
if ((page < IPTV_DEVICE_INFO_ALL) || (page > IPTV_DEVICE_INFO_FILTERS))
|
if ((page < IPTV_DEVICE_INFO_ALL) || (page > IPTV_DEVICE_INFO_FILTERS))
|
||||||
page = IPTV_DEVICE_INFO_ALL;
|
page = IPTV_DEVICE_INFO_ALL;
|
||||||
}
|
}
|
||||||
return device->GetInformation(page);
|
return device->GetInformation(page);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ReplyCode = 550; // Requested action not taken
|
replyCodeP = 550; // Requested action not taken
|
||||||
return cString("IPTV information not available!");
|
return cString("IPTV information not available!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcasecmp(Command, "MODE") == 0) {
|
else if (strcasecmp(commandP, "MODE") == 0) {
|
||||||
unsigned int mode = !IptvConfig.GetUseBytes();
|
unsigned int mode = !IptvConfig.GetUseBytes();
|
||||||
IptvConfig.SetUseBytes(mode);
|
IptvConfig.SetUseBytes(mode);
|
||||||
return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits");
|
return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits");
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ set -e
|
|||||||
# The script originates from Peter Holik
|
# The script originates from Peter Holik
|
||||||
#
|
#
|
||||||
# Example channels.conf entries:
|
# Example channels.conf entries:
|
||||||
# Energy;IPTV:50:IPTV|S0P0|EXT|png.sh|1:P:0:256:257:0:0:3:0:0:0
|
# 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:IPTV|S0P0|EXT|png.sh|2:P: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:IPTV|S0P0|EXT|png.sh|3:P: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:IPTV|S0P0|EXT|png.sh|4:P: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:IPTV|S0P0|EXT|png.sh|5:P: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:IPTV|S0P0|EXT|png.sh|6:P: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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
||||||
#
|
#
|
||||||
# An example channels.conf entry:
|
# An example channels.conf entry:
|
||||||
# internetradio;IPTV:2:IPTV|S0P0|EXT|internetradio.sh|0:P:0:0:256:0:0:2:0:0:0
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ case ${PARAMETER} in
|
|||||||
URL=""
|
URL=""
|
||||||
WIDTH=720
|
WIDTH=720
|
||||||
HEIGHT=576
|
HEIGHT=576
|
||||||
|
FPS=25
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
URL=""
|
URL=""
|
||||||
@@ -66,6 +67,9 @@ TRANSCODE_OPTS="vcodec=${VCODEC},acodec=${ACODEC},vb=${VBITRATE},ab=${ABITRATE}"
|
|||||||
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
|
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
|
||||||
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
|
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "${FPS}" ] ; then
|
||||||
|
TRANSCODE_OPTS="${TRANSCODE_OPTS},fps=${FPS}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create unique pids for the stream
|
# Create unique pids for the stream
|
||||||
let VPID=${PARAMETER}+1
|
let VPID=${PARAMETER}+1
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
||||||
#
|
#
|
||||||
# An example channels.conf entry:
|
# An example channels.conf entry:
|
||||||
# linein;IPTV:5:IPTV|S0P0|EXT|linein.sh|0:P:27500:0:256:0:0:5:5:5:0
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ lookup_channel_and_pids()
|
|||||||
[ ! -e "$CHANNELS_CONF" ] && \
|
[ ! -e "$CHANNELS_CONF" ] && \
|
||||||
exit_with_error "channels.conf not found ($CHANNELS_CONF)"
|
exit_with_error "channels.conf not found ($CHANNELS_CONF)"
|
||||||
|
|
||||||
local CHANNEL_RECORD=`grep "[:]IPTV[|][SP][10][SP][10][|]EXT[|]vlc2iptv[|]$PARAMETER[:]" $CHANNELS_CONF`
|
local CHANNEL_RECORD=`grep "[:]S=[10][|]P=[10][|]F=EXT[|]U=vlc2iptv[|]A=$PARAMETER[:]I" $CHANNELS_CONF`
|
||||||
[ -z "$CHANNEL_RECORD" ] && \
|
[ -z "$CHANNEL_RECORD" ] && \
|
||||||
exit_with_error "no iptv channel with parameter $PARAMETER found"
|
exit_with_error "no iptv channel with parameter $PARAMETER found"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
# http://www.vdr-wiki.de/wiki/index.php/Iptv-plugin
|
||||||
#
|
#
|
||||||
# An example channels.conf entry:
|
# An example channels.conf entry:
|
||||||
# webcam;IPTV:3:IPTV|S0P0|EXT|webcam.sh|0:P:0:256:257:0:0:3:0:0:0
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
22
iptvservice.h
Normal file
22
iptvservice.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
diff -Nru vdr-1.6.0-vanilla/pat.c vdr-1.6.0-disable-ca-updates/pat.c
|
|
||||||
--- vdr-1.6.0-vanilla/pat.c 2008-02-08 15:48:31.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-disable-ca-updates/pat.c 2009-03-07 14:56:42.000000000 +0200
|
|
||||||
@@ -440,6 +440,7 @@
|
|
||||||
}
|
|
||||||
if (Setup.UpdateChannels >= 2) {
|
|
||||||
Channel->SetPids(Vpid, Vpid ? Ppid : 0, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
|
|
||||||
+ if (!Channel->IsPlug())
|
|
||||||
Channel->SetCaIds(CaDescriptors->CaIds());
|
|
||||||
}
|
|
||||||
Channel->SetCaDescriptors(CaDescriptorHandler.AddCaDescriptors(CaDescriptors));
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
diff -Nru vdr-1.6.0-vanilla/eitscan.c vdr-1.6.0-disable_eitscan/eitscan.c
|
|
||||||
--- vdr-1.6.0-vanilla/eitscan.c 2006-01-07 16:10:17.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-disable_eitscan/eitscan.c 2009-06-17 16:04:23.000000000 +0300
|
|
||||||
@@ -146,7 +146,7 @@
|
|
||||||
if (Device) {
|
|
||||||
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
|
|
||||||
const cChannel *Channel = ScanData->GetChannel();
|
|
||||||
- if (Channel) {
|
|
||||||
+ if (Channel && !Channel->IsPlug()) {
|
|
||||||
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
|
|
||||||
if (Device->ProvidesTransponder(Channel)) {
|
|
||||||
if (!Device->Receiving()) {
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
diff -Nru vdr-1.6.0-vanilla/channels.c vdr-1.6.0-pluginparam/channels.c
|
|
||||||
--- vdr-1.6.0-vanilla/channels.c 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/channels.c 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -166,6 +166,7 @@
|
|
||||||
shortName = strdup("");
|
|
||||||
provider = strdup("");
|
|
||||||
portalName = strdup("");
|
|
||||||
+ pluginParam = strdup("");
|
|
||||||
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
|
|
||||||
inversion = INVERSION_AUTO;
|
|
||||||
bandwidth = BANDWIDTH_AUTO;
|
|
||||||
@@ -187,6 +188,7 @@
|
|
||||||
shortName = NULL;
|
|
||||||
provider = NULL;
|
|
||||||
portalName = NULL;
|
|
||||||
+ pluginParam = NULL;
|
|
||||||
schedule = NULL;
|
|
||||||
linkChannels = NULL;
|
|
||||||
refChannel = NULL;
|
|
||||||
@@ -215,6 +217,7 @@
|
|
||||||
free(shortName);
|
|
||||||
free(provider);
|
|
||||||
free(portalName);
|
|
||||||
+ free(pluginParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
cChannel& cChannel::operator= (const cChannel &Channel)
|
|
||||||
@@ -223,6 +226,7 @@
|
|
||||||
shortName = strcpyrealloc(shortName, Channel.shortName);
|
|
||||||
provider = strcpyrealloc(provider, Channel.provider);
|
|
||||||
portalName = strcpyrealloc(portalName, Channel.portalName);
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
|
|
||||||
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
@@ -280,9 +284,26 @@
|
|
||||||
transmission = Channel->transmission;
|
|
||||||
guard = Channel->guard;
|
|
||||||
hierarchy = Channel->hierarchy;
|
|
||||||
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
|
|
||||||
+{
|
|
||||||
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
|
|
||||||
+ if (Number()) {
|
|
||||||
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
|
|
||||||
+ modification |= CHANNELMOD_TRANSP;
|
|
||||||
+ Channels.SetModified();
|
|
||||||
+ }
|
|
||||||
+ source = Source;
|
|
||||||
+ frequency = Frequency;
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
|
|
||||||
+ schedule = NULL;
|
|
||||||
+ }
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH)
|
|
||||||
{
|
|
||||||
// Workarounds for broadcaster stupidity:
|
|
||||||
@@ -407,6 +428,18 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void cChannel::SetPluginParam(const char *PluginParam)
|
|
||||||
+{
|
|
||||||
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
|
|
||||||
+ if (Number()) {
|
|
||||||
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
|
|
||||||
+ modification |= CHANNELMOD_TRANSP;
|
|
||||||
+ Channels.SetModified();
|
|
||||||
+ }
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
#define STRDIFF 0x01
|
|
||||||
#define VALDIFF 0x02
|
|
||||||
|
|
||||||
@@ -593,7 +626,7 @@
|
|
||||||
if (isdigit(type))
|
|
||||||
type = 'S';
|
|
||||||
#define ST(s) if (strchr(s, type))
|
|
||||||
- char buffer[64];
|
|
||||||
+ char buffer[256];
|
|
||||||
char *q = buffer;
|
|
||||||
*q = 0;
|
|
||||||
ST(" S ") q += sprintf(q, "%c", polarization);
|
|
||||||
@@ -605,6 +638,7 @@
|
|
||||||
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
|
|
||||||
ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
|
|
||||||
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
|
|
||||||
+ ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -626,7 +660,7 @@
|
|
||||||
|
|
||||||
bool cChannel::StringToParameters(const char *s)
|
|
||||||
{
|
|
||||||
- while (s && *s) {
|
|
||||||
+ while (s && *s && !IsPlug()) {
|
|
||||||
switch (toupper(*s)) {
|
|
||||||
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
|
|
||||||
case 'C': s = ParseParameter(s, coderateH, CoderateValues); break;
|
|
||||||
@@ -736,7 +770,7 @@
|
|
||||||
dpids[0] = 0;
|
|
||||||
ok = false;
|
|
||||||
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
|
|
||||||
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
|
|
||||||
+ ok = ((source = cSource::FromString(sourcebuf)) >= 0) && StringToParameters(parambuf);
|
|
||||||
|
|
||||||
char *p = strchr(vpidbuf, '+');
|
|
||||||
if (p)
|
|
||||||
@@ -827,6 +861,7 @@
|
|
||||||
shortName = strcpyrealloc(shortName, p);
|
|
||||||
}
|
|
||||||
name = strcpyrealloc(name, namebuf);
|
|
||||||
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
|
|
||||||
|
|
||||||
free(parambuf);
|
|
||||||
free(sourcebuf);
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/channels.h vdr-1.6.0-pluginparam/channels.h
|
|
||||||
--- vdr-1.6.0-vanilla/channels.h 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/channels.h 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -114,6 +114,7 @@
|
|
||||||
char *shortName;
|
|
||||||
char *provider;
|
|
||||||
char *portalName;
|
|
||||||
+ char *pluginParam;
|
|
||||||
int __BeginData__;
|
|
||||||
int frequency; // MHz
|
|
||||||
int source;
|
|
||||||
@@ -165,6 +166,7 @@
|
|
||||||
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
|
|
||||||
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
|
|
||||||
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
|
|
||||||
+ const char *PluginParam(void) const { return pluginParam; }
|
|
||||||
int Source(void) const { return source; }
|
|
||||||
int Srate(void) const { return srate; }
|
|
||||||
int Vpid(void) const { return vpid; }
|
|
||||||
@@ -199,6 +201,7 @@
|
|
||||||
int Hierarchy(void) const { return hierarchy; }
|
|
||||||
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
|
|
||||||
const cChannel *RefChannel(void) const { return refChannel; }
|
|
||||||
+ bool IsPlug(void) const { return cSource::IsPlug(source); }
|
|
||||||
bool IsCable(void) const { return cSource::IsCable(source); }
|
|
||||||
bool IsSat(void) const { return cSource::IsSat(source); }
|
|
||||||
bool IsTerr(void) const { return cSource::IsTerr(source); }
|
|
||||||
@@ -206,12 +209,14 @@
|
|
||||||
bool HasTimer(void) const;
|
|
||||||
int Modification(int Mask = CHANNELMOD_ALL);
|
|
||||||
void CopyTransponderData(const cChannel *Channel);
|
|
||||||
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
|
|
||||||
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
|
|
||||||
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
|
|
||||||
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
|
|
||||||
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
|
|
||||||
void SetName(const char *Name, const char *ShortName, const char *Provider);
|
|
||||||
void SetPortalName(const char *PortalName);
|
|
||||||
+ void SetPluginParam(const char *PluginParam);
|
|
||||||
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
|
|
||||||
void SetCaIds(const int *CaIds); // list must be zero-terminated
|
|
||||||
void SetCaDescriptors(int Level);
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/config.h vdr-1.6.0-pluginparam/config.h
|
|
||||||
--- vdr-1.6.0-vanilla/config.h 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/config.h 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -30,6 +30,8 @@
|
|
||||||
#define APIVERSION "1.6.0"
|
|
||||||
#define APIVERSNUM 10600 // Version * 10000 + Major * 100 + Minor
|
|
||||||
|
|
||||||
+#define PLUGINPARAMPATCHVERSNUM 1
|
|
||||||
+
|
|
||||||
// When loading plugins, VDR searches them by their APIVERSION, which
|
|
||||||
// may be smaller than VDRVERSION in case there have been no changes to
|
|
||||||
// VDR header files since the last APIVERSION. This allows compiled
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/menu.c vdr-1.6.0-pluginparam/menu.c
|
|
||||||
--- vdr-1.6.0-vanilla/menu.c 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/menu.c 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -253,6 +253,7 @@
|
|
||||||
cChannel *channel;
|
|
||||||
cChannel data;
|
|
||||||
char name[256];
|
|
||||||
+ char pluginParam[256];
|
|
||||||
void Setup(void);
|
|
||||||
public:
|
|
||||||
cMenuEditChannel(cChannel *Channel, bool New = false);
|
|
||||||
@@ -285,6 +286,7 @@
|
|
||||||
|
|
||||||
// Parameters for all types of sources:
|
|
||||||
strn0cpy(name, data.name, sizeof(name));
|
|
||||||
+ strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
|
|
||||||
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name)));
|
|
||||||
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
|
|
||||||
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
|
|
||||||
@@ -315,6 +317,7 @@
|
|
||||||
ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
|
|
||||||
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
|
|
||||||
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
|
|
||||||
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
|
|
||||||
|
|
||||||
SetCurrent(Get(current));
|
|
||||||
Display();
|
|
||||||
@@ -329,6 +332,7 @@
|
|
||||||
if (Key == kOk) {
|
|
||||||
if (Channels.HasUniqueChannelID(&data, channel)) {
|
|
||||||
data.name = strcpyrealloc(data.name, name);
|
|
||||||
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
|
|
||||||
if (channel) {
|
|
||||||
*channel = data;
|
|
||||||
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/po/fi_FI.po vdr-1.6.0-pluginparam/po/fi_FI.po
|
|
||||||
--- vdr-1.6.0-vanilla/po/fi_FI.po 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/po/fi_FI.po 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -1001,3 +1001,6 @@
|
|
||||||
#, c-format
|
|
||||||
msgid "VDR will shut down in %s minutes"
|
|
||||||
msgstr "VDR sammuu %s minuutin kuluttua"
|
|
||||||
+
|
|
||||||
+msgid "Parameters"
|
|
||||||
+msgstr "Parametrit"
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/po/fr_FR.po vdr-1.6.0-pluginparam/po/fr_FR.po
|
|
||||||
--- vdr-1.6.0-vanilla/po/fr_FR.po 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/po/fr_FR.po 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -1004,3 +1004,6 @@
|
|
||||||
#, c-format
|
|
||||||
msgid "VDR will shut down in %s minutes"
|
|
||||||
msgstr "VDR s'arr<72>tera dans %s minutes"
|
|
||||||
+
|
|
||||||
+msgid "Parameters"
|
|
||||||
+msgstr "Param<61>tres"
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/sources.c vdr-1.6.0-pluginparam/sources.c
|
|
||||||
--- vdr-1.6.0-vanilla/sources.c 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/sources.c 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -37,6 +37,7 @@
|
|
||||||
char buffer[16];
|
|
||||||
char *q = buffer;
|
|
||||||
switch (Code & st_Mask) {
|
|
||||||
+ case stPlug: *q++ = 'P'; break;
|
|
||||||
case stCable: *q++ = 'C'; break;
|
|
||||||
case stSat: *q++ = 'S';
|
|
||||||
{
|
|
||||||
@@ -56,6 +57,7 @@
|
|
||||||
{
|
|
||||||
int type = stNone;
|
|
||||||
switch (toupper(*s)) {
|
|
||||||
+ case 'P': type = stPlug; break;
|
|
||||||
case 'C': type = stCable; break;
|
|
||||||
case 'S': type = stSat; break;
|
|
||||||
case 'T': type = stTerr; break;
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/sources.conf vdr-1.6.0-pluginparam/sources.conf
|
|
||||||
--- vdr-1.6.0-vanilla/sources.conf 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/sources.conf 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -188,3 +188,7 @@
|
|
||||||
# Terrestrial
|
|
||||||
|
|
||||||
T Terrestrial
|
|
||||||
+
|
|
||||||
+# Plugin
|
|
||||||
+
|
|
||||||
+P Plugin
|
|
||||||
diff -Nru vdr-1.6.0-vanilla/sources.h vdr-1.6.0-pluginparam/sources.h
|
|
||||||
--- vdr-1.6.0-vanilla/sources.h 2008-03-27 21:43:25.000000000 +0200
|
|
||||||
+++ vdr-1.6.0-pluginparam/sources.h 2008-03-27 22:06:47.000000000 +0200
|
|
||||||
@@ -16,10 +16,11 @@
|
|
||||||
public:
|
|
||||||
enum eSourceType {
|
|
||||||
stNone = 0x0000,
|
|
||||||
+ stPlug = 0x2000,
|
|
||||||
stCable = 0x4000,
|
|
||||||
stSat = 0x8000,
|
|
||||||
stTerr = 0xC000,
|
|
||||||
- st_Mask = 0xC000,
|
|
||||||
+ st_Mask = 0xE000,
|
|
||||||
st_Neg = 0x0800,
|
|
||||||
st_Pos = 0x07FF,
|
|
||||||
};
|
|
||||||
@@ -35,6 +36,7 @@
|
|
||||||
static cString ToString(int Code);
|
|
||||||
static int FromString(const char *s);
|
|
||||||
static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
|
|
||||||
+ static bool IsPlug(int Code) { return (Code & st_Mask) == stPlug; }
|
|
||||||
static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
|
|
||||||
static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
|
|
||||||
static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
diff -Nru vdr-1.7.12-vanilla/pat.c vdr-1.7.12-disable_ca_updates/pat.c
|
|
||||||
--- vdr-1.7.12-vanilla/pat.c 2010-02-01 11:45:40.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-disable_ca_updates/pat.c 2010-02-01 13:54:32.000000000 +0200
|
|
||||||
@@ -458,6 +458,7 @@
|
|
||||||
}
|
|
||||||
if (Setup.UpdateChannels >= 2) {
|
|
||||||
Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
|
|
||||||
+ if (!Channel->IsPlug())
|
|
||||||
Channel->SetCaIds(CaDescriptors->CaIds());
|
|
||||||
Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
diff -Nru vdr-1.7.12-vanilla/eitscan.c vdr-1.7.12-disable_eitscan/eitscan.c
|
|
||||||
--- vdr-1.7.12-vanilla/eitscan.c 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-disable_eitscan/eitscan.c 2010-02-01 13:54:20.000000000 +0200
|
|
||||||
@@ -146,7 +146,7 @@
|
|
||||||
if (Device) {
|
|
||||||
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
|
|
||||||
const cChannel *Channel = ScanData->GetChannel();
|
|
||||||
- if (Channel) {
|
|
||||||
+ if (Channel && !Channel->IsPlug()) {
|
|
||||||
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
|
|
||||||
if (Device->ProvidesTransponder(Channel)) {
|
|
||||||
if (!Device->Receiving()) {
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
diff -Nru vdr-1.7.12-vanilla/channels.c vdr-1.7.12-pluginparam/channels.c
|
|
||||||
--- vdr-1.7.12-vanilla/channels.c 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/channels.c 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -188,6 +188,7 @@
|
|
||||||
shortName = strdup("");
|
|
||||||
provider = strdup("");
|
|
||||||
portalName = strdup("");
|
|
||||||
+ pluginParam = strdup("");
|
|
||||||
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
|
|
||||||
inversion = INVERSION_AUTO;
|
|
||||||
bandwidth = 8000000;
|
|
||||||
@@ -211,6 +212,7 @@
|
|
||||||
shortName = NULL;
|
|
||||||
provider = NULL;
|
|
||||||
portalName = NULL;
|
|
||||||
+ pluginParam = NULL;
|
|
||||||
schedule = NULL;
|
|
||||||
linkChannels = NULL;
|
|
||||||
refChannel = NULL;
|
|
||||||
@@ -239,6 +241,7 @@
|
|
||||||
free(shortName);
|
|
||||||
free(provider);
|
|
||||||
free(portalName);
|
|
||||||
+ free(pluginParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
cChannel& cChannel::operator= (const cChannel &Channel)
|
|
||||||
@@ -247,6 +250,7 @@
|
|
||||||
shortName = strcpyrealloc(shortName, Channel.shortName);
|
|
||||||
provider = strcpyrealloc(provider, Channel.provider);
|
|
||||||
portalName = strcpyrealloc(portalName, Channel.portalName);
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
|
|
||||||
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
@@ -307,9 +311,26 @@
|
|
||||||
guard = Channel->guard;
|
|
||||||
hierarchy = Channel->hierarchy;
|
|
||||||
rollOff = Channel->rollOff;
|
|
||||||
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
|
|
||||||
+{
|
|
||||||
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
|
|
||||||
+ if (Number()) {
|
|
||||||
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
|
|
||||||
+ modification |= CHANNELMOD_TRANSP;
|
|
||||||
+ Channels.SetModified();
|
|
||||||
+ }
|
|
||||||
+ source = Source;
|
|
||||||
+ frequency = Frequency;
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
|
|
||||||
+ schedule = NULL;
|
|
||||||
+ }
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff)
|
|
||||||
{
|
|
||||||
// Workarounds for broadcaster stupidity:
|
|
||||||
@@ -439,6 +460,18 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void cChannel::SetPluginParam(const char *PluginParam)
|
|
||||||
+{
|
|
||||||
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
|
|
||||||
+ if (Number()) {
|
|
||||||
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
|
|
||||||
+ modification |= CHANNELMOD_TRANSP;
|
|
||||||
+ Channels.SetModified();
|
|
||||||
+ }
|
|
||||||
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
#define STRDIFF 0x01
|
|
||||||
#define VALDIFF 0x02
|
|
||||||
|
|
||||||
@@ -652,7 +685,7 @@
|
|
||||||
if (isdigit(type))
|
|
||||||
type = 'S';
|
|
||||||
#define ST(s) if (strchr(s, type))
|
|
||||||
- char buffer[64];
|
|
||||||
+ char buffer[256];
|
|
||||||
char *q = buffer;
|
|
||||||
*q = 0;
|
|
||||||
ST(" S ") q += sprintf(q, "%c", polarization);
|
|
||||||
@@ -666,6 +699,7 @@
|
|
||||||
ST(" S ") q += PrintParameter(q, 'S', MapToUser(system, SystemValues));
|
|
||||||
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
|
|
||||||
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
|
|
||||||
+ ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -694,7 +728,7 @@
|
|
||||||
|
|
||||||
bool cChannel::StringToParameters(const char *s)
|
|
||||||
{
|
|
||||||
- while (s && *s) {
|
|
||||||
+ while (s && *s && !IsPlug()) {
|
|
||||||
switch (toupper(*s)) {
|
|
||||||
case 'A': s = SkipDigits(s); break; // for compatibility with the "multiproto" approach - may be removed in future versions
|
|
||||||
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
|
|
||||||
@@ -814,7 +848,7 @@
|
|
||||||
dpids[0] = 0;
|
|
||||||
ok = false;
|
|
||||||
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
|
|
||||||
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
|
|
||||||
+ ok = ((source = cSource::FromString(sourcebuf)) >= 0) && StringToParameters(parambuf);
|
|
||||||
|
|
||||||
char *p;
|
|
||||||
if ((p = strchr(vpidbuf, '=')) != NULL) {
|
|
||||||
@@ -911,6 +945,7 @@
|
|
||||||
shortName = strcpyrealloc(shortName, p);
|
|
||||||
}
|
|
||||||
name = strcpyrealloc(name, namebuf);
|
|
||||||
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
|
|
||||||
|
|
||||||
free(parambuf);
|
|
||||||
free(sourcebuf);
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/channels.h vdr-1.7.12-pluginparam/channels.h
|
|
||||||
--- vdr-1.7.12-vanilla/channels.h 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/channels.h 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -116,6 +116,7 @@
|
|
||||||
char *shortName;
|
|
||||||
char *provider;
|
|
||||||
char *portalName;
|
|
||||||
+ char *pluginParam;
|
|
||||||
int __BeginData__;
|
|
||||||
int frequency; // MHz
|
|
||||||
int source;
|
|
||||||
@@ -174,6 +175,7 @@
|
|
||||||
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
|
|
||||||
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
|
|
||||||
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
|
|
||||||
+ const char *PluginParam(void) const { return pluginParam; }
|
|
||||||
int Source(void) const { return source; }
|
|
||||||
int Srate(void) const { return srate; }
|
|
||||||
int Vpid(void) const { return vpid; }
|
|
||||||
@@ -214,6 +216,7 @@
|
|
||||||
int RollOff(void) const { return rollOff; }
|
|
||||||
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
|
|
||||||
const cChannel *RefChannel(void) const { return refChannel; }
|
|
||||||
+ bool IsPlug(void) const { return cSource::IsPlug(source); }
|
|
||||||
bool IsCable(void) const { return cSource::IsCable(source); }
|
|
||||||
bool IsSat(void) const { return cSource::IsSat(source); }
|
|
||||||
bool IsTerr(void) const { return cSource::IsTerr(source); }
|
|
||||||
@@ -221,12 +224,14 @@
|
|
||||||
bool HasTimer(void) const;
|
|
||||||
int Modification(int Mask = CHANNELMOD_ALL);
|
|
||||||
void CopyTransponderData(const cChannel *Channel);
|
|
||||||
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
|
|
||||||
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff);
|
|
||||||
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
|
|
||||||
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
|
|
||||||
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
|
|
||||||
void SetName(const char *Name, const char *ShortName, const char *Provider);
|
|
||||||
void SetPortalName(const char *PortalName);
|
|
||||||
+ void SetPluginParam(const char *PluginParam);
|
|
||||||
void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
|
|
||||||
void SetCaIds(const int *CaIds); // list must be zero-terminated
|
|
||||||
void SetCaDescriptors(int Level);
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/config.h vdr-1.7.12-pluginparam/config.h
|
|
||||||
--- vdr-1.7.12-vanilla/config.h 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/config.h 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -30,6 +30,8 @@
|
|
||||||
#define APIVERSION "1.7.12"
|
|
||||||
#define APIVERSNUM 10712 // Version * 10000 + Major * 100 + Minor
|
|
||||||
|
|
||||||
+#define PLUGINPARAMPATCHVERSNUM 1
|
|
||||||
+
|
|
||||||
// When loading plugins, VDR searches them by their APIVERSION, which
|
|
||||||
// may be smaller than VDRVERSION in case there have been no changes to
|
|
||||||
// VDR header files since the last APIVERSION. This allows compiled
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/menu.c vdr-1.7.12-pluginparam/menu.c
|
|
||||||
--- vdr-1.7.12-vanilla/menu.c 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/menu.c 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -190,6 +190,7 @@
|
|
||||||
cChannel *channel;
|
|
||||||
cChannel data;
|
|
||||||
char name[256];
|
|
||||||
+ char pluginParam[256];
|
|
||||||
void Setup(void);
|
|
||||||
public:
|
|
||||||
cMenuEditChannel(cChannel *Channel, bool New = false);
|
|
||||||
@@ -222,6 +223,7 @@
|
|
||||||
|
|
||||||
// Parameters for all types of sources:
|
|
||||||
strn0cpy(name, data.name, sizeof(name));
|
|
||||||
+ strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
|
|
||||||
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name)));
|
|
||||||
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
|
|
||||||
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
|
|
||||||
@@ -254,6 +256,7 @@
|
|
||||||
ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
|
|
||||||
ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues));
|
|
||||||
ST(" S ") Add(new cMenuEditMapItem( tr("Rolloff"), &data.rollOff, RollOffValues));
|
|
||||||
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
|
|
||||||
|
|
||||||
SetCurrent(Get(current));
|
|
||||||
Display();
|
|
||||||
@@ -268,6 +271,7 @@
|
|
||||||
if (Key == kOk) {
|
|
||||||
if (Channels.HasUniqueChannelID(&data, channel)) {
|
|
||||||
data.name = strcpyrealloc(data.name, name);
|
|
||||||
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
|
|
||||||
if (channel) {
|
|
||||||
*channel = data;
|
|
||||||
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/po/fi_FI.po vdr-1.7.12-pluginparam/po/fi_FI.po
|
|
||||||
--- vdr-1.7.12-vanilla/po/fi_FI.po 2010-02-01 11:45:40.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/po/fi_FI.po 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -1306,3 +1306,6 @@
|
|
||||||
#, c-format
|
|
||||||
msgid "VDR will shut down in %s minutes"
|
|
||||||
msgstr "VDR sammuu %s minuutin kuluttua"
|
|
||||||
+
|
|
||||||
+msgid "Parameters"
|
|
||||||
+msgstr "Parametrit"
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/po/fr_FR.po vdr-1.7.12-pluginparam/po/fr_FR.po
|
|
||||||
--- vdr-1.7.12-vanilla/po/fr_FR.po 2010-02-01 11:45:40.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/po/fr_FR.po 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -1309,3 +1309,6 @@
|
|
||||||
#, c-format
|
|
||||||
msgid "VDR will shut down in %s minutes"
|
|
||||||
msgstr "VDR s'arr<72>tera dans %s minutes"
|
|
||||||
+
|
|
||||||
+msgid "Parameters"
|
|
||||||
+msgstr "Param<61>tres"
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/sources.c vdr-1.7.12-pluginparam/sources.c
|
|
||||||
--- vdr-1.7.12-vanilla/sources.c 2010-02-01 11:45:40.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/sources.c 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -37,6 +37,7 @@
|
|
||||||
char buffer[16];
|
|
||||||
char *q = buffer;
|
|
||||||
switch (Code & st_Mask) {
|
|
||||||
+ case stPlug: *q++ = 'P'; break;
|
|
||||||
case stCable: *q++ = 'C'; break;
|
|
||||||
case stSat: *q++ = 'S';
|
|
||||||
{
|
|
||||||
@@ -56,6 +57,7 @@
|
|
||||||
{
|
|
||||||
int type = stNone;
|
|
||||||
switch (toupper(*s)) {
|
|
||||||
+ case 'P': type = stPlug; break;
|
|
||||||
case 'C': type = stCable; break;
|
|
||||||
case 'S': type = stSat; break;
|
|
||||||
case 'T': type = stTerr; break;
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/sources.conf vdr-1.7.12-pluginparam/sources.conf
|
|
||||||
--- vdr-1.7.12-vanilla/sources.conf 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/sources.conf 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -195,3 +195,7 @@
|
|
||||||
# Terrestrial
|
|
||||||
|
|
||||||
T Terrestrial
|
|
||||||
+
|
|
||||||
+# Plugin
|
|
||||||
+
|
|
||||||
+P Plugin
|
|
||||||
diff -Nru vdr-1.7.12-vanilla/sources.h vdr-1.7.12-pluginparam/sources.h
|
|
||||||
--- vdr-1.7.12-vanilla/sources.h 2010-02-01 11:45:39.000000000 +0200
|
|
||||||
+++ vdr-1.7.12-pluginparam/sources.h 2010-02-01 13:52:56.000000000 +0200
|
|
||||||
@@ -16,10 +16,11 @@
|
|
||||||
public:
|
|
||||||
enum eSourceType {
|
|
||||||
stNone = 0x0000,
|
|
||||||
+ stPlug = 0x2000,
|
|
||||||
stCable = 0x4000,
|
|
||||||
stSat = 0x8000,
|
|
||||||
stTerr = 0xC000,
|
|
||||||
- st_Mask = 0xC000,
|
|
||||||
+ st_Mask = 0xE000,
|
|
||||||
st_Neg = 0x0800,
|
|
||||||
st_Pos = 0x07FF,
|
|
||||||
};
|
|
||||||
@@ -35,6 +36,7 @@
|
|
||||||
static cString ToString(int Code);
|
|
||||||
static int FromString(const char *s);
|
|
||||||
static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
|
|
||||||
+ static bool IsPlug(int Code) { return (Code & st_Mask) == stPlug; }
|
|
||||||
static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
|
|
||||||
static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
|
|
||||||
static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }
|
|
||||||
147
pidscanner.c
147
pidscanner.c
@@ -13,148 +13,145 @@
|
|||||||
#define PIDSCANNER_VPID_COUNT 5 /* minimum count of video 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 */
|
#define PIDSCANNER_PID_DELTA_COUNT 100 /* minimum count of pid samples for audio/video only pid detection */
|
||||||
|
|
||||||
cPidScanner::cPidScanner(void)
|
cPidScanner::cPidScanner(void)
|
||||||
: timeout(0),
|
: timeoutM(0),
|
||||||
process(true),
|
channelIdM(tChannelID::InvalidID),
|
||||||
Vpid(0xFFFF),
|
processM(true),
|
||||||
Apid(0xFFFF),
|
vPidM(0xFFFF),
|
||||||
numVpids(0),
|
aPidM(0xFFFF),
|
||||||
numApids(0)
|
numVpidsM(0),
|
||||||
|
numApidsM(0)
|
||||||
{
|
{
|
||||||
debug("cPidScanner::cPidScanner()\n");
|
debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
channel = cChannel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cPidScanner::~cPidScanner()
|
cPidScanner::~cPidScanner()
|
||||||
{
|
{
|
||||||
debug("cPidScanner::~cPidScanner()\n");
|
debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPidScanner::SetChannel(const cChannel *Channel)
|
void cPidScanner::SetChannel(const tChannelID &channelIdP)
|
||||||
{
|
{
|
||||||
if (Channel) {
|
debug("cPidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
|
||||||
debug("cPidScanner::SetChannel(): %s\n", Channel->PluginParam());
|
channelIdM = channelIdP;
|
||||||
channel = *Channel;
|
vPidM = 0xFFFF;
|
||||||
}
|
numVpidsM = 0;
|
||||||
else {
|
aPidM = 0xFFFF;
|
||||||
debug("cPidScanner::SetChannel()\n");
|
numApidsM = 0;
|
||||||
channel = cChannel();
|
processM = true;
|
||||||
}
|
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
|
||||||
Vpid = 0xFFFF;
|
|
||||||
numVpids = 0;
|
|
||||||
Apid = 0xFFFF;
|
|
||||||
numApids = 0;
|
|
||||||
process = true;
|
|
||||||
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPidScanner::Process(const uint8_t* buf)
|
void cPidScanner::Process(const uint8_t* bufP)
|
||||||
{
|
{
|
||||||
//debug("cPidScanner::Process()\n");
|
//debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
if (!process)
|
if (!processM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop scanning after defined timeout
|
// Stop scanning after defined timeout
|
||||||
if (timeout.TimedOut()) {
|
if (timeoutM.TimedOut()) {
|
||||||
debug("cPidScanner::Process: Timed out determining pids\n");
|
debug("cPidScanner::%s(): timed out determining pids", __FUNCTION__);
|
||||||
process = false;
|
processM = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify TS packet
|
// Verify TS packet
|
||||||
if (buf[0] != 0x47) {
|
if (bufP[0] != 0x47) {
|
||||||
error("Not TS packet: 0x%X\n", buf[0]);
|
error("Not TS packet: 0x%X\n", bufP[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found TS packet
|
// Found TS packet
|
||||||
int pid = ts_pid(buf);
|
int pid = ts_pid(bufP);
|
||||||
int xpid = (buf[1] << 8 | buf[2]);
|
int xpid = (bufP[1] << 8 | bufP[2]);
|
||||||
|
|
||||||
// Check if payload available
|
// Check if payload available
|
||||||
uint8_t count = payload(buf);
|
uint8_t count = payload(bufP);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xpid & 0x4000) {
|
if (xpid & 0x4000) {
|
||||||
// Stream start (Payload Unit Start Indicator)
|
// Stream start (Payload Unit Start Indicator)
|
||||||
uchar *d = (uint8_t*)buf;
|
uchar *d = (uint8_t*)bufP;
|
||||||
d += 4;
|
d += 4;
|
||||||
// pointer to payload
|
// pointer to payload
|
||||||
if (buf[3] & 0x20)
|
if (bufP[3] & 0x20)
|
||||||
d += d[0] + 1;
|
d += d[0] + 1;
|
||||||
// Skip adaption field
|
// Skip adaption field
|
||||||
if (buf[3] & 0x10) {
|
if (bufP[3] & 0x10) {
|
||||||
// Payload present
|
// Payload present
|
||||||
if ((d[0] == 0) && (d[1] == 0) && (d[2] == 1)) {
|
if ((d[0] == 0) && (d[1] == 0) && (d[2] == 1)) {
|
||||||
// PES packet start
|
// PES packet start
|
||||||
int sid = d[3];
|
int sid = d[3];
|
||||||
// Stream ID
|
// Stream ID
|
||||||
if ((sid >= 0xC0) && (sid <= 0xDF)) {
|
if ((sid >= 0xC0) && (sid <= 0xDF)) {
|
||||||
if (pid < Apid) {
|
if (pid < aPidM) {
|
||||||
debug("cPidScanner::Process: Found lower Apid: 0x%X instead of 0x%X\n", pid, Apid);
|
debug("cPidScanner::%s(): found lower Apid: 0x%X instead of 0x%X", __FUNCTION__, pid, aPidM);
|
||||||
Apid = pid;
|
aPidM = pid;
|
||||||
numApids = 1;
|
numApidsM = 1;
|
||||||
}
|
}
|
||||||
else if (pid == Apid) {
|
else if (pid == aPidM) {
|
||||||
++numApids;
|
++numApidsM;
|
||||||
debug("cPidScanner::Process: Incrementing Apids, now at %d\n", numApids);
|
debug("cPidScanner::%s(): incrementing Apids, now at %d", __FUNCTION__, numApidsM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
|
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
|
||||||
if (pid < Vpid) {
|
if (pid < vPidM) {
|
||||||
debug("cPidScanner::Process: Found lower Vpid: 0x%X instead of 0x%X\n", pid, Vpid);
|
debug("cPidScanner::%s(): found lower Vpid: 0x%X instead of 0x%X", __FUNCTION__, pid, vPidM);
|
||||||
Vpid = pid;
|
vPidM = pid;
|
||||||
numVpids = 1;
|
numVpidsM = 1;
|
||||||
}
|
}
|
||||||
else if (pid == Vpid) {
|
else if (pid == vPidM) {
|
||||||
++numVpids;
|
++numVpidsM;
|
||||||
debug("cPidScanner::Process: Incrementing Vpids, now at %d\n", numVpids);
|
debug("cPidScanner::%s(): incrementing Vpids, now at %d", __FUNCTION__, numVpidsM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((numVpids >= PIDSCANNER_VPID_COUNT) && (numApids >= PIDSCANNER_APID_COUNT)) ||
|
if (((numVpidsM >= PIDSCANNER_VPID_COUNT) && (numApidsM >= PIDSCANNER_APID_COUNT)) ||
|
||||||
(abs(numApids - numVpids) >= PIDSCANNER_PID_DELTA_COUNT)) {
|
(abs(numApidsM - numVpidsM) >= PIDSCANNER_PID_DELTA_COUNT)) {
|
||||||
// Lock channels for pid updates
|
// Lock channels for pid updates
|
||||||
if (!Channels.Lock(true, 10)) {
|
if (!Channels.Lock(true, 10)) {
|
||||||
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
|
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
|
cChannel *IptvChannel = Channels.GetByChannelID(channelIdM);
|
||||||
if (IptvChannel) {
|
if (IptvChannel) {
|
||||||
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
|
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
|
||||||
|
int Atypes[MAXAPIDS + 1] = { 0 };
|
||||||
int Dpids[MAXDPIDS + 1] = { 0 };
|
int Dpids[MAXDPIDS + 1] = { 0 };
|
||||||
|
int Dtypes[MAXDPIDS + 1] = { 0 };
|
||||||
int Spids[MAXSPIDS + 1] = { 0 };
|
int Spids[MAXSPIDS + 1] = { 0 };
|
||||||
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
|
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
|
||||||
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
|
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
|
||||||
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
|
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
|
||||||
|
int Vtype = IptvChannel->Vtype();
|
||||||
int Ppid = IptvChannel->Ppid();
|
int Ppid = IptvChannel->Ppid();
|
||||||
int Tpid = IptvChannel->Tpid();
|
int Tpid = IptvChannel->Tpid();
|
||||||
bool foundApid = false;
|
bool foundApid = false;
|
||||||
if (numVpids < PIDSCANNER_VPID_COUNT)
|
if (numVpidsM < PIDSCANNER_VPID_COUNT)
|
||||||
Vpid = 0; // No detected video pid
|
vPidM = 0; // No detected video pid
|
||||||
else if (numApids < PIDSCANNER_APID_COUNT)
|
else if (numApidsM < PIDSCANNER_APID_COUNT)
|
||||||
Apid = 0; // No detected audio pid
|
aPidM = 0; // No detected audio pid
|
||||||
for (unsigned int i = 1; i < MAXAPIDS; ++i) {
|
for (unsigned int i = 0; i < MAXAPIDS; ++i) {
|
||||||
Apids[i] = IptvChannel->Apid(i);
|
Apids[i] = IptvChannel->Apid(i);
|
||||||
if (Apids[i] && (Apids[i] == Apid))
|
Atypes[i] = IptvChannel->Atype(i);
|
||||||
|
if (Apids[i] && (Apids[i] == aPidM))
|
||||||
foundApid = true;
|
foundApid = true;
|
||||||
}
|
}
|
||||||
if (!foundApid)
|
if (!foundApid) {
|
||||||
Apids[0] = Apid;
|
Apids[0] = aPidM;
|
||||||
for (unsigned int i = 0; i < MAXDPIDS; ++i)
|
Atypes[0] = 4;
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < MAXDPIDS; ++i) {
|
||||||
Dpids[i] = IptvChannel->Dpid(i);
|
Dpids[i] = IptvChannel->Dpid(i);
|
||||||
|
Dtypes[i] = IptvChannel->Dtype(i);
|
||||||
|
}
|
||||||
for (unsigned int i = 0; i < MAXSPIDS; ++i)
|
for (unsigned int i = 0; i < MAXSPIDS; ++i)
|
||||||
Spids[i] = IptvChannel->Spid(i);
|
Spids[i] = IptvChannel->Spid(i);
|
||||||
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid);
|
debug("cPidScanner::%s(): vpid=0x%04X, apid=0x%04X", __FUNCTION__, vPidM, aPidM);
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
|
IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
|
||||||
int Vtype = IptvChannel->Vtype();
|
|
||||||
IptvChannel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
|
|
||||||
#else
|
|
||||||
IptvChannel->SetPids(Vpid, Ppid, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
Channels.Unlock();
|
Channels.Unlock();
|
||||||
process = false;
|
processM = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
pidscanner.h
18
pidscanner.h
@@ -13,19 +13,19 @@
|
|||||||
|
|
||||||
class cPidScanner {
|
class cPidScanner {
|
||||||
private:
|
private:
|
||||||
cTimeMs timeout;
|
cTimeMs timeoutM;
|
||||||
cChannel channel;
|
tChannelID channelIdM;
|
||||||
bool process;
|
bool processM;
|
||||||
int Vpid;
|
int vPidM;
|
||||||
int Apid;
|
int aPidM;
|
||||||
int numVpids;
|
int numVpidsM;
|
||||||
int numApids;
|
int numApidsM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cPidScanner(void);
|
cPidScanner(void);
|
||||||
~cPidScanner();
|
~cPidScanner();
|
||||||
void SetChannel(const cChannel *Channel);
|
void SetChannel(const tChannelID &channelIdP);
|
||||||
void Process(const uint8_t* buf);
|
void Process(const uint8_t* bufP);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __PIDSCANNER_H
|
#endif // __PIDSCANNER_H
|
||||||
|
|||||||
104
po/de_DE.po
104
po/de_DE.po
@@ -5,12 +5,13 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: iptv 0.2.5\n"
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
"PO-Revision-Date: 2007-10-29 21:19+0100\n"
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
"Last-Translator: Tobias Grimm <tg@e-tobi.net>\n"
|
"Last-Translator: Tobias Grimm <tg@e-tobi.net>\n"
|
||||||
"Language-Team: German\n"
|
"Language-Team: German <vdr@linuxtv.org>\n"
|
||||||
|
"Language: de\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
@@ -40,60 +41,6 @@ msgstr "TDT (0x70)"
|
|||||||
msgid "Experience the IPTV"
|
msgid "Experience the IPTV"
|
||||||
msgstr "Erlebe IPTV"
|
msgstr "Erlebe IPTV"
|
||||||
|
|
||||||
msgid "UDP"
|
|
||||||
msgstr "UDP"
|
|
||||||
|
|
||||||
msgid "HTTP"
|
|
||||||
msgstr "HTTP"
|
|
||||||
|
|
||||||
msgid "FILE"
|
|
||||||
msgstr "DATEI"
|
|
||||||
|
|
||||||
msgid "EXT"
|
|
||||||
msgstr "EXT"
|
|
||||||
|
|
||||||
msgid "Protocol"
|
|
||||||
msgstr "Protokoll"
|
|
||||||
|
|
||||||
msgid "Delay (ms)"
|
|
||||||
msgstr "Verzögerung (ms)"
|
|
||||||
|
|
||||||
msgid "Script"
|
|
||||||
msgstr "Skript"
|
|
||||||
|
|
||||||
msgid "Parameter"
|
|
||||||
msgstr "Parameter"
|
|
||||||
|
|
||||||
msgid "Address"
|
|
||||||
msgstr "Adresse"
|
|
||||||
|
|
||||||
msgid "Port"
|
|
||||||
msgstr "Port"
|
|
||||||
|
|
||||||
msgid "Scan Sid"
|
|
||||||
msgstr "Scanne SID"
|
|
||||||
|
|
||||||
msgid "Scan pids"
|
|
||||||
msgstr "Scanne PIDS"
|
|
||||||
|
|
||||||
msgid "Vtype"
|
|
||||||
msgstr "Vtype"
|
|
||||||
|
|
||||||
msgid "Nid"
|
|
||||||
msgstr "Nid"
|
|
||||||
|
|
||||||
msgid "Tid"
|
|
||||||
msgstr "Tid"
|
|
||||||
|
|
||||||
msgid "Rid"
|
|
||||||
msgstr "Rid"
|
|
||||||
|
|
||||||
msgid "Cannot find unique channel settings!"
|
|
||||||
msgstr "Kann eindeutige Kanaleinstellungen nicht finden!"
|
|
||||||
|
|
||||||
msgid "IPTV Channels"
|
|
||||||
msgstr "IPTV Kanäle"
|
|
||||||
|
|
||||||
msgid "IPTV Information"
|
msgid "IPTV Information"
|
||||||
msgstr "IPTV Informationen"
|
msgstr "IPTV Informationen"
|
||||||
|
|
||||||
@@ -167,3 +114,42 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "Help"
|
msgid "Help"
|
||||||
msgstr "Hilfe"
|
msgstr "Hilfe"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "DATEI"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Nid"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Tid"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Rid"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Scanne Section IDS"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Scanne PIDS"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Protokoll"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Adresse"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Parameter"
|
||||||
|
|||||||
104
po/fi_FI.po
104
po/fi_FI.po
@@ -5,12 +5,13 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: iptv 0.2.5\n"
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
"Last-Translator: Rolf Ahrenberg\n"
|
"Last-Translator: Rolf Ahrenberg\n"
|
||||||
"Language-Team: <vdr@linuxtv.org>\n"
|
"Language-Team: Finnish <vdr@linuxtv.org>\n"
|
||||||
|
"Language: fi\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
@@ -39,60 +40,6 @@ msgstr "TDT (0x70)"
|
|||||||
msgid "Experience the IPTV"
|
msgid "Experience the IPTV"
|
||||||
msgstr "Koe IPTV:n ihmeellinen maailma"
|
msgstr "Koe IPTV:n ihmeellinen maailma"
|
||||||
|
|
||||||
msgid "UDP"
|
|
||||||
msgstr "UDP"
|
|
||||||
|
|
||||||
msgid "HTTP"
|
|
||||||
msgstr "HTTP"
|
|
||||||
|
|
||||||
msgid "FILE"
|
|
||||||
msgstr "FILE"
|
|
||||||
|
|
||||||
msgid "EXT"
|
|
||||||
msgstr "EXT"
|
|
||||||
|
|
||||||
msgid "Protocol"
|
|
||||||
msgstr "Protokolla"
|
|
||||||
|
|
||||||
msgid "Delay (ms)"
|
|
||||||
msgstr "Viive (ms)"
|
|
||||||
|
|
||||||
msgid "Script"
|
|
||||||
msgstr "Skripti"
|
|
||||||
|
|
||||||
msgid "Parameter"
|
|
||||||
msgstr "Parametri"
|
|
||||||
|
|
||||||
msgid "Address"
|
|
||||||
msgstr "Osoite"
|
|
||||||
|
|
||||||
msgid "Port"
|
|
||||||
msgstr "Portti"
|
|
||||||
|
|
||||||
msgid "Scan Sid"
|
|
||||||
msgstr "Etsi palvelu-ID"
|
|
||||||
|
|
||||||
msgid "Scan pids"
|
|
||||||
msgstr "Etsi pidit"
|
|
||||||
|
|
||||||
msgid "Vtype"
|
|
||||||
msgstr "Kuvatyyppi"
|
|
||||||
|
|
||||||
msgid "Nid"
|
|
||||||
msgstr "Verkko-ID"
|
|
||||||
|
|
||||||
msgid "Tid"
|
|
||||||
msgstr "Lähete-ID"
|
|
||||||
|
|
||||||
msgid "Rid"
|
|
||||||
msgstr "Radio-ID"
|
|
||||||
|
|
||||||
msgid "Cannot find unique channel settings!"
|
|
||||||
msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!"
|
|
||||||
|
|
||||||
msgid "IPTV Channels"
|
|
||||||
msgstr "IPTV-kanavat"
|
|
||||||
|
|
||||||
msgid "IPTV Information"
|
msgid "IPTV Information"
|
||||||
msgstr "IPTV-tiedot"
|
msgstr "IPTV-tiedot"
|
||||||
|
|
||||||
@@ -182,3 +129,42 @@ msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle
|
|||||||
|
|
||||||
msgid "Help"
|
msgid "Help"
|
||||||
msgstr "Opaste"
|
msgstr "Opaste"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "FILE"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Verkko-ID"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Lähete-ID"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Radio-ID"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Etsi sektiotunnisteet"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Etsi pidit"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Protokolla"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Osoite"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Parametri"
|
||||||
|
|||||||
104
po/fr_FR.po
104
po/fr_FR.po
@@ -6,12 +6,13 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: iptv 0.2.5\n"
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
"PO-Revision-Date: 2008-01-26 13:14+0100\n"
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
|
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
|
||||||
"Language-Team: French\n"
|
"Language-Team: French <vdr@linuxtv.org>\n"
|
||||||
|
"Language: fr\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
@@ -41,60 +42,6 @@ msgstr "TDT (0x70)"
|
|||||||
msgid "Experience the IPTV"
|
msgid "Experience the IPTV"
|
||||||
msgstr "L'expérience IPTV"
|
msgstr "L'expérience IPTV"
|
||||||
|
|
||||||
msgid "UDP"
|
|
||||||
msgstr "UDP"
|
|
||||||
|
|
||||||
msgid "HTTP"
|
|
||||||
msgstr "HTTP"
|
|
||||||
|
|
||||||
msgid "FILE"
|
|
||||||
msgstr "FICHIER"
|
|
||||||
|
|
||||||
msgid "EXT"
|
|
||||||
msgstr "EXT"
|
|
||||||
|
|
||||||
msgid "Protocol"
|
|
||||||
msgstr "Protocole"
|
|
||||||
|
|
||||||
msgid "Delay (ms)"
|
|
||||||
msgstr "Délai (ms)"
|
|
||||||
|
|
||||||
msgid "Script"
|
|
||||||
msgstr "Script"
|
|
||||||
|
|
||||||
msgid "Parameter"
|
|
||||||
msgstr "Paramètre"
|
|
||||||
|
|
||||||
msgid "Address"
|
|
||||||
msgstr "Adresse"
|
|
||||||
|
|
||||||
msgid "Port"
|
|
||||||
msgstr "Port"
|
|
||||||
|
|
||||||
msgid "Scan Sid"
|
|
||||||
msgstr "Scanne les SID"
|
|
||||||
|
|
||||||
msgid "Scan pids"
|
|
||||||
msgstr "Scanne les PID"
|
|
||||||
|
|
||||||
msgid "Vtype"
|
|
||||||
msgstr "Vtype"
|
|
||||||
|
|
||||||
msgid "Nid"
|
|
||||||
msgstr "Nid"
|
|
||||||
|
|
||||||
msgid "Tid"
|
|
||||||
msgstr "Tid"
|
|
||||||
|
|
||||||
msgid "Rid"
|
|
||||||
msgstr "Rid"
|
|
||||||
|
|
||||||
msgid "Cannot find unique channel settings!"
|
|
||||||
msgstr "Impossible de trouver un paramètre de chaîne unique !"
|
|
||||||
|
|
||||||
msgid "IPTV Channels"
|
|
||||||
msgstr "Canal IPTV"
|
|
||||||
|
|
||||||
msgid "IPTV Information"
|
msgid "IPTV Information"
|
||||||
msgstr "Information sur IPTV"
|
msgstr "Information sur IPTV"
|
||||||
|
|
||||||
@@ -184,3 +131,42 @@ msgstr "Définit les mauvais comportement qui doivent être désactivé."
|
|||||||
|
|
||||||
msgid "Help"
|
msgid "Help"
|
||||||
msgstr "Aide"
|
msgstr "Aide"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "FICHIER"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Nid"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Tid"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Rid"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Scanne les section ID"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Scanne les PID"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Protocole"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Adresse"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Paramètre"
|
||||||
|
|||||||
104
po/it_IT.po
104
po/it_IT.po
@@ -5,12 +5,13 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: iptv 0.2.5\n"
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
"PO-Revision-Date: 2008-07-13 03:28+0100\n"
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
|
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
|
||||||
"Language-Team: Italian\n"
|
"Language-Team: Italian <vdr@linuxtv.org>\n"
|
||||||
|
"Language: it\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
@@ -40,60 +41,6 @@ msgstr "TDT (0x70)"
|
|||||||
msgid "Experience the IPTV"
|
msgid "Experience the IPTV"
|
||||||
msgstr "Scopri la IPTV"
|
msgstr "Scopri la IPTV"
|
||||||
|
|
||||||
msgid "UDP"
|
|
||||||
msgstr "UDP"
|
|
||||||
|
|
||||||
msgid "HTTP"
|
|
||||||
msgstr "HTTP"
|
|
||||||
|
|
||||||
msgid "FILE"
|
|
||||||
msgstr "FILE"
|
|
||||||
|
|
||||||
msgid "EXT"
|
|
||||||
msgstr "EXT"
|
|
||||||
|
|
||||||
msgid "Protocol"
|
|
||||||
msgstr "Protocollo"
|
|
||||||
|
|
||||||
msgid "Delay (ms)"
|
|
||||||
msgstr "Ritardo (ms)"
|
|
||||||
|
|
||||||
msgid "Script"
|
|
||||||
msgstr "Script"
|
|
||||||
|
|
||||||
msgid "Parameter"
|
|
||||||
msgstr "Parametro"
|
|
||||||
|
|
||||||
msgid "Address"
|
|
||||||
msgstr "Indirizzo"
|
|
||||||
|
|
||||||
msgid "Port"
|
|
||||||
msgstr "Porta"
|
|
||||||
|
|
||||||
msgid "Scan Sid"
|
|
||||||
msgstr "Scansione Sid"
|
|
||||||
|
|
||||||
msgid "Scan pids"
|
|
||||||
msgstr "Scansione Pids"
|
|
||||||
|
|
||||||
msgid "Vtype"
|
|
||||||
msgstr "Vtype"
|
|
||||||
|
|
||||||
msgid "Nid"
|
|
||||||
msgstr "Nid"
|
|
||||||
|
|
||||||
msgid "Tid"
|
|
||||||
msgstr "Tid"
|
|
||||||
|
|
||||||
msgid "Rid"
|
|
||||||
msgstr "Rid"
|
|
||||||
|
|
||||||
msgid "Cannot find unique channel settings!"
|
|
||||||
msgstr "Impossibile trovare impostazioni canale unico!"
|
|
||||||
|
|
||||||
msgid "IPTV Channels"
|
|
||||||
msgstr "Canali IPTV"
|
|
||||||
|
|
||||||
msgid "IPTV Information"
|
msgid "IPTV Information"
|
||||||
msgstr "Informazione IPTV"
|
msgstr "Informazione IPTV"
|
||||||
|
|
||||||
@@ -183,3 +130,42 @@ msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
|
|||||||
|
|
||||||
msgid "Help"
|
msgid "Help"
|
||||||
msgstr "Aiuto"
|
msgstr "Aiuto"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "FILE"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Nid"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Tid"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Rid"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Scansione Section Ids"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Scansione Pids"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Protocollo"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Indirizzo"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Parametro"
|
||||||
|
|||||||
170
po/nl_NL.po
Normal file
170
po/nl_NL.po
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
# VDR plugin language source file.
|
||||||
|
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
|
||||||
|
# This file is distributed under the same license as the iptv package.
|
||||||
|
# Carel, 2010.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
|
"Last-Translator: Carel\n"
|
||||||
|
"Language-Team: Dutch <vdr@linuxtv.org>\n"
|
||||||
|
"Language: nl\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
msgid "PAT (0x00)"
|
||||||
|
msgstr "PAT (0x00)"
|
||||||
|
|
||||||
|
msgid "NIT (0x40)"
|
||||||
|
msgstr "NIT (0x40)"
|
||||||
|
|
||||||
|
msgid "SDT (0x42)"
|
||||||
|
msgstr "SDT (0x42)"
|
||||||
|
|
||||||
|
msgid "EIT (0x4E/0x4F)"
|
||||||
|
msgstr "EIT (0x4E/0x4F)"
|
||||||
|
|
||||||
|
msgid "EIT (0x5X)"
|
||||||
|
msgstr "EIT (0x5X)"
|
||||||
|
|
||||||
|
msgid "EIT (0x6X)"
|
||||||
|
msgstr "EIT (0x6X)"
|
||||||
|
|
||||||
|
msgid "TDT (0x70)"
|
||||||
|
msgstr "TDT (0x70)"
|
||||||
|
|
||||||
|
msgid "Experience the IPTV"
|
||||||
|
msgstr "TV programma's via IP"
|
||||||
|
|
||||||
|
msgid "IPTV Information"
|
||||||
|
msgstr "IPTV informatie"
|
||||||
|
|
||||||
|
msgid "General"
|
||||||
|
msgstr "Algemeen"
|
||||||
|
|
||||||
|
msgid "Pids"
|
||||||
|
msgstr "Pids"
|
||||||
|
|
||||||
|
msgid "Filters"
|
||||||
|
msgstr "Filter"
|
||||||
|
|
||||||
|
msgid "Bits/bytes"
|
||||||
|
msgstr "Bits/Bytes"
|
||||||
|
|
||||||
|
msgid "IPTV information not available!"
|
||||||
|
msgstr "IPTV informatie niet beschikbaar!"
|
||||||
|
|
||||||
|
msgid "TS buffer size [MB]"
|
||||||
|
msgstr "TS buffergrootte [MB]"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Define a ringbuffer size for transport streams in megabytes.\n"
|
||||||
|
"\n"
|
||||||
|
"Smaller sizes help memory consumption, but are more prone to buffer overflows."
|
||||||
|
msgstr ""
|
||||||
|
"Stel de grootte van de ringbuffer vast voor transportstreams in megabytes.\n"
|
||||||
|
"\n"
|
||||||
|
"Bij lage waarden zapt VDR sneller maar kunnen leiden tot bufferoverschreidingen en dus dropouts."
|
||||||
|
|
||||||
|
msgid "TS buffer prefill ratio [%]"
|
||||||
|
msgstr "TS buffer-preload [%]"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
|
||||||
|
"\n"
|
||||||
|
"This is useful if streaming media over a slow or unreliable connection."
|
||||||
|
msgstr ""
|
||||||
|
"Stel een 'prefil ratio' in voor de ringbuffer voor transportstreams voor de data naar VDR wordt verstuurd.\n"
|
||||||
|
"\n"
|
||||||
|
"Dit is aan te bevelen bij onbetrouwbare of langzame verbindingen."
|
||||||
|
|
||||||
|
msgid "EXT protocol base port"
|
||||||
|
msgstr "EXT protocol basispoort"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Define a base port used by EXT protocol.\n"
|
||||||
|
"\n"
|
||||||
|
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
|
||||||
|
msgstr ""
|
||||||
|
"Bepaal de basispoort voor het EXT protocol.\n"
|
||||||
|
"\n"
|
||||||
|
"De poortrange wordt bepaald door het aantal IPTV apparaten. Deze poort luistert naar inkomende verbindingen wanneer het EXT protocol wordt gebruikt."
|
||||||
|
|
||||||
|
msgid "Use section filtering"
|
||||||
|
msgstr "Benutze Abschnittsfilterung"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Define whether the section filtering shall be used.\n"
|
||||||
|
"\n"
|
||||||
|
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
|
||||||
|
"Enabling this feature does not affect streams that do not contain section data."
|
||||||
|
msgstr ""
|
||||||
|
"Bepaal of er sectionfilterimg moet worden gebrukt.\n"
|
||||||
|
"\n"
|
||||||
|
"Bij sectiefiltering zal de IPTV plugin VDR van extra informatie over de stream voorzien. VDR kan dan bijvoorbeeld automatisch de PIDs wijzigen of de EPG tonen.Het gebruik van deze mogelijkheid heeft geen effect op streams die geen sectiedata bevatten."
|
||||||
|
|
||||||
|
msgid "Disable filters"
|
||||||
|
msgstr "Deactiveer filter"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"Define number of section filters to be disabled.\n"
|
||||||
|
"\n"
|
||||||
|
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
|
||||||
|
msgstr ""
|
||||||
|
"Bepaal het aantal de de-activeren sectiefilters.\n"
|
||||||
|
"\n"
|
||||||
|
"Sommige sctiefilters kunnen ongewenste effecten veroorzaken. Door ze hier op te nemen blijft de data intact zodat VDR het kan blijven gebruiken."
|
||||||
|
|
||||||
|
#. TRANSLATORS: note the singular!
|
||||||
|
msgid "Disable filter"
|
||||||
|
msgstr "Deactiveer filter"
|
||||||
|
|
||||||
|
msgid "Define an ill-behaving filter to be blacklisted."
|
||||||
|
msgstr "Blacklist een probleem veroorzakend filter "
|
||||||
|
|
||||||
|
msgid "Help"
|
||||||
|
msgstr "Help"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "BESTAND"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Nid"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Tid"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Rid"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Scan section IDS"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Scan PIDS"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Protocol"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Adres"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Parameter"
|
||||||
104
po/ru_RU.po
104
po/ru_RU.po
@@ -5,12 +5,13 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: iptv 0.2.5\n"
|
"Project-Id-Version: vdr-iptv 1.2.1\n"
|
||||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
"Report-Msgid-Bugs-To: <see README>\n"
|
||||||
"POT-Creation-Date: 2009-03-06 22:15+0200\n"
|
"POT-Creation-Date: 2012-06-03 06:03+0300\n"
|
||||||
"PO-Revision-Date: 2008-03-16 12:14+0100\n"
|
"PO-Revision-Date: 2012-06-03 06:03+0300\n"
|
||||||
"Last-Translator: Alexander Gross <Bikalexander@gmail.com>\n"
|
"Last-Translator: Alexander Gross <Bikalexander@gmail.com>\n"
|
||||||
"Language-Team: Russian <de@li.org>\n"
|
"Language-Team: Russian <vdr@linuxtv.org>\n"
|
||||||
|
"Language: ru\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
@@ -41,60 +42,6 @@ msgstr "TDT (0x70)"
|
|||||||
msgid "Experience the IPTV"
|
msgid "Experience the IPTV"
|
||||||
msgstr "Попробуй IPTV"
|
msgstr "Попробуй IPTV"
|
||||||
|
|
||||||
msgid "UDP"
|
|
||||||
msgstr "UDP"
|
|
||||||
|
|
||||||
msgid "HTTP"
|
|
||||||
msgstr "HTTP"
|
|
||||||
|
|
||||||
msgid "FILE"
|
|
||||||
msgstr "ФАЙЛ"
|
|
||||||
|
|
||||||
msgid "EXT"
|
|
||||||
msgstr "EXT"
|
|
||||||
|
|
||||||
msgid "Protocol"
|
|
||||||
msgstr "Протокол"
|
|
||||||
|
|
||||||
msgid "Delay (ms)"
|
|
||||||
msgstr "Задержка (мс)"
|
|
||||||
|
|
||||||
msgid "Script"
|
|
||||||
msgstr "Скрипт"
|
|
||||||
|
|
||||||
msgid "Parameter"
|
|
||||||
msgstr "Параметр"
|
|
||||||
|
|
||||||
msgid "Address"
|
|
||||||
msgstr "Адрес"
|
|
||||||
|
|
||||||
msgid "Port"
|
|
||||||
msgstr "Порт"
|
|
||||||
|
|
||||||
msgid "Scan Sid"
|
|
||||||
msgstr "Сканировать SID"
|
|
||||||
|
|
||||||
msgid "Scan pids"
|
|
||||||
msgstr "Сканировать пиды"
|
|
||||||
|
|
||||||
msgid "Vtype"
|
|
||||||
msgstr "Vtype"
|
|
||||||
|
|
||||||
msgid "Nid"
|
|
||||||
msgstr "Nid"
|
|
||||||
|
|
||||||
msgid "Tid"
|
|
||||||
msgstr "Tid"
|
|
||||||
|
|
||||||
msgid "Rid"
|
|
||||||
msgstr "Rid"
|
|
||||||
|
|
||||||
msgid "Cannot find unique channel settings!"
|
|
||||||
msgstr "Невозможно найти уникальные настройки канала!"
|
|
||||||
|
|
||||||
msgid "IPTV Channels"
|
|
||||||
msgstr "IPTV каналы"
|
|
||||||
|
|
||||||
msgid "IPTV Information"
|
msgid "IPTV Information"
|
||||||
msgstr "IPTV информация"
|
msgstr "IPTV информация"
|
||||||
|
|
||||||
@@ -168,3 +115,42 @@ msgstr "Неправильно работающий фильтр, занести
|
|||||||
|
|
||||||
msgid "Help"
|
msgid "Help"
|
||||||
msgstr "Справка"
|
msgstr "Справка"
|
||||||
|
|
||||||
|
msgid "UDP"
|
||||||
|
msgstr "UDP"
|
||||||
|
|
||||||
|
msgid "CURL"
|
||||||
|
msgstr "CURL"
|
||||||
|
|
||||||
|
msgid "HTTP"
|
||||||
|
msgstr "HTTP"
|
||||||
|
|
||||||
|
msgid "FILE"
|
||||||
|
msgstr "ФАЙЛ"
|
||||||
|
|
||||||
|
msgid "EXT"
|
||||||
|
msgstr "EXT"
|
||||||
|
|
||||||
|
msgid "Nid"
|
||||||
|
msgstr "Nid"
|
||||||
|
|
||||||
|
msgid "Tid"
|
||||||
|
msgstr "Tid"
|
||||||
|
|
||||||
|
msgid "Rid"
|
||||||
|
msgstr "Rid"
|
||||||
|
|
||||||
|
msgid "Scan section ids"
|
||||||
|
msgstr "Сканировать section ids"
|
||||||
|
|
||||||
|
msgid "Scan pids"
|
||||||
|
msgstr "Сканировать пиды"
|
||||||
|
|
||||||
|
msgid "Protocol"
|
||||||
|
msgstr "Протокол"
|
||||||
|
|
||||||
|
msgid "Address"
|
||||||
|
msgstr "Адрес"
|
||||||
|
|
||||||
|
msgid "Parameter"
|
||||||
|
msgstr "Параметр"
|
||||||
|
|||||||
524
protocolcurl.c
Normal file
524
protocolcurl.c
Normal file
@@ -0,0 +1,524 @@
|
|||||||
|
/*
|
||||||
|
* 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 "protocolcurl.h"
|
||||||
|
|
||||||
|
#define iptv_curl_easy_setopt(X, Y, Z) \
|
||||||
|
if ((res = curl_easy_setopt((X), (Y), (Z))) != CURLE_OK) { \
|
||||||
|
error("curl_easy_setopt(%s, %s, %s) failed: %d\n", #X, #Y, #Z, res); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define iptv_curl_easy_perform(X) \
|
||||||
|
if ((res = curl_easy_perform((X))) != CURLE_OK) { \
|
||||||
|
error("curl_easy_perform(%s) failed: %d\n", #X, res); \
|
||||||
|
}
|
||||||
|
|
||||||
|
cIptvProtocolCurl::cIptvProtocolCurl()
|
||||||
|
: streamUrlM(""),
|
||||||
|
streamParamM(0),
|
||||||
|
mutexM(),
|
||||||
|
handleM(NULL),
|
||||||
|
multiM(NULL),
|
||||||
|
headerListM(NULL),
|
||||||
|
ringBufferM(new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
|
||||||
|
7 * TS_SIZE, false, "IPTV CURL")),
|
||||||
|
rtspControlM(),
|
||||||
|
modeM(eModeUnknown),
|
||||||
|
connectedM(false),
|
||||||
|
pausedM(false)
|
||||||
|
{
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
if (ringBufferM)
|
||||||
|
ringBufferM->SetTimeouts(100, 0);
|
||||||
|
Connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
cIptvProtocolCurl::~cIptvProtocolCurl()
|
||||||
|
{
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
Disconnect();
|
||||||
|
// Free allocated memory
|
||||||
|
DELETE_POINTER(ringBufferM);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t cIptvProtocolCurl::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
|
||||||
|
{
|
||||||
|
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
||||||
|
size_t len = sizeP * nmembP;
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
|
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;
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, 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;
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
|
cString control = "";
|
||||||
|
char *p = (char *)ptrP;
|
||||||
|
char *r = strtok(p, "\r\n");
|
||||||
|
|
||||||
|
while (r) {
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
|
||||||
|
if (strstr(r, "a=control")) {
|
||||||
|
char *s = NULL;
|
||||||
|
if (sscanf(r, "a=control:%64ms", &s) == 1)
|
||||||
|
control = compactspace(s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
|
char *p = (char *)ptrP;
|
||||||
|
char *r = strtok(p, "\r\n");
|
||||||
|
|
||||||
|
while (r) {
|
||||||
|
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
|
||||||
|
r = strtok(NULL, "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cIptvProtocolCurl::SetRtspControl(const char *controlP)
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
debug("cIptvProtocolCurl::%s(%s)", __FUNCTION__, controlP);
|
||||||
|
rtspControlM = controlP;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
//debug("cIptvProtocolCurl::%s(%d)", __FUNCTION__, lenP);
|
||||||
|
if (pausedM)
|
||||||
|
return false;
|
||||||
|
if (ringBufferM && (lenP >= 0)) {
|
||||||
|
// Should we pause the transfer ?
|
||||||
|
if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) {
|
||||||
|
debug("cIptvProtocolCurl::%s(pause): free=%d available=%d len=%d", __FUNCTION__,
|
||||||
|
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);
|
||||||
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
if (ringBufferM && (lenP >= 0))
|
||||||
|
ringBufferM->Del(lenP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cIptvProtocolCurl::ClearData()
|
||||||
|
{
|
||||||
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
if (ringBufferM)
|
||||||
|
ringBufferM->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char *cIptvProtocolCurl::GetData(int &lenP)
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
//debug("cIptvProtocolCurl::%s()", __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\n", count);
|
||||||
|
ringBufferM->Del(count);
|
||||||
|
lenP = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
count -= (count % TS_SIZE);
|
||||||
|
lenP = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::Connect()
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
if (connectedM)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Initialize the curl session
|
||||||
|
if (!handleM)
|
||||||
|
handleM = curl_easy_init();
|
||||||
|
if (!multiM)
|
||||||
|
multiM = curl_multi_init();
|
||||||
|
|
||||||
|
if (handleM && multiM && !isempty(*streamUrlM)) {
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
cString netrc = cString::sprintf("%s/netrc", IptvConfig.GetConfigDirectory());
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Verbose output
|
||||||
|
iptv_curl_easy_setopt(handleM, CURLOPT_VERBOSE, 1L);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 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 timeout
|
||||||
|
iptv_curl_easy_setopt(handleM, CURLOPT_CONNECTTIMEOUT, (long)eConnectTimeoutS);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
case eModeRtsp:
|
||||||
|
{
|
||||||
|
cString uri, control, transport, range;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
uri = cString::sprintf("%s/%s", *streamUrlM, *rtspControlM);
|
||||||
|
transport = "RTP/AVP/TCP;unicast;interleaved=0-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
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eModeFile:
|
||||||
|
case eModeUnknown:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add handle into multi set
|
||||||
|
curl_multi_add_handle(multiM, handleM);
|
||||||
|
|
||||||
|
connectedM = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::Disconnect()
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
if (!connectedM)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Terminate curl session
|
||||||
|
if (handleM && multiM) {
|
||||||
|
// Mode specific tricks
|
||||||
|
switch (modeM) {
|
||||||
|
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 = "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eModeHttp:
|
||||||
|
case eModeHttps:
|
||||||
|
case eModeFile:
|
||||||
|
case eModeUnknown:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup curl stuff
|
||||||
|
if (headerListM) {
|
||||||
|
curl_slist_free_all(headerListM);
|
||||||
|
headerListM = NULL;
|
||||||
|
}
|
||||||
|
curl_multi_remove_handle(multiM, handleM);
|
||||||
|
curl_easy_cleanup(handleM);
|
||||||
|
handleM = NULL;
|
||||||
|
curl_multi_cleanup(multiM);
|
||||||
|
multiM = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearData();
|
||||||
|
connectedM = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::Open(void)
|
||||||
|
{
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
return Connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::Close(void)
|
||||||
|
{
|
||||||
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
Disconnect();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
|
{
|
||||||
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
int len = 0;
|
||||||
|
if (ringBufferM) {
|
||||||
|
// Fill up the buffer
|
||||||
|
if (handleM && multiM) {
|
||||||
|
switch (modeM) {
|
||||||
|
case eModeRtsp:
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_RECEIVE);
|
||||||
|
iptv_curl_easy_perform(handleM);
|
||||||
|
// @todo - How to detect eof?
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case eModeFile:
|
||||||
|
case eModeHttp:
|
||||||
|
case eModeHttps:
|
||||||
|
{
|
||||||
|
CURLMcode res;
|
||||||
|
int running_handles;
|
||||||
|
|
||||||
|
do {
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
res = curl_multi_perform(multiM, &running_handles);
|
||||||
|
} while (res == CURLM_CALL_MULTI_PERFORM);
|
||||||
|
|
||||||
|
// Shall we continue filling up the buffer?
|
||||||
|
mutexM.Lock();
|
||||||
|
if (pausedM && (ringBufferM->Free() > ringBufferM->Available())) {
|
||||||
|
debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__,
|
||||||
|
ringBufferM->Free(), ringBufferM->Available());
|
||||||
|
pausedM = false;
|
||||||
|
curl_easy_pause(handleM, CURLPAUSE_CONT);
|
||||||
|
}
|
||||||
|
mutexM.Unlock();
|
||||||
|
|
||||||
|
// Check if end of file
|
||||||
|
if (running_handles == 0) {
|
||||||
|
int msgcount;
|
||||||
|
mutexM.Lock();
|
||||||
|
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
|
||||||
|
mutexM.Unlock();
|
||||||
|
if (msg && (msg->msg == CURLMSG_DONE)) {
|
||||||
|
debug("cIptvProtocolCurl::%s(done): %s (%d)", __FUNCTION__,
|
||||||
|
curl_easy_strerror(msg->data.result), msg->data.result);
|
||||||
|
Disconnect();
|
||||||
|
Connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
//debug("cIptvProtocolCurl::%s(): get %d bytes", __FUNCTION__, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
|
{
|
||||||
|
debug("cIptvProtocolCurl::%s(%s, %d, %d)", __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;
|
||||||
|
debug("cIptvProtocolCurl::%s(): %s (%d)", __FUNCTION__, *protocol, modeM);
|
||||||
|
// Update stream parameter
|
||||||
|
streamParamM = parameterP;
|
||||||
|
// Reconnect
|
||||||
|
Connect();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cString cIptvProtocolCurl::GetInformation(void)
|
||||||
|
{
|
||||||
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
|
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
|
||||||
|
}
|
||||||
71
protocolcurl.h
Normal file
71
protocolcurl.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
class cIptvProtocolCurl : public cIptvProtocolIf {
|
||||||
|
private:
|
||||||
|
enum eModeType {
|
||||||
|
eModeUnknown = 0,
|
||||||
|
eModeHttp,
|
||||||
|
eModeHttps,
|
||||||
|
eModeRtsp,
|
||||||
|
eModeFile,
|
||||||
|
eModeCount
|
||||||
|
};
|
||||||
|
enum {
|
||||||
|
eConnectTimeoutS = 5, // in seconds
|
||||||
|
eMaxDownloadSpeedMBits = 20 // in megabits per second
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
cMutex mutexM;
|
||||||
|
CURL *handleM;
|
||||||
|
CURLM *multiM;
|
||||||
|
struct curl_slist *headerListM;
|
||||||
|
cRingBufferLinear *ringBufferM;
|
||||||
|
cString rtspControlM;
|
||||||
|
eModeType modeM;
|
||||||
|
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 Set(const char* locationP, const int parameterP, const int indexP);
|
||||||
|
bool Open(void);
|
||||||
|
bool Close(void);
|
||||||
|
cString GetInformation(void);
|
||||||
|
void SetRtspControl(const char *controlP);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __IPTV_PROTOCOLCURL_H
|
||||||
|
|
||||||
112
protocolext.c
112
protocolext.c
@@ -19,139 +19,159 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "protocolext.h"
|
#include "protocolext.h"
|
||||||
|
|
||||||
|
#ifndef EXTSHELL
|
||||||
|
#define EXTSHELL "/bin/bash"
|
||||||
|
#endif
|
||||||
|
|
||||||
cIptvProtocolExt::cIptvProtocolExt()
|
cIptvProtocolExt::cIptvProtocolExt()
|
||||||
: pid(-1),
|
: pidM(-1),
|
||||||
scriptFile(""),
|
scriptFileM(""),
|
||||||
scriptParameter(0)
|
scriptParameterM(0),
|
||||||
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolExt::~cIptvProtocolExt()
|
cIptvProtocolExt::~cIptvProtocolExt()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::~cIptvProtocolExt()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Drop the socket connection
|
// Drop the socket connection
|
||||||
cIptvProtocolExt::Close();
|
cIptvProtocolExt::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolExt::ExecuteScript(void)
|
void cIptvProtocolExt::ExecuteScript(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::ExecuteScript()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Check if already executing
|
// Check if already executing
|
||||||
if (pid > 0) {
|
if (isActiveM || isempty(scriptFileM))
|
||||||
|
return;
|
||||||
|
if (pidM > 0) {
|
||||||
error("Cannot execute script!");
|
error("Cannot execute script!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Let's fork
|
// Let's fork
|
||||||
ERROR_IF_RET((pid = fork()) == -1, "fork()", return);
|
ERROR_IF_RET((pidM = fork()) == -1, "fork()", return);
|
||||||
// Check if child process
|
// Check if child process
|
||||||
if (pid == 0) {
|
if (pidM == 0) {
|
||||||
// Close all dup'ed filedescriptors
|
// Close all dup'ed filedescriptors
|
||||||
int MaxPossibleFileDescriptors = getdtablesize();
|
int MaxPossibleFileDescriptors = getdtablesize();
|
||||||
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
||||||
close(i);
|
close(i);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort);
|
cString cmd = cString::sprintf("%s %d %d", *scriptFileM, scriptParameterM, streamPortM);
|
||||||
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
|
debug("cIptvProtocolExt::%s(child): %s", __FUNCTION__, *cmd);
|
||||||
if (execl("/bin/sh", "sh", "-c", *cmd, NULL) == -1) {
|
// 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);
|
error("Script execution failed: %s", *cmd);
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
}
|
}
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug("cIptvProtocolExt::ExecuteScript(): pid=%d\n", pid);
|
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolExt::TerminateScript(void)
|
void cIptvProtocolExt::TerminateScript(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pid);
|
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
|
||||||
if (pid > 0) {
|
if (!isActiveM || isempty(scriptFileM))
|
||||||
|
return;
|
||||||
|
if (pidM > 0) {
|
||||||
const unsigned int timeoutms = 100;
|
const unsigned int timeoutms = 100;
|
||||||
unsigned int waitms = 0;
|
unsigned int waitms = 0;
|
||||||
siginfo_t waitStatus;
|
|
||||||
bool waitOver = false;
|
bool waitOver = false;
|
||||||
// signal and wait for termination
|
// Signal and wait for termination
|
||||||
int retval = kill(pid, SIGINT);
|
int retval = killpg(pidM, SIGINT);
|
||||||
ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
|
ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
|
||||||
while (!waitOver) {
|
while (!waitOver) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
waitms += timeoutms;
|
waitms += timeoutms;
|
||||||
if ((waitms % 2000) == 0) {
|
if ((waitms % 2000) == 0) {
|
||||||
error("Script '%s' won't terminate - killing it!", *scriptFile);
|
error("Script '%s' won't terminate - killing it!", *scriptFileM);
|
||||||
kill(pid, SIGKILL);
|
killpg(pidM, SIGKILL);
|
||||||
}
|
}
|
||||||
// Clear wait status to make sure child exit status is accessible
|
// Clear wait status to make sure child exit status is accessible
|
||||||
memset(&waitStatus, '\0', sizeof(waitStatus));
|
// and wait for child termination
|
||||||
// Wait for child termination
|
#ifdef __FreeBSD__
|
||||||
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
|
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__
|
||||||
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
|
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
|
||||||
// These are the acceptable conditions under which child exit is
|
// These are the acceptable conditions under which child exit is
|
||||||
// regarded as successful
|
// regarded as successful
|
||||||
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
|
#ifdef __FreeBSD__
|
||||||
|
if (retval > 0 && (WIFEXITED(waitStatus) || WIFSIGNALED(waitStatus))) {
|
||||||
|
#else // __FreeBSD__
|
||||||
|
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pidM) &&
|
||||||
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
|
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
|
||||||
debug("Child (%d) exited as expected\n", pid);
|
#endif // __FreeBSD__
|
||||||
|
debug("cIptvProtocolExt::%s(): child (%d) exited as expected", __FUNCTION__, pidM);
|
||||||
waitOver = true;
|
waitOver = true;
|
||||||
}
|
}
|
||||||
// Unsuccessful wait, avoid busy looping
|
// Unsuccessful wait, avoid busy looping
|
||||||
if (!waitOver)
|
if (!waitOver)
|
||||||
cCondWait::SleepMs(timeoutms);
|
cCondWait::SleepMs(timeoutms);
|
||||||
}
|
}
|
||||||
pid = -1;
|
pidM = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolExt::Open(void)
|
bool cIptvProtocolExt::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Open()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Reject empty script files
|
// Reject empty script files
|
||||||
if (!strlen(*scriptFile))
|
if (!strlen(*scriptFileM))
|
||||||
return false;
|
return false;
|
||||||
// Create the listening socket
|
// Create the listening socket
|
||||||
OpenSocket(socketPort);
|
OpenSocket(streamPortM);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
ExecuteScript();
|
ExecuteScript();
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolExt::Close(void)
|
bool cIptvProtocolExt::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Close()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Close the socket
|
|
||||||
CloseSocket();
|
|
||||||
// Terminate the external script
|
// Terminate the external script
|
||||||
TerminateScript();
|
TerminateScript();
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
|
// Close the socket
|
||||||
|
CloseSocket();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvProtocolExt::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
return cIptvUdpSocket::Read(BufferAddr, BufferLen);
|
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int Index)
|
bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
|
debug("cIptvProtocolExt::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(Location)) {
|
if (!isempty(locationP)) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
// Update script file and parameter
|
// Update script file and parameter
|
||||||
scriptFile = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), Location);
|
scriptFileM = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), locationP);
|
||||||
if ((stat(*scriptFile, &stbuf) != 0) || (strstr(*scriptFile, "..") != 0)) {
|
if ((stat(*scriptFileM, &stbuf) != 0) || (strstr(*scriptFileM, "..") != 0)) {
|
||||||
error("Non-existent or relative path script '%s'", *scriptFile);
|
error("Non-existent or relative path script '%s'", *scriptFileM);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
scriptParameter = Parameter;
|
scriptParameterM = parameterP;
|
||||||
// Update listen port
|
// Update listen port
|
||||||
socketPort = IptvConfig.GetExtProtocolBasePort() + Index;
|
streamPortM = IptvConfig.GetExtProtocolBasePort() + indexP;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvProtocolExt::GetInformation(void)
|
cString cIptvProtocolExt::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolExt::GetInformation()");
|
//debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("ext://%s:%d", *scriptFile, scriptParameter);
|
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf {
|
class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf {
|
||||||
private:
|
private:
|
||||||
int pid;
|
int pidM;
|
||||||
cString scriptFile;
|
cString scriptFileM;
|
||||||
int scriptParameter;
|
int scriptParameterM;
|
||||||
|
int streamPortM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TerminateScript(void);
|
void TerminateScript(void);
|
||||||
@@ -25,8 +26,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
cIptvProtocolExt();
|
cIptvProtocolExt();
|
||||||
virtual ~cIptvProtocolExt();
|
virtual ~cIptvProtocolExt();
|
||||||
int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool Set(const char* Location, const int Parameter, const int Index);
|
bool Set(const char* locationP, const int parameterP, const int indexP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
cString GetInformation(void);
|
cString GetInformation(void);
|
||||||
|
|||||||
@@ -15,73 +15,73 @@
|
|||||||
#include "protocolfile.h"
|
#include "protocolfile.h"
|
||||||
|
|
||||||
cIptvProtocolFile::cIptvProtocolFile()
|
cIptvProtocolFile::cIptvProtocolFile()
|
||||||
: fileDelay(0),
|
: fileLocationM(strdup("")),
|
||||||
fileStream(NULL),
|
fileDelayM(0),
|
||||||
isActive(false)
|
fileStreamM(NULL),
|
||||||
|
isActiveM(false)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::cIptvProtocolFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
fileLocation = strdup("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolFile::~cIptvProtocolFile()
|
cIptvProtocolFile::~cIptvProtocolFile()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::~cIptvProtocolFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Drop open handles
|
// Drop open handles
|
||||||
cIptvProtocolFile::Close();
|
cIptvProtocolFile::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
free(fileLocation);
|
free(fileLocationM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolFile::OpenFile(void)
|
bool cIptvProtocolFile::OpenFile(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::OpenFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActive && !isempty(fileLocation)) {
|
if (!isActiveM && !isempty(fileLocationM)) {
|
||||||
fileStream = fopen(fileLocation, "rb");
|
fileStreamM = fopen(fileLocationM, "rb");
|
||||||
ERROR_IF_RET(!fileStream || ferror(fileStream), "fopen()", return false);
|
ERROR_IF_RET(!fileStreamM || ferror(fileStreamM), "fopen()", return false);
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolFile::CloseFile(void)
|
void cIptvProtocolFile::CloseFile(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::CloseFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check that file stream is valid
|
// Check that file stream is valid
|
||||||
if (isActive && !isempty(fileLocation)) {
|
if (isActiveM && !isempty(fileLocationM)) {
|
||||||
fclose(fileStream);
|
fclose(fileStreamM);
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvProtocolFile::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolFile::Read()\n");
|
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check errors
|
// Check errors
|
||||||
if (ferror(fileStream)) {
|
if (ferror(fileStreamM)) {
|
||||||
debug("Read error\n");
|
debug("cIptvProtocolFile::%s(): stream error", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Rewind if EOF
|
// Rewind if EOF
|
||||||
if (feof(fileStream))
|
if (feof(fileStreamM))
|
||||||
rewind(fileStream);
|
rewind(fileStreamM);
|
||||||
// Sleep before reading the file stream to prevent aggressive busy looping
|
// Sleep before reading the file stream to prevent aggressive busy looping
|
||||||
// and prevent transfer ringbuffer overflows
|
// and prevent transfer ringbuffer overflows
|
||||||
if (fileDelay)
|
if (fileDelayM)
|
||||||
cCondWait::SleepMs(fileDelay);
|
cCondWait::SleepMs(fileDelayM);
|
||||||
// This check is to prevent a race condition where file may be switched off
|
// This check is to prevent a race condition where file may be switched off
|
||||||
// during the sleep and buffers are disposed. Check here that the plugin is
|
// during the sleep and buffers are disposed. Check here that the plugin is
|
||||||
// still active before accessing the buffers
|
// still active before accessing the buffers
|
||||||
if (isActive)
|
if (isActiveM)
|
||||||
return (int)fread(BufferAddr, sizeof(unsigned char), BufferLen, fileStream);
|
return (int)fread(bufferAddrP, sizeof(unsigned char), bufferLenP, fileStreamM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolFile::Open(void)
|
bool cIptvProtocolFile::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Open()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Open the file stream
|
// Open the file stream
|
||||||
OpenFile();
|
OpenFile();
|
||||||
return true;
|
return true;
|
||||||
@@ -89,21 +89,21 @@ bool cIptvProtocolFile::Open(void)
|
|||||||
|
|
||||||
bool cIptvProtocolFile::Close(void)
|
bool cIptvProtocolFile::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Close()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Close the file stream
|
// Close the file stream
|
||||||
CloseFile();
|
CloseFile();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolFile::Set(const char* Location, const int Parameter, const int Index)
|
bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
|
debug("cIptvProtocolFile::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(Location)) {
|
if (!isempty(locationP)) {
|
||||||
// Close the file stream
|
// Close the file stream
|
||||||
CloseFile();
|
CloseFile();
|
||||||
// Update stream address and port
|
// Update stream address and port
|
||||||
fileLocation = strcpyrealloc(fileLocation, Location);
|
fileLocationM = strcpyrealloc(fileLocationM, locationP);
|
||||||
fileDelay = Parameter;
|
fileDelayM = parameterP;
|
||||||
// Open the file for input
|
// Open the file for input
|
||||||
OpenFile();
|
OpenFile();
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,6 @@ bool cIptvProtocolFile::Set(const char* Location, const int Parameter, const int
|
|||||||
|
|
||||||
cString cIptvProtocolFile::GetInformation(void)
|
cString cIptvProtocolFile::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolFile::GetInformation()");
|
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("file://%s:%d", fileLocation, fileDelay);
|
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
class cIptvProtocolFile : public cIptvProtocolIf {
|
class cIptvProtocolFile : public cIptvProtocolIf {
|
||||||
private:
|
private:
|
||||||
char* fileLocation;
|
char* fileLocationM;
|
||||||
int fileDelay;
|
int fileDelayM;
|
||||||
FILE* fileStream;
|
FILE* fileStreamM;
|
||||||
bool isActive;
|
bool isActiveM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OpenFile(void);
|
bool OpenFile(void);
|
||||||
@@ -25,8 +25,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
cIptvProtocolFile();
|
cIptvProtocolFile();
|
||||||
virtual ~cIptvProtocolFile();
|
virtual ~cIptvProtocolFile();
|
||||||
int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool Set(const char* Location, const int Parameter, const int Index);
|
bool Set(const char* locationP, const int parameterP, const int indexP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
cString GetInformation(void);
|
cString GetInformation(void);
|
||||||
|
|||||||
169
protocolhttp.c
169
protocolhttp.c
@@ -19,130 +19,86 @@
|
|||||||
#include "protocolhttp.h"
|
#include "protocolhttp.h"
|
||||||
|
|
||||||
cIptvProtocolHttp::cIptvProtocolHttp()
|
cIptvProtocolHttp::cIptvProtocolHttp()
|
||||||
|
: streamAddrM(strdup("")),
|
||||||
|
streamPathM(strdup("/")),
|
||||||
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
streamAddr = strdup("");
|
|
||||||
streamPath = strdup("/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolHttp::~cIptvProtocolHttp()
|
cIptvProtocolHttp::~cIptvProtocolHttp()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::~cIptvProtocolHttp()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Close the socket
|
// Close the socket
|
||||||
cIptvProtocolHttp::Close();
|
cIptvProtocolHttp::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
free(streamPath);
|
free(streamPathM);
|
||||||
free(streamAddr);
|
free(streamAddrM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Connect(void)
|
bool cIptvProtocolHttp::Connect(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Connect()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) {
|
||||||
// Ensure that socket is valid
|
// Ensure that socket is valid and connect
|
||||||
OpenSocket(socketPort);
|
OpenSocket(streamPortM, streamAddrM);
|
||||||
|
if (!ConnectSocket()) {
|
||||||
// First try only the IP address
|
|
||||||
sockAddr.sin_addr.s_addr = inet_addr(streamAddr);
|
|
||||||
|
|
||||||
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
|
|
||||||
debug("Cannot convert %s directly to internet address\n", streamAddr);
|
|
||||||
|
|
||||||
// It may be a host name, get the name
|
|
||||||
struct hostent *host;
|
|
||||||
host = gethostbyname(streamAddr);
|
|
||||||
if (!host) {
|
|
||||||
char tmp[64];
|
|
||||||
error("%s is not valid address: %s", streamAddr, strerror_r(h_errno, tmp, sizeof(tmp)));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
int err = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
|
||||||
// Non-blocking sockets always report in-progress error when connected
|
|
||||||
ERROR_IF_FUNC(err < 0 && errno != EINPROGRESS, "connect()", CloseSocket(), return false);
|
|
||||||
// Select with 800ms timeout on the socket completion, check if it is writable
|
|
||||||
int retval = select_single_desc(socketDesc, 800000, true);
|
|
||||||
if (retval < 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
// Select has returned. Get socket errors if there are any
|
|
||||||
int socketStatus = 0;
|
|
||||||
socklen_t len = sizeof(socketStatus);
|
|
||||||
getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &socketStatus, &len);
|
|
||||||
|
|
||||||
// If not any errors, then socket must be ready and connected
|
|
||||||
if (socketStatus != 0) {
|
|
||||||
char tmp[64];
|
|
||||||
error("Cannot connect to %s: %s", streamAddr, strerror_r(socketStatus, tmp, sizeof(tmp)));
|
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formulate and send HTTP request
|
// Formulate and send HTTP request
|
||||||
cString buffer = cString::sprintf("GET %s HTTP/1.1\r\n"
|
cString buffer = cString::sprintf("GET %s HTTP/1.1\r\n"
|
||||||
"Host: %s\r\n"
|
"Host: %s\r\n"
|
||||||
"User-Agent: vdr-iptv\r\n"
|
"User-Agent: vdr-%s/%s\r\n"
|
||||||
"Range: bytes=0-\r\n"
|
"Range: bytes=0-\r\n"
|
||||||
"Connection: Close\r\n"
|
"Connection: Close\r\n"
|
||||||
"\r\n", streamPath, streamAddr);
|
"\r\n", streamPathM, streamAddrM,
|
||||||
|
PLUGIN_NAME_I18N, VERSION);
|
||||||
debug("Sending http request: %s\n", *buffer);
|
unsigned int len = strlen(*buffer);
|
||||||
ssize_t err2 = send(socketDesc, buffer, strlen(buffer), 0);
|
debug("cIptvProtocolHttp::%s(): requesting %d: %s", __FUNCTION__, len, *buffer);
|
||||||
ERROR_IF_FUNC(err2 < 0, "send()", CloseSocket(), return false);
|
if (!Write(*buffer, len)) {
|
||||||
|
CloseSocket();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Now process headers
|
// Now process headers
|
||||||
if (!ProcessHeaders()) {
|
if (!ProcessHeaders()) {
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Disconnect(void)
|
bool cIptvProtocolHttp::Disconnect(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Disconnect()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Check that stream address is valid
|
if (isActiveM) {
|
||||||
if (isActive) {
|
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
|
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
|
||||||
unsigned int &recvLen)
|
unsigned int &recvLenP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::GetHeaderLine()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
bool linefeed = false;
|
bool linefeed = false;
|
||||||
bool newline = false;
|
bool newline = false;
|
||||||
char buf[4096];
|
char *bufptr = destP;
|
||||||
char *bufptr = buf;
|
recvLenP = 0;
|
||||||
memset(buf, '\0', sizeof(buf));
|
|
||||||
recvLen = 0;
|
if (!destP)
|
||||||
|
return false;
|
||||||
|
|
||||||
while (!newline || !linefeed) {
|
while (!newline || !linefeed) {
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
|
||||||
// Wait 500ms for data
|
// Wait 500ms for data
|
||||||
int retval = select_single_desc(socketDesc, 500000, false);
|
if (ReadChar(bufptr, 500)) {
|
||||||
// Check if error
|
|
||||||
if (retval < 0)
|
|
||||||
return false;
|
|
||||||
// Check if data available
|
|
||||||
else if (retval) {
|
|
||||||
ssize_t retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT,
|
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
|
||||||
if (retval <= 0)
|
|
||||||
return false;
|
|
||||||
// Parsing end conditions, if line ends with \r\n
|
// Parsing end conditions, if line ends with \r\n
|
||||||
if (linefeed && *bufptr == '\n')
|
if (linefeed && *bufptr == '\n')
|
||||||
newline = true;
|
newline = true;
|
||||||
@@ -152,45 +108,49 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
|
|||||||
// Saw just data or \r without \n
|
// Saw just data or \r without \n
|
||||||
else {
|
else {
|
||||||
linefeed = false;
|
linefeed = false;
|
||||||
++recvLen;
|
++recvLenP;
|
||||||
}
|
}
|
||||||
++bufptr;
|
++bufptr;
|
||||||
// Check that buffers won't be exceeded
|
// Check that buffer won't be exceeded
|
||||||
if (recvLen >= sizeof(buf) || recvLen >= destLen) {
|
if (recvLenP >= destLenP) {
|
||||||
error("Header wouldn't fit into buffer\n");
|
error("Header wouldn't fit into buffer\n");
|
||||||
recvLen = 0;
|
recvLenP = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("No HTTP response received\n");
|
error("No HTTP response received in 500ms\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(dest, buf, recvLen);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::ProcessHeaders(void)
|
bool cIptvProtocolHttp::ProcessHeaders(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::ProcessHeaders()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
unsigned int lineLength = 0;
|
unsigned int lineLength = 0;
|
||||||
int response = 0;
|
int version = 0, response = 0;
|
||||||
bool responseFound = false;
|
bool responseFound = false;
|
||||||
|
char fmt[32];
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
|
// Generate HTTP response format string with 2 arguments
|
||||||
|
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
|
||||||
|
|
||||||
while (!responseFound || lineLength != 0) {
|
while (!responseFound || lineLength != 0) {
|
||||||
memset(buf, '\0', sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
|
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
|
||||||
return false;
|
return false;
|
||||||
if (!responseFound && sscanf(buf, "HTTP/1.%*i %i ", &response) != 1) {
|
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
|
||||||
error("Expected HTTP header not found\n");
|
error("Expected HTTP header not found\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
responseFound = true;
|
responseFound = true;
|
||||||
if (response != 200) {
|
// Allow only 'OK' and 'Partial Content'
|
||||||
error("%s\n", buf);
|
if ((response != 200) && (response != 206)) {
|
||||||
|
error("Invalid HTTP response (%d): %s\n", response, buf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,41 +159,40 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
|
|||||||
|
|
||||||
bool cIptvProtocolHttp::Open(void)
|
bool cIptvProtocolHttp::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Open()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Connect the socket
|
// Connect the socket
|
||||||
return Connect();
|
return Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Close(void)
|
bool cIptvProtocolHttp::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Close()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Disconnect the current stream
|
// Disconnect the current stream
|
||||||
Disconnect();
|
Disconnect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvProtocolHttp::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
return cIptvTcpSocket::Read(BufferAddr, BufferLen);
|
return cIptvTcpSocket::Read(bufferAddrP, bufferLenP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int Index)
|
bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
|
debug("cIptvProtocolHttp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(Location)) {
|
if (!isempty(locationP)) {
|
||||||
// Disconnect the current socket
|
// Disconnect the current socket
|
||||||
Disconnect();
|
Disconnect();
|
||||||
// Update stream address, path and port
|
// Update stream address, path and port
|
||||||
streamAddr = strcpyrealloc(streamAddr, Location);
|
streamAddrM = strcpyrealloc(streamAddrM, locationP);
|
||||||
char *path = strstr(streamAddr, "/");
|
char *path = strstr(streamAddrM, "/");
|
||||||
if (path) {
|
if (path) {
|
||||||
streamPath = strcpyrealloc(streamPath, path);
|
streamPathM = strcpyrealloc(streamPathM, path);
|
||||||
*path = 0;
|
*path = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
streamPath = strcpyrealloc(streamPath, "/");
|
streamPathM = strcpyrealloc(streamPathM, "/");
|
||||||
socketPort = Parameter;
|
streamPortM = parameterP;
|
||||||
//debug("http://%s:%d%s\n", streamAddr, socketPort, streamPath);
|
|
||||||
// Re-connect the socket
|
// Re-connect the socket
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@@ -242,6 +201,6 @@ bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int
|
|||||||
|
|
||||||
cString cIptvProtocolHttp::GetInformation(void)
|
cString cIptvProtocolHttp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolHttp::GetInformation()");
|
//debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("http://%s:%d%s", streamAddr, socketPort, streamPath);
|
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,21 @@
|
|||||||
|
|
||||||
class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
|
class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
|
||||||
private:
|
private:
|
||||||
char* streamAddr;
|
char* streamAddrM;
|
||||||
char* streamPath;
|
char* streamPathM;
|
||||||
|
int streamPortM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Connect(void);
|
bool Connect(void);
|
||||||
bool Disconnect(void);
|
bool Disconnect(void);
|
||||||
bool GetHeaderLine(char* dest, unsigned int destLen, unsigned int &recvLen);
|
bool GetHeaderLine(char* destP, unsigned int destLenP, unsigned int &recvLenP);
|
||||||
bool ProcessHeaders(void);
|
bool ProcessHeaders(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvProtocolHttp();
|
cIptvProtocolHttp();
|
||||||
virtual ~cIptvProtocolHttp();
|
virtual ~cIptvProtocolHttp();
|
||||||
int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool Set(const char* Location, const int Parameter, const int Index);
|
bool Set(const char* locationP, const int parameterP, const int indexP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
cString GetInformation(void);
|
cString GetInformation(void);
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class cIptvProtocolIf {
|
|||||||
public:
|
public:
|
||||||
cIptvProtocolIf() {}
|
cIptvProtocolIf() {}
|
||||||
virtual ~cIptvProtocolIf() {}
|
virtual ~cIptvProtocolIf() {}
|
||||||
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen) = 0;
|
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP) = 0;
|
||||||
virtual bool Set(const char* Location, const int Parameter, const int Index) = 0;
|
virtual bool Set(const char* locationP, const int parameterP, const int indexP) = 0;
|
||||||
virtual bool Open(void) = 0;
|
virtual bool Open(void) = 0;
|
||||||
virtual bool Close(void) = 0;
|
virtual bool Close(void) = 0;
|
||||||
virtual cString GetInformation(void) = 0;
|
virtual cString GetInformation(void) = 0;
|
||||||
|
|||||||
124
protocoludp.c
124
protocoludp.c
@@ -19,100 +19,94 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
|
||||||
cIptvProtocolUdp::cIptvProtocolUdp()
|
cIptvProtocolUdp::cIptvProtocolUdp()
|
||||||
|
: isIGMPv3M(false),
|
||||||
|
sourceAddrM(strdup("")),
|
||||||
|
streamAddrM(strdup("")),
|
||||||
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
|
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
streamAddr = strdup("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolUdp::~cIptvProtocolUdp()
|
cIptvProtocolUdp::~cIptvProtocolUdp()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::~cIptvProtocolUdp()\n");
|
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
// Drop the multicast group and close the socket
|
// Drop the multicast group and close the socket
|
||||||
cIptvProtocolUdp::Close();
|
cIptvProtocolUdp::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
free(streamAddr);
|
free(streamAddrM);
|
||||||
}
|
free(sourceAddrM);
|
||||||
|
|
||||||
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)
|
bool cIptvProtocolUdp::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Open()\n");
|
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
|
||||||
// Join a new multicast group
|
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
||||||
JoinMulticast();
|
if (!isempty(streamAddrM)) {
|
||||||
|
// Join a new multicast group
|
||||||
|
JoinMulticast();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolUdp::Close(void)
|
bool cIptvProtocolUdp::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Close()\n");
|
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
|
||||||
// Drop the multicast group
|
if (!isempty(streamAddrM)) {
|
||||||
DropMulticast();
|
// Drop the multicast group
|
||||||
|
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
||||||
|
DropMulticast();
|
||||||
|
}
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
|
// Do NOT reset stream and source addresses
|
||||||
|
//sourceAddrM = strcpyrealloc(sourceAddrM, "");
|
||||||
|
//streamAddrM = strcpyrealloc(streamAddrM, "");
|
||||||
|
//streamPortM = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvProtocolUdp::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
return cIptvUdpSocket::Read(BufferAddr, BufferLen);
|
return cIptvUdpSocket::Read(bufferAddrP, bufferLenP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int Index)
|
bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
|
debug("cIptvProtocolUdp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(Location)) {
|
if (!isempty(locationP)) {
|
||||||
// Drop the multicast group
|
// Drop the multicast group
|
||||||
DropMulticast();
|
if (!isempty(streamAddrM)) {
|
||||||
// Update stream address and port
|
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
||||||
streamAddr = strcpyrealloc(streamAddr, Location);
|
DropMulticast();
|
||||||
socketPort = Parameter;
|
}
|
||||||
// Join a new multicast group
|
// Update stream address and port
|
||||||
JoinMulticast();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvProtocolUdp::GetInformation(void)
|
cString cIptvProtocolUdp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolUdp::GetInformation()");
|
//debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("udp://%s:%d", streamAddr, socketPort);
|
if (isIGMPv3M)
|
||||||
|
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
|
||||||
|
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,16 @@
|
|||||||
|
|
||||||
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
|
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
|
||||||
private:
|
private:
|
||||||
char* streamAddr;
|
bool isIGMPv3M;
|
||||||
|
char* sourceAddrM;
|
||||||
private:
|
char* streamAddrM;
|
||||||
bool JoinMulticast(void);
|
int streamPortM;
|
||||||
bool DropMulticast(void);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvProtocolUdp();
|
cIptvProtocolUdp();
|
||||||
virtual ~cIptvProtocolUdp();
|
virtual ~cIptvProtocolUdp();
|
||||||
int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool Set(const char* Location, const int Parameter, const int Index);
|
bool Set(const char* locationP, const int parameterP, const int indexP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
cString GetInformation(void);
|
cString GetInformation(void);
|
||||||
|
|||||||
198
sectionfilter.c
198
sectionfilter.c
@@ -5,110 +5,104 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "sectionfilter.h"
|
#include "sectionfilter.h"
|
||||||
|
|
||||||
cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
|
cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP)
|
||||||
uint16_t Pid, uint8_t Tid, uint8_t Mask)
|
: pusiSeenM(0),
|
||||||
: pusi_seen(0),
|
feedCcM(0),
|
||||||
feedcc(0),
|
doneqM(0),
|
||||||
doneq(0),
|
secBufM(NULL),
|
||||||
secbuf(NULL),
|
secBufpM(0),
|
||||||
secbufp(0),
|
secLenM(0),
|
||||||
seclen(0),
|
tsFeedpM(0),
|
||||||
tsfeedp(0),
|
pidM(pidP),
|
||||||
pid(Pid),
|
devIdM(deviceIndexP)
|
||||||
devid(DeviceIndex),
|
|
||||||
id(Index)
|
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, id);
|
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(secbuf_base, '\0', sizeof(secbuf_base));
|
memset(secBufBaseM, 0, sizeof(secBufBaseM));
|
||||||
memset(filter_value, '\0', sizeof(filter_value));
|
memset(filterValueM, 0, sizeof(filterValueM));
|
||||||
memset(filter_mask, '\0', sizeof(filter_mask));
|
memset(filterMaskM, 0, sizeof(filterMaskM));
|
||||||
memset(filter_mode, '\0', sizeof(filter_mode));
|
memset(filterModeM, 0, sizeof(filterModeM));
|
||||||
memset(maskandmode, '\0', sizeof(maskandmode));
|
memset(maskAndModeM, 0, sizeof(maskAndModeM));
|
||||||
memset(maskandnotmode, '\0', sizeof(maskandnotmode));
|
memset(maskAndNotModeM, 0, sizeof(maskAndNotModeM));
|
||||||
|
|
||||||
filter_value[0] = Tid;
|
filterValueM[0] = tidP;
|
||||||
filter_mask[0] = Mask;
|
filterMaskM[0] = maskP;
|
||||||
|
|
||||||
// Invert the filter
|
// Invert the filter
|
||||||
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i)
|
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i)
|
||||||
filter_value[i] ^= 0xff;
|
filterValueM[i] ^= 0xFF;
|
||||||
|
|
||||||
uint8_t mask, mode, local_doneq = 0;
|
uint8_t mask, mode, doneq = 0;
|
||||||
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
|
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
|
||||||
mode = filter_mode[i];
|
mode = filterModeM[i];
|
||||||
mask = filter_mask[i];
|
mask = filterMaskM[i];
|
||||||
maskandmode[i] = (uint8_t)(mask & mode);
|
maskAndModeM[i] = (uint8_t)(mask & mode);
|
||||||
maskandnotmode[i] = (uint8_t)(mask & ~mode);
|
maskAndNotModeM[i] = (uint8_t)(mask & ~mode);
|
||||||
local_doneq |= maskandnotmode[i];
|
doneq |= maskAndNotModeM[i];
|
||||||
}
|
}
|
||||||
doneq = local_doneq ? 1 : 0;
|
doneqM = doneq ? 1 : 0;
|
||||||
|
|
||||||
// Create sockets
|
// Create filtering buffer
|
||||||
socket[0] = socket[1] = -1;
|
ringbufferM = new cRingBufferLinear(KILOBYTE(128), 0, false, *cString::sprintf("IPTV SECTION %d/%d", devIdM, pidM));
|
||||||
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, socket) != 0) {
|
if (ringbufferM)
|
||||||
char tmp[64];
|
ringbufferM->SetTimeouts(10, 10);
|
||||||
error("Opening section filter sockets failed (device=%d id=%d): %s\n", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
|
else
|
||||||
}
|
error("Failed to allocate buffer for section filter (device=%d pid=%d): ", devIdM, pidM);
|
||||||
else if ((fcntl(socket[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socket[1], F_SETFL, O_NONBLOCK) != 0)) {
|
|
||||||
char tmp[64];
|
|
||||||
error("Setting section filter socket to non-blocking mode failed (device=%d id=%d): %s", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvSectionFilter::~cIptvSectionFilter()
|
cIptvSectionFilter::~cIptvSectionFilter()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, id);
|
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
|
||||||
int tmp = socket[1];
|
DELETE_POINTER(ringbufferM);
|
||||||
socket[1] = -1;
|
secBufM = NULL;
|
||||||
if (tmp >= 0)
|
|
||||||
close(tmp);
|
|
||||||
tmp = socket[0];
|
|
||||||
socket[0] = -1;
|
|
||||||
if (tmp >= 0)
|
|
||||||
close(tmp);
|
|
||||||
secbuf = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvSectionFilter::GetReadDesc(void)
|
int cIptvSectionFilter::Read(void *Data, size_t Length)
|
||||||
{
|
{
|
||||||
return socket[0];
|
int count = 0;
|
||||||
|
uchar *p = ringbufferM->Get(count);
|
||||||
|
if (p && count > 0) {
|
||||||
|
memcpy(Data, p, count);
|
||||||
|
ringbufferM->Del(count);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *Data)
|
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *dataP)
|
||||||
{
|
{
|
||||||
return (uint16_t)(3 + ((Data[1] & 0x0f) << 8) + Data[2]);
|
return (uint16_t)(3 + ((dataP[1] & 0x0f) << 8) + dataP[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvSectionFilter::New(void)
|
void cIptvSectionFilter::New(void)
|
||||||
{
|
{
|
||||||
tsfeedp = secbufp = seclen = 0;
|
tsFeedpM = secBufpM = secLenM = 0;
|
||||||
secbuf = secbuf_base;
|
secBufM = secBufBaseM;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvSectionFilter::Filter(void)
|
int cIptvSectionFilter::Filter(void)
|
||||||
{
|
{
|
||||||
uint8_t neq = 0;
|
if (secBufM) {
|
||||||
int i;
|
int i;
|
||||||
|
uint8_t neq = 0;
|
||||||
|
|
||||||
if (secbuf) {
|
|
||||||
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
|
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
|
||||||
uint8_t local_xor = (uint8_t)(filter_value[i] ^ secbuf[i]);
|
uint8_t calcxor = (uint8_t)(filterValueM[i] ^ secBufM[i]);
|
||||||
if (maskandmode[i] & local_xor)
|
if (maskAndModeM[i] & calcxor)
|
||||||
return 0;
|
return 0;
|
||||||
neq |= (maskandnotmode[i] & local_xor);
|
neq |= (maskAndNotModeM[i] & calcxor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doneq && !neq)
|
if (doneqM && !neq)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// There is no data in the read socket, more can be written
|
if (ringbufferM) {
|
||||||
if ((socket[0] >= 0) && (socket[1] >= 0) /*&& !select_single_desc(socket[0], 0, false)*/) {
|
int len = ringbufferM->Put(secBufM, secLenM);
|
||||||
ssize_t len = write(socket[1], secbuf, seclen);
|
if (len != secLenM)
|
||||||
ERROR_IF(len < 0, "write()");
|
ringbufferM->ReportOverflow(secLenM - len);
|
||||||
// Update statistics
|
// Update statistics
|
||||||
AddSectionStatistic(len, 1);
|
AddSectionStatistic(len, 1);
|
||||||
}
|
}
|
||||||
@@ -120,56 +114,56 @@ inline int cIptvSectionFilter::Feed(void)
|
|||||||
{
|
{
|
||||||
if (Filter() < 0)
|
if (Filter() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
seclen = 0;
|
secLenM = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
|
int cIptvSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
|
||||||
{
|
{
|
||||||
uint16_t limit, seclen_local, n;
|
uint16_t limit, seclen, n;
|
||||||
|
|
||||||
if (tsfeedp >= DMX_MAX_SECFEED_SIZE)
|
if (tsFeedpM >= DMX_MAX_SECFEED_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (tsfeedp + len > DMX_MAX_SECFEED_SIZE)
|
if (tsFeedpM + lenP > DMX_MAX_SECFEED_SIZE)
|
||||||
len = (uint8_t)(DMX_MAX_SECFEED_SIZE - tsfeedp);
|
lenP = (uint8_t)(DMX_MAX_SECFEED_SIZE - tsFeedpM);
|
||||||
|
|
||||||
if (len <= 0)
|
if (lenP <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memcpy(secbuf_base + tsfeedp, buf, len);
|
memcpy(secBufBaseM + tsFeedpM, bufP, lenP);
|
||||||
tsfeedp += len;
|
tsFeedpM = uint16_t(tsFeedpM + lenP);
|
||||||
|
|
||||||
limit = tsfeedp;
|
limit = tsFeedpM;
|
||||||
if (limit > DMX_MAX_SECFEED_SIZE)
|
if (limit > DMX_MAX_SECFEED_SIZE)
|
||||||
return -1; // internal error should never happen
|
return -1; // internal error should never happen
|
||||||
|
|
||||||
// Always set secbuf
|
// Always set secbuf
|
||||||
secbuf = secbuf_base + secbufp;
|
secBufM = secBufBaseM + secBufpM;
|
||||||
|
|
||||||
for (n = 0; secbufp + 2 < limit; ++n) {
|
for (n = 0; secBufpM + 2 < limit; ++n) {
|
||||||
seclen_local = GetLength(secbuf);
|
seclen = GetLength(secBufM);
|
||||||
if ((seclen_local <= 0) || (seclen_local > DMX_MAX_SECTION_SIZE) || ((seclen_local + secbufp) > limit))
|
if ((seclen <= 0) || (seclen > DMX_MAX_SECTION_SIZE) || ((seclen + secBufpM) > limit))
|
||||||
return 0;
|
return 0;
|
||||||
seclen = seclen_local;
|
secLenM = seclen;
|
||||||
if (pusi_seen)
|
if (pusiSeenM)
|
||||||
Feed();
|
Feed();
|
||||||
secbufp += seclen_local;
|
secBufpM = uint16_t(secBufpM + seclen);
|
||||||
secbuf += seclen_local;
|
secBufM += seclen;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvSectionFilter::Process(const uint8_t* Data)
|
void cIptvSectionFilter::Process(const uint8_t* dataP)
|
||||||
{
|
{
|
||||||
if (Data[0] != TS_SYNC_BYTE)
|
if (dataP[0] != TS_SYNC_BYTE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop if not the PID this filter is looking for
|
// Stop if not the PID this filter is looking for
|
||||||
if (ts_pid(Data) != pid)
|
if (ts_pid(dataP) != pidM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t count = payload(Data);
|
uint8_t count = payload(dataP);
|
||||||
|
|
||||||
// Check if no payload or out of range
|
// Check if no payload or out of range
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
@@ -178,41 +172,41 @@ void cIptvSectionFilter::Process(const uint8_t* Data)
|
|||||||
// Payload start
|
// Payload start
|
||||||
uint8_t p = (uint8_t)(TS_SIZE - count);
|
uint8_t p = (uint8_t)(TS_SIZE - count);
|
||||||
|
|
||||||
uint8_t cc = (uint8_t)(Data[3] & 0x0f);
|
uint8_t cc = (uint8_t)(dataP[3] & 0x0f);
|
||||||
int ccok = ((feedcc + 1) & 0x0f) == cc;
|
int ccok = ((feedCcM + 1) & 0x0f) == cc;
|
||||||
feedcc = cc;
|
feedCcM = cc;
|
||||||
|
|
||||||
int dc_i = 0;
|
int dc_i = 0;
|
||||||
if (Data[3] & 0x20) {
|
if (dataP[3] & 0x20) {
|
||||||
// Adaption field present, check for discontinuity_indicator
|
// Adaption field present, check for discontinuity_indicator
|
||||||
if ((Data[4] > 0) && (Data[5] & 0x80))
|
if ((dataP[4] > 0) && (dataP[5] & 0x80))
|
||||||
dc_i = 1;
|
dc_i = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ccok || dc_i) {
|
if (!ccok || dc_i) {
|
||||||
// Discontinuity detected. Reset pusi_seen = 0 to
|
// Discontinuity detected. Reset pusiSeenM = 0 to
|
||||||
// stop feeding of suspicious data until next PUSI=1 arrives
|
// stop feeding of suspicious data until next PUSI=1 arrives
|
||||||
pusi_seen = 0;
|
pusiSeenM = 0;
|
||||||
New();
|
New();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Data[1] & 0x40) {
|
if (dataP[1] & 0x40) {
|
||||||
// PUSI=1 (is set), section boundary is here
|
// PUSI=1 (is set), section boundary is here
|
||||||
if (count > 1 && Data[p] < count) {
|
if (count > 1 && dataP[p] < count) {
|
||||||
const uint8_t *before = &Data[p + 1];
|
const uint8_t *before = &dataP[p + 1];
|
||||||
uint8_t before_len = Data[p];
|
uint8_t before_len = dataP[p];
|
||||||
const uint8_t *after = &before[before_len];
|
const uint8_t *after = &before[before_len];
|
||||||
uint8_t after_len = (uint8_t)(count - 1 - before_len);
|
uint8_t after_len = (uint8_t)(count - 1 - before_len);
|
||||||
CopyDump(before, before_len);
|
CopyDump(before, before_len);
|
||||||
|
|
||||||
// Before start of new section, set pusi_seen = 1
|
// Before start of new section, set pusiSeenM = 1
|
||||||
pusi_seen = 1;
|
pusiSeenM = 1;
|
||||||
New();
|
New();
|
||||||
CopyDump(after, after_len);
|
CopyDump(after, after_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// PUSI=0 (is not set), no section boundary
|
// PUSI=0 (is not set), no section boundary
|
||||||
CopyDump(&Data[p], count);
|
CopyDump(&dataP[p], count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#ifndef __IPTV_SECTIONFILTER_H
|
#ifndef __IPTV_SECTIONFILTER_H
|
||||||
#define __IPTV_SECTIONFILTER_H
|
#define __IPTV_SECTIONFILTER_H
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif // __FreeBSD__
|
||||||
#include <vdr/device.h>
|
#include <vdr/device.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -21,42 +24,41 @@ private:
|
|||||||
DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE)
|
DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE)
|
||||||
};
|
};
|
||||||
|
|
||||||
int pusi_seen;
|
int pusiSeenM;
|
||||||
int feedcc;
|
int feedCcM;
|
||||||
int doneq;
|
int doneqM;
|
||||||
|
|
||||||
uint8_t *secbuf;
|
uint8_t *secBufM;
|
||||||
uint8_t secbuf_base[DMX_MAX_SECFEED_SIZE];
|
uint8_t secBufBaseM[DMX_MAX_SECFEED_SIZE];
|
||||||
uint16_t secbufp;
|
uint16_t secBufpM;
|
||||||
uint16_t seclen;
|
uint16_t secLenM;
|
||||||
uint16_t tsfeedp;
|
uint16_t tsFeedpM;
|
||||||
uint16_t pid;
|
uint16_t pidM;
|
||||||
|
|
||||||
int devid;
|
int devIdM;
|
||||||
int id;
|
|
||||||
int socket[2];
|
|
||||||
|
|
||||||
uint8_t filter_value[DMX_MAX_FILTER_SIZE];
|
uint8_t filterValueM[DMX_MAX_FILTER_SIZE];
|
||||||
uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
|
uint8_t filterMaskM[DMX_MAX_FILTER_SIZE];
|
||||||
uint8_t filter_mode[DMX_MAX_FILTER_SIZE];
|
uint8_t filterModeM[DMX_MAX_FILTER_SIZE];
|
||||||
|
|
||||||
uint8_t maskandmode[DMX_MAX_FILTER_SIZE];
|
uint8_t maskAndModeM[DMX_MAX_FILTER_SIZE];
|
||||||
uint8_t maskandnotmode[DMX_MAX_FILTER_SIZE];
|
uint8_t maskAndNotModeM[DMX_MAX_FILTER_SIZE];
|
||||||
|
|
||||||
inline uint16_t GetLength(const uint8_t *Data);
|
cRingBufferLinear *ringbufferM;
|
||||||
|
|
||||||
|
inline uint16_t GetLength(const uint8_t *dataP);
|
||||||
void New(void);
|
void New(void);
|
||||||
int Filter(void);
|
int Filter(void);
|
||||||
inline int Feed(void);
|
inline int Feed(void);
|
||||||
int CopyDump(const uint8_t *buf, uint8_t len);
|
int CopyDump(const uint8_t *bufP, uint8_t lenP);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// constructor & destructor
|
// constructor & destructor
|
||||||
cIptvSectionFilter(int Index, int DeviceIndex, uint16_t Pid,
|
cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
|
||||||
uint8_t Tid, uint8_t Mask);
|
|
||||||
virtual ~cIptvSectionFilter();
|
virtual ~cIptvSectionFilter();
|
||||||
void Process(const uint8_t* Data);
|
void Process(const uint8_t* dataP);
|
||||||
int GetReadDesc(void);
|
int Read(void *bufferP, size_t lengthP);
|
||||||
uint16_t GetPid(void) const { return pid; }
|
uint16_t GetPid(void) const { return pidM; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __IPTV_SECTIONFILTER_H
|
#endif // __IPTV_SECTIONFILTER_H
|
||||||
|
|||||||
677
setup.c
677
setup.c
@@ -5,10 +5,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <vdr/device.h>
|
|
||||||
#include <vdr/interface.h>
|
|
||||||
#include <vdr/status.h>
|
#include <vdr/status.h>
|
||||||
#include <vdr/menu.h>
|
#include <vdr/menu.h>
|
||||||
|
|
||||||
@@ -17,521 +13,6 @@
|
|||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
// --- cIptvMenuEditChannel --------------------------------------------------
|
|
||||||
|
|
||||||
class cIptvMenuEditChannel : public cOsdMenu
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
enum {
|
|
||||||
eProtocolUDP,
|
|
||||||
eProtocolHTTP,
|
|
||||||
eProtocolFILE,
|
|
||||||
eProtocolEXT,
|
|
||||||
eProtocolCount
|
|
||||||
};
|
|
||||||
struct tIptvChannel {
|
|
||||||
int frequency, source, protocol, parameter, vpid, ppid, vtype, tpid, sid, nid, tid, rid;
|
|
||||||
int apid[MAXAPIDS + 1], dpid[MAXDPIDS + 1], spid[MAXSPIDS + 1], caids[MAXCAIDS + 1];
|
|
||||||
int sidscan, pidscan;
|
|
||||||
char name[256], location[256];
|
|
||||||
} data;
|
|
||||||
cChannel *channel;
|
|
||||||
const char *protocols[eProtocolCount];
|
|
||||||
void Setup(void);
|
|
||||||
cString GetIptvSettings(const char *Param, int *Parameter, int *SidScan, int *PidScan, int *Protocol);
|
|
||||||
void GetChannelData(cChannel *Channel);
|
|
||||||
void SetChannelData(cChannel *Channel);
|
|
||||||
|
|
||||||
public:
|
|
||||||
cIptvMenuEditChannel(cChannel *Channel, bool New = false);
|
|
||||||
virtual eOSState ProcessKey(eKeys Key);
|
|
||||||
};
|
|
||||||
|
|
||||||
cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
|
|
||||||
:cOsdMenu(trVDR("Edit channel"), 16)
|
|
||||||
{
|
|
||||||
protocols[eProtocolUDP] = tr("UDP");
|
|
||||||
protocols[eProtocolHTTP] = tr("HTTP");
|
|
||||||
protocols[eProtocolFILE] = tr("FILE");
|
|
||||||
protocols[eProtocolEXT] = tr("EXT");
|
|
||||||
channel = Channel;
|
|
||||||
GetChannelData(channel);
|
|
||||||
if (New) {
|
|
||||||
channel = NULL;
|
|
||||||
data.nid = 0;
|
|
||||||
data.tid = 0;
|
|
||||||
data.rid = 0;
|
|
||||||
}
|
|
||||||
Setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Parameter, int *SidScan, int *PidScan, int *Protocol)
|
|
||||||
{
|
|
||||||
char *tag = NULL;
|
|
||||||
char *proto = NULL;
|
|
||||||
char *loc = NULL;
|
|
||||||
if (sscanf(Param, "%a[^|]|S%dP%d|%a[^|]|%a[^|]|%d", &tag, SidScan, PidScan, &proto, &loc, Parameter) == 6) {
|
|
||||||
cString tagstr(tag, true);
|
|
||||||
cString protostr(proto, true);
|
|
||||||
cString locstr(loc, true);
|
|
||||||
// check if IPTV tag
|
|
||||||
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
|
|
||||||
// check if protocol is supported and update the pointer
|
|
||||||
if (strncasecmp(*protostr, "UDP", 3) == 0)
|
|
||||||
*Protocol = eProtocolUDP;
|
|
||||||
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
|
|
||||||
*Protocol = eProtocolHTTP;
|
|
||||||
else if (strncasecmp(*protostr, "FILE", 4) == 0)
|
|
||||||
*Protocol = eProtocolFILE;
|
|
||||||
else if (strncasecmp(*protostr, "EXT", 3) == 0)
|
|
||||||
*Protocol = eProtocolEXT;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
// return location
|
|
||||||
return locstr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (sscanf(Param, "%a[^|]|P%dS%d|%a[^|]|%a[^|]|%d", &tag, PidScan, SidScan, &proto, &loc, Parameter) == 6) {
|
|
||||||
cString tagstr(tag, true);
|
|
||||||
cString protostr(proto, true);
|
|
||||||
cString locstr(loc, true);
|
|
||||||
// check if IPTV tag
|
|
||||||
if (strncasecmp(*tagstr, "IPTV", 4) == 0) {
|
|
||||||
// check if protocol is supported and update the pointer
|
|
||||||
if (strncasecmp(*protostr, "UDP", 3) == 0)
|
|
||||||
*Protocol = eProtocolUDP;
|
|
||||||
else if (strncasecmp(*protostr, "HTTP", 4) == 0)
|
|
||||||
*Protocol = eProtocolHTTP;
|
|
||||||
else if (strncasecmp(*protostr, "FILE", 4) == 0)
|
|
||||||
*Protocol = eProtocolFILE;
|
|
||||||
else if (strncasecmp(*protostr, "EXT", 3) == 0)
|
|
||||||
*Protocol = eProtocolEXT;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
// return location
|
|
||||||
return locstr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
|
|
||||||
{
|
|
||||||
if (Channel) {
|
|
||||||
int parameter, protocol, sidscan, pidscan;
|
|
||||||
data.frequency = Channel->Frequency();
|
|
||||||
data.source = Channel->Source();
|
|
||||||
data.vpid = Channel->Vpid();
|
|
||||||
data.ppid = Channel->Ppid();
|
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
|
|
||||||
data.vtype = Channel->Vtype();
|
|
||||||
#endif
|
|
||||||
data.tpid = Channel->Tpid();
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
|
|
||||||
data.apid[i] = Channel->Apid(i);
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
|
|
||||||
data.dpid[i] = Channel->Dpid(i);
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
|
|
||||||
data.spid[i] = Channel->Spid(i);
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.caids); ++i)
|
|
||||||
data.caids[i] = Channel->Ca(i);
|
|
||||||
data.sid = Channel->Sid();
|
|
||||||
data.nid = Channel->Nid();
|
|
||||||
data.tid = Channel->Tid();
|
|
||||||
data.rid = Channel->Rid();
|
|
||||||
strn0cpy(data.name, Channel->Name(), sizeof(data.name));
|
|
||||||
strn0cpy(data.location, *GetIptvSettings(Channel->PluginParam(), ¶meter, &sidscan, &pidscan, &protocol), sizeof(data.location));
|
|
||||||
data.sidscan = sidscan;
|
|
||||||
data.pidscan = pidscan;
|
|
||||||
data.protocol = protocol;
|
|
||||||
data.parameter = parameter;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data.frequency = 1;
|
|
||||||
data.source = cSource::FromData(cSource::stPlug);
|
|
||||||
data.vpid = 0;
|
|
||||||
data.ppid = 0;
|
|
||||||
data.vtype = 0;
|
|
||||||
data.tpid = 0;
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
|
|
||||||
data.apid[i] = 0;
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
|
|
||||||
data.dpid[i] = 0;
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
|
|
||||||
data.spid[i] = 0;
|
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(data.caids); ++i)
|
|
||||||
data.caids[i] = 0;
|
|
||||||
data.sid = 1;
|
|
||||||
data.nid = 0;
|
|
||||||
data.tid = 0;
|
|
||||||
data.rid = 0;
|
|
||||||
strn0cpy(data.name, "IPTV", sizeof(data.name));
|
|
||||||
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
|
|
||||||
data.sidscan = 0;
|
|
||||||
data.pidscan = 0;
|
|
||||||
data.protocol = eProtocolUDP;
|
|
||||||
data.parameter = 1234;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
|
|
||||||
{
|
|
||||||
if (Channel) {
|
|
||||||
cString param;
|
|
||||||
char alangs[MAXAPIDS][MAXLANGCODE2] = { "" };
|
|
||||||
char dlangs[MAXDPIDS][MAXLANGCODE2] = { "" };
|
|
||||||
switch (data.protocol) {
|
|
||||||
case eProtocolEXT:
|
|
||||||
param = cString::sprintf("IPTV|S%dP%d|EXT|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
|
|
||||||
break;
|
|
||||||
case eProtocolFILE:
|
|
||||||
param = cString::sprintf("IPTV|S%dP%d|FILE|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
|
|
||||||
break;
|
|
||||||
case eProtocolHTTP:
|
|
||||||
param = cString::sprintf("IPTV|S%dP%d|HTTP|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case eProtocolUDP:
|
|
||||||
param = cString::sprintf("IPTV|S%dP%d|UDP|%s|%d", data.sidscan, data.pidscan, data.location, data.parameter);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
char slangs[MAXSPIDS][MAXLANGCODE2] = { "" };
|
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
|
|
||||||
Channel->SetPids(data.vpid, data.ppid, data.vtype, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
|
|
||||||
#else
|
|
||||||
Channel->SetPids(data.vpid, data.ppid, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
|
|
||||||
#endif
|
|
||||||
Channel->SetCaIds(data.caids);
|
|
||||||
Channel->SetId(data.nid, data.tid, data.sid, data.rid);
|
|
||||||
Channel->SetName(data.name, "", "IPTV");
|
|
||||||
Channel->SetPlugTransponderData(cSource::stPlug, data.frequency, param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuEditChannel::Setup(void)
|
|
||||||
{
|
|
||||||
int current = Current();
|
|
||||||
Clear();
|
|
||||||
// IPTV specific settings
|
|
||||||
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol,
|
|
||||||
eProtocolCount, protocols));
|
|
||||||
switch (data.protocol) {
|
|
||||||
case eProtocolFILE:
|
|
||||||
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location)));
|
|
||||||
Add(new cMenuEditIntItem(tr("Delay (ms)"), &data.parameter, 0, 0xFFFF));
|
|
||||||
break;
|
|
||||||
case eProtocolEXT:
|
|
||||||
Add(new cMenuEditStrItem(tr("Script"), data.location, sizeof(data.location)));
|
|
||||||
Add(new cMenuEditIntItem(tr("Parameter"), &data.parameter, 0, 0xFFFF));
|
|
||||||
break;
|
|
||||||
case eProtocolHTTP:
|
|
||||||
case eProtocolUDP:
|
|
||||||
default:
|
|
||||||
Add(new cMenuEditStrItem(tr("Address"), data.location, sizeof(data.location)));
|
|
||||||
Add(new cMenuEditIntItem(tr("Port"), &data.parameter, 0, 0xFFFF));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cOsdItem *sidScanItem = new cMenuEditBoolItem(tr("Scan Sid"), &data.sidscan);
|
|
||||||
if (!IptvConfig.GetSectionFiltering())
|
|
||||||
sidScanItem->SetSelectable(false);
|
|
||||||
Add(sidScanItem);
|
|
||||||
Add(new cMenuEditBoolItem(tr("Scan pids"), &data.pidscan));
|
|
||||||
// Normal settings
|
|
||||||
Add(new cMenuEditStrItem(trVDR("Name"), data.name, sizeof(data.name)));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Frequency"), &data.frequency));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Vpid"), &data.vpid, 0, 0x1FFF));
|
|
||||||
#if defined(APIVERSNUM) && APIVERSNUM >= 10704
|
|
||||||
Add(new cMenuEditIntItem(tr ("Vtype"), &data.vtype, 0, 0xFF));
|
|
||||||
#endif
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Ppid"), &data.ppid, 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Apid1"), &data.apid[0], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Apid2"), &data.apid[1], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Dpid1"), &data.dpid[0], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Dpid2"), &data.dpid[1], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Spid1"), &data.spid[0], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Spid2"), &data.spid[1], 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Tpid"), &data.tpid, 0, 0x1FFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("CA"), &data.caids[0], 0, 0xFFFF));
|
|
||||||
Add(new cMenuEditIntItem(trVDR("Sid"), &data.sid, 1, 0xFFFF));
|
|
||||||
Add(new cMenuEditIntItem(tr ("Nid"), &data.nid, 0, 0xFFFF));
|
|
||||||
Add(new cMenuEditIntItem(tr ("Tid"), &data.tid, 0, 0xFFFF));
|
|
||||||
Add(new cMenuEditIntItem(tr ("Rid"), &data.rid, 0, 0x1FFF));
|
|
||||||
SetCurrent(Get(current));
|
|
||||||
Display();
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
|
|
||||||
{
|
|
||||||
int oldProtocol = data.protocol;
|
|
||||||
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
||||||
if (state == osUnknown) {
|
|
||||||
if (Key == kOk) {
|
|
||||||
cChannel newchannel;
|
|
||||||
SetChannelData(&newchannel);
|
|
||||||
bool uniquityFailed = false;
|
|
||||||
bool firstIncrement = true;
|
|
||||||
// Search for identical channels as these will be ignored by vdr
|
|
||||||
for (cChannel *iteratorChannel = Channels.First(); iteratorChannel;
|
|
||||||
iteratorChannel = Channels.Next(iteratorChannel)) {
|
|
||||||
// This is one of the channels cause the uniquity check to fail
|
|
||||||
if (!iteratorChannel->GroupSep() && iteratorChannel != channel &&
|
|
||||||
iteratorChannel->GetChannelID() == newchannel.GetChannelID()) {
|
|
||||||
// See if it has unique Plugin param. If yes then increment
|
|
||||||
// the corresponding Rid until it is unique
|
|
||||||
if (strcmp(iteratorChannel->PluginParam(),
|
|
||||||
newchannel.PluginParam())) {
|
|
||||||
// If the channel RID is already at maximum, then fail the
|
|
||||||
// channel modification
|
|
||||||
if (iteratorChannel->Rid() >= 0x1FFF) {
|
|
||||||
debug("Cannot increment RID over maximum value\n");
|
|
||||||
uniquityFailed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
debug("Incrementing conflicting channel RID\n");
|
|
||||||
iteratorChannel->SetId(iteratorChannel->Nid(),
|
|
||||||
iteratorChannel->Tid(),
|
|
||||||
iteratorChannel->Sid(),
|
|
||||||
firstIncrement ?
|
|
||||||
0 : iteratorChannel->Rid() + 1);
|
|
||||||
|
|
||||||
// Try zero Rid:s at first increment. Prevents them from
|
|
||||||
// creeping slowly towards their maximum value
|
|
||||||
firstIncrement = false;
|
|
||||||
|
|
||||||
// Re-set the search and start again
|
|
||||||
iteratorChannel = Channels.First();
|
|
||||||
continue;
|
|
||||||
// Cannot work around by incrementing rid because channels
|
|
||||||
// are actually copies of each other
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uniquityFailed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!uniquityFailed) {
|
|
||||||
if (channel) {
|
|
||||||
SetChannelData(channel);
|
|
||||||
isyslog("edited channel %d %s", channel->Number(), *channel->ToText());
|
|
||||||
state = osBack;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
channel = new cChannel;
|
|
||||||
SetChannelData(channel);
|
|
||||||
Channels.Add(channel);
|
|
||||||
Channels.ReNumber();
|
|
||||||
isyslog("added channel %d %s", channel->Number(), *channel->ToText());
|
|
||||||
state = osUser1;
|
|
||||||
}
|
|
||||||
Channels.SetModified(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Skins.Message(mtError, tr("Cannot find unique channel settings!"));
|
|
||||||
state = osContinue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((Key != kNone) && (data.protocol != oldProtocol)) {
|
|
||||||
switch (data.protocol) {
|
|
||||||
case eProtocolEXT:
|
|
||||||
strn0cpy(data.location, "iptvstream.sh", sizeof(data.location));
|
|
||||||
data.parameter = 0;
|
|
||||||
break;
|
|
||||||
case eProtocolFILE:
|
|
||||||
strn0cpy(data.location, "/video/stream.ts", sizeof(data.location));
|
|
||||||
data.parameter = 0;
|
|
||||||
break;
|
|
||||||
case eProtocolHTTP:
|
|
||||||
strn0cpy(data.location, "127.0.0.1/TS/1", sizeof(data.location));
|
|
||||||
data.parameter = 3000;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case eProtocolUDP:
|
|
||||||
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
|
|
||||||
data.parameter = 1234;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Setup();
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- cIptvMenuChannelItem --------------------------------------------------
|
|
||||||
|
|
||||||
class cIptvMenuChannelItem : public cOsdItem
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
cChannel *channel;
|
|
||||||
|
|
||||||
public:
|
|
||||||
cIptvMenuChannelItem(cChannel *Channel);
|
|
||||||
virtual void Set(void);
|
|
||||||
cChannel *Channel(void) { return channel; }
|
|
||||||
};
|
|
||||||
|
|
||||||
cIptvMenuChannelItem::cIptvMenuChannelItem(cChannel *Channel)
|
|
||||||
{
|
|
||||||
channel = Channel;
|
|
||||||
Set();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuChannelItem::Set(void)
|
|
||||||
{
|
|
||||||
SetText(cString::sprintf("%d\t%s", channel->Number(), channel->Name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- cIptvMenuChannels -----------------------------------------------------
|
|
||||||
|
|
||||||
class cIptvMenuChannels : public cOsdMenu
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
void Setup(void);
|
|
||||||
cChannel *GetChannel(int Index) const;
|
|
||||||
void Propagate(void);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
eOSState Edit(void);
|
|
||||||
eOSState New(void);
|
|
||||||
eOSState Delete(void);
|
|
||||||
eOSState Switch(void);
|
|
||||||
|
|
||||||
public:
|
|
||||||
cIptvMenuChannels();
|
|
||||||
~cIptvMenuChannels();
|
|
||||||
virtual eOSState ProcessKey(eKeys Key);
|
|
||||||
};
|
|
||||||
|
|
||||||
cIptvMenuChannels::cIptvMenuChannels(void)
|
|
||||||
:cOsdMenu(tr("IPTV Channels"), numdigits(Channels.MaxNumber()) + 1)
|
|
||||||
{
|
|
||||||
Setup();
|
|
||||||
Channels.IncBeingEdited();
|
|
||||||
}
|
|
||||||
|
|
||||||
cIptvMenuChannels::~cIptvMenuChannels()
|
|
||||||
{
|
|
||||||
Channels.DecBeingEdited();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuChannels::Setup(void)
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
|
|
||||||
if (!channel->GroupSep() && channel->IsPlug() && !strncasecmp(channel->PluginParam(), "IPTV", 4)) {
|
|
||||||
cIptvMenuChannelItem *item = new cIptvMenuChannelItem(channel);
|
|
||||||
Add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
|
|
||||||
Display();
|
|
||||||
}
|
|
||||||
|
|
||||||
cChannel *cIptvMenuChannels::GetChannel(int Index) const
|
|
||||||
{
|
|
||||||
cIptvMenuChannelItem *p = dynamic_cast<cIptvMenuChannelItem *>(Get(Index));
|
|
||||||
return p ? (cChannel *)p->Channel() : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cIptvMenuChannels::Propagate(void)
|
|
||||||
{
|
|
||||||
Channels.ReNumber();
|
|
||||||
for (cIptvMenuChannelItem *ci = dynamic_cast<cIptvMenuChannelItem *>(First()); ci; ci = dynamic_cast<cIptvMenuChannelItem *>(ci->Next()))
|
|
||||||
ci->Set();
|
|
||||||
Display();
|
|
||||||
Channels.SetModified(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuChannels::Switch(void)
|
|
||||||
{
|
|
||||||
if (HasSubMenu() || Count() == 0)
|
|
||||||
return osContinue;
|
|
||||||
cChannel *ch = GetChannel(Current());
|
|
||||||
if (ch)
|
|
||||||
return cDevice::PrimaryDevice()->SwitchChannel(ch, true) ? osEnd : osContinue;
|
|
||||||
return osEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuChannels::Edit(void)
|
|
||||||
{
|
|
||||||
if (HasSubMenu() || Count() == 0)
|
|
||||||
return osContinue;
|
|
||||||
cChannel *ch = GetChannel(Current());
|
|
||||||
if (ch)
|
|
||||||
return AddSubMenu(new cIptvMenuEditChannel(ch));
|
|
||||||
return osContinue;
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuChannels::New(void)
|
|
||||||
{
|
|
||||||
if (HasSubMenu())
|
|
||||||
return osContinue;
|
|
||||||
return AddSubMenu(new cIptvMenuEditChannel(GetChannel(Current()), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuChannels::Delete(void)
|
|
||||||
{
|
|
||||||
if (!HasSubMenu() && Count() > 0) {
|
|
||||||
int CurrentChannelNr = cDevice::CurrentChannel();
|
|
||||||
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
|
|
||||||
int Index = Current();
|
|
||||||
cChannel *channel = GetChannel(Current());
|
|
||||||
int DeletedChannel = channel->Number();
|
|
||||||
// Check if there is a timer using this channel:
|
|
||||||
if (channel->HasTimer()) {
|
|
||||||
Skins.Message(mtError, trVDR("Channel is being used by a timer!"));
|
|
||||||
return osContinue;
|
|
||||||
}
|
|
||||||
if (Interface->Confirm(trVDR("Delete channel?"))) {
|
|
||||||
if (CurrentChannel && channel == CurrentChannel) {
|
|
||||||
int n = Channels.GetNextNormal(CurrentChannel->Index());
|
|
||||||
if (n < 0)
|
|
||||||
n = Channels.GetPrevNormal(CurrentChannel->Index());
|
|
||||||
CurrentChannel = Channels.Get(n);
|
|
||||||
CurrentChannelNr = 0; // triggers channel switch below
|
|
||||||
}
|
|
||||||
Channels.Del(channel);
|
|
||||||
cOsdMenu::Del(Index);
|
|
||||||
Propagate();
|
|
||||||
isyslog("channel %d deleted", DeletedChannel);
|
|
||||||
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
|
|
||||||
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
|
|
||||||
Channels.SwitchTo(CurrentChannel->Number());
|
|
||||||
else
|
|
||||||
cDevice::SetCurrentChannel(CurrentChannel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return osContinue;
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvMenuChannels::ProcessKey(eKeys Key)
|
|
||||||
{
|
|
||||||
eOSState state = cOsdMenu::ProcessKey(Key);
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case osUser1: {
|
|
||||||
cChannel *channel = Channels.Last();
|
|
||||||
if (channel) {
|
|
||||||
Add(new cIptvMenuChannelItem(channel), true);
|
|
||||||
return CloseSubMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (state == osUnknown) {
|
|
||||||
switch (Key) {
|
|
||||||
case kOk: return Switch();
|
|
||||||
case kRed: return Edit();
|
|
||||||
case kGreen: return New();
|
|
||||||
case kYellow: return Delete();
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- cIptvMenuInfo ---------------------------------------------------------
|
// --- cIptvMenuInfo ---------------------------------------------------------
|
||||||
|
|
||||||
class cIptvMenuInfo : public cOsdMenu
|
class cIptvMenuInfo : public cOsdMenu
|
||||||
@@ -540,22 +21,23 @@ private:
|
|||||||
enum {
|
enum {
|
||||||
INFO_TIMEOUT_MS = 2000
|
INFO_TIMEOUT_MS = 2000
|
||||||
};
|
};
|
||||||
cString text;
|
cString textM;
|
||||||
cTimeMs timeout;
|
cTimeMs timeoutM;
|
||||||
unsigned int page;
|
unsigned int pageM;
|
||||||
void UpdateInfo();
|
void UpdateInfo();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvMenuInfo();
|
cIptvMenuInfo();
|
||||||
virtual ~cIptvMenuInfo();
|
virtual ~cIptvMenuInfo();
|
||||||
virtual void Display(void);
|
virtual void Display(void);
|
||||||
virtual eOSState ProcessKey(eKeys Key);
|
virtual eOSState ProcessKey(eKeys keyP);
|
||||||
};
|
};
|
||||||
|
|
||||||
cIptvMenuInfo::cIptvMenuInfo()
|
cIptvMenuInfo::cIptvMenuInfo()
|
||||||
:cOsdMenu(tr("IPTV Information")), text(""), timeout(), page(IPTV_DEVICE_INFO_GENERAL)
|
:cOsdMenu(tr("IPTV Information")), textM(""), timeoutM(), pageM(IPTV_DEVICE_INFO_GENERAL)
|
||||||
{
|
{
|
||||||
timeout.Set(INFO_TIMEOUT_MS);
|
SetMenuCategory(mcText);
|
||||||
|
timeoutM.Set(INFO_TIMEOUT_MS);
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes"));
|
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes"));
|
||||||
}
|
}
|
||||||
@@ -568,24 +50,24 @@ void cIptvMenuInfo::UpdateInfo()
|
|||||||
{
|
{
|
||||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||||
if (device)
|
if (device)
|
||||||
text = device->GetInformation(page);
|
textM = device->GetInformation(pageM);
|
||||||
else
|
else
|
||||||
text = cString(tr("IPTV information not available!"));
|
textM = cString(tr("IPTV information not available!"));
|
||||||
Display();
|
Display();
|
||||||
timeout.Set(INFO_TIMEOUT_MS);
|
timeoutM.Set(INFO_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvMenuInfo::Display(void)
|
void cIptvMenuInfo::Display(void)
|
||||||
{
|
{
|
||||||
cOsdMenu::Display();
|
cOsdMenu::Display();
|
||||||
DisplayMenu()->SetText(text, true);
|
DisplayMenu()->SetText(textM, true);
|
||||||
if (*text)
|
if (*textM)
|
||||||
cStatus::MsgOsdTextItem(text);
|
cStatus::MsgOsdTextItem(textM);
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
|
eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
|
||||||
{
|
{
|
||||||
switch (Key) {
|
switch (int(keyP)) {
|
||||||
case kUp|k_Repeat:
|
case kUp|k_Repeat:
|
||||||
case kUp:
|
case kUp:
|
||||||
case kDown|k_Repeat:
|
case kDown|k_Repeat:
|
||||||
@@ -594,30 +76,30 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
|
|||||||
case kLeft:
|
case kLeft:
|
||||||
case kRight|k_Repeat:
|
case kRight|k_Repeat:
|
||||||
case kRight:
|
case kRight:
|
||||||
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
|
DisplayMenu()->Scroll(NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft, NORMALKEY(keyP) == kLeft || NORMALKEY(keyP) == kRight);
|
||||||
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft);
|
cStatus::MsgOsdTextItem(NULL, NORMALKEY(keyP) == kUp || NORMALKEY(keyP) == kLeft);
|
||||||
return osContinue;
|
return osContinue;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState state = cOsdMenu::ProcessKey(Key);
|
eOSState state = cOsdMenu::ProcessKey(keyP);
|
||||||
|
|
||||||
if (state == osUnknown) {
|
if (state == osUnknown) {
|
||||||
switch (Key) {
|
switch (keyP) {
|
||||||
case kOk: return osBack;
|
case kOk: return osBack;
|
||||||
case kRed: page = IPTV_DEVICE_INFO_GENERAL;
|
case kRed: pageM = IPTV_DEVICE_INFO_GENERAL;
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
break;
|
break;
|
||||||
case kGreen: page = IPTV_DEVICE_INFO_PIDS;
|
case kGreen: pageM = IPTV_DEVICE_INFO_PIDS;
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
break;
|
break;
|
||||||
case kYellow: page = IPTV_DEVICE_INFO_FILTERS;
|
case kYellow: pageM = IPTV_DEVICE_INFO_FILTERS;
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
break;
|
break;
|
||||||
case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1);
|
case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1);
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
break;
|
break;
|
||||||
default: if (timeout.TimedOut())
|
default: if (timeoutM.TimedOut())
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
state = osContinue;
|
state = osContinue;
|
||||||
break;
|
break;
|
||||||
@@ -630,20 +112,20 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
|
|||||||
|
|
||||||
cIptvPluginSetup::cIptvPluginSetup()
|
cIptvPluginSetup::cIptvPluginSetup()
|
||||||
{
|
{
|
||||||
debug("cIptvPluginSetup::cIptvPluginSetup()\n");
|
debug("cIptvPluginSetup::%s()", __FUNCTION__);
|
||||||
tsBufferSize = IptvConfig.GetTsBufferSize();
|
tsBufferSizeM = IptvConfig.GetTsBufferSize();
|
||||||
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
|
tsBufferPrefillM = IptvConfig.GetTsBufferPrefillRatio();
|
||||||
extProtocolBasePort = IptvConfig.GetExtProtocolBasePort();
|
extProtocolBasePortM = IptvConfig.GetExtProtocolBasePort();
|
||||||
sectionFiltering = IptvConfig.GetSectionFiltering();
|
sectionFilteringM = IptvConfig.GetSectionFiltering();
|
||||||
numDisabledFilters = IptvConfig.GetDisabledFiltersCount();
|
numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount();
|
||||||
if (numDisabledFilters > SECTION_FILTER_TABLE_SIZE)
|
if (numDisabledFiltersM > SECTION_FILTER_TABLE_SIZE)
|
||||||
numDisabledFilters = SECTION_FILTER_TABLE_SIZE;
|
numDisabledFiltersM = SECTION_FILTER_TABLE_SIZE;
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
||||||
disabledFilterIndexes[i] = IptvConfig.GetDisabledFilters(i);
|
disabledFilterIndexesM[i] = IptvConfig.GetDisabledFilters(i);
|
||||||
disabledFilterNames[i] = tr(section_filter_table[i].description);
|
disabledFilterNamesM[i] = tr(section_filter_table[i].description);
|
||||||
}
|
}
|
||||||
Setup();
|
Setup();
|
||||||
SetHelp(trVDR("Channels"), NULL, NULL, trVDR("Button$Info"));
|
SetHelp(NULL, NULL, NULL, trVDR("Button$Info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvPluginSetup::Setup(void)
|
void cIptvPluginSetup::Setup(void)
|
||||||
@@ -651,28 +133,28 @@ void cIptvPluginSetup::Setup(void)
|
|||||||
int current = Current();
|
int current = Current();
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
help.Clear();
|
helpM.Clear();
|
||||||
|
|
||||||
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 1, 4));
|
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSizeM, 1, 4));
|
||||||
help.Append(tr("Define a ringbuffer size for transport streams in megabytes.\n\nSmaller sizes help memory consumption, but are more prone to buffer overflows."));
|
helpM.Append(tr("Define a ringbuffer size for transport streams in megabytes.\n\nSmaller sizes help memory consumption, but are more prone to buffer overflows."));
|
||||||
|
|
||||||
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
|
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefillM, 0, 40));
|
||||||
help.Append(tr("Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n\nThis is useful if streaming media over a slow or unreliable connection."));
|
helpM.Append(tr("Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n\nThis is useful if streaming media over a slow or unreliable connection."));
|
||||||
|
|
||||||
Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePort, 0, 0xFFF7));
|
Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePortM, 0, 0xFFF7));
|
||||||
help.Append(tr("Define a base port used by EXT protocol.\n\nThe port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."));
|
helpM.Append(tr("Define a base port used by EXT protocol.\n\nThe port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."));
|
||||||
|
|
||||||
Add(new cMenuEditBoolItem(tr("Use section filtering"), §ionFiltering));
|
Add(new cMenuEditBoolItem(tr("Use section filtering"), §ionFilteringM));
|
||||||
help.Append(tr("Define whether the section filtering shall be used.\n\nSection filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\nEnabling this feature does not affect streams that do not contain section data."));
|
helpM.Append(tr("Define 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 (sectionFiltering) {
|
if (sectionFilteringM) {
|
||||||
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFilters, 0, SECTION_FILTER_TABLE_SIZE));
|
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFiltersM, 0, SECTION_FILTER_TABLE_SIZE));
|
||||||
help.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."));
|
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 < numDisabledFilters; ++i) {
|
for (int i = 0; i < numDisabledFiltersM; ++i) {
|
||||||
// TRANSLATORS: note the singular!
|
// TRANSLATORS: note the singular!
|
||||||
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexes[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNames));
|
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexesM[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNamesM));
|
||||||
help.Append(tr("Define an ill-behaving filter to be blacklisted."));
|
helpM.Append(tr("Define an ill-behaving filter to be blacklisted."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,79 +162,70 @@ void cIptvPluginSetup::Setup(void)
|
|||||||
Display();
|
Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState cIptvPluginSetup::EditChannel(void)
|
|
||||||
{
|
|
||||||
debug("cIptvPluginSetup::EditChannel()\n");
|
|
||||||
if (HasSubMenu())
|
|
||||||
return osContinue;
|
|
||||||
return AddSubMenu(new cIptvMenuChannels());
|
|
||||||
}
|
|
||||||
|
|
||||||
eOSState cIptvPluginSetup::ShowInfo(void)
|
eOSState cIptvPluginSetup::ShowInfo(void)
|
||||||
{
|
{
|
||||||
debug("cIptvPluginSetup::ShowInfo()\n");
|
debug("cIptvPluginSetup::%s()", __FUNCTION__);
|
||||||
if (HasSubMenu())
|
if (HasSubMenu())
|
||||||
return osContinue;
|
return osContinue;
|
||||||
return AddSubMenu(new cIptvMenuInfo());
|
return AddSubMenu(new cIptvMenuInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
|
eOSState cIptvPluginSetup::ProcessKey(eKeys keyP)
|
||||||
{
|
{
|
||||||
int oldsectionFiltering = sectionFiltering;
|
int oldsectionFiltering = sectionFilteringM;
|
||||||
int oldNumDisabledFilters = numDisabledFilters;
|
int oldNumDisabledFilters = numDisabledFiltersM;
|
||||||
eOSState state = cMenuSetupPage::ProcessKey(Key);
|
eOSState state = cMenuSetupPage::ProcessKey(keyP);
|
||||||
|
|
||||||
if (state == osUnknown) {
|
if (state == osUnknown) {
|
||||||
switch (Key) {
|
switch (keyP) {
|
||||||
case kRed: return EditChannel();
|
|
||||||
case kBlue: return ShowInfo();
|
case kBlue: return ShowInfo();
|
||||||
case kInfo: if (Current() < help.Size())
|
case kInfo: if (Current() < helpM.Size())
|
||||||
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()]));
|
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; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) {
|
if ((keyP != kNone) && ((numDisabledFiltersM != oldNumDisabledFilters) || (sectionFilteringM != oldsectionFiltering))) {
|
||||||
while ((numDisabledFilters < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
|
while ((numDisabledFiltersM < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
|
||||||
disabledFilterIndexes[--oldNumDisabledFilters] = -1;
|
disabledFilterIndexesM[--oldNumDisabledFilters] = -1;
|
||||||
Setup();
|
Setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvPluginSetup::StoreFilters(const char *Name, int *Values)
|
void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP)
|
||||||
{
|
{
|
||||||
char buffer[SECTION_FILTER_TABLE_SIZE * 4];
|
char buffer[SECTION_FILTER_TABLE_SIZE * 4];
|
||||||
char *q = buffer;
|
char *q = buffer;
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
||||||
char s[3];
|
char s[3];
|
||||||
if (Values[i] < 0)
|
if (valuesP[i] < 0)
|
||||||
break;
|
break;
|
||||||
if (q > buffer)
|
if (q > buffer)
|
||||||
*q++ = ' ';
|
*q++ = ' ';
|
||||||
snprintf(s, sizeof(s), "%d", Values[i]);
|
snprintf(s, sizeof(s), "%d", valuesP[i]);
|
||||||
strncpy(q, s, strlen(s));
|
strncpy(q, s, strlen(s));
|
||||||
q += strlen(s);
|
q += strlen(s);
|
||||||
}
|
}
|
||||||
*q = 0;
|
*q = 0;
|
||||||
debug("cIptvPluginSetup::StoreFilters(): %s=%s\n", Name, buffer);
|
debug("cIptvPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, buffer);
|
||||||
SetupStore(Name, buffer);
|
SetupStore(nameP, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvPluginSetup::Store(void)
|
void cIptvPluginSetup::Store(void)
|
||||||
{
|
{
|
||||||
// Store values into setup.conf
|
// Store values into setup.conf
|
||||||
SetupStore("TsBufferSize", tsBufferSize);
|
SetupStore("TsBufferSize", tsBufferSizeM);
|
||||||
SetupStore("TsBufferPrefill", tsBufferPrefill);
|
SetupStore("TsBufferPrefill", tsBufferPrefillM);
|
||||||
SetupStore("ExtProtocolBasePort", extProtocolBasePort);
|
SetupStore("ExtProtocolBasePort", extProtocolBasePortM);
|
||||||
SetupStore("SectionFiltering", sectionFiltering);
|
SetupStore("SectionFiltering", sectionFilteringM);
|
||||||
StoreFilters("DisabledFilters", disabledFilterIndexes);
|
StoreFilters("DisabledFilters", disabledFilterIndexesM);
|
||||||
// Update global config
|
// Update global config
|
||||||
IptvConfig.SetTsBufferSize(tsBufferSize);
|
IptvConfig.SetTsBufferSize(tsBufferSizeM);
|
||||||
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
|
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefillM);
|
||||||
IptvConfig.SetExtProtocolBasePort(extProtocolBasePort);
|
IptvConfig.SetExtProtocolBasePort(extProtocolBasePortM);
|
||||||
IptvConfig.SetSectionFiltering(sectionFiltering);
|
IptvConfig.SetSectionFiltering(sectionFilteringM);
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
|
||||||
IptvConfig.SetDisabledFilters(i, disabledFilterIndexes[i]);
|
IptvConfig.SetDisabledFilters(i, disabledFilterIndexesM[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
22
setup.h
22
setup.h
@@ -9,27 +9,27 @@
|
|||||||
#define __IPTV_SETUP_H
|
#define __IPTV_SETUP_H
|
||||||
|
|
||||||
#include <vdr/menuitems.h>
|
#include <vdr/menuitems.h>
|
||||||
|
#include <vdr/sourceparams.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
class cIptvPluginSetup : public cMenuSetupPage
|
class cIptvPluginSetup : public cMenuSetupPage
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int tsBufferSize;
|
int tsBufferSizeM;
|
||||||
int tsBufferPrefill;
|
int tsBufferPrefillM;
|
||||||
int extProtocolBasePort;
|
int extProtocolBasePortM;
|
||||||
int sectionFiltering;
|
int sectionFilteringM;
|
||||||
int numDisabledFilters;
|
int numDisabledFiltersM;
|
||||||
int disabledFilterIndexes[SECTION_FILTER_TABLE_SIZE];
|
int disabledFilterIndexesM[SECTION_FILTER_TABLE_SIZE];
|
||||||
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
|
const char *disabledFilterNamesM[SECTION_FILTER_TABLE_SIZE];
|
||||||
cVector<const char*> help;
|
cVector<const char*> helpM;
|
||||||
|
|
||||||
eOSState EditChannel(void);
|
|
||||||
eOSState ShowInfo(void);
|
eOSState ShowInfo(void);
|
||||||
void Setup(void);
|
void Setup(void);
|
||||||
void StoreFilters(const char *Name, int *Values);
|
void StoreFilters(const char *nameP, int *valuesP);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual eOSState ProcessKey(eKeys Key);
|
virtual eOSState ProcessKey(eKeys keyP);
|
||||||
virtual void Store(void);
|
virtual void Store(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
107
sidscanner.c
107
sidscanner.c
@@ -11,55 +11,88 @@
|
|||||||
#include "sidscanner.h"
|
#include "sidscanner.h"
|
||||||
|
|
||||||
cSidScanner::cSidScanner(void)
|
cSidScanner::cSidScanner(void)
|
||||||
|
: channelIdM(tChannelID::InvalidID),
|
||||||
|
sidFoundM(false),
|
||||||
|
nidFoundM(false),
|
||||||
|
tidFoundM(false),
|
||||||
|
isActiveM(false)
|
||||||
{
|
{
|
||||||
debug("cSidScanner::cSidScanner()\n");
|
debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
channel = cChannel();
|
|
||||||
Set(0x00, 0x00); // PAT
|
Set(0x00, 0x00); // PAT
|
||||||
|
Set(0x10, 0x40); // NIT
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSidScanner::SetStatus(bool On)
|
cSidScanner::~cSidScanner()
|
||||||
{
|
{
|
||||||
debug("cSidScanner::SetStatus(): %d\n", On);
|
debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
cFilter::SetStatus(On);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSidScanner::SetChannel(const cChannel *Channel)
|
void cSidScanner::SetChannel(const tChannelID &channelIdP)
|
||||||
{
|
{
|
||||||
if (Channel) {
|
debug("cSidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
|
||||||
debug("cSidScanner::SetChannel(): %s\n", Channel->PluginParam());
|
channelIdM = channelIdP;
|
||||||
channel = *Channel;
|
sidFoundM = false;
|
||||||
}
|
nidFoundM = false;
|
||||||
else {
|
tidFoundM = false;
|
||||||
debug("cSidScanner::SetChannel()\n");
|
|
||||||
channel = cChannel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSidScanner::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
|
void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP)
|
||||||
{
|
{
|
||||||
//debug("cSidScanner::Process()\n");
|
int newSid = -1, newNid = -1, newTid = -1;
|
||||||
if ((Pid == 0x00) && (Tid == 0x00) && channel.GetChannelID().Valid()) {
|
|
||||||
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
|
//debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
SI::PAT pat(Data, false);
|
if (!isActiveM)
|
||||||
if (!pat.CheckCRCAndParse())
|
return;
|
||||||
return;
|
if (channelIdM.Valid()) {
|
||||||
SI::PAT::Association assoc;
|
if ((pidP == 0x00) && (tidP == 0x00)) {
|
||||||
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
|
||||||
if (!assoc.isNITPid()) {
|
SI::PAT pat(dataP, false);
|
||||||
if (assoc.getServiceId() != channel.Sid()) {
|
if (!pat.CheckCRCAndParse())
|
||||||
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
|
return;
|
||||||
if (!Channels.Lock(true, 10))
|
SI::PAT::Association assoc;
|
||||||
return;
|
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
||||||
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
|
if (!assoc.isNITPid()) {
|
||||||
if (IptvChannel)
|
if (assoc.getServiceId() != channelIdM.Sid()) {
|
||||||
IptvChannel->SetId(IptvChannel->Nid(), IptvChannel->Tid(),
|
debug("cSidScanner::%s(): sid=%d", __FUNCTION__, assoc.getServiceId());
|
||||||
assoc.getServiceId(), IptvChannel->Rid());
|
newSid = assoc.getServiceId();
|
||||||
Channels.Unlock();
|
}
|
||||||
|
sidFoundM = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
SetChannel(NULL);
|
|
||||||
SetStatus(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((pidP == 0x10) && (tidP == 0x40)) {
|
||||||
|
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
|
||||||
|
SI::NIT nit(dataP, false);
|
||||||
|
if (!nit.CheckCRCAndParse())
|
||||||
|
return;
|
||||||
|
SI::NIT::TransportStream ts;
|
||||||
|
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
|
||||||
|
if (ts.getTransportStreamId() != channelIdM.Tid()) {
|
||||||
|
debug("cSidScanner::%s(): tsid=%d", __FUNCTION__, ts.getTransportStreamId());
|
||||||
|
newTid = ts.getTransportStreamId();
|
||||||
|
}
|
||||||
|
tidFoundM = true;
|
||||||
|
break; // default to the first one
|
||||||
|
}
|
||||||
|
if (nit.getNetworkId() != channelIdM.Nid()) {
|
||||||
|
debug("cSidScanner::%s(): nid=%d\n", __FUNCTION__, ts.getTransportStreamId());
|
||||||
|
newNid = nit.getNetworkId();
|
||||||
|
}
|
||||||
|
nidFoundM = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((newSid >= 0) || (newNid >= 0) || (newTid >= 0)) {
|
||||||
|
if (!Channels.Lock(true, 10))
|
||||||
|
return;
|
||||||
|
cChannel *IptvChannel = Channels.GetByChannelID(channelIdM);
|
||||||
|
if (IptvChannel)
|
||||||
|
IptvChannel->SetId((newNid < 0) ? IptvChannel->Nid() : newNid, (newTid < 0) ? IptvChannel->Tid() : newTid,
|
||||||
|
(newSid < 0) ? IptvChannel->Sid() : newSid, IptvChannel->Rid());
|
||||||
|
Channels.Unlock();
|
||||||
|
}
|
||||||
|
if (sidFoundM && nidFoundM && tidFoundM) {
|
||||||
|
SetChannel(tChannelID::InvalidID);
|
||||||
|
SetStatus(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
sidscanner.h
16
sidscanner.h
@@ -13,17 +13,21 @@
|
|||||||
|
|
||||||
class cSidScanner : public cFilter {
|
class cSidScanner : public cFilter {
|
||||||
private:
|
private:
|
||||||
cChannel channel;
|
tChannelID channelIdM;
|
||||||
|
bool sidFoundM;
|
||||||
|
bool nidFoundM;
|
||||||
|
bool tidFoundM;
|
||||||
|
bool isActiveM;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
|
virtual void Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP);
|
||||||
virtual void SetStatus(bool On);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cSidScanner(void);
|
cSidScanner(void);
|
||||||
void SetChannel(const cChannel *Channel);
|
~cSidScanner();
|
||||||
void Open() { SetStatus(true); }
|
void SetChannel(const tChannelID &channelIdP);
|
||||||
void Close() { SetStatus(false); }
|
void Open() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = true; }
|
||||||
|
void Close() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __SIDSCANNER_H
|
#endif // __SIDSCANNER_H
|
||||||
|
|||||||
408
socket.c
408
socket.c
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <net/if.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -18,163 +19,392 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
|
||||||
cIptvSocket::cIptvSocket()
|
cIptvSocket::cIptvSocket()
|
||||||
: socketPort(0),
|
: socketPortM(0),
|
||||||
socketDesc(-1),
|
socketDescM(-1),
|
||||||
isActive(false)
|
isActiveM(false)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::cIptvSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvSocket::~cIptvSocket()
|
cIptvSocket::~cIptvSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::~cIptvSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
|
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::OpenSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// If socket is there already and it is bound to a different port, it must
|
// If socket is there already and it is bound to a different port, it must
|
||||||
// be closed first
|
// be closed first
|
||||||
if (Port != socketPort) {
|
if (portP != socketPortM) {
|
||||||
debug("cIptvSocket::OpenSocket(): Socket tear-down\n");
|
debug("cIptvSocket::%s(): socket tear-down", __FUNCTION__);
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
}
|
}
|
||||||
// Bind to the socket if it is not active already
|
// Bind to the socket if it is not active already
|
||||||
if (socketDesc < 0) {
|
if (socketDescM < 0) {
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
// Create socket
|
// Create socket
|
||||||
if (isUdp)
|
if (isUdpP)
|
||||||
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
socketDescM = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
else
|
else
|
||||||
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
|
socketDescM = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
|
ERROR_IF_RET(socketDescM < 0, "socket()", return false);
|
||||||
// Make it use non-blocking I/O to avoid stuck read calls
|
// Make it use non-blocking I/O to avoid stuck read calls
|
||||||
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()",
|
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
|
||||||
CloseSocket(), return false);
|
CloseSocket(), return false);
|
||||||
// Allow multiple sockets to use the same PORT number
|
// Allow multiple sockets to use the same PORT number
|
||||||
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt()",
|
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0,
|
||||||
CloseSocket(), return false);
|
"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__
|
||||||
// Bind socket
|
// Bind socket
|
||||||
memset(&sockAddr, '\0', sizeof(sockAddr));
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
sockAddr.sin_family = AF_INET;
|
sockAddrM.sin_family = AF_INET;
|
||||||
sockAddr.sin_port = htons((uint16_t)(Port & 0xFFFF));
|
sockAddrM.sin_port = htons((uint16_t)(portP & 0xFFFF));
|
||||||
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
if (isUdp) {
|
if (isUdpP)
|
||||||
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0,
|
||||||
ERROR_IF_FUNC(err < 0, "bind()", CloseSocket(), return false);
|
"bind()", CloseSocket(), return false);
|
||||||
}
|
|
||||||
// Update socket port
|
// Update socket port
|
||||||
socketPort = Port;
|
socketPortM = portP;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvSocket::CloseSocket(void)
|
void cIptvSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::CloseSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// Check if socket exists
|
// Check if socket exists
|
||||||
if (socketDesc >= 0) {
|
if (socketDescM >= 0) {
|
||||||
close(socketDesc);
|
close(socketDescM);
|
||||||
socketDesc = -1;
|
socketDescM = -1;
|
||||||
|
socketPortM = 0;
|
||||||
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
|
||||||
|
{
|
||||||
|
if (inAddrP) {
|
||||||
|
// First try only the IP address
|
||||||
|
*inAddrP = htonl(inet_addr(addrP));
|
||||||
|
if (*inAddrP == htonl(INADDR_NONE)) {
|
||||||
|
debug("cIptvSocket::%s(%s): cannot convert to address", __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 = htonl(inet_addr(*host->h_addr_list));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// UDP socket class
|
// UDP socket class
|
||||||
cIptvUdpSocket::cIptvUdpSocket()
|
cIptvUdpSocket::cIptvUdpSocket()
|
||||||
|
: streamAddrM(htonl(INADDR_ANY)),
|
||||||
|
sourceAddrM(htonl(INADDR_ANY)),
|
||||||
|
useIGMPv3M(false)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::cIptvUdpSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvUdpSocket::~cIptvUdpSocket()
|
cIptvUdpSocket::~cIptvUdpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvUdpSocket::OpenSocket(const int Port)
|
bool cIptvUdpSocket::OpenSocket(const int portP)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::OpenSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
return cIptvSocket::OpenSocket(Port, true);
|
streamAddrM = htonl(INADDR_ANY);
|
||||||
|
sourceAddrM = htonl(INADDR_ANY);
|
||||||
|
useIGMPv3M = false;
|
||||||
|
return cIptvSocket::OpenSocket(portP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
|
||||||
{
|
{
|
||||||
//debug("cIptvUdpSocket::Read()\n");
|
debug("cIptvUdpSocket::%s(%d, %s, %s, %d)", __FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
|
||||||
|
CheckAddress(streamAddrP, &streamAddrM);
|
||||||
|
CheckAddress(sourceAddrP, &sourceAddrM);
|
||||||
|
useIGMPv3M = useIGMPv3P;
|
||||||
|
return cIptvSocket::OpenSocket(portP, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cIptvUdpSocket::CloseSocket(void)
|
||||||
|
{
|
||||||
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
|
streamAddrM = htonl(INADDR_ANY);
|
||||||
|
sourceAddrM = htonl(INADDR_ANY);
|
||||||
|
useIGMPv3M = false;
|
||||||
|
cIptvSocket::CloseSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvUdpSocket::JoinMulticast(void)
|
||||||
|
{
|
||||||
|
debug("cIptvUdpSocket::%s()", __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)
|
||||||
|
{
|
||||||
|
debug("cIptvUdpSocket::%s()", __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)
|
||||||
|
{
|
||||||
|
//debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in %s\n", __FUNCTION__);
|
error("Invalid socket in cIptvUdpSocket::%s()\n", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
// Read data from socket
|
// Read data from socket in a loop
|
||||||
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
|
do {
|
||||||
len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
struct msghdr msgh;
|
||||||
if ((len > 0) && (BufferAddr[0] == TS_SYNC_BYTE)) {
|
struct iovec iov;
|
||||||
return len;
|
char cbuf[256];
|
||||||
}
|
len = 0;
|
||||||
else if (len > 3) {
|
// Initialize iov and msgh structures
|
||||||
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
|
memset(&msgh, 0, sizeof(struct msghdr));
|
||||||
// version
|
iov.iov_base = bufferAddrP;
|
||||||
unsigned int v = (BufferAddr[0] >> 6) & 0x03;
|
iov.iov_len = bufferLenP;
|
||||||
// extension bit
|
msgh.msg_control = cbuf;
|
||||||
unsigned int x = (BufferAddr[0] >> 4) & 0x01;
|
msgh.msg_controllen = sizeof(cbuf);
|
||||||
// cscr count
|
msgh.msg_name = &sockAddrM;
|
||||||
unsigned int cc = BufferAddr[0] & 0x0F;
|
msgh.msg_namelen = addrlen;
|
||||||
// payload type: MPEG2 TS = 33
|
msgh.msg_iov = &iov;
|
||||||
//unsigned int pt = readBuffer[1] & 0x7F;
|
msgh.msg_iovlen = 1;
|
||||||
// header lenght
|
msgh.msg_flags = 0;
|
||||||
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
|
|
||||||
// check if extension
|
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
|
||||||
if (x) {
|
len = (int)recvmsg(socketDescM, &msgh, MSG_DONTWAIT);
|
||||||
// extension header length
|
else
|
||||||
unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
|
break;
|
||||||
(BufferAddr[headerlen + 3] & 0xFF));
|
if (len > 0) {
|
||||||
// update header length
|
#ifndef __FreeBSD__
|
||||||
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
|
// Process auxiliary received data and validate source address
|
||||||
}
|
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
|
||||||
// Check that rtp is version 2 and payload contains multiple of TS packet data
|
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
|
||||||
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
|
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
|
||||||
(BufferAddr[headerlen] == TS_SYNC_BYTE)) {
|
if ((i->ipi_addr.s_addr == streamAddrM) || (htonl(INADDR_ANY) == streamAddrM)) {
|
||||||
// Set argument point to payload in read buffer
|
#endif // __FreeBSD__
|
||||||
memmove(BufferAddr, &BufferAddr[headerlen], (len - headerlen));
|
if (bufferAddrP[0] == TS_SYNC_BYTE)
|
||||||
return (len - headerlen);
|
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;
|
||||||
|
// Header lenght
|
||||||
|
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
|
||||||
|
// Check if extension
|
||||||
|
if (x) {
|
||||||
|
// Extension header length
|
||||||
|
unsigned int ehl = (((bufferAddrP[headerlen + 2] & 0xFF) << 8) |
|
||||||
|
(bufferAddrP[headerlen + 3] & 0xFF));
|
||||||
|
// Update header length
|
||||||
|
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
|
||||||
|
}
|
||||||
|
// Check that rtp is version 2 and payload contains multiple of TS packet data
|
||||||
|
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
|
||||||
|
(bufferAddrP[headerlen] == TS_SYNC_BYTE)) {
|
||||||
|
// Set argument point to payload in read buffer
|
||||||
|
memmove(bufferAddrP, &bufferAddrP[headerlen], (len - headerlen));
|
||||||
|
return (len - headerlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifndef __FreeBSD__
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // __FreeBSD__
|
||||||
|
}
|
||||||
|
} while (len > 0);
|
||||||
|
ERROR_IF_RET(len < 0 && errno != EAGAIN, "recvmsg()", return -1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TCP socket class
|
// TCP socket class
|
||||||
cIptvTcpSocket::cIptvTcpSocket()
|
cIptvTcpSocket::cIptvTcpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::cIptvTcpSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvTcpSocket::~cIptvTcpSocket()
|
cIptvTcpSocket::~cIptvTcpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::OpenSocket(const int Port)
|
bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP)
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::OpenSocket()\n");
|
debug("cIptvTcpSocket::%s(%d, %s)", __FUNCTION__, portP, streamAddrP);
|
||||||
return cIptvSocket::OpenSocket(Port, false);
|
// Socket must be opened before setting the host address
|
||||||
|
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.sin_addr.s_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
void cIptvTcpSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvTcpSocket::Read()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
|
cIptvSocket::CloseSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvTcpSocket::ConnectSocket(void)
|
||||||
|
{
|
||||||
|
debug("cIptvTcpSocket::%s()", __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)
|
||||||
|
{
|
||||||
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in %s\n", __FUNCTION__);
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
int len = 0;
|
||||||
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
// Read data from socket
|
// Read data from socket
|
||||||
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
|
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
|
||||||
return (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
|
len = (int)recvfrom(socketDescM, bufferAddrP, bufferLenP, MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
(struct sockaddr *)&sockAddrM, &addrlen);
|
||||||
return 0;
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
|
||||||
|
{
|
||||||
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
|
// Error out if socket not initialized
|
||||||
|
if (socketDescM <= 0) {
|
||||||
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
|
// Wait 500ms for data
|
||||||
|
int retval = select_single_desc(socketDescM, 1000 * timeoutMsP, false);
|
||||||
|
// Check if error
|
||||||
|
if (retval < 0)
|
||||||
|
return false;
|
||||||
|
// Check if data available
|
||||||
|
else if (retval) {
|
||||||
|
retval = (int)recvfrom(socketDescM, bufferAddrP, 1, MSG_DONTWAIT,
|
||||||
|
(struct sockaddr *)&sockAddrM, &addrlen);
|
||||||
|
if (retval <= 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP)
|
||||||
|
{
|
||||||
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
|
// Error out if socket not initialized
|
||||||
|
if (socketDescM <= 0) {
|
||||||
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
39
socket.h
39
socket.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* protocoludp.h: IPTV plugin for the Video Disk Recorder
|
* socket.h: IPTV plugin for the Video Disk Recorder
|
||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
@@ -9,17 +9,23 @@
|
|||||||
#define __IPTV_SOCKET_H
|
#define __IPTV_SOCKET_H
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif // __FreeBSD__
|
||||||
|
|
||||||
class cIptvSocket {
|
class cIptvSocket {
|
||||||
protected:
|
private:
|
||||||
int socketPort;
|
int socketPortM;
|
||||||
int socketDesc;
|
|
||||||
struct sockaddr_in sockAddr;
|
|
||||||
bool isActive;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool OpenSocket(const int Port, const bool isUdp);
|
int socketDescM;
|
||||||
|
struct sockaddr_in sockAddrM;
|
||||||
|
bool isActiveM;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool OpenSocket(const int portP, const bool isUdpP);
|
||||||
void CloseSocket(void);
|
void CloseSocket(void);
|
||||||
|
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvSocket();
|
cIptvSocket();
|
||||||
@@ -27,19 +33,32 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class cIptvUdpSocket : public cIptvSocket {
|
class cIptvUdpSocket : public cIptvSocket {
|
||||||
|
private:
|
||||||
|
in_addr_t streamAddrM;
|
||||||
|
in_addr_t sourceAddrM;
|
||||||
|
bool useIGMPv3M;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvUdpSocket();
|
cIptvUdpSocket();
|
||||||
virtual ~cIptvUdpSocket();
|
virtual ~cIptvUdpSocket();
|
||||||
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool OpenSocket(const int Port);
|
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 {
|
class cIptvTcpSocket : public cIptvSocket {
|
||||||
public:
|
public:
|
||||||
cIptvTcpSocket();
|
cIptvTcpSocket();
|
||||||
virtual ~cIptvTcpSocket();
|
virtual ~cIptvTcpSocket();
|
||||||
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool OpenSocket(const int Port);
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __IPTV_SOCKET_H
|
#endif // __IPTV_SOCKET_H
|
||||||
|
|||||||
186
source.c
Normal file
186
source.c
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* 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 "source.h"
|
||||||
|
|
||||||
|
// --- cIptvTransponderParameters --------------------------------------------
|
||||||
|
|
||||||
|
cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
|
||||||
|
: sidScanM(0),
|
||||||
|
pidScanM(0),
|
||||||
|
protocolM(eProtocolUDP),
|
||||||
|
parameterM(0)
|
||||||
|
{
|
||||||
|
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, parametersP);
|
||||||
|
|
||||||
|
memset(&addressM, 0, sizeof(addressM));
|
||||||
|
Parse(parametersP);
|
||||||
|
}
|
||||||
|
|
||||||
|
cString cIptvTransponderParameters::ToString(char typeP) const
|
||||||
|
{
|
||||||
|
debug("cIptvTransponderParameters::%s(%c)", __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)
|
||||||
|
{
|
||||||
|
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, strP);
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
if (strP && *strP) {
|
||||||
|
const char *delim = "|";
|
||||||
|
char *str = strdup(strP);
|
||||||
|
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\n", str);
|
||||||
|
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- cIptvSourceParam ------------------------------------------------------
|
||||||
|
|
||||||
|
const char *cIptvSourceParam::allowedProtocolCharsS = " abcdefghijklmnopqrstuvwxyz0123456789-.,#~\\^$[]()*+?{}/%@&=";
|
||||||
|
|
||||||
|
cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
|
||||||
|
: cSourceParam(sourceP, descriptionP),
|
||||||
|
paramM(0),
|
||||||
|
nidM(0),
|
||||||
|
tidM(0),
|
||||||
|
ridM(0),
|
||||||
|
dataM(),
|
||||||
|
itpM()
|
||||||
|
{
|
||||||
|
debug("cIptvSourceParam::%s(%c, %s)", __FUNCTION__, sourceP, descriptionP);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
|
||||||
|
dataM = *channelP;
|
||||||
|
nidM = dataM.Nid();
|
||||||
|
tidM = dataM.Tid();
|
||||||
|
ridM = dataM.Rid();
|
||||||
|
itpM.Parse(dataM.Parameters());
|
||||||
|
paramM = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cIptvSourceParam::GetData(cChannel *channelP)
|
||||||
|
{
|
||||||
|
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
|
||||||
|
channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
|
||||||
|
channelP->SetId(nidM, tidM, channelP->Sid(), ridM);
|
||||||
|
}
|
||||||
|
|
||||||
|
cOsdItem *cIptvSourceParam::GetOsdItem(void)
|
||||||
|
{
|
||||||
|
debug("cIptvSourceParam::%s()", __FUNCTION__);
|
||||||
|
switch (paramM++) {
|
||||||
|
case 0: return new cMenuEditIntItem( tr("Nid"), &nidM, 0);
|
||||||
|
case 1: return new cMenuEditIntItem( tr("Tid"), &tidM, 0);
|
||||||
|
case 2: return new cMenuEditIntItem( tr("Rid"), &ridM, 0);
|
||||||
|
case 3: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM);
|
||||||
|
case 4: return new cMenuEditBoolItem(tr("Scan pids"), &itpM.pidScanM);
|
||||||
|
case 5: return new cMenuEditStraItem(tr("Protocol"), &itpM.protocolM, ELEMENTS(protocolsM), protocolsM);
|
||||||
|
case 6: return new cMenuEditStrItem( tr("Address"), itpM.addressM, sizeof(itpM.addressM), allowedProtocolCharsS);
|
||||||
|
case 7: return new cMenuEditIntItem( tr("Parameter"), &itpM.parameterM, 0, 0xFFFF);
|
||||||
|
default: return NULL;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
71
source.h
Normal file
71
source.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* 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];
|
||||||
|
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 nidM;
|
||||||
|
int tidM;
|
||||||
|
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
|
||||||
197
statistics.c
197
statistics.c
@@ -11,87 +11,87 @@
|
|||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
// Section statistic class
|
// Section statistics class
|
||||||
cIptvSectionStatistics::cIptvSectionStatistics()
|
cIptvSectionStatistics::cIptvSectionStatistics()
|
||||||
: filteredData(0),
|
: filteredDataM(0),
|
||||||
numberOfCalls(0),
|
numberOfCallsM(0),
|
||||||
timer(),
|
timerM(),
|
||||||
mutex()
|
mutexM()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::cIptvSectionStatistics()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvSectionStatistics::~cIptvSectionStatistics()
|
cIptvSectionStatistics::~cIptvSectionStatistics()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvSectionStatistics::GetSectionStatistic()
|
cString cIptvSectionStatistics::GetSectionStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::GetStatistic()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timer.Set();
|
timerM.Set();
|
||||||
long bitrate = elapsed ? (long)(1000.0L * filteredData / KILOBYTE(1) / elapsed) : 0L;
|
long bitrate = elapsed ? (long)(1000.0L * filteredDataM / KILOBYTE(1) / elapsed) : 0L;
|
||||||
if (!IptvConfig.GetUseBytes())
|
if (!IptvConfig.GetUseBytes())
|
||||||
bitrate *= 8;
|
bitrate *= 8;
|
||||||
// no trailing linefeed here!
|
// no trailing linefeed here!
|
||||||
cString info = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCalls, bitrate,
|
cString s = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCallsM, bitrate,
|
||||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||||
filteredData = numberOfCalls = 0;
|
filteredDataM = numberOfCallsM = 0;
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvSectionStatistics::AddSectionStatistic(long Bytes, long Calls)
|
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
|
//debug("cIptvSectionStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, callsP);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
filteredData += Bytes;
|
filteredDataM += bytesP;
|
||||||
numberOfCalls += Calls;
|
numberOfCallsM += callsP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- cIptvPidStatistics ----------------------------------------------------
|
// --- cIptvPidStatistics ----------------------------------------------------
|
||||||
|
|
||||||
// Device statistic class
|
// Device statistics class
|
||||||
cIptvPidStatistics::cIptvPidStatistics()
|
cIptvPidStatistics::cIptvPidStatistics()
|
||||||
: timer(),
|
: timerM(),
|
||||||
mutex()
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvPidStatistics::cIptvPidStatistics()\n");
|
debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
memset(mostActivePids, '\0', sizeof(mostActivePids));
|
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvPidStatistics::~cIptvPidStatistics()
|
cIptvPidStatistics::~cIptvPidStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
|
debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvPidStatistics::GetPidStatistic()
|
cString cIptvPidStatistics::GetPidStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::GetStatistic()\n");
|
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timer.Set();
|
timerM.Set();
|
||||||
cString info("Active pids:\n");
|
cString s("Active pids:\n");
|
||||||
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
|
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
|
||||||
if (mostActivePids[i].pid) {
|
if (mostActivePidsM[i].pid) {
|
||||||
long bitrate = elapsed ? (long)(1000.0L * mostActivePids[i].DataAmount / KILOBYTE(1) / elapsed) : 0L;
|
long bitrate = elapsed ? (long)(1000.0L * mostActivePidsM[i].DataAmount / KILOBYTE(1) / elapsed) : 0L;
|
||||||
if (!IptvConfig.GetUseBytes())
|
if (!IptvConfig.GetUseBytes())
|
||||||
bitrate *= 8;
|
bitrate *= 8;
|
||||||
info = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *info, i,
|
s = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *s, i,
|
||||||
mostActivePids[i].pid, bitrate,
|
mostActivePidsM[i].pid, bitrate,
|
||||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(mostActivePids, '\0', sizeof(mostActivePids));
|
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
|
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::SortPids()\n");
|
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
pidStruct *comp1 = (pidStruct*)data1;
|
const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P);
|
||||||
pidStruct *comp2 = (pidStruct*)data2;
|
const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P);
|
||||||
if (comp1->DataAmount > comp2->DataAmount)
|
if (comp1->DataAmount > comp2->DataAmount)
|
||||||
return -1;
|
return -1;
|
||||||
if (comp1->DataAmount < comp2->DataAmount)
|
if (comp1->DataAmount < comp2->DataAmount)
|
||||||
@@ -99,112 +99,113 @@ int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload)
|
void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::AddStatistic(pid=%ld, payload=%ld)\n", Pid, Payload);
|
//debug("cIptvPidStatistics::%s(%ld, %ld)", __FUNCTION__, pidP, payloadP);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
const int numberOfElements = sizeof(mostActivePids) / sizeof(pidStruct);
|
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
|
||||||
// If our statistic already is in the array, update it and quit
|
// If our statistic already is in the array, update it and quit
|
||||||
for (int i = 0; i < numberOfElements; ++i) {
|
for (int i = 0; i < numberOfElements; ++i) {
|
||||||
if (mostActivePids[i].pid == Pid) {
|
if (mostActivePidsM[i].pid == pidP) {
|
||||||
mostActivePids[i].DataAmount += Payload;
|
mostActivePidsM[i].DataAmount += payloadP;
|
||||||
// Now re-sort the array and quit
|
// Now re-sort the array and quit
|
||||||
qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
|
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Apparently our pid isn't in the array. Replace the last element with this
|
// Apparently our pid isn't in the array. Replace the last element with this
|
||||||
// one if new payload is greater
|
// one if new payload is greater
|
||||||
if (mostActivePids[numberOfElements - 1].DataAmount < Payload) {
|
if (mostActivePidsM[numberOfElements - 1].DataAmount < payloadP) {
|
||||||
mostActivePids[numberOfElements - 1].pid = Pid;
|
mostActivePidsM[numberOfElements - 1].pid = pidP;
|
||||||
mostActivePids[numberOfElements - 1].DataAmount = Payload;
|
mostActivePidsM[numberOfElements - 1].DataAmount = payloadP;
|
||||||
// Re-sort
|
// Re-sort
|
||||||
qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
|
qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- cIptvStreamerStatistics -----------------------------------------------
|
// --- cIptvStreamerStatistics -----------------------------------------------
|
||||||
|
|
||||||
// Streamer statistic class
|
// Streamer statistics class
|
||||||
cIptvStreamerStatistics::cIptvStreamerStatistics()
|
cIptvStreamerStatistics::cIptvStreamerStatistics()
|
||||||
: dataBytes(0),
|
: dataBytesM(0),
|
||||||
timer(),
|
timerM(),
|
||||||
mutex()
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamerStatistics::cIptvStreamerStatistics()\n");
|
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
|
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvStreamerStatistics::GetStreamerStatistic()
|
cString cIptvStreamerStatistics::GetStreamerStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::GetStatistic()\n");
|
//debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timer.Set();
|
timerM.Set();
|
||||||
long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
|
long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L;
|
||||||
if (!IptvConfig.GetUseBytes())
|
if (!IptvConfig.GetUseBytes())
|
||||||
bitrate *= 8;
|
bitrate *= 8;
|
||||||
cString info = cString::sprintf("Stream bitrate: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
|
cString s = cString::sprintf("%ld k%s/s", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||||
dataBytes = 0;
|
dataBytesM = 0;
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
|
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
|
//debug("cIptvStreamerStatistics::%s(%ld)", __FUNCTION__, bytesP);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
dataBytes += Bytes;
|
dataBytesM += bytesP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Buffer statistic class
|
// Buffer statistics class
|
||||||
cIptvBufferStatistics::cIptvBufferStatistics()
|
cIptvBufferStatistics::cIptvBufferStatistics()
|
||||||
: dataBytes(0),
|
: dataBytesM(0),
|
||||||
usedSpace(0),
|
freeSpaceM(0),
|
||||||
timer(),
|
usedSpaceM(0),
|
||||||
mutex()
|
timerM(),
|
||||||
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvBufferStatistics::cIptvBufferStatistics()\n");
|
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvBufferStatistics::~cIptvBufferStatistics()
|
cIptvBufferStatistics::~cIptvBufferStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
|
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvBufferStatistics::GetBufferStatistic()
|
cString cIptvBufferStatistics::GetBufferStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvBufferStatistics::GetStatistic()\n");
|
//debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timer.Set();
|
timerM.Set();
|
||||||
long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
|
long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L;
|
||||||
long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
|
long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
|
||||||
float percentage = (float)((float)usedSpace / (float)totalSpace * 100.0);
|
float percentage = (float)((float)usedSpaceM / (float)totalSpace * 100.0);
|
||||||
long totalKilos = totalSpace / KILOBYTE(1);
|
long totalKilos = totalSpace / KILOBYTE(1);
|
||||||
long usedKilos = usedSpace / KILOBYTE(1);
|
long usedKilos = usedSpaceM / KILOBYTE(1);
|
||||||
if (!IptvConfig.GetUseBytes()) {
|
if (!IptvConfig.GetUseBytes()) {
|
||||||
bitrate *= 8;
|
bitrate *= 8;
|
||||||
totalKilos *= 8;
|
totalKilos *= 8;
|
||||||
usedKilos *= 8;
|
usedKilos *= 8;
|
||||||
}
|
}
|
||||||
cString info = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate,
|
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", usedKilos, totalKilos,
|
||||||
IptvConfig.GetUseBytes() ? "B" : "bit", percentage);
|
IptvConfig.GetUseBytes() ? "B" : "bit", percentage);
|
||||||
dataBytes = 0;
|
dataBytesM = 0;
|
||||||
usedSpace = 0;
|
usedSpaceM = 0;
|
||||||
return info;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvBufferStatistics::AddBufferStatistic(long Bytes, long Used)
|
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
|
||||||
{
|
{
|
||||||
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
|
//debug("cIptvBufferStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, usedP);
|
||||||
cMutexLock MutexLock(&mutex);
|
cMutexLock MutexLock(&mutexM);
|
||||||
dataBytes += Bytes;
|
dataBytesM += bytesP;
|
||||||
if (Used > usedSpace)
|
if (usedP > usedSpaceM)
|
||||||
usedSpace = Used;
|
usedSpaceM = usedP;
|
||||||
}
|
}
|
||||||
|
|||||||
40
statistics.h
40
statistics.h
@@ -18,13 +18,13 @@ public:
|
|||||||
cString GetSectionStatistic();
|
cString GetSectionStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddSectionStatistic(long Bytes, long Calls);
|
void AddSectionStatistic(long bytesP, long callsP);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long filteredData;
|
long filteredDataM;
|
||||||
long numberOfCalls;
|
long numberOfCallsM;
|
||||||
cTimeMs timer;
|
cTimeMs timerM;
|
||||||
cMutex mutex;
|
cMutex mutexM;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pid statistics
|
// Pid statistics
|
||||||
@@ -35,19 +35,19 @@ public:
|
|||||||
cString GetPidStatistic();
|
cString GetPidStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddPidStatistic(u_short Pid, long Payload);
|
void AddPidStatistic(u_short pidP, long payloadP);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct pidStruct {
|
struct pidStruct {
|
||||||
u_short pid;
|
u_short pid;
|
||||||
long DataAmount;
|
long DataAmount;
|
||||||
};
|
};
|
||||||
pidStruct mostActivePids[IPTV_STATS_ACTIVE_PIDS_COUNT];
|
pidStruct mostActivePidsM[IPTV_STATS_ACTIVE_PIDS_COUNT];
|
||||||
cTimeMs timer;
|
cTimeMs timerM;
|
||||||
cMutex mutex;
|
cMutex mutexM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int SortPids(const void* data1, const void* data2);
|
static int SortPids(const void* data1P, const void* data2P);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Streamer statistics
|
// Streamer statistics
|
||||||
@@ -58,12 +58,12 @@ public:
|
|||||||
cString GetStreamerStatistic();
|
cString GetStreamerStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddStreamerStatistic(long Bytes);
|
void AddStreamerStatistic(long bytesP);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long dataBytes;
|
long dataBytesM;
|
||||||
cTimeMs timer;
|
cTimeMs timerM;
|
||||||
cMutex mutex;
|
cMutex mutexM;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Buffer statistics
|
// Buffer statistics
|
||||||
@@ -74,14 +74,14 @@ public:
|
|||||||
cString GetBufferStatistic();
|
cString GetBufferStatistic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddBufferStatistic(long Bytes, long Used);
|
void AddBufferStatistic(long bytesP, long usedP);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long dataBytes;
|
long dataBytesM;
|
||||||
long freeSpace;
|
long freeSpaceM;
|
||||||
long usedSpace;
|
long usedSpaceM;
|
||||||
cTimeMs timer;
|
cTimeMs timerM;
|
||||||
cMutex mutex;
|
cMutex mutexM;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __IPTV_STATISTICS_H
|
#endif // __IPTV_STATISTICS_H
|
||||||
|
|||||||
90
streamer.c
90
streamer.c
@@ -11,61 +11,63 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "streamer.h"
|
#include "streamer.h"
|
||||||
|
|
||||||
cIptvStreamer::cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen)
|
cIptvStreamer::cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packetLenP)
|
||||||
: cThread("IPTV streamer"),
|
: cThread("IPTV streamer"),
|
||||||
ringBuffer(RingBuffer),
|
ringBufferM(ringBufferP),
|
||||||
packetBufferLen(PacketLen),
|
sleepM(),
|
||||||
protocol(NULL)
|
packetBufferLenM(packetLenP),
|
||||||
|
protocolM(NULL)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::cIptvStreamer(%d)\n", packetBufferLen);
|
debug("cIptvStreamer::%s(%d)", __FUNCTION__, packetBufferLenM);
|
||||||
// Allocate packet buffer
|
// Allocate packet buffer
|
||||||
packetBuffer = MALLOC(unsigned char, packetBufferLen);
|
packetBufferM = MALLOC(unsigned char, packetBufferLenM);
|
||||||
if (packetBuffer)
|
if (packetBufferM)
|
||||||
memset(packetBuffer, 0, packetBufferLen);
|
memset(packetBufferM, 0, packetBufferLenM);
|
||||||
else
|
else
|
||||||
error("MALLOC() failed for packet buffer");
|
error("MALLOC() failed for packet buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvStreamer::~cIptvStreamer()
|
cIptvStreamer::~cIptvStreamer()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::~cIptvStreamer()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Close the protocol
|
// Close the protocol
|
||||||
Close();
|
Close();
|
||||||
protocol = NULL;
|
protocolM = NULL;
|
||||||
ringBuffer = NULL;
|
ringBufferM = NULL;
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
free(packetBuffer);
|
free(packetBufferM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvStreamer::Action(void)
|
void cIptvStreamer::Action(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Action(): Entering\n");
|
debug("cIptvStreamer::%s(): entering", __FUNCTION__);
|
||||||
// Increase priority
|
// Increase priority
|
||||||
//SetPriority(-1);
|
//SetPriority(-1);
|
||||||
// Do the thread loop
|
// Do the thread loop
|
||||||
while (packetBuffer && Running()) {
|
while (packetBufferM && Running()) {
|
||||||
int length = -1;
|
int length = -1;
|
||||||
if (protocol)
|
unsigned int size = min((unsigned int)ringBufferM->Free(), packetBufferLenM);
|
||||||
length = protocol->Read(packetBuffer, packetBufferLen);
|
if (protocolM && (size > 0))
|
||||||
|
length = protocolM->Read(packetBufferM, size);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
AddStreamerStatistic(length);
|
AddStreamerStatistic(length);
|
||||||
if (ringBuffer) {
|
if (ringBufferM) {
|
||||||
int p = ringBuffer->Put(packetBuffer, length);
|
int p = ringBufferM->Put(packetBufferM, length);
|
||||||
if (p != length)
|
if (p != length)
|
||||||
ringBuffer->ReportOverflow(length - p);
|
ringBufferM->ReportOverflow(length - p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sleep.Wait(10); // to avoid busy loop and reduce cpu load
|
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
|
||||||
}
|
}
|
||||||
debug("cIptvStreamer::Action(): Exiting\n");
|
debug("cIptvStreamer::%s(): exiting", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvStreamer::Open(void)
|
bool cIptvStreamer::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Open()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Open the protocol
|
// Open the protocol
|
||||||
if (protocol && !protocol->Open())
|
if (protocolM && !protocolM->Open())
|
||||||
return false;
|
return false;
|
||||||
// Start thread
|
// Start thread
|
||||||
Start();
|
Start();
|
||||||
@@ -74,42 +76,42 @@ bool cIptvStreamer::Open(void)
|
|||||||
|
|
||||||
bool cIptvStreamer::Close(void)
|
bool cIptvStreamer::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Close()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Stop thread
|
// Stop thread
|
||||||
sleep.Signal();
|
sleepM.Signal();
|
||||||
if (Running())
|
if (Running())
|
||||||
Cancel(3);
|
Cancel(3);
|
||||||
// Close the protocol
|
// Close the protocol
|
||||||
if (protocol)
|
if (protocolM)
|
||||||
protocol->Close();
|
protocolM->Close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol)
|
bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter);
|
debug("cIptvStreamer::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(Location)) {
|
if (!isempty(locationP)) {
|
||||||
// Update protocol and set location and parameter; Close the existing one if changed
|
// Update protocol and set location and parameter; Close the existing one if changed
|
||||||
if (protocol != Protocol) {
|
if (protocolM != protocolP) {
|
||||||
if (protocol)
|
if (protocolM)
|
||||||
protocol->Close();
|
protocolM->Close();
|
||||||
protocol = Protocol;
|
protocolM = protocolP;
|
||||||
if (protocol) {
|
if (protocolM) {
|
||||||
protocol->Set(Location, Parameter, Index);
|
protocolM->Set(locationP, parameterP, indexP);
|
||||||
protocol->Open();
|
protocolM->Open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (protocol)
|
else if (protocolM)
|
||||||
protocol->Set(Location, Parameter, Index);
|
protocolM->Set(locationP, parameterP, indexP);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvStreamer::GetInformation(void)
|
cString cIptvStreamer::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamer::GetInformation()");
|
//debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
cString info("Stream:");
|
cString s;
|
||||||
if (protocol)
|
if (protocolM)
|
||||||
info = cString::sprintf("%s %s", *info, *protocol->GetInformation());
|
s = protocolM->GetInformation();
|
||||||
return cString::sprintf("%s\n", *info);
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
14
streamer.h
14
streamer.h
@@ -18,19 +18,19 @@
|
|||||||
|
|
||||||
class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
|
class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
|
||||||
private:
|
private:
|
||||||
cRingBufferLinear* ringBuffer;
|
cRingBufferLinear* ringBufferM;
|
||||||
cCondWait sleep;
|
cCondWait sleepM;
|
||||||
unsigned char* packetBuffer;
|
unsigned char* packetBufferM;
|
||||||
unsigned int packetBufferLen;
|
unsigned int packetBufferLenM;
|
||||||
cIptvProtocolIf* protocol;
|
cIptvProtocolIf* protocolM;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Action(void);
|
virtual void Action(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen);
|
cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packetLenP);
|
||||||
virtual ~cIptvStreamer();
|
virtual ~cIptvStreamer();
|
||||||
bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol);
|
bool Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP);
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool Close(void);
|
bool Close(void);
|
||||||
cString GetInformation(void);
|
cString GetInformation(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user