Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts mux: add 'accept zero value for TSID' option, fixes #3877
  • Loading branch information
perexg committed Jun 27, 2016
1 parent 0bc30b9 commit 631b6b5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/input/mpegts.h
Expand Up @@ -430,6 +430,8 @@ struct mpegts_mux
uint16_t mm_onid;
uint16_t mm_tsid;
int mm_tsid_checks;
int mm_tsid_accept_zero_value;
tvhlog_limit_t mm_tsid_loglimit;

int mm_update_pids_flag;
mtimer_t mm_update_pids_timer;
Expand Down
10 changes: 8 additions & 2 deletions src/input/mpegts/dvb_psi.c
Expand Up @@ -865,20 +865,26 @@ dvb_pat_callback
mpegts_mux_t *mm = mt->mt_mux;
mpegts_psi_table_state_t *st = NULL;
mpegts_service_t *s;
char buf[256];

/* Begin */
if (tableid != 0) return -1;
tsid = (ptr[0] << 8) | ptr[1];
r = dvb_table_begin((mpegts_psi_table_t *)mt, ptr, len,
tableid, tsid, 5, &st, &sect, &last, &ver);
if (r != 1) return r;
if (tsid == 0) goto end;
if (tsid == 0 && !mm->mm_tsid_accept_zero_value) {
if (tvhlog_limit(&mm->mm_tsid_loglimit, 2)) {
mpegts_mux_nice_name(mm, buf, sizeof(buf));
tvhwarn("pat", "%s: TSID zero value detected, ignoring", buf);
}
goto end;
}

/* Multiplex */
tvhdebug("pat", "%p: tsid %04X (%d)", mm, tsid, tsid);
if (mm->mm_tsid != MPEGTS_TSID_NONE) {
if (mm->mm_tsid && mm->mm_tsid != tsid) {
char buf[256];
if (++mm->mm_tsid_checks > 12) {
mpegts_mux_nice_name(mm, buf, sizeof(buf));
tvhwarn("pat", "%s: TSID change detected - old %04x (%d), new %04x (%d)",
Expand Down
6 changes: 6 additions & 0 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -866,6 +866,12 @@ const idclass_t iptv_auto_network_class = {
.off = offsetof(iptv_network_t, in_ssl_peer_verify),
.opts = PO_EXPERT
},
{
.type = PT_BOOL,
.id = "tsid_zero",
.name = N_("Accept zero value for TSID"),
.off = offsetof(iptv_network_t, in_tsid_accept_zero_value),
},
{
.type = PT_STR,
.id = "remove_args",
Expand Down
2 changes: 2 additions & 0 deletions src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -273,6 +273,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
htsmsg_add_str(conf, "iptv_hdr", custom);
if (epgcfg >= 0)
htsmsg_add_s32(conf, "epg", epgcfg);
if (in->in_tsid_accept_zero_value)
htsmsg_add_s32(conf, "tsid_zero", 1);
im = iptv_mux_create0(in, NULL, conf);
htsmsg_destroy(conf);

Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/iptv/iptv_private.h
Expand Up @@ -101,6 +101,7 @@ struct iptv_network
char *in_icon_url_sane;
int in_ssl_peer_verify;
char *in_remove_args;
int in_tsid_accept_zero_value;

void *in_auto; /* private structure for auto-network */
};
Expand Down
7 changes: 7 additions & 0 deletions src/input/mpegts/mpegts_mux.c
Expand Up @@ -651,6 +651,13 @@ const idclass_t mpegts_mux_class =
.opts = PO_RDONLY | PO_NOSAVE,
.get = mpegts_mux_class_get_num_chn,
},
{
.type = PT_BOOL,
.id = "tsid_zero",
.name = N_("Accept zero value for TSID"),
.off = offsetof(mpegts_mux_t, mm_tsid_accept_zero_value),
.opts = PO_ADVANCED
},
{
.type = PT_INT,
.id = "pmt_06_ac3",
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/tsfile/tsfile.c
Expand Up @@ -142,6 +142,7 @@ void tsfile_add_file ( const char *path )

/* Create logical instance */
mm = tsfile_mux_create(uuid, tsfile_network);
mm->mm_tsid_accept_zero_value = 1;

/* Create physical instance (for each tuner) */
LIST_FOREACH(mi, &tsfile_inputs, tsi_link)
Expand Down

0 comments on commit 631b6b5

Please sign in to comment.