Simplify IPv6 compare functions to unconfuse gcc compiler
In file included from src/tcp.c:32:
In function ‘ip_check_is_any_v6’,
inlined from ‘ip_check_is_any’ at src/tcp.h:110:46,
inlined from ‘ip_check_is_local_address’ at src/tcp.c:89:17:
src/tcp.h:105:57: warning: array subscript 1 is outside array bounds of ‘const struct sockaddr_storage[0]’ [-Warray-bounds]
105 | { return ((uint64_t *)IP_AS_V6(address, addr).s6_addr)[0] == ((uint64_t *)(&in6addr_any.s6_addr))[0] &&
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
src/tcp.h: In function ‘ip_check_is_local_address’:
src/tcp.h:108:19: note: at offset 8 into object ‘address’ of size 8
108 | static inline int ip_check_is_any(const struct sockaddr_storage *address)
| ^~~~~~~~~~~~~~~
And more for the other half of the function and its three-times more or
less copy-paste instances. sockaddr_storage is not an array, but what
we actually do here is access s6_addr – which is an array of uint8_t.
Accessing the 16 uint8_t as 2 uint64_t apparently works, but not doing
it results in hopefully simpler to understand code for both humans and
compilers alike.
If you have e.g. all but dvb disabled and forgot to plug in your usb
adapter the wizard would crash upon you as no inputs are defined and the
looping assumes there is at least one. Ideally a message should be shown
to indicate that you need inputs, but a wizard displaying a mostly empty
page is far better than a crash to discover your mistake.
Use application/json instead of text/x-json as mimetype
The web has mostly agreed on this standardized mimetype and e.g.
trying to open an API URI with Firefox is now opened in its friendly
JSON viewer rather than downloaded.
epgdb: Resolve symlinks before using file location
The new epgdb is written to a temporary file and later renamed to
override the old epgdb file atomically. If you diverted the epgdb
to a different place away from your usual configuration (e.g. for
space and/or disk usage reasons like on an OpenWrt router) this
leads to overriding the symlink with a real file defeating the point.
By applying realpath on the path first we can resolve any symlink
along the path, while not considering it a failure if the epgdb
file doesn't exist yet. If on the other hand the path up to the file
doesn't exist we default to the old way of just taking the path
verbatim and let them be created by hts_settings_makedirs as before.
Note that this relies on the paths being sized PATH_MAX, which as the
manpage notes is POSIX.1-2001 conform, but broken by design as PATH_MAX
can't be relied upon, but the entire codebase makes heavy use of PATH_MAX
and there is a pre-existing usage of realpath() in this way so lets
pretend its okay for now.
Michael Marley [Thu, 27 Oct 2022 21:48:46 +0000 (17:48 -0400)]
iptv_auto: Add support for m3u "channel-number" tag
SiliconDust recently added m3u playlist generation support to the
HDHomeRun products. They use "channel-number" for the channel
number, so add support for that value to TVHeadend. It is used as
a fallback only if the previously-supported "tvh-chnum" and
"tvg-chno" tags aren't present. This should be particularly useful
for usage with ATSC 3.0 channels, as those aren't supported in the
libhdhomerun library that TVHeadend normally uses for HDHomeRun
devices. Without this, the channel number for all channels
imported from the HDHomeRun m3u is "0".
Norm Raden [Mon, 12 Sep 2022 17:30:30 +0000 (13:30 -0400)]
Added more 'text modes' to the ATSC Multiple String Structure decoder and convert text to UTF-8. (Fixes #5162)
- Added support for decoding ATSC's "Multiple String Structure" text modes 0x1-0x6, 0x9-0x10, 0x20-0x27, 0x30-0x33.
- Convert decoded text to UTF-8 instead of ISO-8859-1.
- For unsupported 'compression types' or 'text modes' return a text string "[comptype=0x??,mode=0x??]" indicating
the attempted compression type and text mode instead of the text segment.
Text output from ATSC's "Multiple String Structure" decoder should properly render in web browsers, specifically Unicode characters >= 0x80.
When 'change muxes' option for network discovery is enabled, allow network scan to modify muxes rather than duplicate them on minor changes such as FEC
Norm Raden [Tue, 10 May 2022 18:00:30 +0000 (14:00 -0400)]
Fixed and cleanup the "PSIP: ATSC Grabber" module (Fixes #5610)
- Bumped up limit on number of supported EIT/ETT tables from 5 to 256 (this is the max number of EIT/ETT tables in the ATSC specification)
- Remove table type 4 as a valid ETT table, there is no support for this table here and table type 4 doesn't supply any EPG data--just long names for channels/services, etc.
- Removed the very rapid toggling between mpegts_table_{add,destroy}(...) calls on EIT/ETT tables that caused continuous enabling/disabling of EIT and ETT PIDs.
- Added an 'ETM Location' check to EIT table handling to ensure that an event's extra text is cleared in the EPG database if there is no matching ETT.
- Removed epg_broadcast_change_finish(...) because it was erasing the extra text field in EPG database when updating title in EPG database (in EIT handler).
- Added the ability for receiving ETT tables with the same version ID. ETT tables use the same version ID for long runs of event IDs and 'Extra text's.
- Fix bug in retrieving the number of tables EIT/ETT tables listed in the MGT table.
- Removed the psip_{find,remove,add}_desc(...) functions (and supporting code) that stored ETT extra texts before
there was a matching EIT event and then would try to match up the ETT extra texts when the EIT event showed up.
However, the psip_*_desc(..) functions didn't keep track of the channel and would match up the ETT 'Extra text' with the wrong EIT event.
- Removed some non-functional code.
- Removed old commented out test code.
- Added placeholder support for 'stop' and 'done' functions of this module for future development.
The "Over-the-air: PSIP: ATSC Grabber" module now quickly and correctly populates 'Title', 'Extra text', 'Start time', 'End time', 'Duration', etc... fields in the EPG Database.
Building Tvheadend on Raspberry Pi with gcc 12 fails with this error
src/misc/json.c: In function ‘json_parse_string’:
src/misc/json.c:120:31: error: pointer ‘r’ used after ‘free’ [-Werror=use-after-free]
120 | *failp = (a - r) + start;
| ~~~^~~~
src/misc/json.c:118:19: note: call to ‘free’ here
118 | free(r);
| ^~~~~~~
This PR appears correct and fixes the gcc error but has not been tested as it is an error path.
Nita Vesa [Wed, 23 Feb 2022 19:45:52 +0000 (21:45 +0200)]
Always parse 'src' in RTSP-requests
Originally, the code did not parse 'src' in RTSP-requests for
DVB-C tuners. This patch moves to always parse the parameter,
allowing e.g. Plex and possibly other SAT>IP-clients to work.
Ovaron [Mon, 21 Mar 2022 18:47:08 +0000 (19:47 +0100)]
Update for VAAPI transcoding
VAAPI: Buffer factor (buffersize manipulation) now configurable at WebUI.
VAAPI: Added rc_mode (h264/hevc) and tier (hevc), both configurable via WebUI.
VAAPI: Removed B-Frame workaround from the past at HEVC.
VAAPI: Added an option for ignore b-frames because some drivers needs this (AMD).
VAAPI: Also updated VP8 and VP9 encoding.
VAAPI: VP8 and VP9 now also reacts on options for "Buffer factor" and "Ignore B-Frames" and got the "force_key_frames" expression to increase picture quality.
VAAPI: Added destroy option for h264 codec (might have created memory issues)
Ovaron [Thu, 10 Feb 2022 20:51:21 +0000 (21:51 +0100)]
Update buffer size for h264 and hevc
Increased buffer for h264 and hevc transcoding (from ((self->bit_rate) * 1000) * 2 to ((self->bit_rate) * 1000) * 3).
With bigger buffer picture creates less artefacts on lower bitrates.
Jacek Tomasiak [Sat, 5 Feb 2022 00:03:44 +0000 (01:03 +0100)]
httpc: Fix multi-value "Connection" header checks
Connection header was checked for exact "close" or "upgrade" values
while it could contain multiple values delimited with commas.
New function was added for checking such cases.
Code is based on kv_find_value() function from:
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/relayd/relayd.c
Commit 0165f365cd58bbcc3734e4ec9ce696b42870ff8e introduced an FTBFS
when -Werror=int-conversion is passed to the compiler. For
reasons unknown to me, the "value" argument to AV_DICT_SET_INT was
written as a string (const char *) rather than the int64_t that
the function behind the macro was expecting in the "Set Defaults"
statements. This was resulting in the value of the pointer to the
character array getting used as the argument rather than the
integer itself, which appears to be what was intended. This
triggers the Werror=int-conversion error and also probably results
in unexpected behavior from passing the pointer values.
Michael Marley [Sun, 2 Jan 2022 17:38:17 +0000 (12:38 -0500)]
nvenc: Fix Werror=misleading-indentation FTBFS
Commit 0165f365cd58bbcc3734e4ec9ce696b42870ff8e introduced an FTBFS
when -Werror=misleading-indentation is passed to the compiler. It
appears from changes elsewhere in the file (around line 450) that
the "Set Defaults" statements were not intended to be included in
the if block, so this commit reformats it to make that obvious (and
also add curlybrackets as was done around 450.)
Michael Marley [Sun, 12 Dec 2021 02:01:08 +0000 (21:01 -0500)]
iptv: Fix stream limit starting a new input on a running mux
In iptv.c:iptv_input_is_free(), if all the conf arguments are 0
(when called from input_is_enabled()), return null if the mux
associated with the input is already running. If the mux is
already running, starting a new input on it isn't going to create
a new input stream or break any bandwidth limit. This fixes an
issue where starting a new channel/input on a mux that is already
active when the maximum number of input streams are in use would
result in failure.
This function is rather dense and appears to perform multiple
different functions depending on who called it, so I had a hard
time understanding exactly what is going on. Therefore, I made
this patch in a way to be sure that it wouldn't affect how it works
in other cases than input_is_enabled(). If there is a better way
to do this, please do tell me.
Michael Marley [Sat, 11 Dec 2021 23:09:47 +0000 (18:09 -0500)]
Use clock_gettime() instead of time() in epggrab.c
time() appears to return a slightly-rounded value as compared to
functions that return higher-precision time like gettimeofday() and
timespec_get(). Specifically, when gettimeofday() would return a
value with a low number in tv_usec, time() will return one fewer
seconds than tv_sec from gettimeofday(). The difference is minute
and probably doesn't cause an issue in most cases, but here in
epggrab.c the time of the next cron run is calculated immediately
after the previous run fires. In this case, the value of time()
is actually one second lower than the specified cron run time. This
value is then passed into cron_multi_next(), which correctly sets
the next cron run to the current time. Therefore, as soon as the
EPG grab completes, cron triggers again and re-runs it. Using the
more precise values from gettimeofday() (by way of clock_gettime())
solves this problem and ensures that cron runs only once.
Norm Raden [Tue, 14 Sep 2021 15:28:08 +0000 (11:28 -0400)]
Improve the performance of updating the pid filter table in hdhomerun digital tuners.
- Construct the compact list of pids formatted for the hdhomerun and handle edge cases.
- For each call to tvhdhomerun_frontend_update_pids(...), only issue one set_tuner_filter call to the hdhomerun.
- Turn off pids when done using them.
- Handle the rare case where the requested list of pids does not fit in to the fixed length buffer by enabling all pids, excluding the NULL pid.
Previously, calls to update the pids would generate get_tuner_filter and set_tuner_filter calls for each individual pid.
Also, while a tuner was allocated, pids would never be freed up from the hdhomerun filter table even when they were no longer needed.
And if the list of requested pids had exceeded the fixed length buffer, then not all the requested pids would be properly enabled.
Very noticeably, in cases where the number of pids is large enough, very frequent pid updates would overload the hdhomerun causing it to
drop bursts of program data (mpegts broadcast packets) every several seconds on all tuners for the duration of the rapid pid updates
(reproducible on the HDHR4-2US model).
James Hutchinson [Tue, 19 Oct 2021 14:35:27 +0000 (15:35 +0100)]
opentv: fix missing summary data on rescrape, #5995
Chunks of events within the OpenTV data can contain blank summaries
following a re-scrape.
The issue of blank summary data occurs when the event in question
already exists in the guide, and upon rescrape the summary record for
the event in question is procesed before the title record.
In this scenario we should merge the data to avoid blanking out the
summary data.
James Hutchinson [Sun, 26 Sep 2021 18:30:40 +0000 (19:30 +0100)]
opentv: fix incorrect summaries for skyuk epg, fixes #5995
Events within the OpenTV SkyUK data can contain the same Event ID as
another event on a different channel.
This resulted in missing or incorrect summary data, since matching was
based solely on the Event ID.
This commit adjusts the opentv _entry_cmp function to match based on a
combination of Event ID and Channel ID. This enables the RB_FIND &
RB_INSERT_SORTED functions used within the OpenTV module to reliably
insert and uniquely find the correct entry.
Autobuild: Add arm64, armhf and armel for bullseye and buster.
This is mainly for building packages on the Pi running plain-ol Debian and not Raspbian/Raspberry Pi OS, images are available at https://raspi.debian.net.