summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httptnt/resourceStreamer.ecpp9
-rw-r--r--include/plugin.h3
-rw-r--r--include/tools.h1
-rw-r--r--plugins/profiler/vdrDVBProfiler/channelTitle.conf6
-rw-r--r--plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp89
5 files changed, 99 insertions, 9 deletions
diff --git a/httptnt/resourceStreamer.ecpp b/httptnt/resourceStreamer.ecpp
index 8b6c9f3..3af5768 100644
--- a/httptnt/resourceStreamer.ecpp
+++ b/httptnt/resourceStreamer.ecpp
@@ -45,7 +45,14 @@ using namespace upnp;
if(contentLength > 0){
reply.setContentLengthHeader(contentLength);
- if(streamer->Seekable()) reply.setHeader("Accept-Ranges ", "bytes");
+ if(streamer->Seekable()){
+ reply.setHeader("Accept-Ranges ", "bytes");
+ if(request.hasHeader("getAvailableSeekRange.dlna.org:")){
+ std::stringstream availableRangeHeader;
+ availableRangeHeader << "0 bytes=0-" << contentLength;
+ reply.setHeader("availableSeekRange.dlna.org ", availableRangeHeader.str());
+ }
+ }
if(request.hasHeader("Range:")){
std::string rangeRequest = request.getHeader("Range:");
diff --git a/include/plugin.h b/include/plugin.h
index dfd1ab9..beb24bf 100644
--- a/include/plugin.h
+++ b/include/plugin.h
@@ -434,7 +434,6 @@ public:
virtual void Close();
protected:
-
/**
* Called whenever a container was changed.
*
@@ -546,7 +545,7 @@ public:
* false, if not.
*/
virtual bool GetMetadata(const string& uri, cMetadata& metadata) = 0;
-protected:
+
};
} // namespace upnp
diff --git a/include/tools.h b/include/tools.h
index a92b8a2..4c6908d 100644
--- a/include/tools.h
+++ b/include/tools.h
@@ -34,6 +34,7 @@ namespace upnp {
typedef std::list<std::string> StringList;
typedef std::vector<std::string> StringVector;
+ typedef std::map<std::string, std::string> StringMap;
typedef std::map<std::string, uint32_t> IdList;
}
diff --git a/plugins/profiler/vdrDVBProfiler/channelTitle.conf b/plugins/profiler/vdrDVBProfiler/channelTitle.conf
new file mode 100644
index 0000000..eccea7a
--- /dev/null
+++ b/plugins/profiler/vdrDVBProfiler/channelTitle.conf
@@ -0,0 +1,6 @@
+# This is the channel title configuration
+# %chan% - replaced with the channel name
+# %no% - replaced with the channel number
+# %title% - replaced with the event title
+
+%no% %chan%: %title% \ No newline at end of file
diff --git a/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp b/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp
index 8d41354..1caaf8b 100644
--- a/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp
+++ b/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp
@@ -13,6 +13,8 @@
#include <vdr/epg.h>
#include <vdr/tools.h>
#include <vdr/remux.h>
+#include <vdr/config.h>
+#include <vdr/plugin.h>
#include <plugin.h>
#include <tools.h>
#include <string>
@@ -25,8 +27,70 @@ using namespace std;
namespace upnp {
+class ChannelTitle : public cListObject {
+private:
+ int channelNo;
+ string channelName;
+ string title;
+ string pattern;
+
+ void replaceAll(std::string& str, const std::string& from, const std::string& to) {
+ if(from.empty())
+ return;
+ size_t start_pos = 0;
+ while((start_pos = str.find(from, start_pos)) != std::string::npos) {
+ str.replace(start_pos, from.length(), to);
+ start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
+ }
+ }
+public:
+ ChannelTitle()
+ : channelNo(-1)
+ , pattern("%chan% - %title%")
+ {}
+ void Clear(){
+ channelNo = -1;
+ channelName = string();
+ title = string();
+ }
+ void SetChannelNumber(int no){ channelNo = no; }
+ void SetChannelName(const string& name){ channelName = name; }
+ void SetTitle(const string& t){ title = t; }
+ string ToString(){
+ string output = pattern;
+ if(channelNo > 0)
+ replaceAll(output, "%no%", tools::ToString(channelNo));
+ else
+ replaceAll(output, "%no%", "");
+ if(!channelName.empty())
+ replaceAll(output, "%chan%", channelName);
+ else
+ replaceAll(output, "%chan%", "");
+ if(!title.empty())
+ replaceAll(output, "%title%", title);
+ else
+ replaceAll(output, "%title%", "");
+
+ return output;
+ }
+ bool Parse(const char* str){
+ if(!str || strcmp(str, "") == 0){
+ pattern = "%chan% - %title%";
+ } else {
+ pattern = str;
+ }
+ return true;
+ }
+};
+
class DVBProfiler : public cMediaProfiler {
public:
+ DVBProfiler(){
+ stringstream file;
+ file << cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) << "/channelTitle.conf";
+ channelTitleConfig.Load(file.str().c_str(), true);
+ }
+
virtual bool CanHandleSchema(const string& schema){
if(schema.find("vdr",0) == 0 || schema.find("rec",0) == 0){
return true;
@@ -45,6 +109,8 @@ public:
}
}
+ ::cConfig<ChannelTitle> channelTitleConfig;
+
private:
bool GetRecordingMetadata(const string& u, cMetadata& metadata){
@@ -240,10 +306,6 @@ private:
const cEvent* event = (schedule) ? schedule->GetPresentEvent() : NULL;
if(event){
- stringstream title;
- title << channel->Name() << ": " << event->Title();
- metadata.SetProperty(cMetadata::Property(property::object::KEY_TITLE, title.str()));
-
boost::posix_time::ptime startTime, endTime;
startTime = boost::posix_time::from_time_t(event->StartTime());
endTime = boost::posix_time::from_time_t(event->EndTime());
@@ -253,10 +315,25 @@ private:
metadata.SetProperty(cMetadata::Property(property::object::KEY_SCHEDULED_END, boost::posix_time::to_iso_extended_string(endTime)));
metadata.SetProperty(cMetadata::Property(property::object::KEY_DESCRIPTION, string(event->ShortText()?event->ShortText():"")));
metadata.SetProperty(cMetadata::Property(property::object::KEY_LONG_DESCRIPTION, string(event->Description()?event->Description():"")));
- } else {
- metadata.SetProperty(cMetadata::Property(property::object::KEY_TITLE, string(channel->Name())));
}
+ ChannelTitle* titleConfig = channelTitleConfig.First();
+ if(titleConfig){
+ titleConfig->Clear();
+ if(event)
+ titleConfig->SetTitle(event->Title());
+ titleConfig->SetChannelName(channel->Name());
+ titleConfig->SetChannelNumber(channel->Number());
+
+ metadata.SetProperty(cMetadata::Property(property::object::KEY_TITLE, titleConfig->ToString()));
+ } else {
+ stringstream ss;
+ ss << channel->Name();
+ if(event)
+ ss << " - " << event->Title();
+ metadata.SetProperty(cMetadata::Property(property::object::KEY_TITLE, ss.str()));
+ }
+
cMetadata::Resource resource;
resource.SetResourceUri(uri);