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

Compare commits

...

23 Commits

Author SHA1 Message Date
Rolf Ahrenberg
cbd734fc0d Updated HISTORY. 2010-03-04 17:50:34 +02:00
Rolf Ahrenberg
517547dc15 Updated patches. 2010-02-01 13:57:26 +02:00
Rolf Ahrenberg
60a4d266b7 Updated patches.
Fixed argument corruption.
2010-01-06 19:02:40 +02:00
Rolf Ahrenberg
6901970b8a Updated patches. 2010-01-06 17:14:49 +02:00
Rolf Ahrenberg
d67f0d6ead Updated patches. 2009-11-22 18:23:08 +02:00
Rolf Ahrenberg
c0fc83cba6 Updated HISTORY. 2009-10-01 23:11:46 +03:00
Rolf Ahrenberg
49fcbc8921 Modified sectionfilters to use socket pair instead of filesystem fifos. 2009-10-01 18:48:28 +03:00
Rolf Ahrenberg
dbeb014a85 Updated patches. 2009-08-23 18:23:58 +03:00
Rolf Ahrenberg
26cd1aa1f1 Cleaned up compilation warnings. 2009-06-19 13:28:53 +03:00
Rolf Ahrenberg
a32cb95960 Fixed handling of HTTP protocol headers. 2009-06-17 16:07:58 +03:00
Rolf Ahrenberg
abfa46c064 Updated patches. 2009-06-17 15:15:38 +03:00
Rolf Ahrenberg
aa1bfab60d Updated HISTORY. 2009-06-01 11:17:18 +03:00
Rolf Ahrenberg
3ffba13a6c Updated patches for vdr-1.7.7. 2009-05-22 11:00:54 +03:00
Rolf Ahrenberg
57d63db034 Fixed setting parameters when protocol changes (Thanks to Peter Holik for reporting this one).
Updated example scripts to use ffmpeg's direct UDP output and added a new "image.sh" script (Thanks to Peter Holik).
2009-05-22 10:50:20 +03:00
Rolf Ahrenberg
2484c3bdd6 Updated patches for vdr-1.7.5. 2009-04-14 12:58:09 +03:00
Rolf Ahrenberg
912bf068ac Added iptvstream-notrap.sh script. 2009-03-31 08:17:24 +03:00
Rolf Ahrenberg
a8d01e32a1 Modified default compilation options. 2009-03-23 21:07:50 +02:00
Rolf Ahrenberg
d1c2d48a6b Fixed remaining lint warnings. 2009-03-21 00:56:37 +02:00
Rolf Ahrenberg
e74d4f88f4 Fixed again lint warnings. 2009-03-20 23:38:26 +02:00
Rolf Ahrenberg
55bf971e3e Fixed more lint warnings. 2009-03-20 18:00:17 +02:00
Rolf Ahrenberg
30abbc3e80 Fixed some lint warnings. 2009-03-20 17:43:31 +02:00
Rolf Ahrenberg
74761da04a Fixed a locking bug with section filters. 2009-03-17 17:37:05 +02:00
Rolf Ahrenberg
b221a9a406 Added a note about recommended frequencies into README. 2009-03-17 08:30:57 +02:00
33 changed files with 425 additions and 211 deletions

27
HISTORY
View File

@@ -94,3 +94,30 @@ VDR Plugin 'iptv' Revision History
- Fixed pid scanner to set the existing video stream type - Fixed pid scanner to set the existing video stream type
(Thanks to ua0lnj for reporting this one). (Thanks to ua0lnj for reporting this one).
- Added optional patches to disable CA updates. - Added optional patches to disable CA updates.
2009-03-22: Version 0.2.6
- Added a note about recommended frequencies into README.
- Fixed a locking bug with section filters.
- Fixed some lint warnings.
2009-06-01: Version 0.3.0
- Added iptvstream-notrap.sh script.
- Fixed setting parameters when protocol changes
(Thanks to Peter Holik for reporting this one).
- Updated example scripts to use ffmpeg's direct UDP output
and added a new "image.sh" script (Thanks to Peter Holik).
2009-10-01: Version 0.3.1
- Updated patches.
- Added optional patches to disable EIT scanning.
- Fixed handling of HTTP protocol headers.
- Modified sectionfilters to use socket pair instead of
filesystem fifos.
2010-03-05: Version 0.3.2
- Updated patches.
- Fixed argument corruption.

View File

@@ -23,7 +23,7 @@ VERSION = $(shell grep 'static const char VERSION\[\] *=' $(PLUGIN).c | awk '{ p
### The C++ compiler and options: ### The C++ compiler and options:
CXX ?= g++ CXX ?= g++
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -Wswitch-default -Wfloat-equal -Wundef -Wpointer-arith -Wconversion -Wcast-align -Wredundant-decls -Wno-unused-parameter -Woverloaded-virtual -Wno-parentheses
### The directory environment: ### The directory environment:

16
README
View File

@@ -111,10 +111,10 @@ Configuration:
- channels.conf - channels.conf
TV4;IPTV:4:IPTV|S1P0|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0 TV4;IPTV:40: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 TV3;IPTV:30: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 TV2;IPTV:20: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 TV1;IPTV:10:IPTV|S1P0|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | Source type ("P") | | | | | | Source type ("P")
| | | | | IP Port Number, File delay (ms), Script parameter | | | | | IP Port Number, File delay (ms), Script parameter
@@ -167,6 +167,14 @@ Notes:
startup. If the fifo is found and succesfully opened, the device writes 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. the current data stream into it. This can be used for debugging purposes.
- Multiple channels with identical service id should have frequency
difference of 4 or greater. It's recommended to use frequencies in decades
(10, 20, 30, 40, ...) for all IPTV channel entries.
- VLC processes won't get killed on some setups with the provided iptvstream.sh
script and the iptvstream-notrap.sh script should be used instead in these
cases.
Acknowledgements: Acknowledgements:
- The IPTV section filtering code is derived from Linux kernel. - The IPTV section filtering code is derived from Linux kernel.

View File

@@ -10,7 +10,7 @@
uint16_t ts_pid(const uint8_t *buf) uint16_t ts_pid(const uint8_t *buf)
{ {
return ((buf[1] & 0x1f) << 8) + buf[2]; return (uint16_t)(((buf[1] & 0x1f) << 8) + buf[2]);
} }
uint8_t payload(const uint8_t *tsp) uint8_t payload(const uint8_t *tsp)
@@ -22,7 +22,7 @@ uint8_t payload(const uint8_t *tsp)
if (tsp[4] > 183) // corrupted data? if (tsp[4] > 183) // corrupted data?
return 0; return 0;
else else
return (184 - 1) - tsp[4]; return (uint8_t)((184 - 1) - tsp[4]);
} }
return 184; return 184;

View File

@@ -14,10 +14,10 @@
#ifdef DEBUG #ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x); #define debug(x...) dsyslog("IPTV: " x);
#define error(x...) esyslog("IPTV: " x); #define error(x...) esyslog("ERROR: " x);
#else #else
#define debug(x...) ; #define debug(x...) ;
#define error(x...) esyslog("IPTV: " x); #define error(x...) esyslog("ERROR: " x);
#endif #endif
#ifndef trNOOP #ifndef trNOOP
@@ -28,7 +28,6 @@
#define trVDR(s) tr(s) #define trVDR(s) tr(s)
#endif #endif
#define IPTV_FILTER_FILENAME "/tmp/vdr-iptv%d.filter%d"
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr" #define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
#define IPTV_DEVICE_INFO_ALL 0 #define IPTV_DEVICE_INFO_ALL 0
@@ -41,13 +40,11 @@
#define SECTION_FILTER_TABLE_SIZE 7 #define SECTION_FILTER_TABLE_SIZE 7
#define TS_SYNC_BYTE 0x47
#define ERROR_IF_FUNC(exp, errstr, func, ret) \ #define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \ do { \
if (exp) { \ if (exp) { \
char tmp[64]; \ char tmp[64]; \
error("ERROR: "errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \ error(errstr": %s", strerror_r(errno, tmp, sizeof(tmp))); \
func; \ func; \
ret; \ ret; \
} \ } \

View File

@@ -24,7 +24,7 @@ cIptvConfig::cIptvConfig(void)
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
{ {
unsigned int n = 0; unsigned int n = 0;
while ((disabledFilters[n] != -1) && (n < ARRAY_SIZE(disabledFilters))) while ((n < ARRAY_SIZE(disabledFilters) && (disabledFilters[n] != -1)))
n++; n++;
return n; return n;
} }

View File

@@ -10,7 +10,7 @@
#define IPTV_MAX_DEVICES MAXDEVICES #define IPTV_MAX_DEVICES MAXDEVICES
cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL }; static cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL };
unsigned int cIptvDevice::deviceCount = 0; unsigned int cIptvDevice::deviceCount = 0;
@@ -272,7 +272,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex); debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
location = GetChannelSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol); location = GetChannelSettings(Channel->PluginParam(), &parameter, &sidscan, &pidscan, &protocol);
if (isempty(location)) { if (isempty(location)) {
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam()); error("Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false; return false;
} }
sidScanEnabled = sidscan ? true : false; sidScanEnabled = sidscan ? true : false;
@@ -304,7 +304,7 @@ bool cIptvDevice::DeleteFilter(unsigned int Index)
return false; return false;
} }
bool cIptvDevice::IsBlackListed(u_short Pid, u_char Tid, u_char Mask) bool cIptvDevice::IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const
{ {
//debug("cIptvDevice::IsBlackListed(%d) Pid=%d Tid=%02X Mask=%02X\n", deviceIndex, Pid, Tid, Mask); //debug("cIptvDevice::IsBlackListed(%d) Pid=%d Tid=%02X Mask=%02X\n", deviceIndex, Pid, Tid, Mask);
// loop through section filter table // loop through section filter table
@@ -329,6 +329,8 @@ int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
// Blacklist check, refuse certain filters // Blacklist check, refuse certain filters
if (IsBlackListed(Pid, Tid, Mask)) if (IsBlackListed(Pid, Tid, Mask))
return -1; return -1;
// Lock
cMutexLock MutexLock(&mutex);
// Search the next free filter slot // Search the next free filter slot
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!secfilters[i]) { if (!secfilters[i]) {
@@ -343,6 +345,9 @@ int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
void cIptvDevice::CloseFilter(int Handle) void cIptvDevice::CloseFilter(int Handle)
{ {
// Lock
cMutexLock MutexLock(&mutex);
// Search the filter for deletion
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) { if (secfilters[i] && (Handle == secfilters[i]->GetReadDesc())) {
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle); //debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndex, Handle);
@@ -361,7 +366,7 @@ bool cIptvDevice::OpenDvr(void)
if (pIptvStreamer) if (pIptvStreamer)
pIptvStreamer->Open(); pIptvStreamer->Open();
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering()) if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetStatus(true); pSidScanner->Open();
isOpenDvr = true; isOpenDvr = true;
return true; return true;
} }
@@ -370,7 +375,7 @@ void cIptvDevice::CloseDvr(void)
{ {
debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex); debug("cIptvDevice::CloseDvr(%d)\n", deviceIndex);
if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering()) if (sidScanEnabled && pSidScanner && IptvConfig.GetSectionFiltering())
pSidScanner->SetStatus(false); pSidScanner->Close();
if (pIptvStreamer) if (pIptvStreamer)
pIptvStreamer->Close(); pIptvStreamer->Close();
isOpenDvr = false; isOpenDvr = false;
@@ -422,7 +427,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
} }
} }
tsBuffer->Del(Count); tsBuffer->Del(Count);
error("ERROR: skipped %d bytes to sync on TS packet\n", Count); error("Skipped %d bytes to sync on TS packet\n", Count);
return false; return false;
} }
isPacketDelivered = true; isPacketDelivered = true;
@@ -431,10 +436,12 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
AddPidStatistic(ts_pid(p), payload(p)); AddPidStatistic(ts_pid(p), payload(p));
// Send data also to dvr fifo // Send data also to dvr fifo
if (dvrFd >= 0) if (dvrFd >= 0)
Count = write(dvrFd, p, TS_SIZE); Count = (int)write(dvrFd, p, TS_SIZE);
// Analyze incomplete streams with built-in pid analyzer // Analyze incomplete streams with built-in pid analyzer
if (pidScanEnabled && pPidScanner) if (pidScanEnabled && pPidScanner)
pPidScanner->Process(p); pPidScanner->Process(p);
// Lock
cMutexLock MutexLock(&mutex);
// Run the data through all filters // Run the data through all filters
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (secfilters[i]) if (secfilters[i])

View File

@@ -74,7 +74,7 @@ private:
void ResetBuffering(void); void ResetBuffering(void);
bool IsBuffering(void); bool IsBuffering(void);
bool DeleteFilter(unsigned int Index); bool DeleteFilter(unsigned int Index);
bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask); bool IsBlackListed(u_short Pid, u_char Tid, u_char Mask) const;
// for channel selection // for channel selection
public: public:

4
iptv.c
View File

@@ -20,7 +20,7 @@
#error "VDR-1.6.0 API version or greater is required!" #error "VDR-1.6.0 API version or greater is required!"
#endif #endif
static const char VERSION[] = "0.2.5"; static const char VERSION[] = "0.3.2";
static const char DESCRIPTION[] = trNOOP("Experience the IPTV"); static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin { class cPluginIptv : public cPlugin {
@@ -78,7 +78,7 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
// Implement command line argument processing here if applicable. // Implement command line argument processing here if applicable.
static const struct option long_options[] = { static const struct option long_options[] = {
{ "devices", required_argument, NULL, 'd' }, { "devices", required_argument, NULL, 'd' },
{ NULL } { NULL, no_argument, NULL, 0 }
}; };
int c; int c;

84
iptv/image.sh Executable file
View File

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

View File

@@ -61,7 +61,7 @@ ffmpeg -v -1 \
-i "${FIFO}" \ -i "${FIFO}" \
-title "${TITLE}" \ -title "${TITLE}" \
-f mpegts -acodec mp2 -ac 2 -ab 96k -ar 48000 \ -f mpegts -acodec mp2 -ac 2 -ab 96k -ar 48000 \
- | nc -u 127.0.0.1 ${PORT} "udp://127.0.0.1:${PORT}?pkt_size=16356"
rm -f "${FIFO}" rm -f "${FIFO}"
} > ${LOG} 2>&1 } > ${LOG} 2>&1

76
iptv/iptvstream-notrap.sh Executable file
View File

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

View File

