feat(libwebrtc): implement rtcp::RtcpPacket::Build() #18507

Closed
alvaroelpob wants to merge 9 commits from upstream-pr/18507 into main
alvaroelpob commented 2026-11-11 19:15:51 +00:00 (Migrated from github.com)

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


What

Implements webrtc::rtcp::RtcpPacket::Build() const, which threw through NotImplemented_nid_no_patch.

As in rtcp_packet.cc, it makes an rtc::Buffer of BlockLength() bytes and asks the packet to Create itself at index 0 with that capacity and a null PacketReadyCallback. Both are virtual, so they are called through the packet's vtable, in RtcpPacket order (D1, D0, BlockLength, Create). The buffer follows buffer.h: size and capacity equal to the block length, and data from the guest new[], or null for an empty block. It is returned through the caller's return slot, because rtc::Buffer is not trivially copyable. In a release build upstream ignores Create's result and the written length (RTC_DCHECK only), and so does this. If Create throws, the buffer is freed before the exception continues.

Stacked on #17703, whose WebRtcBuffer already models rtc::Buffer; only the last commits belong to this pull request. rtcp_packet.cc and buffer.h are the same at M127 (e0b28a6a81a9) and M134 (8d78f5de6c27) apart from an out-of-class constexpr definition. The new src/RtcpPacket.cpp starts with its Derived from line and the WebRTC notice and licence.

Tested

Linux (WSL2, Ubuntu): full build and suite on 0704998db4 (stacked on #17703's head), 4678/4678 tests pass; check_conventions passes. The new guest_webrtc_rtcp_packet builds a fake packet through its vtable: a 12-byte block gives a buffer of size and capacity 12 that Create filled, with Create called at index 0, maximum 12 and a null callback; an empty block gives size 0, capacity 0 and null data; an exception from Create propagates.

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: #17698, #17703, #18495, #18498, #18503
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5265399999 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18507). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-11T19:15:51Z. --- ### What Implements `webrtc::rtcp::RtcpPacket::Build() const`, which threw through `NotImplemented_nid_no_patch`. As in [rtcp_packet.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet.cc), it makes an `rtc::Buffer` of `BlockLength()` bytes and asks the packet to `Create` itself at index 0 with that capacity and a null `PacketReadyCallback`. Both are virtual, so they are called through the packet's vtable, in `RtcpPacket` order (D1, D0, `BlockLength`, `Create`). The buffer follows [buffer.h](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/buffer.h): size and capacity equal to the block length, and data from the guest `new[]`, or null for an empty block. It is returned through the caller's return slot, because `rtc::Buffer` is not trivially copyable. In a release build upstream ignores `Create`'s result and the written length (`RTC_DCHECK` only), and so does this. If `Create` throws, the buffer is freed before the exception continues. Stacked on #17703, whose `WebRtcBuffer` already models `rtc::Buffer`; only the last commits belong to this pull request. `rtcp_packet.cc` and `buffer.h` are the same at M127 (e0b28a6a81a9) and M134 (8d78f5de6c27) apart from an out-of-class `constexpr` definition. The new `src/RtcpPacket.cpp` starts with its `Derived from` line and the WebRTC notice and licence. ### 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 0704998db4 (stacked on #17703's head), 4678/4678 tests pass; check_conventions passes. The new guest_webrtc_rtcp_packet builds a fake packet through its vtable: a 12-byte block gives a buffer of size and capacity 12 that Create filled, with Create called at index 0, maximum 12 and a null callback; an empty block gives size 0, capacity 0 and null data; an exception from Create propagates. ### 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: #17698, #17703, #18495, #18498, #18503 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

Pull request closed

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!18507
No description provided.