summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vdr-vdrmanager/handler.cpp10
-rw-r--r--vdr-vdrmanager/helpers.cpp39
-rw-r--r--vdr-vdrmanager/helpers.h2
3 files changed, 46 insertions, 5 deletions
diff --git a/vdr-vdrmanager/handler.cpp b/vdr-vdrmanager/handler.cpp
index c768007..43b500a 100644
--- a/vdr-vdrmanager/handler.cpp
+++ b/vdr-vdrmanager/handler.cpp
@@ -84,8 +84,14 @@ bool cHandler::HandleClientRequest(cVdrmanagerClientSocket * sock)
string text = cHelpers::GetRecordings(args);
sock->PutLine(text);
}
- else if(cmd == "DRECORDING"){
- string text = cHelpers::DelRecording(args);
+ else if(cmd == "DRECORDING")
+ {
+ string text = cHelpers::DelRecording(args);
+ sock->PutLine(text);
+ }
+ else if (cmd == "SETCHANNEL")
+ {
+ string text = cHelpers::SetChannel(args);
sock->PutLine(text);
}
else if (cmd == "QUIT")
diff --git a/vdr-vdrmanager/helpers.cpp b/vdr-vdrmanager/helpers.cpp
index 5a7e21e..4c8b1bd 100644
--- a/vdr-vdrmanager/helpers.cpp
+++ b/vdr-vdrmanager/helpers.cpp
@@ -34,6 +34,10 @@ string cHelpers::GetChannelEvents(string args) {
return SafeCall(GetEventsIntern, Trim(args), "");
}
+string cHelpers::SetChannel(string args) {
+ return SafeCall(SetChannelIntern, args);
+}
+
string cHelpers::GetTimeEvents(string args) {
args = Trim(args);
@@ -144,6 +148,31 @@ string cHelpers::GetChannelsIntern(string wantedChannels) {
return result + "END\r\n";
}
+string cHelpers::SetChannelIntern(string args) {
+
+ if (args.size() == 0) {
+ return "!ERROR:SetChannel;empty args\r\n";
+ }
+
+ int nr = atoi(args.c_str());
+ string result;
+ ostringstream outStream;
+
+ cChannel *channel = Channels.GetByNumber(nr);
+
+ if (channel) {
+ if (!cDevice::PrimaryDevice()->SwitchChannel(channel, true)) {
+ outStream << channel->Number();
+ result = "!ERROR:SetChannel;Error switching to channel " + outStream.str() + "\r\n";
+ return result;
+ } else {
+ return "START\r\nEND\r\n";
+ }
+ } else {
+ return "!ERROR:SetChannel;Unable to find channel " + args + "\r\n";
+ }
+}
+
string cHelpers::GetAudioTracks(const cChannel* channel) {
string result = "";
@@ -851,10 +880,14 @@ string cHelpers::UnMapSpecialChars(string text) {
*/
int cHelpers::RecordingLengthInSeconds(cRecording* recording) {
#if APIVERSNUM < 10721
- return -1;
-#endif
-
+ int nf=cIndexFile::Length(recording->FileName(), recording->IsPesRecording());
+ //esyslog("[vdrmanager] length of record %s: %d", recording->FileName(), length);
+ //if (length >= 0)
+ // return int(length / SecondsToFrames(60, recording->FramesPerSecond()));
+ //return -1;
+#else
int nf = recording->NumFrames();
+#endif
if (nf >= 0)
#if APIVERSNUM >= 10703
return int(((double) nf / recording->FramesPerSecond()));
diff --git a/vdr-vdrmanager/helpers.h b/vdr-vdrmanager/helpers.h
index 6019438..e006d96 100644
--- a/vdr-vdrmanager/helpers.h
+++ b/vdr-vdrmanager/helpers.h
@@ -22,6 +22,7 @@ public:
static string GetTimers(string args);
static string GetChannels(string args);
static string GetChannelEvents(string args);
+ static string SetChannel(string args);
static string GetTimeEvents(string args);
static string GetRecordings(string args);
static string DelRecording(string args);
@@ -39,6 +40,7 @@ private:
static string GetTimersIntern();
static string GetRecordingsIntern();
static string GetChannelsIntern(string wantedChannels);
+ static string SetChannelIntern(string wantedChannel);
static string GetEventsIntern(string wantedChannels, string when);
static string DelRecordingIntern(string index);
static string SetTimerIntern(string args);