mpegts linuxdvb: add routine to create mmi's on the fly
This commit is contained in:
parent
e0c4695239
commit
3cb6be346f
6 changed files with 58 additions and 25 deletions
|
@ -242,11 +242,12 @@ struct mpegts_mux
|
|||
* Functions
|
||||
*/
|
||||
|
||||
void (*mm_config_save) (mpegts_mux_t *mm);
|
||||
int (*mm_start) (mpegts_mux_t *mm, const char *reason, int weight);
|
||||
void (*mm_stop) (mpegts_mux_t *mm);
|
||||
void (*mm_open_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
void (*mm_close_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
void (*mm_config_save) (mpegts_mux_t *mm);
|
||||
int (*mm_start) (mpegts_mux_t *mm, const char *r, int w);
|
||||
void (*mm_stop) (mpegts_mux_t *mm);
|
||||
void (*mm_open_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
void (*mm_close_table) (mpegts_mux_t*,mpegts_table_t*);
|
||||
void (*mm_create_instances) (mpegts_mux_t*);
|
||||
|
||||
/*
|
||||
* Fields
|
||||
|
@ -346,6 +347,7 @@ struct mpegts_mux_instance
|
|||
idnode_t mmi_id;
|
||||
|
||||
LIST_ENTRY(mpegts_mux_instance) mmi_mux_link;
|
||||
LIST_ENTRY(mpegts_mux_instance) mmi_input_link;
|
||||
LIST_ENTRY(mpegts_mux_instance) mmi_active_link;
|
||||
|
||||
streaming_pad_t mmi_streaming_pad;
|
||||
|
@ -371,6 +373,8 @@ struct mpegts_input
|
|||
|
||||
LIST_HEAD(,mpegts_mux_instance) mi_mux_active;
|
||||
|
||||
LIST_HEAD(,mpegts_mux_instance) mi_mux_instances;
|
||||
|
||||
/*
|
||||
* Input processing
|
||||
*/
|
||||
|
|
|
@ -188,8 +188,6 @@ void linuxdvb_device_save ( linuxdvb_device_t *ld )
|
|||
htsmsg_add_str(m, "devid", ld->ld_devid.di_id);
|
||||
htsmsg_add_str(m, "devbus", devinfo_bus2str(ld->ld_devid.di_bus));
|
||||
htsmsg_add_str(m, "devpath", ld->ld_devid.di_path);
|
||||
} else {
|
||||
printf("OH NO, no device ID\n");
|
||||
}
|
||||
|
||||
/* Adapters */
|
||||
|
@ -238,6 +236,7 @@ linuxdvb_device_create0 ( const char *uuid, htsmsg_t *conf )
|
|||
|
||||
/* Create */
|
||||
ld = calloc(1, sizeof(linuxdvb_device_t));
|
||||
printf("create device %p\n", ld);
|
||||
if (idnode_insert(&ld->mi_id, uuid, &linuxdvb_device_class)) {
|
||||
free(ld);
|
||||
return NULL;
|
||||
|
@ -277,9 +276,13 @@ static linuxdvb_device_t *
|
|||
linuxdvb_device_find_by_hwid ( const char *hwid )
|
||||
{
|
||||
linuxdvb_hardware_t *lh;
|
||||
LIST_FOREACH(lh, &linuxdvb_device_all, lh_parent_link)
|
||||
LIST_FOREACH(lh, &linuxdvb_device_all, lh_parent_link) {
|
||||
printf("hwid = %s\n", hwid);
|
||||
printf("lh = %p\n", lh);
|
||||
printf("devid = %s\n", ((linuxdvb_device_t*)lh)->ld_devid.di_id);
|
||||
if (!strcmp(hwid, ((linuxdvb_device_t*)lh)->ld_devid.di_id))
|
||||
return (linuxdvb_device_t*)lh;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -303,6 +306,7 @@ linuxdvb_device_find_by_adapter ( int a )
|
|||
}
|
||||
|
||||
/* Copy device info */
|
||||
printf("added dev info to %p\n", ld);
|
||||
memcpy(&ld->ld_devid, &dev, sizeof(dev));
|
||||
ld->lh_displayname = strdup(dev.di_id);
|
||||
return ld;
|
||||
|
@ -318,9 +322,10 @@ void linuxdvb_device_init ( int adapter_mask )
|
|||
/* Load configuration */
|
||||
if ((s = hts_settings_load_r(1, "input/linuxdvb/devices"))) {
|
||||
HTSMSG_FOREACH(f, s) {
|
||||
if ((e = htsmsg_get_map_by_field(f))) {
|
||||
(void)linuxdvb_device_create0(f->hmf_name, e);
|
||||
}
|
||||
if (!(e = htsmsg_get_map_by_field(f))) continue;
|
||||
if (!(e = htsmsg_get_map(e, "config"))) continue;
|
||||
(void)linuxdvb_device_create0(f->hmf_name, e);
|
||||
printf("created from config\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,6 +220,8 @@ static int
|
|||
linuxdvb_frontend_start_mux
|
||||
( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
|
||||
{
|
||||
printf("fe_start(%p, %p)\n", mi, mmi);
|
||||
return SM_CODE_TUNING_FAILED;
|
||||
#if 0
|
||||
int r;
|
||||
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
|
||||
|
@ -258,7 +260,6 @@ linuxdvb_frontend_start_mux
|
|||
// TODO: should this be moved elsewhere?
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -329,13 +330,7 @@ linuxdvb_frontend_create0
|
|||
linuxdvb_network_t *ln = linuxdvb_network_find_by_uuid(str);
|
||||
if (ln) {
|
||||
if (ln->ln_type == lfe->lfe_info.type) {
|
||||
mpegts_mux_t *mm;
|
||||
extern const idclass_t mpegts_mux_instance_class;
|
||||
mpegts_network_add_input((mpegts_network_t*)ln, (mpegts_input_t*)lfe);
|
||||
// TODO: how the hell should I do this properly
|
||||
LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link)
|
||||
(void)mpegts_mux_instance_create(mpegts_mux_instance, NULL,
|
||||
(mpegts_input_t*)lfe, mm);
|
||||
} else
|
||||
tvhlog(LOG_WARNING, "linuxdvb",
|
||||
"attempt to add network %s of wrong type %s to %s (%s)",
|
||||
|
|
|
@ -106,6 +106,22 @@ linuxdvb_mux_stop ( mpegts_mux_t *mm )
|
|||
}
|
||||
#endif
|
||||
|
||||
extern const idclass_t mpegts_mux_instance_class;
|
||||
|
||||
static void
|
||||
linuxdvb_mux_create_instances ( mpegts_mux_t *mm )
|
||||
{
|
||||
mpegts_input_t *mi;
|
||||
mpegts_mux_instance_t *mmi;
|
||||
LIST_FOREACH(mi, &mm->mm_network->mn_inputs, mi_network_link) {
|
||||
LIST_FOREACH(mmi, &mi->mi_mux_instances, mmi_input_link)
|
||||
if (mmi->mmi_mux == mm) break;
|
||||
if (!mmi)
|
||||
mmi = mpegts_mux_instance_create(mpegts_mux_instance, NULL, mi, mm);
|
||||
// TODO: we might eventually want to keep history!
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linuxdvb_mux_open_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
|
||||
{
|
||||
|
@ -201,9 +217,10 @@ linuxdvb_mux_create0
|
|||
lm = (linuxdvb_mux_t*)mm;
|
||||
|
||||
/* Callbacks */
|
||||
lm->mm_config_save = linuxdvb_mux_config_save;
|
||||
lm->mm_open_table = linuxdvb_mux_open_table;
|
||||
lm->mm_close_table = linuxdvb_mux_close_table;
|
||||
lm->mm_config_save = linuxdvb_mux_config_save;
|
||||
lm->mm_open_table = linuxdvb_mux_open_table;
|
||||
lm->mm_close_table = linuxdvb_mux_close_table;
|
||||
lm->mm_create_instances = linuxdvb_mux_create_instances;
|
||||
|
||||
/* No config */
|
||||
if (!conf)
|
||||
|
|
|
@ -143,6 +143,9 @@ mpegts_mux_start ( mpegts_mux_t *mm, const char *reason, int weight )
|
|||
tvhtrace("mpegts", "mm %p already active", mm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create mux instances (where needed) */
|
||||
//mm->mm_create_instances(mm);
|
||||
|
||||
/* Find */
|
||||
// TODO: don't like this is unbounded, if for some reason mi_start_mux()
|
||||
|
@ -174,8 +177,10 @@ mpegts_mux_start ( mpegts_mux_t *mm, const char *reason, int weight )
|
|||
tvhtrace("mpegts", "found mmi %p to boot", mmi);
|
||||
|
||||
/* No free input */
|
||||
if (!mmi)
|
||||
if (!mmi) {
|
||||
tvhlog(LOG_DEBUG, "mpegts", "no input available");
|
||||
return SM_CODE_NO_FREE_ADAPTER;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tune */
|
||||
|
@ -232,8 +237,11 @@ mpegts_mux_stop ( mpegts_mux_t *mm )
|
|||
|
||||
/* Clear */
|
||||
mm->mm_active = NULL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
mpegts_mux_create_instances ( mpegts_mux_t *mm )
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -285,9 +293,12 @@ mpegts_mux_create0
|
|||
/* Add to network */
|
||||
LIST_INSERT_HEAD(&mn->mn_muxes, mm, mm_network_link);
|
||||
mm->mm_network = mn;
|
||||
mpegts_mux_initial_scan_link(mm);
|
||||
|
||||
/* Start/stop */
|
||||
mm->mm_start = mpegts_mux_start;
|
||||
mm->mm_stop = mpegts_mux_stop;
|
||||
mpegts_mux_initial_scan_link(mm);
|
||||
mm->mm_create_instances = mpegts_mux_create_instances;
|
||||
|
||||
/* Table processing */
|
||||
mm->mm_open_table = mpegts_mux_open_table;
|
||||
|
|
|
@ -47,6 +47,7 @@ mpegts_network_initial_scan(void *aux)
|
|||
mpegts_network_t *mn = aux;
|
||||
mpegts_mux_t *mm;
|
||||
|
||||
tvhtrace("mpegts", "setup initial scan for %p", mn);
|
||||
while((mm = TAILQ_FIRST(&mn->mn_initial_scan_pending_queue)) != NULL) {
|
||||
assert(mm->mm_initial_scan_status == MM_SCAN_PENDING);
|
||||
if (mm->mm_start(mm, "initial scan", 1))
|
||||
|
|
Loading…
Add table
Reference in a new issue