vdr 2.6.4
vdr.c
Go to the documentation of this file.
1/*
2 * vdr.c: Video Disk Recorder main program
3 *
4 * Copyright (C) 2000-2021 Klaus Schmidinger
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 *
21 * The author can be reached at vdr@tvdr.de
22 *
23 * The project's page is at http://www.tvdr.de
24 *
25 * $Id: vdr.c 5.12 2022/12/19 15:13:56 kls Exp $
26 */
27
28#include <getopt.h>
29#include <grp.h>
30#include <langinfo.h>
31#include <locale.h>
32#include <malloc.h>
33#include <pwd.h>
34#include <signal.h>
35#include <stdlib.h>
36#include <sys/capability.h>
37#include <sys/prctl.h>
38#ifdef SDNOTIFY
39#include <systemd/sd-daemon.h>
40#endif
41#include <termios.h>
42#include <unistd.h>
43#include "args.h"
44#include "audio.h"
45#include "channels.h"
46#include "config.h"
47#include "cutter.h"
48#include "device.h"
49#include "diseqc.h"
50#include "dvbdevice.h"
51#include "eitscan.h"
52#include "epg.h"
53#include "i18n.h"
54#include "interface.h"
55#include "keys.h"
56#include "libsi/si.h"
57#include "lirc.h"
58#include "menu.h"
59#include "osdbase.h"
60#include "plugin.h"
61#include "recording.h"
62#include "shutdown.h"
63#include "skinclassic.h"
64#include "skinlcars.h"
65#include "skinsttng.h"
66#include "sourceparams.h"
67#include "sources.h"
68#include "status.h"
69#include "svdrp.h"
70#include "themes.h"
71#include "timers.h"
72#include "tools.h"
73#include "transfer.h"
74#include "videodir.h"
75
76#define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings
77#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
78#define MEMCLEANUPDELTA 3600 // seconds between memory cleanups
79#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
80#define SHUTDOWNRETRY 360 // seconds before trying again to shut down
81#define SHUTDOWNFORCEPROMPT 5 // seconds to wait in user prompt to allow forcing shutdown
82#define SHUTDOWNCANCELPROMPT 5 // seconds to wait in user prompt to allow canceling shutdown
83#define RESTARTCANCELPROMPT 5 // seconds to wait in user prompt before restarting on SIGHUP
84#define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start
85#define CHANNELSAVEDELTA 600 // seconds before saving channels.conf after automatic modifications
86#define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready
87#define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed
88#define TIMERCHECKDELTA 10 // seconds between checks for timers that need to see their channel
89#define TIMERDEVICETIMEOUT 8 // seconds before a device used for timer check may be reused
90#define TIMERLOOKAHEADTIME 60 // seconds before a non-VPS timer starts and the channel is switched if possible
91#define VPSLOOKAHEADTIME 24 // hours within which VPS timers will make sure their events are up to date
92#define VPSUPTODATETIME 3600 // seconds before the event or schedule of a VPS timer needs to be refreshed
93
94#define EXIT(v) { ShutdownHandler.Exit(v); goto Exit; }
95
96static int LastSignal = 0;
97
98static bool SetUser(const char *User, bool UserDump)
99{
100 if (User) {
101 struct passwd *user = isnumber(User) ? getpwuid(atoi(User)) : getpwnam(User);
102 if (!user) {
103 fprintf(stderr, "vdr: unknown user: '%s'\n", User);
104 return false;
105 }
106 if (setgid(user->pw_gid) < 0) {
107 fprintf(stderr, "vdr: cannot set group id %u: %s\n", (unsigned int)user->pw_gid, strerror(errno));
108 return false;
109 }
110 if (initgroups(user->pw_name, user->pw_gid) < 0) {
111 fprintf(stderr, "vdr: cannot set supplemental group ids for user %s: %s\n", user->pw_name, strerror(errno));
112 return false;
113 }
114 if (setuid(user->pw_uid) < 0) {
115 fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
116 return false;
117 }
118 if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
119 fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno));
120 setenv("HOME", user->pw_dir, 1);
121 setenv("USER", user->pw_name, 1);
122 setenv("LOGNAME", user->pw_name, 1);
123 setenv("SHELL", user->pw_shell, 1);
124 }
125 return true;
126}
127
128static bool DropCaps(void)
129{
130 // drop all capabilities except selected ones
131 cap_t caps_all = cap_get_proc();
132 if (!caps_all) {
133 fprintf(stderr, "vdr: cap_get_proc failed: %s\n", strerror(errno));
134 return false;
135 }
136 cap_flag_value_t cap_flag_value;
137 if (cap_get_flag(caps_all, CAP_SYS_TIME, CAP_PERMITTED , &cap_flag_value)) {
138 fprintf(stderr, "vdr: cap_get_flag failed: %s\n", strerror(errno));
139 return false;
140 }
141 cap_t caps;
142 if (cap_flag_value == CAP_SET)
143 caps = cap_from_text("= cap_sys_nice,cap_sys_time,cap_net_raw=ep");
144 else {
145 fprintf(stdout,"vdr: OS does not support cap_sys_time\n");
146 caps = cap_from_text("= cap_sys_nice,cap_net_raw=ep");
147 }
148 if (!caps) {
149 fprintf(stderr, "vdr: cap_from_text failed: %s\n", strerror(errno));
150 return false;
151 }
152 if (cap_set_proc(caps) == -1) {
153 fprintf(stderr, "vdr: cap_set_proc failed: %s\n", strerror(errno));
154 cap_free(caps);
155 return false;
156 }
157 cap_free(caps);
158 return true;
159}
160
161static bool SetKeepCaps(bool On)
162{
163 // set keeping capabilities during setuid() on/off
164 if (prctl(PR_SET_KEEPCAPS, On ? 1 : 0, 0, 0, 0) != 0) {
165 fprintf(stderr, "vdr: prctl failed\n");
166 return false;
167 }
168 return true;
169}
170
171static void SignalHandler(int signum)
172{
173 switch (signum) {
174 case SIGPIPE:
175 break;
176 case SIGHUP:
177 LastSignal = signum;
178 break;
179 default:
180 LastSignal = signum;
183 }
184 signal(signum, SignalHandler);
185}
186
187static void Watchdog(int signum)
188{
189 // Something terrible must have happened that prevented the 'alarm()' from
190 // being called in time, so let's get out of here:
191 esyslog("PANIC: watchdog timer expired - exiting!");
192#ifdef SDNOTIFY
193 sd_notify(0, "STOPPING=1\nSTATUS=PANIC");
194#endif
195 exit(1);
196}
197
198int main(int argc, char *argv[])
199{
200 // Save terminal settings:
201
202 struct termios savedTm;
203 bool HasStdin = (tcgetpgrp(STDIN_FILENO) == getpid() || getppid() != (pid_t)1) && tcgetattr(STDIN_FILENO, &savedTm) == 0;
204
205 // Initiate locale:
206
207 setlocale(LC_ALL, "");
208
209 // Command line options:
210
211#define dd(a, b) (*a ? a : b)
212#define DEFAULTSVDRPPORT 6419
213#define DEFAULTWATCHDOG 0 // seconds
214#define DEFAULTVIDEODIR VIDEODIR
215#define DEFAULTCONFDIR dd(CONFDIR, VideoDirectory)
216#define DEFAULTARGSDIR dd(ARGSDIR, "/etc/vdr/conf.d")
217#define DEFAULTCACHEDIR dd(CACHEDIR, VideoDirectory)
218#define DEFAULTRESDIR dd(RESDIR, ConfigDirectory)
219#define DEFAULTPLUGINDIR PLUGINDIR
220#define DEFAULTLOCDIR LOCDIR
221#define DEFAULTEPGDATAFILENAME "epg.data"
222
223 bool StartedAsRoot = false;
224 const char *VdrUser = NULL;
225 bool UserDump = false;
226 int SVDRPport = DEFAULTSVDRPPORT;
227 const char *AudioCommand = NULL;
228 const char *VideoDirectory = DEFAULTVIDEODIR;
229 const char *ConfigDirectory = NULL;
230 const char *CacheDirectory = NULL;
231 const char *ResourceDirectory = NULL;
232 const char *LocaleDirectory = DEFAULTLOCDIR;
233 const char *EpgDataFileName = DEFAULTEPGDATAFILENAME;
234 bool DisplayHelp = false;
235 bool DisplayVersion = false;
236 bool DaemonMode = false;
237 int SysLogTarget = LOG_USER;
238 bool MuteAudio = false;
239 int WatchdogTimeout = DEFAULTWATCHDOG;
240 const char *Terminal = NULL;
241 const char *OverrideCharacterTable = NULL;
242
243 bool UseKbd = true;
244 const char *LircDevice = NULL;
245#if !defined(REMOTE_KBD)
246 UseKbd = false;
247#endif
248#if defined(REMOTE_LIRC)
249 LircDevice = LIRC_DEVICE;
250#endif
251#if defined(VDR_USER)
252 VdrUser = VDR_USER;
253#endif
254#ifdef SDNOTIFY
255 time_t SdWatchdog = 0;
256 int SdWatchdogTimeout = 0;
257#endif
258
259 cArgs *Args = NULL;
260 if (argc == 1) {
261 Args = new cArgs(argv[0]);
262 if (Args->ReadDirectory(DEFAULTARGSDIR)) {
263 argc = Args->GetArgc();
264 argv = Args->GetArgv();
265 }
266 }
267
268 cVideoDirectory::SetName(VideoDirectory);
269 cPluginManager PluginManager(DEFAULTPLUGINDIR);
270
271 static struct option long_options[] = {
272 { "audio", required_argument, NULL, 'a' },
273 { "cachedir", required_argument, NULL, 'c' | 0x100 },
274 { "chartab", required_argument, NULL, 'c' | 0x200 },
275 { "config", required_argument, NULL, 'c' },
276 { "daemon", no_argument, NULL, 'd' },
277 { "device", required_argument, NULL, 'D' },
278 { "dirnames", required_argument, NULL, 'd' | 0x100 },
279 { "edit", required_argument, NULL, 'e' | 0x100 },
280 { "epgfile", required_argument, NULL, 'E' },
281 { "filesize", required_argument, NULL, 'f' | 0x100 },
282 { "genindex", required_argument, NULL, 'g' | 0x100 },
283 { "grab", required_argument, NULL, 'g' },
284 { "help", no_argument, NULL, 'h' },
285 { "instance", required_argument, NULL, 'i' },
286 { "lib", required_argument, NULL, 'L' },
287 { "lirc", optional_argument, NULL, 'l' | 0x100 },
288 { "localedir",required_argument, NULL, 'l' | 0x200 },
289 { "log", required_argument, NULL, 'l' },
290 { "mute", no_argument, NULL, 'm' },
291 { "no-kbd", no_argument, NULL, 'n' | 0x100 },
292 { "plugin", required_argument, NULL, 'P' },
293 { "port", required_argument, NULL, 'p' },
294 { "record", required_argument, NULL, 'r' },
295 { "resdir", required_argument, NULL, 'r' | 0x100 },
296 { "showargs", optional_argument, NULL, 's' | 0x200 },
297 { "shutdown", required_argument, NULL, 's' },
298 { "split", no_argument, NULL, 's' | 0x100 },
299 { "terminal", required_argument, NULL, 't' },
300 { "updindex", required_argument, NULL, 'u' | 0x200 },
301 { "user", required_argument, NULL, 'u' },
302 { "userdump", no_argument, NULL, 'u' | 0x100 },
303 { "version", no_argument, NULL, 'V' },
304 { "vfat", no_argument, NULL, 'v' | 0x100 },
305 { "video", required_argument, NULL, 'v' },
306 { "watchdog", required_argument, NULL, 'w' },
307 { NULL, no_argument, NULL, 0 }
308 };
309
310 int c;
311 while ((c = getopt_long(argc, argv, "a:c:dD:e:E:g:hi:l:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
312 switch (c) {
313 case 'a': AudioCommand = optarg;
314 break;
315 case 'c' | 0x100:
316 CacheDirectory = optarg;
317 break;
318 case 'c' | 0x200:
319 OverrideCharacterTable = optarg;
320 break;
321 case 'c': ConfigDirectory = optarg;
322 break;
323 case 'd': DaemonMode = true;
324 break;
325 case 'D': if (*optarg == '-') {
327 break;
328 }
329 if (isnumber(optarg)) {
330 int n = atoi(optarg);
331 if (0 <= n && n < MAXDEVICES) {
333 break;
334 }
335 }
336 fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
337 return 2;
338 case 'd' | 0x100: {
339 char *s = optarg;
340 if (*s != ',') {
341 int n = strtol(s, &s, 10);
342 if (n <= 0 || n >= PATH_MAX) { // PATH_MAX includes the terminating 0
343 fprintf(stderr, "vdr: invalid directory path length: %s\n", optarg);
344 return 2;
345 }
347 if (!*s)
348 break;
349 if (*s != ',') {
350 fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
351 return 2;
352 }
353 }
354 s++;
355 if (!*s)
356 break;
357 if (*s != ',') {
358 int n = strtol(s, &s, 10);
359 if (n <= 0 || n > NAME_MAX) { // NAME_MAX excludes the terminating 0
360 fprintf(stderr, "vdr: invalid directory name length: %s\n", optarg);
361 return 2;
362 }
364 if (!*s)
365 break;
366 if (*s != ',') {
367 fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
368 return 2;
369 }
370 }
371 s++;
372 if (!*s)
373 break;
374 int n = strtol(s, &s, 10);
375 if (n != 0 && n != 1) {
376 fprintf(stderr, "vdr: invalid directory encoding: %s\n", optarg);
377 return 2;
378 }
380 if (*s) {
381 fprintf(stderr, "vdr: unexpected data: %s\n", optarg);
382 return 2;
383 }
384 }
385 break;
386 case 'e' | 0x100:
387 return CutRecording(optarg) ? 0 : 2;
388 case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
389 break;
390 case 'f' | 0x100:
396 break;
397 case 'g' | 0x100:
398 return GenerateIndex(optarg) ? 0 : 2;
399 case 'g': SetSVDRPGrabImageDir(*optarg != '-' ? optarg : NULL);
400 break;
401 case 'h': DisplayHelp = true;
402 break;
403 case 'i': if (isnumber(optarg)) {
404 InstanceId = atoi(optarg);
405 if (InstanceId >= 0)
406 break;
407 }
408 fprintf(stderr, "vdr: invalid instance id: %s\n", optarg);
409 return 2;
410 case 'l': {
411 char *p = strchr(optarg, '.');
412 if (p)
413 *p = 0;
414 if (isnumber(optarg)) {
415 int l = atoi(optarg);
416 if (0 <= l && l <= 3) {
417 SysLogLevel = l;
418 if (!p)
419 break;
420 *p = '.';
421 if (isnumber(p + 1)) {
422 int l = atoi(p + 1);
423 if (0 <= l && l <= 7) {
424 int targets[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
425 SysLogTarget = targets[l];
426 break;
427 }
428 }
429 }
430 }
431 if (p)
432 *p = '.';
433 fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
434 return 2;
435 }
436 case 'L': if (access(optarg, R_OK | X_OK) == 0)
437 PluginManager.SetDirectory(optarg);
438 else {
439 fprintf(stderr, "vdr: can't access plugin directory: %s\n", optarg);
440 return 2;
441 }
442 break;
443 case 'l' | 0x100:
444 LircDevice = optarg ? optarg : LIRC_DEVICE;
445 break;
446 case 'l' | 0x200:
447 if (access(optarg, R_OK | X_OK) == 0)
448 LocaleDirectory = optarg;
449 else {
450 fprintf(stderr, "vdr: can't access locale directory: %s\n", optarg);
451 return 2;
452 }
453 break;
454 case 'm': MuteAudio = true;
455 break;
456 case 'n' | 0x100:
457 UseKbd = false;
458 break;
459 case 'p': if (isnumber(optarg))
460 SVDRPport = atoi(optarg);
461 else {
462 fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
463 return 2;
464 }
465 break;
466 case 'P': PluginManager.AddPlugin(optarg);
467 break;
468 case 'r': cRecordingUserCommand::SetCommand(optarg);
469 break;
470 case 'r' | 0x100:
471 ResourceDirectory = optarg;
472 break;
473 case 's': ShutdownHandler.SetShutdownCommand(optarg);
474 break;
475 case 's' | 0x100:
477 break;
478 case 's' | 0x200: {
479 const char *ArgsDir = optarg ? optarg : DEFAULTARGSDIR;
480 cArgs Args(argv[0]);
481 if (!Args.ReadDirectory(ArgsDir)) {
482 fprintf(stderr, "vdr: can't read arguments from directory: %s\n", ArgsDir);
483 return 2;
484 }
485 int c = Args.GetArgc();
486 char **v = Args.GetArgv();
487 for (int i = 1; i < c; i++)
488 printf("%s\n", v[i]);
489 return 0;
490 }
491 case 't': Terminal = optarg;
492 if (access(Terminal, R_OK | W_OK) < 0) {
493 fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal);
494 return 2;
495 }
496 break;
497 case 'u': if (*optarg)
498 VdrUser = optarg;
499 break;
500 case 'u' | 0x100:
501 UserDump = true;
502 break;
503 case 'u' | 0x200:
504 return GenerateIndex(optarg, true) ? 0 : 2;
505 case 'V': DisplayVersion = true;
506 break;
507 case 'v' | 0x100:
508 DirectoryPathMax = 250;
509 DirectoryNameMax = 40;
510 DirectoryEncoding = true;
511 break;
512 case 'v': VideoDirectory = optarg;
513 while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
514 optarg[strlen(optarg) - 1] = 0;
515 cVideoDirectory::SetName(VideoDirectory);
516 break;
517 case 'w': if (isnumber(optarg)) {
518 int t = atoi(optarg);
519 if (t >= 0) {
520 WatchdogTimeout = t;
521 break;
522 }
523 }
524 fprintf(stderr, "vdr: invalid watchdog timeout: %s\n", optarg);
525 return 2;
526 default: return 2;
527 }
528 }
529
530 // Help and version info:
531
532 if (DisplayHelp || DisplayVersion) {
533 if (!PluginManager.HasPlugins())
534 PluginManager.AddPlugin("*"); // adds all available plugins
535 PluginManager.LoadPlugins();
536 if (DisplayHelp) {
537 printf("Usage: vdr [OPTIONS]\n\n" // for easier orientation, this is column 80|
538 " -a CMD, --audio=CMD send Dolby Digital audio to stdin of command CMD\n"
539 " --cachedir=DIR save cache files in DIR (default: %s)\n"
540 " --chartab=CHARACTER_TABLE\n"
541 " set the character table to use for strings in the\n"
542 " DVB data stream that don't begin with a character\n"
543 " table indicator, but don't use the standard default\n"
544 " character table (for instance ISO-8859-9)\n"
545 " -c DIR, --config=DIR read config files from DIR (default: %s)\n"
546 " -d, --daemon run in daemon mode\n"
547 " -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
548 " there may be several -D options (default: all DVB\n"
549 " devices will be used); if -D- is given, no DVB\n"
550 " devices will be used at all, independent of any\n"
551 " other -D options\n"
552 " --dirnames=PATH[,NAME[,ENC]]\n"
553 " set the maximum directory path length to PATH\n"
554 " (default: %d); if NAME is also given, it defines\n"
555 " the maximum directory name length (default: %d);\n"
556 " the optional ENC can be 0 or 1, and controls whether\n"
557 " special characters in directory names are encoded as\n"
558 " hex values (default: 0); if PATH or NAME are left\n"
559 " empty (as in \",,1\" to only set ENC), the defaults\n"
560 " apply\n"
561 " --edit=REC cut recording REC and exit\n"
562 " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
563 " '%s' in the cache directory)\n"
564 " '-E-' disables this\n"
565 " if FILE is a directory, the default EPG file will be\n"
566 " created in that directory\n"
567 " --filesize=SIZE limit video files to SIZE bytes (default is %dM)\n"
568 " only useful in conjunction with --edit\n"
569 " --genindex=REC generate index for recording REC and exit\n"
570 " -g DIR, --grab=DIR write images from the SVDRP command GRAB into the\n"
571 " given DIR; DIR must be the full path name of an\n"
572 " existing directory, without any \"..\", double '/'\n"
573 " or symlinks (default: none, same as -g-)\n"
574 " -h, --help print this help and exit\n"
575 " -i ID, --instance=ID use ID as the id of this VDR instance (default: 0)\n"
576 " -l LEVEL, --log=LEVEL set log level (default: 3)\n"
577 " 0 = no logging, 1 = errors only,\n"
578 " 2 = errors and info, 3 = errors, info and debug\n"
579 " if logging should be done to LOG_LOCALn instead of\n"
580 " LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7)\n"
581 " -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n"
582 " --lirc[=PATH] use a LIRC remote control device, attached to PATH\n"
583 " (default: %s)\n"
584 " --localedir=DIR search for locale files in DIR (default is\n"
585 " %s)\n"
586 " -m, --mute mute audio of the primary DVB device at startup\n"
587 " --no-kbd don't use the keyboard as an input device\n"
588 " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
589 " 0 turns off SVDRP\n"
590 " -P OPT, --plugin=OPT load a plugin defined by the given options\n"
591 " -r CMD, --record=CMD call CMD before and after a recording, and after\n"
592 " a recording has been edited or deleted\n"
593 " --resdir=DIR read resource files from DIR (default: %s)\n"
594 " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
595 " --split split edited files at the editing marks (only\n"
596 " useful in conjunction with --edit)\n"
597 " --showargs[=DIR] print the arguments read from DIR and exit\n"
598 " (default: %s)\n"
599 " -t TTY, --terminal=TTY controlling tty\n"
600 " -u USER, --user=USER run as user USER; only applicable if started as\n"
601 " root; USER can be a user name or a numerical id\n"
602 " --updindex=REC update index for recording REC and exit\n"
603 " --userdump allow coredumps if -u is given (debugging)\n"
604 " -v DIR, --video=DIR use DIR as video directory (default: %s)\n"
605 " -V, --version print version information and exit\n"
606 " --vfat for backwards compatibility (same as\n"
607 " --dirnames=250,40,1)\n"
608 " -w SEC, --watchdog=SEC activate the watchdog timer with a timeout of SEC\n"
609 " seconds (default: %d); '0' disables the watchdog\n"
610 "\n",
613 PATH_MAX - 1,
614 NAME_MAX,
618 LIRC_DEVICE,
625 );
626 }
627 if (DisplayVersion)
628 printf("vdr (%s/%s) - The Video Disk Recorder\n", VDRVERSION, APIVERSION);
629 if (PluginManager.HasPlugins()) {
630 if (DisplayHelp)
631 printf("Plugins: vdr -P\"name [OPTIONS]\"\n\n");
632 for (int i = 0; ; i++) {
633 cPlugin *p = PluginManager.GetPlugin(i);
634 if (p) {
635 const char *help = p->CommandLineHelp();
636 printf("%s (%s) - %s\n", p->Name(), p->Version(), p->Description());
637 if (DisplayHelp && help) {
638 printf("\n");
639 puts(help);
640 }
641 }
642 else
643 break;
644 }
645 }
646 return 0;
647 }
648
649 // Log file:
650
651 if (SysLogLevel > 0)
652 openlog("vdr", LOG_CONS, SysLogTarget); // LOG_PID doesn't work as expected under NPTL
653
654 // Daemon mode:
655
656 if (DaemonMode) {
657 if (daemon(1, 0) == -1) {
658 fprintf(stderr, "vdr: %m\n");
659 esyslog("ERROR: %m");
660 return 2;
661 }
662 }
663 else if (Terminal) {
664 // Claim new controlling terminal
665 stdin = freopen(Terminal, "r", stdin);
666 stdout = freopen(Terminal, "w", stdout);
667 stderr = freopen(Terminal, "w", stderr);
668 HasStdin = true;
669 tcgetattr(STDIN_FILENO, &savedTm);
670 }
671
672 // Set user id in case we were started as root:
673
674 if (VdrUser && geteuid() == 0) {
675 StartedAsRoot = true;
676 if (strcmp(VdrUser, "root") && strcmp(VdrUser, "0")) {
677 if (!SetKeepCaps(true))
678 return 2;
679 if (!SetUser(VdrUser, UserDump))
680 return 2;
681 if (!SetKeepCaps(false))
682 return 2;
683 if (!DropCaps())
684 return 2;
685 }
686 }
687
688 // Check the video directory:
689
690 if (!DirectoryOk(VideoDirectory, true)) {
691 fprintf(stderr, "vdr: can't access video directory %s\n", VideoDirectory);
692 return 2;
693 }
694
695 isyslog("VDR version %s started", VDRVERSION);
696 if (StartedAsRoot && VdrUser)
697 isyslog("switched to user '%s'", VdrUser);
698 if (DaemonMode)
699 dsyslog("running as daemon (tid=%d)", cThread::ThreadId());
701
702 // Set the system character table:
703
704 char *CodeSet = NULL;
705 if (setlocale(LC_CTYPE, ""))
706 CodeSet = nl_langinfo(CODESET);
707 else {
708 char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
709 if (LangEnv) {
710 CodeSet = strchr(LangEnv, '.');
711 if (CodeSet)
712 CodeSet++; // skip the dot
713 }
714 }
715 if (CodeSet) {
716 bool known = SI::SetSystemCharacterTable(CodeSet);
717 isyslog("codeset is '%s' - %s", CodeSet, known ? "known" : "unknown");
719 }
720 if (OverrideCharacterTable) {
721 bool known = SI::SetOverrideCharacterTable(OverrideCharacterTable);
722 isyslog("override character table is '%s' - %s", OverrideCharacterTable, known ? "known" : "unknown");
723 }
724
725 // Initialize internationalization:
726
727 I18nInitialize(LocaleDirectory);
728
729 // Main program loop variables - need to be here to have them initialized before any EXIT():
730
731 cEpgDataReader EpgDataReader;
732 cOsdObject *Menu = NULL;
733 int LastChannel = 0;
734 int LastTimerChannel = -1;
735 int PreviousChannel[2] = { 1, 1 };
736 int PreviousChannelIndex = 0;
737 time_t LastChannelChanged = time(NULL);
738 time_t LastInteract = 0;
739 int MaxLatencyTime = 0;
740 bool InhibitEpgScan = false;
741 bool IsInfoMenu = false;
742 cSkin *CurrentSkin = NULL;
743 int OldPrimaryDVB = 0;
744
745 // Load plugins:
746
747 if (!PluginManager.LoadPlugins(true))
748 EXIT(2);
749
750 // Directories:
751
752 if (!ConfigDirectory)
753 ConfigDirectory = DEFAULTCONFDIR;
754 cPlugin::SetConfigDirectory(ConfigDirectory);
755 if (!CacheDirectory)
756 CacheDirectory = DEFAULTCACHEDIR;
757 cPlugin::SetCacheDirectory(CacheDirectory);
758 if (!ResourceDirectory)
759 ResourceDirectory = DEFAULTRESDIR;
760 cPlugin::SetResourceDirectory(ResourceDirectory);
761 cThemes::SetThemesDirectory("/var/lib/vdr/data/themes");
762
763 // Configuration data:
764
765 Setup.Load(AddDirectory(ConfigDirectory, "setup.conf"));
766 Sources.Load(AddDirectory(ConfigDirectory, "sources.conf"), true, true);
767 Diseqcs.Load(AddDirectory(ConfigDirectory, "diseqc.conf"), true, Setup.DiSEqC);
768 Scrs.Load(AddDirectory(ConfigDirectory, "scr.conf"), true);
769 cChannels::Load(AddDirectory(ConfigDirectory, "channels.conf"), false, true);
770 cTimers::Load(AddDirectory(ConfigDirectory, "timers.conf"));
771 Commands.Load(AddDirectory(ConfigDirectory, "commands.conf"));
772 RecordingCommands.Load(AddDirectory(ConfigDirectory, "reccmds.conf"));
773 SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
774 Keys.Load(AddDirectory(ConfigDirectory, "remote.conf"));
775 KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true);
776 Folders.Load(AddDirectory(ConfigDirectory, "folders.conf"));
777 CamResponsesLoad(AddDirectory(ConfigDirectory, "camresponses.conf"), true);
778 DoneRecordingsPattern.Load(AddDirectory(CacheDirectory, "donerecs.data"));
779
781 const char *msg = "no fonts available - OSD will not show any text!";
782 fprintf(stderr, "vdr: %s\n", msg);
783 esyslog("ERROR: %s", msg);
784 }
785
786 // Recordings:
787
789
790 // EPG data:
791
792 if (EpgDataFileName) {
793 const char *EpgDirectory = NULL;
794 if (DirectoryOk(EpgDataFileName)) {
795 EpgDirectory = EpgDataFileName;
796 EpgDataFileName = DEFAULTEPGDATAFILENAME;
797 }
798 else if (*EpgDataFileName != '/' && *EpgDataFileName != '.')
799 EpgDirectory = CacheDirectory;
800 if (EpgDirectory)
801 cSchedules::SetEpgDataFileName(AddDirectory(EpgDirectory, EpgDataFileName));
802 else
803 cSchedules::SetEpgDataFileName(EpgDataFileName);
804 EpgDataReader.Start();
805 }
806
807 // DVB interfaces:
808
811
812 // Initialize plugins:
813
814 if (!PluginManager.InitializePlugins())
815 EXIT(2);
816
817 // Primary device:
818
820 if (!cDevice::PrimaryDevice() || !cDevice::PrimaryDevice()->HasDecoder()) {
821 if (cDevice::PrimaryDevice() && !cDevice::PrimaryDevice()->HasDecoder())
822 isyslog("device %d has no MPEG decoder", cDevice::PrimaryDevice()->DeviceNumber() + 1);
823 for (int i = 0; i < cDevice::NumDevices(); i++) {
825 if (d && d->HasDecoder()) {
826 isyslog("trying device number %d instead", i + 1);
827 if (cDevice::SetPrimaryDevice(i + 1)) {
828 Setup.PrimaryDVB = i + 1;
829 break;
830 }
831 }
832 }
833 if (!cDevice::PrimaryDevice()) {
834 const char *msg = "no primary device found - using first device!";
835 fprintf(stderr, "vdr: %s\n", msg);
836 esyslog("ERROR: %s", msg);
838 EXIT(2);
839 if (!cDevice::PrimaryDevice()) {
840 const char *msg = "no primary device found - giving up!";
841 fprintf(stderr, "vdr: %s\n", msg);
842 esyslog("ERROR: %s", msg);
843 EXIT(2);
844 }
845 }
846 }
847 OldPrimaryDVB = Setup.PrimaryDVB;
848
849 // Check for timers in automatic start time window:
850
852
853 // User interface:
854
855 Interface = new cInterface;
856
857 // Default skins:
858
859 new cSkinLCARS;
860 new cSkinSTTNG;
861 new cSkinClassic;
864 CurrentSkin = Skins.Current();
865
866 // Start plugins:
867
868 if (!PluginManager.StartPlugins())
869 EXIT(2);
870
871 // Set skin and theme in case they're implemented by a plugin:
872
873 if (!CurrentSkin || CurrentSkin == Skins.Current() && strcmp(Skins.Current()->Name(), Setup.OSDSkin) != 0) {
876 }
877
878 // Remote Controls:
879 if (LircDevice)
880 cLircRemote::NewLircRemote(LircDevice);
881 if (!DaemonMode && HasStdin && UseKbd)
882 new cKbdRemote;
884
885 // External audio:
886
887 if (AudioCommand)
888 new cExternalAudio(AudioCommand);
889
890 // Positioner:
891
892 if (!cPositioner::GetPositioner()) // no plugin has created a positioner
894
895 // CAM data:
896
897 ChannelCamRelations.Load(AddDirectory(CacheDirectory, "cam.data"));
898
899 // Channel:
900
902 dsyslog("not all devices ready after %d seconds", DEVICEREADYTIMEOUT);
904 dsyslog("not all CAM slots ready after %d seconds", DEVICEREADYTIMEOUT);
905 if (*Setup.InitialChannel) {
907 if (isnumber(Setup.InitialChannel)) { // for compatibility with old setup.conf files
908 if (const cChannel *Channel = Channels->GetByNumber(atoi(Setup.InitialChannel)))
909 Setup.InitialChannel = Channel->GetChannelID().ToString();
910 }
911 if (const cChannel *Channel = Channels->GetByChannelID(tChannelID::FromString(Setup.InitialChannel)))
912 Setup.CurrentChannel = Channel->Number();
913 }
914 if (Setup.InitialVolume >= 0)
916 {
918 Channels->SwitchTo(Setup.CurrentChannel);
919 }
920
921 // Restore volume:
922
924 if (MuteAudio)
926
927 // Signal handlers:
928
929 if (signal(SIGHUP, SignalHandler) == SIG_IGN) signal(SIGHUP, SIG_IGN);
930 if (signal(SIGINT, SignalHandler) == SIG_IGN) signal(SIGINT, SIG_IGN);
931 if (signal(SIGTERM, SignalHandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
932 if (signal(SIGPIPE, SignalHandler) == SIG_IGN) signal(SIGPIPE, SIG_IGN);
933 if (WatchdogTimeout > 0)
934 if (signal(SIGALRM, Watchdog) == SIG_IGN) signal(SIGALRM, SIG_IGN);
935
936 // Watchdog:
937
938 if (WatchdogTimeout > 0) {
939 dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout);
940 alarm(WatchdogTimeout); // Initial watchdog timer start
941 }
942
943#ifdef SDNOTIFY
944 if (sd_watchdog_enabled(0, NULL) > 0) {
945 uint64_t timeout;
946 SdWatchdog = time(NULL);
947 sd_watchdog_enabled(0, &timeout);
948 SdWatchdogTimeout = (int)timeout/1000000;
949 dsyslog("SD_WATCHDOG enabled with timeout set to %d seconds", SdWatchdogTimeout);
950 }
951
952 // Startup notification:
953
954 sd_notify(0, "READY=1\nSTATUS=Ready");
955#endif
956
957 // SVDRP:
958
961
962 // Main program loop:
963
964#define DELETE_MENU ((IsInfoMenu &= (Menu == NULL)), delete Menu, Menu = NULL)
965
966 while (!ShutdownHandler.DoExit()) {
967#ifdef DEBUGRINGBUFFERS
968 cRingBufferLinear::PrintDebugRBL();
969#endif
970 // Attach launched player control:
972
973 time_t Now = time(NULL);
974
975 // Make sure we have a visible programme in case device usage has changed:
977 static time_t lastTime = 0;
978 if (!cDevice::PrimaryDevice()->HasProgramme()) {
979 if (!CamMenuActive() && Now - lastTime > MINCHANNELWAIT) { // !CamMenuActive() to avoid interfering with the CAM if a CAM menu is open
981 const cChannel *Channel = Channels->GetByNumber(cDevice::CurrentChannel());
982 if (Channel && (Channel->Vpid() || Channel->Apid(0) || Channel->Dpid(0))) {
983 if (cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels->SwitchTo(Channel->Number())) // try to switch to the original channel...
984 ;
985 else if (LastTimerChannel > 0) {
986 Channel = Channels->GetByNumber(LastTimerChannel);
987 if (Channel && cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels->SwitchTo(LastTimerChannel)) // ...or the one used by the last timer
988 ;
989 }
990 }
991 lastTime = Now; // don't do this too often
992 LastTimerChannel = -1;
993 }
994 }
995 else
996 lastTime = 0; // makes sure we immediately try again next time
997 }
998 // Update the OSD size:
999 {
1000 static time_t lastOsdSizeUpdate = 0;
1001 if (Now != lastOsdSizeUpdate) { // once per second
1003 static int OsdState = 0;
1004 if (cOsdProvider::OsdSizeChanged(OsdState)) {
1005 if (cOsdMenu *OsdMenu = dynamic_cast<cOsdMenu *>(Menu))
1006 OsdMenu->Display();
1007 }
1008 lastOsdSizeUpdate = Now;
1009 }
1010 }
1011 // Restart the Watchdog timer:
1012 if (WatchdogTimeout > 0) {
1013 int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
1014 if (LatencyTime > MaxLatencyTime) {
1015 MaxLatencyTime = LatencyTime;
1016 dsyslog("max. latency time %d seconds", MaxLatencyTime);
1017 }
1018 }
1019#ifdef SDNOTIFY
1020 // Ping systemd watchdog when half the timeout is elapsed:
1021 if (SdWatchdogTimeout && (Now - SdWatchdog) * 2 > SdWatchdogTimeout) {
1022 sd_notify(0, "WATCHDOG=1");
1023 SdWatchdog = Now;
1024 dsyslog("SD_WATCHDOG ping");
1025 }
1026#endif
1027 // Handle channel and timer modifications:
1028 {
1029 // Channels and timers need to be stored in a consistent manner,
1030 // therefore if one of them is changed, we save both.
1031 static time_t ChannelSaveTimeout = 0;
1032 static cStateKey TimersStateKey(true);
1033 static cStateKey ChannelsStateKey(true);
1034 static int ChannelsModifiedByUser = 0;
1035 const cTimers *Timers = cTimers::GetTimersRead(TimersStateKey);
1036 const cChannels *Channels = cChannels::GetChannelsRead(ChannelsStateKey);
1037 if (ChannelSaveTimeout != 1) {
1038 if (Channels) {
1039 if (Channels->ModifiedByUser(ChannelsModifiedByUser))
1040 ChannelSaveTimeout = 1; // triggers an immediate save
1041 else if (!ChannelSaveTimeout)
1042 ChannelSaveTimeout = Now + CHANNELSAVEDELTA;
1043 }
1044 if (Timers)
1045 ChannelSaveTimeout = 1; // triggers an immediate save
1046 }
1047 if (ChannelSaveTimeout && Now > ChannelSaveTimeout && !cRecordControls::Active())
1048 ChannelSaveTimeout = 1; // triggers an immediate save
1049 if (Timers && Channels) {
1050 Channels->Save();
1051 Timers->Save();
1052 ChannelSaveTimeout = 0;
1053 }
1054 if (Channels) {
1055 for (const cChannel *Channel = Channels->First(); Channel; Channel = Channels->Next(Channel)) {
1056 if (Channel->Modification(CHANNELMOD_RETUNE)) {
1058 if (Channel->Number() == cDevice::CurrentChannel() && cDevice::PrimaryDevice()->HasDecoder()) {
1059 if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring()) {
1060 if (cDevice::ActualDevice()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
1061 isyslog("retuning due to modification of channel %d (%s)", Channel->Number(), Channel->Name());
1062 Channels->SwitchTo(Channel->Number());
1063 }
1064 }
1065 }
1067 }
1068 }
1069 }
1070 // State keys are removed in reverse order!
1071 if (Channels)
1072 ChannelsStateKey.Remove();
1073 if (Timers)
1074 TimersStateKey.Remove();
1075 if (ChannelSaveTimeout == 1) {
1076 // Only one of them was modified, so we reset the state keys to handle them both in the next turn:
1077 ChannelsStateKey.Reset();
1078 TimersStateKey.Reset();
1079 }
1080 }
1081 // Channel display:
1082 if (!EITScanner.Active() && cDevice::CurrentChannel() != LastChannel) {
1083 if (!Menu)
1084 Menu = new cDisplayChannel(cDevice::CurrentChannel(), LastChannel >= 0);
1085 LastChannel = cDevice::CurrentChannel();
1086 LastChannelChanged = Now;
1087 }
1088 if (Now - LastChannelChanged >= Setup.ZapTimeout && LastChannel != PreviousChannel[PreviousChannelIndex])
1089 PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel;
1090 {
1091 // Timers and Recordings:
1092 static cStateKey TimersStateKey;
1093 cTimers *Timers = cTimers::GetTimersWrite(TimersStateKey);
1094 {
1095 LOCK_CHANNELS_READ; // Channels are needed for spawning pattern timers!
1096 // Assign events to timers:
1097 static cStateKey SchedulesStateKey;
1098 if (TimersStateKey.StateChanged())
1099 SchedulesStateKey.Reset(); // we assign events if either the Timers or the Schedules have changed
1100 bool TimersModified = false;
1101 if (const cSchedules *Schedules = cSchedules::GetSchedulesRead(SchedulesStateKey)) {
1102 Timers->SetSyncStateKey(StateKeySVDRPRemoteTimersPoll); // setting events shall not trigger a remote timer poll...
1103 if (Timers->AdjustSpawnedTimers()) { // must do this *before* SetEvents()!
1104 StateKeySVDRPRemoteTimersPoll.Reset(); // ...but adjusting spawned timers...
1105 TimersModified = true;
1106 }
1107 if (Timers->SetEvents(Schedules))
1108 TimersModified = true;
1109 if (Timers->SpawnPatternTimers(Schedules)) {
1110 StateKeySVDRPRemoteTimersPoll.Reset(); // ...or spawning new timers must!
1111 TimersModified = true;
1112 }
1113 SchedulesStateKey.Remove();
1114 }
1115 TimersStateKey.Remove(TimersModified); // we need to remove the key here, so that syncing StateKeySVDRPRemoteTimersPoll takes effect!
1116 }
1117 // Must do all following calls with the exact same time!
1118 // Process ongoing recordings:
1119 Timers = cTimers::GetTimersWrite(TimersStateKey);
1120 bool TimersModified = false;
1121 if (cRecordControls::Process(Timers, Now))
1122 TimersModified = true;
1123 // Start new recordings:
1124 if (cTimer *Timer = Timers->GetMatch(Now)) {
1125 if (!cRecordControls::Start(Timers, Timer))
1126 Timer->SetPending(true);
1127 else
1128 LastTimerChannel = Timer->Channel()->Number();
1129 TimersModified = true;
1130 }
1131 // Make sure timers "see" their channel early enough:
1132 static time_t LastTimerCheck = 0;
1133 if (Now - LastTimerCheck > TIMERCHECKDELTA) { // don't do this too often
1134 InhibitEpgScan = false;
1135 for (cTimer *Timer = Timers->First(); Timer; Timer = Timers->Next(Timer)) {
1136 if (Timer->Remote() || Timer->IsPatternTimer())
1137 continue;
1138 bool InVpsMargin = false;
1139 bool NeedsTransponder = false;
1140 if (Timer->HasFlags(tfActive) && !Timer->Recording()) {
1141 if (Timer->HasFlags(tfVps)) {
1142 if (Timer->Matches(Now, true, Setup.VpsMargin)) {
1143 InVpsMargin = true;
1144 Timer->SetInVpsMargin(InVpsMargin);
1145 }
1146 else if (Timer->Event()) {
1147 InVpsMargin = Timer->Event()->StartTime() <= Now && Now < Timer->Event()->EndTime();
1148 NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
1149 }
1150 else {
1152 const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel());
1153 InVpsMargin = !Schedule; // we must make sure we have the schedule
1154 NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME);
1155 }
1156 InhibitEpgScan |= InVpsMargin | NeedsTransponder;
1157 }
1158 else
1159 NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME);
1160 }
1161 if (NeedsTransponder || InVpsMargin) {
1162 // Find a device that provides the required transponder:
1163 cDevice *Device = cDevice::GetDeviceForTransponder(Timer->Channel(), MINPRIORITY);
1164 if (!Device && InVpsMargin)
1165 Device = cDevice::GetDeviceForTransponder(Timer->Channel(), LIVEPRIORITY);
1166 // Switch the device to the transponder:
1167 if (Device) {
1168 bool HadProgramme = cDevice::PrimaryDevice()->HasProgramme();
1169 if (!Device->IsTunedToTransponder(Timer->Channel())) {
1170 if (Device == cDevice::ActualDevice() && !Device->IsPrimaryDevice())
1171 cDevice::PrimaryDevice()->StopReplay(); // stop transfer mode
1172 dsyslog("switching device %d to channel %d %s (%s)", Device->DeviceNumber() + 1, Timer->Channel()->Number(), *Timer->Channel()->GetChannelID().ToString(), Timer->Channel()->Name());
1173 if (Device->SwitchChannel(Timer->Channel(), false))
1175 }
1176 if (cDevice::PrimaryDevice()->HasDecoder() && HadProgramme && !cDevice::PrimaryDevice()->HasProgramme())
1177 Skins.QueueMessage(mtInfo, tr("Upcoming recording!")); // the previous SwitchChannel() has switched away the current live channel
1178 }
1179 }
1180 }
1181 LastTimerCheck = Now;
1182 }
1183 // Delete expired timers:
1184 if (Timers->DeleteExpired(TimersModified))
1185 TimersModified = true;
1186 // Make sure there is enough free disk space for ongoing recordings:
1187 int MaxPriority = Timers->GetMaxPriority();
1188 if (MaxPriority >= 0)
1189 AssertFreeDiskSpace(MaxPriority);
1190 TimersStateKey.Remove(TimersModified);
1191 }
1192 // Recordings:
1193 if (!Menu) {
1196 }
1197 // CAM control:
1198 if (!Menu && !cOsd::IsOpen())
1199 Menu = CamControl();
1200 // Queued messages:
1202 // User Input:
1203 bool NeedsFastResponse = Menu && Menu->NeedsFastResponse();
1204 if (!NeedsFastResponse) {
1205 // Must limit the scope of ControlMutexLock here to not hold the lock during the call to Interface->GetKey().
1206 cMutexLock ControlMutexLock;
1207 cControl *Control = cControl::Control(ControlMutexLock);
1208 NeedsFastResponse = Control && Control->NeedsFastResponse();
1209 }
1210 eKeys key = Interface->GetKey(!NeedsFastResponse);
1211 cOsdObject *Interact = Menu;
1212 cMutexLock ControlMutexLock;
1213 cControl *Control = NULL;
1214 if (!Menu)
1215 Interact = Control = cControl::Control(ControlMutexLock);
1216 if (ISREALKEY(key)) {
1218 // Cancel shutdown countdown:
1221 // Set user active for MinUserInactivity time in the future:
1223 }
1224 // Keys that must work independent of any interactive mode:
1225 switch (int(key)) {
1226 // Menu control:
1227 case kMenu: {
1228 key = kNone; // nobody else needs to see this key
1229 bool WasOpen = Interact != NULL;
1230 bool WasMenu = Interact && Interact->IsMenu();
1231 if (Menu)
1233 else if (Control) {
1234 if (cOsd::IsOpen())
1235 Control->Hide();
1236 else
1237 WasOpen = false;
1238 }
1239 if (!WasOpen || !WasMenu && !Setup.MenuKeyCloses)
1240 Menu = new cMenuMain;
1241 }
1242 break;
1243 // Info:
1244 case kInfo: {
1245 if (IsInfoMenu) {
1246 key = kNone; // nobody else needs to see this key
1248 }
1249 else if (!Menu) {
1250 IsInfoMenu = true;
1251 if (Control) {
1252 Control->Hide();
1253 Menu = Control->GetInfo();
1254 if (Menu)
1255 Menu->Show();
1256 else
1257 IsInfoMenu = false;
1258 }
1259 else {
1260 cRemote::Put(kOk, true);
1261 cRemote::Put(kSchedule, true);
1262 }
1263 key = kNone; // nobody else needs to see this key
1264 }
1265 }
1266 break;
1267 // Direct main menu functions:
1268 #define DirectMainFunction(function)\
1269 { DELETE_MENU;\
1270 if (Control)\
1271 Control->Hide();\
1272 Menu = new cMenuMain(function);\
1273 key = kNone; } // nobody else needs to see this key
1276 case kTimers: DirectMainFunction(osTimers); break;
1278 case kSetup: DirectMainFunction(osSetup); break;
1280 case kUser0 ... kUser9: cRemote::PutMacro(key); key = kNone; break;
1281 case k_Plugin: {
1282 const char *PluginName = cRemote::GetPlugin();
1283 if (PluginName) {
1285 if (Control)
1286 Control->Hide();
1287 cPlugin *plugin = cPluginManager::GetPlugin(PluginName);
1288 if (plugin) {
1289 Menu = plugin->MainMenuAction();
1290 if (Menu)
1291 Menu->Show();
1292 }
1293 else
1294 esyslog("ERROR: unknown plugin '%s'", PluginName);
1295 }
1296 key = kNone; // nobody else needs to see these keys
1297 }
1298 break;
1299 // Channel up/down:
1300 case kChanUp|k_Repeat:
1301 case kChanUp:
1302 case kChanDn|k_Repeat:
1303 case kChanDn:
1304 if (!Interact) {
1305 Menu = new cDisplayChannel(NORMALKEY(key));
1306 continue;
1307 }
1308 else if (cDisplayChannel::IsOpen() || Control) {
1309 Interact->ProcessKey(key);
1310 continue;
1311 }
1312 else
1313 cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1);
1314 break;
1315 // Volume control:
1316 case kVolUp|k_Repeat:
1317 case kVolUp:
1318 case kVolDn|k_Repeat:
1319 case kVolDn:
1320 case kMute:
1321 if (key == kMute) {
1322 if (!cDevice::PrimaryDevice()->ToggleMute() && !Menu) {
1323 key = kNone; // nobody else needs to see these keys
1324 break; // no need to display "mute off"
1325 }
1326 }
1327 else
1329 if (!Menu && !cOsd::IsOpen())
1330 Menu = cDisplayVolume::Create();
1332 key = kNone; // nobody else needs to see these keys
1333 break;
1334 // Audio track control:
1335 case kAudio:
1336 if (Control)
1337 Control->Hide();
1338 if (!cDisplayTracks::IsOpen()) {
1340 Menu = cDisplayTracks::Create();
1341 }
1342 else
1344 key = kNone;
1345 break;
1346 // Subtitle track control:
1347 case kSubtitles:
1348 if (Control)
1349 Control->Hide();
1353 }
1354 else
1356 key = kNone;
1357 break;
1358 // Pausing live video:
1359 case kPlayPause:
1360 case kPause:
1361 if (!Control) {
1363 if (Setup.PauseKeyHandling) {
1364 if (Setup.PauseKeyHandling > 1 || Interface->Confirm(tr("Pause live video?"))) {
1366 Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1367 }
1368 }
1369 key = kNone; // nobody else needs to see this key
1370 }
1371 break;
1372 // Instant recording:
1373 case kRecord:
1374 if (!Control) {
1376 if (Setup.RecordKeyHandling > 1 || Interface->Confirm(tr("Start recording?"))) {
1378 Skins.QueueMessage(mtInfo, tr("Recording started"));
1379 }
1380 }
1381 key = kNone; // nobody else needs to see this key
1382 }
1383 break;
1384 // Power off:
1385 case kPower:
1386 isyslog("Power button pressed");
1388 // Check for activity, request power button again if active:
1389 if (!ShutdownHandler.ConfirmShutdown(false) && Skins.Message(mtWarning, tr("VDR will shut down later - press Power to force"), SHUTDOWNFORCEPROMPT) != kPower) {
1390 // Not pressed power - set VDR to be non-interactive and power down later:
1392 break;
1393 }
1394 // No activity or power button pressed twice - ask for confirmation:
1395 if (!ShutdownHandler.ConfirmShutdown(true)) {
1396 // Non-confirmed background activity - set VDR to be non-interactive and power down later:
1398 break;
1399 }
1400 // Ask the final question:
1401 if (!Interface->Confirm(tr("Press any key to cancel shutdown"), SHUTDOWNCANCELPROMPT, true))
1402 // If final question was canceled, continue to be active:
1403 break;
1404 // Ok, now call the shutdown script:
1406 // Set VDR to be non-interactive and power down again later:
1408 // Do not attempt to automatically shut down for a while:
1410 break;
1411 default: break;
1412 }
1413 Interact = Menu ? Menu : Control; // might have been closed in the mean time
1414 if (Interact) {
1415 LastInteract = Now;
1416 eOSState state = Interact->ProcessKey(key);
1417 if (state == osUnknown && Interact != Control) {
1418 if (ISMODELESSKEY(key) && Control) {
1419 state = Control->ProcessKey(key);
1420 if (state == osEnd) {
1421 // let's not close a menu when replay ends:
1422 Control = NULL;
1424 continue;
1425 }
1426 }
1427 else if (Now - cRemote::LastActivity() > MENUTIMEOUT)
1428 state = osEnd;
1429 }
1430 switch (state) {
1431 case osPause: DELETE_MENU;
1433 Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1434 break;
1435 case osRecord: DELETE_MENU;
1437 Skins.QueueMessage(mtInfo, tr("Recording started"));
1438 break;
1439 case osRecordings:
1441 Control = NULL;
1443 Menu = new cMenuMain(osRecordings, true);
1444 break;
1445 case osReplay: DELETE_MENU;
1446 Control = NULL;
1449 break;
1450 case osStopReplay:
1452 Control = NULL;
1454 break;
1455 case osPlugin: DELETE_MENU;
1457 if (Menu)
1458 Menu->Show();
1459 break;
1460 case osBack:
1461 case osEnd: if (Interact == Menu)
1463 else {
1464 Control = NULL;
1466 }
1467 break;
1468 default: ;
1469 }
1470 }
1471 else {
1472 // Key functions in "normal" viewing mode:
1473 if (key != kNone && KeyMacros.Get(key)) {
1474 cRemote::PutMacro(key);
1475 key = kNone;
1476 }
1477 switch (int(key)) {
1478 // Toggle channels:
1479 case kChanPrev:
1480 case k0: {
1481 if (PreviousChannel[PreviousChannelIndex ^ 1] == LastChannel || LastChannel != PreviousChannel[0] && LastChannel != PreviousChannel[1])
1482 PreviousChannelIndex ^= 1;
1484 Channels->SwitchTo(PreviousChannel[PreviousChannelIndex ^= 1]);
1485 break;
1486 }
1487 // Direct Channel Select:
1488 case k1 ... k9:
1489 // Left/Right rotates through channel groups:
1490 case kLeft|k_Repeat:
1491 case kLeft:
1492 case kRight|k_Repeat:
1493 case kRight:
1494 // Previous/Next rotates through channel groups:
1495 case kPrev|k_Repeat:
1496 case kPrev:
1497 case kNext|k_Repeat:
1498 case kNext:
1499 // Up/Down Channel Select:
1500 case kUp|k_Repeat:
1501 case kUp:
1502 case kDown|k_Repeat:
1503 case kDown:
1504 Menu = new cDisplayChannel(NORMALKEY(key));
1505 break;
1506 // Viewing Control:
1507 case kOk: LastChannel = -1; break; // forces channel display
1508 // Instant resume of the last viewed recording:
1509 case kPlay:
1511 Control = NULL;
1514 }
1515 else
1516 DirectMainFunction(osRecordings); // no last viewed recording, so enter the Recordings menu
1517 break;
1518 default: break;
1519 }
1520 }
1521 if (!Menu) {
1522 if (!InhibitEpgScan)
1524 bool Error = false;
1525 if (RecordingsHandler.Finished(Error)) {
1526 if (Error)
1527 Skins.Message(mtError, tr("Editing process failed!"));
1528 else
1529 Skins.Message(mtInfo, tr("Editing process finished"));
1530 }
1531 }
1532
1533 // Change primary device:
1534 int NewPrimaryDVB = Setup.PrimaryDVB;
1535 if (NewPrimaryDVB != OldPrimaryDVB) {
1537 Control = NULL;
1539 Skins.QueueMessage(mtInfo, tr("Switching primary DVB..."));
1541 cDevice::SetPrimaryDevice(NewPrimaryDVB);
1542 OldPrimaryDVB = NewPrimaryDVB;
1543 }
1544
1545 // SIGHUP shall cause a restart:
1546 if (LastSignal == SIGHUP) {
1547 if (ShutdownHandler.ConfirmRestart(true) && Interface->Confirm(tr("Press any key to cancel restart"), RESTARTCANCELPROMPT, true))
1548 EXIT(1);
1549 LastSignal = 0;
1550 }
1551
1552 // Update the shutdown countdown:
1554 if (!ShutdownHandler.ConfirmShutdown(false))
1556 }
1557
1559 // Shutdown:
1560 // Check whether VDR will be ready for shutdown in SHUTDOWNWAIT seconds:
1561 time_t Soon = Now + SHUTDOWNWAIT;
1564 // Time to shut down - start final countdown:
1565 ShutdownHandler.countdown.Start(tr("VDR will shut down in %s minutes"), SHUTDOWNWAIT); // the placeholder is really %s!
1566 // Dont try to shut down again for a while:
1568 }
1569 // Countdown run down to 0?
1571 // Timed out, now do a final check:
1574 // Do this again a bit later:
1576 }
1577 // Handle housekeeping tasks
1578 if ((Now - LastInteract) > ACTIVITYTIMEOUT) {
1579 // Disk housekeeping:
1583 // Plugins housekeeping:
1584 PluginManager.Housekeeping();
1585 // Memory cleanup:
1586 static time_t LastMemoryCleanup = 0;
1587 if ((Now - LastMemoryCleanup) > MEMCLEANUPDELTA) {
1588 malloc_trim(0);
1589 LastMemoryCleanup = Now;
1590 }
1591 }
1592 }
1593
1595
1596 // Main thread hooks of plugins:
1597 PluginManager.MainThreadHook();
1598 }
1599
1601 esyslog("emergency exit requested - shutting down");
1602
1603Exit:
1604
1605 // Reset all signal handlers to default before Interface gets deleted:
1606 signal(SIGHUP, SIG_DFL);
1607 signal(SIGINT, SIG_DFL);
1608 signal(SIGTERM, SIG_DFL);
1609 signal(SIGPIPE, SIG_DFL);
1610 signal(SIGALRM, SIG_DFL);
1611
1615 PluginManager.StopPlugins();
1617 delete Menu;
1619 delete Interface;
1621 Remotes.Clear();
1622 Audios.Clear();
1623 Skins.Clear();
1625 if (ShutdownHandler.GetExitCode() != 2) {
1628 Setup.Save();
1629 }
1634 cSchedules::Cleanup(true);
1637 PluginManager.Shutdown(true);
1639 if (WatchdogTimeout > 0)
1640 dsyslog("max. latency time %d seconds", MaxLatencyTime);
1641 if (LastSignal)
1642 isyslog("caught signal %d", LastSignal);
1644 esyslog("emergency exit!");
1645 isyslog("exiting, exit code %d", ShutdownHandler.GetExitCode());
1646 if (SysLogLevel > 0)
1647 closelog();
1648 if (HasStdin)
1649 tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
1650#ifdef SDNOTIFY
1651 if (ShutdownHandler.GetExitCode() == 2)
1652 sd_notify(0, "STOPPING=1\nSTATUS=Startup failed, exiting");
1653 else
1654 sd_notify(0, "STOPPING=1\nSTATUS=Exiting");
1655#endif
1657}
cAudios Audios
Definition audio.c:27
#define CHANNELMOD_RETUNE
Definition channels.h:29
#define LOCK_CHANNELS_READ
Definition channels.h:269
cChannelCamRelations ChannelCamRelations
Definition ci.c:2947
cCamSlots CamSlots
Definition ci.c:2838
cCiResourceHandlers CiResourceHandlers
Definition ci.c:1777
bool CamResponsesLoad(const char *FileName, bool AllowComments, bool MustExist)
Definition ci.c:481
Definition args.h:17
int GetArgc(void) const
Definition args.h:30
char ** GetArgv(void) const
Definition args.h:31
bool ReadDirectory(const char *Directory)
Definition args.c:39
bool WaitForAllCamSlotsReady(int Timeout=0)
Waits until all CAM slots have become ready, or the given Timeout (seconds) has expired.
Definition ci.c:2850
void Load(const char *FileName)
Definition ci.c:3043
void Save(void)
Definition ci.c:3077
int Vpid(void) const
Definition channels.h:153
int Number(void) const
Definition channels.h:178
int Dpid(int i) const
Definition channels.h:160
int Apid(int i) const
Definition channels.h:159
bool ModifiedByUser(int &State) const
Returns true if the channels have been modified by the user since the last call to this function with...
Definition channels.c:1098
static const cChannels * GetChannelsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of channels for read access.
Definition channels.c:855
bool SwitchTo(int Number) const
Definition channels.c:1062
static bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition channels.c:884
static void SetSystemCharacterTable(const char *CharacterTable)
Definition tools.c:986
bool Save(void) const
Definition config.h:174
bool Load(const char *FileName=NULL, bool AllowComments=false, bool MustExist=false)
Definition config.h:127
static void Shutdown(void)
Definition player.c:108
virtual cOsdObject * GetInfo(void)
Returns an OSD object that displays information about the currently played programme.
Definition player.c:58
static void Attach(void)
Definition player.c:95
static cControl * Control(bool Hidden=false)
Old version of this function, for backwards compatibility with plugins.
Definition player.c:74
static void Launch(cControl *Control)
Definition player.c:87
virtual void Hide(void)=0
bool Update(void)
Update status display of the countdown.
Definition shutdown.c:64
void Start(const char *Message, int Seconds)
Start the 5 minute shutdown warning countdown.
Definition shutdown.c:37
void Cancel(void)
Cancel the 5 minute shutdown warning countdown.
Definition shutdown.c:46
bool Done(void)
Check if countdown timer has run out without canceling.
Definition shutdown.c:55
bool IsPrimaryDevice(void) const
Definition device.h:220
static bool WaitForAllDevicesReady(int Timeout=0)
Waits until all devices have become ready, or the given Timeout (seconds) has expired.
Definition device.c:131
static cDevice * ActualDevice(void)
Returns the actual receiving device in case of Transfer Mode, or the primary device otherwise.
Definition device.c:220
static cDevice * PrimaryDevice(void)
Returns the primary device.
Definition device.h:148
static void SetUseDevice(int n)
Sets the 'useDevice' flag of the given device.
Definition device.c:147
static cDevice * GetDevice(int Index)
Gets the device with the given Index.
Definition device.c:228
static void Shutdown(void)
Closes down all devices.
Definition device.c:457
void SetOccupied(int Seconds)
Sets the occupied timeout for this device to the given number of Seconds, This can be used to tune a ...
Definition device.c:965
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
Definition device.c:807
int DeviceNumber(void) const
Returns the number of this device (0 ... numDevices - 1).
Definition device.c:165
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
Definition device.h:358
static bool SetPrimaryDevice(int n)
Sets the primary device to 'n'.
Definition device.c:192
void StopReplay(void)
Stops the current replay session (if any).
Definition device.c:1386
void SetVolume(int Volume, bool Absolute=false)
Sets the volume to the given value, either absolutely or relative to the current volume.
Definition device.c:1041
static int NumDevices(void)
Returns the total number of devices.
Definition device.h:129
virtual bool HasDecoder(void) const
Tells whether this device has an MPEG decoder.
Definition device.c:210
virtual bool HasProgramme(void) const
Returns true if the device is currently showing any programme to the user, either through replaying o...
Definition device.c:981
static int CurrentVolume(void)
Definition device.h:634
virtual bool IsTunedToTransponder(const cChannel *Channel) const
Returns true if this device is currently tuned to the given Channel's transponder.
Definition device.c:797
static cDevice * GetDeviceForTransponder(const cChannel *Channel, int Priority)
Returns a device that is not currently "occupied" and can be tuned to the transponder of the given Ch...
Definition device.c:420
bool ToggleMute(void)
Turns the volume off or on and returns the new mute state.
Definition device.c:1012
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition diseqc.c:441
static bool IsOpen(void)
Definition menu.h:145
static void Process(eKeys Key)
Definition menu.c:5342
static bool IsOpen(void)
Definition menu.h:192
static cDisplaySubtitleTracks * Create(void)
Definition menu.c:5331
static cDisplayTracks * Create(void)
Definition menu.c:5213
static void Process(eKeys Key)
Definition menu.c:5224
static bool IsOpen(void)
Definition menu.h:174
static cDisplayVolume * Create(void)
Definition menu.c:5123
static void Process(eKeys Key)
Definition menu.c:5130
bool Load(const char *FileName)
Definition recording.c:3101
static bool BondDevices(const char *Bondings)
Bonds the devices as defined in the given Bondings string.
Definition dvbdevice.c:2002
static bool useDvbDevices
Definition dvbdevice.h:175
static bool Initialize(void)
Initializes the DVB devices.
Definition dvbdevice.c:1939
bool Active(void)
Definition eitscan.h:33
void Process(void)
Definition eitscan.c:128
void Activity(void)
Definition eitscan.c:118
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
Definition font.c:482
bool Confirm(const char *s, int Seconds=10, bool WaitForTimeout=false)
Definition interface.c:59
void Interrupt(void)
Definition interface.h:24
eKeys GetKey(bool Wait=true)
Definition interface.c:31
void LearnKeys(void)
Definition interface.c:147
const cKeyMacro * Get(eKeys Key)
Definition keys.c:269
static void NewLircRemote(const char *Name)
Definition lirc.c:64
virtual void Clear(void)
Definition tools.c:2265
void SetSyncStateKey(cStateKey &StateKey)
When making changes to this list (while holding a write lock) that shall not affect some other code t...
Definition tools.h:609
void Purge(bool Force=false)
Definition tools.c:2147
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
Definition tools.h:653
const T * Next(const T *Object) const
< Returns the element immediately before Object in this list, or NULL if Object is the first element ...
Definition tools.h:660
static cOsdObject * PluginOsdObject(void)
Definition menu.c:4549
bool Load(const char *FileName)
Definition config.c:234
virtual bool NeedsFastResponse(void)
Definition osdbase.h:79
virtual eOSState ProcessKey(eKeys Key)
Definition osdbase.h:82
bool IsMenu(void) const
Definition osdbase.h:80
virtual void Show(void)
Definition osdbase.c:70
static bool OsdSizeChanged(int &State)
Checks if the OSD size has changed and a currently displayed OSD needs to be redrawn.
Definition osd.c:2262
static void Shutdown(void)
Shuts down the OSD provider facility by deleting the current OSD provider.
Definition osd.c:2322
static void UpdateOsdSize(bool Force=false)
Inquires the actual size of the video display and adjusts the OSD and font sizes accordingly.
Definition osd.c:2235
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
Definition osd.h:813
void StopPlugins(void)
Definition plugin.c:512
void MainThreadHook(void)
Definition plugin.c:418
bool StartPlugins(void)
Definition plugin.c:388
void SetDirectory(const char *Directory)
Definition plugin.c:324
bool InitializePlugins(void)
Definition plugin.c:375
void AddPlugin(const char *Args)
Definition plugin.c:330
static bool HasPlugins(void)
Definition plugin.c:464
bool LoadPlugins(bool Log=false)
Definition plugin.c:366
void Shutdown(bool Log=false)
Definition plugin.c:524
void Housekeeping(void)
Definition plugin.c:402
static cPlugin * GetPlugin(int Index)
Definition plugin.c:469
virtual const char * CommandLineHelp(void)
Definition plugin.c:48
virtual const char * Version(void)=0
const char * Name(void)
Definition plugin.h:36
static void SetCacheDirectory(const char *Dir)
Definition plugin.c:149
virtual cOsdObject * MainMenuAction(void)
Definition plugin.c:95
static void SetConfigDirectory(const char *Dir)
Definition plugin.c:135
static void SetResourceDirectory(const char *Dir)
Definition plugin.c:163
virtual const char * Description(void)=0
static cPositioner * GetPositioner(void)
Returns a previously created positioner.
Definition positioner.c:133
static void DestroyPositioner(void)
Destroys a previously created positioner.
Definition positioner.c:138
static void ChannelDataModified(const cChannel *Channel)
Definition menu.c:5695
static bool Process(cTimers *Timers, time_t t)
Definition menu.c:5680
static bool PauseLiveVideo(void)
Definition menu.c:5632
static void Shutdown(void)
Definition menu.c:5721
static bool Start(cTimers *Timers, cTimer *Timer, bool Pause=false)
Definition menu.c:5537
static bool Active(void)
Definition menu.c:5712
static void SetCommand(const char *Command)
Definition recording.h:436
void DelAll(void)
Deletes/terminates all operations.
Definition recording.c:2102
bool Finished(bool &Error)
Returns true if all operations in the list have been finished.
Definition recording.c:2117
static void Update(bool Wait=false)
Triggers an update of the list of recordings, which will run as a separate thread if Wait is false.
Definition recording.c:1557
static bool NeedsUpdate(void)
Definition recording.c:1549
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin().
Definition remote.c:162
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
Definition remote.c:124
static bool PutMacro(eKeys Key)
Definition remote.c:110
static time_t LastActivity(void)
Absolute time when last key was delivered by Get().
Definition remote.h:68
static const char * LastReplayed(void)
Definition menu.c:5874
bool PresentSeenWithin(int Seconds) const
Definition epg.h:170
static const cSchedules * GetSchedulesRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of schedules for read access.
Definition epg.c:1269
static void SetEpgDataFileName(const char *FileName)
Definition epg.c:1279
static void Cleanup(bool Force=false)
Definition epg.c:1286
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition diseqc.c:184
int SplitEditedFiles
Definition config.h:345
int CurrentVolume
Definition config.h:365
int CurrentChannel
Definition config.h:364
bool Save(void)
Definition config.c:734
char OSDTheme[MaxThemeName]
Definition config.h:267
char OSDSkin[MaxSkinName]
Definition config.h:266
int VpsMargin
Definition config.h:315
int ZapTimeout
Definition config.h:305
int RecordKeyHandling
Definition config.h:310
int PauseKeyHandling
Definition config.h:311
bool Load(const char *FileName)
Definition config.c:542
int MenuKeyCloses
Definition config.h:273
int DiSEqC
Definition config.h:280
char FontOsd[MAXFONTNAME]
Definition config.h:335
int MaxVideoFileSize
Definition config.h:344
cString DeviceBondings
Definition config.h:375
int PrimaryDVB
Definition config.h:268
cString InitialChannel
Definition config.h:374
int InitialVolume
Definition config.h:369
void CheckManualStart(int ManualStart)
Check whether the next timer is in ManualStart time window.
Definition shutdown.c:104
void SetShutdownCommand(const char *ShutdownCommand)
Set the command string for shutdown command.
Definition shutdown.c:121
bool ConfirmShutdown(bool Ask)
Check for background activity that blocks shutdown.
Definition shutdown.c:157
bool EmergencyExitRequested(void)
Returns true if an emergency exit was requested.
Definition shutdown.h:61
void SetRetry(int Seconds)
Set shutdown retry so that VDR will not try to automatically shut down within Seconds.
Definition shutdown.h:93
bool Retry(time_t AtTime=0)
Check whether its time to re-try the shutdown.
Definition shutdown.h:88
bool IsUserInactive(time_t AtTime=0)
Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown).
Definition shutdown.h:72
bool DoShutdown(bool Force)
Call the shutdown script with data of the next pending timer.
Definition shutdown.c:233
bool ConfirmRestart(bool Ask)
Check for background activity that blocks restart.
Definition shutdown.c:209
void Exit(int ExitCode)
Set VDR exit code and initiate end of VDR main loop.
Definition shutdown.h:54
void SetUserInactiveTimeout(int Seconds=-1, bool Force=false)
Set the time in the future when VDR will switch into non-interactive mode or power down.
Definition shutdown.c:141
bool DoExit(void)
Check if an exit code was set, and VDR should exit.
Definition shutdown.h:57
cCountdown countdown
Definition shutdown.h:51
void SetUserInactive(void)
Set VDR manually into non-interactive mode from now on.
Definition shutdown.h:86
int GetExitCode(void)
Get the currently set exit code of VDR.
Definition shutdown.h:59
Definition skins.h:402
cTheme * Theme(void)
Definition skins.h:422
const char * Name(void)
Definition skins.h:421
bool SetCurrent(const char *Name=NULL)
Sets the current skin to the one indicated by name.
Definition skins.c:231
eKeys Message(eMessageType Type, const char *s, int Seconds=0)
Displays the given message, either through a currently visible display object that is capable of doin...
Definition skins.c:250
cSkin * Current(void)
Returns a pointer to the current skin.
Definition skins.h:468
virtual void Clear(void)
Free up all registered skins.
Definition skins.c:408
void ProcessQueuedMessages(void)
Processes the first queued message, if any.
Definition skins.c:352
int QueueMessage(eMessageType Type, const char *s, int Seconds=0, int Timeout=0)
Like Message(), but this function may be called from a background thread.
Definition skins.c:296
void Remove(bool IncState=true)
Removes this key from the lock it was previously used with.
Definition thread.c:867
void Reset(void)
Resets the state of this key, so that the next call to a lock's Lock() function with this key will re...
Definition thread.c:862
bool StateChanged(void)
Returns true if this key is used for obtaining a write lock, and the lock's state differs from that o...
Definition thread.c:877
static void MsgChannelChange(const cChannel *Channel)
Definition status.c:26
static void SetThemesDirectory(const char *ThemesDirectory)
Definition themes.c:295
bool Load(const char *SkinName)
Definition themes.c:239
static void SetMainThreadId(void)
Definition thread.c:377
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
Definition thread.c:304
bool Active(void)
Checks whether the thread is still alive.
Definition thread.c:329
static tThreadId ThreadId(void)
Definition thread.c:372
static bool Load(const char *FileName)
Definition timers.c:1051
int GetMaxPriority(void) const
Returns the maximum priority of all local timers that are currently recording.
Definition timers.c:1145
static cTimers * GetTimersWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of timers for write access.
Definition timers.c:1173
static const cTimers * GetTimersRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of timers for read access.
Definition timers.c:1168
const cTimer * GetMatch(time_t t) const
Definition timers.c:1095
bool SpawnPatternTimers(const cSchedules *Schedules)
Definition timers.c:1217
bool DeleteExpired(bool Force)
Definition timers.c:1243
bool SetEvents(const cSchedules *Schedules)
Definition timers.c:1207
bool AdjustSpawnedTimers(void)
Definition timers.c:1229
static void Destroy(void)
Definition videodir.c:50
static void SetName(const char *Name)
Definition videodir.c:65
cNestedItemList Commands
Definition config.c:275
cSetup Setup
Definition config.c:372
cSVDRPhosts SVDRPhosts
Definition config.c:280
cNestedItemList Folders
Definition config.c:274
cNestedItemList RecordingCommands
Definition config.c:276
#define MINPRIORITY
Definition config.h:44
#define VDRVERSION
Definition config.h:25
#define APIVERSION
Definition config.h:30
#define LIVEPRIORITY
Definition config.h:45
bool CutRecording(const char *FileName)
Definition cutter.c:728
#define MAXDEVICES
Definition device.h:29
#define VOLUMEDELTA
Definition device.h:33
cDiseqcs Diseqcs
Definition diseqc.c:439
cScrs Scrs
Definition diseqc.c:182
cEITScanner EITScanner
Definition eitscan.c:90
cEpgHandlers EpgHandlers
Definition epg.c:1429
void ReportEpgBugFixStats(bool Force)
Definition epg.c:611
#define LOCK_SCHEDULES_READ
Definition epg.h:233
void I18nInitialize(const char *LocaleDir)
Detects all available locales and loads the language names and codes.
Definition i18n.c:142
#define tr(s)
Definition i18n.h:85
cInterface * Interface
Definition interface.c:20
cKeyMacros KeyMacros
Definition keys.c:267
cKeys Keys
Definition keys.c:156
#define ISMODELESSKEY(k)
Definition keys.h:80
#define ISREALKEY(k)
Definition keys.h:81
#define NORMALKEY(k)
Definition keys.h:79
eKeys
Definition keys.h:16
@ kPower
Definition keys.h:39
@ kRecord
Definition keys.h:34
@ kSchedule
Definition keys.h:48
@ kUser9
Definition keys.h:54
@ kPlayPause
Definition keys.h:30
@ kCommands
Definition keys.h:53
@ kRight
Definition keys.h:23
@ kRecordings
Definition keys.h:51
@ kPause
Definition keys.h:32
@ k9
Definition keys.h:28
@ kSetup
Definition keys.h:52
@ kUp
Definition keys.h:17
@ kChanUp
Definition keys.h:40
@ kNone
Definition keys.h:55
@ kPlay
Definition keys.h:31
@ kChanPrev
Definition keys.h:42
@ kDown
Definition keys.h:18
@ k1
Definition keys.h:28
@ kSubtitles
Definition keys.h:47
@ kLeft
Definition keys.h:22
@ k_Plugin
Definition keys.h:58
@ kAudio
Definition keys.h:46
@ kMute
Definition keys.h:45
@ kPrev
Definition keys.h:38
@ k0
Definition keys.h:28
@ kChannels
Definition keys.h:49
@ kTimers
Definition keys.h:50
@ kMenu
Definition keys.h:19
@ k_Repeat
Definition keys.h:61
@ kChanDn
Definition keys.h:41
@ kVolDn
Definition keys.h:44
@ kNext
Definition keys.h:37
@ kOk
Definition keys.h:20
@ kVolUp
Definition keys.h:43
@ kInfo
Definition keys.h:29
@ kUser0
Definition keys.h:54
cOsdObject * CamControl(void)
Definition menu.c:2490
bool CamMenuActive(void)
Definition menu.c:2499
bool SetSystemCharacterTable(const char *CharacterTable)
Definition si.c:339
bool SetOverrideCharacterTable(const char *CharacterTable)
Definition si.c:324
eOSState
Definition osdbase.h:18
@ osRecordings
Definition osdbase.h:23
@ osPause
Definition osdbase.h:27
@ osPlugin
Definition osdbase.h:24
@ osChannels
Definition osdbase.h:21
@ osStopReplay
Definition osdbase.h:31
@ osRecord
Definition osdbase.h:28
@ osEnd
Definition osdbase.h:34
@ osSetup
Definition osdbase.h:25
@ osTimers
Definition osdbase.h:22
@ osReplay
Definition osdbase.h:29
@ osUnknown
Definition osdbase.h:18
@ osSchedule
Definition osdbase.h:20
@ osCommands
Definition osdbase.h:26
@ osBack
Definition osdbase.h:33
int DirectoryNameMax
Definition recording.c:76
bool GenerateIndex(const char *FileName, bool Update)
Generates the index of the existing recording with the given FileName.
Definition recording.c:2905
void AssertFreeDiskSpace(int Priority, bool Force)
The special Priority value -1 means that we shall get rid of any deleted recordings faster than norma...
Definition recording.c:153
int DirectoryPathMax
Definition recording.c:75
int InstanceId
Definition recording.c:78
bool DirectoryEncoding
Definition recording.c:77
cDoneRecordings DoneRecordingsPattern
Definition recording.c:3099
cRecordingsHandler RecordingsHandler
Definition recording.c:2012
void RemoveDeletedRecordings(void)
Definition recording.c:136
#define MAXVIDEOFILESIZEDEFAULT
Definition recording.h:451
#define MAXVIDEOFILESIZETS
Definition recording.h:448
#define MINVIDEOFILESIZE
Definition recording.h:450
cRemotes Remotes
Definition remote.c:211
cShutdownHandler ShutdownHandler
Definition shutdown.c:27
cSkins Skins
Definition skins.c:219
@ mtWarning
Definition skins.h:37
@ mtInfo
Definition skins.h:37
@ mtError
Definition skins.h:37
cSourceParams SourceParams
cSources Sources
Definition sources.c:117
static tChannelID FromString(const char *s)
Definition channels.c:23
void StopSVDRPHandler(void)
Definition svdrp.c:2837
void SetSVDRPGrabImageDir(const char *GrabImageDir)
Definition svdrp.c:2739
void StartSVDRPHandler(void)
Definition svdrp.c:2821
void SetSVDRPPorts(int TcpPort, int UdpPort)
Definition svdrp.c:2733
cStateKey StateKeySVDRPRemoteTimersPoll
Controls whether a change to the local list of timers needs to result in sending a POLL to the remote...
@ tfActive
Definition timers.h:19
@ tfVps
Definition timers.h:21
int SysLogLevel
Definition tools.c:31
bool DirectoryOk(const char *DirName, bool LogErrors)
Definition tools.c:481
bool isnumber(const char *s)
Definition tools.c:364
cString AddDirectory(const char *DirName, const char *FileName)
Definition tools.c:402
cListGarbageCollector ListGarbageCollector
Definition tools.c:2124
int64_t StrToNum(const char *s)
Converts the given string to a number.
Definition tools.c:375
#define MEGABYTE(n)
Definition tools.h:45
#define dsyslog(a...)
Definition tools.h:37
#define esyslog(a...)
Definition tools.h:35
#define isyslog(a...)
Definition tools.h:36
static bool SetUser(const char *User, bool UserDump)
Definition vdr.c:98
#define SHUTDOWNFORCEPROMPT
Definition vdr.c:81
static int LastSignal
Definition vdr.c:96
int main(int argc, char *argv[])
Definition vdr.c:198
#define DEFAULTRESDIR
#define DEFAULTWATCHDOG
#define DEFAULTARGSDIR
#define MEMCLEANUPDELTA
Definition vdr.c:78
#define MANUALSTART
Definition vdr.c:84
#define DEFAULTLOCDIR
#define TIMERLOOKAHEADTIME
Definition vdr.c:90
#define DEFAULTPLUGINDIR
#define CHANNELSAVEDELTA
Definition vdr.c:85
#define SHUTDOWNCANCELPROMPT
Definition vdr.c:82
#define SHUTDOWNWAIT
Definition vdr.c:79
#define DEFAULTEPGDATAFILENAME
static void SignalHandler(int signum)
Definition vdr.c:171
#define DEFAULTCONFDIR
static bool SetKeepCaps(bool On)
Definition vdr.c:161
#define DEFAULTVIDEODIR
#define VPSLOOKAHEADTIME
Definition vdr.c:91
#define DirectMainFunction(function)
#define MINCHANNELWAIT
Definition vdr.c:76
#define TIMERDEVICETIMEOUT
Definition vdr.c:89
static bool DropCaps(void)
Definition vdr.c:128
#define MENUTIMEOUT
Definition vdr.c:87
static void Watchdog(int signum)
Definition vdr.c:187
#define RESTARTCANCELPROMPT
Definition vdr.c:83
#define EXIT(v)
Definition vdr.c:94
#define DEFAULTCACHEDIR
#define DEVICEREADYTIMEOUT
Definition vdr.c:86
#define TIMERCHECKDELTA
Definition vdr.c:88
#define ACTIVITYTIMEOUT
Definition vdr.c:77
#define VPSUPTODATETIME
Definition vdr.c:92
#define DELETE_MENU
#define SHUTDOWNRETRY
Definition vdr.c:80
#define DEFAULTSVDRPPORT