feat(libwebrtc): implement webrtc::rtcp::Pli::Parse #15092

Merged
alvaroelpob merged 3 commits from upstream-pr/15092 into main 2026-11-06 02:39:23 +00:00
alvaroelpob commented 2026-11-02 15:14:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-02T15:14:00Z.


What

Implements webrtc::rtcp::Pli::Parse(const CommonHeader&) in libwebrtc, which threw and was declared without parameters.

The module's WebRTC revision lies between M127 and M134, as recorded in the debt file. Pli::Parse and Psfb::ParseCommonFeedback are the same at M127 branch-heads/6533 and M134 branch-heads/6998. pli.h, psfb.h and rtcp_packet.h are identical at both, and M134 only drops the out-of-line constexpr definitions.

The function is adapted from pli.cc and psfb.cc and lives in src/RtcpPli.cpp. That file starts with their WebRTC copyright notice and the BSD licence text from WebRTC's LICENSE.

WebRtcRtcpPli is the 16-byte layout of rtcp_packet.h and psfb.h: the vtable pointer from RtcpPacket's virtual destructor, sender_ssrc_ at 8 and media_ssrc_ at 12. Pli adds no members. static_asserts check it. Parse takes this first and the CommonHeader (the existing WebRtcRtcpCommonHeader) second:

  • If the payload is shorter than 8 bytes (kCommonFeedbackLength), it returns false and leaves the packet untouched.
  • Otherwise it reads the sender and media SSRCs big-endian from the first 8 payload bytes and returns true. The vtable pointer is never written.

Gaps, recorded as debt:

  • Upstream writes an RTC_LOG(LS_WARNING) for a short payload; libwebrtc's logging is not implemented, so it is not emitted.
  • Upstream only RTC_DCHECKs the packet type and format, so, as in a release build, neither is checked.

Upstream reads a null packet, a null header, and a null payload of 8 bytes or more, so all three throw. The inventory drops from 352 to 351.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON.

  • New guest_webrtc_rtcp_pli test, on packets filled with 0xA5 and headers from CommonHeader::Parse:
    • A PLI with an 8-byte payload: both SSRCs are read big-endian and the vtable pointer is unchanged.
    • A 12-byte payload: only the first 8 bytes are read.
    • Returns false and leaves the packet untouched: an empty payload, a payload that padding cuts to 7 bytes, and a 7-byte payload with a null pointer.
    • A null packet, a null header, or a null 8-byte payload throws std::invalid_argument.
  • Full ctest -j16 on head 241005be7b: 3533/3533 pass. check_conventions.py --base upstream/main passes.
  • pr_overlap.py: no other open PR implements Pli::Parse. The shared lines are the pending-export count in docs/dev/debt/libwebrtc.md and, with #14224, the target_sources list in CMakeLists.txt.
  • Rebased on main 096c45570f (after #14087, #14095, #14116, #14120, #14129 and #14148), head b675b4075e, to resolve the conflicts on the shared CMakeLists.txt, Api.hpp and debt-file lines; both sides are kept and the count is 351, the 291 stubs left plus the 60 NID exports. Full build and ctest -j16: 3596/3596 pass. check_conventions.py --base upstream/main passes.
  • Not tested: Windows, a title.
  • Rebased on main 4f41f4c375, head 4cab30e768, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp and debt-file lines; both sides are kept and the debt count is recomputed from Export.cpp. Full build and ctest -j16: 3796/3800 pass; guest_sce_net, guest_poll, guest_select_wait and guest_memory failed under that load, pass when run alone, and main 4f41f4c375 passes all 3799 with -j16 on the same machine. check_conventions.py --base upstream/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5122626722 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15092). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-02T15:14:00Z. --- ### What Implements `webrtc::rtcp::Pli::Parse(const CommonHeader&)` in libwebrtc, which threw and was declared without parameters. The module's WebRTC revision lies between M127 and M134, as recorded in the debt file. `Pli::Parse` and `Psfb::ParseCommonFeedback` are the same at [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/modules/rtp_rtcp/source/rtcp_packet/pli.cc) and [M134 branch-heads/6998](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/pli.cc). `pli.h`, `psfb.h` and `rtcp_packet.h` are identical at both, and M134 only drops the out-of-line `constexpr` definitions. The function is adapted from `pli.cc` and `psfb.cc` and lives in `src/RtcpPli.cpp`. That file starts with their WebRTC copyright notice and the BSD licence text from WebRTC's `LICENSE`. `WebRtcRtcpPli` is the 16-byte layout of `rtcp_packet.h` and `psfb.h`: the vtable pointer from `RtcpPacket`'s virtual destructor, `sender_ssrc_` at 8 and `media_ssrc_` at 12. `Pli` adds no members. `static_assert`s check it. `Parse` takes `this` first and the `CommonHeader` (the existing `WebRtcRtcpCommonHeader`) second: - If the payload is shorter than 8 bytes (`kCommonFeedbackLength`), it returns false and leaves the packet untouched. - Otherwise it reads the sender and media SSRCs big-endian from the first 8 payload bytes and returns true. The vtable pointer is never written. Gaps, recorded as debt: - Upstream writes an `RTC_LOG(LS_WARNING)` for a short payload; libwebrtc's logging is not implemented, so it is not emitted. - Upstream only `RTC_DCHECK`s the packet type and format, so, as in a release build, neither is checked. Upstream reads a null packet, a null header, and a null payload of 8 bytes or more, so all three throw. The inventory drops from 352 to 351. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. - New `guest_webrtc_rtcp_pli` test, on packets filled with 0xA5 and headers from `CommonHeader::Parse`: - A PLI with an 8-byte payload: both SSRCs are read big-endian and the vtable pointer is unchanged. - A 12-byte payload: only the first 8 bytes are read. - Returns false and leaves the packet untouched: an empty payload, a payload that padding cuts to 7 bytes, and a 7-byte payload with a null pointer. - A null packet, a null header, or a null 8-byte payload throws `std::invalid_argument`. - Full `ctest -j16` on head 241005be7b: 3533/3533 pass. `check_conventions.py --base upstream/main` passes. - `pr_overlap.py`: no other open PR implements `Pli::Parse`. The shared lines are the pending-export count in `docs/dev/debt/libwebrtc.md` and, with #14224, the `target_sources` list in `CMakeLists.txt`. - Rebased on `main` 096c45570f (after #14087, #14095, #14116, #14120, #14129 and #14148), head b675b4075e, to resolve the conflicts on the shared `CMakeLists.txt`, `Api.hpp` and debt-file lines; both sides are kept and the count is 351, the 291 stubs left plus the 60 NID exports. Full build and `ctest -j16`: 3596/3596 pass. `check_conventions.py --base upstream/main` passes. - Not tested: Windows, a title. - Rebased on `main` 4f41f4c375, head 4cab30e768, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp` and debt-file lines; both sides are kept and the debt count is recomputed from `Export.cpp`. Full build and `ctest -j16`: 3796/3800 pass; `guest_sce_net`, `guest_poll`, `guest_select_wait` and `guest_memory` failed under that load, pass when run alone, and `main` 4f41f4c375 passes all 3799 with `-j16` on the same machine. `check_conventions.py --base upstream/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-02 15:54:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T15:54:30Z.

