diff --git a/HISTORY b/HISTORY index 65cfbb5..5324faa 100644 --- a/HISTORY +++ b/HISTORY @@ -159,7 +159,8 @@ VDR Plugin 'iptv' Revision History - Added support for LDFLAGS. - Added cppcheck target into Makefile. -2012-04-01: Version 0.5.1 +2012-xx-xx: Version 0.5.1 - Updated for vdr-1.7.27. - Fixed some channel switching bugs. +- Added support for a service interface. diff --git a/common.h b/common.h index 6203a15..c3728f9 100644 --- a/common.h +++ b/common.h @@ -30,6 +30,8 @@ #define IPTV_DEVICE_INFO_GENERAL 1 #define IPTV_DEVICE_INFO_PIDS 2 #define IPTV_DEVICE_INFO_FILTERS 3 +#define IPTV_DEVICE_INFO_PROTOCOL 4 +#define IPTV_DEVICE_INFO_BITRATE 5 #define IPTV_STATS_ACTIVE_PIDS_COUNT 10 #define IPTV_STATS_ACTIVE_FILTERS_COUNT 10 diff --git a/device.c b/device.c index 8eb5683..b1b7180 100644 --- a/device.c +++ b/device.c @@ -123,7 +123,7 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex) cString cIptvDevice::GetGeneralInformation(void) { //debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndex); - return cString::sprintf("IPTV device: %d\nCardIndex: %d\n%s%s%sChannel: %s", + return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s", deviceIndex, CardIndex(), pIptvStreamer ? *pIptvStreamer->GetInformation() : "", pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : "", @@ -169,6 +169,12 @@ cString cIptvDevice::GetInformation(unsigned int Page) case IPTV_DEVICE_INFO_FILTERS: info = GetFiltersInformation(); break; + case IPTV_DEVICE_INFO_PROTOCOL: + info = pIptvStreamer ? *pIptvStreamer->GetInformation() : ""; + break; + case IPTV_DEVICE_INFO_BITRATE: + info = pIptvStreamer ? *pIptvStreamer->GetStreamerStatistic() : ""; + break; default: info = cString::sprintf("%s%s%s", *GetGeneralInformation(), diff --git a/iptv.c b/iptv.c index db6138d..43bbc77 100644 --- a/iptv.c +++ b/iptv.c @@ -11,6 +11,7 @@ #include "config.h" #include "setup.h" #include "device.h" +#include "iptvservice.h" #if defined(APIVERSNUM) && APIVERSNUM < 10727 #error "VDR-1.7.27 API version or greater is required!" @@ -200,8 +201,18 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value) bool cPluginIptv::Service(const char *Id, void *Data) { - //debug("cPluginIptv::Service()\n"); - // Handle custom service requests from other plugins + debug("cPluginIptv::Service()\n"); + if (strcmp(Id,"IptvService-v1.0") == 0) { + if (Data) { + IptvService_v1_0 *data = (IptvService_v1_0*)Data; + cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex); + if (!dev) + return false; + data->protocol = dev->GetInformation(IPTV_DEVICE_INFO_PROTOCOL); + data->bitrate = dev->GetInformation(IPTV_DEVICE_INFO_BITRATE); + } + return true; + } return false; } diff --git a/iptvservice.h b/iptvservice.h new file mode 100644 index 0000000..1e48665 --- /dev/null +++ b/iptvservice.h @@ -0,0 +1,22 @@ +/* + * iptvservice.h: IPTV plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef __IPTVSERVICE_H +#define __IPTVSERVICE_H + +#include + +#define stIptv ('I' << 24) + +struct IptvService_v1_0 { + unsigned int cardIndex; + cString protocol; + cString bitrate; + }; + +#endif //__IPTVSERVICE_H + diff --git a/statistics.c b/statistics.c index 0dddc37..6c24b15 100644 --- a/statistics.c +++ b/statistics.c @@ -148,7 +148,7 @@ cString cIptvStreamerStatistics::GetStreamerStatistic() long bitrate = elapsed ? (long)(1000.0L * dataBytes / KILOBYTE(1) / elapsed) : 0L; if (!IptvConfig.GetUseBytes()) bitrate *= 8; - cString info = cString::sprintf("Stream bitrate: %ld k%s/s\n", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit"); + cString info = cString::sprintf("%ld k%s/s", bitrate, IptvConfig.GetUseBytes() ? "B" : "bit"); dataBytes = 0; return info; } diff --git a/streamer.c b/streamer.c index 30c7862..6c811a8 100644 --- a/streamer.c +++ b/streamer.c @@ -108,8 +108,8 @@ bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Ind cString cIptvStreamer::GetInformation(void) { //debug("cIptvStreamer::GetInformation()"); - cString info("Stream:"); + cString info; if (protocol) - info = cString::sprintf("%s %s", *info, *protocol->GetInformation()); - return cString::sprintf("%s\n", *info); + info = protocol->GetInformation(); + return info; }