]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Improve copy operation for satellite muxes - allow specify the dst LNB config
authorJaroslav Kysela <perex@perex.cz>
Tue, 28 Feb 2012 19:48:55 +0000 (20:48 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 28 Feb 2012 19:48:55 +0000 (20:48 +0100)
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>
src/dvb/dvb.h
src/dvb/dvb_adapter.c
src/dvb/dvb_multiplex.c
src/dvb/dvb_preconf.c
src/dvb/dvb_tables.c
src/webui/extjs_dvb.c
src/webui/static/app/dvb.js

index 9c14e23f2c087b4b509bcb76f8b51c1ae44b400c..ad9c30fbcdbad00fcadfd74ddc81cd109a34b2db 100644 (file)
@@ -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)
index 9f6afd56464eb536444080a6ca75dd672e4b899c..433107aed48199cc3c1f03ff25026d9bc1d2eb99 100644 (file)
@@ -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);
 }
index 9756fd6e767e737346f4e8c474d0013965239efc..770e03a2465b521d09cf2bed3a55d774516d21a1 100644 (file)
@@ -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
index ee6098ffe832e8b9ce6271f945d7fc476275460e..07f8c6abcc9b0dd33d1232ef801add9d3a5ee7fe 100644 (file)
@@ -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++;
   }
 }
index 74aa46766dfdd70deb4ba265cdc203a7d46f8970..53004aa3e2dd83064f5e47500165a4ba9afbe43a 100644 (file)
@@ -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;
 }
index c0d9c7f0c96d840924cfba4b1532ced981bef561..4080868e645e873624186d2f52b3d93dc1fcc589 100644 (file)
@@ -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);
 
index 7fae890afcd1092f7fbd9fa7391485724a8ee721..1fee1bcc1206c68f1c65a755388ad0ff1bac429e 100644 (file)
@@ -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