@@ -50,5 +50,5 @@ ffmpeg -v -1 \
-i - \ -i - \
-title "${TITLE}" \ -title "${TITLE}" \
-f mpegts -acodec mp2 -ac 2 -ab 128k -ar 48000 \ -f mpegts -acodec mp2 -ac 2 -ab 128k -ar 48000 \
- | nc -nu 127.0.0.1 ${PORT} "udp://127.0.0.1:${PORT}?pkt_size=16356"
} > ${LOG} 2>&1 } > ${LOG} 2>&1

View File

@@ -63,7 +63,7 @@ ffmpeg -v -1 \
-title "${TITLE}" \ -title "${TITLE}" \
-f mpegts -intra -r 24 -vcodec mpeg2video -b 500k -s 352x288 \ -f mpegts -intra -r 24 -vcodec mpeg2video -b 500k -s 352x288 \
-acodec mp2 -ac 2 -ab 96k -ar 48000 \ -acodec mp2 -ac 2 -ab 96k -ar 48000 \
- | nc -u 127.0.0.1 ${PORT} "udp://127.0.0.1:${PORT}?pkt_size=16356"
rm -f "${FIFO}" rm -f "${FIFO}"
} > ${LOG} 2>&1 } > ${LOG} 2>&1

View File

@@ -0,0 +1,12 @@
diff -Nru vdr-1.6.0-vanilla/eitscan.c vdr-1.6.0-disable_eitscan/eitscan.c
--- vdr-1.6.0-vanilla/eitscan.c 2006-01-07 16:10:17.000000000 +0200
+++ vdr-1.6.0-disable_eitscan/eitscan.c 2009-06-17 16:04:23.000000000 +0300
@@ -146,7 +146,7 @@
if (Device) {
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
const cChannel *Channel = ScanData->GetChannel();
- if (Channel) {
+ if (Channel && !Channel->IsPlug()) {
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
if (Device->ProvidesTransponder(Channel)) {
if (!Device->Receiving()) {

View File

@@ -0,0 +1,11 @@
diff -Nru vdr-1.7.12-vanilla/pat.c vdr-1.7.12-disable_ca_updates/pat.c
--- vdr-1.7.12-vanilla/pat.c 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.12-disable_ca_updates/pat.c 2010-02-01 13:54:32.000000000 +0200
@@ -458,6 +458,7 @@
}
if (Setup.UpdateChannels >= 2) {
Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
+ if (!Channel->IsPlug())
Channel->SetCaIds(CaDescriptors->CaIds());
Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
}

View File

@@ -0,0 +1,12 @@
diff -Nru vdr-1.7.12-vanilla/eitscan.c vdr-1.7.12-disable_eitscan/eitscan.c
--- vdr-1.7.12-vanilla/eitscan.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.12-disable_eitscan/eitscan.c 2010-02-01 13:54:20.000000000 +0200
@@ -146,7 +146,7 @@
if (Device) {
for (cScanData *ScanData = scanList->First(); ScanData; ScanData = scanList->Next(ScanData)) {
const cChannel *Channel = ScanData->GetChannel();
- if (Channel) {
+ if (Channel && !Channel->IsPlug()) {
if (!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= CA_ENCRYPTED_MIN) {
if (Device->ProvidesTransponder(Channel)) {
if (!Device->Receiving()) {

View File

@@ -1,6 +1,6 @@
diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c diff -Nru vdr-1.7.12-vanilla/channels.c vdr-1.7.12-pluginparam/channels.c
--- vdr-1.7.4-vanilla/channels.c 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/channels.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/channels.c 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/channels.c 2010-02-01 13:52:56.000000000 +0200
@@ -188,6 +188,7 @@ @@ -188,6 +188,7 @@
shortName = strdup(""); shortName = strdup("");
provider = strdup(""); provider = strdup("");
@@ -33,7 +33,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__); memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
return *this; return *this;
} }
@@ -306,9 +310,26 @@ @@ -307,9 +311,26 @@
guard = Channel->guard; guard = Channel->guard;
hierarchy = Channel->hierarchy; hierarchy = Channel->hierarchy;
rollOff = Channel->rollOff; rollOff = Channel->rollOff;
@@ -60,7 +60,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff) bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff)
{ {
// Workarounds for broadcaster stupidity: // Workarounds for broadcaster stupidity:
@@ -438,6 +459,18 @@ @@ -439,6 +460,18 @@
} }
} }
@@ -79,7 +79,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
#define STRDIFF 0x01 #define STRDIFF 0x01
#define VALDIFF 0x02 #define VALDIFF 0x02
@@ -632,7 +665,7 @@ @@ -652,7 +685,7 @@
if (isdigit(type)) if (isdigit(type))
type = 'S'; type = 'S';
#define ST(s) if (strchr(s, type)) #define ST(s) if (strchr(s, type))
@@ -88,7 +88,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
char *q = buffer; char *q = buffer;
*q = 0; *q = 0;
ST(" S ") q += sprintf(q, "%c", polarization); ST(" S ") q += sprintf(q, "%c", polarization);
@@ -646,6 +679,7 @@ @@ -666,6 +699,7 @@
ST(" S ") q += PrintParameter(q, 'S', MapToUser(system, SystemValues)); ST(" S ") q += PrintParameter(q, 'S', MapToUser(system, SystemValues));
ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues)); ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues)); ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
@@ -96,7 +96,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
return buffer; return buffer;
} }
@@ -674,7 +708,7 @@ @@ -694,7 +728,7 @@
bool cChannel::StringToParameters(const char *s) bool cChannel::StringToParameters(const char *s)
{ {
@@ -105,7 +105,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
switch (toupper(*s)) { switch (toupper(*s)) {
case 'A': s = SkipDigits(s); break; // for compatibility with the "multiproto" approach - may be removed in future versions 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; case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
@@ -792,7 +826,7 @@ @@ -814,7 +848,7 @@
dpids[0] = 0; dpids[0] = 0;
ok = false; ok = false;
if (parambuf && sourcebuf && vpidbuf && apidbuf) { if (parambuf && sourcebuf && vpidbuf && apidbuf) {
@@ -114,7 +114,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
char *p; char *p;
if ((p = strchr(vpidbuf, '=')) != NULL) { if ((p = strchr(vpidbuf, '=')) != NULL) {
@@ -887,6 +921,7 @@ @@ -911,6 +945,7 @@
shortName = strcpyrealloc(shortName, p); shortName = strcpyrealloc(shortName, p);
} }
name = strcpyrealloc(name, namebuf); name = strcpyrealloc(name, namebuf);
@@ -122,9 +122,9 @@ diff -Nru vdr-1.7.4-vanilla/channels.c vdr-1.7.4-pluginparam/channels.c
free(parambuf); free(parambuf);
free(sourcebuf); free(sourcebuf);
diff -Nru vdr-1.7.4-vanilla/channels.h vdr-1.7.4-pluginparam/channels.h diff -Nru vdr-1.7.12-vanilla/channels.h vdr-1.7.12-pluginparam/channels.h
--- vdr-1.7.4-vanilla/channels.h 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/channels.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/channels.h 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/channels.h 2010-02-01 13:52:56.000000000 +0200
@@ -116,6 +116,7 @@ @@ -116,6 +116,7 @@
char *shortName; char *shortName;
char *provider; char *provider;
@@ -133,7 +133,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.h vdr-1.7.4-pluginparam/channels.h
int __BeginData__; int __BeginData__;
int frequency; // MHz int frequency; // MHz
int source; int source;
@@ -171,6 +172,7 @@ @@ -174,6 +175,7 @@
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf' 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 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 static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
@@ -141,7 +141,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.h vdr-1.7.4-pluginparam/channels.h
int Source(void) const { return source; } int Source(void) const { return source; }
int Srate(void) const { return srate; } int Srate(void) const { return srate; }
int Vpid(void) const { return vpid; } int Vpid(void) const { return vpid; }
@@ -208,6 +210,7 @@ @@ -214,6 +216,7 @@
int RollOff(void) const { return rollOff; } int RollOff(void) const { return rollOff; }
const cLinkChannels* LinkChannels(void) const { return linkChannels; } const cLinkChannels* LinkChannels(void) const { return linkChannels; }
const cChannel *RefChannel(void) const { return refChannel; } const cChannel *RefChannel(void) const { return refChannel; }
@@ -149,7 +149,7 @@ diff -Nru vdr-1.7.4-vanilla/channels.h vdr-1.7.4-pluginparam/channels.h
bool IsCable(void) const { return cSource::IsCable(source); } bool IsCable(void) const { return cSource::IsCable(source); }
bool IsSat(void) const { return cSource::IsSat(source); } bool IsSat(void) const { return cSource::IsSat(source); }
bool IsTerr(void) const { return cSource::IsTerr(source); } bool IsTerr(void) const { return cSource::IsTerr(source); }
@@ -215,12 +218,14 @@ @@ -221,12 +224,14 @@
bool HasTimer(void) const; bool HasTimer(void) const;
int Modification(int Mask = CHANNELMOD_ALL); int Modification(int Mask = CHANNELMOD_ALL);
void CopyTransponderData(const cChannel *Channel); void CopyTransponderData(const cChannel *Channel);
@@ -164,21 +164,21 @@ diff -Nru vdr-1.7.4-vanilla/channels.h vdr-1.7.4-pluginparam/channels.h
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 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 SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level); void SetCaDescriptors(int Level);
diff -Nru vdr-1.7.4-vanilla/config.h vdr-1.7.4-pluginparam/config.h diff -Nru vdr-1.7.12-vanilla/config.h vdr-1.7.12-pluginparam/config.h
--- vdr-1.7.4-vanilla/config.h 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/config.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/config.h 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/config.h 2010-02-01 13:52:56.000000000 +0200
@@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
#define APIVERSION "1.7.4" #define APIVERSION "1.7.12"
#define APIVERSNUM 10704 // Version * 10000 + Major * 100 + Minor #define APIVERSNUM 10712 // Version * 10000 + Major * 100 + Minor
+#define PLUGINPARAMPATCHVERSNUM 1 +#define PLUGINPARAMPATCHVERSNUM 1
+ +
// When loading plugins, VDR searches them by their APIVERSION, which // When loading plugins, VDR searches them by their APIVERSION, which
// may be smaller than VDRVERSION in case there have been no changes to // may be smaller than VDRVERSION in case there have been no changes to
// VDR header files since the last APIVERSION. This allows compiled // VDR header files since the last APIVERSION. This allows compiled
diff -Nru vdr-1.7.4-vanilla/menu.c vdr-1.7.4-pluginparam/menu.c diff -Nru vdr-1.7.12-vanilla/menu.c vdr-1.7.12-pluginparam/menu.c
--- vdr-1.7.4-vanilla/menu.c 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/menu.c 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/menu.c 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/menu.c 2010-02-01 13:52:56.000000000 +0200
@@ -190,6 +190,7 @@ @@ -190,6 +190,7 @@
cChannel *channel; cChannel *channel;
cChannel data; cChannel data;
@@ -211,29 +211,29 @@ diff -Nru vdr-1.7.4-vanilla/menu.c vdr-1.7.4-pluginparam/menu.c
if (channel) { if (channel) {
*channel = data; *channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText()); isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.7.4-vanilla/po/fi_FI.po vdr-1.7.4-pluginparam/po/fi_FI.po diff -Nru vdr-1.7.12-vanilla/po/fi_FI.po vdr-1.7.12-pluginparam/po/fi_FI.po
--- vdr-1.7.4-vanilla/po/fi_FI.po 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/po/fi_FI.po 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.4-pluginparam/po/fi_FI.po 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/po/fi_FI.po 2010-02-01 13:52:56.000000000 +0200
@@ -1010,3 +1010,6 @@ @@ -1306,3 +1306,6 @@
#, c-format #, c-format
msgid "VDR will shut down in %s minutes" msgid "VDR will shut down in %s minutes"
msgstr "VDR sammuu %s minuutin kuluttua" msgstr "VDR sammuu %s minuutin kuluttua"
+ +
+msgid "Parameters" +msgid "Parameters"
+msgstr "Parametrit" +msgstr "Parametrit"
diff -Nru vdr-1.7.4-vanilla/po/fr_FR.po vdr-1.7.4-pluginparam/po/fr_FR.po diff -Nru vdr-1.7.12-vanilla/po/fr_FR.po vdr-1.7.12-pluginparam/po/fr_FR.po
--- vdr-1.7.4-vanilla/po/fr_FR.po 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/po/fr_FR.po 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.4-pluginparam/po/fr_FR.po 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/po/fr_FR.po 2010-02-01 13:52:56.000000000 +0200
@@ -1013,3 +1013,6 @@ @@ -1309,3 +1309,6 @@
#, c-format #, c-format
msgid "VDR will shut down in %s minutes" msgid "VDR will shut down in %s minutes"
msgstr "VDR s'arrêtera dans %s minutes" msgstr "VDR s'arrêtera dans %s minutes"
+ +
+msgid "Parameters" +msgid "Parameters"
+msgstr "Paramètres" +msgstr "Paramètres"
diff -Nru vdr-1.7.4-vanilla/sources.c vdr-1.7.4-pluginparam/sources.c diff -Nru vdr-1.7.12-vanilla/sources.c vdr-1.7.12-pluginparam/sources.c
--- vdr-1.7.4-vanilla/sources.c 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/sources.c 2010-02-01 11:45:40.000000000 +0200
+++ vdr-1.7.4-pluginparam/sources.c 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/sources.c 2010-02-01 13:52:56.000000000 +0200
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
char buffer[16]; char buffer[16];
char *q = buffer; char *q = buffer;
@@ -250,10 +250,10 @@ diff -Nru vdr-1.7.4-vanilla/sources.c vdr-1.7.4-pluginparam/sources.c
case 'C': type = stCable; break; case 'C': type = stCable; break;
case 'S': type = stSat; break; case 'S': type = stSat; break;
case 'T': type = stTerr; break; case 'T': type = stTerr; break;
diff -Nru vdr-1.7.4-vanilla/sources.conf vdr-1.7.4-pluginparam/sources.conf diff -Nru vdr-1.7.12-vanilla/sources.conf vdr-1.7.12-pluginparam/sources.conf
--- vdr-1.7.4-vanilla/sources.conf 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/sources.conf 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/sources.conf 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/sources.conf 2010-02-01 13:52:56.000000000 +0200
@@ -194,3 +194,7 @@ @@ -195,3 +195,7 @@
# Terrestrial # Terrestrial
T Terrestrial T Terrestrial
@@ -261,9 +261,9 @@ diff -Nru vdr-1.7.4-vanilla/sources.conf vdr-1.7.4-pluginparam/sources.conf
+# Plugin +# Plugin
+ +
+P Plugin +P Plugin
diff -Nru vdr-1.7.4-vanilla/sources.h vdr-1.7.4-pluginparam/sources.h diff -Nru vdr-1.7.12-vanilla/sources.h vdr-1.7.12-pluginparam/sources.h
--- vdr-1.7.4-vanilla/sources.h 2009-01-26 11:44:48.000000000 +0200 --- vdr-1.7.12-vanilla/sources.h 2010-02-01 11:45:39.000000000 +0200
+++ vdr-1.7.4-pluginparam/sources.h 2009-02-24 13:31:33.000000000 +0200 +++ vdr-1.7.12-pluginparam/sources.h 2010-02-01 13:52:56.000000000 +0200
@@ -16,10 +16,11 @@ @@ -16,10 +16,11 @@
public: public:
enum eSourceType { enum eSourceType {

View File

@@ -1,11 +0,0 @@
diff -Nru vdr-1.7.4-vanilla/pat.c vdr-1.7.4-disable-ca-updates/pat.c
--- vdr-1.7.4-vanilla/pat.c 2008-07-06 17:01:32.000000000 +0300
+++ vdr-1.7.4-disable-ca-updates/pat.c 2009-03-07 14:54:12.000000000 +0200
@@ -444,6 +444,7 @@
}
if (Setup.UpdateChannels >= 2) {
Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
+ if (!Channel->IsPlug())
Channel->SetCaIds(CaDescriptors->CaIds());
}
Channel->SetCaDescriptors(CaDescriptorHandler.AddCaDescriptors(CaDescriptors));

View File

@@ -39,7 +39,7 @@ void cIptvProtocolExt::ExecuteScript(void)
debug("cIptvProtocolExt::ExecuteScript()\n"); debug("cIptvProtocolExt::ExecuteScript()\n");
// Check if already executing // Check if already executing
if (pid > 0) { if (pid > 0) {
error("ERROR: Cannot execute script!"); error("Cannot execute script!");
return; return;
} }
// Let's fork // Let's fork
@@ -54,7 +54,7 @@ void cIptvProtocolExt::ExecuteScript(void)
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort); cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort);
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd); debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
if (execl("/bin/sh", "sh", "-c", *cmd, NULL) == -1) { if (execl("/bin/sh", "sh", "-c", *cmd, NULL) == -1) {
error("ERROR: Script execution failed: %s", *cmd); error("Script execution failed: %s", *cmd);
_exit(-1); _exit(-1);
} }
_exit(0); _exit(0);
@@ -79,7 +79,7 @@ void cIptvProtocolExt::TerminateScript(void)
retval = 0; retval = 0;
waitms += timeoutms; waitms += timeoutms;
if ((waitms % 2000) == 0) { if ((waitms % 2000) == 0) {
error("ERROR: Script '%s' won't terminate - killing it!", *scriptFile); error("Script '%s' won't terminate - killing it!", *scriptFile);
kill(pid, SIGKILL); kill(pid, SIGKILL);
} }
// Clear wait status to make sure child exit status is accessible // Clear wait status to make sure child exit status is accessible
@@ -106,7 +106,7 @@ bool cIptvProtocolExt::Open(void)
{ {
debug("cIptvProtocolExt::Open()\n"); debug("cIptvProtocolExt::Open()\n");
// Reject empty script files // Reject empty script files
if (!strlen(scriptFile)) if (!strlen(*scriptFile))
return false; return false;
// Create the listening socket // Create the listening socket
OpenSocket(socketPort); OpenSocket(socketPort);
@@ -139,8 +139,8 @@ bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int
struct stat stbuf; struct stat stbuf;
// Update script file and parameter // Update script file and parameter
scriptFile = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), Location); scriptFile = cString::sprintf("%s/%s", IptvConfig.GetConfigDirectory(), Location);
if ((stat(scriptFile, &stbuf) != 0) || (strstr(scriptFile, "..") != 0)) { if ((stat(*scriptFile, &stbuf) != 0) || (strstr(*scriptFile, "..") != 0)) {
error("ERROR: Non-existent or relative path script '%s'", *scriptFile); error("Non-existent or relative path script '%s'", *scriptFile);
return false; return false;
} }
scriptParameter = Parameter; scriptParameter = Parameter;

View File

@@ -16,6 +16,7 @@
cIptvProtocolFile::cIptvProtocolFile() cIptvProtocolFile::cIptvProtocolFile()
: fileDelay(0), : fileDelay(0),
fileStream(NULL),
isActive(false) isActive(false)
{ {
debug("cIptvProtocolFile::cIptvProtocolFile()\n"); debug("cIptvProtocolFile::cIptvProtocolFile()\n");
@@ -74,7 +75,7 @@ int cIptvProtocolFile::Read(unsigned char* BufferAddr, unsigned int BufferLen)
// during the sleep and buffers are disposed. Check here that the plugin is // during the sleep and buffers are disposed. Check here that the plugin is
// still active before accessing the buffers // still active before accessing the buffers
if (isActive) if (isActive)
return fread(BufferAddr, sizeof(unsigned char), BufferLen, fileStream); return (int)fread(BufferAddr, sizeof(unsigned char), BufferLen, fileStream);
return -1; return -1;
} }

View File

@@ -53,17 +53,15 @@ bool cIptvProtocolHttp::Connect(void)
struct hostent *host; struct hostent *host;
host = gethostbyname(streamAddr); host = gethostbyname(streamAddr);
if (!host) { if (!host) {
error("%s is not valid address\n", streamAddr);
char tmp[64]; char tmp[64];
error("ERROR: %s", strerror_r(h_errno, tmp, sizeof(tmp))); error("%s is not valid address: %s", streamAddr, strerror_r(h_errno, tmp, sizeof(tmp)));
return false; return false;
} }
sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list); sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list);
} }
int err = connect(socketDesc, (struct sockaddr*)&sockAddr, int err = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
sizeof(sockAddr));
// Non-blocking sockets always report in-progress error when connected // Non-blocking sockets always report in-progress error when connected
ERROR_IF_FUNC(err < 0 && errno != EINPROGRESS, "connect()", 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 // Select with 800ms timeout on the socket completion, check if it is writable
@@ -78,9 +76,8 @@ bool cIptvProtocolHttp::Connect(void)
// If not any errors, then socket must be ready and connected // If not any errors, then socket must be ready and connected
if (socketStatus != 0) { if (socketStatus != 0) {
error("Cannot connect to %s\n", streamAddr);
char tmp[64]; char tmp[64];
error("ERROR: %s", strerror_r(socketStatus, tmp, sizeof(tmp))); error("Cannot connect to %s: %s", streamAddr, strerror_r(socketStatus, tmp, sizeof(tmp)));
CloseSocket(); CloseSocket();
return false; return false;
} }
@@ -94,8 +91,8 @@ bool cIptvProtocolHttp::Connect(void)
"\r\n", streamPath, streamAddr); "\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); ssize_t err2 = send(socketDesc, buffer, strlen(buffer), 0);
ERROR_IF_FUNC(err < 0, "send()", CloseSocket(), return false); ERROR_IF_FUNC(err2 < 0, "send()", CloseSocket(), return false);
// Now process headers // Now process headers
if (!ProcessHeaders()) { if (!ProcessHeaders()) {
@@ -128,7 +125,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
debug("cIptvProtocolHttp::GetHeaderLine()\n"); debug("cIptvProtocolHttp::GetHeaderLine()\n");
bool linefeed = false; bool linefeed = false;
bool newline = false; bool newline = false;
char buf[256]; char buf[4096];
char *bufptr = buf; char *bufptr = buf;
memset(buf, '\0', sizeof(buf)); memset(buf, '\0', sizeof(buf));
recvLen = 0; recvLen = 0;
@@ -142,7 +139,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
return false; return false;
// Check if data available // Check if data available
else if (retval) { else if (retval) {
int retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT, ssize_t retval = recvfrom(socketDesc, bufptr, 1, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen); (struct sockaddr *)&sockAddr, &addrlen);
if (retval <= 0) if (retval <= 0)
return false; return false;
@@ -161,6 +158,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
// Check that buffers won't be exceeded // Check that buffers won't be exceeded
if (recvLen >= sizeof(buf) || recvLen >= destLen) { if (recvLen >= sizeof(buf) || recvLen >= destLen) {
error("Header wouldn't fit into buffer\n"); error("Header wouldn't fit into buffer\n");
recvLen = 0;
return false; return false;
} }
} }
@@ -179,20 +177,20 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
unsigned int lineLength = 0; unsigned int lineLength = 0;
int response = 0; int response = 0;
bool responseFound = false; bool responseFound = false;
char buf[256]; char buf[4096];
while (!responseFound || lineLength != 0) { while (!responseFound || lineLength != 0) {
memset(buf, '\0', sizeof(buf)); memset(buf, '\0', sizeof(buf));
if (!GetHeaderLine(buf, sizeof(buf), lineLength)) if (!GetHeaderLine(buf, sizeof(buf), lineLength))
return false; return false;
if (!responseFound && sscanf(buf, "HTTP/1.%*i %i ",&response) != 1) { if (!responseFound && sscanf(buf, "HTTP/1.%*i %i ", &response) != 1) {
error("Expected HTTP header not found\n"); error("Expected HTTP header not found\n");
continue; continue;
} }
else else
responseFound = true; responseFound = true;
if (response != 200) { if (response != 200) {
error("ERROR: %s\n", buf); error("%s\n", buf);
return false; return false;
} }
} }

View File

@@ -20,8 +20,7 @@ private:
private: private:
bool Connect(void); bool Connect(void);
bool Disconnect(void); bool Disconnect(void);
bool GetHeaderLine(char* dest, unsigned int destLen, bool GetHeaderLine(char* dest, unsigned int destLen, unsigned int &recvLen);
unsigned int &recvLen);
bool ProcessHeaders(void); bool ProcessHeaders(void);
public: public:

View File

@@ -8,7 +8,7 @@
#include "sectionfilter.h" #include "sectionfilter.h"
cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index, cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
u_short Pid, u_char Tid, u_char Mask) uint16_t Pid, uint8_t Tid, uint8_t Mask)
: pusi_seen(0), : pusi_seen(0),
feedcc(0), feedcc(0),
doneq(0), doneq(0),
@@ -18,8 +18,7 @@ cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
tsfeedp(0), tsfeedp(0),
pid(Pid), pid(Pid),
devid(DeviceIndex), devid(DeviceIndex),
id(Index), id(Index)
pipeName("")
{ {
//debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, id); //debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devid, id);
int i; int i;
@@ -42,42 +41,46 @@ cIptvSectionFilter::cIptvSectionFilter(int DeviceIndex, int Index,
for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) { for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) {
mode = filter_mode[i]; mode = filter_mode[i];
mask = filter_mask[i]; mask = filter_mask[i];
maskandmode[i] = mask & mode; maskandmode[i] = (uint8_t)(mask & mode);
local_doneq |= maskandnotmode[i] = mask & ~mode; maskandnotmode[i] = (uint8_t)(mask & ~mode);
local_doneq |= maskandnotmode[i];
} }
doneq = local_doneq ? 1 : 0; doneq = local_doneq ? 1 : 0;
struct stat sb; // Create sockets
pipeName = cString::sprintf(IPTV_FILTER_FILENAME, devid, id); socket[0] = socket[1] = -1;
stat(pipeName, &sb); if (socketpair(AF_UNIX, SOCK_DGRAM, 0, socket) != 0) {
if (S_ISFIFO(sb.st_mode)) char tmp[64];
unlink(pipeName); error("Opening section filter sockets failed (device=%d id=%d): %s\n", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
i = mknod(pipeName, 0644 | S_IFIFO, 0); }
ERROR_IF_RET(i < 0, "mknod()", return); else if ((fcntl(socket[0], F_SETFL, O_NONBLOCK) != 0) || (fcntl(socket[1], F_SETFL, O_NONBLOCK) != 0)) {
char tmp[64];
// Create descriptors error("Setting section filter socket to non-blocking mode failed (device=%d id=%d): %s", devid, id, strerror_r(errno, tmp, sizeof(tmp)));
fifoDescriptor = open(pipeName, O_RDWR | O_NONBLOCK); }
readDescriptor = open(pipeName, O_RDONLY | O_NONBLOCK);
} }
cIptvSectionFilter::~cIptvSectionFilter() cIptvSectionFilter::~cIptvSectionFilter()
{ {
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, id); //debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devid, id);
close(fifoDescriptor); int tmp = socket[1];
close(readDescriptor); socket[1] = -1;
unlink(pipeName); if (tmp >= 0)
fifoDescriptor = -1; close(tmp);
readDescriptor = -1; tmp = socket[0];
socket[0] = -1;
if (tmp >= 0)
close(tmp);
secbuf = NULL;
} }
int cIptvSectionFilter::GetReadDesc(void) int cIptvSectionFilter::GetReadDesc(void)
{ {
return readDescriptor; return socket[0];
} }
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *Data) inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *Data)
{ {
return 3 + ((Data[1] & 0x0f) << 8) + Data[2]; return (uint16_t)(3 + ((Data[1] & 0x0f) << 8) + Data[2]);
} }
void cIptvSectionFilter::New(void) void cIptvSectionFilter::New(void)
@@ -91,24 +94,25 @@ int cIptvSectionFilter::Filter(void)
uint8_t neq = 0; uint8_t neq = 0;
int i; int i;
if (secbuf) {
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]; uint8_t local_xor = (uint8_t)(filter_value[i] ^ secbuf[i]);
if (maskandmode[i] & local_xor) if (maskandmode[i] & local_xor)
return 0; return 0;
neq |= maskandnotmode[i] & local_xor; neq |= (maskandnotmode[i] & local_xor);
} }
if (doneq && !neq) if (doneq && !neq)
return 0; return 0;
// There is no data in the fifo, more can be written // There is no data in the read socket, more can be written
if (!select_single_desc(fifoDescriptor, 0, false)) { if ((socket[0] >= 0) && (socket[1] >= 0) /*&& !select_single_desc(socket[0], 0, false)*/) {
i = write(fifoDescriptor, secbuf, seclen); ssize_t len = write(socket[1], secbuf, seclen);
ERROR_IF(i < 0, "write()"); ERROR_IF(len < 0, "write()");
// Update statistics // Update statistics
AddSectionStatistic(i, 1); AddSectionStatistic(len, 1);
}
} }
return 0; return 0;
} }
@@ -128,7 +132,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
return 0; return 0;
if (tsfeedp + len > DMX_MAX_SECFEED_SIZE) if (tsfeedp + len > DMX_MAX_SECFEED_SIZE)
len = DMX_MAX_SECFEED_SIZE - tsfeedp; len = (uint8_t)(DMX_MAX_SECFEED_SIZE - tsfeedp);
if (len <= 0) if (len <= 0)
return 0; return 0;
@@ -145,8 +149,7 @@ int cIptvSectionFilter::CopyDump(const uint8_t *buf, uint8_t len)
for (n = 0; secbufp + 2 < limit; ++n) { for (n = 0; secbufp + 2 < limit; ++n) {
seclen_local = GetLength(secbuf); seclen_local = GetLength(secbuf);
if (seclen_local <= 0 || seclen_local > DMX_MAX_SECTION_SIZE || if ((seclen_local <= 0) || (seclen_local > DMX_MAX_SECTION_SIZE) || ((seclen_local + secbufp) > limit))
seclen_local + secbufp > limit)
return 0; return 0;
seclen = seclen_local; seclen = seclen_local;
if (pusi_seen) if (pusi_seen)
@@ -173,9 +176,9 @@ void cIptvSectionFilter::Process(const uint8_t* Data)
return; return;
// Payload start // Payload start
uint8_t p = TS_SIZE - count; uint8_t p = (uint8_t)(TS_SIZE - count);
uint8_t cc = Data[3] & 0x0f; uint8_t cc = (uint8_t)(Data[3] & 0x0f);
int ccok = ((feedcc + 1) & 0x0f) == cc; int ccok = ((feedcc + 1) & 0x0f) == cc;
feedcc = cc; feedcc = cc;
@@ -199,7 +202,7 @@ void cIptvSectionFilter::Process(const uint8_t* Data)
const uint8_t *before = &Data[p + 1]; const uint8_t *before = &Data[p + 1];
uint8_t before_len = Data[p]; uint8_t before_len = Data[p];
const uint8_t *after = &before[before_len]; const uint8_t *after = &before[before_len];
uint8_t after_len = (count - 1) - before_len; uint8_t after_len = (uint8_t)(count - 1 - before_len);
CopyDump(before, before_len); CopyDump(before, before_len);
// Before start of new section, set pusi_seen = 1 // Before start of new section, set pusi_seen = 1

View File

@@ -15,25 +15,12 @@
class cIptvSectionFilter : public cIptvSectionStatistics { class cIptvSectionFilter : public cIptvSectionStatistics {
private: private:
enum dmx_success {
DMX_OK = 0, // Received OK
DMX_LENGTH_ERROR, // Incorrect length
DMX_OVERRUN_ERROR, // Receiver ring buffer overrun
DMX_CRC_ERROR, // Incorrect CRC
DMX_FRAME_ERROR, // Frame alignment error
DMX_FIFO_ERROR, // Receiver FIFO overrun
DMX_MISSED_ERROR // Receiver missed packet
};
enum dmx_limits { enum dmx_limits {
DMX_MAX_FILTER_SIZE = 18, DMX_MAX_FILTER_SIZE = 18,
DMX_MAX_SECTION_SIZE = 4096, DMX_MAX_SECTION_SIZE = 4096,
DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE) DMX_MAX_SECFEED_SIZE = (DMX_MAX_SECTION_SIZE + TS_SIZE)
}; };
int fifoDescriptor;
int readDescriptor;
int pusi_seen; int pusi_seen;
int feedcc; int feedcc;
int doneq; int doneq;
@@ -47,7 +34,7 @@ private:
int devid; int devid;
int id; int id;
cString pipeName; int socket[2];
uint8_t filter_value[DMX_MAX_FILTER_SIZE]; uint8_t filter_value[DMX_MAX_FILTER_SIZE];
uint8_t filter_mask[DMX_MAX_FILTER_SIZE]; uint8_t filter_mask[DMX_MAX_FILTER_SIZE];
@@ -64,12 +51,12 @@ private:
public: public:
// constructor & destructor // constructor & destructor
cIptvSectionFilter(int Index, int DeviceIndex, u_short Pid, cIptvSectionFilter(int Index, int DeviceIndex, uint16_t Pid,
u_char Tid, u_char Mask); uint8_t Tid, uint8_t Mask);
virtual ~cIptvSectionFilter(); virtual ~cIptvSectionFilter();
void Process(const uint8_t* Data); void Process(const uint8_t* Data);
int GetReadDesc(void); int GetReadDesc(void);
uint16_t GetPid(void) { return pid; } uint16_t GetPid(void) const { return pid; }
}; };
#endif // __IPTV_SECTIONFILTER_H #endif // __IPTV_SECTIONFILTER_H

16
setup.c
View File

@@ -17,10 +17,6 @@
#include "device.h" #include "device.h"
#include "setup.h" #include "setup.h"
#ifndef trVDR
#define trVDR(s) tr(s)
#endif
// --- cIptvMenuEditChannel -------------------------------------------------- // --- cIptvMenuEditChannel --------------------------------------------------
class cIptvMenuEditChannel : public cOsdMenu class cIptvMenuEditChannel : public cOsdMenu
@@ -391,7 +387,7 @@ class cIptvMenuChannels : public cOsdMenu
{ {
private: private:
void Setup(void); void Setup(void);
cChannel *GetChannel(int Index); cChannel *GetChannel(int Index) const;
void Propagate(void); void Propagate(void);
protected: protected:
@@ -431,16 +427,16 @@ void cIptvMenuChannels::Setup(void)
Display(); Display();
} }
cChannel *cIptvMenuChannels::GetChannel(int Index) cChannel *cIptvMenuChannels::GetChannel(int Index) const
{ {
cIptvMenuChannelItem *p = (cIptvMenuChannelItem *)Get(Index); cIptvMenuChannelItem *p = dynamic_cast<cIptvMenuChannelItem *>(Get(Index));
return p ? (cChannel *)p->Channel() : NULL; return p ? (cChannel *)p->Channel() : NULL;
} }
void cIptvMenuChannels::Propagate(void) void cIptvMenuChannels::Propagate(void)
{ {
Channels.ReNumber(); Channels.ReNumber();
for (cIptvMenuChannelItem *ci = (cIptvMenuChannelItem *)First(); ci; ci = (cIptvMenuChannelItem *)ci->Next()) for (cIptvMenuChannelItem *ci = dynamic_cast<cIptvMenuChannelItem *>(First()); ci; ci = dynamic_cast<cIptvMenuChannelItem *>(ci->Next()))
ci->Set(); ci->Set();
Display(); Display();
Channels.SetModified(true); Channels.SetModified(true);
@@ -618,7 +614,7 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
case kYellow: page = IPTV_DEVICE_INFO_FILTERS; case kYellow: page = IPTV_DEVICE_INFO_FILTERS;
UpdateInfo(); UpdateInfo();
break; break;
case kBlue: IptvConfig.SetUseBytes(!IptvConfig.GetUseBytes()); case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1);
UpdateInfo(); UpdateInfo();
break; break;
default: if (timeout.TimedOut()) default: if (timeout.TimedOut())
@@ -712,7 +708,7 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
case kBlue: return ShowInfo(); case kBlue: return ShowInfo();
case kInfo: if (Current() < help.Size()) case kInfo: if (Current() < help.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()])); return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), help[Current()]));
default: state = osContinue; default: state = osContinue; break;
} }
} }

