[FIX]: Restore XMLTV generation for ATSC EIT/VCT streams and correct EIT bounds checks #1773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Description
Fixes #1759 - This PR restores functional XMLTV generation for ATSC broadcast streams, ATSC streams with VCT/TVCT tables now generate XMLTV output correctly.
Problem
The
-xmltvparameter was being ignored for ATSC broadcast streams. When processing ATSC transport streams with valid EPG data (EIT tables) and channel information (VCT/TVCT tables), CCExtractor would:This made it impossible to extract Electronic Program Guide data from ATSC streams, despite the
-xmltvparameter being specified.Root causes identified:
TS_PMT_MAP_SIZE) were never outputSolution
Core Fixes
Fixed EPG output logic (
EPG_output()function)nb_program == 0Fixed critical buffer boundary check (
CHECK_OFFSETmacro)<to>if (offset + val < offset_end)(allowed buffer overruns)if (offset + (val) > offset_end)(prevents overruns)Extended ATSC table support (
EPG_parse_table()function)Testing
Tested with 1 2 sample files provided by @TPeterson94070:
channel5FullTS.ts- 5 channels with VCT/TVCT tablesch12FullTS.ts- Additional ATSC test casech29FullTS.ts- 5 programs with extended EIT data (Nov 26-28, 2025)Before this fix:
.srtfile generatedAfter this fix:
.srtAND.xmlfiles generatedts-meta-idvalues matching EIT event IDsKnown Limitations
ATSC EIT timestamps appear incorrect in some streams (e.g., year showing as 2047). This is due to pre-existing limitations in ATSC date/time decoding logic.
XMLTV output uses numeric channel IDs instead of full ATSC channel names. VCT short_name and major/minor channel numbers are not currently mapped.
Some EIT events appear under channel="0". This happens when service_id does not map to a VCT-defined program.
Backward Compatibility
Note on Known Limitations:
This PR focuses solely on fixing the core issue: restoring XMLTV generation for ATSC streams. The three accuracy issues mentioned above (incorrect dates, channel naming, orphaned programs) are data quality problems that existed in the codebase previously and are not directly caused by or related to the primary bug fix in this PR.
I believe these should be addressed in follow-up PRs for better separation of concerns. However, if maintainers prefer the date/time conversion issue (year 2047 bug) to be fixed in this PR due to its impact on usability, I'm happy to include it. Please advise on your preferred approach.