int dae_maxduration;
uint32_t dae_retention;
uint32_t dae_removal;
+ uint32_t dae_max_count;
time_t dae_start_extra;
time_t dae_stop_extra;
int dvr_autorec_get_extra_time_pre( dvr_autorec_entry_t *dae );
+void dvr_autorec_completed( dvr_entry_t *de, int error_code );
+
/**
*
*/
return bcast;
}
+/**
+ * Handle maxcount
+ */
+void
+dvr_autorec_completed(dvr_entry_t *de, int error_code)
+{
+ uint32_t count, total = 0;
+ dvr_entry_t *de_prev;
+ dvr_autorec_entry_t *dae = de->de_autorec;
+
+ if (dae == NULL) return;
+ if (dae->dae_max_count <= 0) return;
+ while (1) {
+ count = 0;
+ de_prev = NULL;
+ LIST_FOREACH(de, &dae->dae_spawns, de_autorec_link) {
+ if (de->de_sched_state != DVR_COMPLETED) continue;
+ if (dvr_get_filesize(de) < 0) continue;
+ if (de_prev && de_prev->de_start > de->de_start)
+ de_prev = de;
+ count++;
+ }
+ if (total == 0)
+ total = count;
+ if (count < dae->dae_max_count)
+ break;
+ if (de_prev) {
+ tvhinfo("dvr", "autorec %s removing recordings %s (allowed count %u total %u)",
+ dae->dae_name, idnode_uuid_as_sstr(&de_prev->de_id), dae->dae_max_count, total);
+ dvr_entry_cancel_delete(de_prev);
+ }
+ }
+}
+
/**
* return 1 if the event 'e' is matched by the autorec rule 'dae'
*/
.off = offsetof(dvr_autorec_entry_t, dae_removal),
.opts = PO_HIDDEN,
},
+ {
+ .type = PT_U32,
+ .id = "maxcount",
+ .name = N_("Maximum count (0=unlimited)"),
+ .off = offsetof(dvr_autorec_entry_t, dae_max_count),
+ .opts = PO_HIDDEN,
+ },
{
.type = PT_STR,
.id = "config_name",
dedup: { width: 160 },
retention: { width: 80 },
removal: { width: 80 },
+ maxcount: { width: 80 },
config_name: { width: 120 },
owner: { width: 100 },
creator: { width: 200 },
url: 'api/dvr/autorec',
params: {
list: 'enabled,name,directory,title,fulltext,channel,tag,content_type,minduration,' +
- 'maxduration,weekdays,start,start_window,pri,dedup,config_name,comment'
+ 'maxduration,weekdays,start,start_window,pri,dedup,retention,removal,' +
+ 'maxcount,config_name,comment'
},
create: { }
},