View File

@@ -25,7 +25,7 @@ private:
eOSState EditChannel(void); eOSState EditChannel(void);
eOSState ShowInfo(void); eOSState ShowInfo(void);
virtual void Setup(void); void Setup(void);
void StoreFilters(const char *Name, int *Values); void StoreFilters(const char *Name, int *Values);
protected: protected:

View File

@@ -17,11 +17,13 @@ private:
protected: protected:
virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length);
virtual void SetStatus(bool On);
public: public:
cSidScanner(void); cSidScanner(void);
virtual void SetStatus(bool On);
void SetChannel(const cChannel *Channel); void SetChannel(const cChannel *Channel);
void Open() { SetStatus(true); }
void Close() { SetStatus(false); }
}; };
#endif // __SIDSCANNER_H #endif // __SIDSCANNER_H

View File

@@ -59,7 +59,7 @@ bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
// Bind socket // Bind socket
memset(&sockAddr, '\0', sizeof(sockAddr)); memset(&sockAddr, '\0', sizeof(sockAddr));
sockAddr.sin_family = AF_INET; sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(Port); sockAddr.sin_port = htons((uint16_t)(Port & 0xFFFF));
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY); sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (isUdp) { if (isUdp) {
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr)); int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
@@ -103,14 +103,14 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
//debug("cIptvUdpSocket::Read()\n"); //debug("cIptvUdpSocket::Read()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDesc <= 0) { if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return -1; return -1;
} }
socklen_t addrlen = sizeof(sockAddr); socklen_t addrlen = sizeof(sockAddr);
int len = 0; int len = 0;
// Read data from socket // Read data from socket
if (isActive) if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
len = recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT, len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen); (struct sockaddr *)&sockAddr, &addrlen);
if ((len > 0) && (BufferAddr[0] == TS_SYNC_BYTE)) { if ((len > 0) && (BufferAddr[0] == TS_SYNC_BYTE)) {
return len; return len;
@@ -126,14 +126,14 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
// payload type: MPEG2 TS = 33 // payload type: MPEG2 TS = 33
//unsigned int pt = readBuffer[1] & 0x7F; //unsigned int pt = readBuffer[1] & 0x7F;
// header lenght // header lenght
unsigned int headerlen = (3 + cc) * sizeof(uint32_t); unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
// check if extension // check if extension
if (x) { if (x) {
// extension header length // extension header length
unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) | unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
(BufferAddr[headerlen + 3] & 0xFF)); (BufferAddr[headerlen + 3] & 0xFF));
// update header length // update header length
headerlen += (ehl + 1) * sizeof(uint32_t); headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
} }
// Check that rtp is version 2 and payload contains multiple of TS packet data // Check that rtp is version 2 and payload contains multiple of TS packet data
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) && if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
@@ -168,13 +168,13 @@ int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
//debug("cIptvTcpSocket::Read()\n"); //debug("cIptvTcpSocket::Read()\n");
// Error out if socket not initialized // Error out if socket not initialized
if (socketDesc <= 0) { if (socketDesc <= 0) {
error("ERROR: Invalid socket in %s\n", __FUNCTION__); error("Invalid socket in %s\n", __FUNCTION__);
return -1; return -1;
} }
socklen_t addrlen = sizeof(sockAddr); socklen_t addrlen = sizeof(sockAddr);
// Read data from socket // Read data from socket
if (isActive) if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
return recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT, return (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
(struct sockaddr *)&sockAddr, &addrlen); (struct sockaddr *)&sockAddr, &addrlen);
return 0; return 0;
} }

