uint16_t pm_pmt_pid;
uint16_t pm_src_sid;
uint16_t pm_dst_sid;
+ uint16_t pm_src_tsid;
+ uint16_t pm_dst_tsid;
+ uint16_t pm_src_onid;
+ uint16_t pm_dst_onid;
mpegts_psi_table_t pm_pat;
mpegts_psi_table_t pm_pmt;
out[1] = 0x80;
out[2] = 13; /* section_length (number of bytes after this field, including CRC) */
+ out[3] = pm->pm_dst_tsid >> 8;
+ out[4] = pm->pm_dst_tsid;
out[7] = 0;
- out[8] = (pm->pm_dst_sid & 0xff00) >> 8;
- out[9] = pm->pm_dst_sid & 0x00ff;
+ out[8] = pm->pm_dst_sid >> 8;
+ out[9] = pm->pm_dst_sid;
out[10] = 0xe0 | ((pm->pm_pmt_pid & 0x1f00) >> 8);
out[11] = pm->pm_pmt_pid & 0x00ff;
memcpy(out, buf, ol);
buf += ol;
len -= ol;
+
+ out[3] = pm->pm_dst_tsid >> 8;
+ out[4] = pm->pm_dst_tsid;
+ out[8] = pm->pm_dst_onid >> 8;
+ out[9] = pm->pm_dst_onid;
+
while (len >= 5) {
sid = (buf[0] << 8) | buf[1];
l = (buf[3] & 0x0f) << 8 | buf[4];
pass_muxer_nit_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len)
{
pass_muxer_t *pm;
- uint8_t out[4096], *ob;
- int l, ol;
+ uint8_t out[4096], *ob, dtag;
+ int l, ol, lptr, dlen;
/* filter out the other networks */
if (buf[0] != 0x40)
return;
pm = (pass_muxer_t*)mt->mt_opaque;
- l = (buf[8] & 0x0f) << 8 | buf[9];
- ol = 2 + 3 + 2 + 3 + l;
- if (ol > len)
- return;
+ memcpy(out, buf, ol = 10);
+ l = (buf[8] & 0x0f) << 8 | buf[9];
+ buf += 10;
+ len -= 10;
+
+ if (pm->m_config.u.pass.m_rewrite_sid > 0) {
+ out[3] = 0;
+ out[4] = 1;
+ }
+
+ while (l > 1 && len > 1) {
+ dtag = buf[0];
+ dlen = buf[1];
+ if (dtag == DVB_DESC_PRIVATE_DATA) {
+ if (sizeof(out) - 32 < ol) {
+ tvherror(LS_PASS, "NIT entry too long (%i)", ol);
+ return;
+ }
+ memcpy(out, buf, dlen + 2);
+ ol += dlen + 2;
+ }
+ dlen += 2;
+ buf += dlen;
+ len -= dlen;
+ l -= dlen;
+ }
+ out[8] &= 0xf0;
+ out[8] |= ((ol - 10) >> 8) & 0x0f;
+ out[9] = ol - 10;
- if (sizeof(out) < ol) {
+ if (sizeof(out) - 32 < ol) {
tvherror(LS_PASS, "NIT entry too long (%i)", ol);
return;
}
- memcpy(out, buf, ol);
+ /* mux info length */
+ lptr = ol;
+ out[ol++] = 0xf0;
+ out[ol++] = 0x00;
+
+ /* mux info */
+ out[ol++] = pm->pm_dst_tsid >> 8;
+ out[ol++] = pm->pm_dst_tsid;
+ out[ol++] = pm->pm_dst_onid >> 8;
+ out[ol++] = pm->pm_dst_onid;
+ /* mux tags */
+ out[ol++] = 0xf0;
+ out[ol++] = 5;
+ out[ol++] = DVB_DESC_SERVICE_LIST;
+ out[ol++] = 3;
+ out[ol++] = pm->pm_dst_sid >> 8;
+ out[ol++] = pm->pm_dst_sid;
+ out[ol++] = 0x11;
+ out[lptr] = (ol - lptr - 2) >> 8;
+ out[lptr+1] = ol - lptr - 2;
+
+ /* update section length */
+ out[1] = (out[1] & 0xf0) | ((ol + 4 - 3) >> 8);
+ out[2] = (ol + 4 - 3) & 0xff;
ol = dvb_table_append_crc32(out, ol, sizeof(out));
sbuf = malloc(len + 4);
memcpy(sbuf, buf, len);
sbuf[3] = pm->pm_dst_sid >> 8;
- sbuf[4] = pm->pm_dst_sid & 0xff;
+ sbuf[4] = pm->pm_dst_sid;
len = dvb_table_append_crc32(sbuf, len, len + 4);
if (len > 0 && (olen = dvb_table_remux(mt, sbuf, len, &out)) > 0) {
int i;
pm->pm_src_sid = ss->ss_service_id;
- if (pm->m_config.u.pass.m_rewrite_sid > 0)
+ pm->pm_src_tsid = ss->ss_si.si_tsid;
+ pm->pm_src_onid = ss->ss_si.si_onid;
+ if (pm->m_config.u.pass.m_rewrite_sid > 0) {
pm->pm_dst_sid = pm->m_config.u.pass.m_rewrite_sid;
- else
- pm->pm_dst_sid = ss->ss_service_id;
+ pm->pm_dst_tsid = 1;
+ pm->pm_dst_onid = 1;
+ } else {
+ pm->pm_dst_sid = pm->pm_src_sid;
+ pm->pm_dst_tsid = pm->pm_src_tsid;
+ pm->pm_dst_onid = pm->pm_src_onid;
+ }
pm->pm_pmt_pid = ss->ss_pmt_pid;
pm->pm_rewrite_sdt = !!pm->m_config.u.pass.m_rewrite_sdt;
pm->pm_rewrite_nit = !!pm->m_config.u.pass.m_rewrite_nit;
service_send_streaming_status(t);
}
+/**
+ *
+ */
+streaming_start_t *
+service_build_streaming_start(service_t *t)
+{
+ streaming_start_t *ss;
+ ss = elementary_stream_build_start(&t->s_components);
+ t->s_setsourceinfo(t, &ss->ss_si);
+ return ss;
+}
+
/**
* Restart output on a service (streams only).
* Happens if the stream composition changes.
sm = streaming_msg_create_code(SMT_STOP, SM_CODE_SOURCE_RECONFIGURED);
streaming_service_deliver(t, sm);
}
- ss = elementary_stream_build_start(&t->s_components);
- t->s_setsourceinfo(t, &ss->ss_si);
+ ss = service_build_streaming_start(t);
sm = streaming_msg_create_data(SMT_START, ss);
streaming_pad_deliver(&t->s_streaming_pad, sm);
t->s_running = 1;