From ae75f0dffd00997d692b135cd1d4255dcd9fefa1 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Wed, 12 Sep 2007 21:14:51 +0000 Subject: [PATCH] Modified protocol parsing. --- device.c | 14 +++++++------- device.h | 4 ++-- streamer.c | 7 +++---- streamer.h | 10 ++-------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/device.c b/device.c index 66f482b..d9d5f27 100644 --- a/device.c +++ b/device.c @@ -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); diff --git a/device.h b/device.h index 414a3e3..360f4e6 100644 --- a/device.h +++ b/device.h @@ -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 diff --git a/streamer.c b/streamer.c index 5075170..952b4d0 100644 --- a/streamer.c +++ b/streamer.c @@ -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 @@ -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 diff --git a/streamer.h b/streamer.h index 4f03787..baef2f0 100644 --- a/streamer.h +++ b/streamer.h @@ -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(); };