blob: bcf06a49a00a5206f56943a84fe85a68e3cda985 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* vdrProvider.cpp
*
* Created on: 01.10.2012
* Author: savop
*/
#include <plugin.h>
#include <vdr/channels.h>
#include <vdr/tools.h>
#include <vdr/config.h>
#include <string>
#include <sstream>
#include <tools.h>
#include <vdr/thread.h>
using namespace std;
namespace upnp {
class VdrProvider : public cUPnPResourceProvider, cThread {
private:
int lastUpdateID;
public:
VdrProvider()
: lastUpdateID(0)
{}
virtual string ProvidesSchema(){ return "vdr"; }
virtual string GetRootContainer(){
return ProvidesSchema() + "://";
}
virtual cUPnPResourceProvider::EntryList GetContainerEntries(const string& uri){
if(uri.find(GetRootContainer(), 0) != 0){
isyslog("VdrProvider\tUri does not contain the root.");
return cUPnPResourceProvider::EntryList();
}
EntryList list;
// Check if this is the root:
if(uri.compare(GetRootContainer()) == 0){
cChannel* channel = NULL;
for(int index = 0; (channel = Channels.Get(index)); index = Channels.GetNextNormal(index)){
if(!channel->GroupSep()){
list.push_back(*channel->GetChannelID().ToString());
}
}
}
return list;
}
virtual bool IsContainer(const string& uri){
return uri.compare(GetRootContainer()) == 0;
}
virtual bool IsLink(const string& uri, string& target){
// TODO: what are Channel::RefChannel or LinkChannels ?
return false;
}
virtual long GetContainerUpdateId(const string&){
// TODO: provide a container update id
return lastUpdateID;
}
virtual bool GetMetadata(const string& uri, cMetadata& metadata){
if(uri.find(GetRootContainer(), 0) != 0){
isyslog("VdrProvider\tUri does not contain the root.");
return false;
}
return false;
}
virtual string GetHTTPUri(const string& uri, const string& currentIP){
if(uri.find(GetRootContainer(), 0) != 0){
isyslog("VdrProvider\tUri does not contain the root.");
return string();
}
int port = 3000;
stringstream ss;
ss << "http://" << currentIP << ":" << port << "/TS/" << uri.substr(6);
return ss.str();
}
virtual void Action(){
}
};
UPNP_REGISTER_RESOURCE_PROVIDER(VdrProvider);
} // namespace upnp
|