View File

@@ -32,7 +32,7 @@ cString cIptvSectionStatistics::GetSectionStatistic()
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timer.Set(); timer.Set();
long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * filteredData / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * filteredData / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
// no trailing linefeed here! // no trailing linefeed here!
@@ -75,7 +75,7 @@ cString cIptvPidStatistics::GetPidStatistic()
cString info("Active pids:\n"); cString info("Active pids:\n");
for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) { for (unsigned int i = 0; i < IPTV_STATS_ACTIVE_PIDS_COUNT; ++i) {
if (mostActivePids[i].pid) { if (mostActivePids[i].pid) {
long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * mostActivePids[i].DataAmount / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * mostActivePids[i].DataAmount / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
info = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *info, i, info = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *info, i,
@@ -119,7 +119,7 @@ void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload)
mostActivePids[numberOfElements - 1].pid = Pid; mostActivePids[numberOfElements - 1].pid = Pid;
mostActivePids[numberOfElements - 1].DataAmount = Payload; mostActivePids[numberOfElements - 1].DataAmount = Payload;
// Re-sort // Re-sort
qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids); qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids);
} }
} }
@@ -145,7 +145,7 @@ cString cIptvStreamerStatistics::GetStreamerStatistic()
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timer.Set(); timer.Set();
long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * dataBytes / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
if (!IptvConfig.GetUseBytes()) if (!IptvConfig.GetUseBytes())
bitrate *= 8; bitrate *= 8;
cString info = cString::sprintf("Stream bitrate: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit"); cString info = cString::sprintf("Stream bitrate: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit");
@@ -182,7 +182,7 @@ cString cIptvBufferStatistics::GetBufferStatistic()
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
uint64_t elapsed = timer.Elapsed(); /* in milliseconds */ uint64_t elapsed = timer.Elapsed(); /* in milliseconds */
timer.Set(); timer.Set();
long bitrate = elapsed ? (long)((float)1000 / KILOBYTE(1) * dataBytes / elapsed) : 0L; long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L;
long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize()); long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize());
float percentage = (float)((float)usedSpace / (float)totalSpace * 100.0); float percentage = (float)((float)usedSpace / (float)totalSpace * 100.0);
long totalKilos = totalSpace / KILOBYTE(1); long totalKilos = totalSpace / KILOBYTE(1);

View File

@@ -23,7 +23,7 @@ cIptvStreamer::cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketL
if (packetBuffer) if (packetBuffer)
memset(packetBuffer, 0, packetBufferLen); memset(packetBuffer, 0, packetBufferLen);
else else
error("ERROR: MALLOC() failed for packet buffer"); error("MALLOC() failed for packet buffer");
} }
cIptvStreamer::~cIptvStreamer() cIptvStreamer::~cIptvStreamer()
@@ -31,6 +31,8 @@ cIptvStreamer::~cIptvStreamer()
debug("cIptvStreamer::~cIptvStreamer()\n"); debug("cIptvStreamer::~cIptvStreamer()\n");
// Close the protocol // Close the protocol
Close(); Close();
protocol = NULL;
ringBuffer = NULL;
// Free allocated memory // Free allocated memory
free(packetBuffer); free(packetBuffer);
} }
@@ -87,16 +89,17 @@ bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Ind
{ {
debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter); debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter);
if (!isempty(Location)) { if (!isempty(Location)) {
// Update protocol; Close the existing one if changed // Update protocol and set location and parameter; Close the existing one if changed
if (protocol != Protocol) { if (protocol != Protocol) {
if (protocol) if (protocol)
protocol->Close(); protocol->Close();
protocol = Protocol; protocol = Protocol;
if (protocol) if (protocol) {
protocol->Set(Location, Parameter, Index);
protocol->Open(); protocol->Open();
} }
// Set protocol location and parameter }
if (protocol) else if (protocol)
protocol->Set(Location, Parameter, Index); protocol->Set(Location, Parameter, Index);
} }
return true; return true;

View File

@@ -24,10 +24,12 @@ private:
unsigned int packetBufferLen; unsigned int packetBufferLen;
cIptvProtocolIf* protocol; cIptvProtocolIf* protocol;
protected:
virtual void Action(void);
public: public:
cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen); cIptvStreamer(cRingBufferLinear* RingBuffer, unsigned int PacketLen);
virtual ~cIptvStreamer(); virtual ~cIptvStreamer();
virtual void Action(void);
bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol); bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol);
bool Open(void); bool Open(void);
bool Close(void); bool Close(void);