mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Fixed some channel switching bugs.
This commit is contained in:
parent
ff84c54d50
commit
b3b06e569f
4
HISTORY
4
HISTORY
@ -159,7 +159,7 @@ VDR Plugin 'iptv' Revision History
|
|||||||
- Added support for LDFLAGS.
|
- Added support for LDFLAGS.
|
||||||
- Added cppcheck target into Makefile.
|
- Added cppcheck target into Makefile.
|
||||||
|
|
||||||
2012-03-25: Version 0.5.1
|
2012-04-01: Version 0.5.1
|
||||||
|
|
||||||
- Updated for vdr-1.7.27.
|
- Updated for vdr-1.7.27.
|
||||||
- Fixed channel switching in UDP protocol.
|
- Fixed some channel switching bugs.
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
cIptvProtocolExt::cIptvProtocolExt()
|
cIptvProtocolExt::cIptvProtocolExt()
|
||||||
: pid(-1),
|
: pid(-1),
|
||||||
scriptFile(""),
|
scriptFile(""),
|
||||||
scriptParameter(0)
|
scriptParameter(0),
|
||||||
|
streamPort(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
|
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ void cIptvProtocolExt::ExecuteScript(void)
|
|||||||
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
|
||||||
close(i);
|
close(i);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, socketPort);
|
cString cmd = cString::sprintf("%s %d %d", *scriptFile, scriptParameter, streamPort);
|
||||||
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
|
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
|
||||||
if (execl("/bin/bash", "sh", "-c", *cmd, (char *)NULL) == -1) {
|
if (execl("/bin/bash", "sh", "-c", *cmd, (char *)NULL) == -1) {
|
||||||
error("Script execution failed: %s", *cmd);
|
error("Script execution failed: %s", *cmd);
|
||||||
@ -113,7 +114,7 @@ bool cIptvProtocolExt::Open(void)
|
|||||||
if (!strlen(*scriptFile))
|
if (!strlen(*scriptFile))
|
||||||
return false;
|
return false;
|
||||||
// Create the listening socket
|
// Create the listening socket
|
||||||
OpenSocket(socketPort);
|
OpenSocket(streamPort);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
ExecuteScript();
|
ExecuteScript();
|
||||||
isActive = true;
|
isActive = true;
|
||||||
@ -149,7 +150,7 @@ bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int
|
|||||||
}
|
}
|
||||||
scriptParameter = Parameter;
|
scriptParameter = Parameter;
|
||||||
// Update listen port
|
// Update listen port
|
||||||
socketPort = IptvConfig.GetExtProtocolBasePort() + Index;
|
streamPort = IptvConfig.GetExtProtocolBasePort() + Index;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ private:
|
|||||||
int pid;
|
int pid;
|
||||||
cString scriptFile;
|
cString scriptFile;
|
||||||
int scriptParameter;
|
int scriptParameter;
|
||||||
|
int streamPort;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TerminateScript(void);
|
void TerminateScript(void);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
cIptvProtocolHttp::cIptvProtocolHttp()
|
cIptvProtocolHttp::cIptvProtocolHttp()
|
||||||
: streamAddr(strdup("")),
|
: streamAddr(strdup("")),
|
||||||
streamPath(strdup("/"))
|
streamPath(strdup("/")),
|
||||||
|
streamPort(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
|
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
|
||||||
}
|
}
|
||||||
@ -41,7 +42,7 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
||||||
// Ensure that socket is valid and connect
|
// Ensure that socket is valid and connect
|
||||||
OpenSocket(socketPort, streamAddr);
|
OpenSocket(streamPort, streamAddr);
|
||||||
if (!ConnectSocket()) {
|
if (!ConnectSocket()) {
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
@ -185,8 +186,8 @@ bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
streamPath = strcpyrealloc(streamPath, "/");
|
streamPath = strcpyrealloc(streamPath, "/");
|
||||||
socketPort = Parameter;
|
streamPort = Parameter;
|
||||||
//debug("http://%s:%d%s\n", streamAddr, socketPort, streamPath);
|
//debug("http://%s:%d%s\n", streamAddr, streamPort, streamPath);
|
||||||
// Re-connect the socket
|
// Re-connect the socket
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -196,5 +197,5 @@ bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int
|
|||||||
cString cIptvProtocolHttp::GetInformation(void)
|
cString cIptvProtocolHttp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolHttp::GetInformation()");
|
//debug("cIptvProtocolHttp::GetInformation()");
|
||||||
return cString::sprintf("http://%s:%d%s", streamAddr, socketPort, streamPath);
|
return cString::sprintf("http://%s:%d%s", streamAddr, streamPort, streamPath);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ class cIptvProtocolHttp : public cIptvTcpSocket, public cIptvProtocolIf {
|
|||||||
private:
|
private:
|
||||||
char* streamAddr;
|
char* streamAddr;
|
||||||
char* streamPath;
|
char* streamPath;
|
||||||
|
int streamPort;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Connect(void);
|
bool Connect(void);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
cIptvProtocolUdp::cIptvProtocolUdp()
|
cIptvProtocolUdp::cIptvProtocolUdp()
|
||||||
: streamAddr(strdup("")),
|
: streamAddr(strdup("")),
|
||||||
sourceAddr(strdup(""))
|
sourceAddr(strdup("")),
|
||||||
|
streamPort(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
|
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
|
||||||
}
|
}
|
||||||
@ -38,7 +39,7 @@ cIptvProtocolUdp::~cIptvProtocolUdp()
|
|||||||
bool cIptvProtocolUdp::Open(void)
|
bool cIptvProtocolUdp::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Open(): sourceAddr=%s streamAddr=%s\n", sourceAddr, streamAddr);
|
debug("cIptvProtocolUdp::Open(): sourceAddr=%s streamAddr=%s\n", sourceAddr, streamAddr);
|
||||||
OpenSocket(socketPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
OpenSocket(streamPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
||||||
if (!isempty(streamAddr)) {
|
if (!isempty(streamAddr)) {
|
||||||
// Join a new multicast group
|
// Join a new multicast group
|
||||||
JoinMulticast(inet_addr(streamAddr));
|
JoinMulticast(inet_addr(streamAddr));
|
||||||
@ -51,7 +52,7 @@ bool cIptvProtocolUdp::Close(void)
|
|||||||
debug("cIptvProtocolUdp::Close(): sourceAddr=%s streamAddr=%s\n", sourceAddr, streamAddr);
|
debug("cIptvProtocolUdp::Close(): sourceAddr=%s streamAddr=%s\n", sourceAddr, streamAddr);
|
||||||
if (!isempty(streamAddr)) {
|
if (!isempty(streamAddr)) {
|
||||||
// Drop the multicast group
|
// Drop the multicast group
|
||||||
OpenSocket(socketPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
OpenSocket(streamPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
||||||
DropMulticast(inet_addr(streamAddr));
|
DropMulticast(inet_addr(streamAddr));
|
||||||
}
|
}
|
||||||
// Close the socket
|
// Close the socket
|
||||||
@ -73,7 +74,7 @@ bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int
|
|||||||
if (!isempty(Location)) {
|
if (!isempty(Location)) {
|
||||||
// Drop the multicast group
|
// Drop the multicast group
|
||||||
if (!isempty(streamAddr)) {
|
if (!isempty(streamAddr)) {
|
||||||
OpenSocket(socketPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
OpenSocket(streamPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
||||||
DropMulticast(inet_addr(streamAddr));
|
DropMulticast(inet_addr(streamAddr));
|
||||||
}
|
}
|
||||||
// Update stream address and port
|
// Update stream address and port
|
||||||
@ -85,10 +86,10 @@ bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
sourceAddr = strcpyrealloc(sourceAddr, "");
|
sourceAddr = strcpyrealloc(sourceAddr, "");
|
||||||
socketPort = Parameter;
|
streamPort = Parameter;
|
||||||
// Join a new multicast group
|
// Join a new multicast group
|
||||||
if (!isempty(streamAddr)) {
|
if (!isempty(streamAddr)) {
|
||||||
OpenSocket(socketPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
OpenSocket(streamPort, isempty(sourceAddr) ? INADDR_ANY : inet_addr(sourceAddr));
|
||||||
JoinMulticast(inet_addr(streamAddr));
|
JoinMulticast(inet_addr(streamAddr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,5 +99,5 @@ bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int
|
|||||||
cString cIptvProtocolUdp::GetInformation(void)
|
cString cIptvProtocolUdp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolUdp::GetInformation()");
|
//debug("cIptvProtocolUdp::GetInformation()");
|
||||||
return cString::sprintf("udp://%s:%d", streamAddr, socketPort);
|
return cString::sprintf("udp://%s:%d", streamAddr, streamPort);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ class cIptvProtocolUdp : public cIptvUdpSocket, public cIptvProtocolIf {
|
|||||||
private:
|
private:
|
||||||
char* streamAddr;
|
char* streamAddr;
|
||||||
char* sourceAddr;
|
char* sourceAddr;
|
||||||
|
int streamPort;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvProtocolUdp();
|
cIptvProtocolUdp();
|
||||||
|
Loading…
Reference in New Issue
Block a user