summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormethodus <methodus@web.de>2012-11-30 22:33:50 +0100
committermethodus <methodus@web.de>2012-11-30 22:33:50 +0100
commit6e84bf963413305833c980b2fe070fc690892418 (patch)
treeb8ebf5543852d31ede005faae1f7bc6e8a5313f2
parente6c28c5209b5508a61affc947179260cec0d2733 (diff)
downloadvdr-plugin-upnp-6e84bf963413305833c980b2fe070fc690892418.tar.gz
vdr-plugin-upnp-6e84bf963413305833c980b2fe070fc690892418.tar.bz2
Added the ability to filter the number of channels outputed by the vdrProvider
-rw-r--r--include/server.h2
-rw-r--r--plugins/provider/fileProvider/fileProvider.cpp3
-rw-r--r--plugins/provider/vdrProvider/vdrProvider.cpp44
-rw-r--r--server/server.cpp2
4 files changed, 46 insertions, 5 deletions
diff --git a/include/server.h b/include/server.h
index be76e41..4d28c3d 100644
--- a/include/server.h
+++ b/include/server.h
@@ -57,6 +57,7 @@ public:
void SetConfiguration(upnp::cConfig newConfig);
upnp::cConfig GetConfiguration() const;
+ const string& GetConfigDirectory() const { return mConfigDirectory; };
const char* GetServerIPAddress() const;
uint16_t GetServerPort() const;
@@ -90,6 +91,7 @@ private:
Description mServerDescription;
iconList mServerIcons;
upnp::cConfig mCurrentConfiguration;
+ string mConfigDirectory;
UpnpDevice_Handle mDeviceHandle;
int mAnnounceMaxAge;
size_t mMaxContentLength;
diff --git a/plugins/provider/fileProvider/fileProvider.cpp b/plugins/provider/fileProvider/fileProvider.cpp
index cbc84c2..a60d772 100644
--- a/plugins/provider/fileProvider/fileProvider.cpp
+++ b/plugins/provider/fileProvider/fileProvider.cpp
@@ -6,6 +6,7 @@
*/
#include <plugin.h>
+#include <server.h>
#include <fstream>
#include <sstream>
#include <tools/string.h>
@@ -82,7 +83,7 @@ public:
: fileFD(NULL)
{
stringstream file;
- file << cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) << "/directories.conf";
+ file << cMediaServer::GetInstance()->GetConfigDirectory() << "/directories.conf";
Load(file.str());
}
diff --git a/plugins/provider/vdrProvider/vdrProvider.cpp b/plugins/provider/vdrProvider/vdrProvider.cpp
index 9a45690..c9b9a95 100644
--- a/plugins/provider/vdrProvider/vdrProvider.cpp
+++ b/plugins/provider/vdrProvider/vdrProvider.cpp
@@ -6,11 +6,14 @@
*/
#include <plugin.h>
+#include <server.h>
#include <vdr/epg.h>
#include <vdr/channels.h>
#include <vdr/tools.h>
+#include <vdr/plugin.h>
#include <string>
#include <sstream>
+#include <fstream>
#include <algorithm>
#include <tools.h>
#include <pwd.h>
@@ -22,7 +25,33 @@ namespace upnp {
class VdrProvider : public cUPnPResourceProvider {
private:
- time_t lastModified;
+ time_t lastModified;
+ int from;
+ int to;
+
+ bool Load(const string& filename)
+ {
+ if (access(filename.c_str(), F_OK) == 0) {
+ isyslog("loading %s", filename.c_str());
+ ifstream file;
+ file.open(filename.c_str(), ifstream::in);
+ if(!file.is_open())
+ return false;
+ string line; int pos;
+ while(getline(file, line)){
+ if(line.length() > 0 && line[0] != '#'){
+ if((pos = line.find_first_of('-')) != string::npos){
+ from = atoi(line.substr(0, pos).c_str());
+ to = atoi(line.substr(pos+1).c_str());
+ break;
+ }
+ }
+ }
+ if(to == 0) to = INT_MAX;
+ return true;
+ }
+ return false;
+ }
bool IsRootContainer(const string& uri){
if(uri.find(GetRootContainer(), 0) != 0){
@@ -51,7 +80,13 @@ public:
VdrProvider()
: lastModified(0)
- {}
+ , from(0)
+ , to(INT_MAX)
+ {
+ stringstream file;
+ file << cMediaServer::GetInstance()->GetConfigDirectory() << "/vdrProvider.conf";
+ Load(file.str());
+ }
virtual ~VdrProvider(){
Cancel(2);
@@ -69,9 +104,10 @@ public:
StringList list;
int index;
cChannel* channel = NULL;
+ if(to == 0) to = INT_MAX;
// Check if this is the root and we have no groups in the channels.conf:
if(uri.compare(GetRootContainer()) == 0 && Channels.GetNextGroup(0) == -1){
- for(index = Channels.GetNextNormal(-1); (channel = Channels.Get(index)); index = Channels.GetNextNormal(index)){
+ for(index = Channels.GetNextNormal(from - 1); (channel = Channels.Get(index)) && index < to; index = Channels.GetNextNormal(index)){
list.push_back(*channel->GetChannelID().ToString());
}
} else {
@@ -87,7 +123,7 @@ public:
}
}
} else {
- for(index = Channels.GetNextGroup(-1); (channel = Channels.Get(index)); index = Channels.GetNextGroup(index)){
+ for(index = Channels.GetNextGroup(from - 1); (channel = Channels.Get(index)) && index < to; index = Channels.GetNextGroup(index)){
string group = string(channel->Name()) + '/';
list.push_back(group);
}
diff --git a/server/server.cpp b/server/server.cpp
index b397a94..af2295a 100644
--- a/server/server.cpp
+++ b/server/server.cpp
@@ -169,6 +169,8 @@ bool cMediaServer::Initialize(){
string address;
uint16_t port = 0;
+ mConfigDirectory = cPlugin::ConfigDirectory(PLUGIN_NAME_I18N);
+
if(mCurrentConfiguration.expertSettings){
address = mCurrentConfiguration.bindToAddress
? mCurrentConfiguration.address