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

New command line option '-r'

This commit is contained in:
Klaus Schmidinger 2001-09-22 14:23:55 +02:00
parent 8223bd1f18
commit 9f1046221d
5 changed files with 43 additions and 4 deletions

View File

@ -778,3 +778,5 @@ Video Disk Recorder Revision History
word and the options. word and the options.
- The current volume setting is now saved to setup.conf and restored at the - The current volume setting is now saved to setup.conf and restored at the
next program start. next program start.
- New command line option '-r' to define a command that gets called before and
after each recording (see INSTALL for details).

15
INSTALL
View File

@ -158,6 +158,21 @@ particular hard- and software environment.
If the '-s' option is present, the VDR machine can be turned off by pressing If the '-s' option is present, the VDR machine can be turned off by pressing
the "Power" key on the remote control. 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: Command line options:
--------------------- ---------------------

17
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "menu.h"
@ -2104,6 +2104,8 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
// --- cRecordControl -------------------------------------------------------- // --- cRecordControl --------------------------------------------------------
const char *cRecordControl::userCommand = NULL;
cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
{ {
eventInfo = NULL; eventInfo = NULL;
@ -2128,6 +2130,7 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
Summary = eventInfo->GetExtendedDescription(); Summary = eventInfo->GetExtendedDescription();
} }
cRecording Recording(timer, Subtitle, Summary); cRecording Recording(timer, Subtitle, Summary);
InvokeUserCommand(true);
if (dvbApi->StartRecord(Recording.FileName(), Channels.GetByNumber(timer->channel)->ca, timer->priority)) if (dvbApi->StartRecord(Recording.FileName(), Channels.GetByNumber(timer->channel)->ca, timer->priority))
Recording.WriteSummary(); Recording.WriteSummary();
Interface->DisplayRecording(dvbApi->CardIndex(), true); Interface->DisplayRecording(dvbApi->CardIndex(), true);
@ -2170,6 +2173,17 @@ bool cRecordControl::GetEventInfo(void)
return false; 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) void cRecordControl::Stop(bool KeepInstant)
{ {
if (timer) { if (timer) {
@ -2184,6 +2198,7 @@ void cRecordControl::Stop(bool KeepInstant)
} }
timer = NULL; timer = NULL;
Interface->DisplayRecording(dvbApi->CardIndex(), false); Interface->DisplayRecording(dvbApi->CardIndex(), false);
InvokeUserCommand(false);
} }
} }

5
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef _MENU_H
@ -71,14 +71,17 @@ public:
class cRecordControl { class cRecordControl {
private: private:
static const char *userCommand;
cDvbApi *dvbApi; cDvbApi *dvbApi;
cTimer *timer; cTimer *timer;
const cEventInfo *eventInfo; const cEventInfo *eventInfo;
char *instantId; char *instantId;
bool GetEventInfo(void); bool GetEventInfo(void);
void InvokeUserCommand(bool Before);
public: public:
cRecordControl(cDvbApi *DvbApi, cTimer *Timer = NULL); cRecordControl(cDvbApi *DvbApi, cTimer *Timer = NULL);
virtual ~cRecordControl(); virtual ~cRecordControl();
static void SetUserCommand(const char *UserCommand) { userCommand = UserCommand; }
bool Process(time_t t); bool Process(time_t t);
bool Uses(cDvbApi *DvbApi) { return DvbApi == dvbApi; } bool Uses(cDvbApi *DvbApi) { return DvbApi == dvbApi; }
void Stop(bool KeepInstant = false); void Stop(bool KeepInstant = false);

8
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * 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 #define _GNU_SOURCE
@ -96,6 +96,7 @@ int main(int argc, char *argv[])
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "log", required_argument, NULL, 'l' }, { "log", required_argument, NULL, 'l' },
{ "port", required_argument, NULL, 'p' }, { "port", required_argument, NULL, 'p' },
{ "record", required_argument, NULL, 'r' },
{ "shutdown", required_argument, NULL, 's' }, { "shutdown", required_argument, NULL, 's' },
{ "terminal", required_argument, NULL, 't' }, { "terminal", required_argument, NULL, 't' },
{ "video", required_argument, NULL, 'v' }, { "video", required_argument, NULL, 'v' },
@ -106,7 +107,7 @@ int main(int argc, char *argv[])
int c; int c;
int option_index = 0; 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) { switch (c) {
case 'a': cDvbApi::SetAudioCommand(optarg); case 'a': cDvbApi::SetAudioCommand(optarg);
break; break;
@ -143,6 +144,7 @@ int main(int argc, char *argv[])
" 2 = errors and info, 3 = errors, info and debug\n" " 2 = errors and info, 3 = errors, info and debug\n"
" -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n" " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n"
" 0 turns off SVDRP\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" " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
" -t TTY, --terminal=TTY controlling tty\n" " -t TTY, --terminal=TTY controlling tty\n"
" -v DIR, --video=DIR use DIR as video directory (default: %s)\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; return 2;
} }
break; break;
case 'r': cRecordControl::SetUserCommand(optarg);
break;
case 's': Shutdown = optarg; case 's': Shutdown = optarg;
break; break;
case 't': Terminal = optarg; case 't': Terminal = optarg;