diff --git a/ajaxui/ajaxui_config_dvb.c b/ajaxui/ajaxui_config_dvb.c
index adf97879..8fe3bd52 100644
--- a/ajaxui/ajaxui_config_dvb.c
+++ b/ajaxui/ajaxui_config_dvb.c
@@ -165,7 +165,7 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
tcp_queue_t *tq = &hr->hr_tq;
- th_dvb_adapter_t *tda;
+ th_dvb_adapter_t *tda, *tda2;
const char *s;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
@@ -217,10 +217,40 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
tcp_qprintf(tq, "");
+ tcp_qprintf(tq, "
");
+
+ tcp_qprintf(tq, "
");
ajax_a_jsfuncf(tq, "Rename adapter...",
"dvb_adapter_rename('%s', '%s');",
tda->tda_identifier, tda->tda_displayname);
-
+
+ tcp_qprintf(tq, "
");
+
+ /* Clone adapter */
+
+ tcp_qprintf(tq, "
");
+ tcp_qprintf(tq,
+ "
");
+ tcp_qprintf(tq, "
");
+
+ tcp_qprintf(tq, "");
+
tcp_qprintf(tq, "");
/* Muxes and transports */
@@ -872,6 +902,39 @@ ajax_dvbadapteraddnetwork(http_connection_t *hc, http_reply_t *hr,
return 0;
}
+/**
+ * Clone adapter
+ */
+static int
+ajax_dvbadapterclone(http_connection_t *hc, http_reply_t *hr,
+ const char *remain, void *opaque)
+{
+ tcp_queue_t *tq = &hr->hr_tq;
+ th_dvb_adapter_t *src, *dst;
+ const char *s;
+
+ if(remain == NULL || (dst = dvb_adapter_find_by_identifier(remain)) == NULL)
+ return HTTP_STATUS_NOT_FOUND;
+
+ if((s = http_arg_get(&hc->hc_req_args, "source")) == NULL)
+ return HTTP_STATUS_BAD_REQUEST;
+
+ if((src = dvb_adapter_find_by_identifier(s)) == NULL)
+ return HTTP_STATUS_BAD_REQUEST;
+
+ printf("Clone from %s to %s\n", src->tda_displayname, dst->tda_displayname);
+
+ dvb_tda_clone(dst, src);
+
+ tcp_qprintf(tq, "new Ajax.Updater('dvbadaptereditor', "
+ "'/ajax/dvbadaptereditor/%s', "
+ "{method: 'get', evalScripts: true});\r\n",
+ dst->tda_identifier);
+
+ http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
+ return 0;
+}
+
/**
*
@@ -899,5 +962,7 @@ ajax_config_dvb_init(void)
AJAX_ACCESS_CONFIG);
http_path_add("/ajax/dvbadapteraddnetwork", NULL, ajax_dvbadapteraddnetwork,
AJAX_ACCESS_CONFIG);
+ http_path_add("/ajax/dvbadapterclone", NULL, ajax_dvbadapterclone,
+ AJAX_ACCESS_CONFIG);
}
diff --git a/dvb.c b/dvb.c
index 104221a5..5ac63603 100644
--- a/dvb.c
+++ b/dvb.c
@@ -692,3 +692,68 @@ dvb_source_name(th_transport_t *t)
return buf;
}
+
+/**
+ *
+ */
+void
+dvb_tda_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src)
+{
+ th_dvb_mux_instance_t *tdmi_src, *tdmi_dst;
+ th_transport_t *t_src, *t_dst;
+ th_stream_t *st_src, *st_dst;
+
+ while((tdmi_dst = LIST_FIRST(&dst->tda_muxes)) != NULL)
+ dvb_mux_destroy(tdmi_dst);
+
+ LIST_FOREACH(tdmi_src, &src->tda_muxes, tdmi_adapter_link) {
+ tdmi_dst = dvb_mux_create(dst,
+ tdmi_src->tdmi_fe_params,
+ tdmi_src->tdmi_polarisation,
+ tdmi_src->tdmi_switchport,
+ 0,
+ tdmi_src->tdmi_transport_stream_id,
+ tdmi_src->tdmi_network);
+
+ LIST_FOREACH(t_src, &tdmi_src->tdmi_transports, tht_mux_link) {
+ t_dst = dvb_find_transport(tdmi_dst,
+ t_src->tht_dvb_service_id,
+ t_src->tht_pmt,
+ NULL);
+
+ t_dst->tht_pcr_pid = t_src->tht_pcr_pid;
+ t_dst->tht_disabled = t_src->tht_disabled;
+ t_dst->tht_servicetype = t_src->tht_servicetype;
+ t_dst->tht_scrambled = t_src->tht_scrambled;
+
+ if(t_src->tht_provider != NULL)
+ t_dst->tht_provider = strdup(t_src->tht_provider);
+
+ if(t_src->tht_servicename != NULL)
+ t_dst->tht_servicename = strdup(t_src->tht_servicename);
+
+ if(t_src->tht_channelname != NULL)
+ t_dst->tht_channelname = strdup(t_src->tht_channelname);
+
+ if(t_src->tht_channel != NULL)
+ transport_set_channel(t_dst, t_src->tht_channel->ch_name);
+
+
+
+ LIST_FOREACH(st_src, &t_src->tht_streams, st_link) {
+
+ st_dst = transport_add_stream(t_dst,
+ st_src->st_pid,
+ st_src->st_type);
+
+ st_dst->st_tb = (AVRational){1, 90000};
+
+ memcpy(st_dst->st_lang, st_src->st_lang, 4);
+ st_dst->st_frame_duration = st_src->st_frame_duration;
+ st_dst->st_caid = st_src->st_caid;
+ }
+ }
+ dvb_tdmi_save(tdmi_dst);
+ }
+ dvb_tda_save(dst);
+}
diff --git a/dvb.h b/dvb.h
index ce73cf8f..9f645560 100644
--- a/dvb.h
+++ b/dvb.h
@@ -68,4 +68,6 @@ void dvb_mux_destroy(th_dvb_mux_instance_t *tdmi);
void tdmi_stop(th_dvb_mux_instance_t *tdmi);
+void dvb_tda_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src);
+
#endif /* DVB_H_ */