summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-09-23 14:02:11 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-09-23 14:02:11 +0200
commitf412897373b05ea78df93b56ab9d97c4bb522801 (patch)
treea18122202f89ca354808630a8baca079b4fbad9e
parente1f7348922bbca20c29923035cf298bf7f49a392 (diff)
downloadvdr-f412897373b05ea78df93b56ab9d97c4bb522801.tar.gz
vdr-f412897373b05ea78df93b56ab9d97c4bb522801.tar.bz2
Calling the '-r' program after editing, too
-rw-r--r--INSTALL42
-rw-r--r--dvbapi.c13
-rw-r--r--dvbapi.h3
-rw-r--r--menu.c24
-rw-r--r--menu.h6
-rw-r--r--recording.c16
-rw-r--r--recording.h14
-rw-r--r--vdr.c4
8 files changed, 85 insertions, 37 deletions
diff --git a/INSTALL b/INSTALL
index 4691c9a8..b942603e 100644
--- a/INSTALL
+++ b/INSTALL
@@ -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
-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
-is *before* the recording, and "0" if this is *after* the recording.
+The program will be called with two string parameters. The first parameter
+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
-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!
+after a recording or after an editing process. However, the program must return
+as soon as possible, because otherwise it will block further execution of VDR.
+Be especially careful to make sure the program returns before the watchdog
+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:
---------------------
diff --git a/dvbapi.c b/dvbapi.c
index 064bb49c..8a6e6915 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -7,7 +7,7 @@
* DVD support initially written by Andreas Schultz <aschultz@warp10.net>
* 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
@@ -2406,16 +2406,18 @@ void cCuttingBuffer::Action(void)
// --- cVideoCutter ----------------------------------------------------------
+char *cVideoCutter::editedVersionName = NULL;
cCuttingBuffer *cVideoCutter::cuttingBuffer = NULL;
bool cVideoCutter::Start(const char *FileName)
{
if (!cuttingBuffer) {
cRecording Recording(FileName);
- const char *EditedVersionName = Recording.PrefixFileName('%');
- if (EditedVersionName && RemoveVideoFile(EditedVersionName) && MakeDirs(EditedVersionName, true)) {
+ const char *evn = Recording.PrefixFileName('%');
+ if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) {
+ editedVersionName = strdup(evn);
Recording.WriteSummary();
- cuttingBuffer = new cCuttingBuffer(FileName, EditedVersionName);
+ cuttingBuffer = new cCuttingBuffer(FileName, editedVersionName);
return true;
}
}
@@ -2434,6 +2436,9 @@ bool cVideoCutter::Active(void)
if (cuttingBuffer->Active())
return true;
Stop();
+ cRecordingUserCommand::InvokeCommand(RUC_EDITEDRECORDING, editedVersionName);
+ delete editedVersionName;
+ editedVersionName = NULL;
}
return false;
}
diff --git a/dvbapi.h b/dvbapi.h
index 13365e47..8e67f9b4 100644
--- a/dvbapi.h
+++ b/dvbapi.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -73,6 +73,7 @@ class cCuttingBuffer;
class cVideoCutter {
private:
+ static char *editedVersionName;
static cCuttingBuffer *cuttingBuffer;
public:
static bool Start(const char *FileName);
diff --git a/menu.c b/menu.c
index 54edc7ba..23b16e29 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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"
@@ -2104,12 +2104,11 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
// --- cRecordControl --------------------------------------------------------
-const char *cRecordControl::userCommand = NULL;
-
cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
{
eventInfo = NULL;
instantId = NULL;
+ fileName = NULL;
dvbApi = DvbApi;
if (!dvbApi) dvbApi = cDvbApi::PrimaryDvbApi;//XXX
timer = Timer;
@@ -2130,8 +2129,9 @@ 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))
+ fileName = strdup(Recording.FileName());
+ cRecordingUserCommand::InvokeCommand(RUC_BEFORERECORDING, fileName);
+ if (dvbApi->StartRecord(fileName, Channels.GetByNumber(timer->channel)->ca, timer->priority))
Recording.WriteSummary();
Interface->DisplayRecording(dvbApi->CardIndex(), true);
}
@@ -2143,6 +2143,7 @@ cRecordControl::~cRecordControl()
{
Stop(true);
delete instantId;
+ delete fileName;
}
bool cRecordControl::GetEventInfo(void)
@@ -2173,17 +2174,6 @@ 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) {
@@ -2198,7 +2188,7 @@ void cRecordControl::Stop(bool KeepInstant)
}
timer = NULL;
Interface->DisplayRecording(dvbApi->CardIndex(), false);
- InvokeUserCommand(false);
+ cRecordingUserCommand::InvokeCommand(RUC_AFTERRECORDING, fileName);
}
}
diff --git a/menu.h b/menu.h
index 53924c9c..f7411c61 100644
--- a/menu.h
+++ b/menu.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -71,17 +71,15 @@ public:
class cRecordControl {
private:
- static const char *userCommand;
cDvbApi *dvbApi;
cTimer *timer;
const cEventInfo *eventInfo;
char *instantId;
+ char *fileName;
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);
diff --git a/recording.c b/recording.c
index f6573781..df504074 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -513,3 +513,17 @@ cMark *cMarks::GetNext(int Position)
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;
+ }
+}
diff --git a/recording.h b/recording.h
index e1af3db3..d2391a90 100644
--- a/recording.h
+++ b/recording.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -83,4 +83,16 @@ public:
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
diff --git a/vdr.c b/vdr.c
index e08c590a..a095dc9d 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* 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
@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
return 2;
}
break;
- case 'r': cRecordControl::SetUserCommand(optarg);
+ case 'r': cRecordingUserCommand::SetCommand(optarg);
break;
case 's': Shutdown = optarg;
break;