Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ then
AC_DEFINE(TUNE_OLD, 1, Define if you want the old code for tuning)
fi

AC_ARG_ENABLE([rewrite_nit_support],
[AS_HELP_STRING([--enable-rewrite_nit_support],
[Build with rewrite NIT support (default disabled)])],
[],
[enable_rewrite_nit_support="no"])

if test "${enable_rewrite_nit_support}" = "yes"
then
AC_DEFINE(REWRITE_NIT_SUPPORT, 1, Define if you want to rewrite the NIT Table)
fi
AM_CONDITIONAL([BUILD_REWRITE_NIT], [test "${enable_rewrite_nit_support}" = "yes"])

# Checks for header files.
AC_HEADER_RESOLV
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h values.h])
Expand Down Expand Up @@ -220,6 +232,12 @@ if test "${enable_tune_old}" = "yes" ; then
echo "Build with old tuning code: yes"
fi

if test "${enable_rewrite_nit_support}" = "yes" ; then
echo "Build with rewrite nit support: yes"
else
echo "Build with rewrite nit support: no"
fi

echo ""
echo "Debugging"
echo ""
Expand Down
1 change: 1 addition & 0 deletions doc/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The `[configure options]` specific to MuMuDVB are:
--enable-duma Debbuging DUMA library (default disabled)
--enable-android Support for Android (default disabled)
--disable-dvb-support Build without Linux DVB-API support, even on systems where the headers are present
--enable-rewrite_nit_support Build with rewrite nit support
---------------------------------------------------------------------

[NOTE]
Expand Down
4 changes: 3 additions & 1 deletion doc/README_CONF.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ Packets sending parameters
|rewrite_pmt | Do we rewrite the PMT PID | 0 | 0 or 1 | See README, important if you don't stream all PIDs
|rewrite_eit sort_eit | Do we rewrite/sort the EIT PID | 0 | 0 or 1 | See README
|sdt_force_eit | Do we force the EIT_schedule_flag and EIT_present_following_flag in SDT | 0 | 0 or 1 | Set to 0 if you don't understand
|rtp_header | Send the stream with the rtp headers (except for HTTP unicast) | 0 | 0 or 1 |
|rtp_header | Send the stream with the rtp headers (except for HTTP unicast) | 0 | 0 or 1 |
|rewrite_nit | Patch certain frequencies in the nit table | 0 | 0 or 1 | see freq_patch and configure options
|freq_patch | Map the old frequency given as a hexadecimal value to a new frequency. For example `freq_patch=0x03300000->0x07700000` will rewrite the nit entry with the frequency 330MHz to 770MHz| | `%x->%x` | rewrite_nit needs to be enabled
|==================================================================================================================

