Improve copy operation for satellite muxes - allow specify the dst LNB config
The previous code was creating wrong mux entries with references to a LNB configuration used by the source adapter. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
b8778005b4
commit
eecf66f3ca
7 changed files with 92 additions and 25 deletions
|
@ -265,7 +265,8 @@ th_dvb_mux_instance_t *dvb_mux_create(th_dvb_adapter_t *tda,
|
|||
const struct dvb_mux_conf *dmc,
|
||||
uint16_t tsid, const char *network,
|
||||
const char *logprefix, int enabled,
|
||||
int initialscan, const char *identifier);
|
||||
int initialscan, const char *identifier,
|
||||
dvb_satconf_t *satconf);
|
||||
|
||||
void dvb_mux_set_networkname(th_dvb_mux_instance_t *tdmi, const char *name);
|
||||
|
||||
|
@ -295,7 +296,8 @@ const char *dvb_mux_add_by_params(th_dvb_adapter_t *tda,
|
|||
int polarisation,
|
||||
const char *satconf);
|
||||
|
||||
int dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src);
|
||||
int dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src,
|
||||
dvb_satconf_t *satconf);
|
||||
|
||||
/**
|
||||
* DVB Transport (aka DVB service)
|
||||
|
|
|
@ -458,7 +458,7 @@ dvb_adapter_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src)
|
|||
dvb_mux_destroy(tdmi_dst);
|
||||
|
||||
LIST_FOREACH(tdmi_src, &src->tda_muxes, tdmi_adapter_link)
|
||||
dvb_mux_copy(dst, tdmi_src);
|
||||
dvb_mux_copy(dst, tdmi_src, NULL);
|
||||
|
||||
tda_save(dst);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,8 @@ tdmi_compare_conf(int adapter_type,
|
|||
th_dvb_mux_instance_t *
|
||||
dvb_mux_create(th_dvb_adapter_t *tda, const struct dvb_mux_conf *dmc,
|
||||
uint16_t tsid, const char *network, const char *source,
|
||||
int enabled, int initialscan, const char *identifier)
|
||||
int enabled, int initialscan, const char *identifier,
|
||||
dvb_satconf_t *satconf)
|
||||
{
|
||||
th_dvb_mux_instance_t *tdmi, *c;
|
||||
unsigned int hash;
|
||||
|
@ -225,8 +226,9 @@ dvb_mux_create(th_dvb_adapter_t *tda, const struct dvb_mux_conf *dmc,
|
|||
|
||||
snprintf(buf, sizeof(buf), "%s%d%s%s%s",
|
||||
tda->tda_identifier, dmc->dmc_fe_params.frequency, qpsktxt,
|
||||
dmc->dmc_satconf ? "_satconf_" : "",
|
||||
dmc->dmc_satconf ? dmc->dmc_satconf->sc_id : "");
|
||||
(satconf || dmc->dmc_satconf) ? "_satconf_" : "",
|
||||
(satconf ? satconf->sc_id :
|
||||
(dmc->dmc_satconf ? dmc->dmc_satconf->sc_id : "")));
|
||||
|
||||
tdmi->tdmi_identifier = strdup(buf);
|
||||
} else {
|
||||
|
@ -259,6 +261,8 @@ dvb_mux_create(th_dvb_adapter_t *tda, const struct dvb_mux_conf *dmc,
|
|||
|
||||
|
||||
memcpy(&tdmi->tdmi_conf, dmc, sizeof(struct dvb_mux_conf));
|
||||
if(satconf)
|
||||
tdmi->tdmi_conf.dmc_satconf = satconf;
|
||||
if(tdmi->tdmi_conf.dmc_satconf != NULL) {
|
||||
LIST_INSERT_HEAD(&tdmi->tdmi_conf.dmc_satconf->sc_tdmis,
|
||||
tdmi, tdmi_satconf_link);
|
||||
|
@ -708,7 +712,7 @@ tdmi_create_by_msg(th_dvb_adapter_t *tda, htsmsg_t *m, const char *identifier)
|
|||
|
||||
tdmi = dvb_mux_create(tda, &dmc,
|
||||
tsid, htsmsg_get_str(m, "network"), NULL, enabled, 1,
|
||||
identifier);
|
||||
identifier, NULL);
|
||||
if(tdmi != NULL) {
|
||||
|
||||
if((s = htsmsg_get_str(m, "status")) != NULL)
|
||||
|
@ -1058,7 +1062,7 @@ dvb_mux_add_by_params(th_dvb_adapter_t *tda,
|
|||
}
|
||||
dmc.dmc_polarisation = polarisation;
|
||||
|
||||
tdmi = dvb_mux_create(tda, &dmc, 0xffff, NULL, NULL, 1, 1, NULL);
|
||||
tdmi = dvb_mux_create(tda, &dmc, 0xffff, NULL, NULL, 1, 1, NULL, NULL);
|
||||
|
||||
if(tdmi == NULL)
|
||||
return "Mux already exist";
|
||||
|
@ -1071,7 +1075,8 @@ dvb_mux_add_by_params(th_dvb_adapter_t *tda,
|
|||
*
|
||||
*/
|
||||
int
|
||||
dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src)
|
||||
dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src,
|
||||
dvb_satconf_t *satconf)
|
||||
{
|
||||
th_dvb_mux_instance_t *tdmi_dst;
|
||||
service_t *t_src, *t_dst;
|
||||
|
@ -1083,7 +1088,7 @@ dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src)
|
|||
tdmi_src->tdmi_transport_stream_id,
|
||||
tdmi_src->tdmi_network,
|
||||
"copy operation", tdmi_src->tdmi_enabled,
|
||||
1, NULL);
|
||||
1, NULL, satconf);
|
||||
|
||||
if(tdmi_dst == NULL)
|
||||
return -1; // Already exist
|
||||
|
|
|
@ -102,7 +102,7 @@ dvb_mux_preconf_add(th_dvb_adapter_t *tda, const struct mux *m, int num,
|
|||
|
||||
dmc.dmc_satconf = dvb_satconf_entry_find(tda, satconf, 0);
|
||||
|
||||
dvb_mux_create(tda, &dmc, 0xffff, NULL, source, 1, 1, NULL);
|
||||
dvb_mux_create(tda, &dmc, 0xffff, NULL, source, 1, 1, NULL, NULL);
|
||||
m++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -938,7 +938,7 @@ dvb_table_cable_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
|
|||
dmc.dmc_fe_params.u.qam.fec_inner = fec_tab[ptr[10] & 0x07];
|
||||
|
||||
dvb_mux_create(tdmi->tdmi_adapter, &dmc, tsid, NULL,
|
||||
"automatic mux discovery", 1, 1, NULL);
|
||||
"automatic mux discovery", 1, 1, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ dvb_table_sat_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
|
|||
|
||||
#endif
|
||||
dvb_mux_create(tdmi->tdmi_adapter, &dmc, tsid, NULL,
|
||||
"automatic mux discovery", 1, 1, NULL);
|
||||
"automatic mux discovery", 1, 1, NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -454,11 +454,14 @@ extjs_dvbsatconf(http_connection_t *hc, const char *remain, void *opaque)
|
|||
htsbuf_queue_t *hq = &hc->hc_reply;
|
||||
th_dvb_adapter_t *tda;
|
||||
htsmsg_t *out;
|
||||
const char *adapter = http_arg_get(&hc->hc_req_args, "adapter");
|
||||
|
||||
pthread_mutex_lock(&global_lock);
|
||||
|
||||
if(remain == NULL ||
|
||||
(tda = dvb_adapter_find_by_identifier(remain)) == NULL) {
|
||||
if((remain == NULL ||
|
||||
(tda = dvb_adapter_find_by_identifier(remain)) == NULL) &&
|
||||
(adapter == NULL ||
|
||||
(tda = dvb_adapter_find_by_identifier(adapter)) == NULL)) {
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
return 404;
|
||||
}
|
||||
|
@ -582,9 +585,11 @@ extjs_dvb_copymux(http_connection_t *hc, const char *remain, void *opaque)
|
|||
th_dvb_adapter_t *tda;
|
||||
htsmsg_t *in;
|
||||
const char *entries = http_arg_get(&hc->hc_req_args, "entries");
|
||||
const char *satconf = http_arg_get(&hc->hc_req_args, "satconf");
|
||||
const char *id;
|
||||
htsmsg_field_t *f;
|
||||
th_dvb_mux_instance_t *tdmi;
|
||||
dvb_satconf_t *sc = NULL;
|
||||
|
||||
in = entries != NULL ? htsmsg_json_deserialize(entries) : NULL;
|
||||
|
||||
|
@ -599,13 +604,20 @@ extjs_dvb_copymux(http_connection_t *hc, const char *remain, void *opaque)
|
|||
return 404;
|
||||
}
|
||||
|
||||
if (satconf) {
|
||||
sc = dvb_satconf_entry_find(tda, satconf, 0);
|
||||
if (sc == NULL) {
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(f, &in->hm_fields, hmf_link) {
|
||||
if((id = htsmsg_field_get_string(f)) != NULL &&
|
||||
(tdmi = dvb_mux_find_by_identifier(id)) != NULL &&
|
||||
tda != tdmi->tdmi_adapter) {
|
||||
|
||||
if(dvb_mux_copy(tda, tdmi)) {
|
||||
if(dvb_mux_copy(tda, tdmi, sc)) {
|
||||
char buf[100];
|
||||
dvb_mux_nicename(buf, sizeof(buf), tdmi);
|
||||
|
||||
|
|
|
@ -169,14 +169,24 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) {
|
|||
var selectedKeys = grid.selModel.selections.keys;
|
||||
var target = panel.getForm().getValues('targetID').targetID;
|
||||
|
||||
if(adapterData.satConf) {
|
||||
var satconf = panel.getForm().getValues('targetSatConfID').targetSatConfID;
|
||||
var mparams = {
|
||||
entries:Ext.encode(selectedKeys),
|
||||
satconf:satconf
|
||||
};
|
||||
} else {
|
||||
var mparams = {
|
||||
entries:Ext.encode(selectedKeys)
|
||||
};
|
||||
}
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: "dvb/copymux/" + target,
|
||||
params: {
|
||||
entries:Ext.encode(selectedKeys)
|
||||
},
|
||||
failure:function(response,options) {
|
||||
params: mparams,
|
||||
failure:function(response,options) {
|
||||
Ext.MessageBox.alert('Server Error','Unable to copy');
|
||||
},
|
||||
},
|
||||
success: function() {
|
||||
win.close();
|
||||
}
|
||||
|
@ -191,13 +201,38 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) {
|
|||
'name'],
|
||||
baseParams: {sibling: adapterId}
|
||||
});
|
||||
if(adapterData.satConf) {
|
||||
targetSatConfStore = new Ext.data.JsonStore({
|
||||
root:'entries',
|
||||
id: 'identifier',
|
||||
url:'dvb/satconf',
|
||||
fields: ['identifier',
|
||||
'name'],
|
||||
baseParams: {adapter: adapterId}
|
||||
});
|
||||
satConf = new Ext.form.ComboBox({
|
||||
store: targetSatConfStore,
|
||||
fieldLabel: 'Target Satellite config',
|
||||
name: 'targetsatconf',
|
||||
hiddenName: 'targetSatConfID',
|
||||
editable: false,
|
||||
allowBlank: false,
|
||||
triggerAction: 'all',
|
||||
mode: 'remote',
|
||||
displayField:'name',
|
||||
valueField:'identifier',
|
||||
emptyText: 'Select target adapter first...'
|
||||
});
|
||||
} else {
|
||||
satConf = null;
|
||||
}
|
||||
|
||||
var panel = new Ext.FormPanel({
|
||||
frame:true,
|
||||
border:true,
|
||||
bodyStyle:'padding:5px',
|
||||
labelAlign: 'right',
|
||||
labelWidth: 110,
|
||||
labelWidth: 150,
|
||||
defaultType: 'textfield',
|
||||
items: [
|
||||
|
||||
|
@ -212,8 +247,21 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) {
|
|||
mode: 'remote',
|
||||
displayField:'name',
|
||||
valueField:'identifier',
|
||||
emptyText: 'Select target adapter...'
|
||||
})
|
||||
emptyText: 'Select target adapter...',
|
||||
listeners: {
|
||||
'select': function(combo, value) {
|
||||
if (satConf) {
|
||||
satConf.emptyText = 'Select satellite configuration...';
|
||||
satConf.clearValue();
|
||||
targetSatConfStore.baseParams = {adapter: combo.value};
|
||||
targetSatConfStore.load();
|
||||
satConf.focus();
|
||||
satConf.expand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
satConf,
|
||||
],
|
||||
buttons: [{
|
||||
text: 'Copy',
|
||||
|
@ -225,7 +273,7 @@ tvheadend.dvb_muxes = function(adapterData, satConfStore) {
|
|||
title: 'Copy multiplex configuration',
|
||||
layout: 'fit',
|
||||
width: 500,
|
||||
height: 120,
|
||||
height: 150,
|
||||
modal: true,
|
||||
plain: true,
|
||||
items: panel
|
||||
|
|
Loading…
Add table
Reference in a new issue