feat(libwebrtc): implement rtcp::Pli::Pli() #18503

Open
alvaroelpob wants to merge 9 commits from upstream-pr/18503 into main
alvaroelpob commented 2026-11-11 19:06:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-11T19:06:43Z.


What

Implements webrtc::rtcp::Pli::Pli(), which threw through NotImplemented_nid_no_patch.

pli.cc defaults the constructor, so sender_ssrc_ (rtcp_packet.h) and media_ssrc_ (psfb.h) start at 0 and the object gets Pli's vtable. BlockLength and Create are not exported but a guest reaches them through that vtable (for example through RtcpPacket::Build), so the object gets a local vtable in RtcpPacket order: D1 (the existing export), D0, BlockLength and Create, as rtc::RateTracker does.

  • BlockLength returns 12: the 4-byte header plus the 8-byte common feedback.
  • Create follows Pli::Create, RtcpPacket::OnBufferFull, RtcpPacket::CreateHeader and Psfb::CreateCommonFeedback: while the packet does not fit it flushes through the PacketReadyCallback or fails when nothing is buffered, then writes the header (version 2, format 1, type 206, length in words from BlockLength) and both SSRCs big-endian. BlockLength is called through the object's vtable as upstream does, so a derived class's override is used.
  • The rtc::FunctionView callback is passed as its two pointers (the callable and call_), and call_ receives the ArrayView as data and size. A flush without a callback throws, where upstream only RTC_DCHECKs it.

These files are the same at M127 (e0b28a6a81a9) and M134 (8d78f5de6c27) apart from out-of-class constexpr definitions and a comment in function_view.h. src/RtcpPli.cpp now carries one Derived from line per source file and the 2014 notice of rtcp_packet.cc next to the 2015 one.

Tested

Linux (WSL2, Ubuntu): full build and suite on c027347e69, 4925/4925 tests pass; check_conventions passes. guest_webrtc_rtcp_pli now constructs a Pli over 0xA5 bytes and calls the vtable slots: BlockLength returns 12; Create writes 81 CE 00 02 and both SSRCs big-endian, fails without touching the index when nothing is buffered and 11 bytes are left, flushes 4 buffered bytes through the FunctionView callback before writing, and uses a fake subclass's BlockLength of 16 (length field 3); the deleting destructor frees a guest-allocated Pli.

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: #18495, #18498
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5265279596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18503). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-11T19:06:43Z. --- ### What Implements `webrtc::rtcp::Pli::Pli()`, which threw through `NotImplemented_nid_no_patch`. [pli.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/pli.cc) defaults the constructor, so `sender_ssrc_` ([rtcp_packet.h](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet.h)) and `media_ssrc_` ([psfb.h](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/psfb.h)) start at 0 and the object gets `Pli`'s vtable. `BlockLength` and `Create` are not exported but a guest reaches them through that vtable (for example through `RtcpPacket::Build`), so the object gets a local vtable in `RtcpPacket` order: D1 (the existing export), D0, `BlockLength` and `Create`, as `rtc::RateTracker` does. - `BlockLength` returns 12: the 4-byte header plus the 8-byte common feedback. - `Create` follows `Pli::Create`, `RtcpPacket::OnBufferFull`, `RtcpPacket::CreateHeader` and `Psfb::CreateCommonFeedback`: while the packet does not fit it flushes through the `PacketReadyCallback` or fails when nothing is buffered, then writes the header (version 2, format 1, type 206, length in words from `BlockLength`) and both SSRCs big-endian. `BlockLength` is called through the object's vtable as upstream does, so a derived class's override is used. - The `rtc::FunctionView` callback is passed as its two pointers (the callable and `call_`), and `call_` receives the `ArrayView` as data and size. A flush without a callback throws, where upstream only `RTC_DCHECK`s it. These files are the same at M127 (e0b28a6a81a9) and M134 (8d78f5de6c27) apart from out-of-class `constexpr` definitions and a comment in `function_view.h`. `src/RtcpPli.cpp` now carries one `Derived from` line per source file and the 2014 notice of `rtcp_packet.cc` next to the 2015 one. ### 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. --> Linux (WSL2, Ubuntu): full build and suite on c027347e69, 4925/4925 tests pass; check_conventions passes. guest_webrtc_rtcp_pli now constructs a Pli over 0xA5 bytes and calls the vtable slots: BlockLength returns 12; Create writes 81 CE 00 02 and both SSRCs big-endian, fails without touching the index when nothing is buffered and 11 bytes are left, flushes 4 buffered bytes through the FunctionView callback before writing, and uses a fake subclass's BlockLength of 16 (length field 3); the deleting destructor frees a guest-allocated Pli. ### 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: #18495, #18498 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-12 14:28:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:28:24Z.

