Skip to content

Add --per-program for SRT ingest - #61

Open
gwendalsimon wants to merge 2 commits into
openmoq:mainfrom
gwendalsimon:feat/srt-per-program
Open

gwendalsimon wants to merge 2 commits into
openmoq:mainfrom
gwendalsimon:feat/srt-per-program

Conversation

@gwendalsimon

@gwendalsimon gwendalsimon commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

I added an opt-in --per-program option, so that SRT ingest can publish one program without its null packets. Unmodified carriage stays the default. On a constant-rate contribution feed, the nulls can take a large share of the rate. The catalog declares the source's rate in mpeg2tsMuxRate, so a receiver can pad back to it.

With --per-program, the --si, --retain-si, and --retain-null options apply on SRT. When the PAT stops listing the program, as during an encoder restart, the track ends and a new session waits for the program instead of the process exiting.

This PR depends on #59, because per-program carriage needs the PMT, which the old scan misses at high rates. I tested it in November 2026. New tests cover the nulls, the rate, the restart, and an interrupt during the wait. All 22 unit tests pass.


This change is Reviewable

gwendalsimon and others added 2 commits November 16, 2026 18:45
The PSI scan of a single-program live source read at most 4096
packets, which is 154 ms at 40 Mbit/s. An encoder that sends a PAT
every 476 ms, within the 500 ms of ETSI TR 101 290, then failed most
starts with "No PAT found at the start of the source".

* On a live source, wait for the PAT up to 1 s of PCR time
  (kPsiWindowPcr), then for its PMT up to 1 s after the PAT.
* Cap the single-program live scan, which keeps what it reads, at
  106,400 packets (2 s at 80 Mbit/s, about 20 MB). A source without
  a PCR stops at that cap.
* A program of a multiplex (timed windows) now also waits up to 1 s
  after the PAT for its PMT, where it stopped 1 s after the first PCR.
  Its 600,000-packet cap and stall error are unchanged.
* Keep the 4096-packet scan for seekable files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SRT ingest always forwarded the source unmodified. On a constant-rate
contribution feed, the null packets can be a large share of the rate,
for example 7.5 of 20 Mbit/s. Per-program carriage removes them and
declares the source's rate in mpeg2tsMuxRate, so that a receiver can
pad back to it.

* --per-program opts SRT ingest into per-program carriage; without it,
  SRT ingest stays unmodified, as before. The decision is
  moq2ts::srtCarriage, with its own test.
* --si, --retain-si, and --retain-null apply with it, and their
  "ignored" warning no longer appears. --per-program with --unmodified
  is refused, and --per-program without SRT ingest warns.
* When the PAT of a live source stops listing the program, as during
  an encoder restart, the per-program track ends and a new session
  waits for a PAT that lists the program, without a deadline and
  keeping nothing until then, instead of the process exiting. It logs
  one line when it starts waiting. An interrupt during the wait is
  not an error, so the process exits 0. The wait's packet counters
  are 64-bit.
* At open, per-program carriage now takes the first PAT that lists the
  program, not only the first PAT. A file whose first PAT lacks the
  program and a later one lists it now opens.
* Tests: a constant-rate live source in per-program carriage (no null
  packet, PAT and PCR carried, the source's rate declared; nulls kept
  and no rate with --retain-null); an encoder restart of 0.6, 1.5,
  and 2.5 s, the last also without a PCR (no error, a second session
  that publishes); an interrupt during the wait (no error); and the
  wait's memory bound.

Depends on the live PSI window (openmoq#59): per-program carriage needs the
PMT, which a 4096-packet scan misses at high rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mondain

mondain commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@gwendalsimon Holding this until the next MSFTS draft revision is out. --per-program on SRT depends on fields the revision may change: the per-program mode, mpeg2tsMuxRate (and how the catalog bitrate relates to it), and the SI PIDs. It matches draft -02 as it stands, and #59, which it depends on, is merged. After the revision lands I'll check the PR against the new text and then merge it, or ask for changes. No action needed from you now.

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.

2 participants