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

Compare commits

...

131 Commits

Author SHA1 Message Date
Rolf Ahrenberg
00cf880a5d Updated HISTORY. 2008-12-16 17:14:45 +02:00
Rolf Ahrenberg
71472a1033 Updated for vdr-1.7.2. 2008-12-14 20:27:45 +02:00
Rolf Ahrenberg
0eff9de2ee Silenced a warning about ignoring a return value of write(). 2008-11-10 12:32:34 +02:00
Rolf Ahrenberg
9a19009451 Cleaned up Makefile header. 2008-11-04 23:29:20 +02:00
Rolf Ahrenberg
04c194ffc7 Incremented the version number. 2008-10-12 23:08:41 +03:00
Rolf Ahrenberg
40125dd9bb Updated HISTORY for the release. 2008-10-12 22:44:17 +03:00
Rolf Ahrenberg
c5a7598544 Optimized streamer thread termination. 2008-09-10 17:22:36 +03:00
Rolf Ahrenberg
4e8e26a4b3 Updated iptvstream.sh script to support optional video resolution settings. 2008-09-01 14:28:05 +03:00
Rolf Ahrenberg
9ec10262d4 Fifo shouldn't be opened as write-only, if there're no readers. 2008-08-31 12:56:22 +03:00
Rolf Ahrenberg
501701e3d3 Added .gitignore. 2008-08-29 17:38:46 +03:00
Rolf Ahrenberg
53b5644973 Migration changes for git and UTF-8.
Updated contact information.
2008-08-23 08:15:30 +03:00
Rolf Ahrenberg
17b4709c30 Tweaked pid scanner parameters for HD broadcasts. 2008-08-06 08:05:52 +00:00
Rolf Ahrenberg
2bff3d0f8f Updated Italian translation. 2008-07-14 10:13:48 +00:00
Rolf Ahrenberg
6324eaf128 Updated HISTORY. 2008-06-20 19:34:50 +00:00
Rolf Ahrenberg
b31de2ec23 Rephrased. 2008-06-20 19:34:18 +00:00
Rolf Ahrenberg
b3b28a5faa Initial import. 2008-06-20 19:33:43 +00:00
Rolf Ahrenberg
037adaac86 Added pluginparam patch for vdr-1.7.0. 2008-04-13 16:04:03 +00:00
Rolf Ahrenberg
6fa46ca9e3 Revert non-working retuning optimization. 2008-04-04 20:55:44 +00:00
Rolf Ahrenberg
c507f373ff Fixed channels.conf format used in vlc2iptv. Disabled retuning feature and added some minor corrections. 2008-04-02 22:55:04 +00:00
Rolf Ahrenberg
e798ff1424 Removed old channels.conf format support and disabled re-tuning of EXT protocol. 2008-04-02 20:22:48 +00:00
Rolf Ahrenberg
613152c6db Updated Italian translations and incremented version number. 2008-03-30 20:25:12 +00:00
Rolf Ahrenberg
740d93aa2c Updated russian translation and API dependency. 2008-03-27 20:27:26 +00:00
Rolf Ahrenberg
94e70db977 Updated for vdr-1.6.0. 2008-03-27 20:14:18 +00:00
Rolf Ahrenberg
698ebb3a3c Updated pluginparam patches. 2008-03-13 23:32:51 +00:00
Rolf Ahrenberg
aaf93246c1 Added Russian translation. 2008-03-13 23:26:04 +00:00
Rolf Ahrenberg
1d8044b4e4 Updated Italian translation. 2008-02-23 12:37:56 +00:00
Rolf Ahrenberg
573584022c Fixed installation instructions. 2008-02-19 22:32:24 +00:00
Rolf Ahrenberg
5420374543 Removed obsolete patches. 2008-02-19 22:30:43 +00:00
Rolf Ahrenberg
71952ae0dc Removed support for older vdr versions. 2008-02-19 22:29:02 +00:00
Rolf Ahrenberg
c8fe6b1389 Fixed SetText copy mode. 2008-02-18 16:50:07 +00:00
Rolf Ahrenberg
dd540f8eef Preparing for 0.0.7 release. 2008-02-18 14:18:11 +00:00
Rolf Ahrenberg
3de5d6c467 Added a note about asprintf to cString modification. 2008-02-18 12:19:46 +00:00
Rolf Ahrenberg
c525b553e4 Updated for vdr-1.5.15. 2008-02-18 11:54:01 +00:00
Rolf Ahrenberg
71b0e52712 Added support for fifo dvr and modificationsfor vdr-1.5.15. 2008-02-17 19:18:47 +00:00
Rolf Ahrenberg
398a8d75b9 Initial import. 2008-02-17 17:16:04 +00:00
Rolf Ahrenberg
554bc5cb41 Modified pid scanner timeout to 15s. 2008-02-02 21:06:14 +00:00
Rolf Ahrenberg
4188a5d4e2 Added check for already known audio pid. 2008-02-02 20:51:47 +00:00
Antti Seppälä
55440bf047 Implement detection of audio or video-only channel pids. 2008-02-02 20:23:44 +00:00
Rolf Ahrenberg
3fe71ae011 Added explanations for scan sid/pids menu entries. 2008-02-02 17:19:12 +00:00
Rolf Ahrenberg
16b40c6774 Reset timeout if channel locking fails. 2008-02-01 21:58:22 +00:00
Rolf Ahrenberg
a03bd6309c Removed [PS]idScanner setup options and added a timeout mechanism for pid scanner. 2008-02-01 21:54:24 +00:00
Rolf Ahrenberg
89e3aba59e Added channel specific sid and pid scanning options. 2008-01-31 22:28:53 +00:00
Rolf Ahrenberg
68459e6553 Added preliminary automatic Pid scanning functionality. 2008-01-30 22:41:58 +00:00
Rolf Ahrenberg
29cb25485f Added some funky moves. 2008-01-30 21:57:33 +00:00
Rolf Ahrenberg
c176429338 Fixed indentation. 2008-01-29 20:50:05 +00:00
Rolf Ahrenberg
05d70f67b1 Modified VDR locale detection. 2008-01-28 22:37:26 +00:00
Rolf Ahrenberg
537c16a43b Added support for vdr-1.5.14. 2008-01-28 21:36:32 +00:00
Rolf Ahrenberg
b88b14912c Updated French translation. 2008-01-26 20:45:25 +00:00
Rolf Ahrenberg
c1544453b6 Fixed compilation under vdr-1.4.7. 2008-01-20 16:15:14 +00:00
Rolf Ahrenberg
5c14668598 Updated finnish translations for help. 2008-01-20 14:13:28 +00:00
Rolf Ahrenberg
d4a255a773 Removed. 2008-01-20 14:11:14 +00:00
Antti Seppälä
24bcf25571 Provide some more information in infokey help. 2008-01-20 13:17:36 +00:00
Rolf Ahrenberg
78f4a2a0fc Initial import. 2008-01-20 00:02:45 +00:00
Rolf Ahrenberg
65d79abbf4 Updated finnish translation. 2008-01-19 23:54:49 +00:00
Rolf Ahrenberg
caf326bb4d Added help texts. 2008-01-19 23:17:20 +00:00
Antti Seppälä
18c2962cd9 Get rid of bad interface design in statistic collectors. 2008-01-19 21:08:02 +00:00
Rolf Ahrenberg
1e2d0955de Updated version number to 0.0.6. 2008-01-19 20:24:10 +00:00
Antti Seppälä
27437381d0 Fix compiler warning. 2008-01-19 16:51:59 +00:00
Rolf Ahrenberg
7ce44c9175 Added preliminary help support for setup. 2008-01-19 16:24:40 +00:00
Rolf Ahrenberg
7206a8d189 Translation update. 2008-01-17 18:19:02 +00:00
Rolf Ahrenberg
dce9d3361f Modified .po headers 2008-01-13 17:10:22 +00:00
Rolf Ahrenberg
d71f79bdd8 Added '-Wno-parentheses' to the compiler options. 2008-01-13 16:45:02 +00:00
Rolf Ahrenberg
dcf7ce5447 Updated translation file headers. 2008-01-11 23:07:29 +00:00
Rolf Ahrenberg
3ae015cf51 Fixed a typo and some reformatting. 2008-01-06 20:19:02 +00:00
Antti Seppälä
4915630cfc Bug and style fixes. 2008-01-04 23:36:37 +00:00
Rolf Ahrenberg
28d1869a28 Minor corrections. 2007-11-27 19:44:02 +00:00
Rolf Ahrenberg
c8c9dccf2b Added a release date. 2007-11-27 19:31:46 +00:00
Antti Seppälä
adcde3954c Switch away from utf-8 2007-11-24 16:44:20 +00:00
Antti Seppälä
c3d38f2345 Add vlc2iptv example script from Tobias Grimm. 2007-11-24 16:34:20 +00:00
Antti Seppälä
8f552bd19f Add GPL boilerplate 2007-11-24 15:14:52 +00:00
Antti Seppälä
3b5b7eac24 One more consistency change. 2007-11-22 17:36:37 +00:00
Antti Seppälä
3daea8b1ba Use consistent variable names. 2007-11-22 17:36:00 +00:00
Antti Seppälä
b5744903cd Add an entry about iptvstream.sh modifications. 2007-11-22 17:33:51 +00:00
Antti Seppälä
61a588ed22 An attempt at more posix compliance in iptvstream.sh. 2007-11-22 17:25:20 +00:00
Rolf Ahrenberg
9e630760f6 Added French translation. 2007-11-08 18:49:40 +00:00
Rolf Ahrenberg
b3b0ae3567 Incremented version number. 2007-11-04 17:07:25 +00:00
Rolf Ahrenberg
4b8b396f6b Fixed a typo. 2007-11-04 15:31:05 +00:00
Rolf Ahrenberg
19b49e00e5 Modified cMenuEditStrItem for vdr-1.5.11. 2007-11-04 15:23:16 +00:00
Rolf Ahrenberg
bde204f3b3 Updated Makefile 'i18n' targets. 2007-11-04 14:13:11 +00:00
Rolf Ahrenberg
60ed46f42f Added patch for vdr-1.5.11. 2007-11-04 13:00:23 +00:00
Rolf Ahrenberg
c6671b20db Incremented version number. 2007-10-29 21:21:39 +00:00
Antti Seppälä
edb54e537d History file entry about German translation 2007-10-29 21:07:54 +00:00
Antti Seppälä
9750b0f565 Added German translations from Tobias Grimm. 2007-10-29 21:03:24 +00:00
Rolf Ahrenberg
470197eb77 Fixed VERSION code. 2007-10-28 16:26:28 +00:00
Rolf Ahrenberg
ea18decf44 Added localization support for non-gettext VDRs. 2007-10-28 16:22:44 +00:00
Rolf Ahrenberg
7bda3e47ce Added note about localization. 2007-10-28 00:01:29 +00:00
Rolf Ahrenberg
e016a97841 Updated installation instructions. 2007-10-27 12:55:04 +00:00
Rolf Ahrenberg
e842c4f181 Removed Spids from menu if vdr is old enough. 2007-10-27 12:07:40 +00:00
Rolf Ahrenberg
fe02d29eef Simplified GetTSPacket(). 2007-10-26 23:48:30 +00:00
Rolf Ahrenberg
fab6904a57 Reorganized header files. 2007-10-26 23:18:49 +00:00
Rolf Ahrenberg
2bd95ab23e Added preliminary support for vdr-1.4.7. 2007-10-26 23:13:24 +00:00
Rolf Ahrenberg
f07e3bf485 Prevent busylooping in GetTSPacket() and modified RTP to accect any TS stream. 2007-10-26 22:07:10 +00:00
Antti Seppälä
13fa932a5a Remove unnecessary type parameter from DELETE macro. 2007-10-22 19:32:19 +00:00
Rolf Ahrenberg
eb1cd9b01a Fixed shutdown crash. 2007-10-22 16:22:11 +00:00
Rolf Ahrenberg
8e979d2940 Some comment additions. 2007-10-21 19:46:03 +00:00
Antti Seppälä
e1c4d22fda Refactor out an unnecessary socket parameter. 2007-10-21 19:32:14 +00:00
Antti Seppälä
eebd990991 Improve object constructs of protocols. Create Separate ProtocolUdp and
ProtocolTcp -classes.
2007-10-21 17:32:43 +00:00
Rolf Ahrenberg
ced3540d3b Changed initialization of socket port number. 2007-10-21 15:49:54 +00:00
Antti Seppälä
4bc08e8cc0 Refactor socket code to a separate common class. 2007-10-21 13:31:21 +00:00
Rolf Ahrenberg
7330887512 Renamed 'Command' to 'Script'. 2007-10-21 09:24:24 +00:00
Antti Seppälä
63ad1a66d7 Re-name error macros and eliminate need for specifying empty parameters. 2007-10-20 23:25:14 +00:00
Antti Seppälä
64dd6a5f3f Reduce duplicated code by using an error -macro. 2007-10-20 23:16:28 +00:00
Antti Seppälä
30409fac2c Use c-style function naming for functions outside of classes. 2007-10-20 20:43:22 +00:00
Rolf Ahrenberg
3c30852c81 Modified channels.conf parameters to be caseinsensitive. 2007-10-20 20:35:06 +00:00
Antti Seppälä
cf6195bb8a Refactor usages of select() to common code. 2007-10-20 20:27:58 +00:00
Rolf Ahrenberg
742e059dd3 Added Spids to channel editor. 2007-10-20 18:28:51 +00:00
Antti Seppälä
5e7118d3ca Moved text around. 2007-10-20 18:26:38 +00:00
Antti Seppälä
3caa49b468 Update as for upcoming release. 2007-10-20 18:01:01 +00:00
Antti Seppälä
f6653370be Typo fix. 2007-10-20 17:48:49 +00:00
Rolf Ahrenberg
0670667e9b Moved EXT protocol base port setting from the command line switch to the setup menu entry. 2007-10-20 17:26:46 +00:00
Antti Seppälä
987696a35b Add documentation about external streaming. 2007-10-20 16:57:35 +00:00
Rolf Ahrenberg
8be05ea419 Updated installation instructions. 2007-10-20 16:02:11 +00:00
Antti Seppälä
2758993bb2 Robustify network protocols with more error checking. 2007-10-20 11:36:21 +00:00
Antti Seppälä
0a516fd934 Added a clarifying comment. 2007-10-20 08:58:15 +00:00
Antti Seppälä
7511373d74 Attempt to fix segmentation fault at close; widen the effective critical
section area and prohibit Close() from accessing it at the same time
with Action()
2007-10-20 08:32:00 +00:00
Antti Seppälä
3e989d7050 Parametrize the bitrates for easier editing and management. 2007-10-19 23:08:24 +00:00
Rolf Ahrenberg
2b574bafa2 Modified error message. 2007-10-19 22:56:25 +00:00
Rolf Ahrenberg
1aeccbe51d Forced EXT script location only to plugin's config directory. 2007-10-19 22:54:03 +00:00
Antti Seppälä
78b1c491f0 Added a sample switch-case construct. Increased the transcoding
bitrates. Set an unique pid based on the parameter received via script
call.
2007-10-19 22:44:42 +00:00
Rolf Ahrenberg
4dd9e42a71 Added configurable UDP listen port for EXT protocol. 2007-10-19 22:18:55 +00:00
Rolf Ahrenberg
8e3956cbeb Channel parameter refactoring. 2007-10-19 21:36:27 +00:00
Antti Seppälä
5ed04a6e72 Refactored and added more error checking. 2007-10-19 18:26:27 +00:00
Antti Seppälä
5dc7117720 Improved child exit waiting functionality. Also send a bit milder signal
to child at close.
2007-10-19 18:03:19 +00:00
Rolf Ahrenberg
50bed6a8c6 Changed the default file location for EXT protocol in channel editor. 2007-10-19 17:49:35 +00:00
Antti Seppälä
9cd2d1f024 Fix channel editor EXT entry. 2007-10-19 17:07:13 +00:00
Antti Seppälä
5b91ea05eb Exec doesn't need that much escaping. The url should be however wrapped
in quotation marks because it may contain spaces.
2007-10-18 20:18:33 +00:00
Rolf Ahrenberg
90abed4598 Removed SystemExec() from EXT protocol. 2007-10-18 19:33:15 +00:00
Rolf Ahrenberg
f9252cc925 Added EXT protocol listen port to channels.conf. 2007-10-16 22:13:44 +00:00
Antti Seppälä
d69901ffb6 More work on external protocol, this one can already launch external
scripts. "Channel" switching does not work at all.
2007-10-16 20:03:59 +00:00
Rolf Ahrenberg
31b6264a54 Added some missing EXT protocol code. 2007-10-15 21:03:45 +00:00
Antti Seppälä
f1319fb34f Add EXT -protocol framework. Does not do anything yet. 2007-10-15 20:06:38 +00:00
47 changed files with 2911 additions and 804 deletions

6
.gitignore vendored Normal file
View File

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

73
HISTORY
View File

@@ -4,3 +4,76 @@ VDR Plugin 'iptv' Revision History
2007-10-14: Version 0.0.1
- Initial revision.
2007-10-21: Version 0.0.2
- Added EXT protocol.
- Added Spids to channel editor.
- Fixed shutdown logic.
- Improved error checking in protocols.
2007-10-28: Version 0.0.3
- Fixed shutdown crash.
- Added some minor tweaks.
- RTP payload now restricted to TS only.
- Added preliminary support for vdr-1.4.7.
2007-11-04: Version 0.0.4
- Added German translation (Thanks to Tobias Grimm).
- Added pluginparam patch for vdr-1.5.11.
- Updated Makefile 'i18n' targets.
2007-11-27: Version 0.0.5
- Added French translation (Thanks to Bruno Roussel).
- Added a more sophisticated example script (Thanks to Tobias Grimm).
- Improved iptvstream.sh compatibility under non-bash shells.
2008-01-20: Version 0.0.6
- Fixed some lint warnings.
- Added Italian translation (Thanks to Diego Pierotto).
- Added '-Wno-parentheses' to the compiler options.
- Mapped 'kInfo' as help key in setup menu.
- Refactored statistic collecting code.
2008-02-18: Version 0.0.7
- Updated for vdr-1.5.15.
- Replaced asprintf with cString.
- Updated French translation (Thanks to Michaël Nival).
- Modified VDR locale support detection.
- Added preliminary automatic Pid scanning functionality.
- Modified channels.conf format to enable/disable channel
specific pid and sid scanning functionality.
- Removed the general sid scanning setup option.
2008-03-27: Version 0.2.0
- Updated for vdr-1.6.0.
- Updated Italian translation (Thanks to Diego Pierotto).
- Added Russian translation (Thanks to Alexander Gross).
2008-06-20: Version 0.2.1
- Updated Italian translation (Thanks to Diego Pierotto).
- Removed compatibility mode for old channels.conf format.
- Updated vlc2iptv script for new channels.conf format.
- Added pluginparam patch for vdr-1.7.0.
- Added new example scripts from VDR-WIKI.
2008-10-12: Version 0.2.2
- Converted HISTORY and fi_FI.po to UTF-8.
- Updated Italian translation (Thanks to Diego Pierotto).
- Tweaked pid scanner parameters for HD broadcasts.
- Fixed opening of fifo tap.
- Updated iptvstream.sh script to support optional video resolution settings.
- Optimized streamer thread termination.
2008-12-16: Version 0.2.3
- Updated for vdr-1.7.2.
- Silenced a compilation warning.

View File

@@ -1,7 +1,6 @@
#
# Makefile for a Video Disk Recorder plugin
# Makefile for IPTV plugin
#
# $Id: Makefile,v 1.18 2007/10/14 18:45:34 rahrenbe Exp $
# Debugging on/off
#IPTV_DEBUG = 1
@@ -19,12 +18,12 @@ PLUGIN = iptv
### 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 'static const char VERSION\[\] *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
### The directory environment:
@@ -55,11 +54,14 @@ ifdef IPTV_DEBUG
DEFINES += -DDEBUG
endif
.PHONY: all all-redirect
all-redirect: all
### The object files (add further files here):
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o \
protocolhttp.o protocolfile.o sectionfilter.o sidscanner.o \
statistics.o common.o
protocolhttp.o protocolfile.o protocolext.o sectionfilter.o \
sidscanner.o pidscanner.o statistics.o common.o socket.o
### The main target:
@@ -84,25 +86,25 @@ $(DEPFILE): Makefile
PODIR = po
LOCALEDIR = $(VDRDIR)/locale
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
I18Ndirs = $(notdir $(foreach file, $(I18Npo), $(basename $(file))))
I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po
msgfmt -c -o $@ $<
$(I18Npot): $(wildcard *.c)
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $(wildcard *.c)
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $^
$(I18Npo): $(I18Npot)
%.po: $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q $@ $<
@touch $@
i18n: $(I18Npot) $(I18Nmo)
@mkdir -p $(LOCALEDIR)
for i in $(I18Ndirs); do\
mkdir -p $(LOCALEDIR)/$$i/LC_MESSAGES;\
cp $(PODIR)/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/vdr-$(PLUGIN).mo;\
done
$(I18Nmsgs): $(LOCALEDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
@mkdir -p $(dir $@)
cp $< $@
.PHONY: i18n
i18n: $(I18Nmsgs) $(I18Npot)
### Targets:
@@ -117,7 +119,7 @@ dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@tar czf $(PACKAGE).tgz -C $(TMPDIR) --exclude CVS $(ARCHIVE)
@tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(PACKAGE).tgz

90
README
View File

@@ -3,8 +3,8 @@ This is an IPTV plugin for the Video Disk Recorder (VDR).
Written by: Rolf Ahrenberg
< R o l f . A h r e n b e r g @ s c i . f i >
Antti Sepp<EFBFBD>l<EFBFBD>
<a j h s e p p a @ n i k s u l a . h u t . f i >
Antti Seppälä
< a . s e p p a l a @ g m a i l . c o m >
Project's homepage: http://www.saunalahti.fi/~rahrenbe/vdr/iptv/
@@ -17,8 +17,7 @@ See the file COPYING for more information.
Requirements:
An IPTV patched VDR-1.5.10 (or later) setup and DVB compatible MPEG1/2
network video streams.
An IPTV patched VDR setup and DVB compatible MPEG1/2 network video streams.
Description:
@@ -28,11 +27,16 @@ live viewing, recording, etc. The plugin also features full section
filtering capabilities which allow for example EIT information to be
extracted from the incoming stream.
Currently the IPTV plugin supports both multicast UDP/RTP and unicast
HTTP MPEG1/2 transport streams. Also a file input method is supported,
but a file delay must be selected individually to prevent VDR's transfer
buffer over/underflow. Therefore the file input should be considered
as a testing feature only.
Currently the IPTV plugin has direct support for both multicast UDP/RTP
and unicast HTTP MPEG1/2 transport streams. Also a file input method is
supported, but a file delay must be selected individually to prevent
VDR's transfer buffer over/underflow. Therefore the file input should be
considered as a testing feature only.
IPTV plugin also features a support for external streaming applications.
With proper helper applications and configuration IPTV plugin is able to
display not only MPEG1/2 transport streams but also other formats like
MP3 radio streams, mms video streams and so on.
Installation:
@@ -42,6 +46,7 @@ ln -s iptv-X.Y.Z iptv
cd /put/your/path/here/VDR
patch -p1 < PLUGINS/src/iptv/patches/vdr-X.Y.Z-pluginparam.patch
cp sources.conf /path/to/vdrconf/
cp -R PLUGINS/src/iptv/iptv /path/to/vdrconf/plugins/
make
make plugins
./vdr -P iptv
@@ -54,14 +59,14 @@ Setup menu:
- TS buffer prefill ratio [%] = 0 Defines prefill ratio for transport
stream ringbuffer before data is
transferred to VDR.
The valid range: 0...40
Valid range: 0...40
- EXT protocol base port = 4321 Defines base port used in EXT protocol.
The port range is defined by the number
of IPTV devices (max. 8).
Valid range: 0...65527
- Use section filtering = 1 Defines whether section filtering shall
be used.
Valid range: 0...1
- Scan Sid automatically = 1 Defines whether service id shall be
scanned automatically. Requires section
filtering.
Valid range: 0...1
- Disable filters = 0 Certain section filters might cause some
unwanted behaviour to VDR such as time
being falsely synchronized etc. This
@@ -84,6 +89,17 @@ Channel editor menu:
pressing the Red button. The channel editor is functionally similar to
VDR's built-in channel editor.
- Scan Sid: [yes|no] Defines whether service id shall be
scanned automatically. Service id is
used in channel identification and
EPG information is set according to it.
This option requires section filtering.
- Scan pids: [yes|no] Defines whether video and audio pids
shall be scanned automatically. This
option is useful with streams missing
correct PAT/PMT information.
Information menu:
- [Red:General] Opens the general information page.
@@ -95,14 +111,16 @@ Configuration:
- channels.conf
TV3;IPTV:3:IPTV|FILE|/media/video.ts|5:P:0:514:670:2321:0:3:0:0:0
TV2;IPTV:2:IPTV|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0
TV1;IPTV:1:IPTV|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^
| | | | | Source type ("P")
| | | | IP Port Number or File delay (ms)
| | | IP Address or File Location
| | Protocol ("UDP", "HTTP", "FILE")
TV4;IPTV:4:IPTV|S1P0|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0
TV3;IPTV:3:IPTV|S0P1|FILE|/video/stream.ts|5:P:0:514:670:2321:0:3:0:0:0
TV2;IPTV:2:IPTV|S0P1|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0
TV1;IPTV:1:IPTV|S1P0|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^ ^
| | | | | | Source type ("P")
| | | | | IP Port Number, File delay (ms), Script parameter
| | | | IP Address, File location, Script location
| | | Protocol ("UDP", "HTTP", "FILE", "EXT")
| | Parameters ("S" Sid scan, "P" Pid scan, "0" disable, "1" enable)
| Plugin ID ("IPTV")
Unique enumeration
@@ -114,6 +132,28 @@ Configuration:
# IGMP required by multicasts
iptables -A INPUT -i eth0 -p igmp -d 224.0.0.0/4 -j ACCEPT
External streaming:
- To watch an externally received channel add an EXT entry to channels.conf
and specify a script name and parameter. The specified script is executed
from plugin configuration directory when VDR tunes to the channel. The
specified script parameter is passed to the script and it can be used to
select for example between different URLs.
- When an EXT channel is opened the IPTV plugin opens an UDP listening port
on the localhost. The external script is responsible for supplying IPTV
plugin with MPEG2 TS data in UDP/RTP format to the listening port. The
data will be processed in VDR like a normal DVB broadcast. The listening
base port can be specified in the plugin configuration menu.
- Each IPTV device has different listen port. The port number is specified
as a base port number plus IPTV device index minus one. Maximum of 8 IPTV
devices can be used simultaneously.
- IPTV plugin includes an example script which uses VLC media player for
receiving streams, transcoding and handing the result to IPTV plugin. The
plugin was tested with VLC version 0.8.6c.
Notes:
- Working EIT requires correct Nid/Tid/Sid values as the NIT filter cannot
@@ -123,6 +163,12 @@ Notes:
- The following section filters are recommended to be disabled:
"NIT (0x40)", "SDT (0x42)", "TDT (0x70)"
- The IPTV devices look for a "/tmp/vdr-iptv<devicenumber>.dvr" fifo at
startup. If the fifo is found and succesfully opened, the device writes
the current data stream into it. This can be used for debugging purposes.
Acknowledgements:
- The IPTV section filtering code is derived from Linux kernel.
- The pid scanning code is derived from Udo Richter's streamplayer plugin.

View File

@@ -3,10 +3,8 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: common.c,v 1.3 2007/10/10 19:41:10 rahrenbe Exp $
*/
#include <vdr/i18n.h>
#include <vdr/tools.h>
#include "common.h"
@@ -24,7 +22,7 @@ uint8_t payload(const uint8_t *tsp)
if (tsp[4] > 183) // corrupted data?
return 0;
else
return 184 - 1 - tsp[4];
return (184 - 1) - tsp[4];
}
return 184;
@@ -39,6 +37,26 @@ const char *id_pid(const u_short Pid)
return "---";
}
int select_single_desc(int descriptor, const int usecs, const bool selectWrite)
{
// Wait for data
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = usecs;
// Use select
fd_set fds;
FD_ZERO(&fds);
FD_SET(descriptor, &fds);
int retval = 0;
if (selectWrite)
retval = select(descriptor + 1, NULL, &fds, NULL, &tv);
else
retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
// Check if error
ERROR_IF_RET(retval < 0, "select()", return retval);
return retval;
}
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
{
/* description tag pid tid mask */

View File

@@ -3,13 +3,14 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: common.h,v 1.9 2007/10/10 19:41:10 rahrenbe Exp $
*/
#ifndef __IPTV_COMMON_H
#define __IPTV_COMMON_H
#include <vdr/tools.h>
#include <vdr/config.h>
#include <vdr/i18n.h>
#ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x);
@@ -19,6 +20,17 @@
#define error(x...) esyslog("IPTV: " x);
#endif
#ifndef trNOOP
#define trNOOP(s) (s)
#endif
#ifndef trVDR
#define trVDR(s) tr(s)
#endif
#define IPTV_FILTER_FILENAME "/tmp/vdr-iptv%d.filter%d"
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
#define IPTV_DEVICE_INFO_ALL 0
#define IPTV_DEVICE_INFO_GENERAL 1
#define IPTV_DEVICE_INFO_PIDS 2
@@ -29,9 +41,36 @@
#define SECTION_FILTER_TABLE_SIZE 7
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \
if (exp) { \
char tmp[64]; \
error("ERROR: "errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
func; \
ret; \
} \
} while (0)
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );
#define DELETE_POINTER(ptr) \
do { \
if (ptr) { \
typeof(*ptr) *tmp = ptr; \
ptr = NULL; \
delete(tmp); \
} \
} while (0)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
uint16_t ts_pid(const uint8_t *buf);
uint8_t payload(const uint8_t *tsp);
const char *id_pid(const u_short Pid);
int select_single_desc(int descriptor, const int usecs, const bool selectWrite);
struct section_filter_table_type {
const char *description;

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: config.c,v 1.15 2007/10/08 23:51:58 rahrenbe Exp $
*/
#include "config.h"
@@ -14,29 +13,36 @@ cIptvConfig::cIptvConfig(void)
: readBufferTsCount(48),
tsBufferSize(2),
tsBufferPrefillRatio(0),
extProtocolBasePort(4321),
useBytes(1),
sectionFiltering(1),
sidScanning(1)
sectionFiltering(1)
{
for (unsigned int i = 0; i < sizeof(disabledFilters); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFilters) - 1; ++i)
disabledFilters[i] = -1;
memset(configDirectory, '\0', sizeof(configDirectory));
}
unsigned int cIptvConfig::GetDisabledFiltersCount(void)
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
{
unsigned int n = 0;
while ((disabledFilters[n] != -1) && (n < sizeof(disabledFilters)))
n++;
while ((disabledFilters[n] != -1) && (n < ARRAY_SIZE(disabledFilters) - 1))
n++;
return n;
}
int cIptvConfig::GetDisabledFilters(unsigned int Index)
int cIptvConfig::GetDisabledFilters(unsigned int Index) const
{
return (Index < sizeof(disabledFilters)) ? disabledFilters[Index] : -1;
return (Index < ARRAY_SIZE(disabledFilters)) ? disabledFilters[Index] : -1;
}
void cIptvConfig::SetDisabledFilters(unsigned int Index, int Number)
{
if (Index < sizeof(disabledFilters))
if (Index < ARRAY_SIZE(disabledFilters))
disabledFilters[Index] = Number;
}
void cIptvConfig::SetConfigDirectory(const char *directoryP)
{
debug("cIptvConfig::SetConfigDirectory(%s)", directoryP);
strn0cpy(configDirectory, directoryP, sizeof(configDirectory));
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: config.h,v 1.13 2007/10/08 23:51:58 rahrenbe Exp $
*/
#ifndef __IPTV_CONFIG_H
@@ -11,35 +10,37 @@
#include <vdr/menuitems.h>
#include "common.h"
#include "config.h"
class cIptvConfig
{
protected:
private:
unsigned int readBufferTsCount;
unsigned int tsBufferSize;
unsigned int tsBufferPrefillRatio;
unsigned int extProtocolBasePort;
unsigned int useBytes;
unsigned int sectionFiltering;
unsigned int sidScanning;
int disabledFilters[SECTION_FILTER_TABLE_SIZE];
char configDirectory[255];
public:
cIptvConfig();
unsigned int GetReadBufferTsCount(void) { return readBufferTsCount; }
unsigned int GetTsBufferSize(void) { return tsBufferSize; }
unsigned int GetTsBufferPrefillRatio(void) { return tsBufferPrefillRatio; }
unsigned int GetUseBytes(void) { return useBytes; }
unsigned int GetSectionFiltering(void) { return sectionFiltering; }
unsigned int GetSidScanning(void) { return sidScanning; }
unsigned int GetDisabledFiltersCount(void);
int GetDisabledFilters(unsigned int Index);
unsigned int GetReadBufferTsCount(void) const { return readBufferTsCount; }
unsigned int GetTsBufferSize(void) const { return tsBufferSize; }
unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatio; }
unsigned int GetExtProtocolBasePort(void) const { return extProtocolBasePort; }
unsigned int GetUseBytes(void) const { return useBytes; }
unsigned int GetSectionFiltering(void) const { return sectionFiltering; }
const char *GetConfigDirectory(void) const { return configDirectory; }
unsigned int GetDisabledFiltersCount(void) const;
int GetDisabledFilters(unsigned int Index) const;
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
void SetExtProtocolBasePort(unsigned int PortNumber) { extProtocolBasePort = PortNumber; }
void SetUseBytes(unsigned int On) { useBytes = On; }
void SetSectionFiltering(unsigned int On) { sectionFiltering = On; }
void SetSidScanning(unsigned int On) { sidScanning = On; }
void SetDisabledFilters(unsigned int Index, int Number);
void SetConfigDirectory(const char *directoryP);
};
extern cIptvConfig IptvConfig;

