vdr  2.2.0
vdr.c
Go to the documentation of this file.
1 /*
2  * vdr.c: Video Disk Recorder main program
3  *
4  * Copyright (C) 2000, 2003, 2006, 2008, 2013 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 3.16 2015/02/10 14:13:12 kls Exp $
26  */
27 
28 #include <getopt.h>
29 #include <grp.h>
30 #include <langinfo.h>
31 #include <locale.h>
32 #include <pwd.h>
33 #include <signal.h>
34 #include <stdlib.h>
35 #include <sys/capability.h>
36 #include <sys/prctl.h>
37 #ifdef SDNOTIFY
38 #include <systemd/sd-daemon.h>
39 #endif
40 #include <termios.h>
41 #include <unistd.h>
42 #include "args.h"
43 #include "audio.h"
44 #include "channels.h"
45 #include "config.h"
46 #include "cutter.h"
47 #include "device.h"
48 #include "diseqc.h"
49 #include "dvbdevice.h"
50 #include "eitscan.h"
51 #include "epg.h"
52 #include "i18n.h"
53 #include "interface.h"
54 #include "keys.h"
55 #include "libsi/si.h"
56 #include "lirc.h"
57 #include "menu.h"
58 #include "osdbase.h"
59 #include "plugin.h"
60 #include "recording.h"
61 #include "shutdown.h"
62 #include "skinclassic.h"
63 #include "skinlcars.h"
64 #include "skinsttng.h"
65 #include "sourceparams.h"
66 #include "sources.h"
67 #include "status.h"
68 #include "themes.h"
69 #include "timers.h"
70 #include "tools.h"
71 #include "transfer.h"
72 #include "videodir.h"
73 
74 #define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings
75 #define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
76 #define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
77 #define SHUTDOWNRETRY 360 // seconds before trying again to shut down
78 #define SHUTDOWNFORCEPROMPT 5 // seconds to wait in user prompt to allow forcing shutdown
79 #define SHUTDOWNCANCELPROMPT 5 // seconds to wait in user prompt to allow canceling shutdown
80 #define RESTARTCANCELPROMPT 5 // seconds to wait in user prompt before restarting on SIGHUP
81 #define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start
82 #define CHANNELSAVEDELTA 600 // seconds before saving channels.conf after automatic modifications
83 #define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready
84 #define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed
85 #define TIMERCHECKDELTA 10 // seconds between checks for timers that need to see their channel
86 #define TIMERDEVICETIMEOUT 8 // seconds before a device used for timer check may be reused
87 #define TIMERLOOKAHEADTIME 60 // seconds before a non-VPS timer starts and the channel is switched if possible
88 #define VPSLOOKAHEADTIME 24 // hours within which VPS timers will make sure their events are up to date
89 #define VPSUPTODATETIME 3600 // seconds before the event or schedule of a VPS timer needs to be refreshed
90 
91 #define EXIT(v) { ShutdownHandler.Exit(v); goto Exit; }
92 
93 static int LastSignal = 0;
94 
95 static bool SetUser(const char *UserName, bool UserDump)
96 {
97  if (UserName) {
98  struct passwd *user = getpwnam(UserName);
99  if (!user) {
100  fprintf(stderr, "vdr: unknown user: '%s'\n", UserName);
101  return false;
102  }
103  if (setgid(user->pw_gid) < 0) {
104  fprintf(stderr, "vdr: cannot set group id %u: %s\n", (unsigned int)user->pw_gid, strerror(errno));
105  return false;
106  }
107  if (initgroups(user->pw_name, user->pw_gid) < 0) {
108  fprintf(stderr, "vdr: cannot set supplemental group ids for user %s: %s\n", user->pw_name, strerror(errno));
109  return false;
110  }
111  if (setuid(user->pw_uid) < 0) {
112  fprintf(stderr, "vdr: cannot set user id %u: %s\n", (unsigned int)user->pw_uid, strerror(errno));
113  return false;
114  }
115  if (UserDump && prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
116  fprintf(stderr, "vdr: warning - cannot set dumpable: %s\n", strerror(errno));
117  setenv("HOME", user->pw_dir, 1);
118  setenv("USER", user->pw_name, 1);
119  setenv("LOGNAME", user->pw_name, 1);
120  setenv("SHELL", user->pw_shell, 1);
121  }
122  return true;
123 }
124 
125 static bool DropCaps(void)
126 {
127  // drop all capabilities except selected ones
128  cap_t caps = cap_from_text("= cap_sys_nice,cap_sys_time,cap_net_raw=ep");
129  if (!caps) {
130  fprintf(stderr, "vdr: cap_from_text failed: %s\n", strerror(errno));
131  return false;
132  }
133  if (cap_set_proc(caps) == -1) {
134  fprintf(stderr, "vdr: cap_set_proc failed: %s\n", strerror(errno));
135  cap_free(caps);
136  return false;
137  }
138  cap_free(caps);
139  return true;
140 }
141 
142 static bool SetKeepCaps(bool On)
143 {
144  // set keeping capabilities during setuid() on/off
145  if (prctl(PR_SET_KEEPCAPS, On ? 1 : 0, 0, 0, 0) != 0) {
146  fprintf(stderr, "vdr: prctl failed\n");
147  return false;
148  }
149  return true;
150 }
151 
152 static void SignalHandler(int signum)
153 {
154  switch (signum) {
155  case SIGPIPE:
156  break;
157  case SIGHUP:
158  LastSignal = signum;
159  break;
160  default:
161  LastSignal = signum;
162  Interface->Interrupt();
164  }
165  signal(signum, SignalHandler);
166 }
167 
168 static void Watchdog(int signum)
169 {
170  // Something terrible must have happened that prevented the 'alarm()' from
171  // being called in time, so let's get out of here:
172  esyslog("PANIC: watchdog timer expired - exiting!");
173  exit(1);
174 }
175 
176 int main(int argc, char *argv[])
177 {
178  // Save terminal settings:
179 
180  struct termios savedTm;
181  bool HasStdin = (tcgetpgrp(STDIN_FILENO) == getpid() || getppid() != (pid_t)1) && tcgetattr(STDIN_FILENO, &savedTm) == 0;
182 
183  // Initiate locale:
184 
185  setlocale(LC_ALL, "");
186 
187  // Command line options:
188 
189 #define dd(a, b) (*a ? a : b)
190 #define DEFAULTSVDRPPORT 6419
191 #define DEFAULTWATCHDOG 0 // seconds
192 #define DEFAULTVIDEODIR VIDEODIR
193 #define DEFAULTCONFDIR dd(CONFDIR, VideoDirectory)
194 #define DEFAULTARGSDIR dd(ARGSDIR, "/etc/vdr/conf.d")
195 #define DEFAULTCACHEDIR dd(CACHEDIR, VideoDirectory)
196 #define DEFAULTRESDIR dd(RESDIR, ConfigDirectory)
197 #define DEFAULTPLUGINDIR PLUGINDIR
198 #define DEFAULTLOCDIR LOCDIR
199 #define DEFAULTEPGDATAFILENAME "epg.data"
200 
201  bool StartedAsRoot = false;
202  const char *VdrUser = NULL;
203  bool UserDump = false;
204  int SVDRPport = DEFAULTSVDRPPORT;
205  const char *AudioCommand = NULL;
206  const char *VideoDirectory = DEFAULTVIDEODIR;
207  const char *ConfigDirectory = NULL;
208  const char *CacheDirectory = NULL;
209  const char *ResourceDirectory = NULL;
210  const char *LocaleDirectory = DEFAULTLOCDIR;
211  const char *EpgDataFileName = DEFAULTEPGDATAFILENAME;
212  bool DisplayHelp = false;
213  bool DisplayVersion = false;
214  bool DaemonMode = false;
215  int SysLogTarget = LOG_USER;
216  bool MuteAudio = false;
217  int WatchdogTimeout = DEFAULTWATCHDOG;
218  const char *Terminal = NULL;
219  const char *OverrideCharacterTable = NULL;
220 #define DEPRECATED_VDR_CHARSET_OVERRIDE
221 #ifdef DEPRECATED_VDR_CHARSET_OVERRIDE
222  OverrideCharacterTable = getenv("VDR_CHARSET_OVERRIDE");
223  const char *DeprecatedVdrCharsetOverride = OverrideCharacterTable;
224 #endif
225 
226  bool UseKbd = true;
227  const char *LircDevice = NULL;
228 #if !defined(REMOTE_KBD)
229  UseKbd = false;
230 #endif
231 #if defined(REMOTE_LIRC)
232  LircDevice = LIRC_DEVICE;
233 #endif
234 #if defined(VDR_USER)
235  VdrUser = VDR_USER;
236 #endif
237 
238  cArgs *Args = NULL;
239  if (argc == 1) {
240  Args = new cArgs(argv[0]);
241  if (Args->ReadDirectory(DEFAULTARGSDIR)) {
242  argc = Args->GetArgc();
243  argv = Args->GetArgv();
244  }
245  }
246 
247  cVideoDirectory::SetName(VideoDirectory);
248  cPluginManager PluginManager(DEFAULTPLUGINDIR);
249 
250  static struct option long_options[] = {
251  { "audio", required_argument, NULL, 'a' },
252  { "cachedir", required_argument, NULL, 'c' | 0x100 },
253  { "chartab", required_argument, NULL, 'c' | 0x200 },
254  { "config", required_argument, NULL, 'c' },
255  { "daemon", no_argument, NULL, 'd' },
256  { "device", required_argument, NULL, 'D' },
257  { "dirnames", required_argument, NULL, 'd' | 0x100 },
258  { "edit", required_argument, NULL, 'e' | 0x100 },
259  { "epgfile", required_argument, NULL, 'E' },
260  { "filesize", required_argument, NULL, 'f' | 0x100 },
261  { "genindex", required_argument, NULL, 'g' | 0x100 },
262  { "grab", required_argument, NULL, 'g' },
263  { "help", no_argument, NULL, 'h' },
264  { "instance", required_argument, NULL, 'i' },
265  { "lib", required_argument, NULL, 'L' },
266  { "lirc", optional_argument, NULL, 'l' | 0x100 },
267  { "localedir",required_argument, NULL, 'l' | 0x200 },
268  { "log", required_argument, NULL, 'l' },
269  { "mute", no_argument, NULL, 'm' },
270  { "no-kbd", no_argument, NULL, 'n' | 0x100 },
271  { "plugin", required_argument, NULL, 'P' },
272  { "port", required_argument, NULL, 'p' },
273  { "record", required_argument, NULL, 'r' },
274  { "resdir", required_argument, NULL, 'r' | 0x100 },
275  { "showargs", optional_argument, NULL, 's' | 0x200 },
276  { "shutdown", required_argument, NULL, 's' },
277  { "split", no_argument, NULL, 's' | 0x100 },
278  { "terminal", required_argument, NULL, 't' },
279  { "updindex", required_argument, NULL, 'u' | 0x200 },
280  { "user", required_argument, NULL, 'u' },
281  { "userdump", no_argument, NULL, 'u' | 0x100 },
282  { "version", no_argument, NULL, 'V' },
283  { "vfat", no_argument, NULL, 'v' | 0x100 },
284  { "video", required_argument, NULL, 'v' },
285  { "watchdog", required_argument, NULL, 'w' },
286  { NULL, no_argument, NULL, 0 }
287  };
288 
289  int c;
290  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) {
291  switch (c) {
292  case 'a': AudioCommand = optarg;
293  break;
294  case 'c' | 0x100:
295  CacheDirectory = optarg;
296  break;
297  case 'c' | 0x200:
298  OverrideCharacterTable = optarg;
299  break;
300  case 'c': ConfigDirectory = optarg;
301  break;
302  case 'd': DaemonMode = true;
303  break;
304  case 'D': if (isnumber(optarg)) {
305  int n = atoi(optarg);
306  if (0 <= n && n < MAXDEVICES) {
308  break;
309  }
310  }
311  fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
312  return 2;
313  case 'd' | 0x100: {
314  char *s = optarg;
315  if (*s != ',') {
316  int n = strtol(s, &s, 10);
317  if (n <= 0 || n >= PATH_MAX) { // PATH_MAX includes the terminating 0
318  fprintf(stderr, "vdr: invalid directory path length: %s\n", optarg);
319  return 2;
320  }
321  DirectoryPathMax = n;
322  if (!*s)
323  break;
324  if (*s != ',') {
325  fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
326  return 2;
327  }
328  }
329  s++;
330  if (!*s)
331  break;
332  if (*s != ',') {
333  int n = strtol(s, &s, 10);
334  if (n <= 0 || n > NAME_MAX) { // NAME_MAX excludes the terminating 0
335  fprintf(stderr, "vdr: invalid directory name length: %s\n", optarg);
336  return 2;
337  }
338  DirectoryNameMax = n;
339  if (!*s)
340  break;
341  if (*s != ',') {
342  fprintf(stderr, "vdr: invalid delimiter: %s\n", optarg);
343  return 2;
344  }
345  }
346  s++;
347  if (!*s)
348  break;
349  int n = strtol(s, &s, 10);
350  if (n != 0 && n != 1) {
351  fprintf(stderr, "vdr: invalid directory encoding: %s\n", optarg);
352  return 2;
353  }
354  DirectoryEncoding = n;
355  if (*s) {
356  fprintf(stderr, "vdr: unexpected data: %s\n", optarg);
357  return 2;
358  }
359  }
360  break;
361  case 'e' | 0x100:
362  return CutRecording(optarg) ? 0 : 2;
363  case 'E': EpgDataFileName = (*optarg != '-' ? optarg : NULL);
364  break;
365  case 'f' | 0x100:
366  Setup.MaxVideoFileSize = StrToNum(optarg) / MEGABYTE(1);
371  break;
372  case 'g' | 0x100:
373  return GenerateIndex(optarg) ? 0 : 2;
374  case 'g': cSVDRP::SetGrabImageDir(*optarg != '-' ? optarg : NULL);
375  break;
376  case 'h': DisplayHelp = true;
377  break;
378  case 'i': if (isnumber(optarg)) {
379  InstanceId = atoi(optarg);
380  if (InstanceId >= 0)
381  break;
382  }
383  fprintf(stderr, "vdr: invalid instance id: %s\n", optarg);
384  return 2;
385  case 'l': {
386  char *p = strchr(optarg, '.');
387  if (p)
388  *p = 0;
389  if (isnumber(optarg)) {
390  int l = atoi(optarg);
391  if (0 <= l && l <= 3) {
392  SysLogLevel = l;
393  if (!p)
394  break;
395  if (isnumber(p + 1)) {
396  int l = atoi(p + 1);
397  if (0 <= l && l <= 7) {
398  int targets[] = { LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
399  SysLogTarget = targets[l];
400  break;
401  }
402  }
403  }
404  }
405  if (p)
406  *p = '.';
407  fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
408  return 2;
409  }
410  case 'L': if (access(optarg, R_OK | X_OK) == 0)
411  PluginManager.SetDirectory(optarg);
412  else {
413  fprintf(stderr, "vdr: can't access plugin directory: %s\n", optarg);
414  return 2;
415  }
416  break;
417  case 'l' | 0x100:
418  LircDevice = optarg ? optarg : LIRC_DEVICE;
419  break;
420  case 'l' | 0x200:
421  if (access(optarg, R_OK | X_OK) == 0)
422  LocaleDirectory = optarg;
423  else {
424  fprintf(stderr, "vdr: can't access locale directory: %s\n", optarg);
425  return 2;
426  }
427  break;
428  case 'm': MuteAudio = true;
429  break;
430  case 'n' | 0x100:
431  UseKbd = false;
432  break;
433  case 'p': if (isnumber(optarg))
434  SVDRPport = atoi(optarg);
435  else {
436  fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
437  return 2;
438  }
439  break;
440  case 'P': PluginManager.AddPlugin(optarg);
441  break;
442  case 'r': cRecordingUserCommand::SetCommand(optarg);
443  break;
444  case 'r' | 0x100:
445  ResourceDirectory = optarg;
446  break;
447  case 's': ShutdownHandler.SetShutdownCommand(optarg);
448  break;
449  case 's' | 0x100:
451  break;
452  case 's' | 0x200: {
453  const char *ArgsDir = optarg ? optarg : DEFAULTARGSDIR;
454  cArgs Args(argv[0]);
455  if (!Args.ReadDirectory(ArgsDir)) {
456  fprintf(stderr, "vdr: can't read arguments from directory: %s\n", ArgsDir);
457  return 2;
458  }
459  int c = Args.GetArgc();
460  char **v = Args.GetArgv();
461  for (int i = 1; i < c; i++)
462  printf("%s\n", v[i]);
463  return 0;
464  }
465  case 't': Terminal = optarg;
466  if (access(Terminal, R_OK | W_OK) < 0) {
467  fprintf(stderr, "vdr: can't access terminal: %s\n", Terminal);
468  return 2;
469  }
470  break;
471  case 'u': if (*optarg)
472  VdrUser = optarg;
473  break;
474  case 'u' | 0x100:
475  UserDump = true;
476  break;
477  case 'u' | 0x200:
478  return GenerateIndex(optarg, true) ? 0 : 2;
479  case 'V': DisplayVersion = true;
480  break;
481  case 'v' | 0x100:
482  DirectoryPathMax = 250;
483  DirectoryNameMax = 40;
484  DirectoryEncoding = true;
485  break;
486  case 'v': VideoDirectory = optarg;
487  while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
488  optarg[strlen(optarg) - 1] = 0;
489  cVideoDirectory::SetName(VideoDirectory);
490  break;
491  case 'w': if (isnumber(optarg)) {
492  int t = atoi(optarg);
493  if (t >= 0) {
494  WatchdogTimeout = t;
495  break;
496  }
497  }
498  fprintf(stderr, "vdr: invalid watchdog timeout: %s\n", optarg);
499  return 2;
500  default: return 2;
501  }
502  }
503 
504  // Set user id in case we were started as root:
505 
506  if (VdrUser && geteuid() == 0) {
507  StartedAsRoot = true;
508  if (strcmp(VdrUser, "root")) {
509  if (!SetKeepCaps(true))
510  return 2;
511  if (!SetUser(VdrUser, UserDump))
512  return 2;
513  if (!SetKeepCaps(false))
514  return 2;
515  if (!DropCaps())
516  return 2;
517  }
518  }
519 
520  // Help and version info:
521 
522  if (DisplayHelp || DisplayVersion) {
523  if (!PluginManager.HasPlugins())
524  PluginManager.AddPlugin("*"); // adds all available plugins
525  PluginManager.LoadPlugins();
526  if (DisplayHelp) {
527  printf("Usage: vdr [OPTIONS]\n\n" // for easier orientation, this is column 80|
528  " -a CMD, --audio=CMD send Dolby Digital audio to stdin of command CMD\n"
529  " --cachedir=DIR save cache files in DIR (default: %s)\n"
530  " --chartab=CHARACTER_TABLE\n"
531  " set the character table to use for strings in the\n"
532  " DVB data stream that don't begin with a character\n"
533  " table indicator, but don't use the standard default\n"
534  " character table (for instance ISO-8859-9)\n"
535  " -c DIR, --config=DIR read config files from DIR (default: %s)\n"
536  " -d, --daemon run in daemon mode\n"
537  " -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
538  " there may be several -D options (default: all DVB\n"
539  " devices will be used)\n"
540  " --dirnames=PATH[,NAME[,ENC]]\n"
541  " set the maximum directory path length to PATH\n"
542  " (default: %d); if NAME is also given, it defines\n"
543  " the maximum directory name length (default: %d);\n"
544  " the optional ENC can be 0 or 1, and controls whether\n"
545  " special characters in directory names are encoded as\n"
546  " hex values (default: 0); if PATH or NAME are left\n"
547  " empty (as in \",,1\" to only set ENC), the defaults\n"
548  " apply\n"
549  " --edit=REC cut recording REC and exit\n"
550  " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
551  " '%s' in the cache directory)\n"
552  " '-E-' disables this\n"
553  " if FILE is a directory, the default EPG file will be\n"
554  " created in that directory\n"
555  " --filesize=SIZE limit video files to SIZE bytes (default is %dM)\n"
556  " only useful in conjunction with --edit\n"
557  " --genindex=REC generate index for recording REC and exit\n"
558  " -g DIR, --grab=DIR write images from the SVDRP command GRAB into the\n"
559  " given DIR; DIR must be the full path name of an\n"
560  " existing directory, without any \"..\", double '/'\n"
561  " or symlinks (default: none, same as -g-)\n"
562  " -h, --help print this help and exit\n"
563  " -i ID, --instance=ID use ID as the id of this VDR instance (default: 0)\n"
564  " -l LEVEL, --log=LEVEL set log level (default: 3)\n"
565  " 0 = no logging, 1 = errors only,\n"
566  " 2 = errors and info, 3 = errors, info and debug\n"
567  " if logging should be done to LOG_LOCALn instead of\n"
568  " LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7)\n"
569  " -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n"
570  " --lirc[=PATH] use a LIRC remote control device, attached to PATH\n"
571  " (default: %s)\n"
572  " --localedir=DIR search for locale files in DIR (default is\n"
573  " %s)\n"
574  " -m, --mute mute audio of the primary DVB device at startup\n"
575  " --no-kbd don't use the keyboard as an input device\n"
576  " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
577  " 0 turns off SVDRP\n"
578  " -P OPT, --plugin=OPT load a plugin defined by the given options\n"
579  " -r CMD, --record=CMD call CMD before and after a recording, and after\n"
580  " a recording has been edited or deleted\n"
581  " --resdir=DIR read resource files from DIR (default: %s)\n"
582  " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
583  " --split split edited files at the editing marks (only\n"
584  " useful in conjunction with --edit)\n"
585  " --showargs[=DIR] print the arguments read from DIR and exit\n"
586  " (default: %s)\n"
587  " -t TTY, --terminal=TTY controlling tty\n"
588  " -u USER, --user=USER run as user USER; only applicable if started as\n"
589  " root\n"
590  " --updindex=REC update index for recording REC and exit\n"
591  " --userdump allow coredumps if -u is given (debugging)\n"
592  " -v DIR, --video=DIR use DIR as video directory (default: %s)\n"
593  " -V, --version print version information and exit\n"
594  " --vfat for backwards compatibility (same as\n"
595  " --dirnames=250,40,1)\n"
596  " -w SEC, --watchdog=SEC activate the watchdog timer with a timeout of SEC\n"
597  " seconds (default: %d); '0' disables the watchdog\n"
598  "\n",
601  PATH_MAX - 1,
602  NAME_MAX,
606  LIRC_DEVICE,
613  );
614  }
615  if (DisplayVersion)
616  printf("vdr (%s/%s) - The Video Disk Recorder\n", VDRVERSION, APIVERSION);
617  if (PluginManager.HasPlugins()) {
618  if (DisplayHelp)
619  printf("Plugins: vdr -P\"name [OPTIONS]\"\n\n");
620  for (int i = 0; ; i++) {
621  cPlugin *p = PluginManager.GetPlugin(i);
622  if (p) {
623  const char *help = p->CommandLineHelp();
624  printf("%s (%s) - %s\n", p->Name(), p->Version(), p->Description());
625  if (DisplayHelp && help) {
626  printf("\n");
627  puts(help);
628  }
629  }
630  else
631  break;
632  }
633  }
634  return 0;
635  }
636 
637  // Log file:
638 
639  if (SysLogLevel > 0)
640  openlog("vdr", LOG_CONS, SysLogTarget); // LOG_PID doesn't work as expected under NPTL
641 
642  // Check the video directory:
643 
644  if (!DirectoryOk(VideoDirectory, true)) {
645  fprintf(stderr, "vdr: can't access video directory %s\n", VideoDirectory);
646  return 2;
647  }
648 
649  // Daemon mode:
650 
651  if (DaemonMode) {
652  if (daemon(1, 0) == -1) {
653  fprintf(stderr, "vdr: %m\n");
654  esyslog("ERROR: %m");
655  return 2;
656  }
657  }
658  else if (Terminal) {
659  // Claim new controlling terminal
660  stdin = freopen(Terminal, "r", stdin);
661  stdout = freopen(Terminal, "w", stdout);
662  stderr = freopen(Terminal, "w", stderr);
663  HasStdin = true;
664  tcgetattr(STDIN_FILENO, &savedTm);
665  }
666 
667  isyslog("VDR version %s started", VDRVERSION);
668  if (StartedAsRoot && VdrUser)
669  isyslog("switched to user '%s'", VdrUser);
670  if (DaemonMode)
671  dsyslog("running as daemon (tid=%d)", cThread::ThreadId());
673 
674  // Set the system character table:
675 
676  char *CodeSet = NULL;
677  if (setlocale(LC_CTYPE, ""))
678  CodeSet = nl_langinfo(CODESET);
679  else {
680  char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
681  if (LangEnv) {
682  CodeSet = strchr(LangEnv, '.');
683  if (CodeSet)
684  CodeSet++; // skip the dot
685  }
686  }
687  if (CodeSet) {
688  bool known = SI::SetSystemCharacterTable(CodeSet);
689  isyslog("codeset is '%s' - %s", CodeSet, known ? "known" : "unknown");
691  }
692 #ifdef DEPRECATED_VDR_CHARSET_OVERRIDE
693  if (DeprecatedVdrCharsetOverride)
694  isyslog("use of environment variable VDR_CHARSET_OVERRIDE (%s) is deprecated!", DeprecatedVdrCharsetOverride);
695 #endif
696  if (OverrideCharacterTable) {
697  isyslog("override character table is '%s'", OverrideCharacterTable);
698  SI::SetOverrideCharacterTable(OverrideCharacterTable);
699  }
700 
701  // Initialize internationalization:
702 
703  I18nInitialize(LocaleDirectory);
704 
705  // Main program loop variables - need to be here to have them initialized before any EXIT():
706 
707  cEpgDataReader EpgDataReader;
708  cOsdObject *Menu = NULL;
709  int LastChannel = 0;
710  int LastTimerChannel = -1;
711  int PreviousChannel[2] = { 1, 1 };
712  int PreviousChannelIndex = 0;
713  time_t LastChannelChanged = time(NULL);
714  time_t LastInteract = 0;
715  int MaxLatencyTime = 0;
716  bool InhibitEpgScan = false;
717  bool IsInfoMenu = false;
718  cSkin *CurrentSkin = NULL;
719 
720  // Load plugins:
721 
722  if (!PluginManager.LoadPlugins(true))
723  EXIT(2);
724 
725  // Directories:
726 
727  if (!ConfigDirectory)
728  ConfigDirectory = DEFAULTCONFDIR;
729  cPlugin::SetConfigDirectory(ConfigDirectory);
730  if (!CacheDirectory)
731  CacheDirectory = DEFAULTCACHEDIR;
732  cPlugin::SetCacheDirectory(CacheDirectory);
733  if (!ResourceDirectory)
734  ResourceDirectory = DEFAULTRESDIR;
735  cPlugin::SetResourceDirectory(ResourceDirectory);
736  cThemes::SetThemesDirectory(AddDirectory(ConfigDirectory, "themes"));
737 
738  // Configuration data:
739 
740  Setup.Load(AddDirectory(ConfigDirectory, "setup.conf"));
741  Sources.Load(AddDirectory(ConfigDirectory, "sources.conf"), true, true);
742  Diseqcs.Load(AddDirectory(ConfigDirectory, "diseqc.conf"), true, Setup.DiSEqC);
743  Scrs.Load(AddDirectory(ConfigDirectory, "scr.conf"), true);
744  Channels.Load(AddDirectory(ConfigDirectory, "channels.conf"), false, true);
745  Timers.Load(AddDirectory(ConfigDirectory, "timers.conf"));
746  Commands.Load(AddDirectory(ConfigDirectory, "commands.conf"));
747  RecordingCommands.Load(AddDirectory(ConfigDirectory, "reccmds.conf"));
748  SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
749  Keys.Load(AddDirectory(ConfigDirectory, "remote.conf"));
750  KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true);
751  Folders.Load(AddDirectory(ConfigDirectory, "folders.conf"));
752 
754  const char *msg = "no fonts available - OSD will not show any text!";
755  fprintf(stderr, "vdr: %s\n", msg);
756  esyslog("ERROR: %s", msg);
757  }
758 
759  // Recordings:
760 
761  Recordings.Update();
763 
764  // EPG data:
765 
766  if (EpgDataFileName) {
767  const char *EpgDirectory = NULL;
768  if (DirectoryOk(EpgDataFileName)) {
769  EpgDirectory = EpgDataFileName;
770  EpgDataFileName = DEFAULTEPGDATAFILENAME;
771  }
772  else if (*EpgDataFileName != '/' && *EpgDataFileName != '.')
773  EpgDirectory = CacheDirectory;
774  if (EpgDirectory)
775  cSchedules::SetEpgDataFileName(AddDirectory(EpgDirectory, EpgDataFileName));
776  else
777  cSchedules::SetEpgDataFileName(EpgDataFileName);
778  EpgDataReader.Start();
779  }
780 
781  // DVB interfaces:
782 
785 
786  // Initialize plugins:
787 
788  if (!PluginManager.InitializePlugins())
789  EXIT(2);
790 
791  // Primary device:
792 
794  if (!cDevice::PrimaryDevice() || !cDevice::PrimaryDevice()->HasDecoder()) {
795  if (cDevice::PrimaryDevice() && !cDevice::PrimaryDevice()->HasDecoder())
796  isyslog("device %d has no MPEG decoder", cDevice::PrimaryDevice()->DeviceNumber() + 1);
797  for (int i = 0; i < cDevice::NumDevices(); i++) {
798  cDevice *d = cDevice::GetDevice(i);
799  if (d && d->HasDecoder()) {
800  isyslog("trying device number %d instead", i + 1);
801  if (cDevice::SetPrimaryDevice(i + 1)) {
802  Setup.PrimaryDVB = i + 1;
803  break;
804  }
805  }
806  }
807  if (!cDevice::PrimaryDevice()) {
808  const char *msg = "no primary device found - using first device!";
809  fprintf(stderr, "vdr: %s\n", msg);
810  esyslog("ERROR: %s", msg);
812  EXIT(2);
813  if (!cDevice::PrimaryDevice()) {
814  const char *msg = "no primary device found - giving up!";
815  fprintf(stderr, "vdr: %s\n", msg);
816  esyslog("ERROR: %s", msg);
817  EXIT(2);
818  }
819  }
820  }
821 
822  // Check for timers in automatic start time window:
823 
825 
826  // User interface:
827 
828  Interface = new cInterface(SVDRPport);
829 
830  // Default skins:
831 
832  new cSkinLCARS;
833  new cSkinSTTNG;
834  new cSkinClassic;
837  CurrentSkin = Skins.Current();
838 
839  // Start plugins:
840 
841  if (!PluginManager.StartPlugins())
842  EXIT(2);
843 
844  // Set skin and theme in case they're implemented by a plugin:
845 
846  if (!CurrentSkin || CurrentSkin == Skins.Current() && strcmp(Skins.Current()->Name(), Setup.OSDSkin) != 0) {
849  }
850 
851  // Remote Controls:
852  if (LircDevice)
853  new cLircRemote(LircDevice);
854  if (!DaemonMode && HasStdin && UseKbd)
855  new cKbdRemote;
856  Interface->LearnKeys();
857 
858  // External audio:
859 
860  if (AudioCommand)
861  new cExternalAudio(AudioCommand);
862 
863  // Positioner:
864 
865  if (!cPositioner::GetPositioner()) // no plugin has created a positioner
866  new cDiseqcPositioner;
867 
868  // Channel:
869 
871  dsyslog("not all devices ready after %d seconds", DEVICEREADYTIMEOUT);
873  dsyslog("not all CAM slots ready after %d seconds", DEVICEREADYTIMEOUT);
874  if (*Setup.InitialChannel) {
875  if (isnumber(Setup.InitialChannel)) { // for compatibility with old setup.conf files
876  if (cChannel *Channel = Channels.GetByNumber(atoi(Setup.InitialChannel)))
877  Setup.InitialChannel = Channel->GetChannelID().ToString();
878  }
880  Setup.CurrentChannel = Channel->Number();
881  }
882  if (Setup.InitialVolume >= 0)
885  if (MuteAudio)
887  else
889 
890  // Signal handlers:
891 
892  if (signal(SIGHUP, SignalHandler) == SIG_IGN) signal(SIGHUP, SIG_IGN);
893  if (signal(SIGINT, SignalHandler) == SIG_IGN) signal(SIGINT, SIG_IGN);
894  if (signal(SIGTERM, SignalHandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
895  if (signal(SIGPIPE, SignalHandler) == SIG_IGN) signal(SIGPIPE, SIG_IGN);
896  if (WatchdogTimeout > 0)
897  if (signal(SIGALRM, Watchdog) == SIG_IGN) signal(SIGALRM, SIG_IGN);
898 
899  // Watchdog:
900 
901  if (WatchdogTimeout > 0) {
902  dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout);
903  alarm(WatchdogTimeout); // Initial watchdog timer start
904  }
905 
906 #ifdef SDNOTIFY
907  sd_notify(0, "READY=1\nSTATUS=Ready");
908 #endif
909 
910  // Main program loop:
911 
912 #define DELETE_MENU ((IsInfoMenu &= (Menu == NULL)), delete Menu, Menu = NULL)
913 
914  while (!ShutdownHandler.DoExit()) {
915 #ifdef DEBUGRINGBUFFERS
916  cRingBufferLinear::PrintDebugRBL();
917 #endif
918  // Attach launched player control:
920 
921  time_t Now = time(NULL);
922 
923  // Make sure we have a visible programme in case device usage has changed:
925  static time_t lastTime = 0;
927  if (!CamMenuActive() && Now - lastTime > MINCHANNELWAIT) { // !CamMenuActive() to avoid interfering with the CAM if a CAM menu is open
929  if (Channel && (Channel->Vpid() || Channel->Apid(0) || Channel->Dpid(0))) {
930  if (cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels.SwitchTo(Channel->Number())) // try to switch to the original channel...
931  ;
932  else if (LastTimerChannel > 0) {
933  Channel = Channels.GetByNumber(LastTimerChannel);
934  if (Channel && cDevice::GetDeviceForTransponder(Channel, LIVEPRIORITY) && Channels.SwitchTo(LastTimerChannel)) // ...or the one used by the last timer
935  ;
936  }
937  }
938  lastTime = Now; // don't do this too often
939  LastTimerChannel = -1;
940  }
941  }
942  else
943  lastTime = 0; // makes sure we immediately try again next time
944  }
945  // Update the OSD size:
946  {
947  static time_t lastOsdSizeUpdate = 0;
948  if (Now != lastOsdSizeUpdate) { // once per second
950  lastOsdSizeUpdate = Now;
951  }
952  }
953  // Restart the Watchdog timer:
954  if (WatchdogTimeout > 0) {
955  int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
956  if (LatencyTime > MaxLatencyTime) {
957  MaxLatencyTime = LatencyTime;
958  dsyslog("max. latency time %d seconds", MaxLatencyTime);
959  }
960  }
961  // Handle channel and timer modifications:
962  if (!Channels.BeingEdited() && !Timers.BeingEdited()) {
963  int modified = Channels.Modified();
964  static time_t ChannelSaveTimeout = 0;
965  static int TimerState = 0;
966  // Channels and timers need to be stored in a consistent manner,
967  // therefore if one of them is changed, we save both.
968  if (modified == CHANNELSMOD_USER || Timers.Modified(TimerState))
969  ChannelSaveTimeout = 1; // triggers an immediate save
970  else if (modified && !ChannelSaveTimeout)
971  ChannelSaveTimeout = Now + CHANNELSAVEDELTA;
972  bool timeout = ChannelSaveTimeout == 1 || ChannelSaveTimeout && Now > ChannelSaveTimeout && !cRecordControls::Active();
973  if ((modified || timeout) && Channels.Lock(false, 100)) {
974  if (timeout) {
975  Channels.Save();
976  Timers.Save();
977  ChannelSaveTimeout = 0;
978  }
979  for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
980  if (Channel->Modification(CHANNELMOD_RETUNE)) {
982  if (Channel->Number() == cDevice::CurrentChannel() && cDevice::PrimaryDevice()->HasDecoder()) {
984  if (cDevice::ActualDevice()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
985  isyslog("retuning due to modification of channel %d (%s)", Channel->Number(), Channel->Name());
986  Channels.SwitchTo(Channel->Number());
987  }
988  }
989  }
990  cStatus::MsgChannelChange(Channel);
991  }
992  }
993  Channels.Unlock();
994  }
995  }
996  // Channel display:
997  if (!EITScanner.Active() && cDevice::CurrentChannel() != LastChannel) {
998  if (!Menu)
999  Menu = new cDisplayChannel(cDevice::CurrentChannel(), LastChannel >= 0);
1000  LastChannel = cDevice::CurrentChannel();
1001  LastChannelChanged = Now;
1002  }
1003  if (Now - LastChannelChanged >= Setup.ZapTimeout && LastChannel != PreviousChannel[PreviousChannelIndex])
1004  PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel;
1005  // Timers and Recordings:
1006  if (!Timers.BeingEdited()) {
1007  // Assign events to timers:
1008  Timers.SetEvents();
1009  // Must do all following calls with the exact same time!
1010  // Process ongoing recordings:
1012  // Start new recordings:
1013  cTimer *Timer = Timers.GetMatch(Now);
1014  if (Timer) {
1015  if (!cRecordControls::Start(Timer))
1016  Timer->SetPending(true);
1017  else
1018  LastTimerChannel = Timer->Channel()->Number();
1019  }
1020  // Make sure timers "see" their channel early enough:
1021  static time_t LastTimerCheck = 0;
1022  if (Now - LastTimerCheck > TIMERCHECKDELTA) { // don't do this too often
1023  InhibitEpgScan = false;
1024  for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) {
1025  bool InVpsMargin = false;
1026  bool NeedsTransponder = false;
1027  if (Timer->HasFlags(tfActive) && !Timer->Recording()) {
1028  if (Timer->HasFlags(tfVps)) {
1029  if (Timer->Matches(Now, true, Setup.VpsMargin)) {
1030  InVpsMargin = true;
1031  Timer->SetInVpsMargin(InVpsMargin);
1032  }
1033  else if (Timer->Event()) {
1034  InVpsMargin = Timer->Event()->StartTime() <= Now && Now < Timer->Event()->EndTime();
1035  NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
1036  }
1037  else {
1038  cSchedulesLock SchedulesLock;
1039  const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
1040  if (Schedules) {
1041  const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel());
1042  InVpsMargin = !Schedule; // we must make sure we have the schedule
1043  NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME);
1044  }
1045  }
1046  InhibitEpgScan |= InVpsMargin | NeedsTransponder;
1047  }
1048  else
1049  NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME);
1050  }
1051  if (NeedsTransponder || InVpsMargin) {
1052  // Find a device that provides the required transponder:
1054  if (!Device && InVpsMargin)
1056  // Switch the device to the transponder:
1057  if (Device) {
1058  bool HadProgramme = cDevice::PrimaryDevice()->HasProgramme();
1059  if (!Device->IsTunedToTransponder(Timer->Channel())) {
1060  if (Device == cDevice::ActualDevice() && !Device->IsPrimaryDevice())
1061  cDevice::PrimaryDevice()->StopReplay(); // stop transfer mode
1062  dsyslog("switching device %d to channel %d (%s)", Device->DeviceNumber() + 1, Timer->Channel()->Number(), Timer->Channel()->Name());
1063  if (Device->SwitchChannel(Timer->Channel(), false))
1065  }
1066  if (cDevice::PrimaryDevice()->HasDecoder() && HadProgramme && !cDevice::PrimaryDevice()->HasProgramme())
1067  Skins.QueueMessage(mtInfo, tr("Upcoming recording!")); // the previous SwitchChannel() has switched away the current live channel
1068  }
1069  }
1070  }
1071  LastTimerCheck = Now;
1072  }
1073  // Delete expired timers:
1075  }
1076  if (!Menu && Recordings.NeedsUpdate()) {
1077  Recordings.Update();
1079  }
1080  // CAM control:
1081  if (!Menu && !cOsd::IsOpen())
1082  Menu = CamControl();
1083  // Queued messages:
1084  if (!Skins.IsOpen())
1086  // User Input:
1087  cOsdObject *Interact = Menu ? Menu : cControl::Control();
1088  eKeys key = Interface->GetKey(!Interact || !Interact->NeedsFastResponse());
1089  if (ISREALKEY(key)) {
1090  EITScanner.Activity();
1091  // Cancel shutdown countdown:
1094  // Set user active for MinUserInactivity time in the future:
1096  }
1097  // Keys that must work independent of any interactive mode:
1098  switch (int(key)) {
1099  // Menu control:
1100  case kMenu: {
1101  key = kNone; // nobody else needs to see this key
1102  bool WasOpen = Interact != NULL;
1103  bool WasMenu = Interact && Interact->IsMenu();
1104  if (Menu)
1105  DELETE_MENU;
1106  else if (cControl::Control()) {
1107  if (cOsd::IsOpen())
1108  cControl::Control()->Hide();
1109  else
1110  WasOpen = false;
1111  }
1112  if (!WasOpen || !WasMenu && !Setup.MenuKeyCloses)
1113  Menu = new cMenuMain;
1114  }
1115  break;
1116  // Info:
1117  case kInfo: {
1118  if (IsInfoMenu) {
1119  key = kNone; // nobody else needs to see this key
1120  DELETE_MENU;
1121  }
1122  else if (!Menu) {
1123  IsInfoMenu = true;
1124  if (cControl::Control()) {
1125  cControl::Control()->Hide();
1126  Menu = cControl::Control()->GetInfo();
1127  if (Menu)
1128  Menu->Show();
1129  else
1130  IsInfoMenu = false;
1131  }
1132  else {
1133  cRemote::Put(kOk, true);
1134  cRemote::Put(kSchedule, true);
1135  }
1136  key = kNone; // nobody else needs to see this key
1137  }
1138  }
1139  break;
1140  // Direct main menu functions:
1141  #define DirectMainFunction(function)\
1142  { DELETE_MENU;\
1143  if (cControl::Control())\
1144  cControl::Control()->Hide();\
1145  Menu = new cMenuMain(function);\
1146  key = kNone; } // nobody else needs to see this key
1147  case kSchedule: DirectMainFunction(osSchedule); break;
1148  case kChannels: DirectMainFunction(osChannels); break;
1149  case kTimers: DirectMainFunction(osTimers); break;
1151  case kSetup: DirectMainFunction(osSetup); break;
1152  case kCommands: DirectMainFunction(osCommands); break;
1153  case kUser0 ... kUser9: cRemote::PutMacro(key); key = kNone; break;
1154  case k_Plugin: {
1155  const char *PluginName = cRemote::GetPlugin();
1156  if (PluginName) {
1157  DELETE_MENU;
1158  if (cControl::Control())
1159  cControl::Control()->Hide();
1160  cPlugin *plugin = cPluginManager::GetPlugin(PluginName);
1161  if (plugin) {
1162  Menu = plugin->MainMenuAction();
1163  if (Menu)
1164  Menu->Show();
1165  }
1166  else
1167  esyslog("ERROR: unknown plugin '%s'", PluginName);
1168  }
1169  key = kNone; // nobody else needs to see these keys
1170  }
1171  break;
1172  // Channel up/down:
1173  case kChanUp|k_Repeat:
1174  case kChanUp:
1175  case kChanDn|k_Repeat:
1176  case kChanDn:
1177  if (!Interact)
1178  Menu = new cDisplayChannel(NORMALKEY(key));
1179  else if (cDisplayChannel::IsOpen() || cControl::Control()) {
1180  Interact->ProcessKey(key);
1181  continue;
1182  }
1183  else
1184  cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1);
1185  key = kNone; // nobody else needs to see these keys
1186  break;
1187  // Volume control:
1188  case kVolUp|k_Repeat:
1189  case kVolUp:
1190  case kVolDn|k_Repeat:
1191  case kVolDn:
1192  case kMute:
1193  if (key == kMute) {
1194  if (!cDevice::PrimaryDevice()->ToggleMute() && !Menu) {
1195  key = kNone; // nobody else needs to see these keys
1196  break; // no need to display "mute off"
1197  }
1198  }
1199  else
1201  if (!Menu && !cOsd::IsOpen())
1202  Menu = cDisplayVolume::Create();
1204  key = kNone; // nobody else needs to see these keys
1205  break;
1206  // Audio track control:
1207  case kAudio:
1208  if (cControl::Control())
1209  cControl::Control()->Hide();
1210  if (!cDisplayTracks::IsOpen()) {
1211  DELETE_MENU;
1212  Menu = cDisplayTracks::Create();
1213  }
1214  else
1216  key = kNone;
1217  break;
1218  // Subtitle track control:
1219  case kSubtitles:
1220  if (cControl::Control())
1221  cControl::Control()->Hide();
1223  DELETE_MENU;
1225  }
1226  else
1228  key = kNone;
1229  break;
1230  // Pausing live video:
1231  case kPlayPause:
1232  case kPause:
1233  if (!cControl::Control()) {
1234  DELETE_MENU;
1235  if (Setup.PauseKeyHandling) {
1236  if (Setup.PauseKeyHandling > 1 || Interface->Confirm(tr("Pause live video?"))) {
1238  Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1239  }
1240  }
1241  key = kNone; // nobody else needs to see this key
1242  }
1243  break;
1244  // Instant recording:
1245  case kRecord:
1246  if (!cControl::Control()) {
1247  if (cRecordControls::Start())
1248  Skins.QueueMessage(mtInfo, tr("Recording started"));
1249  key = kNone; // nobody else needs to see this key
1250  }
1251  break;
1252  // Power off:
1253  case kPower:
1254  isyslog("Power button pressed");
1255  DELETE_MENU;
1256  // Check for activity, request power button again if active:
1257  if (!ShutdownHandler.ConfirmShutdown(false) && Skins.Message(mtWarning, tr("VDR will shut down later - press Power to force"), SHUTDOWNFORCEPROMPT) != kPower) {
1258  // Not pressed power - set VDR to be non-interactive and power down later:
1260  break;
1261  }
1262  // No activity or power button pressed twice - ask for confirmation:
1263  if (!ShutdownHandler.ConfirmShutdown(true)) {
1264  // Non-confirmed background activity - set VDR to be non-interactive and power down later:
1266  break;
1267  }
1268  // Ask the final question:
1269  if (!Interface->Confirm(tr("Press any key to cancel shutdown"), SHUTDOWNCANCELPROMPT, true))
1270  // If final question was canceled, continue to be active:
1271  break;
1272  // Ok, now call the shutdown script:
1274  // Set VDR to be non-interactive and power down again later:
1276  // Do not attempt to automatically shut down for a while:
1278  break;
1279  default: break;
1280  }
1281  Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time
1282  if (Interact) {
1283  LastInteract = Now;
1284  eOSState state = Interact->ProcessKey(key);
1285  if (state == osUnknown && Interact != cControl::Control()) {
1286  if (ISMODELESSKEY(key) && cControl::Control()) {
1287  state = cControl::Control()->ProcessKey(key);
1288  if (state == osEnd) {
1289  // let's not close a menu when replay ends:
1291  continue;
1292  }
1293  }
1294  else if (Now - cRemote::LastActivity() > MENUTIMEOUT)
1295  state = osEnd;
1296  }
1297  switch (state) {
1298  case osPause: DELETE_MENU;
1300  Skins.QueueMessage(mtError, tr("No free DVB device to record!"));
1301  break;
1302  case osRecord: DELETE_MENU;
1303  if (cRecordControls::Start())
1304  Skins.QueueMessage(mtInfo, tr("Recording started"));
1305  break;
1306  case osRecordings:
1307  DELETE_MENU;
1309  Menu = new cMenuMain(osRecordings, true);
1310  break;
1311  case osReplay: DELETE_MENU;
1314  break;
1315  case osStopReplay:
1316  DELETE_MENU;
1318  break;
1319  case osSwitchDvb:
1320  DELETE_MENU;
1322  Skins.QueueMessage(mtInfo, tr("Switching primary DVB..."));
1324  break;
1325  case osPlugin: DELETE_MENU;
1326  Menu = cMenuMain::PluginOsdObject();
1327  if (Menu)
1328  Menu->Show();
1329  break;
1330  case osBack:
1331  case osEnd: if (Interact == Menu)
1332  DELETE_MENU;
1333  else
1335  break;
1336  default: ;
1337  }
1338  }
1339  else {
1340  // Key functions in "normal" viewing mode:
1341  if (key != kNone && KeyMacros.Get(key)) {
1342  cRemote::PutMacro(key);
1343  key = kNone;
1344  }
1345  switch (int(key)) {
1346  // Toggle channels:
1347  case kChanPrev:
1348  case k0: {
1349  if (PreviousChannel[PreviousChannelIndex ^ 1] == LastChannel || LastChannel != PreviousChannel[0] && LastChannel != PreviousChannel[1])
1350  PreviousChannelIndex ^= 1;
1351  Channels.SwitchTo(PreviousChannel[PreviousChannelIndex ^= 1]);
1352  break;
1353  }
1354  // Direct Channel Select:
1355  case k1 ... k9:
1356  // Left/Right rotates through channel groups:
1357  case kLeft|k_Repeat:
1358  case kLeft:
1359  case kRight|k_Repeat:
1360  case kRight:
1361  // Previous/Next rotates through channel groups:
1362  case kPrev|k_Repeat:
1363  case kPrev:
1364  case kNext|k_Repeat:
1365  case kNext:
1366  // Up/Down Channel Select:
1367  case kUp|k_Repeat:
1368  case kUp:
1369  case kDown|k_Repeat:
1370  case kDown:
1371  Menu = new cDisplayChannel(NORMALKEY(key));
1372  break;
1373  // Viewing Control:
1374  case kOk: LastChannel = -1; break; // forces channel display
1375  // Instant resume of the last viewed recording:
1376  case kPlay:
1380  }
1381  else
1382  DirectMainFunction(osRecordings); // no last viewed recording, so enter the Recordings menu
1383  break;
1384  default: break;
1385  }
1386  }
1387  if (!Menu) {
1388  if (!InhibitEpgScan)
1389  EITScanner.Process();
1390  bool Error = false;
1391  if (RecordingsHandler.Finished(Error)) {
1392  if (Error)
1393  Skins.Message(mtError, tr("Editing process failed!"));
1394  else
1395  Skins.Message(mtInfo, tr("Editing process finished"));
1396  }
1397  }
1398 
1399  // SIGHUP shall cause a restart:
1400  if (LastSignal == SIGHUP) {
1401  if (ShutdownHandler.ConfirmRestart(true) && Interface->Confirm(tr("Press any key to cancel restart"), RESTARTCANCELPROMPT, true))
1402  EXIT(1);
1403  LastSignal = 0;
1404  }
1405 
1406  // Update the shutdown countdown:
1408  if (!ShutdownHandler.ConfirmShutdown(false))
1410  }
1411 
1412  // Keep the recordings handler alive:
1414 
1416  // Handle housekeeping tasks
1417 
1418  // Shutdown:
1419  // Check whether VDR will be ready for shutdown in SHUTDOWNWAIT seconds:
1420  time_t Soon = Now + SHUTDOWNWAIT;
1422  if (ShutdownHandler.ConfirmShutdown(false))
1423  // Time to shut down - start final countdown:
1424  ShutdownHandler.countdown.Start(tr("VDR will shut down in %s minutes"), SHUTDOWNWAIT); // the placeholder is really %s!
1425  // Dont try to shut down again for a while:
1427  }
1428  // Countdown run down to 0?
1429  if (ShutdownHandler.countdown.Done()) {
1430  // Timed out, now do a final check:
1432  ShutdownHandler.DoShutdown(false);
1433  // Do this again a bit later:
1435  }
1436 
1437  // Disk housekeeping:
1441  // Plugins housekeeping:
1442  PluginManager.Housekeeping();
1443  }
1444 
1446 
1447  // Main thread hooks of plugins:
1448  PluginManager.MainThreadHook();
1449  }
1450 
1452  esyslog("emergency exit requested - shutting down");
1453 
1454 Exit:
1455 
1456  // Reset all signal handlers to default before Interface gets deleted:
1457  signal(SIGHUP, SIG_DFL);
1458  signal(SIGINT, SIG_DFL);
1459  signal(SIGTERM, SIG_DFL);
1460  signal(SIGPIPE, SIG_DFL);
1461  signal(SIGALRM, SIG_DFL);
1462 
1463  PluginManager.StopPlugins();
1466  delete Menu;
1468  delete Interface;
1470  Remotes.Clear();
1471  Audios.Clear();
1472  Skins.Clear();
1473  SourceParams.Clear();
1474  if (ShutdownHandler.GetExitCode() != 2) {
1477  Setup.Save();
1478  }
1482  EpgHandlers.Clear();
1483  PluginManager.Shutdown(true);
1484  cSchedules::Cleanup(true);
1485  ReportEpgBugFixStats(true);
1486  if (WatchdogTimeout > 0)
1487  dsyslog("max. latency time %d seconds", MaxLatencyTime);
1488  if (LastSignal)
1489  isyslog("caught signal %d", LastSignal);
1491  esyslog("emergency exit!");
1492  isyslog("exiting, exit code %d", ShutdownHandler.GetExitCode());
1493  if (SysLogLevel > 0)
1494  closelog();
1495  if (HasStdin)
1496  tcsetattr(STDIN_FILENO, TCSANOW, &savedTm);
1497  return ShutdownHandler.GetExitCode();
1498 }
Definition: keys.h:29
cDiseqcs Diseqcs
Definition: diseqc.c:439
static void Watchdog(int signum)
Definition: vdr.c:168
void SetEvents(void)
Definition: timers.c:799
void ClearVanishedRecordings(void)
Definition: recording.c:233
bool Replaying(void) const
Returns true if we are currently replaying.
Definition: device.c:1279
int DeviceNumber(void) const
Returns the number of this device (0 ... numDevices - 1).
Definition: device.c:197
#define MENUTIMEOUT
Definition: vdr.c:84
int Modified(void)
Returns 0 if no channels have been modified, 1 if an automatic modification has been made...
Definition: channels.c:1022
bool DirectoryEncoding
Definition: recording.c:77
int Vpid(void) const
Definition: channels.h:154
int Number(void) const
Definition: channels.h:179
bool 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:1499
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:903
cString DeviceBondings
Definition: config.h:363
Definition: keys.h:37
cChannels Channels
Definition: channels.c:810
int CurrentChannel
Definition: config.h:352
static void SetThemesDirectory(const char *ThemesDirectory)
Definition: themes.c:295
static tChannelID FromString(const char *s)
Definition: channels.c:25
bool ToggleMute(void)
Turns the volume off or on and returns the new mute state.
Definition: device.c:953
void CheckManualStart(int ManualStart)
Check whether the next timer is in ManualStart time window.
Definition: shutdown.c:107
#define dsyslog(a...)
Definition: tools.h:36
cString AddDirectory(const char *DirName, const char *FileName)
Definition: tools.c:350
#define TIMERDEVICETIMEOUT
Definition: vdr.c:86
bool isnumber(const char *s)
Definition: tools.c:312
#define SHUTDOWNFORCEPROMPT
Definition: vdr.c:78
Definition: keys.h:34
time_t EndTime(void) const
Definition: epg.h:107
bool Confirm(const char *s, int Seconds=10, bool WaitForTimeout=false)
Definition: interface.c:67
bool IsUserInactive(time_t AtTime=0)
Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown).
Definition: shutdown.h:72
cEpgHandlers EpgHandlers
Definition: epg.c:1381
static bool Initialize(void)
Initializes the DVB devices.
Definition: dvbdevice.c:1251
Definition: keys.h:23
bool LoadPlugins(bool Log=false)
Definition: plugin.c:354
#define CHANNELSAVEDELTA
Definition: vdr.c:82
bool Load(const char *SkinName)
Definition: themes.c:239
Definition: keys.h:19
virtual cOsdObject * GetInfo(void)
Returns an OSD object that displays information about the currently played programme.
Definition: player.c:58
cEITScanner EITScanner
Definition: eitscan.c:90
const char * Name(void)
Definition: plugin.h:34
void Shutdown(bool Log=false)
Definition: plugin.c:512
#define DEFAULTVIDEODIR
#define ISMODELESSKEY(k)
Definition: keys.h:80
bool DirectoryOk(const char *DirName, bool LogErrors)
Definition: tools.c:427
#define VPSLOOKAHEADTIME
Definition: vdr.c:88
Definition: keys.h:43
static void Shutdown(void)
Definition: menu.c:5118
virtual const char * Version(void)=0
int Dpid(int i) const
Definition: channels.h:161
Definition: keys.h:39
static bool DropCaps(void)
Definition: vdr.c:125
Definition: keys.h:46
#define RESTARTCANCELPROMPT
Definition: vdr.c:80
cTimers Timers
Definition: timers.c:694
void DeleteExpired(void)
Definition: timers.c:817
int ZapTimeout
Definition: config.h:296
int DirectoryNameMax
Definition: recording.c:76
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:293
void ReportEpgBugFixStats(bool Force)
Definition: epg.c:585
virtual cOsdObject * MainMenuAction(void)
Definition: plugin.c:95
#define DEFAULTRESDIR
#define APIVERSION
Definition: config.h:30
static cDisplayVolume * Create(void)
Definition: menu.c:4549
void ProcessQueuedMessages(void)
Processes the first queued message, if any.
Definition: skins.c:349
Definition: plugin.h:20
Definition: keys.h:17
cTimer * GetMatch(time_t t)
Definition: timers.c:716
const cEvent * Event(void) const
Definition: timers.h:69
Definition: args.h:17
Definition: keys.h:61
#define MAXDEVICES
Definition: device.h:29
#define esyslog(a...)
Definition: tools.h:34
#define TIMERCHECKDELTA
Definition: vdr.c:85
static void ChannelDataModified(cChannel *Channel)
Definition: menu.c:5092
cNestedItemList Commands
Definition: config.c:275
bool Matches(time_t t=0, bool Directly=false, int Margin=0) const
Definition: timers.c:400
void SetUserInactive(void)
Set VDR manually into non-interactive mode from now on.
Definition: shutdown.h:86
static cDevice * GetDevice(int Index)
Gets the device with the given Index.
Definition: device.c:261
void SetInVpsMargin(bool InVpsMargin)
Definition: timers.c:600
static cControl * Control(bool Hidden=false)
Returns the current replay control (if any) in case it is currently visible.
Definition: player.c:73
static void Process(time_t t)
Definition: menu.c:5080
#define ISREALKEY(k)
Definition: keys.h:81
bool Save(void)
Definition: config.c:724
bool Load(const char *FileName=NULL, bool AllowComments=false, bool MustExist=false)
Definition: config.h:120
Definition: keys.h:49
static void Process(eKeys Key)
Definition: menu.c:4768
bool Update(void)
Update status display of the countdown.
Definition: shutdown.c:64
#define DEFAULTCACHEDIR
#define VDRVERSION
Definition: config.h:25
bool EmergencyExitRequested(void)
Returns true if an emergency exit was requested.
Definition: shutdown.h:61
static int NumDevices(void)
Returns the total number of devices.
Definition: device.h:118
void SetPending(bool Pending)
Definition: timers.c:595
bool DoShutdown(bool Force)
Call the shutdown script with data of the next pending timer.
Definition: shutdown.c:234
void Exit(int ExitCode)
Set VDR exit code and initiate end of VDR main loop.
Definition: shutdown.h:54
#define MINPRIORITY
Definition: config.h:44
bool InitializePlugins(void)
Definition: plugin.c:363
const char * Name(void)
Definition: skins.h:389
time_t StartTime(void) const
Definition: epg.h:106
int MenuKeyCloses
Definition: config.h:267
bool IsMenu(void) const
Definition: osdbase.h:81
cRemotes Remotes
Definition: remote.c:211
#define NORMALKEY(k)
Definition: keys.h:79
void MainThreadHook(void)
Definition: plugin.c:406
static bool SetKeepCaps(bool On)
Definition: vdr.c:142
#define DEFAULTSVDRPPORT
static void SetEpgDataFileName(const char *FileName)
Definition: epg.c:1206
bool PresentSeenWithin(int Seconds) const
Definition: epg.h:157
static void SetCommand(const char *Command)
Definition: recording.h:405
static const cSchedules * Schedules(cSchedulesLock &SchedulesLock)
Caller must provide a cSchedulesLock which has to survive the entire time the returned cSchedules is ...
Definition: epg.c:1201
#define MINCHANNELWAIT
Definition: vdr.c:74
int SysLogLevel
Definition: tools.c:31
cCountdown countdown
Definition: shutdown.h:51
Definition: keys.h:38
static bool IsOpen(void)
Definition: menu.h:168
cNestedItemList RecordingCommands
Definition: config.c:276
#define MAXVIDEOFILESIZEDEFAULT
Definition: recording.h:420
virtual void Clear(void)
Definition: tools.c:2087
const cChannel * Channel(void) const
Definition: timers.h:56
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition: channels.c:839
static cPositioner * GetPositioner(void)
Returns a previously created positioner.
Definition: positioner.c:133
static int CurrentVolume(void)
Definition: device.h:588
void Interrupt(void)
Definition: interface.h:27
Definition: keys.h:55
bool IsPrimaryDevice(void) const
Definition: device.h:830
Definition: keys.h:58
void Unlock(void)
Definition: thread.c:170
Definition: timers.h:27
#define TIMERLOOKAHEADTIME
Definition: vdr.c:87
virtual const char * Description(void)=0
#define SHUTDOWNWAIT
Definition: vdr.c:76
virtual const char * CommandLineHelp(void)
Definition: plugin.c:48
bool Transferring(void) const
Returns true if we are currently in Transfer Mode.
Definition: device.c:1284
eOSState
Definition: osdbase.h:18
static void Destroy(void)
Definition: videodir.c:43
void Start(const char *Message, int Seconds)
Start the 5 minute shutdown warning countdown.
Definition: shutdown.c:37
bool Active(void)
Definition: eitscan.h:33
bool Recording(void) const
Definition: timers.h:52
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
Definition: device.h:319
const char * Name(void) const
Definition: channels.c:122
cSVDRPhosts SVDRPhosts
Definition: config.c:280
static bool PutMacro(eKeys Key)
Definition: remote.c:110
T * Next(const T *object) const
Definition: tools.h:495
int InitialVolume
Definition: config.h:357
void Activity(void)
Definition: eitscan.c:118
Definition: keys.h:54
static bool BondDevices(const char *Bondings)
Bonds the devices as defined in the given Bondings string.
Definition: dvbdevice.c:1393
bool Modified(int &State)
Returns true if any of the timers have been modified, which is detected by State being different than...
Definition: timers.c:792
Definition: keys.h:40
Definition: osdbase.h:35
cAudios Audios
Definition: audio.c:27
cTheme * Theme(void)
Definition: skins.h:390
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:982
int GetExitCode(void)
Get the currently set exit code of VDR.
Definition: shutdown.h:59
bool Save(void)
Definition: config.h:167
Definition: keys.h:44
static char * OverrideCharacterTable
Definition: si.c:322
virtual void Clear(void)
Free up all registered skins.
Definition: skins.c:397
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
Definition: device.c:750
Definition: keys.h:48
static bool SetUser(const char *UserName, bool UserDump)
Definition: vdr.c:95
#define SHUTDOWNRETRY
Definition: vdr.c:77
char FontOsd[MAXFONTNAME]
Definition: config.h:323
#define DEFAULTPLUGINDIR
void RemoveDeletedRecordings(void)
Definition: recording.c:133
Definition: keys.h:54
bool HasFlags(uint Flags) const
Definition: timers.c:664
bool DoExit(void)
Check if an exit code was set, and VDR should exit.
Definition: shutdown.h:57
cSources Sources
Definition: sources.c:117
int main(int argc, char *argv[])
Definition: vdr.c:176
int GetArgc(void) const
Definition: args.h:30
static void SetName(const char *Name)
Definition: videodir.c:58
const cKeyMacro * Get(eKeys Key)
Definition: keys.c:269
Definition: keys.h:18
void Process(void)
Definition: eitscan.c:127
cKeys Keys
Definition: keys.c:156
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:273
Definition: keys.h:50
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:2026
char ** GetArgv(void) const
Definition: args.h:31
#define DEFAULTLOCDIR
cSourceParams SourceParams
Definition: sourceparams.c:34
#define ACTIVITYTIMEOUT
Definition: vdr.c:75
Definition: keys.h:52
bool Finished(bool &Error)
Returns true if all operations in the list have been finished.
Definition: recording.c:2002
Definition: keys.h:28
Definition: skins.h:24
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:923
bool GenerateIndex(const char *FileName, bool Update)
Generates the index of the existing recording with the given FileName.
Definition: recording.c:2778
static bool Active(void)
Definition: menu.c:5109
bool ConfirmShutdown(bool Ask)
Check for background activity that blocks shutdown.
Definition: shutdown.c:160
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition: diseqc.c:441
cSetup Setup
Definition: config.c:372
int PauseKeyHandling
Definition: config.h:302
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
Definition: remote.c:124
Definition: keys.h:20
bool ReadDirectory(const char *Directory)
Definition: args.c:39
static void Cleanup(bool Force=false)
Definition: epg.c:1219
cShutdownHandler ShutdownHandler
Definition: shutdown.c:27
bool Lock(bool Write, int TimeoutMs=0)
Definition: thread.c:155
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
Definition: osd.h:795
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
static void SetSystemCharacterTable(const char *CharacterTable)
Definition: tools.c:932
int SplitEditedFiles
Definition: config.h:333
static bool WaitForAllDevicesReady(int Timeout=0)
Waits until all devices have become ready, or the given Timeout (seconds) has expired.
Definition: device.c:163
static tThreadId ThreadId(void)
Definition: thread.c:341
int InstanceId
Definition: recording.c:78
static cDisplaySubtitleTracks * Create(void)
Definition: menu.c:4757
cRecordingsHandler RecordingsHandler
Definition: recording.c:1911
Definition: keys.h:45
#define MINVIDEOFILESIZE
Definition: recording.h:419
Definition: skins.h:370
#define DEVICEREADYTIMEOUT
Definition: vdr.c:83
bool IsOpen(void)
Returns true if there is currently a skin display object active.
Definition: skins.h:438
cChannel * GetByChannelID(tChannelID ChannelID, bool TryWithoutRid=false, bool TryWithoutPolarization=false)
Definition: channels.c:937
static void Launch(cControl *Control)
Definition: player.c:79
virtual bool ProvidesTransponder(const cChannel *Channel) const
Returns true if this device can provide the transponder of the given Channel (which implies that it c...
Definition: device.c:691
static const char * LastReplayed(void)
Definition: menu.c:5250
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
virtual void Show(void)
Definition: osdbase.c:70
bool SetSystemCharacterTable(const char *CharacterTable)
Definition: si.c:330
int MaxVideoFileSize
Definition: config.h:332
#define DEFAULTWATCHDOG
cNestedItemList Folders
Definition: config.c:274
cRecordings DeletedRecordings
int BeingEdited(void)
Definition: timers.h:121
static bool HasPlugins(void)
Definition: plugin.c:452
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:374
int PrimaryDVB
Definition: config.h:262
virtual eOSState ProcessKey(eKeys Key)
Definition: osdbase.h:83
Definition: skins.h:24
bool HasSVDRPConnection(void)
Definition: interface.h:26
int64_t StrToNum(const char *s)
Converts the given string to a number.
Definition: tools.c:323
const cSchedule * GetSchedule(tChannelID ChannelID) const
Definition: epg.c:1328
int DirectoryPathMax
Definition: recording.c:75
int VpsMargin
Definition: config.h:305
void Housekeeping(void)
Definition: plugin.c:390
#define MEGABYTE(n)
Definition: tools.h:44
static void SetMainThreadId(void)
Definition: thread.c:346
#define DEFAULTEPGDATAFILENAME
bool WaitForAllCamSlotsReady(int Timeout=0)
Waits until all CAM slots have become ready, or the given Timeout (seconds) has expired.
Definition: ci.c:2237
#define CHANNELMOD_RETUNE
Definition: channels.h:29
T * First(void) const
Definition: tools.h:492
static time_t LastActivity(void)
Absolute time when last key was delivered by Get().
Definition: remote.h:68
static void Attach(void)
Definition: player.c:87
static void Process(eKeys Key)
Definition: menu.c:4556
#define MANUALSTART
Definition: vdr.c:81
void DelAll(void)
Deletes/terminates all operations.
Definition: recording.c:1975
static void SetCacheDirectory(const char *Dir)
Definition: plugin.c:149
static void Process(eKeys Key)
Definition: menu.c:4650
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
Definition: font.c:474
cChannel * GetByNumber(int Number, int SkipGap=0)
Definition: channels.c:909
bool CutRecording(const char *FileName)
Definition: cutter.c:729
eKeys GetKey(bool Wait=true)
Definition: interface.c:35
static cDevice * PrimaryDevice(void)
Returns the primary device.
Definition: device.h:137
static bool IsOpen(void)
Definition: menu.h:186
bool Load(const char *FileName)
Definition: config.c:537
static int LastSignal
Definition: vdr.c:93
Definition: epg.h:143
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:144
cKeyMacros KeyMacros
Definition: keys.c:267
Definition: timers.h:21
void AddPlugin(const char *Args)
Definition: plugin.c:318
bool NeedsUpdate(void)
Definition: recording.c:1491
#define DELETE_MENU
static bool SetPrimaryDevice(int n)
Sets the primary device to 'n'.
Definition: device.c:226
static cDisplayTracks * Create(void)
Definition: menu.c:4639
void StopReplay(void)
Stops the current replay session (if any).
Definition: device.c:1332
int Apid(int i) const
Definition: channels.h:160
#define tr(s)
Definition: i18n.h:85
cScrs Scrs
Definition: diseqc.c:182
virtual bool NeedsFastResponse(void)
Definition: osdbase.h:80
bool Retry(time_t AtTime=0)
Check whether its time to re-try the shutdown.
Definition: shutdown.h:88
cRecordings Recordings
Any access to Recordings that loops through the list of recordings needs to hold a thread lock on thi...
Definition: recording.c:1366
bool ConfirmRestart(bool Ask)
Check for background activity that blocks restart.
Definition: shutdown.c:211
#define CHANNELSMOD_USER
Definition: channels.h:33
static void SetGrabImageDir(const char *GrabImageDir)
Definition: svdrp.c:1808
void SetDirectory(const char *Directory)
Definition: plugin.c:312
#define isyslog(a...)
Definition: tools.h:35
virtual bool IsTunedToTransponder(const cChannel *Channel) const
Returns true if this device is currently tuned to the given Channel's transponder.
Definition: device.c:740
Definition: keys.h:42
static void SignalHandler(int signum)
Definition: vdr.c:152
static cPlugin * GetPlugin(int Index)
Definition: plugin.c:457
int CurrentVolume
Definition: config.h:353
static void Shutdown(void)
Closes down all devices.
Definition: device.c:407
Definition: keys.h:32
static cDevice * ActualDevice(void)
Returns the actual receiving device in case of Transfer Mode, or the primary device otherwise...
Definition: device.c:253
Definition: keys.h:31
#define DEFAULTCONFDIR
bool SwitchTo(int Number)
Definition: channels.c:988
Definition: keys.h:28
#define VPSUPTODATETIME
Definition: vdr.c:89
static cOsdObject * PluginOsdObject(void)
Definition: menu.c:3992
#define SHUTDOWNCANCELPROMPT
Definition: vdr.c:79
virtual bool HasDecoder(void) const
Tells whether this device has an MPEG decoder.
Definition: device.c:243
bool Load(const char *FileName)
Definition: config.c:234
bool Active(void)
Checks whether there is currently any operation running and starts the next one form the list if the ...
Definition: recording.c:1990
bool StartPlugins(void)
Definition: plugin.c:376
bool SeenWithin(int Seconds) const
Definition: epg.h:111
static void MsgChannelChange(const cChannel *Channel)
Definition: status.c:26
Definition: osdbase.h:34
#define EXIT(v)
Definition: vdr.c:91
cInterface * Interface
Definition: interface.c:20
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
Definition: diseqc.c:184
void SetRetry(int Seconds)
Set shutdown retry so that VDR will not try to automatically shut down within Seconds.
Definition: shutdown.h:93
char OSDTheme[MaxThemeName]
Definition: config.h:260
void SetShutdownCommand(const char *ShutdownCommand)
Set the command string for shutdown command.
Definition: shutdown.c:124
cString InitialChannel
Definition: config.h:362
#define MAXVIDEOFILESIZETS
Definition: recording.h:417
char OSDSkin[MaxSkinName]
Definition: config.h:259
#define LIVEPRIORITY
Definition: config.h:45
void StopPlugins(void)
Definition: plugin.c:500
static bool PauseLiveVideo(void)
Definition: menu.c:5032
cSkin * Current(void)
Returns a pointer to the current skin.
Definition: skins.h:436
Definition: keys.h:28
static void SetResourceDirectory(const char *Dir)
Definition: plugin.c:163
Definition: keys.h:53
static bool IsOpen(void)
Definition: menu.h:139
bool SetCurrent(const char *Name=NULL)
Sets the current skin to the one indicated by name.
Definition: skins.c:231
static void Shutdown(void)
Definition: player.c:100
#define VOLUMEDELTA
Definition: device.h:33
int BeingEdited(void)
Definition: channels.h:232
#define DirectMainFunction(function)
eKeys
Definition: keys.h:16
void SetOverrideCharacterTable(const char *CharacterTable)
Definition: si.c:324
static void SetUseDevice(int n)
Sets the 'useDevice' flag of the given device.
Definition: device.c:179
cCamSlots CamSlots
Definition: ci.c:2235
void I18nInitialize(const char *LocaleDir)
Detects all available locales and loads the language names and codes.
Definition: i18n.c:103
The cDevice class is the base from which actual devices can be derived.
Definition: device.h:109
static void Shutdown(void)
Shuts down the OSD provider facility by deleting the current OSD provider.
Definition: osd.c:2113
Definition: keys.h:41
static void DestroyPositioner(void)
Destroys a previously created positioner.
Definition: positioner.c:138
void Cancel(void)
Cancel the 5 minute shutdown warning countdown.
Definition: shutdown.c:46
static void SetConfigDirectory(const char *Dir)
Definition: plugin.c:135
virtual void Hide(void)=0
bool Done(void)
Check if countdown timer has run out without canceling.
Definition: shutdown.c:55
#define DEFAULTARGSDIR
void LearnKeys(void)
Definition: interface.c:155
Definition: keys.h:22
cSkins Skins
Definition: skins.c:219
static bool Start(cTimer *Timer=NULL, bool Pause=false)
Definition: menu.c:4961
int DiSEqC
Definition: config.h:274