1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

The new SVDRP commands 'LSTD' and 'PRIM' can be used to list all available devices and to switch the primary device

This commit is contained in:
Klaus Schmidinger 2017-11-11 12:04:17 +01:00
parent 950b248220
commit d19a3fc3b8
3 changed files with 55 additions and 2 deletions

View File

@ -3373,6 +3373,7 @@ Thomas Reufer <thomas@reufer.ch>
for adding cFont::Width(void) to get the default character width and allow stretched for adding cFont::Width(void) to get the default character width and allow stretched
font drawing in high level OSDs font drawing in high level OSDs
for fixing regenerating the index of audio recordings for fixing regenerating the index of audio recordings
for implementing the SVDRP commands 'LSTD' and 'PRIM'
Eike Sauer <EikeSauer@t-online.de> Eike Sauer <EikeSauer@t-online.de>
for reporting a problem with channels that need more than 5 TS packets for detecting for reporting a problem with channels that need more than 5 TS packets for detecting

View File

@ -9162,7 +9162,7 @@ Video Disk Recorder Revision History
a subdirectory. a subdirectory.
- SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details). - SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details).
2017-11-09: Version 2.3.9 2017-11-11: Version 2.3.9
- Updated the Italian OSD texts (thanks to Diego Pierotto). - Updated the Italian OSD texts (thanks to Diego Pierotto).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
@ -9196,3 +9196,5 @@ Video Disk Recorder Revision History
in case there is more than one timer that will record that event. in case there is more than one timer that will record that event.
- Switching the primary device is no longer done via osSwitchDvb (which has been - Switching the primary device is no longer done via osSwitchDvb (which has been
removed), but rather by the main program loop reacting to changes in Setup.PrimaryDVB. removed), but rather by the main program loop reacting to changes in Setup.PrimaryDVB.
- The new SVDRP commands 'LSTD' and 'PRIM' can be used to list all available devices
and to switch the primary device (thanks to Thomas Reufer).

52
svdrp.c
View File

