feat(libwebrtc): implement webrtc::rtcp::CommonHeader::Parse #13692

Merged
alvaroelpob merged 9 commits from upstream-pr/13692 into main 2026-10-31 20:40:01 +00:00
alvaroelpob commented 2026-10-31 00:07:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-31T00:07:32Z.


What

Implements webrtc::rtcp::CommonHeader::Parse(const uint8_t*, size_t) 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 by #13687. The parsing logic of modules/rtp_rtcp/source/rtcp_packet/common_header.cc is the same at M127 branch-heads/6533 and M134 branch-heads/6998, and common_header.h is identical. The only difference is that M134 drops the out-of-line constexpr definition of kHeaderSizeBytes.

The function is adapted from common_header.cc and lives in src/RtcpCommonHeader.cpp, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's LICENSE at the same revision. The debt entry says it is adapted from common_header.cc.

WebRtcRtcpCommonHeader is the 16-byte layout from common_header.h: packet_type_, count_or_format_ and padding_size_ as bytes at 0 to 2, payload_size_ as uint32_t at 4, and payload_ at 8. static_asserts check it. Parse takes this first and keeps upstream's order of checks:

  • If the buffer is shorter than 4 bytes, or the version is not 2, it returns false without touching the header.
  • Otherwise it stores the count or format, the type, the payload size (the length field × 4) and the payload pointer, and clears the padding.
  • It returns false if the buffer cannot hold the payload. With the padding bit set, it also returns false if the payload is empty, the last payload byte is 0, or that byte exceeds the payload. Otherwise it takes the padding off the payload size.

Each failure also writes an RTC_LOG(LS_WARNING) upstream. libwebrtc's logging is not implemented, so that is recorded as debt. Upstream reads a null header, and a null buffer of 4 bytes or more, so both throw. The inventory drops from 409 to 408.

Tested

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

  • New guest_webrtc_rtcp_common_header test, starting from headers filled with 0xA5:
    • Accepted packets: a receiver report (count 1, type 201, payload 28), a feedback header with format 31 and an empty payload, and padded packets of 3 and 8 bytes (payload 5 and 0).
    • Rejected with the header untouched: buffers of 3 bytes (also with a null buffer) and versions 0, 1 and 3.
    • Rejected with the fields already parsed: a payload larger than the buffer, padding with an empty payload, a padding byte of 0, and padding larger than the payload.
    • A null header, or a null 4-byte buffer, throws std::invalid_argument.
  • Full ctest -j16 on head 42087bf118: 3032/3032 pass. check_conventions.py --base upstream/main passes. pr_overlap.py reports no overlap with open pull requests.
  • Not tested: Windows, a title.

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:5092692782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13692). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-31T00:07:32Z. --- ### What Implements `webrtc::rtcp::CommonHeader::Parse(const uint8_t*, size_t)` 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 by #13687. The parsing logic of `modules/rtp_rtcp/source/rtcp_packet/common_header.cc` is the same at [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/modules/rtp_rtcp/source/rtcp_packet/common_header.cc) and [M134 branch-heads/6998](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/common_header.cc), and `common_header.h` is identical. The only difference is that M134 drops the out-of-line `constexpr` definition of `kHeaderSizeBytes`. The function is adapted from `common_header.cc` and lives in `src/RtcpCommonHeader.cpp`, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's `LICENSE` at the same revision. The debt entry says it is adapted from `common_header.cc`. `WebRtcRtcpCommonHeader` is the 16-byte layout from `common_header.h`: `packet_type_`, `count_or_format_` and `padding_size_` as bytes at 0 to 2, `payload_size_` as `uint32_t` at 4, and `payload_` at 8. `static_assert`s check it. `Parse` takes `this` first and keeps upstream's order of checks: - If the buffer is shorter than 4 bytes, or the version is not 2, it returns false without touching the header. - Otherwise it stores the count or format, the type, the payload size (the length field × 4) and the payload pointer, and clears the padding. - It returns false if the buffer cannot hold the payload. With the padding bit set, it also returns false if the payload is empty, the last payload byte is 0, or that byte exceeds the payload. Otherwise it takes the padding off the payload size. Each failure also writes an `RTC_LOG(LS_WARNING)` upstream. libwebrtc's logging is not implemented, so that is recorded as debt. Upstream reads a null header, and a null buffer of 4 bytes or more, so both throw. The inventory drops from 409 to 408. ### 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_common_header` test, starting from headers filled with 0xA5: - Accepted packets: a receiver report (count 1, type 201, payload 28), a feedback header with format 31 and an empty payload, and padded packets of 3 and 8 bytes (payload 5 and 0). - Rejected with the header untouched: buffers of 3 bytes (also with a null buffer) and versions 0, 1 and 3. - Rejected with the fields already parsed: a payload larger than the buffer, padding with an empty payload, a padding byte of 0, and padding larger than the payload. - A null header, or a null 4-byte buffer, throws `std::invalid_argument`. - Full `ctest -j16` on head 42087bf118: 3032/3032 pass. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports no overlap with open pull requests. - Not tested: Windows, a title. ### 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
MarcZX10 commented 2026-10-31 00:24:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T00:24:15Z.

Review: APPROVED


Reviewed — looks good

The RTCP header parser and its tests match the pinned WebRTC implementation for valid inputs; I found no blocking issue in this stacked head.

What I ran

Reviewed head 48d996ede902cf289624b5a9e158a8ae15d6ba09 against PR base f25279c0ca4cb068370df4baaa46de7b4f4741c7. The stack check previewed it cleanly against current main 93c71cc1bbe43b5e9e9d33fdded98e77efacbdba; the declared #13687 and #13689 heads are included. Environment: Debian Linux x86-64, Python 3.11.2; no project build or local C++ tests were run.

git diff --check f25279c0ca4cb068370df4baaa46de7b4f4741c7...48d996ede902cf289624b5a9e158a8ae15d6ba09
python3 tools/check_conventions.py --base f25279c0ca4cb068370df4baaa46de7b4f4741c7 --head 48d996ede902cf289624b5a9e158a8ae15d6ba09 --title 'feat(libwebrtc): implement webrtc::rtcp::CommonHeader::Parse' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13692-48d996ede902/pr-body.md
python3 tools/pr_abi_audit.py --base f25279c0ca4cb068370df4baaa46de7b4f4741c7 --head 48d996ede902cf289624b5a9e158a8ae15d6ba09 --json
git grep -n -E 'guest_webrtc_rtcp_common_header|RtcpCommonHeader.cpp' 48d996ede902cf289624b5a9e158a8ae15d6ba09 --
python3 tools/pr_stack_check.py 13692 --repo boykopovar/AnyPS5 --output-dir /tmp/pr13692-stack-final
gh pr checks 13692 --repo boykopovar/AnyPS5

Results

Check Result
Diff and conventions Passed.
Export audit passed_with_warnings; the four changed exports have matching declarations/definitions and no target-specific findings. Remaining alias warnings concern pre-existing libwebrtcUnknown* exports.
Test registration guest_webrtc_rtcp_common_header is registered in core/libs/prx/libwebrtc/CMakeLists.txt. I inspected the assertions for layout, short/invalid headers, payload sizing, padding, and failure-state mutation.
Stack/current-main preview Clean; dependency heads #13687 and #13689 are included in this head.
Hosted CI Windows, conventions, intake, labels, library-portability, eligibility, and report passed. Linux and specialized build jobs were skipped.
Focused C++ tests Not run locally because they require a build. The author reports full CTest passed 3032/3032 on this head; I did not reproduce that run.
Precheck helpers The isolated precheck checkout lacked the workspace-only ABI and test-quality scripts. I ran the ABI audit directly; the test-quality heuristic was unavailable, so I reviewed the changed assertions manually.
Unedited outputs
All conventions checks passed.
status: passed_with_warnings
_ZN3rtc9ExpFilter5ApplyEff_nid_postfix 6KIZ6hIOqDk ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] []
_ZN3rtc9ExpFilter5ResetEf_nid_postfix A8OVQ4wC21Y ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] []
_ZN4absl16numbers_internal15FastIntToBufferEiPc_nid_postfix +g8fWHAUVNQ ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] []
_ZN6webrtc4rtcp12CommonHeader5ParseEPKhm_nid_postfix 83HKwbPCn6E ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] []
findings: []
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:26:    add_test_executable(guest_webrtc_rtcp_common_header_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/RtcpCommonHeader.cpp)
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:27:    target_include_directories(guest_webrtc_rtcp_common_header_tests PRIVATE ${LIBS_INCLUDE_DIR})
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:28:    target_link_libraries(guest_webrtc_rtcp_common_header_tests PRIVATE libwebrtc libc)
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:29:    configure_windows_unwind(guest_webrtc_rtcp_common_header_tests)
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:30:    add_test(NAME guest_webrtc_rtcp_common_header COMMAND guest_webrtc_rtcp_common_header_tests)
48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:31:    set_tests_properties(guest_webrtc_rtcp_common_header PROPERTIES TIMEOUT 20)
# PR stack check — fresh

Target: https://github.com/boykopovar/AnyPS5/pull/13692
Target branch tip: `93c71cc1bbe43b5e9e9d33fdded98e77efacbdba`
All heads unchanged: **True**
Dependency order: #13687 → #13689 → #13692

## Individual merge previews

- PR #13687: **clean** against current base; head `314a8c5b492c364f6ce9d520e78dde41c2fa2a91`; changed paths: none reported
- PR #13689: **clean** against current base; head `8f63559455b61e103a370148dd46d2e469ae1fc8`; changed paths: none reported
- PR #13692: **clean** against current base; head `48d996ede902cf289624b5a9e158a8ae15d6ba09`; changed paths: none reported
conventions	pass	20s	https://github.com/boykopovar/AnyPS5/actions/runs/41148587902/job/124379430959
intake	pass	18s	https://github.com/boykopovar/AnyPS5/actions/runs/41148427036/job/124378906845
labels	pass	8s	https://github.com/boykopovar/AnyPS5/actions/runs/41148587845/job/124380273851
library-portability	pass	1m19s	https://github.com/boykopovar/AnyPS5/actions/runs/41148427341/job/124378906682
windows	pass	5m43s	https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124380158175
linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124379430959
relinker	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124380159732

Findings

Blocking

None found in the reviewed code and evidence.

Non-blocking

The PR description says upstream “throws” for null header/buffer inputs. The pinned upstream implementation does not define an exception for those invalid pointers; a null buffer with a size of at least four is dereferenced. The new std::invalid_argument checks are reasonable defensive behavior, but should be described as this implementation's behavior rather than upstream compatibility.

Sources

Not verified

No local build, C++ test execution, Linux hosted build, console test, or title test was performed. The full CTest result is author-reported.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720082337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13692#pullrequestreview-5720082337). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T00:24:15Z. **Review:** APPROVED --- # Reviewed — looks good The RTCP header parser and its tests match the pinned WebRTC implementation for valid inputs; I found no blocking issue in this stacked head. ## What I ran Reviewed head `48d996ede902cf289624b5a9e158a8ae15d6ba09` against PR base `f25279c0ca4cb068370df4baaa46de7b4f4741c7`. The stack check previewed it cleanly against current `main` `93c71cc1bbe43b5e9e9d33fdded98e77efacbdba`; the declared #13687 and #13689 heads are included. Environment: Debian Linux x86-64, Python 3.11.2; no project build or local C++ tests were run. ```sh git diff --check f25279c0ca4cb068370df4baaa46de7b4f4741c7...48d996ede902cf289624b5a9e158a8ae15d6ba09 python3 tools/check_conventions.py --base f25279c0ca4cb068370df4baaa46de7b4f4741c7 --head 48d996ede902cf289624b5a9e158a8ae15d6ba09 --title 'feat(libwebrtc): implement webrtc::rtcp::CommonHeader::Parse' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13692-48d996ede902/pr-body.md python3 tools/pr_abi_audit.py --base f25279c0ca4cb068370df4baaa46de7b4f4741c7 --head 48d996ede902cf289624b5a9e158a8ae15d6ba09 --json git grep -n -E 'guest_webrtc_rtcp_common_header|RtcpCommonHeader.cpp' 48d996ede902cf289624b5a9e158a8ae15d6ba09 -- python3 tools/pr_stack_check.py 13692 --repo boykopovar/AnyPS5 --output-dir /tmp/pr13692-stack-final gh pr checks 13692 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff and conventions | Passed. | | Export audit | `passed_with_warnings`; the four changed exports have matching declarations/definitions and no target-specific findings. Remaining alias warnings concern pre-existing `libwebrtcUnknown*` exports. | | Test registration | `guest_webrtc_rtcp_common_header` is registered in `core/libs/prx/libwebrtc/CMakeLists.txt`. I inspected the assertions for layout, short/invalid headers, payload sizing, padding, and failure-state mutation. | | Stack/current-main preview | Clean; dependency heads #13687 and #13689 are included in this head. | | Hosted CI | Windows, conventions, intake, labels, library-portability, eligibility, and report passed. Linux and specialized build jobs were skipped. | | Focused C++ tests | Not run locally because they require a build. The author reports full CTest passed 3032/3032 on this head; I did not reproduce that run. | | Precheck helpers | The isolated precheck checkout lacked the workspace-only ABI and test-quality scripts. I ran the ABI audit directly; the test-quality heuristic was unavailable, so I reviewed the changed assertions manually. | <details> <summary>Unedited outputs</summary> ```text All conventions checks passed. ``` ```text status: passed_with_warnings _ZN3rtc9ExpFilter5ApplyEff_nid_postfix 6KIZ6hIOqDk ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] [] _ZN3rtc9ExpFilter5ResetEf_nid_postfix A8OVQ4wC21Y ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] [] _ZN4absl16numbers_internal15FastIntToBufferEiPc_nid_postfix +g8fWHAUVNQ ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] [] _ZN6webrtc4rtcp12CommonHeader5ParseEPKhm_nid_postfix 83HKwbPCn6E ['core/libs/prx/libwebrtc/include/Api.hpp'] ['core/libs/prx/libwebrtc/Export.cpp'] [] findings: [] ``` ```text 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:26: add_test_executable(guest_webrtc_rtcp_common_header_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/RtcpCommonHeader.cpp) 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:27: target_include_directories(guest_webrtc_rtcp_common_header_tests PRIVATE ${LIBS_INCLUDE_DIR}) 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:28: target_link_libraries(guest_webrtc_rtcp_common_header_tests PRIVATE libwebrtc libc) 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:29: configure_windows_unwind(guest_webrtc_rtcp_common_header_tests) 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:30: add_test(NAME guest_webrtc_rtcp_common_header COMMAND guest_webrtc_rtcp_common_header_tests) 48d996ede902cf289624b5a9e158a8ae15d6ba09:core/libs/prx/libwebrtc/CMakeLists.txt:31: set_tests_properties(guest_webrtc_rtcp_common_header PROPERTIES TIMEOUT 20) ``` ```text # PR stack check — fresh Target: https://github.com/boykopovar/AnyPS5/pull/13692 Target branch tip: `93c71cc1bbe43b5e9e9d33fdded98e77efacbdba` All heads unchanged: **True** Dependency order: #13687 → #13689 → #13692 ## Individual merge previews - PR #13687: **clean** against current base; head `314a8c5b492c364f6ce9d520e78dde41c2fa2a91`; changed paths: none reported - PR #13689: **clean** against current base; head `8f63559455b61e103a370148dd46d2e469ae1fc8`; changed paths: none reported - PR #13692: **clean** against current base; head `48d996ede902cf289624b5a9e158a8ae15d6ba09`; changed paths: none reported ``` ```text conventions pass 20s https://github.com/boykopovar/AnyPS5/actions/runs/41148587902/job/124379430959 intake pass 18s https://github.com/boykopovar/AnyPS5/actions/runs/41148427036/job/124378906845 labels pass 8s https://github.com/boykopovar/AnyPS5/actions/runs/41148587845/job/124380273851 library-portability pass 1m19s https://github.com/boykopovar/AnyPS5/actions/runs/41148427341/job/124378906682 windows pass 5m43s https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124380158175 linux skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124379430959 relinker skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41148427178/job/124380159732 ``` </details> ## Findings ### Blocking None found in the reviewed code and evidence. ### Non-blocking The PR description says upstream “throws” for null header/buffer inputs. The pinned upstream implementation does not define an exception for those invalid pointers; a null buffer with a size of at least four is dereferenced. The new `std::invalid_argument` checks are reasonable defensive behavior, but should be described as this implementation's behavior rather than upstream compatibility. ## Sources - [Parser implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/48d996ede902cf289624b5a9e158a8ae15d6ba09/core/libs/prx/libwebrtc/Export.cpp#L1155-L1178) - [Parser state layout at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/48d996ede902cf289624b5a9e158a8ae15d6ba09/core/libs/prx/libwebrtc/include/RtcpCommonHeader.hpp) - [Pinned WebRTC M134 parser source](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/common_header.cc) - [Pinned WebRTC M134 header layout](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/rtp_rtcp/source/rtcp_packet/common_header.h) ## Not verified No local build, C++ test execution, Linux hosted build, console test, or title test was performed. The full CTest result is author-reported.
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!13692
No description provided.