154
device.c
View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.68 2007/10/14 18:45:34 rahrenbe Exp $
*/
#include "config.h"
@@ -17,11 +16,15 @@ unsigned int cIptvDevice::deviceCount = 0;
cIptvDevice::cIptvDevice(unsigned int Index)
: deviceIndex(Index),
dvrFd(-1),
isPacketDelivered(false),
isOpenDvr(false),
sidScanEnabled(false),
pidScanEnabled(false),
mutex()
{
debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex);
//debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex);
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndex, CardIndex());
tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
false, "IPTV");
@@ -30,33 +33,54 @@ cIptvDevice::cIptvDevice(unsigned int Index)
pUdpProtocol = new cIptvProtocolUdp();
pHttpProtocol = new cIptvProtocolHttp();
pFileProtocol = new cIptvProtocolFile();
pExtProtocol = new cIptvProtocolExt();
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
pPidScanner = new cPidScanner;
// Initialize filter pointers
memset(&secfilters, '\0', sizeof(secfilters));
memset(secfilters, '\0', sizeof(secfilters));
// Start section handler for iptv device
StartSectionHandler();
// Sid scanner must be created after the section handler
pSidScanner = new cSidScanner;
if (pSidScanner)
AttachFilter(pSidScanner);
// Check if dvr fifo exists
struct stat sb;
cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndex);
stat(filename, &sb);
if (S_ISFIFO(sb.st_mode)) {
dvrFd = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFd >= 0)
dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndex, *filename);
}
}
cIptvDevice::~cIptvDevice()
{
debug("cIptvDevice::~cIptvDevice(%d)\n", deviceIndex);
DELETENULL(pIptvStreamer);
DELETENULL(pUdpProtocol);
DELETENULL(pHttpProtocol);
DELETENULL(pFileProtocol);
DELETENULL(tsBuffer);
// Stop section handler of iptv device
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);
DELETENULL(pSidScanner);
DELETE_POINTER(pSidScanner);
}
// Destroy all filters
for (int i = 0; i < eMaxSecFilterCount; ++i)
DeleteFilter(i);
// Close dvr fifo
if (dvrFd >= 0) {
int fd = dvrFd;
dvrFd = -1;
close(fd);
}
}
bool cIptvDevice::Initialize(unsigned int DeviceCount)
@@ -100,15 +124,15 @@ cString cIptvDevice::GetGeneralInformation(void)
return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s",
deviceIndex, CardIndex(),
pIptvStreamer ? *pIptvStreamer->GetInformation() : "",
pIptvStreamer ? *pIptvStreamer->GetStatistic() : "",
*cIptvBufferStatistics::GetStatistic(),
pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "",
*GetBufferStatistic(),
*Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
}
cString cIptvDevice::GetPidsInformation(void)
{
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndex);
return cIptvPidStatistics::GetStatistic();
return GetPidStatistic();
}
cString cIptvDevice::GetFiltersInformation(void)
@@ -120,7 +144,7 @@ cString cIptvDevice::GetFiltersInformation(void)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i]) {
info = cString::sprintf("%sFilter %d: %s Pid=0x%02X (%s)\n", *info, i,
*secfilters[i]->GetStatistic(), secfilters[i]->GetPid(),
*secfilters[i]->GetSectionStatistic(), secfilters[i]->GetPid(),
id_pid(secfilters[i]->GetPid()));
if (++count > IPTV_STATS_ACTIVE_FILTERS_COUNT)
break;
@@ -153,24 +177,53 @@ cString cIptvDevice::GetInformation(unsigned int Page)
return info;
}
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol)
cString cIptvDevice::GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol)
{
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
char *tag = NULL;
char *proto = NULL;
char *loc = NULL;
if (sscanf(Param, "IPTV|UDP|%a[^|]|%u", &loc, IpPort) == 2) {
cString addr(loc, true);
*Protocol = pUdpProtocol;
return addr;
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(Param, "IPTV|HTTP|%a[^|]|%u", &loc, IpPort) == 2) {
cString addr(loc, true);
*Protocol = pHttpProtocol;
return addr;
}
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, IpPort) == 2) {
cString addr(loc, true);
*Protocol = pFileProtocol;
return addr;
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;
}
@@ -178,7 +231,7 @@ cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvPro
bool cIptvDevice::ProvidesIptv(const char *Param) const
{
debug("cIptvDevice::ProvidesIptv(%d)\n", deviceIndex);
return (strncmp(Param, "IPTV", 4) == 0);
return (strncasecmp(Param, "IPTV", 4) == 0);
}
bool cIptvDevice::ProvidesSource(int Source) const
@@ -206,21 +259,31 @@ bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *N
return result;
}
int cIptvDevice::NumProvidedSystems(void) const
{
return 1;
}
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
int port;
cString addr;
int parameter, sidscan, pidscan;
cString location;
cIptvProtocolIf *protocol;
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
addr = GetChannelSettings(Channel->PluginParam(), &port, &protocol);
if (isempty(addr)) {
location = GetChannelSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol);
if (isempty(location)) {
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false;
}
pIptvStreamer->Set(addr, port, protocol);
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
pSidScanner->SetChannel(Channel);
sidScanEnabled = sidscan ? true : false;
pidScanEnabled = pidscan ? true : false;
if (pIptvStreamer->Set(location, parameter, deviceIndex, protocol)) {
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetChannel(Channel);
if (pidScanEnabled && pPidScanner)
pPidScanner->SetChannel(Channel);
}
return true;
}
@@ -299,7 +362,7 @@ bool cIptvDevice::OpenDvr(void)
mutex.Unlock();
ResetBuffering();
pIptvStreamer->Open();
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetStatus(true);
isOpenDvr = true;
return true;
@@ -308,9 +371,10 @@ bool cIptvDevice::OpenDvr(void)
void cIptvDevice::CloseDvr(void)
{
debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex);
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetStatus(false);
pIptvStreamer->Close();
if (pIptvStreamer)
pIptvStreamer->Close();
isOpenDvr = false;
}
@@ -348,7 +412,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
tsBuffer->Del(TS_SIZE);
isPacketDelivered = false;
// Update buffer statistics
cIptvBufferStatistics::AddStatistic(TS_SIZE, tsBuffer->Available());
AddBufferStatistic(TS_SIZE, tsBuffer->Available());
}
uchar *p = tsBuffer->Get(Count);
if (p && Count >= TS_SIZE) {
@@ -365,8 +429,14 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
}
isPacketDelivered = true;
Data = p;
// Update pid statistics
cIptvPidStatistics::AddStatistic(ts_pid(p), payload(p));
// Update pid statistics
AddPidStatistic(ts_pid(p), payload(p));
// Send data also to dvr fifo
if ((dvrFd >= 0) && (write(dvrFd, p, TS_SIZE) != TS_SIZE))
error("ERROR: write failed to FIFO\n");
// Analyze incomplete streams with built-in pid analyzer
if (pidScanEnabled && pPidScanner)
pPidScanner->Process(p);
// Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i])
@@ -375,6 +445,8 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
return true;
}
}
// Reduce cpu load by preventing busylooping
cCondWait::SleepMs(100);
Data = NULL;
return true;
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.h,v 1.32 2007/10/14 18:45:34 rahrenbe Exp $
*/
#ifndef __IPTV_DEVICE_H
@@ -14,8 +13,10 @@
#include "protocoludp.h"
#include "protocolhttp.h"
#include "protocolfile.h"
#include "protocolext.h"
#include "streamer.h"
#include "sectionfilter.h"
#include "pidscanner.h"
#include "sidscanner.h"
#include "statistics.h"
@@ -33,14 +34,19 @@ private:
eMaxSecFilterCount = 32
};
unsigned int deviceIndex;
int dvrFd;
bool isPacketDelivered;
bool isOpenDvr;
bool sidScanEnabled;
bool pidScanEnabled;
cRingBufferLinear *tsBuffer;
int tsBufferPrefill;
cIptvProtocolUdp *pUdpProtocol;
cIptvProtocolHttp *pHttpProtocol;
cIptvProtocolFile *pFileProtocol;
cIptvProtocolExt *pExtProtocol;
cIptvStreamer *pIptvStreamer;
cPidScanner *pPidScanner;
cSidScanner *pSidScanner;
cMutex mutex;
cIptvSectionFilter* secfilters[eMaxSecFilterCount];
@@ -51,15 +57,19 @@ public:
virtual ~cIptvDevice();
cString GetInformation(unsigned int Page = IPTV_DEVICE_INFO_ALL);
// for statistics and general information
// copy and assignment constructors
private:
cIptvDevice(const cIptvDevice&);
cIptvDevice& operator=(const cIptvDevice&);
// for statistics and general information
cString GetGeneralInformation(void);
cString GetPidsInformation(void);
cString GetFiltersInformation(void);
// for channel parsing & buffering
private:
cString GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol);
cString GetChannelSettings(const char *IptvParam, int *Parameter, int *SidScan, int *PidScan, cIptvProtocolIf* *Protocol);
bool ProvidesIptv(const char *Param) const;
void ResetBuffering(void);
bool IsBuffering(void);
@@ -71,6 +81,7 @@ public:
virtual bool ProvidesSource(int Source) const;
virtual bool ProvidesTransponder(const cChannel *Channel) const;
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
virtual int NumProvidedSystems(void) const;
protected:
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);

66
iptv.c
View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: iptv.c,v 1.20 2007/10/14 18:45:34 rahrenbe Exp $
*/
#include <getopt.h>
@@ -13,12 +12,16 @@
#include "setup.h"
#include "device.h"
#if defined(APIVERSNUM) && APIVERSNUM < 10510
#error "VDR-1.5.10 API version or greater is required!"
#ifndef PLUGINPARAMPATCHVERSNUM
#error "You must apply the pluginparam patch for VDR!"
#endif
static const char *VERSION = "0.0.1";
static const char *DESCRIPTION = trNOOP("Experience the IPTV");
#if defined(APIVERSNUM) && APIVERSNUM < 10600
#error "VDR-1.6.0 API version or greater is required!"
#endif
static const char VERSION[] = "0.2.3";
static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin {
private:
@@ -66,7 +69,7 @@ const char *cPluginIptv::CommandLineHelp(void)
{
debug("cPluginIptv::CommandLineHelp()\n");
// Return a string that describes all known command line options.
return " -d <num>, --devices=<number> number of devices to be created (default: 1)\n";
return " -d <num>, --devices=<number> number of devices to be created\n";
}
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
@@ -74,20 +77,20 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
debug("cPluginIptv::ProcessArgs()\n");
// Implement command line argument processing here if applicable.
static const struct option long_options[] = {
{ "devices", required_argument, NULL, 'd' },
{ NULL }
};
{ "devices", required_argument, NULL, 'd' },
{ NULL }
};
int c;
while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
switch (c) {
case 'd':
deviceCount = atoi(optarg);
break;
default:
return false;
}
}
switch (c) {
case 'd':
deviceCount = atoi(optarg);
break;
default:
return false;
}
}
return true;
}
@@ -95,6 +98,7 @@ bool cPluginIptv::Initialize(void)
{
debug("cPluginIptv::Initialize()\n");
// Initialize any background activities the plugin shall perform.
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
return cIptvDevice::Initialize(deviceCount);
}
@@ -158,14 +162,14 @@ int cPluginIptv::ParseFilters(const char *Value, int *Filters)
char buffer[256];
int n = 0;
while (Value && *Value && (n < SECTION_FILTER_TABLE_SIZE)) {
strn0cpy(buffer, Value, sizeof(buffer));
int i = atoi(buffer);
//debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
if (i >= 0)
Filters[n++] = i;
if ((Value = strchr(Value, ' ')) != NULL)
Value++;
}
strn0cpy(buffer, Value, sizeof(buffer));
int i = atoi(buffer);
//debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
if (i >= 0)
Filters[n++] = i;
if ((Value = strchr(Value, ' ')) != NULL)
Value++;
}
return n;
}
@@ -177,14 +181,16 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value)
IptvConfig.SetTsBufferSize(atoi(Value));
else if (!strcasecmp(Name, "TsBufferPrefill"))
IptvConfig.SetTsBufferPrefillRatio(atoi(Value));
else if (!strcasecmp(Name, "ExtProtocolBasePort"))
IptvConfig.SetExtProtocolBasePort(atoi(Value));
else if (!strcasecmp(Name, "SectionFiltering"))
IptvConfig.SetSectionFiltering(atoi(Value));
else if (!strcasecmp(Name, "SidScanning"))
IptvConfig.SetSidScanning(atoi(Value));
else if (!strcasecmp(Name, "DisabledFilters")) {
int DisabledFilters[SECTION_FILTER_TABLE_SIZE] = { -1 };
int DisabledFiltersCount = ParseFilters(Value, DisabledFilters);
for (int i = 0; i < DisabledFiltersCount; ++i)
int DisabledFilters[SECTION_FILTER_TABLE_SIZE];
for (unsigned int i = 0; i < ARRAY_SIZE(DisabledFilters); ++i)
DisabledFilters[i] = -1;
unsigned int DisabledFiltersCount = ParseFilters(Value, DisabledFilters);
for (unsigned int i = 0; i < DisabledFiltersCount; ++i)
IptvConfig.SetDisabledFilters(i, DisabledFilters[i]);
}
else

67
iptv/internetradio.sh Executable file
View File

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

83
iptv/iptvstream.sh Executable file
View File

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

54
iptv/linein.sh Executable file
View File

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

100
iptv/vlc2iptv Executable file
View File

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

69
iptv/webcam.sh Executable file
View File

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

View File

@@ -1,6 +1,6 @@
diff -Nru vdr-1.5.10-vanilla/channels.c vdr-1.5.10-pluginparam/channels.c
--- vdr-1.5.10-vanilla/channels.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/channels.c 2007-10-14 20:31:12.000000000 +0300
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("");
@@ -44,17 +44,17 @@ diff -Nru vdr-1.5.10-vanilla/channels.c vdr-1.5.10-pluginparam/channels.c
+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;
+ 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)
@@ -122,9 +122,9 @@ diff -Nru vdr-1.5.10-vanilla/channels.c vdr-1.5.10-pluginparam/channels.c
free(parambuf);
free(sourcebuf);
diff -Nru vdr-1.5.10-vanilla/channels.h vdr-1.5.10-pluginparam/channels.h
--- vdr-1.5.10-vanilla/channels.h 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/channels.h 2007-10-14 20:32:16.000000000 +0300
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;
@@ -164,10 +164,22 @@ diff -Nru vdr-1.5.10-vanilla/channels.h vdr-1.5.10-pluginparam/channels.h
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
void SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level);
diff -Nru vdr-1.5.10-vanilla/menu.c vdr-1.5.10-pluginparam/menu.c
--- vdr-1.5.10-vanilla/menu.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/menu.c 2007-10-14 20:31:12.000000000 +0300
@@ -219,6 +219,7 @@
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];
@@ -175,15 +187,15 @@ diff -Nru vdr-1.5.10-vanilla/menu.c vdr-1.5.10-pluginparam/menu.c
void Setup(void);
public:
cMenuEditChannel(cChannel *Channel, bool New = false);
@@ -251,6 +252,7 @@
@@ -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), tr(FileNameChars)));
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name)));
Add(new cMenuEditSrcItem( tr("Source"), &data.source));
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
@@ -281,6 +283,7 @@
@@ -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")));
@@ -191,7 +203,7 @@ diff -Nru vdr-1.5.10-vanilla/menu.c vdr-1.5.10-pluginparam/menu.c
SetCurrent(Get(current));
Display();
@@ -295,6 +298,7 @@
@@ -329,6 +332,7 @@
if (Key == kOk) {
if (Channels.HasUniqueChannelID(&data, channel)) {
data.name = strcpyrealloc(data.name, name);
@@ -199,19 +211,29 @@ diff -Nru vdr-1.5.10-vanilla/menu.c vdr-1.5.10-pluginparam/menu.c
if (channel) {
*channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.5.10-vanilla/po/fi_FI.po vdr-1.5.10-pluginparam/po/fi_FI.po
--- vdr-1.5.10-vanilla/po/fi_FI.po 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/po/fi_FI.po 2007-10-14 20:34:41.000000000 +0300
@@ -998,3 +998,6 @@
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.5.10-vanilla/sources.c vdr-1.5.10-pluginparam/sources.c
--- vdr-1.5.10-vanilla/sources.c 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.c 2007-10-14 20:31:12.000000000 +0300
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êtera dans %s minutes"
+
+msgid "Parameters"
+msgstr "Paramè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;
@@ -228,9 +250,9 @@ diff -Nru vdr-1.5.10-vanilla/sources.c vdr-1.5.10-pluginparam/sources.c
case 'C': type = stCable; break;
case 'S': type = stSat; break;
case 'T': type = stTerr; break;
diff -Nru vdr-1.5.10-vanilla/sources.conf vdr-1.5.10-pluginparam/sources.conf
--- vdr-1.5.10-vanilla/sources.conf 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.conf 2007-10-14 20:31:12.000000000 +0300
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
@@ -239,9 +261,9 @@ diff -Nru vdr-1.5.10-vanilla/sources.conf vdr-1.5.10-pluginparam/sources.conf
+# Plugin
+
+P Plugin
diff -Nru vdr-1.5.10-vanilla/sources.h vdr-1.5.10-pluginparam/sources.h
--- vdr-1.5.10-vanilla/sources.h 2007-10-14 18:21:57.000000000 +0300
+++ vdr-1.5.10-pluginparam/sources.h 2007-10-14 20:31:12.000000000 +0300
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 {

View File

@@ -0,0 +1,287 @@
diff -Nru vdr-1.7.2-vanilla/channels.c vdr-1.7.2-pluginparam/channels.c
--- vdr-1.7.2-vanilla/channels.c 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/channels.c 2008-12-14 19:52:45.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;
}
@@ -306,9 +310,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:
@@ -438,6 +459,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
@@ -632,7 +665,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);
@@ -646,6 +679,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;
}
@@ -674,7 +708,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;
@@ -792,7 +826,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) {
@@ -887,6 +921,7 @@
shortName = strcpyrealloc(shortName, p);
}
name = strcpyrealloc(name, namebuf);
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
free(parambuf);
free(sourcebuf);
diff -Nru vdr-1.7.2-vanilla/channels.h vdr-1.7.2-pluginparam/channels.h
--- vdr-1.7.2-vanilla/channels.h 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/channels.h 2008-12-14 19:53:44.000000000 +0200
@@ -116,6 +116,7 @@
char *shortName;
char *provider;
char *portalName;
+ char *pluginParam;
int __BeginData__;
int frequency; // MHz
int source;
@@ -171,6 +172,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; }
@@ -208,6 +210,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); }
@@ -215,12 +218,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.2-vanilla/config.h vdr-1.7.2-pluginparam/config.h
--- vdr-1.7.2-vanilla/config.h 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/config.h 2008-12-14 19:52:45.000000000 +0200
@@ -30,6 +30,8 @@
#define APIVERSION "1.7.0"
#define APIVERSNUM 10700 // 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.2-vanilla/menu.c vdr-1.7.2-pluginparam/menu.c
--- vdr-1.7.2-vanilla/menu.c 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/menu.c 2008-12-14 19:52:45.000000000 +0200
@@ -189,6 +189,7 @@
cChannel *channel;
cChannel data;
char name[256];
+ char pluginParam[256];
void Setup(void);
public:
cMenuEditChannel(cChannel *Channel, bool New = false);
@@ -221,6 +222,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));
@@ -253,6 +255,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();
@@ -267,6 +270,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.2-vanilla/po/fi_FI.po vdr-1.7.2-pluginparam/po/fi_FI.po
--- vdr-1.7.2-vanilla/po/fi_FI.po 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/po/fi_FI.po 2008-12-14 19:52:45.000000000 +0200
@@ -1010,3 +1010,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.2-vanilla/po/fr_FR.po vdr-1.7.2-pluginparam/po/fr_FR.po
--- vdr-1.7.2-vanilla/po/fr_FR.po 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/po/fr_FR.po 2008-12-14 19:52:45.000000000 +0200
@@ -1013,3 +1013,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.2-vanilla/sources.c vdr-1.7.2-pluginparam/sources.c
--- vdr-1.7.2-vanilla/sources.c 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/sources.c 2008-12-14 19:52:45.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.2-vanilla/sources.conf vdr-1.7.2-pluginparam/sources.conf
--- vdr-1.7.2-vanilla/sources.conf 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/sources.conf 2008-12-14 19:52:45.000000000 +0200
@@ -194,3 +194,7 @@
# Terrestrial
T Terrestrial
+
+# Plugin
+
+P Plugin
diff -Nru vdr-1.7.2-vanilla/sources.h vdr-1.7.2-pluginparam/sources.h
--- vdr-1.7.2-vanilla/sources.h 2008-12-14 18:36:17.000000000 +0200
+++ vdr-1.7.2-pluginparam/sources.h 2008-12-14 19:52:45.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; }

158
pidscanner.c Normal file
View File

@@ -0,0 +1,158 @@
/*
* pidscanner.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include "common.h"
#include "pidscanner.h"
#define PIDSCANNER_TIMEOUT_IN_MS 15000 /* 15s timeout for detection */
#define PIDSCANNER_APID_COUNT 5 /* minimum count of audio pid samples for pid detection */
#define PIDSCANNER_VPID_COUNT 5 /* minimum count of video pid samples for pid detection */
#define PIDSCANNER_PID_DELTA_COUNT 100 /* minimum count of pid samples for audio/video only pid detection */
cPidScanner::cPidScanner(void)
: timeout(0),
process(true),
Vpid(0xFFFF),
Apid(0xFFFF),
numVpids(0),
numApids(0)
{
debug("cPidScanner::cPidScanner()\n");
channel = cChannel();
}
cPidScanner::~cPidScanner()
{
debug("cPidScanner::~cPidScanner()\n");
}
void cPidScanner::SetChannel(const cChannel *Channel)
{
if (Channel) {
debug("cPidScanner::SetChannel(): %s\n", Channel->PluginParam());
channel = *Channel;
}
else {
debug("cPidScanner::SetChannel()\n");
channel = cChannel();
}
Vpid = 0xFFFF;
numVpids = 0;
Apid = 0xFFFF;
numApids = 0;
process = true;
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
}
void cPidScanner::Process(const uint8_t* buf)
{
//debug("cPidScanner::Process()\n");
if (!process)
return;
// Stop scanning after defined timeout
if (timeout.TimedOut()) {
debug("cPidScanner::Process: Timed out determining pids\n");
process = false;
}
// Verify TS packet
if (buf[0] != 0x47) {
error("Not TS packet: 0x%X\n", buf[0]);
return;
}
// Found TS packet
int pid = ts_pid(buf);
int xpid = (buf[1] << 8 | buf[2]);
// Check if payload available
uint8_t count = payload(buf);
if (count == 0)
return;
if (xpid & 0x4000) {
// Stream start (Payload Unit Start Indicator)
uchar *d = (uint8_t*)buf;
d += 4;
// pointer to payload
if (buf[3] & 0x20)
d += d[0] + 1;
// Skip adaption field
if (buf[3] & 0x10) {
// Payload present
if ((d[0] == 0) && (d[1] == 0) && (d[2] == 1)) {
// PES packet start
int sid = d[3];
// Stream ID
if ((sid >= 0xC0) && (sid <= 0xDF)) {
if (pid < Apid) {
debug("cPidScanner::Process: Found lower Apid: 0x%X instead of 0x%X\n", pid, Apid);
Apid = pid;
numApids = 1;
}
else if (pid == Apid) {
++numApids;
debug("cPidScanner::Process: Incrementing Apids, now at %d\n", numApids);
}
}
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
if (pid < Vpid) {
debug("cPidScanner::Process: Found lower Vpid: 0x%X instead of 0x%X\n", pid, Vpid);
Vpid = pid;
numVpids = 1;
}
else if (pid == Vpid) {
++numVpids;
debug("cPidScanner::Process: Incrementing Vpids, now at %d\n", numVpids);
}
}
}
if (((numVpids >= PIDSCANNER_VPID_COUNT) && (numApids >= PIDSCANNER_APID_COUNT)) ||
(abs(numApids - numVpids) >= PIDSCANNER_PID_DELTA_COUNT)) {
// Lock channels for pid updates
if (!Channels.Lock(true, 10)) {
timeout.Set(PIDSCANNER_TIMEOUT_IN_MS);
return;
}
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
int Dpids[MAXDPIDS + 1] = { 0 };
int Spids[MAXSPIDS + 1] = { 0 };
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
int Ppid = IptvChannel->Ppid();
int Tpid = IptvChannel->Tpid();
bool foundApid = false;
if (numVpids < PIDSCANNER_VPID_COUNT)
Vpid = 0; // No detected video pid
else if (numApids < PIDSCANNER_APID_COUNT)
Apid = 0; // No detected audio pid
for (unsigned int i = 1; i < MAXAPIDS; ++i) {
Apids[i] = IptvChannel->Apid(i);
if (Apids[i] && (Apids[i] == Apid))
foundApid = true;
}
if (!foundApid)
Apids[0] = Apid;
for (unsigned int i = 0; i < MAXDPIDS; ++i)
Dpids[i] = IptvChannel->Dpid(i);
for (unsigned int i = 0; i < MAXSPIDS; ++i)
Spids[i] = IptvChannel->Spid(i);
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid);
#if defined(APIVERSNUM) && APIVERSNUM >= 10700
IptvChannel->SetPids(Vpid, Ppid, 0, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#else
IptvChannel->SetPids(Vpid, Ppid, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#endif
Channels.Unlock();
process = false;
}
}
}
}

31
pidscanner.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* pidscanner.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __PIDSCANNER_H
#define __PIDSCANNER_H
#include <vdr/tools.h>
#include <vdr/channels.h>
class cPidScanner {
private:
cTimeMs timeout;
cChannel channel;
bool process;
int Vpid;
int Apid;
int numVpids;
int numApids;
public:
cPidScanner(void);
~cPidScanner();
void SetChannel(const cChannel *Channel);
void Process(const uint8_t* buf);
};
#endif // __PIDSCANNER_H

166
po/de_DE.po Normal file
View File

@@ -0,0 +1,166 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Tobias <vdr@e-tobi.net>, 2007.
#
msgid ""
msgstr ""
"Project-Id-Version: iptv 0.2.0\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2008-02-01 23:43+0200\n"
"PO-Revision-Date: 2007-10-29 21:19+0100\n"
"Last-Translator: Tobias Grimm <tg@e-tobi.net>\n"
"Language-Team: German\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 "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 "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Kann eindeutige Kanaleinstellungen nicht finden!"
msgid "IPTV Channels"
msgstr "IPTV Kanäle"
msgid "IPTV Information"
msgstr "IPTV Informationen"
msgid "General"
msgstr "Allgemein"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filter"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "IPTV Informationen nicht verfügbar!"
msgid "TS buffer size [MB]"
msgstr "TS Puffergröße [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 ""
msgid "TS buffer prefill ratio [%]"
msgstr "TS Puffer-Preload [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
msgid "EXT protocol base port"
msgstr "EXT Protokoll Basisport"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
msgid "Use section filtering"
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 ""
msgid "Disable filters"
msgstr "Deaktiviere 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 ""
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Deaktiviere Filter"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr ""
msgid "Help"
msgstr "Hilfe"

View File

@@ -1,18 +1,18 @@
# VDR plugin language source file.
# Copyright (C) 2007 Klaus Schmidinger <kls@cadsoft.de>
# This file is distributed under the same license as the VDR package.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Rolf Ahrenberg
#
msgid ""
msgstr ""
"Project-Id-Version: VDR 1.5.7\n"
"Project-Id-Version: iptv 0.2.0\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2007-10-14 21:42+0300\n"
"POT-Creation-Date: 2008-02-01 23:43+0200\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: <vdr@linuxtv.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "PAT (0x00)"
@@ -48,29 +48,44 @@ 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 "Nid"
msgstr "Verkko-ID"
msgid "Tid"
msgstr "L<EFBFBD>hete-ID"
msgstr "Lähete-ID"
msgid "Rid"
msgstr "Radio-ID"
msgid "Cannot find unique channel settings!"
msgstr "Yksil<EFBFBD>llisi<EFBFBD> kanava-asetuksia ei l<EFBFBD>ydet<EFBFBD>!"
msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!"
msgid "IPTV Channels"
msgstr "IPTV-kanavat"
@@ -96,18 +111,71 @@ msgstr "IPTV-tietoja ei saatavilla!"
msgid "TS buffer size [MB]"
msgstr "TS-puskurin koko [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 ""
"Määritä rengaspuskurin koko TS-lähetteelle megatavuina.\n"
"\n"
"Pienempi rengaspuskuri vähentää muistinkulutusta, mutta on virhealttiimpi puskurin ylivuodolle."
msgid "TS buffer prefill ratio [%]"
msgstr "TS-puskurin esit<EFBFBD>ytt<EFBFBD>aste [%]"
msgstr "TS-puskurin esitäyttöaste [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
"Määrittele TS-rengaspuskurin esitäyttöaste, jonka jälkeen lähetettä aletaan siirtämään eteenpäin VDR:lle.\n"
"\n"
"Puskurin esitäyttö parantaa suoratoistoa hitailla ja epäluotettavilla yhteyksillä."
msgid "EXT protocol base port"
msgstr "EXT-protokollan perusportti"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
"Määrittele EXT-protokollan käyttämä perusportti.\n"
"\n"
"Porttiavaruuden koko määräytyy käytettyjen IPTV-laitteiden mukaan. Laajennos lukee EXT-protokollan yhteydessä perusportista dataa, jota ulkoiset ohjelmistot tarjoavat."
msgid "Use section filtering"
msgstr "K<EFBFBD>yt<EFBFBD> sektioiden suodatusta"
msgstr "Käytä sektioiden suodatusta"
msgid "Scan Sid automatically"
msgstr "Etsi palvelu-ID automaattisesti"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
"Määrittele suodatuksen käyttö sektioille.\n"
"\n"
"IPTV-laajennos voi suodattaa lähetteestä VDR:lle tarjottavia sektioita, joita käytetään esim. ohjelmaoppaan ja ohjelmatunnisteiden (PID) päivittämiseen.\n"
"Toiminto ei vaikuta lähetteeseen, jossa ei ole sektioita."
msgid "Disable filters"
msgstr "Poista suodattimia k<EFBFBD>yt<EFBFBD>st<EFBFBD>"
msgstr "Poista suodattimia käytöstä"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Määrittele käytöstä poistettavien suodattimien lukumäärä sektioille.\n"
"\n"
"Tietyt sektiot saattavat aiheuttaa virheellistä toimintaa VDR:ssä, esimerkiksi asettavat väärän kellonajan, ja näiden poistaminen auttaa VDR:ää toimimaan kunnolla jäljelle jäävien sektioiden kanssa."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Poista suodatin k<EFBFBD>yt<EFBFBD>st<EFBFBD>"
msgstr "Poista suodatin käytöstä"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Määrittele käytöstä poistettava suodatin, joka lisätään mustalle listalle."
msgid "Help"
msgstr "Opaste"

183
po/fr_FR.po Normal file
View File

@@ -0,0 +1,183 @@
# French translations for iptv package.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Bruno ROUSSEL <bruno.roussel@free.fr>, 2007.
# NIVAL Michaël <mnival@club-internet.fr>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: iptv 0.2.0\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2008-02-01 23:43+0200\n"
"PO-Revision-Date: 2008-01-26 13:14+0100\n"
"Last-Translator: NIVAL Michaël <mnival@club-internet.fr>\n"
"Language-Team: French\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 "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 "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Impossible de trouver un paramètre de chaîne unique !"
msgid "IPTV Channels"
msgstr "Canal IPTV"
msgid "IPTV Information"
msgstr "Information sur IPTV"
msgid "General"
msgstr "Général"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtres"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "IPTV information not available!"
msgstr "Information sur IPTV non disponible !"
msgid "TS buffer size [MB]"
msgstr "Taille du buffer TS [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 ""
"Définit la taille du ringbuffer pour le transport du flux en megabytes.\n"
"\n"
"Une taille plus petite taille aide la consommation de mémoire, mais c'est sujet à plus de débordement de tampon."
msgid "TS buffer prefill ratio [%]"
msgstr "Taux du buffer de pré-remplissage TS [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
"Définit le ratio de pré-remplissage du ringbuffer pour le transport du flux avant transfert dans VDR.\n"
"\n"
"Cette option est utile si le streaming est sur une connexion lente ou peu fiables."
msgid "EXT protocol base port"
msgstr "Port de base du protocole EXT"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
"Définit le port de base utilisé par le protocole EXT.\n"
"\n"
"La plage de port est défini par le nombre de dispositif IPTV. Ce paramètre défini le port qui est écouté pour les connexions à partir d'applications externes en utilisant le protocole EXT."
msgid "Use section filtering"
msgstr "Utiliser le filtrage de section"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
"Définit si la section de filtrage doit être utilisé.\n"
"\n"
"La section filtrage signifie que le plugin IPTV essayera d'analyser et de fournir à VDR des données secondaires disponible sur le flux. VDR peut alors utiliser ces données pour fournir des fonctionnalitées supplémentaires tel que la détection de changement de pid et d'EPG etc.\n"
"L'activation de cette fonctionnalité n'a pas d'incidence sur les flux qui ne contiennent pas de données de la section."
msgid "Disable filters"
msgstr "Désactiver les filtres"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Définit le numéro de section de filtrage qui sont désactivé.\n"
"\n"
"Certains filtrage de section peux engendrer des comportement indésirables. Blacklist les filtres qui seront laissé intact pour VDR."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Désactiver le filtre"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Définit les mauvais comportement qui doivent être désactivé."
msgid "Help"
msgstr "Aide"

183
po/it_IT.po Normal file
View File

@@ -0,0 +1,183 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Diego Pierotto <vdr-italian@tiscali.it>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: iptv 0.2.0\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2008-02-01 23:43+0200\n"
"PO-Revision-Date: 2008-07-13 03:28+0100\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: Italian\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 "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 "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Impossibile trovare impostazioni canale unico!"
msgid "IPTV Channels"
msgstr "Canali IPTV"
msgid "IPTV Information"
msgstr "Informazione IPTV"
msgid "General"
msgstr "Generale"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtri"
msgid "Bits/bytes"
msgstr "Bits/bytes"
msgid "IPTV information not available!"
msgstr "Informazione IPTV non disponibile!"
msgid "TS buffer size [MB]"
msgstr "Dimensione buffer TS [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 ""
"Definisci una dimensione del buffer in MB per i flussi di trasporto.\n"
"\n"
"Dimensioni più piccole aiutano il consumo di memoria, ma sono più inclini a generare buffer overflows."
msgid "TS buffer prefill ratio [%]"
msgstr "Riempimento buffer TS [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
"Definisci un rapporto di riempimento del buffer per i flussi di trasporto prima che i dati siano trasferiti a VDR.\n"
"\n"
"Questo è utile se si trasmette dati su una connessione lenta oppure inaffidabile."
msgid "EXT protocol base port"
msgstr "Porta base protocollo EXT"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
"Definisci una porta base usata dal protocollo EXT.\n"
"\n"
"Il range della porta è definito dal numero di periferiche IPTV. Questo parametro imposta la porta che è in ascolto per connessioni da applicazioni esterne quando si usa il protocollo EXT."
msgid "Use section filtering"
msgstr "Utilizza sezione filtri"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
"Definisci se la sezione filtri sarà utilizzata.\n"
"\n"
"La sezioni filtri significa che il plugin IPTV prova a elaborare e fornire a VDR dati secondari sul flusso attualmente attivo. VDR può successivamente usare questi dati per fornire varie funzionalità come il rilevamento del cambio Pid automatico, EPG, etc.\n"
"Abilitare questa funzione non influisce sui flussi che non contengono dati di sezione."
msgid "Disable filters"
msgstr "Disabilita filtri"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Definisci il numero di sezione filtri che sarà disabilitato.\n"
"\n"
"Certe sezioni filtri potrebbero generare alcuni comportamenti indesiderati per VDR come la non sincronizzazione dell'ora. Inserendo qui i filtri nella lista nera i dati di sezione utili possono essere lasciati intatti per l'elaborazione da parte di VDR."
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Disabilita filtro"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definisci un filtro corrotto che sarà messo nella lista nera."
msgid "Help"
msgstr "Aiuto"

168
po/ru_RU.po Normal file
View File

@@ -0,0 +1,168 @@
# VDR plugin language source file.
# Copyright (C) 2007 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Alexander Gross <Bikalexander@gmail.com>, 2008.
#
msgid ""
msgstr ""
"Project-Id-Version: iptv 0.2.0\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2008-02-01 23:43+0200\n"
"PO-Revision-Date: 2008-03-16 12:14+0100\n"
"Last-Translator: Alexander Gross <Bikalexander@gmail.com>\n"
"Language-Team: Russian <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: KBabel 1.11.4\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F)"
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 "Попробуй 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 "Nid"
msgstr "Nid"
msgid "Tid"
msgstr "Tid"
msgid "Rid"
msgstr "Rid"
msgid "Cannot find unique channel settings!"
msgstr "Невозможно найти уникальные настройки канала!"
msgid "IPTV Channels"
msgstr "IPTV каналы"
msgid "IPTV Information"
msgstr "IPTV информация"
msgid "General"
msgstr "Общее"
msgid "Pids"
msgstr "Пиды"
msgid "Filters"
msgstr "Фильтры"
msgid "Bits/bytes"
msgstr "Биты / байт"
msgid "IPTV information not available!"
msgstr "IPTV информация отсутствует!"
msgid "TS buffer size [MB]"
msgstr "Размер TS буфера [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 ""
msgid "TS buffer prefill ratio [%]"
msgstr "Предварительный буфер TS [%]"
msgid ""
"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n"
"\n"
"This is useful if streaming media over a slow or unreliable connection."
msgstr ""
msgid "EXT protocol base port"
msgstr "Базисный порт EXT протокола"
msgid ""
"Define a base port used by EXT protocol.\n"
"\n"
"The port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the EXT protocol."
msgstr ""
msgid "Use section filtering"
msgstr "Использовать область фильтрации"
msgid ""
"Define whether the section filtering shall be used.\n"
"\n"
"Section filtering means that IPTV plugin tries to parse and provide VDR with secondary data about the currently active stream. VDR can then use this data for providing various functionalities such as automatic pid change detection and EPG etc.\n"
"Enabling this feature does not affect streams that do not contain section data."
msgstr ""
msgid "Disable filters"
msgstr "Деактивировать фильтры"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
#. TRANSLATORS: note the singular!
msgid "Disable filter"
msgstr "Деактивировать фильтр"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Неправильно работающий фильтр, занести в черный список."
msgid "Help"
msgstr "Справка"

157
protocolext.c Normal file
View File

@@ -0,0 +1,157 @@
/*
* protocolext.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <vdr/device.h>
#include <vdr/plugin.h>
#include "common.h"
#include "config.h"
#include "protocolext.h"
cIptvProtocolExt::cIptvProtocolExt()
: pid(-1),
scriptFile(""),
scriptParameter(0)
{
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
}
cIptvProtocolExt::~cIptvProtocolExt()
{
debug("cIptvProtocolExt::~cIptvProtocolExt()\n");
// Drop the socket connection
cIptvProtocolExt::Close();
}
void cIptvProtocolExt::ExecuteScript(void)
{
debug("cIptvProtocolExt::ExecuteScript()\n");
// Check if already executing
if (pid > 0) {
error("ERROR: Cannot execute script!");
return;
}
// Let's fork
ERROR_IF_RET((pid = fork()) == -1, "fork()", return);
// Check if child process
if (pid == 0) {
// Close all dup'ed filedescriptors
int MaxPossibleFileDescriptors = getdtablesize();
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
close(i);
// Execute the external script
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort);
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
if (execl("/bin/sh", "sh", "-c", *cmd, NULL) == -1) {
error("ERROR: Script execution failed: %s", *cmd);
_exit(-1);
}
_exit(0);
}
else {
debug("cIptvProtocolExt::ExecuteScript(): pid=%d\n", pid);
}
}
void cIptvProtocolExt::TerminateScript(void)
{
debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pid);
if (pid > 0) {
const unsigned int timeoutms = 100;
unsigned int waitms = 0;
siginfo_t waitStatus;
bool waitOver = false;
// signal and wait for termination
int retval = kill(pid, SIGINT);
ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
while (!waitOver) {
retval = 0;
waitms += timeoutms;
if ((waitms % 2000) == 0) {
error("ERROR: Script '%s' won't terminate - killing it!", *scriptFile);
kill(pid, SIGKILL);
}
// Clear wait status to make sure child exit status is accessible
memset(&waitStatus, '\0', sizeof(waitStatus));
// Wait for child termination
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
// These are the acceptable conditions under which child exit is
// regarded as successful
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
debug("Child (%d) exited as expected\n", pid);
waitOver = true;
}
// Unsuccessful wait, avoid busy looping
if (!waitOver)
cCondWait::SleepMs(timeoutms);
}
pid = -1;
}
}
bool cIptvProtocolExt::Open(void)
{
debug("cIptvProtocolExt::Open()\n");
// Reject empty script files
if (!strlen(scriptFile))
return false;
// Create the listening socket
OpenSocket(socketPort);
// Execute the external script
ExecuteScript();
isActive = true;
return true;
}
bool cIptvProtocolExt::Close(void)
{
debug("cIptvProtocolExt::Close()\n");
// Close the socket
CloseSocket();
// Terminate the external script
TerminateScript();
isActive = false;
return true;
}
int cIptvProtocolExt::Read(unsigned char* *BufferAddr)
{
return cIptvUdpSocket::Read(BufferAddr);
}
bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int Index)
{
debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
struct stat stbuf;
// Update script file and parameter
scriptFile = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), Location);
if ((stat(scriptFile, &stbuf) != 0) || (strstr(scriptFile, "..") != 0)) {
error("ERROR: Non-existent or relative path script '%s'", *scriptFile);
return false;
}
scriptParameter = Parameter;
// Update listen port
socketPort = IptvConfig.GetExtProtocolBasePort() + Index;
}
return true;
}
cString cIptvProtocolExt::GetInformation(void)
{
//debug("cIptvProtocolExt::GetInformation()");
return cString::sprintf("ext://%s:%d", *scriptFile, scriptParameter);
}

36
protocolext.h Normal file
View File

@@ -0,0 +1,36 @@
/*
* protocolext.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_PROTOCOLEXT_H
#define __IPTV_PROTOCOLEXT_H
#include <arpa/inet.h>
#include "protocolif.h"
#include "socket.h"
class cIptvProtocolExt : public cIptvUdpSocket, public cIptvProtocolIf {
private:
int pid;
cString scriptFile;
int scriptParameter;
private:
void TerminateScript(void);
void ExecuteScript(void);
public:
cIptvProtocolExt();
virtual ~cIptvProtocolExt();
int Read(unsigned char* *BufferAddr);
bool Set(const char* Location, const int Parameter, const int Index);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLEXT_H

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolfile.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $
*/
#include <fcntl.h>
@@ -16,11 +15,12 @@
#include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile()
: readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
: fileDelay(0),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug("cIptvProtocolFile::cIptvProtocolFile()\n");
streamAddr = strdup("");
fileLocation = strdup("");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
@@ -31,9 +31,9 @@ cIptvProtocolFile::~cIptvProtocolFile()
{
debug("cIptvProtocolFile::~cIptvProtocolFile()\n");
// Drop open handles
Close();
cIptvProtocolFile::Close();
// Free allocated memory
free(streamAddr);
free(fileLocation);
free(readBuffer);
}
@@ -41,13 +41,9 @@ bool cIptvProtocolFile::OpenFile(void)
{
debug("cIptvProtocolFile::OpenFile()\n");
// Check that stream address is valid
if (!isActive && !isempty(streamAddr)) {
fileStream = fopen(streamAddr, "rb");
if (ferror(fileStream) || !fileStream) {
char tmp[64];
error("ERROR: fopen(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return false;
}
if (!isActive && !isempty(fileLocation)) {
fileStream = fopen(fileLocation, "rb");
ERROR_IF_RET(!fileStream || ferror(fileStream), "fopen()", return false);
// Update active flag
isActive = true;
}
@@ -58,7 +54,7 @@ void cIptvProtocolFile::CloseFile(void)
{
debug("cIptvProtocolFile::CloseFile()\n");
// Check that file stream is valid
if (isActive && !isempty(streamAddr)) {
if (isActive && !isempty(fileLocation)) {
fclose(fileStream);
// Update active flag
isActive = false;
@@ -79,8 +75,8 @@ int cIptvProtocolFile::Read(unsigned char* *BufferAddr)
rewind(fileStream);
// Sleep before reading the file stream to prevent aggressive busy looping
// and prevent transfer ringbuffer overflows
if (streamPort)
cCondWait::SleepMs(streamPort);
if (fileDelay)
cCondWait::SleepMs(fileDelay);
// This check is to prevent a race condition where file may be switched off
// during the sleep and buffers are disposed. Check here that the plugin is
// still active before accessing the buffers
@@ -91,7 +87,7 @@ int cIptvProtocolFile::Read(unsigned char* *BufferAddr)
bool cIptvProtocolFile::Open(void)
{
debug("cIptvProtocolFile::Open(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolFile::Open()\n");
// Open the file stream
OpenFile();
return true;
@@ -99,21 +95,21 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void)
{
debug("cIptvProtocolFile::Close(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolFile::Close()\n");
// Close the file stream
CloseFile();
return true;
}
bool cIptvProtocolFile::Set(const char* Address, const int Port)
bool cIptvProtocolFile::Set(const char* Location, const int Parameter, const int Index)
{
debug("cIptvProtocolFile::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Close the file stream
CloseFile();
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Address);
streamPort = Port;
fileLocation = strcpyrealloc(fileLocation, Location);
fileDelay = Parameter;
// Open the file for input
OpenFile();
}
@@ -123,5 +119,5 @@ bool cIptvProtocolFile::Set(const char* Address, const int Port)
cString cIptvProtocolFile::GetInformation(void)
{
//debug("cIptvProtocolFile::GetInformation()");
return cString::sprintf("file://%s:%d", streamAddr, streamPort);
return cString::sprintf("file://%s:%d", fileLocation, fileDelay);
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolfile.h,v 1.5 2007/10/07 22:54:09 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLFILE_H
@@ -14,8 +13,8 @@
class cIptvProtocolFile : public cIptvProtocolIf {
private:
char* streamAddr;
int streamPort;
char* fileLocation;
int fileDelay;
FILE* fileStream;
unsigned char* readBuffer;
unsigned int readBufferLen;
@@ -28,11 +27,11 @@ private:
public:
cIptvProtocolFile();
virtual ~cIptvProtocolFile();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
int Read(unsigned char* *BufferAddr);
bool Set(const char* Location, const int Parameter, const int Index);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLFILE_H

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolhttp.c,v 1.10 2007/10/07 22:54:09 rahrenbe Exp $
*/
#include <sys/types.h>
@@ -20,88 +19,20 @@
#include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp()
: streamPort(3000),
socketDesc(-1),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
streamAddr = strdup("");
streamPath = strdup("/");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
error("ERROR: MALLOC() failed in ProtocolHttp()");
}
cIptvProtocolHttp::~cIptvProtocolHttp()
{
debug("cIptvProtocolHttp::~cIptvProtocolHttp()\n");
// Close the socket
Close();
cIptvProtocolHttp::Close();
// Free allocated memory
free(streamPath);
free(streamAddr);
free(readBuffer);
}
bool cIptvProtocolHttp::OpenSocket(const int Port)
{
debug("cIptvProtocolHttp::OpenSocket()\n");
// If socket is there already and it is bound to a different port, it must
// be closed first
if (Port != streamPort) {
debug("cIptvProtocolHttp::OpenSocket(): Socket tear-down\n");
CloseSocket();
}
// Bind to the socket if it is not active already
if (socketDesc < 0) {
int yes = 1;
// Create socket
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
if (socketDesc < 0) {
char tmp[64];
error("ERROR: socket(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return false;
}
// Make it use non-blocking I/O to avoid stuck read calls
if (fcntl(socketDesc, F_SETFL, O_NONBLOCK)) {
char tmp[64];
error("ERROR: fcntl(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Allow multiple sockets to use the same PORT number
if (setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0) {
char tmp[64];
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Create default socket
memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(Port);
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
// Update stream port
streamPort = Port;
}
return true;
}
void cIptvProtocolHttp::CloseSocket(void)
{
debug("cIptvProtocolHttp::CloseSocket()\n");
// Check if socket exists
if (socketDesc >= 0) {
close(socketDesc);
socketDesc = -1;
}
}
bool cIptvProtocolHttp::Connect(void)
@@ -110,7 +41,7 @@ bool cIptvProtocolHttp::Connect(void)
// Check that stream address is valid
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
// Ensure that socket is valid
OpenSocket(streamPort);
OpenSocket(socketPort);
// First try only the IP address
sockAddr.sin_addr.s_addr = inet_addr(streamAddr);
@@ -134,29 +65,12 @@ bool cIptvProtocolHttp::Connect(void)
int err = connect(socketDesc, (struct sockaddr*)&sockAddr,
sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected
if (err < 0 && errno != EINPROGRESS) {
char tmp[64];
error("ERROR: Connect(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
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 on the socket completion
struct timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
// Use select to check socket writability
fd_set wfds;
FD_ZERO(&wfds);
FD_SET(socketDesc, &wfds);
int retval = select(socketDesc + 1, NULL, &wfds, NULL, &tv);
// Check if error
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return -1;
}
// Select has returned. Get socket errors if there are any
int socketStatus = 0;
socklen_t len = sizeof(socketStatus);
@@ -172,24 +86,16 @@ bool cIptvProtocolHttp::Connect(void)
}
// Formulate and send HTTP request
char buffer[256];
memset(buffer, '\0', sizeof(buffer));
snprintf(buffer, sizeof(buffer),
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: vdr-iptv\r\n"
"Range: bytes=0-\r\n"
"Connection: Close\r\n"
"\r\n", streamPath, streamAddr);
cString buffer = cString::sprintf("GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: vdr-iptv\r\n"
"Range: bytes=0-\r\n"
"Connection: Close\r\n"
"\r\n", streamPath, streamAddr);
//debug("Sending http request: %s\n", buffer);
debug("Sending http request: %s\n", *buffer);
err = send(socketDesc, buffer, strlen(buffer), 0);
if (err < 0) {
char tmp[64];
error("ERROR: send(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
ERROR_IF_FUNC(err < 0, "send()", CloseSocket(), return false);
// Now process headers
if (!ProcessHeaders()) {
@@ -208,10 +114,10 @@ bool cIptvProtocolHttp::Disconnect(void)
debug("cIptvProtocolHttp::Disconnect()\n");
// Check that stream address is valid
if (isActive) {
// Close the socket
CloseSocket();
// Update active flag
isActive = false;
// Close the socket
CloseSocket();
// Update active flag
isActive = false;
}
return true;
}
@@ -229,22 +135,11 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
while (!newline || !linefeed) {
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
// Wait for data
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 500000;
// Use select
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(socketDesc, &rfds);
int retval = select(socketDesc + 1, &rfds, NULL, NULL, &tv);
// Wait 500ms for data
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
if (retval < 0)
return false;
}
// Check if data available
else if (retval) {
int retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT,
@@ -304,76 +199,51 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
return true;
}
int cIptvProtocolHttp::Read(unsigned char* *BufferAddr)
{
//debug("cIptvProtocolHttp::Read()\n");
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait for data
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 500000;
// Use select
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(socketDesc, &rfds);
int retval = select(socketDesc + 1, &rfds, NULL, NULL, &tv);
// Check if error
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return -1;
}
// Check if data available
else if (retval) {
// Read data from socket
return recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
}
return 0;
}
bool cIptvProtocolHttp::Open(void)
{
debug("cIptvProtocolHttp::Open(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolHttp::Open()\n");
// Connect the socket
return Connect();
}
bool cIptvProtocolHttp::Close(void)
{
debug("cIptvProtocolHttp::Close(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolHttp::Close()\n");
// Disconnect the current stream
Disconnect();
return true;
}
bool cIptvProtocolHttp::Set(const char* Address, const int Port)
int cIptvProtocolHttp::Read(unsigned char* *BufferAddr)
{
debug("cIptvProtocolHttp::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
// Disconnect the current socket
Disconnect();
// Update stream address, path and port
streamAddr = strcpyrealloc(streamAddr, Address);
char *path = strstr(streamAddr, "/");
if (path) {
streamPath = strcpyrealloc(streamPath, path);
*path = 0;
}
else
streamPath = strcpyrealloc(streamPath, "/");
streamPort = Port;
debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
// Re-connect the socket
Connect();
}
return cIptvTcpSocket::Read(BufferAddr);
}
bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int Index)
{
debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Disconnect the current socket
Disconnect();
// Update stream address, path and port
streamAddr = strcpyrealloc(streamAddr, Location);
char *path = strstr(streamAddr, "/");
if (path) {
streamPath = strcpyrealloc(streamPath, path);
*path = 0;
}
else
streamPath = strcpyrealloc(streamPath, "/");
socketPort = Parameter;
//debug("http://%s:%d%s\n", streamAddr, socketPort, streamPath);
// Re-connect the socket
Connect();
}
return true;
}
cString cIptvProtocolHttp::GetInformation(void)
{
//debug("cIptvProtocolHttp::GetInformation()");
return cString::sprintf("http://%s:%d%s", streamAddr, streamPort, streamPath);
return cString::sprintf("http://%s:%d%s", streamAddr, socketPort, streamPath);
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolhttp.h,v 1.7 2007/10/07 22:54:09 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLHTTP_H
@@ -11,21 +10,14 @@
#include <arpa/inet.h>
#include "protocolif.h"
#include "socket.h"
class cIptvProtocolHttp : public cIptvProtocolIf {
class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
private:
char* streamAddr;
char* streamPath;
int streamPort;
int socketDesc;
unsigned char* readBuffer;
unsigned int readBufferLen;
struct sockaddr_in sockAddr;
bool isActive;
private:
bool OpenSocket(const int Port);
void CloseSocket(void);
bool Connect(void);
bool Disconnect(void);
bool GetHeaderLine(char* dest, unsigned int destLen,
@@ -35,11 +27,11 @@ private:
public:
cIptvProtocolHttp();
virtual ~cIptvProtocolHttp();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
int Read(unsigned char* *BufferAddr);
bool Set(const char* Location, const int Parameter, const int Index);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLHTTP_H

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolif.h,v 1.5 2007/10/07 22:54:09 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLIF_H
@@ -14,14 +13,14 @@ public:
cIptvProtocolIf() {}
virtual ~cIptvProtocolIf() {}
virtual int Read(unsigned char* *BufferAddr) = 0;
virtual bool Set(const char* Address, const int Port) = 0;
virtual bool Set(const char* Location, const int Parameter, const int Index) = 0;
virtual bool Open(void) = 0;
virtual bool Close(void) = 0;
virtual cString GetInformation(void) = 0;
private:
cIptvProtocolIf(const cIptvProtocolIf&);
cIptvProtocolIf& operator=(const cIptvProtocolIf&);
cIptvProtocolIf(const cIptvProtocolIf&);
cIptvProtocolIf& operator=(const cIptvProtocolIf&);
};
#endif // __IPTV_PROTOCOLIF_H

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocoludp.c,v 1.11 2007/10/07 22:54:09 rahrenbe Exp $
*/
#include <sys/types.h>
@@ -17,91 +16,21 @@
#include "common.h"
#include "config.h"
#include "protocoludp.h"
#include "socket.h"
cIptvProtocolUdp::cIptvProtocolUdp()
: streamPort(1234),
socketDesc(-1),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
streamAddr = strdup("");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
error("ERROR: MALLOC() failed in ProtocolUdp()");
}
cIptvProtocolUdp::~cIptvProtocolUdp()
{
debug("cIptvProtocolUdp::~cIptvProtocolUdp()\n");
// Drop the multicast group and close the socket
Close();
cIptvProtocolUdp::Close();
// Free allocated memory
free(streamAddr);
free(readBuffer);
}
bool cIptvProtocolUdp::OpenSocket(const int Port)
{
debug("cIptvProtocolUdp::OpenSocket()\n");
// If socket is there already and it is bound to a different port, it must
// be closed first
if (Port != streamPort) {
debug("cIptvProtocolUdp::OpenSocket(): Socket tear-down\n");
CloseSocket();
}
// Bind to the socket if it is not active already
if (socketDesc < 0) {
int yes = 1;
// Create socket
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
if (socketDesc < 0) {
char tmp[64];
error("ERROR: socket(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return false;
}
// Make it use non-blocking I/O to avoid stuck read calls
if (fcntl(socketDesc, F_SETFL, O_NONBLOCK)) {
char tmp[64];
error("ERROR: fcntl(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Allow multiple sockets to use the same PORT number
if (setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0) {
char tmp[64];
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Bind socket
memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(Port);
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
if (err < 0) {
char tmp[64];
error("ERROR: bind(): %s", strerror_r(errno, tmp, sizeof(tmp)));
CloseSocket();
return false;
}
// Update stream port
streamPort = Port;
}
return true;
}
void cIptvProtocolUdp::CloseSocket(void)
{
debug("cIptvProtocolUdp::CloseSocket()\n");
// Check if socket exists
if (socketDesc >= 0) {
close(socketDesc);
socketDesc = -1;
}
}
bool cIptvProtocolUdp::JoinMulticast(void)
@@ -110,18 +39,14 @@ bool cIptvProtocolUdp::JoinMulticast(void)
// Check that stream address is valid
if (!isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(streamPort);
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));
if (err < 0) {
char tmp[64];
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return false;
}
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = true;
}
@@ -134,89 +59,23 @@ bool cIptvProtocolUdp::DropMulticast(void)
// Check that stream address is valid
if (isActive && !isempty(streamAddr)) {
// Ensure that socket is valid
OpenSocket(streamPort);
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));
if (err < 0) {
char tmp[64];
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return false;
}
ERROR_IF_RET(err < 0, "setsockopt()", return false);
// Update multicasting flag
isActive = false;
}
return true;
}
int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
{
//debug("cIptvProtocolUdp::Read()\n");
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait for data
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 500000;
// Use select
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(socketDesc, &rfds);
int retval = select(socketDesc + 1, &rfds, NULL, NULL, &tv);
// Check if error
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return -1;
}
// Check if data available
else if (retval) {
// Read data from socket
int len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
if ((len > 0) && (readBuffer[0] == 0x47)) {
// Set argument point to read buffer
*BufferAddr = &readBuffer[0];
return len;
}
else if (len > 3) {
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
// version
unsigned int v = (readBuffer[0] >> 6) & 0x03;
// extension bit
unsigned int x = (readBuffer[0] >> 4) & 0x01;
// cscr count
unsigned int cc = readBuffer[0] & 0x0F;
// payload type
unsigned int pt = readBuffer[1] & 0x7F;
// header lenght
unsigned int headerlen = (3 + cc) * sizeof(uint32_t);
// check if extension
if (x) {
// extension header length
unsigned int ehl = (((readBuffer[headerlen + 2] & 0xFF) << 8) | (readBuffer[headerlen + 3] & 0xFF));
// update header length
headerlen += (ehl + 1) * sizeof(uint32_t);
}
// Check that rtp is version 2, payload type is MPEG2 TS
// and payload contains multiple of TS packet data
if ((v == 2) && (pt == 33) && (((len - headerlen) % TS_SIZE) == 0)) {
// Set argument point to payload in read buffer
*BufferAddr = &readBuffer[headerlen];
return (len - headerlen);
}
}
}
return 0;
}
bool cIptvProtocolUdp::Open(void)
{
debug("cIptvProtocolUdp::Open(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolUdp::Open()\n");
// Join a new multicast group
JoinMulticast();
return true;
@@ -224,7 +83,7 @@ bool cIptvProtocolUdp::Open(void)
bool cIptvProtocolUdp::Close(void)
{
debug("cIptvProtocolUdp::Close(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolUdp::Close()\n");
// Drop the multicast group
DropMulticast();
// Close the socket
@@ -232,15 +91,20 @@ bool cIptvProtocolUdp::Close(void)
return true;
}
bool cIptvProtocolUdp::Set(const char* Address, const int Port)
int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
{
debug("cIptvProtocolUdp::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
return cIptvUdpSocket::Read(BufferAddr);
}
bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int Index)
{
debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index);
if (!isempty(Location)) {
// Drop the multicast group
DropMulticast();
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Address);
streamPort = Port;
streamAddr = strcpyrealloc(streamAddr, Location);
socketPort = Parameter;
// Join a new multicast group
JoinMulticast();
}
@@ -250,5 +114,5 @@ bool cIptvProtocolUdp::Set(const char* Address, const int Port)
cString cIptvProtocolUdp::GetInformation(void)
{
//debug("cIptvProtocolUdp::GetInformation()");
return cString::sprintf("udp://%s:%d", streamAddr, streamPort);
return cString::sprintf("udp://%s:%d", streamAddr, socketPort);
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocoludp.h,v 1.8 2007/10/07 22:54:09 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLUDP_H
@@ -11,31 +10,24 @@
#include <arpa/inet.h>
#include "protocolif.h"
#include "socket.h"
class cIptvProtocolUdp : public cIptvProtocolIf {
class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
private:
char* streamAddr;
int streamPort;
int socketDesc;
unsigned char* readBuffer;
unsigned int readBufferLen;
struct sockaddr_in sockAddr;
bool isActive;
private:
bool OpenSocket(const int Port);
void CloseSocket(void);
bool JoinMulticast(void);
bool DropMulticast(void);
public:
cIptvProtocolUdp();
virtual ~cIptvProtocolUdp();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);
int Read(unsigned char* *BufferAddr);
bool Set(const char* Location, const int Parameter, const int Index);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_PROTOCOLUDP_H

View File

@@ -3,13 +3,9 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.c,v 1.11 2007/10/08 16:24:48 rahrenbe Exp $
*/
#include "sectionfilter.h"
#include "statistics.h"
#define IPTV_FILTER_FILENAME "/tmp/vdr-iptv%d.filter%d"
cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
u_short Pid, u_char Tid, u_char Mask)
@@ -21,7 +17,8 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
seclen(0),
tsfeedp(0),
pid(Pid),
id(Index)
id(Index),
pipeName("")
{
//debug("cIptvSectionFilter::cIptvSectionFilter(%d)\n", Index);
memset(secbuf_base, '\0', sizeof(secbuf_base));
@@ -30,7 +27,6 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
memset(filter_mode, '\0', sizeof(filter_mode));
memset(maskandmode, '\0', sizeof(maskandmode));
memset(maskandnotmode, '\0', sizeof(maskandnotmode));
memset(pipeName, '\0', sizeof(pipeName));
SetPipeName(devInd);
@@ -38,17 +34,16 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
filter_mask[0] = Mask;
// Invert the filter
for (int i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
for (int i = 0; i < DMX_MAX_FILTER_SIZE; ++i)
filter_value[i] ^= 0xff;
}
uint8_t mask, mode, local_doneq = 0;
for (int i = 0; i < DMX_MAX_FILTER_SIZE; i++) {
mode = filter_mode[i];
mask = filter_mask[i];
maskandmode[i] = mask & mode;
local_doneq |= maskandnotmode[i] = mask & ~mode;
}
for (int i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
mode = filter_mode[i];
mask = filter_mask[i];
maskandmode[i] = mask & mode;
local_doneq |= maskandnotmode[i] = mask & ~mode;
}
doneq = local_doneq ? 1 : 0;
struct stat sb;
@@ -56,11 +51,7 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
if (S_ISFIFO(sb.st_mode))
unlink(pipeName);
int err = mknod(pipeName, 0644 | S_IFIFO, 0);
if (err < 0) {
char tmp[64];
error("ERROR: mknod(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return;
}
ERROR_IF_RET(err < 0, "mknod()", return);
// Create descriptors
fifoDescriptor = open(pipeName, O_RDWR | O_NONBLOCK);
@@ -73,14 +64,13 @@ cIptvSectionFilter::~cIptvSectionFilter()
close(fifoDescriptor);
close(readDescriptor);
unlink(pipeName);
memset(pipeName, '\0', sizeof(pipeName));
fifoDescriptor = -1;
readDescriptor = -1;
}
void cIptvSectionFilter::SetPipeName(int deviceIndex)
{
snprintf(pipeName, sizeof(pipeName), IPTV_FILTER_FILENAME, deviceIndex, id);
pipeName = cString::sprintf(IPTV_FILTER_FILENAME, deviceIndex, id);
}
int cIptvSectionFilter::GetReadDesc()
@@ -97,21 +87,10 @@ int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t b
const uint8_t *buffer2, size_t buffer2_len,
enum dmx_success success)
{
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(fifoDescriptor, &rfds);
int retval = select(fifoDescriptor + 1, &rfds, NULL, NULL, &tv);
// Check if error
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
}
// See if there is data in the fifo
int retval = select_single_desc(fifoDescriptor, 0, false);
// There is no data in the fifo, more can be written
else if (!retval) {
if (!retval) {
#ifdef DEBUG_PRINTF
printf("id = %d, pid %d would now write %d data to buffer\n", id, pid, buffer1_len);
for (unsigned int i = 0; i < buffer1_len; ++i)
@@ -119,12 +98,9 @@ int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t b
printf("\n");
#endif
retval = write(fifoDescriptor, buffer1, buffer1_len);
if (retval < 0) {
char tmp[64];
error("ERROR: write(): %s", strerror_r(errno, tmp, sizeof(tmp)));
}
ERROR_IF(retval < 0, "write()");
// Update statistics
AddStatistic(retval, 1);
AddSectionStatistic(retval, 1);
}
#ifdef DEBUG_PRINTF
else if (retval)
@@ -133,8 +109,6 @@ int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t b
return 0;
}
void cIptvSectionFilter::demux_swfilter_section_new()
{
#ifdef DEMUX_SECTION_LOSS_LOG
@@ -149,7 +123,7 @@ void cIptvSectionFilter::demux_swfilter_section_new()
printf("sectionfilter.c section ts padding loss: %d/%d\n",
n, tsfeedp);
printf("sectionfilter.c pad data:");
for (i = 0; i < n; i++)
for (i = 0; i < n; ++i)
printf(" %02x", secbuf[i]);
printf("\n");
}
@@ -164,7 +138,7 @@ int cIptvSectionFilter::demux_swfilter_sectionfilter()
uint8_t neq = 0;
int i;
for (i = 0; i < DMX_MAX_FILTER_SIZE; i++) {
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
uint8_t local_xor = filter_value[i] ^ secbuf[i];
if (maskandmode[i] & local_xor) {
#ifdef DEBUG_PRINTF
@@ -224,7 +198,7 @@ int cIptvSectionFilter::demux_swfilter_section_copy_dump(const uint8_t *buf, uin
/* to be sure always set secbuf */
secbuf = secbuf_base + secbufp;
for (n = 0; secbufp + 2 < limit; n++) {
for (n = 0; secbufp + 2 < limit; ++n) {
seclen_local = section_length(secbuf);
if (seclen_local <= 0 || seclen_local > DMX_MAX_SECTION_SIZE ||
seclen_local + secbufp > limit)
@@ -301,7 +275,7 @@ void cIptvSectionFilter::ProcessData(const uint8_t* buf)
const uint8_t *before = &buf[p + 1];
uint8_t before_len = buf[p];
const uint8_t *after = &before[before_len];
uint8_t after_len = count - 1 - before_len;
uint8_t after_len = (count - 1) - before_len;
demux_swfilter_section_copy_dump(before, before_len);
/* before start of new section, set pusi_seen = 1 */

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sectionfilter.h,v 1.7 2007/10/08 23:51:58 rahrenbe Exp $
*/
#ifndef __IPTV_SECTIONFILTER_H
@@ -65,7 +64,7 @@ private:
uint8_t maskandmode[DMX_MAX_FILTER_SIZE];
uint8_t maskandnotmode[DMX_MAX_FILTER_SIZE];
char pipeName[128];
cString pipeName;
inline uint16_t section_length(const uint8_t *buf);

266
setup.c
View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: setup.c,v 1.33 2007/10/14 18:51:21 rahrenbe Exp $
*/
#include <string.h>
@@ -11,6 +10,7 @@
#include <vdr/device.h>
#include <vdr/interface.h>
#include <vdr/status.h>
#include <vdr/menu.h>
#include "common.h"
#include "config.h"
@@ -30,17 +30,19 @@ private:
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolEXT,
eProtocolCount
};
struct tIptvChannel {
int frequency, source, protocol, port, vpid, ppid, tpid, sid, nid, tid, rid;
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 *Port, int *Protocol);
cString GetIptvSettings(const char *Param, int *Parameter, int *SidScan, int *PidScan, int *Protocol);
void GetChannelData(cChannel *Channel);
void SetChannelData(cChannel *Channel);
@@ -55,6 +57,7 @@ cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
protocols[eProtocolUDP] = tr("UDP");
protocols[eProtocolHTTP] = tr("HTTP");
protocols[eProtocolFILE] = tr("FILE");
protocols[eProtocolEXT] = tr("EXT");
channel = Channel;
GetChannelData(channel);
if (New) {
@@ -66,23 +69,52 @@ cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
Setup();
}
cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Port, int *Protocol)
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, "IPTV|UDP|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolUDP;
return addr;
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, "IPTV|HTTP|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolHTTP;
return addr;
}
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolFILE;
return addr;
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;
}
@@ -90,42 +122,48 @@ cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Port, int
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
{
if (Channel) {
int port, protocol;
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 >= 10700
data.vtype = Channel->Vtype();
#endif
data.tpid = Channel->Tpid();
for (unsigned int i = 0; i < sizeof(data.apid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
data.apid[i] = Channel->Apid(i);
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
data.dpid[i] = Channel->Dpid(i);
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
data.spid[i] = Channel->Spid(i);
for (unsigned int i = 0; i < sizeof(data.caids); ++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(), &port, &protocol), sizeof(data.location));
strn0cpy(data.location, *GetIptvSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol), sizeof(data.location));
data.sidscan = sidscan;
data.pidscan = pidscan;
data.protocol = protocol;
data.port = port;
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 < sizeof(data.apid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.apid); ++i)
data.apid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.dpid); ++i)
data.dpid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.spid); ++i)
data.spid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.caids); ++i)
for (unsigned int i = 0; i < ARRAY_SIZE(data.caids); ++i)
data.caids[i] = 0;
data.sid = 1;
data.nid = 0;
@@ -133,8 +171,10 @@ void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
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.port = 1234;
data.parameter = 1234;
}
}
@@ -144,20 +184,27 @@ void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
cString param;
char alangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char dlangs[MAXDPIDS][MAXLANGCODE2] = { "" };
char slangs[MAXSPIDS][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|FILE|%s|%d", data.location, data.port);
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|HTTP|%s|%d", data.location, data.port);
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|UDP|%s|%d", data.location, data.port);
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 >= 10700
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");
@@ -170,21 +217,31 @@ void cIptvMenuEditChannel::Setup(void)
int current = Current();
Clear();
// IPTV specific settings
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol, 3, protocols));
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol,
eProtocolCount, protocols));
switch (data.protocol) {
case eProtocolFILE:
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Delay (ms)"), &data.port, 0, 0xFFFF));
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), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Port"), &data.port, 0, 0xFFFF));
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), trVDR(FileNameChars)));
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));
Add(new cMenuEditIntItem(trVDR("Ppid"), &data.ppid, 0, 0x1FFF));
@@ -216,44 +273,44 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
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);
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;
// 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;
}
}
}
// 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);
@@ -278,18 +335,22 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
}
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, "/tmp/video.ts", sizeof(data.location));
data.port = 0;
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.port = 3000;
data.parameter = 3000;
break;
default:
case eProtocolUDP:
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.port = 1234;
data.parameter = 1234;
break;
}
Setup();
@@ -318,9 +379,7 @@ cIptvMenuChannelItem::cIptvMenuChannelItem(cChannel *Channel)
void cIptvMenuChannelItem::Set(void)
{
char *buffer = NULL;
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
SetText(buffer, false);
SetText(cString::sprintf("%d\t%s", channel->Number(), channel->Name()));
}
// --- cIptvMenuChannels -----------------------------------------------------
@@ -360,7 +419,7 @@ void cIptvMenuChannels::Setup(void)
{
Clear();
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() && channel->IsPlug() && !strncmp(channel->PluginParam(), "IPTV", 4)) {
if (!channel->GroupSep() && channel->IsPlug() && !strncasecmp(channel->PluginParam(), "IPTV", 4)) {
cIptvMenuChannelItem *item = new cIptvMenuChannelItem(channel);
Add(item);
}
@@ -495,8 +554,9 @@ public:
};
cIptvMenuInfo::cIptvMenuInfo()
:cOsdMenu(tr("IPTV Information")), text(""), timeout(INFO_TIMEOUT_MS), page(IPTV_DEVICE_INFO_GENERAL)
:cOsdMenu(tr("IPTV Information")), text(""), timeout(), page(IPTV_DEVICE_INFO_GENERAL)
{
timeout.Set(INFO_TIMEOUT_MS);
UpdateInfo();
SetHelp(tr("General"), tr("Pids"), tr("Filters"), tr("Bits/bytes"));
}
@@ -520,7 +580,7 @@ void cIptvMenuInfo::Display(void)
{
cOsdMenu::Display();
DisplayMenu()->SetText(text, true);
if (text)
if (*text)
cStatus::MsgOsdTextItem(text);
}
@@ -574,8 +634,8 @@ cIptvPluginSetup::cIptvPluginSetup()
debug("cIptvPluginSetup::cIptvPluginSetup()\n");
tsBufferSize = IptvConfig.GetTsBufferSize();
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
extProtocolBasePort = IptvConfig.GetExtProtocolBasePort();
sectionFiltering = IptvConfig.GetSectionFiltering();
sidScanning = IptvConfig.GetSidScanning();
numDisabledFilters = IptvConfig.GetDisabledFiltersCount();
if (numDisabledFilters > SECTION_FILTER_TABLE_SIZE)
numDisabledFilters = SECTION_FILTER_TABLE_SIZE;
@@ -590,18 +650,33 @@ cIptvPluginSetup::cIptvPluginSetup()
void cIptvPluginSetup::Setup(void)
{
int current = Current();
Clear();
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 1, 4));
help.Clear();
Add(new cMenuEditIntItem( tr("TS buffer size [MB]"), &tsBufferSize, 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."));
Add(new cMenuEditIntItem( tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFiltering));
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."));
Add(new cMenuEditIntItem( tr("EXT protocol base port"), &extProtocolBasePort, 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."));
Add(new cMenuEditBoolItem(tr("Use section filtering"), &sectionFiltering));
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."));
if (sectionFiltering) {
Add(new cMenuEditBoolItem(tr("Scan Sid automatically"), &sidScanning));
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFilters, 0, SECTION_FILTER_TABLE_SIZE));
Add(new cMenuEditIntItem( tr("Disable filters"), &numDisabledFilters, 0, SECTION_FILTER_TABLE_SIZE));
help.Append(tr("Define number of section filters to be disabled.\n\nCertain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By black-listing the filters here useful section data can be left intact for VDR to process."));
for (int i = 0; i < numDisabledFilters; ++i) {
// TRANSLATORS: note the singular!
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexes[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNames));
Add(new cMenuEditStraItem(tr("Disable filter"), &disabledFilterIndexes[i], SECTION_FILTER_TABLE_SIZE, disabledFilterNames));
help.Append(tr("Define an ill-behaving filter to be blacklisted."));
}
}
SetCurrent(Get(current));
Display();
}
@@ -627,18 +702,23 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
int oldsectionFiltering = sectionFiltering;
int oldNumDisabledFilters = numDisabledFilters;
eOSState state = cMenuSetupPage::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kRed: return EditChannel();
case kBlue: return ShowInfo();
case kInfo: if (Current() < help.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()]));
default: state = osContinue;
}
}
if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) {
while ((numDisabledFilters < oldNumDisabledFilters) && (oldNumDisabledFilters > 0))
disabledFilterIndexes[--oldNumDisabledFilters] = -1;
Setup();
}
return state;
}
@@ -666,14 +746,14 @@ void cIptvPluginSetup::Store(void)
// Store values into setup.conf
SetupStore("TsBufferSize", tsBufferSize);
SetupStore("TsBufferPrefill", tsBufferPrefill);
SetupStore("ExtProtocolBasePort", extProtocolBasePort);
SetupStore("SectionFiltering", sectionFiltering);
SetupStore("SidScanning", sidScanning);
StoreFilters("DisabledFilters", disabledFilterIndexes);
// Update global config
IptvConfig.SetTsBufferSize(tsBufferSize);
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
IptvConfig.SetExtProtocolBasePort(extProtocolBasePort);
IptvConfig.SetSectionFiltering(sectionFiltering);
IptvConfig.SetSidScanning(sidScanning);
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i)
IptvConfig.SetDisabledFilters(i, disabledFilterIndexes[i]);
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: setup.h,v 1.15 2007/10/09 16:37:16 rahrenbe Exp $
*/
#ifndef __IPTV_SETUP_H
@@ -17,11 +16,12 @@ class cIptvPluginSetup : public cMenuSetupPage
private:
int tsBufferSize;
int tsBufferPrefill;
int extProtocolBasePort;
int sectionFiltering;
int sidScanning;
int numDisabledFilters;
int disabledFilterIndexes[SECTION_FILTER_TABLE_SIZE];
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
cVector<const char*> help;
eOSState EditChannel(void);
eOSState ShowInfo(void);

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sidscanner.c,v 1.1 2007/10/01 18:14:57 rahrenbe Exp $
*/
#include <libsi/section.h>

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: sidscanner.h,v 1.1 2007/10/01 18:14:57 rahrenbe Exp $
*/
#ifndef __SIDSCANNER_H

