if (mod->done)
mod->done(mod);
pthread_mutex_lock(&global_lock);
- epggrab_channel_flush(mod->channels, 0);
+ epggrab_channel_flush(mod, 0);
free((void *)mod->id);
free((void *)mod->name);
free(mod);
idnode_t idnode;
TAILQ_ENTRY(epggrab_channel) all_link; ///< Global link
RB_ENTRY(epggrab_channel) link; ///< Global tree link
- epggrab_channel_tree_t *tree; ///< Member of this tree
epggrab_module_t *mod; ///< Linked module
int enabled; ///< Enabled/disabled
int enabled; ///< Whether the module is enabled
int active; ///< Whether the module is active
int priority; ///< Priority of the module
- epggrab_channel_tree_t *channels; ///< Channel list
+ epggrab_channel_tree_t channels; ///< Channel list
/* Activate */
int (*activate) ( void *m, int activate );
{
epggrab_module_t ; ///< Parent object
- //TAILQ_HEAD(, epggrab_ota_mux) muxes; ///< List of related muxes
-
/* Transponder tuning */
int (*start) ( epggrab_ota_map_t *map, struct mpegts_mux *mm );
int (*tune) ( epggrab_ota_map_t *map, epggrab_ota_mux_t *om,
{
epggrab_channel_t *ec;
- assert(owner->channels);
-
if (htsmsg_get_str(conf, "id") == NULL)
return NULL;
ec->mod = owner;
ec->enabled = 1;
- ec->tree = owner->channels;
if (conf)
idnode_load(&ec->idnode, conf);
TAILQ_INSERT_TAIL(&epggrab_channel_entries, ec, all_link);
- if (RB_INSERT_SORTED(owner->channels, ec, link, _ch_id_cmp)) abort();
+ if (RB_INSERT_SORTED(&owner->channels, ec, link, _ch_id_cmp)) abort();
return ec;
}
/* Find/Create channel in the list */
epggrab_channel_t *epggrab_channel_find
- ( epggrab_channel_tree_t *tree, const char *id, int create, int *save,
- epggrab_module_t *owner )
+ ( epggrab_module_t *mod, const char *id, int create, int *save )
{
char *s;
epggrab_channel_t *ec;
/* Find */
if (!create) {
- ec = RB_FIND(tree, epggrab_channel_skel, link, _ch_id_cmp);
+ ec = RB_FIND(&mod->channels, epggrab_channel_skel, link, _ch_id_cmp);
/* Find/Create */
} else {
- ec = RB_INSERT_SORTED(tree, epggrab_channel_skel, link, _ch_id_cmp);
+ ec = RB_INSERT_SORTED(&mod->channels, epggrab_channel_skel, link, _ch_id_cmp);
if (!ec) {
- assert(owner);
ec = epggrab_channel_skel;
SKEL_USED(epggrab_channel_skel);
ec->enabled = 1;
- ec->tree = tree;
ec->id = strdup(ec->id);
- ec->mod = owner;
+ ec->mod = mod;
TAILQ_INSERT_TAIL(&epggrab_channel_entries, ec, all_link);
if (idnode_insert(&ec->idnode, NULL, &epggrab_channel_class, 0))
/* Already linked */
epggrab_channel_links_delete(ec, 0);
- RB_REMOVE(ec->tree, ec, link);
+ RB_REMOVE(&ec->mod->channels, ec, link);
TAILQ_REMOVE(&epggrab_channel_entries, ec, all_link);
idnode_unlink(&ec->idnode);
}
void epggrab_channel_flush
- ( epggrab_channel_tree_t *tree, int delconf )
+ ( epggrab_module_t *mod, int delconf )
{
epggrab_channel_t *ec;
- if (tree == NULL)
- return;
- while ((ec = RB_FIRST(tree)) != NULL) {
- assert(tree == ec->tree);
+ while ((ec = RB_FIRST(&mod->channels)) != NULL)
epggrab_channel_destroy(ec, delconf);
- }
}
/* **************************************************************************
epggrab_channel_t *egc;
LIST_FOREACH(mod, &epggrab_modules, link)
- if (mod->channels)
- RB_FOREACH(egc, mod->channels, link)
- if (epggrab_channel_match_and_link(egc, ch))
- break;
+ RB_FOREACH(egc, &mod->channels, link)
+ if (epggrab_channel_match_and_link(egc, ch))
+ break;
}
void epggrab_channel_rem ( channel_t *ch )
strncpy(buf, id, sizeof(buf));
buf[sizeof(buf)-1] = '\0';
if ((mid = strtok_r(buf, "|", &cid)) && cid)
- if ((mod = epggrab_module_find_by_id(mid)) && mod->channels)
- return epggrab_channel_find(mod->channels, cid, 0, NULL, NULL);
+ if ((mod = epggrab_module_find_by_id(mid)) != NULL)
+ return epggrab_channel_find(mod, cid, 0, NULL);
return NULL;
}
return &prop_sbuf_ptr;
}
+static const void *
+epggrab_channel_class_path_get ( void *obj )
+{
+ epggrab_channel_t *ec = obj;
+ if (ec->mod->type == EPGGRAB_INT || ec->mod->type == EPGGRAB_EXT)
+ snprintf(prop_sbuf, PROP_SBUF_LEN, "%s", ((epggrab_module_int_t *)ec->mod)->path ?: "");
+ else
+ prop_sbuf[0] = '\0';
+ return &prop_sbuf_ptr;
+}
+
static const void *
epggrab_channel_class_channels_get ( void *obj )
{
.get = epggrab_channel_class_module_get,
.opts = PO_RDONLY | PO_NOSAVE,
},
+ {
+ .type = PT_STR,
+ .id = "path",
+ .name = N_("Path"),
+ .get = epggrab_channel_class_path_get,
+ .opts = PO_RDONLY | PO_NOSAVE,
+ },
{
.type = PT_STR,
.id = "id",
.ic_class = "epggrab_mod_int",
.ic_caption = N_("Internal EPG Grabber"),
.ic_properties = (const property_t[]){
+ {
+ .type = PT_STR,
+ .id = "path",
+ .name = N_("Path"),
+ .off = offsetof(epggrab_module_int_t, path),
+ .opts = PO_RDONLY | PO_NOSAVE,
+ .group = 1
+ },
{}
}
};
epggrab_module_t *epggrab_module_create
( epggrab_module_t *skel, const idclass_t *cls,
- const char *id, const char *name, int priority,
- epggrab_channel_tree_t *channels )
+ const char *id, const char *name, int priority )
{
assert(skel);
skel->id = strdup(id);
skel->name = strdup(name);
skel->priority = priority;
- skel->channels = channels;
+ RB_INIT(&skel->channels);
/* Insert */
assert(!epggrab_module_find_by_id(id));
{
htsmsg_t *m, *e;
htsmsg_field_t *f;
- if (!mod || !mod->channels) return;
+ if (!mod) return;
if ((m = hts_settings_load_r(1, "epggrab/%s/channels", mod->id))) {
HTSMSG_FOREACH(f, m) {
if ((e = htsmsg_get_map_by_field(f)))
const char *path,
char* (*grab) (void*m),
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
- htsmsg_t* (*trans) (void *mod, char *data),
- epggrab_channel_tree_t *channels )
+ htsmsg_t* (*trans) (void *mod, char *data) )
{
/* Allocate data */
if (!skel) skel = calloc(1, sizeof(epggrab_module_int_t));
/* Pass through */
epggrab_module_create((epggrab_module_t*)skel,
cls ?: &epggrab_class_mod_int,
- id, name, priority, channels);
+ id, name, priority);
/* Int data */
skel->type = EPGGRAB_INT;
skel->path = strdup(path);
- skel->channels = channels;
skel->grab = grab ?: epggrab_module_grab_spawn;
skel->trans = trans ?: epggrab_module_trans_xml;
skel->parse = parse;
( epggrab_module_ext_t *skel,
const char *id, const char *name, int priority, const char *sockid,
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
- htsmsg_t* (*trans) (void *mod, char *data),
- epggrab_channel_tree_t *channels )
+ htsmsg_t* (*trans) (void *mod, char *data) )
{
char path[512];
epggrab_module_int_create((epggrab_module_int_t*)skel,
&epggrab_class_mod_ext,
id, name, priority, path,
- NULL, parse, trans,
- channels);
+ NULL, parse, trans);
/* Local */
skel->type = EPGGRAB_EXT;
epggrab_module_ota_t *epggrab_module_ota_create
( epggrab_module_ota_t *skel,
const char *id, const char *name, int priority,
- epggrab_ota_module_ops_t *ops,
- epggrab_channel_tree_t *channels )
+ epggrab_ota_module_ops_t *ops )
{
if (!skel) skel = calloc(1, sizeof(epggrab_module_ota_t));
/* Pass through */
epggrab_module_create((epggrab_module_t*)skel,
&epggrab_class_mod_ota,
- id, name, priority, channels);
+ id, name, priority);
/* Setup */
skel->type = EPGGRAB_OTA;
skel->start = ops->start;
skel->done = ops->done;
skel->tune = ops->tune;
- //TAILQ_INIT(&skel->muxes);
return skel;
}
.tune = _eit_tune,
};
- epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber", 1, &ops, NULL);
- epggrab_module_ota_create(NULL, "uk_freesat", "UK: Freesat", 5, &ops, NULL);
- epggrab_module_ota_create(NULL, "uk_freeview", "UK: Freeview", 5, &ops, NULL);
- epggrab_module_ota_create(NULL, "viasat_baltic", "VIASAT: Baltic", 5, &ops, NULL);
- epggrab_module_ota_create(NULL, "Bulsatcom_39E", "Bulsatcom: Bula 39E", 5, &ops, NULL);
+ epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber", 1, &ops);
+ epggrab_module_ota_create(NULL, "uk_freesat", "UK: Freesat", 5, &ops);
+ epggrab_module_ota_create(NULL, "uk_freeview", "UK: Freeview", 5, &ops);
+ epggrab_module_ota_create(NULL, "viasat_baltic", "VIASAT: Baltic", 5, &ops);
+ epggrab_module_ota_create(NULL, "Bulsatcom_39E", "Bulsatcom: Bula 39E", 5, &ops);
}
void eit_done ( void )
#include "settings.h"
#include "input.h"
-static epggrab_channel_tree_t _opentv_channels;
-
#define OPENTV_TITLE_BASE 0xA0
#define OPENTV_SUMMARY_BASE 0xA8
#define OPENTV_TABLE_MASK 0xFC
{
char chid[256];
snprintf(chid, sizeof(chid), "%s-%d", mod->id, cid);
- return epggrab_channel_find(&_opentv_channels, chid, create, save,
- (epggrab_module_t*)mod);
+ return epggrab_channel_find((epggrab_module_t*)mod, chid, create, save);
}
/* ************************************************************************
/* Create */
sprintf(nbuf, "OpenTV: %s", name);
- mod = (opentv_module_t*)
+ mod = (opentv_module_t *)
epggrab_module_ota_create(calloc(1, sizeof(opentv_module_t)),
- ibuf, nbuf, 2, &ops, NULL);
+ ibuf, nbuf, 2, &ops);
/* Add provider details */
mod->dict = dict;
mod->channel = _pid_list_to_array(cl);
mod->title = _pid_list_to_array(tl);
mod->summary = _pid_list_to_array(sl);
- mod->channels = &_opentv_channels;
_opentv_compile_pattern_list(&mod->p_snum, htsmsg_get_list(m, "season_num"));
_opentv_compile_pattern_list(&mod->p_enum, htsmsg_get_list(m, "episode_num"));
_opentv_compile_pattern_list(&mod->p_pnum, htsmsg_get_list(m, "part_num"));
{
htsmsg_t *m;
- RB_INIT(&_opentv_channels);
-
/* Load dictionaries */
if ((m = hts_settings_load("epggrab/opentv/dict")))
_opentv_dict_load(m);
opentv_dict_t *dict;
opentv_genre_t *genre;
- epggrab_channel_flush(&_opentv_channels, 0);
while ((dict = RB_FIRST(&_opentv_dicts)) != NULL) {
RB_REMOVE(&_opentv_dicts, dict, h_link);
huffman_tree_destroy(dict->codes);
.tune = _psip_tune,
};
- epggrab_module_ota_create(NULL, "psip", "PSIP: ATSC Grabber", 1, &ops, NULL);
+ epggrab_module_ota_create(NULL, "psip", "PSIP: ATSC Grabber", 1, &ops);
}
void psip_done ( void )
#include "epggrab.h"
#include "epggrab/private.h"
-static epggrab_channel_tree_t _pyepg_channels;
-static epggrab_module_t *_pyepg_module; // primary module
-
-static epggrab_channel_t *_pyepg_channel_find
- ( const char *id, int create, int *save )
-{
- return epggrab_channel_find(&_pyepg_channels, id, create, save,
- _pyepg_module);
-}
-
/* **************************************************************************
* Parsing
* *************************************************************************/
if ((attr = htsmsg_get_map(data, "attrib")) == NULL) return 0;
if ((str = htsmsg_get_str(attr, "id")) == NULL) return 0;
if ((tags = htsmsg_get_map(data, "tags")) == NULL) return 0;
- if (!(ch = _pyepg_channel_find(str, 1, &save))) return 0;
+ if (!(ch = epggrab_channel_find(mod, str, 1, &save))) return 0;
stats->channels.total++;
if (save) stats->channels.created++;
if ((attr = htsmsg_get_map(data, "attrib")) == NULL) return 0;
if ((str = htsmsg_get_str(attr, "channel")) == NULL) return 0;
- if ((ec = _pyepg_channel_find(str, 0, NULL)) == NULL) return 0;
+ if ((ec = epggrab_channel_find(mod, str, 0, NULL)) == NULL) return 0;
if ((tags = htsmsg_get_map(data, "tags")) == NULL) return 0;
HTSMSG_FOREACH(f, tags) {
{
char buf[256];
- RB_INIT(&_pyepg_channels);
-
/* Internal module */
if (find_exec("pyepg", buf, sizeof(buf)-1))
epggrab_module_int_create(NULL, NULL,
"pyepg-internal", "PyEPG", 4, buf,
- NULL, _pyepg_parse, NULL, NULL);
+ NULL, _pyepg_parse, NULL);
/* External module */
- _pyepg_module = (epggrab_module_t*)
- epggrab_module_ext_create(NULL, "pyepg", "PyEPG", 4, "pyepg",
- _pyepg_parse, NULL,
- &_pyepg_channels);
+ epggrab_module_ext_create(NULL, "pyepg", "PyEPG", 4, "pyepg",
+ _pyepg_parse, NULL);
}
void pyepg_done ( void )
{
- epggrab_channel_flush(&_pyepg_channels, 0);
}
void pyepg_load ( void )
#define XMLTV_FIND "tv_find_grabbers"
#define XMLTV_GRAB "tv_grab_"
-static epggrab_channel_tree_t _xmltv_channels;
-static epggrab_module_t *_xmltv_module;
-
-static epggrab_channel_t *_xmltv_channel_find
- ( const char *id, int create, int *save )
-{
- return epggrab_channel_find(&_xmltv_channels, id, create, save,
- _xmltv_module);
-}
-
/* **************************************************************************
* Parsing
* *************************************************************************/
if((attribs = htsmsg_get_map(body, "attrib")) == NULL) return 0;
if((tags = htsmsg_get_map(body, "tags")) == NULL) return 0;
if((chid = htsmsg_get_str(attribs, "channel")) == NULL) return 0;
- if((ec = _xmltv_channel_find(chid, 1, &chsave)) == NULL) return 0;
+ if((ec = epggrab_channel_find(mod, chid, 1, &chsave)) == NULL) return 0;
if (chsave) {
epggrab_channel_updated(ec);
stats->channels.created++;
if((attribs = htsmsg_get_map(body, "attrib")) == NULL) return 0;
if((id = htsmsg_get_str(attribs, "id")) == NULL) return 0;
if((tags = htsmsg_get_map(body, "tags")) == NULL) return 0;
- if((ch = _xmltv_channel_find(id, 1, &save)) == NULL) return 0;
+ if((ch = epggrab_channel_find(mod, id, 1, &save)) == NULL) return 0;
stats->channels.total++;
if (save) stats->channels.created++;
outbuf[i] = '\0';
sprintf(name, "XMLTV: %s", &outbuf[n]);
epggrab_module_int_create(NULL, NULL, &outbuf[p], name, 3, &outbuf[p],
- NULL, _xmltv_parse, NULL, NULL);
+ NULL, _xmltv_parse, NULL);
p = n = i + 1;
} else if ( outbuf[i] == '\\') {
memmove(outbuf, outbuf + 1, strlen(outbuf));
if ((dir = opendir(tmp))) {
while ((de = readdir(dir))) {
if (strstr(de->d_name, XMLTV_GRAB) != de->d_name) continue;
+ if (de->d_name[0] && de->d_name[strlen(de->d_name)-1] == '~') continue;
snprintf(bin, sizeof(bin), "%s/%s", tmp, de->d_name);
if (epggrab_module_find_by_id(bin)) continue;
if (stat(bin, &st)) continue;
if (outbuf[outlen-1] == '\n') outbuf[outlen-1] = '\0';
snprintf(name, sizeof(name), "XMLTV: %s", outbuf);
epggrab_module_int_create(NULL, NULL, bin, name, 3, bin,
- NULL, _xmltv_parse, NULL, NULL);
+ NULL, _xmltv_parse, NULL);
free(outbuf);
} else {
if (rd >= 0)
void xmltv_init ( void )
{
- RB_INIT(&_xmltv_channels);
-
/* External module */
- _xmltv_module = (epggrab_module_t*)
- epggrab_module_ext_create(NULL, "xmltv", "XMLTV", 3, "xmltv",
- _xmltv_parse, NULL,
- &_xmltv_channels);
+ epggrab_module_ext_create(NULL, "xmltv", "XMLTV", 3, "xmltv",
+ _xmltv_parse, NULL);
/* Standard modules */
_xmltv_load_grabbers();
void xmltv_done ( void )
{
- epggrab_channel_flush(&_xmltv_channels, 0);
}
void xmltv_load ( void )
epggrab_module_t *epggrab_module_create
( epggrab_module_t *skel, const idclass_t *cls,
- const char *id, const char *name, int priority,
- epggrab_channel_tree_t *channels );
+ const char *id, const char *name, int priority );
char *epggrab_module_grab_spawn ( void *m );
htsmsg_t *epggrab_module_trans_xml ( void *m, char *data );
( epggrab_module_t *owner, htsmsg_t *conf, const char *uuid );
epggrab_channel_t *epggrab_channel_find
- ( epggrab_channel_tree_t *chs, const char *id, int create, int *save,
- epggrab_module_t *owner );
+ ( epggrab_module_t *mod, const char *id, int create, int *save );
void epggrab_channel_save ( epggrab_channel_t *ec );
void epggrab_channel_destroy
( epggrab_channel_t *ec, int delconf );
void epggrab_channel_flush
- ( epggrab_channel_tree_t *tree, int delconf );
+ ( epggrab_module_t *mod, int delconf );
void epggrab_channel_init(void);
void epggrab_channel_done(void);
const char *path,
char* (*grab) (void*m),
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
- htsmsg_t* (*trans) (void *mod, char *data),
- epggrab_channel_tree_t *channels );
+ htsmsg_t* (*trans) (void *mod, char *data) );
/* **************************************************************************
* External module routines
const char *id, const char *name, int priority,
const char *sockid,
int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
- htsmsg_t* (*trans) (void *mod, char *data),
- epggrab_channel_tree_t *channels );
+ htsmsg_t* (*trans) (void *mod, char *data) );
/* **************************************************************************
* OTA module routines
epggrab_module_ota_t *epggrab_module_ota_create
( epggrab_module_ota_t *skel,
const char *id, const char *name, int priority,
- epggrab_ota_module_ops_t *ops,
- epggrab_channel_tree_t *channels );
+ epggrab_ota_module_ops_t *ops );
/* **************************************************************************
* OTA mux link routines