Logs parameters
Expand Down
13 changes: 7 additions & 6 deletions doc/html/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 9.0.0rc1" />
<meta name="generator" content="AsciiDoc 10.1.2" />
<title>MuMuDVB - README</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
Expand Down Expand Up @@ -738,9 +738,9 @@ <h1>MuMuDVB - README</h1>
<span id="author">Brice Dubost</span><br />
<span id="email"><code>&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</code></span><br />
<span id="revdate">Version 2.1.0</span>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="content">
Expand Down Expand Up @@ -949,7 +949,8 @@ <h4 id="_from_a_release_package">4.1.2. From a release package</h4>
--enable-coverage build for test coverage (default disabled)
--enable-duma Debbuging DUMA library (default disabled)
--enable-android Support for Android (default disabled)
--disable-dvb-support Build without Linux DVB-API support, even on systems where the headers are present</code></pre>
--disable-dvb-support Build without Linux DVB-API support, even on systems where the headers are present
--enable-rewrite_nit_support Build with rewrite nit support</code></pre>
</div></div>
<div class="admonitionblock">
<table><tr>
Expand Down Expand Up @@ -1956,7 +1957,7 @@ <h4 id="_mythtv_configuration">17.2.2. Mythtv configuration:</h4>
<div id="footer">
<div id="footer-text">
Last updated
2024-03-23 16:36:54 CET
2025-01-16 13:47:47 CET
</div>
</div>
</body>
Expand Down
24 changes: 19 additions & 5 deletions doc/html/README_CONF.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 9.0.0rc1" />
<meta name="generator" content="AsciiDoc 10.1.2" />
<title>MuMuDVB - README for the configuration file</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
Expand Down Expand Up @@ -738,9 +738,9 @@ <h1>MuMuDVB - README for the configuration file</h1>
<span id="author">Brice Dubost</span><br />
<span id="email"><code>&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</code></span><br />
<span id="revdate">Version 2.1.0</span>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="content">
Expand Down Expand Up @@ -1445,6 +1445,20 @@ <h3 id="_packets_sending_parameters">4.3. Packets sending parameters</h3>
<td align="left" valign="top"><p class="table">0 or 1</p></td>
<td align="left" valign="top"><p class="table"></p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">rewrite_nit</p></td>
<td align="left" valign="top"><p class="table">Patch certain frequencies in the nit table</p></td>
<td align="left" valign="top"><p class="table">0</p></td>
<td align="left" valign="top"><p class="table">0 or 1</p></td>
<td align="left" valign="top"><p class="table">see freq_patch and configure options</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">freq_patch</p></td>
<td align="left" valign="top"><p class="table">Map the old frequency given as a hexadecimal value to a new frequency. For example <code>freq_patch=0x03300000-&gt;0x07700000</code> will rewrite the nit entry with the frequency 330MHz to 770MHz</p></td>
<td align="left" valign="top"><p class="table"></p></td>
<td align="left" valign="top"><p class="table"><code>%x-&gt;%x</code></p></td>
<td align="left" valign="top"><p class="table">rewrite_nit needs to be enabled</p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -2129,7 +2143,7 @@ <h4 id="_scan_only_one_transponder">4.11.3. Scan only one transponder</h4>
<div id="footer">
<div id="footer-text">
Last updated
2024-03-23 16:36:54 CET
2025-01-16 14:46:57 CET
</div>
</div>
</body>
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ SOURCES_scamsupport = \
scam_send.h \
$(NULL)

if BUILD_REWRITE_NIT
mumudvb_SOURCES += rewrite_nit.c
endif
33 changes: 18 additions & 15 deletions src/autoconf_nit.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int autoconf_read_nit(auto_p_t *auto_p, mumu_chan_p_t *chan_p)
buf += network_descriptors_length;
nit_mid_t *middle=(nit_mid_t *)buf;
int ts_loop_length=HILO(middle->transport_stream_loop_length);
buf +=SIZE_NIT_MID;
buf += SIZE_NIT_MID;
parse_nit_ts_descriptor(buf,ts_loop_length, chan_p->channels, chan_p->number_of_channels, auto_p->transport_stream_id);


Expand Down Expand Up @@ -199,23 +199,26 @@ void parse_nit_ts_descriptor(unsigned char* buf, int ts_descriptors_loop_len, mu
break;
}
//We parse only descriptors with the right transport_stream_id
if(pat_tsid==ts_id)
{
if(descriptor_tag==0x83)
{
if(pat_tsid==ts_id) {
if(descriptor_tag==0x83) {
ts_display_lcn_descriptor(log_module, buf);
parse_lcn_descriptor(buf, channels, number_of_channels);
}
else if(descriptor_tag==0x41)
ts_display_service_list_descriptor(log_module, buf);
else if(descriptor_tag==0x43)
ts_display_satellite_delivery_system_descriptor(log_module, buf);
else if(descriptor_tag==0x5A)
ts_display_terrestrial_delivery_system_descriptor(log_module, buf);
else if(descriptor_tag==0x62)
ts_display_frequency_list_descriptor(log_module, buf);
else
} else if(descriptor_tag==0x41) {
ts_display_service_list_descriptor(log_module, buf);
} else if(descriptor_tag==0x43) {
ts_display_satellite_delivery_system_descriptor(log_module, buf);
} else if(descriptor_tag==0x44) {
log_message(log_module, MSG_FLOOD, " --- NIT TS descriptor --- cable delivery system descriptor "
"len %d descriptors_loop_len %d ------------\n",
descriptor_len, descriptors_loop_len);
ts_display_cable_delivery_system_descriptor(log_module, buf);
} else if(descriptor_tag==0x5A) {
ts_display_terrestrial_delivery_system_descriptor(log_module, buf);
} else if(descriptor_tag==0x62) {
ts_display_frequency_list_descriptor(log_module, buf);
} else {
log_message( log_module, MSG_FLOOD, " --- NIT TS descriptor --- descriptor_tag == 0x%02x len %d descriptors_loop_len %d ------------\n", descriptor_tag, descriptor_len, descriptors_loop_len);
}
}
buf += descriptor_len;
descriptors_loop_len -= descriptor_len;
Expand Down
34 changes: 34 additions & 0 deletions src/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
* it contains the precomputed table
*/

#include "crc32.h"

#include <stdint.h>
#include "ts.h"

/**CRC table for PAT rebuilding, cam support and autoconfiguration*/
uint32_t crc32_table[256] =
Expand Down Expand Up @@ -98,3 +101,34 @@ uint32_t crc32_table[256] =
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};

