Add backing code for auto recording.
This more or less marks the DVR infrastructure in Tvheadend back to what it once was! Fixes issue #18
This commit is contained in:
parent
3b3a8ce29d
commit
08c0e7a2f4
3 changed files with 70 additions and 2 deletions
|
@ -166,5 +166,6 @@ void dvr_autorec_add(const char *title, const char *channel,
|
||||||
const char *tag, const char *contentgrp,
|
const char *tag, const char *contentgrp,
|
||||||
const char *creator, const char *comment);
|
const char *creator, const char *comment);
|
||||||
|
|
||||||
|
void dvr_autorec_check(event_t *e);
|
||||||
|
|
||||||
#endif /* DVR_H */
|
#endif /* DVR_H */
|
||||||
|
|
|
@ -59,9 +59,10 @@ typedef struct dvr_autorec_entry {
|
||||||
|
|
||||||
} dvr_autorec_entry_t;
|
} dvr_autorec_entry_t;
|
||||||
|
|
||||||
|
static void dvr_autorec_check_just_enabled(dvr_autorec_entry_t *dae);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/**
|
/**
|
||||||
* return 1 if the event 'e' is matched by the autorec rule 'ar'
|
* return 1 if the event 'e' is matched by the autorec rule 'ar'
|
||||||
*/
|
*/
|
||||||
|
@ -70,6 +71,9 @@ autorec_cmp(dvr_autorec_entry_t *dae, event_t *e)
|
||||||
{
|
{
|
||||||
channel_tag_mapping_t *ctm;
|
channel_tag_mapping_t *ctm;
|
||||||
|
|
||||||
|
if(dae->dae_enabled == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(dae->dae_channel != NULL &&
|
if(dae->dae_channel != NULL &&
|
||||||
dae->dae_channel != e->e_channel)
|
dae->dae_channel != e->e_channel)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -95,7 +99,6 @@ autorec_cmp(dvr_autorec_entry_t *dae, event_t *e)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,6 +242,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
||||||
const char *s;
|
const char *s;
|
||||||
channel_t *ch;
|
channel_t *ch;
|
||||||
channel_tag_t *ct;
|
channel_tag_t *ct;
|
||||||
|
uint32_t u32;
|
||||||
|
|
||||||
if((dae = autorec_entry_find(id, maycreate)) == NULL)
|
if((dae = autorec_entry_find(id, maycreate)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -284,6 +288,12 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
||||||
if((s = htsmsg_get_str(values, "contentgrp")) != NULL)
|
if((s = htsmsg_get_str(values, "contentgrp")) != NULL)
|
||||||
dae->dae_ecg = epg_content_group_find_by_name(s);
|
dae->dae_ecg = epg_content_group_find_by_name(s);
|
||||||
|
|
||||||
|
if(!htsmsg_get_u32(values, "enabled", &u32))
|
||||||
|
dae->dae_enabled = u32;
|
||||||
|
|
||||||
|
if(dae->dae_enabled)
|
||||||
|
dvr_autorec_check_just_enabled(dae);
|
||||||
|
|
||||||
return autorec_record_build(dae);
|
return autorec_record_build(dae);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,4 +385,57 @@ dvr_autorec_add(const char *title, const char *channel,
|
||||||
m = htsmsg_create();
|
m = htsmsg_create();
|
||||||
htsmsg_add_u32(m, "asyncreload", 1);
|
htsmsg_add_u32(m, "asyncreload", 1);
|
||||||
notify_by_msg("autorec", m);
|
notify_by_msg("autorec", m);
|
||||||
|
|
||||||
|
dvr_autorec_check_just_enabled(dae);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
autorec_schedule(event_t *e, dvr_autorec_entry_t *dae)
|
||||||
|
{
|
||||||
|
char buf[200];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "Auto recording by: %s", dae->dae_creator);
|
||||||
|
dvr_entry_create_by_event(e, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dvr_autorec_check(event_t *e)
|
||||||
|
{
|
||||||
|
dvr_autorec_entry_t *dae;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(dae, &autorec_entries, dae_link)
|
||||||
|
if(autorec_cmp(dae, e))
|
||||||
|
autorec_schedule(e, dae);
|
||||||
|
|
||||||
|
if((e = RB_NEXT(e, e_channel_link)) == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Check next event too */
|
||||||
|
TAILQ_FOREACH(dae, &autorec_entries, dae_link)
|
||||||
|
if(autorec_cmp(dae, e))
|
||||||
|
autorec_schedule(e, dae);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
dvr_autorec_check_just_enabled(dvr_autorec_entry_t *dae)
|
||||||
|
{
|
||||||
|
channel_t *ch;
|
||||||
|
|
||||||
|
RB_FOREACH(ch, &channel_name_tree, ch_name_link) {
|
||||||
|
if(ch->ch_epg_current == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(autorec_cmp(dae, ch->ch_epg_current))
|
||||||
|
autorec_schedule(ch->ch_epg_current, dae);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
4
epg.c
4
epg.c
|
@ -26,6 +26,7 @@
|
||||||
#include "tvhead.h"
|
#include "tvhead.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "epg.h"
|
#include "epg.h"
|
||||||
|
#include "dvr/dvr.h"
|
||||||
|
|
||||||
#define EPG_MAX_AGE 86400
|
#define EPG_MAX_AGE 86400
|
||||||
|
|
||||||
|
@ -52,6 +53,9 @@ static void
|
||||||
epg_set_current(channel_t *ch, event_t *e)
|
epg_set_current(channel_t *ch, event_t *e)
|
||||||
{
|
{
|
||||||
ch->ch_epg_current = e;
|
ch->ch_epg_current = e;
|
||||||
|
if(e != NULL)
|
||||||
|
dvr_autorec_check(e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue