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

Calling the '-r' program after editing, too

This commit is contained in:
Klaus Schmidinger 2001-09-23 14:02:11 +02:00
parent e1f7348922
commit f412897373
8 changed files with 85 additions and 37 deletions

42
INSTALL
View File

@ -162,16 +162,44 @@ Executing commands before and after a recording:
------------------------------------------------ ------------------------------------------------
You can use the '-r' option to define a program or script that gets called You can use the '-r' option to define a program or script that gets called
before and after a recording is performed. before and after a recording is performed, and after an editing process
has finished.
The program will be called with one integer parameter that is "1" if this The program will be called with two string parameters. The first parameter
is *before* the recording, and "0" if this is *after* the recording. is one of
before if this is *before* a recording starts
after if this is *after* a recording has finished
edited if this is after a recording has been *edited*
and the second parameter contains the full name of the recording's
directory (which may not yet exists at that moment in the "before" case).
In the "edited" case it will be the name of the edited version.
Within this program you can do anything you would like to do before and/or 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, after a recording or after an editing process. However, the program must return
because otherwise it will block further execution of VDR. Be expecially careful as soon as possible, because otherwise it will block further execution of VDR.
to make sure the program returns before the watchdog timeout you may have set Be especially careful to make sure the program returns before the watchdog
up with the '-w' option! timeout you may have set up with the '-w' option! If the operation you want to
perform will take longer, you will have to run it as a background job.
An example script for use with the '-r' option could look like this:
#!/bin/sh
case "$1" in
before)
echo "Before recording $2"
;;
after)
echo "After recording $2"
;;
edited)
echo "Edited recording $2"
;;
*)
echo "ERROR: unknown state: $1"
;;
esac
Command line options: Command line options:
--------------------- ---------------------

View File

@ -7,7 +7,7 @@
* DVD support initially written by Andreas Schultz <aschultz@warp10.net> * DVD support initially written by Andreas Schultz <aschultz@warp10.net>
* based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si> * based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si>
* *
* $Id: dvbapi.c 1.128 2001/09/22 13:39:56 kls Exp $ * $Id: dvbapi.c 1.129 2001/09/23 13:44:27 kls Exp $
*/ */
//#define DVDDEBUG 1 //#define DVDDEBUG 1
@ -2406,16 +2406,18 @@ void cCuttingBuffer::Action(void)
// --- cVideoCutter ---------------------------------------------------------- // --- cVideoCutter ----------------------------------------------------------
char *cVideoCutter::editedVersionName = NULL;
cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL; cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL;
bool cVideoCutter::Start(const char *FileName) bool cVideoCutter::Start(const char *FileName)
{ {
if (!cuttingBuffer) { if (!cuttingBuffer) {
cRecording Recording(FileName); cRecording Recording(FileName);
const char *EditedVersionName = Recording.PrefixFileName('%'); const char *evn = Recording.PrefixFileName('%');
if (EditedVersionName && RemoveVideoFile(EditedVersionName) && MakeDirs(EditedVersionName, true)) { if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) {
editedVersionName = strdup(evn);
Recording.WriteSummary(); Recording.WriteSummary();
cuttingBuffer = new cCuttingBuffer(FileName, EditedVersionName); cuttingBuffer = new cCuttingBuffer(FileName, editedVersionName);
return true; return true;
} }
} }
@ -2434,6 +2436,9 @@ bool cVideoCutter::Active(void)
if (cuttingBuffer->Active()) if (cuttingBuffer->Active())
return true; return true;
Stop(); Stop();
cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
delete editedVersionName;
editedVersionName = NULL;
} }
return false; return false;
} }

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: dvbapi.h 1.52 2001/09/22 13:40:30 kls Exp $ * $Id: dvbapi.h 1.53 2001/09/23 11:01:46 kls Exp $
*/ */
#ifndef __DVBAPI_H #ifndef __DVBAPI_H
@ -73,6 +73,7 @@ class cCuttingBuffer;
class cVideoCutter { class cVideoCutter {
private: private:
static char *editedVersionName;
static cCuttingBuffer *cuttingBuffer; static cCuttingBuffer *cuttingBuffer;
public: public:
static bool Start(const char *FileName); static bool Start(const char *FileName);

24
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.126 2001/09/22 14:17:27 kls Exp $ * $Id: menu.c 1.127 2001/09/23 10:58:48 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -2104,12 +2104,11 @@ 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;
instantId = NULL; instantId = NULL;
fileName = NULL;
dvbApi = DvbApi; dvbApi = DvbApi;
if (!dvbApi) dvbApi = cDvbApi::PrimaryDvbApi;//XXX if (!dvbApi) dvbApi = cDvbApi::PrimaryDvbApi;//XXX
timer = Timer; timer = Timer;
@ -2130,8 +2129,9 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
Summary = eventInfo->GetExtendedDescription(); Summary = eventInfo->GetExtendedDescription();
} }
cRecording Recording(timer, Subtitle, Summary); cRecording Recording(timer, Subtitle, Summary);
InvokeUserCommand(true); fileName = strdup(Recording.FileName());
if (dvbApi->StartRecord(Recording.FileName(), Channels.GetByNumber(timer->channel)->ca, timer->priority)) cRecordingUserCommand::InvokeCommand(RUC_BEFORERECORDING, fileName);
if (dvbApi->StartRecord(fileName, Channels.GetByNumber(timer->channel)->ca, timer->priority))
Recording.WriteSummary(); Recording.WriteSummary();
Interface->DisplayRecording(dvbApi->CardIndex(), true); Interface->DisplayRecording(dvbApi->CardIndex(), true);
} }
@ -2143,6 +2143,7 @@ cRecordControl::~cRecordControl()
{ {
Stop(true); Stop(true);
delete instantId; delete instantId;
delete fileName;
} }
bool cRecordControl::GetEventInfo(void) bool cRecordControl::GetEventInfo(void)
@ -2173,17 +2174,6 @@ 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) {
@ -2198,7 +2188,7 @@ void cRecordControl::Stop(bool KeepInstant)
} }
timer = NULL; timer = NULL;
Interface->DisplayRecording(dvbApi->CardIndex(), false); Interface->DisplayRecording(dvbApi->CardIndex(), false);
InvokeUserCommand(false); cRecordingUserCommand::InvokeCommand(RUC_AFTERRECORDING, fileName);
} }
} }

