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

Modified protocol parsing.

This commit is contained in:
Rolf Ahrenberg 2007-09-12 21:14:51 +00:00
parent 41d459dbf6
commit ae75f0dffd
4 changed files with 14 additions and 21 deletions

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.2 2007/09/12 18:55:31 rahrenbe Exp $
* $Id: device.c,v 1.3 2007/09/12 21:14:51 rahrenbe Exp $
*/
#include "common.h"
@ -64,24 +64,24 @@ cIptvDevice *cIptvDevice::Get(unsigned int DeviceIndex)
return NULL;
}
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, int *Protocol)
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cString *Protocol)
{
unsigned int a, b, c, d;
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);
if (sscanf(Param, "IPTV-UDP-%u.%u.%u.%u-%u", &a, &b, &c, &d, IpPort) == 5) {
debug("UDP channel detected\n");
Protocol = (int*)(cIptvStreamer::PROTOCOL_UDP);
*Protocol = cString("udp", true);
return cString::sprintf("%u.%u.%u.%u", a, b, c, d);
}
else if (sscanf(Param, "IPTV-RTSP-%u.%u.%u.%u-%u", &a, &b, &c, &d, IpPort) == 5) {
debug("RTSP channel detected\n");
Protocol = (int*)(cIptvStreamer::PROTOCOL_RTSP);
*Protocol = cString("rtsp", true);
return cString::sprintf("%u.%u.%u.%u", a, b, c, d);
}
else if (sscanf(Param, "IPTV-HTTP-%u.%u.%u.%u-%u", &a, &b, &c, &d, IpPort) == 5) {
debug("HTTP channel detected\n");
Protocol = (int*)cIptvStreamer::PROTOCOL_HTTP;
*Protocol = cString("http", true);
return cString::sprintf("%u.%u.%u.%u", a, b, c, d);
}
return NULL;
@ -120,8 +120,8 @@ bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *N
bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
int port, protocol;
cString addr;
int port;
cString protocol, addr;
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
addr = GetChannelSettings(Channel->Param(), &port, &protocol);

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.h,v 1.1 2007/09/12 17:28:59 rahrenbe Exp $
* $Id: device.h,v 1.2 2007/09/12 21:14:51 rahrenbe Exp $
*/
#ifndef __IPTV_DEVICE_H
@ -36,7 +36,7 @@ public:
// for channel parsing
private:
cString GetChannelSettings(const char *Param, int *IpPort, int *Protocol);
cString GetChannelSettings(const char *Param, int *IpPort, cString *Protocol);
bool ProvidesIptv(const char *Param) const;
// for channel selection

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.c,v 1.6 2007/09/12 18:58:39 ajhseppa Exp $
* $Id: streamer.c,v 1.7 2007/09/12 21:14:51 rahrenbe Exp $
*/
#include <sys/types.h>
@ -22,7 +22,6 @@
cIptvStreamer::cIptvStreamer(cRingBufferLinear* BufferPtr, cMutex* Mutex)
: cThread("IPTV streamer"),
dataPort(1234),
dataProtocol(PROTOCOL_UDP),
pRingBuffer(BufferPtr),
bufferSize(TS_SIZE * 7),
mutex(Mutex),
@ -193,9 +192,9 @@ bool cIptvStreamer::Deactivate()
return true;
}
bool cIptvStreamer::SetStream(const char* address, const int port, const int protocol)
bool cIptvStreamer::SetStream(const char* address, const int port, const char* protocol)
{
debug("cIptvStreamer::SetChannel(): channel = %s:%d (%d)\n", address, port, protocol);
debug("cIptvStreamer::SetChannel(): %s://%s:%d\n", protocol, address, port);
// De-activate the reception if it is running currently. Otherwise the
// reception stream is overwritten and cannot be un-set after this

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: streamer.h,v 1.2 2007/09/12 18:33:56 ajhseppa Exp $
* $Id: streamer.h,v 1.3 2007/09/12 21:14:51 rahrenbe Exp $
*/
#ifndef __IPTV_STREAMER_H
@ -19,7 +19,6 @@ private:
char stream[256];
int socketDesc;
int dataPort;
int dataProtocol;
struct sockaddr_in sa;
cRingBufferLinear* pRingBuffer;
unsigned char* pReceiveBuffer;
@ -32,16 +31,11 @@ private:
void CloseSocket();
public:
enum {
PROTOCOL_UDP,
PROTOCOL_RTSP,
PROTOCOL_HTTP
};
cIptvStreamer();
cIptvStreamer(cRingBufferLinear* BufferPtr, cMutex* Mutex);
virtual ~cIptvStreamer();
virtual void Action();
bool SetStream(const char* address, const int port, const int protocol);
bool SetStream(const char* address, const int port, const char* protocol);
bool Activate();
bool Deactivate();
};