/**
* @brief CRC32 calculation inspired by the xine project
* @param data to be hashed
* @param len of data
* @return CRC32 value of data
*/
unsigned long calculateCRC32(const unsigned char *data, int len)
{
// Now we must adjust the CRC32
unsigned long crc32 = 0xffffffff;
for (int i = 0; i < len; ++i) {
crc32 = (crc32 << 8) ^ crc32_table[((crc32 >> 24) ^ data[i]) & 0xff];
}
return crc32;
}

/**
* @brief Calculates and sets CRC32 for PAT, EIT, SDT, PMT, NIT
* @param data pointer to table
*/
void setCRC32(unsigned char *data)
{
tbl_h_t *table = (tbl_h_t *)data;
int len = 3 + HILO(table->section_length) - 4; // CRC for complete section but CRC (4 Bytes)
unsigned long crc32 = calculateCRC32(data, len);
// We write the CRC32 to the buffer
data[len] = (crc32 >> 24) & 0xff;
data[len + 1] = (crc32 >> 16) & 0xff;
data[len + 2] = (crc32 >> 8) & 0xff;
data[len + 3] = crc32 & 0xff;
}
12 changes: 12 additions & 0 deletions src/crc32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _CRC32_H
#define _CRC32_H

#include <stdint.h>

extern uint32_t crc32_table[256];

unsigned long calculateCRC32(const unsigned char *data, int len);

void setCRC32(unsigned char *data);

#endif //_CRC32_H
3 changes: 3 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ void print_info ()
#ifdef DVBT2
"Built with support for DVB-T2.\n"
#endif
#ifdef REWRITE_NIT_SUPPORT
"Built with rewrite nit support.\n"
#endif
#endif
"---------\n"
"Originally based on dvbstream 0.6 by (C) Dave Chapman 2001-2004\n"
Expand Down
16 changes: 16 additions & 0 deletions src/mumudvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ int main (int argc, char **argv)
if(iRet==-1)
exit(ERROR_CONF);
}
#ifdef REWRITE_NIT_SUPPORT
else if((iRet=read_rewrite_nit_config(substring))) {
if (iRet==-1)
exit(ERROR_CONF);
}
#endif // REWRITE_NIT_SUPPORT
else if((iRet=read_logging_configuration(&stats_infos, substring))) //Read the line concerning the logging parameters
{
if(iRet==-1)
Expand Down Expand Up @@ -1636,6 +1642,16 @@ int main (int argc, char **argv)
{
eit_rewrite_new_global_packet(actual_ts_packet, &rewrite_vars);
}
#ifdef REWRITE_NIT_SUPPORT
/******************************************************/
//NIT rewrite
/******************************************************/
if ((pid == 0x10) && //This is a NIT PID
rewrite_vars.rewrite_nit == OPTION_ON) //AND we asked for rewrite
{
nit_rewrite_new_global_packet(actual_ts_packet, &rewrite_vars);
}
#endif // REWRITE_NIT_SUPPORT


/******************************************************/
Expand Down
Loading