From: Jaroslav Kysela Date: Tue, 13 Oct 2015 18:54:09 +0000 (+0200) Subject: IPTV: mux - add channel number, autonet - channel numbers from X-Git-Tag: v4.2.1~1923 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d4133ba3fbb6d847d14f3a3c1d8d63f0eaf418b;p=thirdparty%2Ftvheadend.git IPTV: mux - add channel number, autonet - channel numbers from --- diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 95445d1ee..d5bb165c0 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -22,6 +22,7 @@ #include "tcp.h" #include "settings.h" #include "htsstr.h" +#include "channels.h" #include #include @@ -559,6 +560,13 @@ const idclass_t iptv_auto_network_class = { .name = N_("URL"), .off = offsetof(iptv_network_t, in_url), }, + { + .type = PT_S64, + .intsplit = CHANNEL_SPLIT, + .id = "channel_number", + .name = N_("Channel numbers from"), + .off = offsetof(iptv_network_t, in_channel_number), + }, { .type = PT_U32, .id = "refetch_period", diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index 929050fec..d9b8bb41f 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -20,6 +20,7 @@ #include "tvheadend.h" #include "http.h" #include "iptv_private.h" +#include "channels.h" #include #include @@ -31,7 +32,7 @@ static void iptv_auto_network_process_m3u_item(iptv_network_t *in, const http_arg_list_t *remove_args, const char *url, const char *name, - int *total, int *count) + int64_t chnum, int *total, int *count) { htsmsg_t *conf; mpegts_mux_t *mm; @@ -50,6 +51,13 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, strncmp(url, "https://", 8))) return; + if (chnum) { + if (chnum % CHANNEL_SPLIT) + chnum += *total; + else + chnum += (int64_t)*total * CHANNEL_SPLIT; + } + memset(&u, 0, sizeof(u)); if (urlparse(url, &u)) return; @@ -102,6 +110,10 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, im->mm_iptv_svcname = name ? strdup(name) : NULL; change = 1; } + if (im->mm_iptv_chnum != chnum) { + im->mm_iptv_chnum = chnum; + change = 1; + } if (change) idnode_notify_changed(&im->mm_id); (*total)++; @@ -129,7 +141,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, */ static int iptv_auto_network_process_m3u(iptv_network_t *in, char *data, - http_arg_list_t *remove_args) + http_arg_list_t *remove_args, + int64_t chnum) { char *url, *name = NULL; int total = 0, count = 0; @@ -156,7 +169,8 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data, while (*data && *data != '\n') data++; if (*data) { *data = '\0'; data++; } if (*url) - iptv_auto_network_process_m3u_item(in, remove_args, url, name, &total, &count); + iptv_auto_network_process_m3u_item(in, remove_args, url, name, + chnum, &total, &count); } if (total == 0) @@ -195,7 +209,7 @@ iptv_auto_network_process(iptv_network_t *in, char *data, size_t len) while (*data && *data <= ' ') data++; if (!strncmp(data, "#EXTM3U", 7)) - r = iptv_auto_network_process_m3u(in, data, &remove_args); + r = iptv_auto_network_process_m3u(in, data, &remove_args, in->in_channel_number); if (r == 0) { count = 0; diff --git a/src/input/mpegts/iptv/iptv_mux.c b/src/input/mpegts/iptv/iptv_mux.c index 7d4cc9210..4a90d017e 100644 --- a/src/input/mpegts/iptv/iptv_mux.c +++ b/src/input/mpegts/iptv/iptv_mux.c @@ -19,6 +19,7 @@ #include "iptv_private.h" #include "settings.h" +#include "channels.h" /* * Class @@ -153,6 +154,13 @@ const idclass_t iptv_mux_class = .name = N_("Mux Name"), .off = offsetof(iptv_mux_t, mm_iptv_muxname), }, + { + .type = PT_S64, + .intsplit = CHANNEL_SPLIT, + .id = "channel_number", + .name = N_("Channel number"), + .off = offsetof(iptv_mux_t, mm_iptv_chnum), + }, { .type = PT_STR, .id = "iptv_sname", diff --git a/src/input/mpegts/iptv/iptv_private.h b/src/input/mpegts/iptv/iptv_private.h index ee8ad231f..1af8fe386 100644 --- a/src/input/mpegts/iptv/iptv_private.h +++ b/src/input/mpegts/iptv/iptv_private.h @@ -82,6 +82,7 @@ struct iptv_network uint32_t in_max_timeout; char *in_url; + int64_t in_channel_number; uint32_t in_refetch_period; int in_ssl_peer_verify; char *in_remove_args; @@ -112,6 +113,7 @@ struct iptv_mux char *mm_iptv_muxname; char *mm_iptv_svcname; + int64_t mm_iptv_chnum; int mm_iptv_respawn; time_t mm_iptv_respawn_last; diff --git a/src/input/mpegts/iptv/iptv_service.c b/src/input/mpegts/iptv/iptv_service.c index b274f19c4..19e1d61e5 100644 --- a/src/input/mpegts/iptv/iptv_service.c +++ b/src/input/mpegts/iptv/iptv_service.c @@ -67,6 +67,16 @@ iptv_service_channel_name ( service_t *s ) return is->s_dvb_svcname; } +static int64_t +iptv_service_channel_number ( service_t *s ) +{ + iptv_service_t *is = (iptv_service_t *)s; + iptv_mux_t *im = (iptv_mux_t *)is->s_dvb_mux; + if (im->mm_iptv_chnum) + return im->mm_iptv_chnum; + return mpegts_service_channel_number(s); +} + /* * Create */ @@ -80,9 +90,10 @@ iptv_service_create0 &mpegts_service_class, uuid, (mpegts_mux_t*)im, sid, pmt, conf); - is->s_config_save = iptv_service_config_save; - is->s_delete = iptv_service_delete; - is->s_channel_name = iptv_service_channel_name; + is->s_config_save = iptv_service_config_save; + is->s_delete = iptv_service_delete; + is->s_channel_name = iptv_service_channel_name; + is->s_channel_number = iptv_service_channel_number; /* Set default service name */ if (!is->s_dvb_svcname || !*is->s_dvb_svcname) diff --git a/src/input/mpegts/mpegts_dvb.h b/src/input/mpegts/mpegts_dvb.h index f786ecc45..a780a0730 100644 --- a/src/input/mpegts/mpegts_dvb.h +++ b/src/input/mpegts/mpegts_dvb.h @@ -78,4 +78,9 @@ dvb_mux_t *dvb_mux_create0 #define dvb_mux_create1(n, u, c)\ dvb_mux_create0(n, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, NULL, u, c) +/* + * + */ +int64_t mpegts_service_channel_number ( service_t *s ); + #endif /* __TVH_MPEGTS_DVB_H__ */ diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index c97a1702f..bd145dc53 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -439,7 +439,7 @@ mpegts_service_grace_period(service_t *t) /* * Channel number */ -static int64_t +int64_t mpegts_service_channel_number ( service_t *s ) { mpegts_service_t *ms = (mpegts_service_t*)s;