feat(libwebrtc): implement webrtc::rtcp::App::Parse and its destructor #17698

Merged
LeandroLP23 merged 3 commits from upstream-pr/17698 into main 2026-11-12 04:51:47 +00:00
LeandroLP23 commented 2026-11-09 10:35:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-09T10:35:10Z.


What

Implements webrtc::rtcp::App::Parse and the App destructor in libwebrtc, adapted from app.cc and BufferT::SetData in buffer.h. Like Pli::Parse, the WebRTC notice and BSD licence are at the top of the file.

  • Same code at both bounding revisions. app.h, rtcp_packet.h and buffer.h are byte-identical at M127 (e0b28a6a81) and M134 (8d78f5de6c). app.cc differs only by two redundant out-of-class constexpr definitions.
  • Layout: 48 bytes, from app.h on top of RtcpPacket. The vtable pointer is at 0, sender_ssrc_ at 8, sub_type_ at 12 and name_ at 16. The rtc::Buffer size, capacity and data pointer are at 24, 32 and 40.
  • Parse:
    • Rejects a payload shorter than 8 bytes or not a multiple of 4 and leaves the packet untouched.
    • Otherwise takes the sub-type from the header format, reads the SSRC and name big-endian, and copies the rest into the buffer.
    • The buffer grows through the guest operator new[] to the larger of the data size and 1.5 times its capacity, and frees the old block through operator delete[]. #16485 does the same for CopyOnWriteBuffer.
  • Destructor: frees the data block through operator delete[].
  • Not done:
    • The RTC_LOG(LS_WARNING) messages are not emitted, and the packet type that upstream only RTC_DCHECKs is not checked.
    • A null packet, header, or payload of 8 bytes or more throws.

rtc::Buffer is modelled in include/Buffer.hpp, byte-identical to the file #17703 adds, so the two merge cleanly in either order.

The App constructor still throws: it would have to install an App vtable, and the module defines none. Until that exists no title reaches these two exports, as with Pli::Parse. The debt entry says so.

Nack::Parse was the obvious companion but is left out. It fills two guest std::vectors, and the repository has no measured layout for the console's std::vector. The console's std::string carries an extra leading word, so the vector layout cannot be assumed.

Tested

Windows 11, MinGW GCC Release build. guest_webrtc_rtcp_app is new; guest_webrtc_rtcp_pli and guest_webrtc_rtp_extension still pass. The new test covers:

  • Parsing through CommonHeader::Parse.
  • The buffer's growth sequence 8 → 12 → 18 capacity, with the old block freed each time.
  • Reuse without allocation when the data fits, and an empty data block that keeps the buffer.
  • Short and unaligned payloads that leave the packet untouched, a destructor with no data, and null arguments.

As a negative control, removing the 1.5× headroom fails the test at the capacity-18 check.

tools/check_conventions.py --base origin/main passes.

tools/pr_overlap.py --branch could not merge #14212, #15189 and #17691, so I compared them by hand:

  • #14212 only respaces the debt file.
  • #15189 adds ColorSpace to the same files but touches none of these exports.
  • #17691 deletes 7,279 files, the whole tree.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5222490297 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17698). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-09T10:35:10Z. --- ### What Implements `webrtc::rtcp::App::Parse` and the `App` destructor in libwebrtc, adapted from [app.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/app.cc) and `BufferT::SetData` in [buffer.h](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/buffer.h). Like `Pli::Parse`, the WebRTC notice and BSD licence are at the top of the file. - **Same code at both bounding revisions.** `app.h`, `rtcp_packet.h` and `buffer.h` are byte-identical at M127 ([e0b28a6a81](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d)) and M134 ([8d78f5de6c](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100)). `app.cc` differs only by two redundant out-of-class `constexpr` definitions. - **Layout:** 48 bytes, from `app.h` on top of `RtcpPacket`. The vtable pointer is at 0, `sender_ssrc_` at 8, `sub_type_` at 12 and `name_` at 16. The `rtc::Buffer` size, capacity and data pointer are at 24, 32 and 40. - **Parse:** - Rejects a payload shorter than 8 bytes or not a multiple of 4 and leaves the packet untouched. - Otherwise takes the sub-type from the header format, reads the SSRC and name big-endian, and copies the rest into the buffer. - The buffer grows through the guest `operator new[]` to the larger of the data size and 1.5 times its capacity, and frees the old block through `operator delete[]`. #16485 does the same for `CopyOnWriteBuffer`. - **Destructor:** frees the data block through `operator delete[]`. - **Not done:** - The `RTC_LOG(LS_WARNING)` messages are not emitted, and the packet type that upstream only `RTC_DCHECK`s is not checked. - A null packet, header, or payload of 8 bytes or more throws. `rtc::Buffer` is modelled in `include/Buffer.hpp`, byte-identical to the file #17703 adds, so the two merge cleanly in either order. The `App` constructor still throws: it would have to install an `App` vtable, and the module defines none. Until that exists no title reaches these two exports, as with `Pli::Parse`. The debt entry says so. `Nack::Parse` was the obvious companion but is left out. It fills two guest `std::vector`s, and the repository has no measured layout for the console's `std::vector`. The console's `std::string` carries an extra leading word, so the vector layout cannot be assumed. ### Tested Windows 11, MinGW GCC Release build. `guest_webrtc_rtcp_app` is new; `guest_webrtc_rtcp_pli` and `guest_webrtc_rtp_extension` still pass. The new test covers: - Parsing through `CommonHeader::Parse`. - The buffer's growth sequence 8 → 12 → 18 capacity, with the old block freed each time. - Reuse without allocation when the data fits, and an empty data block that keeps the buffer. - Short and unaligned payloads that leave the packet untouched, a destructor with no data, and null arguments. As a negative control, removing the 1.5× headroom fails the test at the capacity-18 check. `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py --branch` could not merge #14212, #15189 and #17691, so I compared them by hand: - #14212 only respaces the debt file. - #15189 adds ColorSpace to the same files but touches none of these exports. - #17691 deletes 7,279 files, the whole tree. ### 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 (Claude Code)
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!17698
No description provided.