feat(libwebrtc): implement the CodecSpecificInfo constructor and destructor #20031

Merged
Krille2004zzz merged 2 commits from upstream-pr/20031 into main 2026-11-14 15:43:11 +00:00
Krille2004zzz commented 2026-11-14 12:33:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Krille2004zzz on 2026-11-14T12:33:06Z.


What

Implements webrtc::CodecSpecificInfo::CodecSpecificInfo() (_ZN6webrtc17CodecSpecificInfoC1Ev) and ~CodecSpecificInfo() (_ZN6webrtc17CodecSpecificInfoD1Ev), replacing their NotImplemented stubs.

  • The constructor follows video_codec_interface.cc: codecType = kVideoCodecGeneric, the codec-specific union zeroed, end_of_picture = true, all optionals disengaged.
  • The defaulted destructor releases what the engaged optionals own through guest scalar delete: heap-allocated absl::InlinedVector storage in GenericFrameInfo / FrameDependencyStructure (including every template), part_of_chain, the templates vector, and FrameInstrumentationData::sample_values. Malformed sample_values and template vectors, unknown variant indexes and null objects throw before anything is freed. part_of_chain and heap-allocated InlinedVector storage are freed as they are, without extra validation, as upstream's defaulted destructor does.
  • Layout follows M134, not M127: frame_instrumentation_data was added in M130, and the module exports BuiltinAudioProcessingBuilder, which first appears in M132; all headers involved are identical between M132 and M134. Clang 19 + libc++ probes of the real headers give 2064 bytes (union at 8, end_of_picture at 1632, optionals at 1640/1856/1992/2000, 4-byte variant index at 2048), and a cross-check reading real libc++ objects through the new structs matched every field.

docs/dev/debt/libwebrtc.md lists what is unverified: libc++ as the module's standard library, absl::variant as std::variant, the allocator, and the console behaviour.

Tested

Linux (Debian trixie, GCC 14.2), build with BUILD_TESTING=ON. Not tested on a console, a title or Windows.

  • New tests in core/libs/prx/libwebrtc/tests/CodecSpecificInfo.cpp cover the default state, a destructor that frees every owned allocation and leaves inline storage alone, sync and valueless variants, malformed vectors and variant indexes, and null objects.
  • ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Cc]odec|public_headers|export_gap|conventions|progress_report|test_registration|debt': 249/249 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • tools/pr_overlap.py reports no open PR with these exports.

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:5311268234 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20031). Originally posted by [Krille2004zzz](https://github.com/Krille2004zzz) on 2026-11-14T12:33:06Z. --- ### What Implements `webrtc::CodecSpecificInfo::CodecSpecificInfo()` (`_ZN6webrtc17CodecSpecificInfoC1Ev`) and `~CodecSpecificInfo()` (`_ZN6webrtc17CodecSpecificInfoD1Ev`), replacing their `NotImplemented` stubs. - The constructor follows [video_codec_interface.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/video_coding/include/video_codec_interface.cc): `codecType = kVideoCodecGeneric`, the codec-specific union zeroed, `end_of_picture = true`, all optionals disengaged. - The defaulted destructor releases what the engaged optionals own through guest scalar delete: heap-allocated `absl::InlinedVector` storage in `GenericFrameInfo` / `FrameDependencyStructure` (including every template), `part_of_chain`, the templates vector, and `FrameInstrumentationData::sample_values`. Malformed `sample_values` and template vectors, unknown variant indexes and null objects throw before anything is freed. `part_of_chain` and heap-allocated `InlinedVector` storage are freed as they are, without extra validation, as upstream's defaulted destructor does. - Layout follows M134, not M127: `frame_instrumentation_data` was added in M130, and the module exports `BuiltinAudioProcessingBuilder`, which first appears in M132; all headers involved are identical between M132 and M134. Clang 19 + libc++ probes of the real headers give 2064 bytes (union at 8, `end_of_picture` at 1632, optionals at 1640/1856/1992/2000, 4-byte variant index at 2048), and a cross-check reading real libc++ objects through the new structs matched every field. `docs/dev/debt/libwebrtc.md` lists what is unverified: libc++ as the module's standard library, `absl::variant` as `std::variant`, the allocator, and the console behaviour. ### Tested Linux (Debian trixie, GCC 14.2), build with `BUILD_TESTING=ON`. Not tested on a console, a title or Windows. - New tests in `core/libs/prx/libwebrtc/tests/CodecSpecificInfo.cpp` cover the default state, a destructor that frees every owned allocation and leaves inline storage alone, sync and valueless variants, malformed vectors and variant indexes, and null objects. - `ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Cc]odec|public_headers|export_gap|conventions|progress_report|test_registration|debt'`: 249/249 passed. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - `tools/pr_overlap.py` reports no open PR with these exports. ### 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
PrivacyOnion commented 2026-11-14 13:11:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T13:11:13Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 6e7b4bbd8e:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_codec_specific_info_tests built cleanly.
  • CTest (guest_webrtc_codec_specific_info_default, guest_webrtc_codec_specific_info_destructor):
    1/2 Test #5086: guest_webrtc_codec_specific_info_default ......   Passed    0.01 sec
    2/2 Test #5087: guest_webrtc_codec_specific_info_destructor ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified in core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp that both _ZN6webrtc17CodecSpecificInfoC1Ev_nid_postfix and _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix check info for nullptr and throw std::invalid_argument before dereferencing.
    • Validated vector pointer bounds and alignment checks in Count (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:59-67), verifying that begin/end/capacity ordering, nullability combinations, and element stride divisibility are enforced without underflow or overflow.
    • Confirmed exception safety in _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:117-128), verifying that HoldsData and template Count validate the variant index and vector pointers before any memory is deallocated with _ZdlPv_nid_postfix.
    • Verified data structure layout and cross-platform type definitions in core/libs/prx/libwebrtc/include/CodecSpecificInfo.hpp:81-130, ensuring static assertions guarantee identical 2064-byte size and field offsets across Linux (LP64) and Windows (LLP64).
    • Audited variant handling in HoldsData (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:92-100), ensuring WebRtcFrameInstrumentationSyncIndex (0) and WebRtcFrameInstrumentationValueless (0xffffffffu) do not trigger invalid sample value dereferences or frees.
    • Verified test coverage in core/libs/prx/libwebrtc/tests/CodecSpecificInfo.cpp and CMakeLists.txt:148-160, confirming tests exercise default state, 8 distinct heap frees during destruction, invalid variant indexes, malformed vector pointers, and null inputs.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904474671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20031#pullrequestreview-5904474671). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T13:11:13Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `6e7b4bbd8e`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_codec_specific_info_tests` built cleanly. - **CTest** (`guest_webrtc_codec_specific_info_default`, `guest_webrtc_codec_specific_info_destructor`): ``` 1/2 Test #5086: guest_webrtc_codec_specific_info_default ...... Passed 0.01 sec 2/2 Test #5087: guest_webrtc_codec_specific_info_destructor ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified in core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp that both _ZN6webrtc17CodecSpecificInfoC1Ev_nid_postfix and _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix check info for nullptr and throw std::invalid_argument before dereferencing. - Validated vector pointer bounds and alignment checks in Count (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:59-67), verifying that begin/end/capacity ordering, nullability combinations, and element stride divisibility are enforced without underflow or overflow. - Confirmed exception safety in _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:117-128), verifying that HoldsData and template Count validate the variant index and vector pointers before any memory is deallocated with _ZdlPv_nid_postfix. - Verified data structure layout and cross-platform type definitions in core/libs/prx/libwebrtc/include/CodecSpecificInfo.hpp:81-130, ensuring static assertions guarantee identical 2064-byte size and field offsets across Linux (LP64) and Windows (LLP64). - Audited variant handling in HoldsData (core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:92-100), ensuring WebRtcFrameInstrumentationSyncIndex (0) and WebRtcFrameInstrumentationValueless (0xffffffffu) do not trigger invalid sample value dereferences or frees. - Verified test coverage in core/libs/prx/libwebrtc/tests/CodecSpecificInfo.cpp and CMakeLists.txt:148-160, confirming tests exercise default state, 8 distinct heap frees during destruction, invalid variant indexes, malformed vector pointers, and null inputs. - Note: the AI-assisted checkbox can stay. Looks Good To Me
MarcZX10 commented 2026-11-14 14:29:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T14:29:43Z.

Review: COMMENTED


Reviewed — comments

The implementation and tests are readable, but the malformed-vector claim is broader than the destructor checks, and I could not run the reported checks.

What I ran

Reviewed head 6e7b4bbd8e617036d967328992225abce84974be using the review reader. No build or test commands were run. Read all seven changed files listed as included; no changed files were excluded.