@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured * and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection. * graphical interface that sits on top of an SVDRP connection.
* *
* $Id: svdrp.c 4.22 2017/06/30 09:49:39 kls Exp $ * $Id: svdrp.c 4.23 2017/11/11 12:04:17 kls Exp $
*/ */
#include "svdrp.h" #include "svdrp.h"
@ -771,6 +771,10 @@ const char *HelpPages[] = {
" separators. The channel number of a group separator is always 0.\n" " separators. The channel number of a group separator is always 0.\n"
" With ':ids' the channel ids are listed following the channel numbers.\n" " With ':ids' the channel ids are listed following the channel numbers.\n"
" The special number 0 can be given to list the current channel.", " The special number 0 can be given to list the current channel.",
"LSTD\n"
" List all available devices. Each device is listed with its name and\n"
" whether it is currently the primary device ('P') or it implements a\n"
" decoder ('D') and can be used as output device.",
"LSTE [ <channel> ] [ now | next | at <time> ]\n" "LSTE [ <channel> ] [ now | next | at <time> ]\n"
" List EPG data. Without any parameters all data of all channels is\n" " List EPG data. Without any parameters all data of all channels is\n"
" listed. If a channel is given (either by number or by channel ID),\n" " listed. If a channel is given (either by number or by channel ID),\n"
@ -851,6 +855,10 @@ const char *HelpPages[] = {
" Used by peer-to-peer connections between VDRs to inform other machines\n" " Used by peer-to-peer connections between VDRs to inform other machines\n"
" about changes to timers. The receiving VDR shall use LSTT to query the\n" " about changes to timers. The receiving VDR shall use LSTT to query the\n"
" remote machine's timers and update its list of timers accordingly.\n", " remote machine's timers and update its list of timers accordingly.\n",
"PRIM [ <number> ]\n"
" Make the device with the given number the primary device.\n"
" Without option it returns the currently active primary device in the same\n"
" format as used by the LSTD command.",
"PUTE [ file ]\n" "PUTE [ file ]\n"
" Put data into the EPG list. The data entered has to strictly follow the\n" " Put data into the EPG list. The data entered has to strictly follow the\n"
" format defined in vdr(5) for the 'epg.data' file. A '.' on a line\n" " format defined in vdr(5) for the 'epg.data' file. A '.' on a line\n"
@ -964,6 +972,7 @@ private:
void CmdHELP(const char *Option); void CmdHELP(const char *Option);
void CmdHITK(const char *Option); void CmdHITK(const char *Option);
void CmdLSTC(const char *Option); void CmdLSTC(const char *Option);
void CmdLSTD(const char *Option);
void CmdLSTE(const char *Option); void CmdLSTE(const char *Option);
void CmdLSTR(const char *Option); void CmdLSTR(const char *Option);
void CmdLSTT(const char *Option); void CmdLSTT(const char *Option);
@ -979,6 +988,7 @@ private:
void CmdPLAY(const char *Option); void CmdPLAY(const char *Option);
void CmdPLUG(const char *Option); void CmdPLUG(const char *Option);
void CmdPOLL(const char *Option); void CmdPOLL(const char *Option);
void CmdPRIM(const char *Option);
void CmdPUTE(const char *Option); void CmdPUTE(const char *Option);
void CmdREMO(const char *Option); void CmdREMO(const char *Option);
void CmdSCAN(const char *Option); void CmdSCAN(const char *Option);
@ -1620,6 +1630,18 @@ void cSVDRPServer::CmdLSTC(const char *Option)
Reply(550, "No channels defined"); Reply(550, "No channels defined");
} }
void cSVDRPServer::CmdLSTD(const char *Option)
{
if (cDevice::NumDevices()) {
for (int i = 0; i < cDevice::NumDevices(); i++) {
if (const cDevice *d = cDevice::GetDevice(i))
Reply(d->DeviceNumber() + 1 == cDevice::NumDevices() ? 250 : -250, "%d [%s%s] %s", d->DeviceNumber() + 1, d->HasDecoder() ? "D" : "-", d->DeviceNumber() + 1 == Setup.PrimaryDVB ? "P" : "-", *d->DeviceName());
}
}
else
Reply(550, "No devices found");
}
void cSVDRPServer::CmdLSTE(const char *Option) void cSVDRPServer::CmdLSTE(const char *Option)
{ {
LOCK_CHANNELS_READ; LOCK_CHANNELS_READ;
@ -2216,6 +2238,32 @@ void cSVDRPServer::CmdPOLL(const char *Option)
Reply(501, "Missing parameters"); Reply(501, "Missing parameters");
} }
void cSVDRPServer::CmdPRIM(const char *Option)
{
int n = -1;
if (*Option) {
if (isnumber(Option)) {
int o = strtol(Option, NULL, 10);
if (o > 0 && o <= cDevice::NumDevices())
n = o;
else
Reply(501, "Invalid device number \"%s\"", Option);
}
else
Reply(501, "Invalid parameter \"%s\"", Option);
if (n >= 0) {
Setup.PrimaryDVB = n;
Reply(250, "Primary device set to %d", n);
}
}
else {
if (const cDevice *d = cDevice::PrimaryDevice())
Reply(250, "%d [%s%s] %s", d->DeviceNumber() + 1, d->HasDecoder() ? "D" : "-", d->DeviceNumber() + 1 == Setup.PrimaryDVB ? "P" : "-", *d->DeviceName());
else
Reply(501, "Failed to get primary device");
}
}
void cSVDRPServer::CmdPUTE(const char *Option) void cSVDRPServer::CmdPUTE(const char *Option)
{ {
if (*Option) { if (*Option) {
@ -2368,6 +2416,7 @@ void cSVDRPServer::Execute(char *Cmd)
else if (CMD("HELP")) CmdHELP(s); else if (CMD("HELP")) CmdHELP(s);
else if (CMD("HITK")) CmdHITK(s); else if (CMD("HITK")) CmdHITK(s);
else if (CMD("LSTC")) CmdLSTC(s); else if (CMD("LSTC")) CmdLSTC(s);
else if (CMD("LSTD")) CmdLSTD(s);
else if (CMD("LSTE")) CmdLSTE(s); else if (CMD("LSTE")) CmdLSTE(s);
else if (CMD("LSTR")) CmdLSTR(s); else if (CMD("LSTR")) CmdLSTR(s);
else if (CMD("LSTT")) CmdLSTT(s); else if (CMD("LSTT")) CmdLSTT(s);
@ -2383,6 +2432,7 @@ void cSVDRPServer::Execute(char *Cmd)
else if (CMD("PLAY")) CmdPLAY(s); else if (CMD("PLAY")) CmdPLAY(s);
else if (CMD("PLUG")) CmdPLUG(s); else if (CMD("PLUG")) CmdPLUG(s);
else if (CMD("POLL")) CmdPOLL(s); else if (CMD("POLL")) CmdPOLL(s);
else if (CMD("PRIM")) CmdPRIM(s);
else if (CMD("PUTE")) CmdPUTE(s); else if (CMD("PUTE")) CmdPUTE(s);
else if (CMD("REMO")) CmdREMO(s); else if (CMD("REMO")) CmdREMO(s);
else if (CMD("SCAN")) CmdSCAN(s); else if (CMD("SCAN")) CmdSCAN(s);