207
socket.c Normal file
View File

@@ -0,0 +1,207 @@
/*
* socket.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <vdr/device.h>
#include "common.h"
#include "config.h"
#include "socket.h"
cIptvSocket::cIptvSocket()
: socketPort(0),
socketDesc(-1),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
{
debug("cIptvSocket::cIptvSocket()\n");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
if (!readBuffer)
error("ERROR: MALLOC() failed in socket()");
}
cIptvSocket::~cIptvSocket()
{
debug("cIptvSocket::~cIptvSocket()\n");
// Close the socket
CloseSocket();
// Free allocated memory
free(readBuffer);
}
bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
{
debug("cIptvSocket::OpenSocket()\n");
// If socket is there already and it is bound to a different port, it must
// be closed first
if (Port != socketPort) {
debug("cIptvSocket::OpenSocket(): Socket tear-down\n");
CloseSocket();
}
// Bind to the socket if it is not active already
if (socketDesc < 0) {
int yes = 1;
// Create socket
if (isUdp)
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
else
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
// Make it use non-blocking I/O to avoid stuck read calls
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
// Allow multiple sockets to use the same PORT number
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes,
sizeof(yes)) < 0, "setsockopt()", CloseSocket(), return false);
// Bind socket
memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(Port);
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdp) {
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
ERROR_IF_FUNC(err < 0, "bind()", CloseSocket(), return false);
}
// Update socket port
socketPort = Port;
}
return true;
}
void cIptvSocket::CloseSocket(void)
{
debug("cIptvSocket::CloseSocket()\n");
// Check if socket exists
if (socketDesc >= 0) {
close(socketDesc);
socketDesc = -1;
}
}
// UDP socket class
cIptvUdpSocket::cIptvUdpSocket()
{
debug("cIptvUdpSocket::cIptvUdpSocket()\n");
}
cIptvUdpSocket::~cIptvUdpSocket()
{
debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
}
bool cIptvUdpSocket::OpenSocket(const int Port)
{
debug("cIptvUdpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, true);
}
int cIptvUdpSocket::Read(unsigned char* *BufferAddr)
{
//debug("cIptvUdpSocket::Read()\n");
// Error out if socket not initialized
if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__);
return -1;
}
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait 500ms for data
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return retval;
// Check if data available
else if (retval) {
int len = 0;
// Read data from socket
if (isActive)
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
ERROR_IF_RET(len < 0, "recvfrom()", return len);
if ((len > 0) && (readBuffer[0] == 0x47)) {
// Set argument point to read buffer
*BufferAddr = &readBuffer[0];
return len;
}
else if (len > 3) {
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
// version
unsigned int v = (readBuffer[0] >> 6) & 0x03;
// extension bit
unsigned int x = (readBuffer[0] >> 4) & 0x01;
// cscr count
unsigned int cc = readBuffer[0] & 0x0F;
// payload type: MPEG2 TS = 33
//unsigned int pt = readBuffer[1] & 0x7F;
// header lenght
unsigned int headerlen = (3 + cc) * sizeof(uint32_t);
// check if extension
if (x) {
// extension header length
unsigned int ehl = (((readBuffer[headerlen + 2] & 0xFF) << 8) | (readBuffer[headerlen + 3] & 0xFF));
// update header length
headerlen += (ehl + 1) * sizeof(uint32_t);
}
// Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) && (readBuffer[headerlen] == 0x47)) {
// Set argument point to payload in read buffer
*BufferAddr = &readBuffer[headerlen];
return (len - headerlen);
}
}
}
return 0;
}
// TCP socket class
cIptvTcpSocket::cIptvTcpSocket()
{
debug("cIptvTcpSocket::cIptvTcpSocket()\n");
}
cIptvTcpSocket::~cIptvTcpSocket()
{
debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
}
bool cIptvTcpSocket::OpenSocket(const int Port)
{
debug("cIptvTcpSocket::OpenSocket()\n");
return cIptvSocket::OpenSocket(Port, false);
}
int cIptvTcpSocket::Read(unsigned char* *BufferAddr)
{
//debug("cIptvTcpSocket::Read()\n");
// Error out if socket not initialized
if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__);
return -1;
}
socklen_t addrlen = sizeof(sockAddr);
// Set argument point to read buffer
*BufferAddr = readBuffer;
// Wait 500ms for data
int retval = select_single_desc(socketDesc, 500000, false);
// Check if error
if (retval < 0)
return retval;
// Check if data available
else if (retval) {
// Read data from socket
if (isActive)
return recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen);
}
return 0;
}

48
socket.h Normal file
View File

@@ -0,0 +1,48 @@
/*
* protocoludp.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_SOCKET_H
#define __IPTV_SOCKET_H
#include <arpa/inet.h>
class cIptvSocket {
protected:
int socketPort;
int socketDesc;
unsigned char* readBuffer;
unsigned int readBufferLen;
struct sockaddr_in sockAddr;
bool isActive;
protected:
bool OpenSocket(const int Port, const bool isUdp);
void CloseSocket(void);
public:
cIptvSocket();
virtual ~cIptvSocket();
};
class cIptvUdpSocket : public cIptvSocket {
public:
cIptvUdpSocket();
virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
};
class cIptvTcpSocket : public cIptvSocket {
public:
cIptvTcpSocket();
virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* *BufferAddr);
bool OpenSocket(const int Port);
};
#endif // __IPTV_SOCKET_H

View File

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

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statistics.c,v 1.20 2007/10/11 23:06:49 rahrenbe Exp $
*/
#include <limits.h>
@@ -27,7 +26,7 @@ cIptvSectionStatistics::~cIptvSectionStatistics()
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
}
cString cIptvSectionStatistics::GetStatistic()
cString cIptvSectionStatistics::GetSectionStatistic()
{
//debug("cIptvSectionStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@@ -43,7 +42,7 @@ cString cIptvSectionStatistics::GetStatistic()
return info;
}
void cIptvSectionStatistics::AddStatistic(long Bytes, long Calls)
void cIptvSectionStatistics::AddSectionStatistic(long Bytes, long Calls)
{
//debug("cIptvSectionStatistics::AddStatistic(Bytes=%ld, Calls=%ld)\n", Bytes, Calls);
cMutexLock MutexLock(&mutex);
@@ -67,7 +66,7 @@ cIptvPidStatistics::~cIptvPidStatistics()
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
}
cString cIptvPidStatistics::GetStatistic()
cString cIptvPidStatistics::GetPidStatistic()
{
//debug("cIptvPidStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@@ -84,7 +83,7 @@ cString cIptvPidStatistics::GetStatistic()
IptvConfig.GetUseBytes() ? "B" : "bit");
}
}
memset(&mostActivePids, '\0', sizeof(mostActivePids));
memset(mostActivePids, '\0', sizeof(mostActivePids));
return info;
}
@@ -100,7 +99,7 @@ int cIptvPidStatistics::SortPids(const void* data1, const void* data2)
return 0;
}
void cIptvPidStatistics::AddStatistic(u_short Pid, long Payload)
void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload)
{
//debug("cIptvPidStatistics::AddStatistic(pid=%ld, payload=%ld)\n", Pid, Payload);
cMutexLock MutexLock(&mutex);
@@ -110,7 +109,7 @@ void cIptvPidStatistics::AddStatistic(u_short Pid, long Payload)
if (mostActivePids[i].pid == Pid) {
mostActivePids[i].DataAmount += Payload;
// Now re-sort the array and quit
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
return;
}
}
@@ -140,7 +139,7 @@ cIptvStreamerStatistics::~cIptvStreamerStatistics()
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
}
cString cIptvStreamerStatistics::GetStatistic()
cString cIptvStreamerStatistics::GetStreamerStatistic()
{
//debug("cIptvStreamerStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@@ -154,7 +153,7 @@ cString cIptvStreamerStatistics::GetStatistic()
return info;
}
void cIptvStreamerStatistics::AddStatistic(long Bytes)
void cIptvStreamerStatistics::AddStreamerStatistic(long Bytes)
{
//debug("cIptvStreamerStatistics::AddStatistic(Bytes=%ld)\n", Bytes);
cMutexLock MutexLock(&mutex);
@@ -177,7 +176,7 @@ cIptvBufferStatistics::~cIptvBufferStatistics()
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
}
cString cIptvBufferStatistics::GetStatistic()
cString cIptvBufferStatistics::GetBufferStatistic()
{
//debug("cIptvBufferStatistics::GetStatistic()\n");
cMutexLock MutexLock(&mutex);
@@ -201,7 +200,7 @@ cString cIptvBufferStatistics::GetStatistic()
return info;
}
void cIptvBufferStatistics::AddStatistic(long Bytes, long Used)
void cIptvBufferStatistics::AddBufferStatistic(long Bytes, long Used)
{
//debug("cIptvBufferStatistics::AddStatistic(Bytes=%ld, Used=%ld)\n", Bytes, Used);
cMutexLock MutexLock(&mutex);

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: statistics.h,v 1.10 2007/10/11 23:06:49 rahrenbe Exp $
*/
#ifndef __IPTV_STATISTICS_H
@@ -11,17 +10,15 @@
#include <vdr/thread.h>
#include "statisticif.h"
// Section statistics
class cIptvSectionStatistics : public cIptvStatisticIf {
class cIptvSectionStatistics {
public:
cIptvSectionStatistics();
virtual ~cIptvSectionStatistics();
cString GetStatistic();
cString GetSectionStatistic();
protected:
void AddStatistic(long Bytes, long Calls);
void AddSectionStatistic(long Bytes, long Calls);
private:
long filteredData;
@@ -31,14 +28,14 @@ private:
};
// Pid statistics
class cIptvPidStatistics : public cIptvStatisticIf {
class cIptvPidStatistics {
public:
cIptvPidStatistics();
virtual ~cIptvPidStatistics();
cString GetStatistic();
cString GetPidStatistic();
protected:
void AddStatistic(u_short Pid, long Payload);
void AddPidStatistic(u_short Pid, long Payload);
private:
struct pidStruct {
@@ -54,14 +51,14 @@ private:
};
// Streamer statistics
class cIptvStreamerStatistics : public cIptvStatisticIf {
class cIptvStreamerStatistics {
public:
cIptvStreamerStatistics();
virtual ~cIptvStreamerStatistics();
cString GetStatistic();
cString GetStreamerStatistic();
protected:
void AddStatistic(long Bytes);
void AddStreamerStatistic(long Bytes);
private:
long dataBytes;
@@ -70,14 +67,14 @@ private:
};
// Buffer statistics
class cIptvBufferStatistics : public cIptvStatisticIf {
class cIptvBufferStatistics {
public:
cIptvBufferStatistics();
virtual ~cIptvBufferStatistics();
cString GetStatistic();
cString GetBufferStatistic();
protected:
void AddStatistic(long Bytes, long Used);
void AddBufferStatistic(long Bytes, long Used);
private:
long dataBytes;

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.c,v 1.23 2007/10/11 23:06:49 rahrenbe Exp $
*/
#include <vdr/thread.h>
@@ -35,20 +34,22 @@ void cIptvStreamer::Action(void)
while (Running()) {
if (ringBuffer && mutex && protocol && ringBuffer->Free()) {
unsigned char *buffer = NULL;
mutex->Lock();
int length = protocol->Read(&buffer);
if (length >= 0) {
AddStatistic(length);
mutex->Lock();
AddStreamerStatistic(length);
int p = ringBuffer->Put(buffer, length);
if (p != length && Running())
ringBuffer->ReportOverflow(length - p);
mutex->Unlock();
}
else
cCondWait::SleepMs(100); // to reduce cpu load
else {
mutex->Unlock();
sleep.Wait(100); // to reduce cpu load
}
}
else
cCondWait::SleepMs(100); // and avoid busy loop
sleep.Wait(100); // and avoid busy loop
}
debug("cIptvStreamer::Action(): Exiting\n");
}
@@ -57,9 +58,8 @@ bool cIptvStreamer::Open(void)
{
debug("cIptvStreamer::Open()\n");
// Open the protocol
if (protocol)
if(!protocol->Open())
return false;
if (protocol && !protocol->Open())
return false;
// Start thread
Start();
return true;
@@ -69,18 +69,25 @@ bool cIptvStreamer::Close(void)
{
debug("cIptvStreamer::Close()\n");
// Stop thread
sleep.Signal();
if (Running())
Cancel(3);
// Close the protocol
// Close the protocol. A mutex should be taken here to avoid a race condition
// where thread Action() may be in the process of accessing the protocol.
// Taking a mutex serializes the Close() and Action() -calls.
if (mutex)
mutex->Lock();
if (protocol)
protocol->Close();
if (mutex)
mutex->Unlock();
return true;
}
bool cIptvStreamer::Set(const char* Address, const int Port, cIptvProtocolIf* Protocol)
bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol)
{
debug("cIptvStreamer::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter);
if (!isempty(Location)) {
// Update protocol; Close the existing one if changed
if (protocol != Protocol) {
if (protocol)
@@ -89,9 +96,9 @@ bool cIptvStreamer::Set(const char* Address, const int Port, cIptvProtocolIf* Pr
if (protocol)
protocol->Open();
}
// Set protocol address and port
// Set protocol location and parameter
if (protocol)
protocol->Set(Address, Port);
protocol->Set(Location, Parameter, Index);
}
return true;
}

View File

@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.h,v 1.11 2007/10/09 22:12:17 rahrenbe Exp $
*/
#ifndef __IPTV_STREAMER_H
@@ -21,6 +20,7 @@ class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
private:
cRingBufferLinear* ringBuffer;
cMutex* mutex;
cCondWait sleep;
unsigned char* readBuffer;
unsigned int readBufferLen;
cIptvProtocolIf* protocol;
@@ -29,11 +29,10 @@ public:
cIptvStreamer(cRingBufferLinear* RingBuffer, cMutex* Mutex);
virtual ~cIptvStreamer();
virtual void Action(void);
bool Set(const char* Address, const int Port, cIptvProtocolIf* Protocol);
bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol);
bool Open(void);
bool Close(void);
cString GetInformation(void);
};
#endif // __IPTV_STREAMER_H