diff options
author | lado <herrlado@gmail.com> | 2012-04-29 22:48:34 +0200 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2012-04-29 22:48:34 +0200 |
commit | 3b9bafa7c95e79fb4bd2a88f56fc6d594b0f9860 (patch) | |
tree | fb8a44a8d6b26f7f9726264ff9b81a08a16043ec /vdr-vdrmanager | |
parent | d48b577683a6f1992a8bac65d8e5e3365fd55cef (diff) | |
download | vdr-manager-3b9bafa7c95e79fb4bd2a88f56fc6d594b0f9860.tar.gz vdr-manager-3b9bafa7c95e79fb4bd2a88f56fc6d594b0f9860.tar.bz2 |
Feature #951
Bug #950
Diffstat (limited to 'vdr-vdrmanager')
-rw-r--r-- | vdr-vdrmanager/handler.cpp | 10 | ||||
-rw-r--r-- | vdr-vdrmanager/helpers.cpp | 39 | ||||
-rw-r--r-- | vdr-vdrmanager/helpers.h | 2 |
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); |