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

Channel parameter refactoring.

This commit is contained in:
Rolf Ahrenberg 2007-10-19 21:36:27 +00:00
parent 5ed04a6e72
commit 8e3956cbeb
17 changed files with 151 additions and 137 deletions

4
README
View File

@ -101,8 +101,8 @@ Configuration:
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
| | | | IP Port Number, File delay (ms), Script parameter
| | | IP Address, File location, Script location
| | Protocol ("UDP", "HTTP", "FILE", "EXT")
| Plugin ID ("IPTV")
Unique enumeration

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.69 2007/10/15 20:06:38 ajhseppa Exp $
* $Id: device.c,v 1.70 2007/10/19 21:36:27 rahrenbe Exp $
*/
#include "config.h"
@ -155,26 +155,26 @@ 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, cIptvProtocolIf* *Protocol)
{
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
char *loc = NULL;
if (sscanf(Param, "IPTV|UDP|%a[^|]|%u", &loc, IpPort) == 2) {
if (sscanf(IptvParam, "IPTV|UDP|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = pUdpProtocol;
return addr;
}
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, IpPort) == 2) {
else if (sscanf(IptvParam, "IPTV|HTTP|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = pHttpProtocol;
return addr;
}
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, IpPort) == 2) {
else if (sscanf(IptvParam, "IPTV|FILE|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = pFileProtocol;
return addr;
}
else if (sscanf(Param, "IPTV|EXT|%a[^|]|%u", &loc, IpPort) == 2) {
else if (sscanf(IptvParam, "IPTV|EXT|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = pExtProtocol;
return addr;
@ -215,17 +215,17 @@ bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *N
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
int port;
cString addr;
int parameter;
cString location;
cIptvProtocolIf *protocol;
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
addr = GetChannelSettings(Channel->PluginParam(), &port, &protocol);
if (isempty(addr)) {
location = GetChannelSettings(Channel->PluginParam(), &parameter, &protocol);
if (isempty(location)) {
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false;
}
pIptvStreamer->Set(addr, port, protocol);
pIptvStreamer->Set(location, parameter, protocol);
if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning())
pSidScanner->SetChannel(Channel);
return true;

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.h,v 1.33 2007/10/15 21:03:45 rahrenbe Exp $
* $Id: device.h,v 1.34 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_DEVICE_H
@ -61,7 +61,7 @@ private:
// for channel parsing & buffering
private:
cString GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol);
cString GetChannelSettings(const char *IptvParam, int *Parameter, cIptvProtocolIf* *Protocol);
bool ProvidesIptv(const char *Param) const;
void ResetBuffering(void);
bool IsBuffering(void);

View File

@ -1,5 +1,17 @@
#!/bin/sh
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}
# Define stream address
URL=""
if [ -z "${URL}" ]; then
@ -7,9 +19,5 @@ if [ -z "${URL}" ]; then
exit 1;
fi
if [ $# -ne 1 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1;
fi
exec vlc "${URL}" --sout "#transcode{vcodec=mp2v,acodec=mpga,vb=800,ab=192}:standard{access=udp,mux=ts,dst=127.0.0.1:${1}}" --intf dummy
# Use 'exec' for capturing script pid
exec vlc "${URL}" --sout "#transcode{vcodec=mp2v,acodec=mpga,vb=800,ab=192}:standard{access=udp,mux=ts,dst=127.0.0.1:${PORT}}" --intf dummy

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: VDR 1.5.7\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2007-10-17 00:19+0300\n"
"POT-Creation-Date: 2007-10-19 23:10+0300\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: <vdr@linuxtv.org>\n"
@ -57,12 +57,18 @@ msgstr "Protokolla"
msgid "Delay (ms)"
msgstr "Viive (ms)"
msgid "Port"
msgstr "Portti"
msgid "Script"
msgstr "Skripti"
msgid "Parameter"
msgstr "Parametri"
msgid "Address"
msgstr "Osoite"
msgid "Port"
msgstr "Portti"
msgid "Nid"
msgstr "Verkko-ID"

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolext.c,v 1.6 2007/10/19 18:26:27 ajhseppa Exp $
* $Id: protocolext.c,v 1.7 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <sys/wait.h>
@ -23,12 +23,12 @@
cIptvProtocolExt::cIptvProtocolExt()
: pid(-1),
listenPort(4321),
scriptParameter(0),
socketDesc(-1),
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()),
isActive(false)
readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount())
{
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
streamAddr = strdup("");
scriptFile = strdup("");
listenAddr = strdup("127.0.0.1");
// Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen);
@ -42,7 +42,7 @@ cIptvProtocolExt::~cIptvProtocolExt()
// Drop the multicast group and close the socket
Close();
// Free allocated memory
free(streamAddr);
free(scriptFile);
free(listenAddr);
free(readBuffer);
}
@ -104,13 +104,17 @@ void cIptvProtocolExt::CloseSocket(void)
void cIptvProtocolExt::ExecuteCommand(void)
{
debug("cIptvProtocolExt::ExecuteCommand()\n");
// Check if already executing
if (pid > 0) {
error("ERROR: Cannot execute command!");
return;
}
// Let's fork
if ((pid = fork()) == -1) {
char tmp[64];
error("ERROR: fork(): %s", strerror_r(errno, tmp, sizeof(tmp)));
return;
}
// Check if child process
if (pid == 0) {
// Close all dup'ed filedescriptors
@ -119,18 +123,17 @@ void cIptvProtocolExt::ExecuteCommand(void)
close(i);
// Execute the external script
char* cmd = NULL;
asprintf(&cmd, "%s %d", streamAddr, listenPort);
asprintf(&cmd, "%s %d %d", scriptFile, scriptParameter, listenPort);
debug("cIptvProtocolExt::ExecuteCommand(child): %s\n", cmd);
if (execl("/bin/sh", "sh", "-c", cmd, NULL) == -1) {
error("ERROR: Command failed: %s", cmd);
free(cmd);
error("ERROR: Command failed: %s", streamAddr);
_exit(-1);
}
free(cmd);
_exit(0);
}
else {
isActive = true;
debug("cIptvProtocolExt::ExecuteCommand(): pid=%d\n", pid);
}
}
@ -150,18 +153,17 @@ void cIptvProtocolExt::TerminateCommand(void)
error("ERROR: kill(): %s", strerror_r(errno, tmp, sizeof(tmp)));
waitOver = true;
}
while (!waitOver) {
retval = 0;
waitms += timeoutms;
if ((waitms % 2000) == 0) {
error("ERROR: Script '%s' won't terminate - killing it", streamAddr);
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);
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
if (retval < 0) {
char tmp[64];
error("ERROR: waitid(): %s", strerror_r(errno, tmp, sizeof(tmp)));
@ -169,20 +171,16 @@ void cIptvProtocolExt::TerminateCommand(void)
}
// 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)) {
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;
isActive = false;
}
}
@ -250,34 +248,34 @@ int cIptvProtocolExt::Read(unsigned char* *BufferAddr)
bool cIptvProtocolExt::Open(void)
{
debug("cIptvProtocolExt::Open(): streamAddr=%s listenPort=%d\n", streamAddr, listenPort);
// Reject completely empty stream addresses
if (!strlen(streamAddr))
debug("cIptvProtocolExt::Open()\n");
// Reject empty script files
if (!strlen(scriptFile))
return false;
// Create the listening socket
OpenSocket();
if (!isActive)
ExecuteCommand();
return isActive;
// Execute the external command
ExecuteCommand();
return true;
}
bool cIptvProtocolExt::Close(void)
{
debug("cIptvProtocolExt::Close(): streamAddr=%s\n", streamAddr);
debug("cIptvProtocolExt::Close()\n");
// Close the socket
CloseSocket();
if (isActive)
TerminateCommand();
return !isActive;
// Terminate the external script
TerminateCommand();
return true;
}
bool cIptvProtocolExt::Set(const char* Address, const int Port)
bool cIptvProtocolExt::Set(const char* Location, const int Parameter)
{
debug("cIptvProtocolExt::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d\n", Location, Parameter);
if (!isempty(Location)) {
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Address);
listenPort = Port;
scriptFile = strcpyrealloc(scriptFile, Location);
scriptParameter = Parameter;
}
return true;
}
@ -285,5 +283,5 @@ bool cIptvProtocolExt::Set(const char* Address, const int Port)
cString cIptvProtocolExt::GetInformation(void)
{
//debug("cIptvProtocolExt::GetInformation()");
return cString::sprintf("ext://%s:%d", streamAddr, listenPort);
return cString::sprintf("ext://%s:%d", scriptFile, scriptParameter);
}

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolext.h,v 1.3 2007/10/18 19:33:15 rahrenbe Exp $
* $Id: protocolext.h,v 1.4 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLEXT_H
@ -17,7 +17,8 @@ private:
int pid;
char* listenAddr;
int listenPort;
char* streamAddr;
char* scriptFile;
int scriptParameter;
int socketDesc;
unsigned char* readBuffer;
unsigned int readBufferLen;
@ -34,7 +35,7 @@ public:
cIptvProtocolExt();
virtual ~cIptvProtocolExt();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Set(const char* Location, const int Parameter);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocolfile.c,v 1.11 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <fcntl.h>
@ -16,11 +16,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)
@ -33,7 +34,7 @@ cIptvProtocolFile::~cIptvProtocolFile()
// Drop open handles
Close();
// Free allocated memory
free(streamAddr);
free(fileLocation);
free(readBuffer);
}
@ -41,8 +42,8 @@ bool cIptvProtocolFile::OpenFile(void)
{
debug("cIptvProtocolFile::OpenFile()\n");
// Check that stream address is valid
if (!isActive && !isempty(streamAddr)) {
fileStream = fopen(streamAddr, "rb");
if (!isActive && !isempty(fileLocation)) {
fileStream = fopen(fileLocation, "rb");
if (ferror(fileStream) || !fileStream) {
char tmp[64];
error("ERROR: fopen(): %s", strerror_r(errno, tmp, sizeof(tmp)));
@ -58,7 +59,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 +80,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 +92,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 +100,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)
{
debug("cIptvProtocolFile::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d\n", Location, Parameter);
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 +124,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,7 @@
*
* 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 $
* $Id: protocolfile.h,v 1.6 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLFILE_H
@ -14,8 +14,8 @@
class cIptvProtocolFile : public cIptvProtocolIf {
private:
char* streamAddr;
int streamPort;
char* fileLocation;
int fileDelay;
FILE* fileStream;
unsigned char* readBuffer;
unsigned int readBufferLen;
@ -29,7 +29,7 @@ public:
cIptvProtocolFile();
virtual ~cIptvProtocolFile();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Set(const char* Location, const int Parameter);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocolhttp.c,v 1.11 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <sys/types.h>
@ -336,27 +336,27 @@ int cIptvProtocolHttp::Read(unsigned char* *BufferAddr)
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)
bool cIptvProtocolHttp::Set(const char* Location, const int Parameter)
{
debug("cIptvProtocolHttp::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d\n", Location, Parameter);
if (!isempty(Location)) {
// Disconnect the current socket
Disconnect();
// Update stream address, path and port
streamAddr = strcpyrealloc(streamAddr, Address);
streamAddr = strcpyrealloc(streamAddr, Location);
char *path = strstr(streamAddr, "/");
if (path) {
streamPath = strcpyrealloc(streamPath, path);
@ -364,7 +364,7 @@ bool cIptvProtocolHttp::Set(const char* Address, const int Port)
}
else
streamPath = strcpyrealloc(streamPath, "/");
streamPort = Port;
streamPort = Parameter;
debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
// Re-connect the socket
Connect();

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocolhttp.h,v 1.8 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLHTTP_H
@ -36,7 +36,7 @@ public:
cIptvProtocolHttp();
virtual ~cIptvProtocolHttp();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Set(const char* Location, const int Parameter);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocolif.h,v 1.6 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLIF_H
@ -14,7 +14,7 @@ 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) = 0;
virtual bool Open(void) = 0;
virtual bool Close(void) = 0;
virtual cString GetInformation(void) = 0;

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocoludp.c,v 1.12 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <sys/types.h>
@ -216,7 +216,7 @@ int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
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 +224,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 +232,15 @@ bool cIptvProtocolUdp::Close(void)
return true;
}
bool cIptvProtocolUdp::Set(const char* Address, const int Port)
bool cIptvProtocolUdp::Set(const char* Location, const int Parameter)
{
debug("cIptvProtocolUdp::Set(): %s:%d\n", Address, Port);
if (!isempty(Address)) {
debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d\n", Location, Parameter);
if (!isempty(Location)) {
// Drop the multicast group
DropMulticast();
// Update stream address and port
streamAddr = strcpyrealloc(streamAddr, Address);
streamPort = Port;
streamAddr = strcpyrealloc(streamAddr, Location);
streamPort = Parameter;
// Join a new multicast group
JoinMulticast();
}

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: protocoludp.h,v 1.9 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_PROTOCOLUDP_H
@ -32,7 +32,7 @@ public:
cIptvProtocolUdp();
virtual ~cIptvProtocolUdp();
virtual int Read(unsigned char* *BufferAddr);
virtual bool Set(const char* Address, const int Port);
virtual bool Set(const char* Location, const int Parameter);
virtual bool Open(void);
virtual bool Close(void);
virtual cString GetInformation(void);

48
setup.c
View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: setup.c,v 1.37 2007/10/19 17:49:35 rahrenbe Exp $
* $Id: setup.c,v 1.38 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <string.h>
@ -34,14 +34,14 @@ private:
eProtocolCount
};
struct tIptvChannel {
int frequency, source, protocol, port, vpid, ppid, tpid, sid, nid, tid, rid;
int frequency, source, protocol, parameter, vpid, ppid, tpid, sid, nid, tid, rid;
int apid[MAXAPIDS + 1], dpid[MAXDPIDS + 1], spid[MAXSPIDS + 1], caids[MAXCAIDS + 1];
char name[256], location[256];
} data;
cChannel *channel;
const char *protocols[eProtocolCount];
void Setup(void);
cString GetIptvSettings(const char *Param, int *Port, int *Protocol);
cString GetIptvSettings(const char *Param, int *Parameter, int *Protocol);
void GetChannelData(cChannel *Channel);
void SetChannelData(cChannel *Channel);
@ -68,25 +68,25 @@ 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 *Protocol)
{
char *loc = NULL;
if (sscanf(Param, "IPTV|UDP|%a[^|]|%u", &loc, Port) == 2) {
if (sscanf(Param, "IPTV|UDP|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = eProtocolUDP;
return addr;
}
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, Port) == 2) {
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = eProtocolHTTP;
return addr;
}
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, Port) == 2) {
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = eProtocolFILE;
return addr;
}
else if (sscanf(Param, "IPTV|EXT|%a[^|]|%u", &loc, Port) == 2) {
else if (sscanf(Param, "IPTV|EXT|%a[^|]|%u", &loc, Parameter) == 2) {
cString addr(loc, true);
*Protocol = eProtocolEXT;
return addr;
@ -97,7 +97,7 @@ cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Port, int
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
{
if (Channel) {
int port, protocol;
int parameter, protocol;
data.frequency = Channel->Frequency();
data.source = Channel->Source();
data.vpid = Channel->Vpid();
@ -116,9 +116,9 @@ void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
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, &protocol), sizeof(data.location));
data.protocol = protocol;
data.port = port;
data.parameter = parameter;
}
else {
data.frequency = 1;
@ -141,7 +141,7 @@ void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
strn0cpy(data.name, "IPTV", sizeof(data.name));
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.protocol = eProtocolUDP;
data.port = 1234;
data.parameter = 1234;
}
}
@ -154,17 +154,17 @@ void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
char slangs[MAXSPIDS][MAXLANGCODE2] = { "" };
switch (data.protocol) {
case eProtocolEXT:
param = cString::sprintf("IPTV|EXT|%s|%d", data.location, data.port);
param = cString::sprintf("IPTV|EXT|%s|%d", data.location, data.parameter);
break;
case eProtocolFILE:
param = cString::sprintf("IPTV|FILE|%s|%d", data.location, data.port);
param = cString::sprintf("IPTV|FILE|%s|%d", data.location, data.parameter);
break;
case eProtocolHTTP:
param = cString::sprintf("IPTV|HTTP|%s|%d", data.location, data.port);
param = cString::sprintf("IPTV|HTTP|%s|%d", data.location, data.parameter);
break;
default:
case eProtocolUDP:
param = cString::sprintf("IPTV|UDP|%s|%d", data.location, data.port);
param = cString::sprintf("IPTV|UDP|%s|%d", data.location, data.parameter);
break;
}
Channel->SetPids(data.vpid, data.ppid, data.apid, alangs, data.dpid, dlangs, data.spid, slangs, data.tpid);
@ -185,17 +185,17 @@ void cIptvMenuEditChannel::Setup(void)
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 cMenuEditIntItem(tr("Delay (ms)"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolEXT:
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Port"), &data.port, 0, 0xFFFF));
Add(new cMenuEditStrItem(tr("Script"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Parameter"), &data.parameter, 0, 0xFFFF));
break;
case eProtocolHTTP:
case eProtocolUDP:
default:
Add(new cMenuEditStrItem(tr("Address"), data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Port"), &data.port, 0, 0xFFFF));
Add(new cMenuEditIntItem(tr("Port"), &data.parameter, 0, 0xFFFF));
break;
}
// Normal settings
@ -295,20 +295,20 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
switch (data.protocol) {
case eProtocolEXT:
strn0cpy(data.location, "/video/iptvstream.sh", sizeof(data.location));
data.port = 0;
data.parameter = 0;
break;
case eProtocolFILE:
strn0cpy(data.location, "/tmp/video.ts", sizeof(data.location));
data.port = 0;
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();

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: streamer.c,v 1.24 2007/10/19 21:36:28 rahrenbe Exp $
*/
#include <vdr/thread.h>
@ -77,10 +77,10 @@ bool cIptvStreamer::Close(void)
return true;
}
bool cIptvStreamer::Set(const char* Address, const int Port, cIptvProtocolIf* Protocol)
bool cIptvStreamer::Set(const char* Location, const int Parameter, 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 +89,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);
}
return true;
}

View File

@ -3,7 +3,7 @@
*
* 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 $
* $Id: streamer.h,v 1.12 2007/10/19 21:36:28 rahrenbe Exp $
*/
#ifndef __IPTV_STREAMER_H
@ -29,7 +29,7 @@ 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, cIptvProtocolIf* Protocol);
bool Open(void);
bool Close(void);
cString GetInformation(void);