Review: COMMENTED


Reviewed — no blocking findings

The diff implements rtcp::Pli::Pli(), BlockLength and Create with vtable slots that match the test, and I found no blocking defect in the code I read.

What I ran

  • Head: c027347e69571b40366c410d8978bc82b742413f (base main). No merged-preview check.
  • Read-only review: the changed hunks in diff.patch, plus repository reads at head through the reader.
  • Reader calls: searches for PliC1Ev, _Znwm_nid_postfix, _ZdlPv_nid_postfix, ApplicationHeapInitialize_nid_no_patch and Filled; RtcpPli.cpp lines 60–135; RtcpPli.hpp lines 1–22; test file lines 1–12.
  • No build and no test run were done in this review.

Results

Check Result Note
Full build and test suite not run Author reports 4925/4925 on WSL2
check_conventions not run Author reports pass
Vtable slots against the test passed Read only; slots 1–3 agree
Declaration and definition of the constructor passed Api.hpp:274 matches RtcpPli.cpp:130

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libwebrtc/src/RtcpPli.cpp:106 — Create writes 12 bytes (:106–:109) but only checks that VirtualBlockLength(pli) fits. If a vtable's BlockLength returns less than 12, for example 4, the writes can run up to 8 bytes past maxLength. A guard that throws or returns false when the block length is under 12 would close this. No test covers a BlockLength below 12. Upstream Pli never returns less, so this needs a hostile override to trigger.

Not verified

  • Build, test suite and check_conventions: not run here; author-reported only.
  • The "Derived from" lines and the 2014 notice of rtcp_packet.cc in RtcpPli.cpp:1–13: not compared with upstream.
  • The rtc::FunctionView ABI (two pointers, ArrayView as data and size): not checked on a console or against the toolchain.
  • Full text of the changed files outside the hunks: only the ranges listed under What I ran were read. The test file was read through its hunks and lines 1–12, and Export.cpp, Api.hpp and docs/dev/debt/libwebrtc.md through their hunks only.
  • Debt count 256 → 255 in docs/dev/debt/libwebrtc.md:278: consistent with the removed stub, not checked against the export table.

To get this to a good state

  • Optional: add the block-length guard in Create and a test with BlockLength returning 4.
  • Re-run the full suite and check_conventions on the new head if the code changes.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876135190 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18503#pullrequestreview-5876135190). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T14:28:24Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The diff implements `rtcp::Pli::Pli()`, `BlockLength` and `Create` with vtable slots that match the test, and I found no blocking defect in the code I read. **What I ran** - Head: `c027347e69571b40366c410d8978bc82b742413f` (base `main`). No merged-preview check. - Read-only review: the changed hunks in `diff.patch`, plus repository reads at head through the reader. - Reader calls: searches for `PliC1Ev`, `_Znwm_nid_postfix`, `_ZdlPv_nid_postfix`, `ApplicationHeapInitialize_nid_no_patch` and `Filled`; `RtcpPli.cpp` lines 60–135; `RtcpPli.hpp` lines 1–22; test file lines 1–12. - No build and no test run were done in this review. **Results** | Check | Result | Note | | --- | --- | --- | | Full build and test suite | not run | Author reports 4925/4925 on WSL2 | | `check_conventions` | not run | Author reports pass | | Vtable slots against the test | passed | Read only; slots 1–3 agree | | Declaration and definition of the constructor | passed | `Api.hpp:274` matches `RtcpPli.cpp:130` | **Findings** **Blocking** None. **Non-blocking** - `core/libs/prx/libwebrtc/src/RtcpPli.cpp:106` — `Create` writes 12 bytes (`:106`–`:109`) but only checks that `VirtualBlockLength(pli)` fits. If a vtable's `BlockLength` returns less than 12, for example 4, the writes can run up to 8 bytes past `maxLength`. A guard that throws or returns `false` when the block length is under 12 would close this. No test covers a `BlockLength` below 12. Upstream `Pli` never returns less, so this needs a hostile override to trigger. **Not verified** - Build, test suite and `check_conventions`: not run here; author-reported only. - The "Derived from" lines and the 2014 notice of `rtcp_packet.cc` in `RtcpPli.cpp:1–13`: not compared with upstream. - The `rtc::FunctionView` ABI (two pointers, `ArrayView` as data and size): not checked on a console or against the toolchain. - Full text of the changed files outside the hunks: only the ranges listed under What I ran were read. The test file was read through its hunks and lines 1–12, and `Export.cpp`, `Api.hpp` and `docs/dev/debt/libwebrtc.md` through their hunks only. - Debt count `256` → `255` in `docs/dev/debt/libwebrtc.md:278`: consistent with the removed stub, not checked against the export table. **To get this to a good state** - Optional: add the block-length guard in `Create` and a test with `BlockLength` returning 4. - Re-run the full suite and `check_conventions` on the new head if the code changes.
MarcZX10 commented 2026-11-21 08:45:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T08:45:53Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation and focused tests are consistent with the stated PLI constructor and packet creation behavior at head 792ef6f902e395625a73059dade03f67ed6c05b9; programmatic checks were not run in this review.

What I ran

Read the prepared diff and targeted source context. No commands or tests were run. The description reports a full build and suite on a different revision (c027347e69); that result was not independently verified.

Results

Check Result Note
Diff and source review passed Focused code paths inspected
Build and test suite not run Reported run is on another revision

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run on this head, and console behavior remains unverified as documented in the PR. Read the changed files Export.cpp, Api.hpp, RtcpPli.hpp, src/RtcpPli.cpp, tests/RtcpPli.cpp, and docs/dev/debt/libwebrtc.md; targeted portions of Export.cpp and Api.hpp were inspected. No files were excluded by the prepared manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004223267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18503#pullrequestreview-6004223267). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T08:45:53Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation and focused tests are consistent with the stated PLI constructor and packet creation behavior at head `792ef6f902e395625a73059dade03f67ed6c05b9`; programmatic checks were not run in this review. ## What I ran Read the prepared diff and targeted source context. No commands or tests were run. The description reports a full build and suite on a different revision (`c027347e69`); that result was not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | Focused code paths inspected | | Build and test suite | not run | Reported run is on another revision | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests were run on this head, and console behavior remains unverified as documented in the PR. Read the changed files `Export.cpp`, `Api.hpp`, `RtcpPli.hpp`, `src/RtcpPli.cpp`, `tests/RtcpPli.cpp`, and `docs/dev/debt/libwebrtc.md`; targeted portions of `Export.cpp` and `Api.hpp` were inspected. No files were excluded by the prepared manifest. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 13:02:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:02:16Z.

Review: COMMENTED


Built the changed sources and ran RtcpPli on Linux against the existing runtime. It passed the vtable, serialized packet, and short-buffer checks.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170318470 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18503#pullrequestreview-6170318470). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:02:16Z. **Review:** COMMENTED --- Built the changed sources and ran `RtcpPli` on Linux against the existing runtime. It passed the vtable, serialized packet, and short-buffer checks. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/18503:upstream-pr/18503'
git switch 'upstream-pr/18503'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/18503'
git switch 'upstream-pr/18503'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/18503'
git switch 'upstream-pr/18503'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/18503'
git switch 'main'
git merge --squash 'upstream-pr/18503'
git switch 'main'
git merge --ff-only 'upstream-pr/18503'
git switch 'main'
git merge 'upstream-pr/18503'
git push origin 'main'
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!18503
No description provided.