Skip to content

Conversation

hack03er
Copy link
Contributor

I would like to propose this feature to MuMuDVB. In my use case this enables me
to reduce a stream to only a few frequencies, which we forward to our CMTS.
Several MuMuDVB instances are streaming a frequency, which allows the CMTS to
establish a reduced stream again. The patching of the frequencies in the NIT is
only implemented for cable_delivery_system_descriptor.
An exemplary config for the first instance would be:

# --------------- TUNING ----------------
delivery_system=DVBC_ANNEX_AC # DVBC_ANNEX_B
card=0
freq=330000
srate=6900

# ---------- AUTOCONFIGURATION ----------
autoconfiguration=full
autoconf_radios=1

# -------------- NETWORKING -------------
autoconf_ip4=239.192.%card.%number
common_port=10000
multicast_ttl=16
multicast_ipv4=1
multicast_ipv6=0
rtp_header=1

# ------------ SAP ANNOUNCES ------------
# MuMuDVB patched to not include channels without name
sap_default_group=%type
sap_organisation=nw-cable

# ---------- WHOLE TRANSPONDER ----------
new_channel
ip=239.255.0.1
port=10000
pids=8192

# ----------- TABLE REWRITING -----------
# For full autoconf the pat is rewritten which breaks the full transponder
# streaming. As we stream all PIDs for each SID no rewrite is required.
rewrite_pat=0

# send EPG Data only for the current SID (or all for whole transponder)
#rewrite_eit=1
rewrite_eit=0

rewrite_nit=1
# E58-E61 band
freq_patch=0x03300000->0x07700000
freq_patch=0x04500000->0x07780000
freq_patch=0x04660000->0x07860000 # TSID 10000
freq_patch=0x05620000->0x07940000 # TSID 10017

The feature implements NIT-rewriting in the way that only given frequencies are kept.
If you agree, I would also replace void setCRC32(unsigned char *data) and
bool table_needs_update(char *mod_log_module, const int stored_version, unsigned char *buf)
in the other modules.

I tested the check for a new nit version with this:

diff --git a/src/rewrite_nit.c b/src/rewrite_nit.c
index 58b3c62..629e7d6 100644
--- a/src/rewrite_nit.c
+++ b/src/rewrite_nit.c
@@ -357,6 +357,7 @@ void get_nit_packet(const nit_section_t *nit_section_array, int section_number, 
 
 int global_packet_number = -1;
 int global_section_number = -1;
+int nit_section_count = 0;
 
 /**
  * @brief Swapping the NIT packet with a patched packet for every channel
@@ -374,7 +375,16 @@ void nit_rewrite_new_global_packet(unsigned char *ts_packet, rewrite_parameters_
 			log_message(log_module, MSG_DEBUG, "NIT not yet valid, we get a new one (current_next_indicator == 0)");
 			return;
 		}
+		nit_section_count++;
+		if (nit_section_count % 50 == 0) {
+			log_message(log_module, MSG_DEBUG, "NEW!");
+		}
+		nit_t *nit_header = (nit_t *)(ts_packet + NIT_TS_HEADER_LEN + 1);
+		nit_header->version_number += nit_section_count / 50;
+		nit->version_number += nit_section_count / 50;
+
 		if (table_needs_update(log_module, rewrite_vars->nit_version, ts_packet)) {
+			log_message(log_module, MSG_INFO, "New NIT version. Start caching NIT sections.");
 			rewrite_vars->nit_version = nit->version_number;
 
 			rewrite_vars->nit_section_count = nit->last_section_number + 1;

hack03er and others added 11 commits March 12, 2025 14:58
- add nit rewrite parameters
- add Cable Delivery System Descriptor
- adjusted Automake
- enabled rewrite by configure
- log NIT_REWRITE during startup
- cable delivery system descriptor
- nit transport stream loop
- complete nit
- ignore future packets
- check nit version
@hack03er hack03er force-pushed the final_nit_rewrite branch from d1be378 to 0e65f56 Compare March 12, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant