diff options
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | INSTALL | 15 | ||||
-rw-r--r-- | menu.c | 17 | ||||
-rw-r--r-- | menu.h | 5 | ||||
-rw-r--r-- | vdr.c | 8 |
5 files changed, 43 insertions, 4 deletions
@@ -778,3 +778,5 @@ Video Disk Recorder Revision History word and the options. - The current volume setting is now saved to setup.conf and restored at the next program start. +- New command line option '-r' to define a command that gets called before and + after each recording (see INSTALL for details). @@ -158,6 +158,21 @@ particular hard- and software environment. If the '-s' option is present, the VDR machine can be turned off by pressing the "Power" key on the remote control. +Executing commands before and after a recording: +------------------------------------------------ + +You can use the '-r' option to define a program or script that gets called +before and after a recording is performed. + +The program will be called with one integer parameter that is "1" if this +is *before* the recording, and "0" if this is *after* the recording. + +Within this program you can do anything you would like to do before and/or +after a recording. However, the program must return as soon as possible, +because otherwise it will block further execution of VDR. Be expecially careful +to make sure the program returns before the watchdog timeout you may have set +up with the '-w' option! + Command line options: --------------------- @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.125 2001/09/21 16:22:15 kls Exp $ + * $Id: menu.c 1.126 2001/09/22 14:17:27 kls Exp $ */ #include "menu.h" @@ -2104,6 +2104,8 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key) // --- cRecordControl -------------------------------------------------------- +const char *cRecordControl::userCommand = NULL; + cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) { eventInfo = NULL; @@ -2128,6 +2130,7 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) Summary = eventInfo->GetExtendedDescription(); } cRecording Recording(timer, Subtitle, Summary); + InvokeUserCommand(true); if (dvbApi->StartRecord(Recording.FileName(), Channels.GetByNumber(timer->channel)->ca, timer->priority)) Recording.WriteSummary(); Interface->DisplayRecording(dvbApi->CardIndex(), true); @@ -2170,6 +2173,17 @@ bool cRecordControl::GetEventInfo(void) return false; } +void cRecordControl::InvokeUserCommand(bool Before) +{ + if (userCommand) { + char *cmd; + asprintf(&cmd, "%s %d", userCommand, Before); + isyslog(LOG_INFO, "executing '%s'", cmd); + system(cmd); + delete cmd; + } +} + void cRecordControl::Stop(bool KeepInstant) { if (timer) { @@ -2184,6 +2198,7 @@ void cRecordControl::Stop(bool KeepInstant) } timer = NULL; Interface->DisplayRecording(dvbApi->CardIndex(), false); + InvokeUserCommand(false); } } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.h 1.28 2001/09/14 15:09:49 kls Exp $ + * $Id: menu.h 1.29 2001/09/22 14:02:37 kls Exp $ */ #ifndef _MENU_H @@ -71,14 +71,17 @@ public: class cRecordControl { private: + static const char *userCommand; cDvbApi *dvbApi; cTimer *timer; const cEventInfo *eventInfo; char *instantId; bool GetEventInfo(void); + void InvokeUserCommand(bool Before); public: cRecordControl(cDvbApi *DvbApi, cTimer *Timer = NULL); virtual ~cRecordControl(); + static void SetUserCommand(const char *UserCommand) { userCommand = UserCommand; } bool Process(time_t t); bool Uses(cDvbApi *DvbApi) { return DvbApi == dvbApi; } void Stop(bool KeepInstant = false); @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.74 2001/09/22 13:38:28 kls Exp $ + * $Id: vdr.c 1.75 2001/09/22 14:05:40 kls Exp $ */ #define _GNU_SOURCE @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "log", required_argument, NULL, 'l' }, { "port", required_argument, NULL, 'p' }, + { "record", required_argument, NULL, 'r' }, { "shutdown", required_argument, NULL, 's' }, { "terminal", required_argument, NULL, 't' }, { "video", required_argument, NULL, 'v' }, @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) int c; int option_index = 0; - while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:p:s:t:v:V:w:", long_options, &option_index)) != -1) { + while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:p:r:s:t:v:V:w:", long_options, &option_index)) != -1) { switch (c) { case 'a': cDvbApi::SetAudioCommand(optarg); break; @@ -143,6 +144,7 @@ int main(int argc, char *argv[]) " 2 = errors and info, 3 = errors, info and debug\n" " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n" " 0 turns off SVDRP\n" + " -r CMD, --record=CMD call CMD before and after a recording\n" " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n" " -t TTY, --terminal=TTY controlling tty\n" " -v DIR, --video=DIR use DIR as video directory (default: %s)\n" @@ -180,6 +182,8 @@ int main(int argc, char *argv[]) return 2; } break; + case 'r': cRecordControl::SetUserCommand(optarg); + break; case 's': Shutdown = optarg; break; case 't': Terminal = optarg; |