6
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.29 2001/09/22 14:02:37 kls Exp $ * $Id: menu.h 1.30 2001/09/23 10:57:33 kls Exp $
*/ */
#ifndef _MENU_H #ifndef _MENU_H
@ -71,17 +71,15 @@ 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;
char *fileName;
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);

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: recording.c 1.36 2001/09/02 15:09:28 kls Exp $ * $Id: recording.c 1.37 2001/09/23 13:43:29 kls Exp $
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
@ -513,3 +513,17 @@ cMark *cMarks::GetNext(int Position)
return NULL; return NULL;
} }
// --- cRecordingUserCommand -------------------------------------------------
const char *cRecordingUserCommand::command = NULL;
void cRecordingUserCommand::InvokeCommand(const char *State, const char *RecordingFileName)
{
if (command) {
char *cmd;
asprintf(&cmd, "%s %s '%s'", command, State, RecordingFileName);
isyslog(LOG_INFO, "executing '%s'", cmd);
system(cmd);
delete cmd;
}
}

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: recording.h 1.16 2001/09/02 11:35:56 kls Exp $ * $Id: recording.h 1.17 2001/09/23 13:43:58 kls Exp $
*/ */
#ifndef __RECORDING_H #ifndef __RECORDING_H
@ -83,4 +83,16 @@ public:
cMark *GetNext(int Position); cMark *GetNext(int Position);
}; };
#define RUC_BEFORERECORDING "before"
#define RUC_AFTERRECORDING "after"
#define RUC_EDITEDRECORDING "edited"
class cRecordingUserCommand {
private:
static const char *command;
public:
static void SetCommand(const char *Command) { command = Command; }
static void InvokeCommand(const char *State, const char *RecordingFileName);
};
#endif //__RECORDING_H #endif //__RECORDING_H

4
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.77 2001/09/23 10:11:07 kls Exp $ * $Id: vdr.c 1.78 2001/09/23 10:59:29 kls Exp $
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
@ -182,7 +182,7 @@ int main(int argc, char *argv[])
return 2; return 2;
} }
break; break;
case 'r': cRecordControl::SetUserCommand(optarg); case 'r': cRecordingUserCommand::SetCommand(optarg);
break; break;
case 's': Shutdown = optarg; case 's': Shutdown = optarg;
break; break;