Review: APPROVED


Checked against firmware 13.42's own module as well as the upstream source. libwebrtc.sprx (sha256 d59d0caf6967329b39201a2a0bd6df7b994516f21701b9801908db6735ae5314), lgJuzIdaeRU at 0x3c64a0, read from disassembly only, not measured on a console:

3c64a1: mov ebx, [rsi+4] ; cmp ebx, 7 ; jbe 3c64b4    ; payload_size_bytes() < 8 -> log path
3c64a9: mov rsi, [rsi+8] ; call 0x3c65c0              ; ParseCommonFeedback(payload)
  3c65c0: mov eax, [rsi] ; movbe [rdi+8], eax         ; sender_ssrc_, big-endian
  3c65c7: mov eax, [rsi+4] ; movbe [rdi+0xc], eax     ; media_ssrc_
3c64b4: call 0x36580 ; ... call 0x154060 (line 0x18a) ; the RTC_LOG(LS_WARNING) path
3c64de: cmp ebx, 8 ; setae al ; ret

This matches the PR:

  • payloadSize is at header+4 and payload at +8, as in WebRtcRtcpCommonHeader.
  • The two SSRCs go to +8 and +0xc, as in WebRtcRtcpPli.
  • A short payload returns false, leaves the packet untouched, and only logs.
  • The vtable is never written.

Build and test on Windows (WinLibs GCC, BUILD_TESTING=ON), PR merged into current main: guest_webrtc_rtcp_pli passes. On main the export throws not implemented.

One note, no change needed: the three invalid_argument throws for null arguments are host-side. The module dereferences rsi straight away, so the console faults there.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5739325139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15092#pullrequestreview-5739325139). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T15:54:30Z. **Review:** APPROVED --- Checked against firmware 13.42's own module as well as the upstream source. `libwebrtc.sprx` (sha256 `d59d0caf6967329b39201a2a0bd6df7b994516f21701b9801908db6735ae5314`), `lgJuzIdaeRU` at `0x3c64a0`, read from disassembly only, not measured on a console: ``` 3c64a1: mov ebx, [rsi+4] ; cmp ebx, 7 ; jbe 3c64b4 ; payload_size_bytes() < 8 -> log path 3c64a9: mov rsi, [rsi+8] ; call 0x3c65c0 ; ParseCommonFeedback(payload) 3c65c0: mov eax, [rsi] ; movbe [rdi+8], eax ; sender_ssrc_, big-endian 3c65c7: mov eax, [rsi+4] ; movbe [rdi+0xc], eax ; media_ssrc_ 3c64b4: call 0x36580 ; ... call 0x154060 (line 0x18a) ; the RTC_LOG(LS_WARNING) path 3c64de: cmp ebx, 8 ; setae al ; ret ``` This matches the PR: - `payloadSize` is at header+4 and `payload` at +8, as in `WebRtcRtcpCommonHeader`. - The two SSRCs go to +8 and +0xc, as in `WebRtcRtcpPli`. - A short payload returns false, leaves the packet untouched, and only logs. - The vtable is never written. Build and test on Windows (WinLibs GCC, `BUILD_TESTING=ON`), PR merged into current `main`: `guest_webrtc_rtcp_pli` passes. On `main` the export throws `not implemented`. One note, no change needed: the three `invalid_argument` throws for null arguments are host-side. The module dereferences `rsi` straight away, so the console faults there.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15092
No description provided.