Results

Check Result Note
Source review passed All seven changed files read
Build and tests not run Description reports author-run checks
Console behavior not run ABI and allocator assumptions remain unverified

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:76 frees partOfChain.begin without validating its size/capacity, and :53 frees an inlined vector allocation based only on the metadata bit. The description says malformed vectors throw before anything is freed, but the tests only exercise malformed sample and template pointer ranges. Please validate these vector representations before freeing, or narrow the documented claim and add tests for malformed partOfChain and inlined-vector state.

Sources

Not verified

The reported Debian build, 249 CTest checks, convention check, and overlap check were author-reported and not run during this review. Console ABI, allocator behavior, and console execution remain unverified as the description notes.

To get this to a good state

Nothing is required. Optionally validate or clarify the malformed-vector behavior and add the corresponding edge-case tests.

Continued review (pass 2)

The three specified added lines and their surrounding context were read at head 6e7b4bbd8e617036d967328992225abce84974be; they introduce no additional issue.

What I ran

Read the prepared description, commit list, diff, manifest, and the specified source lines with repo_read.py. No tests or build commands were run in this continuation pass.

Results

Check Result Note
Specified added lines passed All three requested lines and surrounding context read
Tests/build not run Continuation pass only

Findings

Blocking

None in the specified lines.

Non-blocking

None in the specified lines.

Not verified

This continuation pass covers only core/libs/prx/libwebrtc/CMakeLists.txt:11, core/libs/prx/libwebrtc/include/Api.hpp:9, and docs/dev/debt/libwebrtc.md:5. The rest of the changed lines and prior-pass findings are outside this pass. The reviewed source files were not excluded; other repository files were not read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904936483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20031#pullrequestreview-5904936483). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T14:29:43Z. **Review:** COMMENTED --- # Reviewed — comments The implementation and tests are readable, but the malformed-vector claim is broader than the destructor checks, and I could not run the reported checks. ## What I ran Reviewed head `6e7b4bbd8e617036d967328992225abce84974be` using the review reader. No build or test commands were run. Read all seven changed files listed as included; no changed files were excluded. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | All seven changed files read | | Build and tests | not run | Description reports author-run checks | | Console behavior | not run | ABI and allocator assumptions remain unverified | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp:76` frees `partOfChain.begin` without validating its size/capacity, and `:53` frees an inlined vector allocation based only on the metadata bit. The description says malformed vectors throw before anything is freed, but the tests only exercise malformed sample and template pointer ranges. Please validate these vector representations before freeing, or narrow the documented claim and add tests for malformed `partOfChain` and inlined-vector state. ## Sources - [Destructor implementation at the reviewed commit](https://github.com/boykopovar/AnyPS5/blob/6e7b4bbd8e617036d967328992225abce84974be/core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp#L53-L89) - [Destructor tests at the reviewed commit](https://github.com/boykopovar/AnyPS5/blob/6e7b4bbd8e617036d967328992225abce84974be/core/libs/prx/libwebrtc/tests/CodecSpecificInfo.cpp#L146-L165) ## Not verified The reported Debian build, 249 CTest checks, convention check, and overlap check were author-reported and not run during this review. Console ABI, allocator behavior, and console execution remain unverified as the description notes. ## To get this to a good state Nothing is required. Optionally validate or clarify the malformed-vector behavior and add the corresponding edge-case tests. ## Continued review (pass 2) The three specified added lines and their surrounding context were read at head `6e7b4bbd8e617036d967328992225abce84974be`; they introduce no additional issue. ## What I ran Read the prepared description, commit list, diff, manifest, and the specified source lines with `repo_read.py`. No tests or build commands were run in this continuation pass. ## Results | Check | Result | Note | |---|---|---| | Specified added lines | passed | All three requested lines and surrounding context read | | Tests/build | not run | Continuation pass only | ## Findings ### Blocking None in the specified lines. ### Non-blocking None in the specified lines. ## Not verified This continuation pass covers only `core/libs/prx/libwebrtc/CMakeLists.txt:11`, `core/libs/prx/libwebrtc/include/Api.hpp:9`, and `docs/dev/debt/libwebrtc.md:5`. The rest of the changed lines and prior-pass findings are outside this pass. The reviewed source files were not excluded; other repository files were not read. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-14 15:34:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T15:34:05Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 09ac0c32bb:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_codec_specific_info_tests built cleanly.
  • CTest (guest_webrtc_codec_specific_info_default, guest_webrtc_codec_specific_info_destructor):
    1/2 Test #5094: guest_webrtc_codec_specific_info_default ......   Passed    0.01 sec
    2/2 Test #5095: guest_webrtc_codec_specific_info_destructor ...   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified _ZN6webrtc17CodecSpecificInfoC1Ev_nid_postfix and _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix enforce null pointer checks on info, throwing std::invalid_argument before any field access or deallocation.
    • core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified Count validates vector pointer triples (begin, end, capacity) for alignment (first % alignof(TValue)), ordering (last < first, limit < last), divisibility (sizeof(TValue)), and null consistency (!first && limit), ensuring malformed templates and sample vectors throw std::invalid_argument before freeing resources.
    • core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified HoldsData and destructor logic correctly discriminate WebRtcFrameInstrumentationVariant active members by index (WebRtcFrameInstrumentationSyncIndex, WebRtcFrameInstrumentationDataIndex, and WebRtcFrameInstrumentationValueless), freeing sampleValuesBegin with _ZdlPv_nid_postfix only for engaged data variants while throwing on unknown indexes.
    • core/libs/prx/libwebrtc/include/CodecSpecificInfo.hpp: verified ABI layout, sizes, and offsets match WebRTC M134 with libc++ via static asserts (sizeof(WebRtcCodecSpecificInfo) == 2064, 8-byte alignment, union size 1624, optionals at offsets 1640, 1856, 1992, and 2000).
    • core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified recursive release of WebRtcGenericFrameInfo and WebRtcFrameDependencyStructure properly deallocates heap-allocated InlinedVector storage based on metadata bit 0, frees partOfChain.begin, and destroys template array elements up to count before freeing the template buffer.
    • docs/dev/debt/libwebrtc.md & AGENTS.md: verified no forbidden comments in code, export count decremented (221 to 219), unverified console ABI assumptions documented in debt tracking, and test registration configured cleanly in CMakeLists.txt.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905440857 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20031#pullrequestreview-5905440857). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T15:34:05Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `09ac0c32bb`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_codec_specific_info_tests` built cleanly. - **CTest** (`guest_webrtc_codec_specific_info_default`, `guest_webrtc_codec_specific_info_destructor`): ``` 1/2 Test #5094: guest_webrtc_codec_specific_info_default ...... Passed 0.01 sec 2/2 Test #5095: guest_webrtc_codec_specific_info_destructor ... Passed 0.03 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified _ZN6webrtc17CodecSpecificInfoC1Ev_nid_postfix and _ZN6webrtc17CodecSpecificInfoD1Ev_nid_postfix enforce null pointer checks on info, throwing std::invalid_argument before any field access or deallocation. - core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified Count validates vector pointer triples (begin, end, capacity) for alignment (first % alignof(TValue)), ordering (last < first, limit < last), divisibility (sizeof(TValue)), and null consistency (!first && limit), ensuring malformed templates and sample vectors throw std::invalid_argument before freeing resources. - core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified HoldsData and destructor logic correctly discriminate WebRtcFrameInstrumentationVariant active members by index (WebRtcFrameInstrumentationSyncIndex, WebRtcFrameInstrumentationDataIndex, and WebRtcFrameInstrumentationValueless), freeing sampleValuesBegin with _ZdlPv_nid_postfix only for engaged data variants while throwing on unknown indexes. - core/libs/prx/libwebrtc/include/CodecSpecificInfo.hpp: verified ABI layout, sizes, and offsets match WebRTC M134 with libc++ via static asserts (sizeof(WebRtcCodecSpecificInfo) == 2064, 8-byte alignment, union size 1624, optionals at offsets 1640, 1856, 1992, and 2000). - core/libs/prx/libwebrtc/src/CodecSpecificInfo.cpp: verified recursive release of WebRtcGenericFrameInfo and WebRtcFrameDependencyStructure properly deallocates heap-allocated InlinedVector storage based on metadata bit 0, frees partOfChain.begin, and destroys template array elements up to count before freeing the template buffer. - docs/dev/debt/libwebrtc.md & AGENTS.md: verified no forbidden comments in code, export count decremented (221 to 219), unverified console ABI assumptions documented in debt tracking, and test registration configured cleanly in CMakeLists.txt. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!20031
No description provided.