Skip to content

Fix issue where end of stream wasn't signaled if last pes had length field set#3206

Merged
copybara-service[bot] merged 2 commits into
androidx:mainfrom
nift4:peseof
May 11, 2026
Merged

Fix issue where end of stream wasn't signaled if last pes had length field set#3206
copybara-service[bot] merged 2 commits into
androidx:mainfrom
nift4:peseof

Conversation

@nift4
Copy link
Copy Markdown
Contributor

@nift4 nift4 commented May 7, 2026

In PesReader, endOfInput wasn't set to true if last pes had length field set. Originally, ExoPlayer was always dropping last frame in pes, it was fixed in #419 for pes without length and this fixes it for pes with length set. Thus, the dumps changed because last sample is now correctly parsed by ExoPlayer for both TsExtractor and PsExtractor.

Split packetFinished(boolean) into two methods because:

  • If pes length is unset, we only know packet is finished once next one starts or stream ends, so we know packet end and stream end at the same time. (This is what was handled so far)
  • If pes length is set, we may know packet end far before stream ends. Waiting for next pes to know whether to set isEndOfInput would introduce latency issues for ID3 or SCTE-35, but when we don't wait we can't deliver end of stream event later.

Thus split off a endOfInputReached() method to deliver end of stream event later, and every codec can override the method that best fits without latency issues.

@rohitjoins rohitjoins self-assigned this May 7, 2026
@rohitjoins rohitjoins force-pushed the peseof branch 3 times, most recently from 0ba5faf to ff63427 Compare May 8, 2026 01:06
@rohitjoins rohitjoins force-pushed the peseof branch 2 times, most recently from 24b35da to 10515ec Compare May 8, 2026 10:06
@FongMi
Copy link
Copy Markdown

FongMi commented May 8, 2026

Is there anything else that needs adjusting? If not, I'd like to merge and test it.

@rohitjoins
Copy link
Copy Markdown
Contributor

@FongMi,

Please feel free to test this PR. If you also want to test the stuttering you reported in #3147, you can also rebase that PR on top of this to verify it works smoothly now?

@FongMi
Copy link
Copy Markdown

FongMi commented May 8, 2026

Okay, thank you.

@rohitjoins rohitjoins force-pushed the peseof branch 3 times, most recently from 79a7cd2 to be5a260 Compare May 11, 2026 12:20
nift4 and others added 2 commits May 11, 2026 13:31
…field

set

In PesReader, endOfInput wasn't set to true if last pes had length field
set. Originally, ExoPlayer was always dropping last frame in pes, it was
fixed in androidx#419 for pes without length
and this fixes it for pes with length set. Thus, the dumps changed because
last sample is now correctly parsed by ExoPlayer for both TsExtractor and
PsExtractor.

Split packetFinished(boolean) into two methods because:
- If pes length is unset, we only know packet is finished once next one
  starts or stream ends, so we know packet end and stream end at the same
  time. (This is what was handled so far)
- If pes length is set, we may know packet end far before stream ends.
  Waiting for next pes to know whether to set isEndOfInput would introduce
  latency issues for ID3 or SCTE-35, but when we don't wait we can't deliver
  end of stream event later.

Thus split off a endOfInputReached() method to deliver end of stream event
later, and every codec can override the method that best fits without
latency issues.
@copybara-service copybara-service Bot merged commit cf56109 into androidx:main May 11, 2026
1 check passed
@nift4 nift4 deleted the peseof branch May 11, 2026 16:03
@nift4
Copy link
Copy Markdown
Contributor Author

nift4 commented May 11, 2026

I'm really grateful for you being so responsive and helpful while working on getting this chain merged, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants