struct tm tm;
const char *filename;
char *str1, *str2;
- char tbuf[64], ubuf[UUID_HEX_SIZE], *rdir, *postcmd;
+ char tbuf[64], ubuf[UUID_HEX_SIZE], *rdir, *cmd;
int r, ret = 0;
t = dvr_entry_get_start_time(de, 1);
tvhlog(LOG_WARNING, "dvr", "Unable to remove file '%s' from disk -- %s",
filename, strerror(-errno));
- postcmd = de->de_config->dvr_postremove;
- if (postcmd && postcmd[0])
- dvr_spawn_postcmd(de, postcmd, filename);
+ cmd = de->de_config->dvr_postremove;
+ if (cmd && cmd[0])
+ dvr_spawn_cmd(de, cmd, filename, 0);
htsmsg_delete_field(m, "filename");
ret = 1;
}
atomic_set(&de->de_thread_shutdown, 0);
tvhthread_create(&de->de_thread, NULL, dvr_thread, de, "dvr");
+
+ if (de->de_config->dvr_preproc)
+ dvr_spawn_cmd(de, de->de_config->dvr_preproc, NULL, 1);
return 0;
}
*
*/
void
-dvr_spawn_postcmd(dvr_entry_t *de, const char *postcmd, const char *filename)
+dvr_spawn_cmd(dvr_entry_t *de, const char *cmd, const char *filename, int pre)
{
char buf1[MAX(PATH_MAX, 2048)], *buf2;
char tmp[MAX(PATH_MAX, 512)];
- htsmsg_t *info, *e;
+ htsmsg_t *info = NULL, *e;
htsmsg_field_t *f;
char **args;
- if ((f = htsmsg_field_last(de->de_files)) != NULL &&
- (e = htsmsg_field_get_map(f)) != NULL) {
- if (filename == NULL) {
- filename = htsmsg_get_str(e, "filename");
- if (filename == NULL)
- return;
+ if (!pre) {
+ if ((f = htsmsg_field_last(de->de_files)) != NULL &&
+ (e = htsmsg_field_get_map(f)) != NULL) {
+ if (filename == NULL) {
+ filename = htsmsg_get_str(e, "filename");
+ if (filename == NULL)
+ return;
+ }
+ info = htsmsg_get_list(e, "info");
+ } else {
+ return;
}
- info = htsmsg_get_list(e, "info");
- } else {
- return;
}
/* Substitute DVR entry formatters */
- htsstr_substitute(postcmd, buf1, sizeof(buf1), '%', dvr_subs_postproc_entry, de, tmp, sizeof(tmp));
+ htsstr_substitute(cmd, buf1, sizeof(buf1), '%', dvr_subs_postproc_entry, de, tmp, sizeof(tmp));
buf2 = tvh_strdupa(buf1);
/* Substitute filename formatters */
- htsstr_substitute(buf2, buf1, sizeof(buf1), '%', dvr_subs_postproc_filename, filename, tmp, sizeof(tmp));
- buf2 = tvh_strdupa(buf1);
+ if (!pre) {
+ htsstr_substitute(buf2, buf1, sizeof(buf1), '%', dvr_subs_postproc_filename, filename, tmp, sizeof(tmp));
+ buf2 = tvh_strdupa(buf1);
+ }
/* Substitute info formatters */
- htsstr_substitute(buf2, buf1, sizeof(buf1), '%', dvr_subs_postproc_info, info, tmp, sizeof(tmp));
+ if (info)
+ htsstr_substitute(buf2, buf1, sizeof(buf1), '%', dvr_subs_postproc_info, info, tmp, sizeof(tmp));
args = htsstr_argsplit(buf1);
if(args[0])
prch->prch_muxer = NULL;
if(dvr_postproc && dvr_postproc[0])
- dvr_spawn_postcmd(de, dvr_postproc, NULL);
+ dvr_spawn_cmd(de, dvr_postproc, NULL, 0);
}