Skip to content

feat(libwebrtc): implement AudioCodecInfo constructor - #14381

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlexWhitehouse:feat/libwebrtc-audio-codec-info
Nov 6, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlexWhitehouse:feat/libwebrtc-audio-codec-info

Conversation

@AlexWhitehouse

Copy link
Copy Markdown
Contributor

What

Implement _ZN6webrtc14AudioCodecInfoC1Eimiii (NID uPZSgYg7CZI) as a typed C export with an explicit object pointer. It stores all five arguments and initializes comfort noise to true and network adaption to false.

The constructor and struct are identical at WebRTC M127 e0b28a6a81a989c1f5c89e30fcd247870047390d and M134 8d78f5de6c27b2c793039989ea381f1428fb0100, in api/audio_codecs/audio_format.cc and .h. Sony's exact revision and console parity remain unverified. The implementation retains the upstream copyright notice and BSD licence.

Assert the 32-byte guest layout and every field offset (0, 8, 16, 20, 24, 28, 29). LP64 gives 4-byte ints, an 8-byte channel count and two 1-byte flags; alignment adds four internal padding bytes and two tail bytes. A fixed-width channel count also preserves the guest layout on Windows.

Null objects and violations of the five upstream DCHECK preconditions throw std::invalid_argument locally before writing. These exceptions are defensive local behavior; release upstream does not enforce those DCHECKs or provide this exception contract.

Update the throwing-export inventory from 385 to 384. The previous 325 figure counts only named __func__ stubs and omits 60 literal-NID stubs; the debt total includes both. The 31 unresolved data exports are unchanged.

Tested

Linux x86-64, GCC 15, Release, configured full build:

  • cmake --build build-full --target libs guest_webrtc_audio_codec_info_tests --parallel 6: passed.
  • Built existing libwebrtc test executables, then ctest --test-dir build-full -R 'guest_webrtc|public_headers' --output-on-failure: 72/72 passed in 146.83 seconds. Constructor test: 0.01 seconds.
  • Negative control: separately built the original origin/main library with its original declaration and throwing definition, then ran the final test executable against it. It linked and exited 1 with _ZN6webrtc14AudioCodecInfoC1Eimiii_nid_postfix not implemented.
  • Mutation check: swapped the minimum and maximum bitrate stores. The test failed at its minimum-bitrate assertion; restored the implementation, rebuilt, and passed the focused test and complete sweep above.
  • Coverage includes all fields and both flags, guard bytes on both sides, 1/2/6 channels, equal bitrate bounds, zero minimum, integer boundaries, and each violated precondition.
  • python3 tools/check_conventions.py --base origin/main and git diff --check: passed.
  • Open export-name searches found no duplicate implementation. Read open libwebrtc diffs and ran python3 tools/pr_overlap.py --branch feat/libwebrtc-audio-codec-info after committing. Shared inventory/header/CMake edits may need reconciliation as other PRs merge; no semantic dependency. The tool returned exit 2 because documentation cleanup docs(debt): separate entries with blank lines and drop derived export totals #14212 conflicts with main; manually read its libwebrtc debt diff, which removes inventory numbers and changes spacing, with no constructor implementation.
  • No Windows or console execution. An initial sweep ran before the VAD test executable was built and reported it Not Run; built the existing targets and reran successfully as above.

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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for this; the layout and the kept BSD notice look right at 0fbba07b8e. One behaviour point:

The constructor throws std::invalid_argument for bounds that upstream only checks with RTC_DCHECK. In a release build of webrtc, which is what titles ship, those values are stored as given. So a title passing such a value would work on the console but stop here. Please store the values the way release upstream does (keep the null-object guard), and drop the six assertions in tests/AudioCodecInfo.cpp:54-59 that expect those throws.

Merge order against #14246 is free: only the count line in docs/dev/debt/libwebrtc.md conflicts, so whichever lands second recounts.

@AlexWhitehouse

Copy link
Copy Markdown
Contributor Author

Done in 821b209: the constructor now throws only for a null object and stores all five arguments as given, the six bound assertions are gone, and new cases such as min > default and all-negative values check they are stored unchanged. Swapping the min and max stores, or putting back a min > default throw, makes the test fail.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 14087 docs/dev/debt/libwebrtc.md L5, L16
PR 14095 docs/dev/debt/libwebrtc.md L5, L16
PR 14116 core/libs/prx/libwebrtc/CMakeLists.txt L4-5
core/libs/prx/libwebrtc/include/Api.hpp L3-4
docs/dev/debt/libwebrtc.md L5, L16
PR 14120 core/libs/prx/libwebrtc/CMakeLists.txt L4-5
core/libs/prx/libwebrtc/include/Api.hpp L3-4
docs/dev/debt/libwebrtc.md L5, L16
PR 14129 core/libs/prx/libwebrtc/CMakeLists.txt L4-5
core/libs/prx/libwebrtc/include/Api.hpp L3-4
docs/dev/debt/libwebrtc.md L5, L16
PR 14148 core/libs/prx/libwebrtc/CMakeLists.txt L4-5
core/libs/prx/libwebrtc/include/Api.hpp L3-4
docs/dev/debt/libwebrtc.md L5, L16
PR 14224 docs/dev/debt/libwebrtc.md L5
PR 14232 docs/dev/debt/libwebrtc.md L5, L16

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 14212 docs/dev/debt/libwebrtc.md

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Progress report (ea3ae18 → 4569246)

📈 System libraries: 27.88% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libwebrtc _ZN6webrtc14AudioCodecInfoC1Eimiii_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libwebrtc 71/412 (17.23%) 72/412 (17.48%) +0.24%

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The AudioCodecInfo five-argument constructor stores its arguments into a 32-byte struct whose LP64 offsets I checked, its NID matches the mangled name under the repository's own NID function, and the constructor sets the two defaults the PR states; the layout and the WebRTC source it follows are cited, not checked against WebRTC here.

What I ran

  • Exact head 821b209e953ef669e48e3fef3a5a5852704e1dcd, base e67cc81869.
  • Environment: Linux, /usr/bin/python3 3.11.2, no build.
  • Precheck: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14381 --output-dir /dev/shm/reviewer-run/precheck/14381
  • ABI audit by hand (helper absent from the head tree): python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base e67cc81869 --head 821b209e953ef669e48e3fef3a5a5852704e1dcd --json (exit 0; passed_with_warnings; 60 findings of kind nid-alias-differs-from-symbol-hash, none for the new constructor; 412 symbols). The new constructor's computed NID is uPZSgYg7CZI, the value the export carries.
  • NID recomputed with tools/nid_names.py (compute_nid) for _ZN6webrtc14AudioCodecInfoC1Eimiii: uPZSgYg7CZI.
  • Test-quality helper on core/libs/prx/libwebrtc/tests/AudioCodecInfo.cpp from a head extract: one literal-path registration heuristic.
  • Struct layout checked against the static_asserts in include/AudioCodecInfo.hpp (size 32; offsets 0, 8, 16, 20, 24, 28, 29), which I recomputed by hand for LP64 (int, std::uint64_t, three int, two bool).

Results

Precheck report, checks table, unedited (/dev/shm/reviewer-run/precheck/14381/report.md):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check e67cc818696fd6e6c58ac80adc6550c54aed68e8...821b209e953ef669e48e3fef3a5a5852704e1dcd
conventions_and_pr_template passed /usr/bin/python3 tools/check_conventions.py --base e67cc818696fd6e6c58ac80adc6550c54aed68e8 --head 821b209e953ef669e48e3fef3a5a5852704e1dcd --title feat(libwebrtc): implement AudioCodecInfo constructor --body /dev/shm/reviewer-run/precheck/14381/pr-body.md
changed_export_abi_audit failed /usr/bin/python3 tools/pr_abi_audit.py --base e67cc818696fd6e6c58ac80adc6550c54aed68e8 --head 821b209e953ef669e48e3fef3a5a5852704e1dcd --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.
python_test_registration not_applicable No changed test_*.py files.
live_dependency_and_mergeability_check passed /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14381 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14381/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /usr/bin/python3 /dev/shm/reviewer-run/precheck/14381/head-821b209e953e-c9fb54fd/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14381/head-821b209e953e-c9fb54fd --json core/libs/prx/libwebrtc/CMakeLists.txt core/libs/prx/libwebrtc/Export.cpp core/libs/prx/libwebrtc/include/Api.hpp core/libs/prx/libwebrtc/include/AudioCodecInfo.hpp core/libs/prx/libwebrtc/src/AudioCodecInfo.cpp core/libs/prx/libwebrtc/tests/AudioCodecInfo.cpp docs/dev/debt/libwebrtc.md
negative_controls not_applicable No changed Python test module in tools/ can be run as a no-build base-source control.

Negative control

Not run here. The C++ test needs a build.

Findings

Blocking: none.

Non-blocking:

  • The new source file carries WebRTC's BSD licence header (copyright 2016 and 2011 notices). The same library already has WebRTC-licensed sources (src/RtcpCommonHeader.cpp carries the same 2016 header), so this follows precedent; whether copied licence text belongs in these files is the same maintainer question as in #14431.
  • The WebRTC revisions cited (M127 and M134) and the field order were not fetched here; the struct matches my recollection of audio_format.h, but that is not a check.

Sources

Not verified

  • The WebRTC source the PR adapts (M127 and M134) was not fetched; the field order and defaults are the author's citation.
  • The C++ test was not built or run here.
  • Hosted: at this head conventions, eligibility, labels, library-portability and report succeeded; linux, register-context, relinker, relinker-asan and write-watch were skipped.

@AlexWhitehouse

Copy link
Copy Markdown
Contributor Author

Thanks. On the unverified points: audio_format.h is identical at M127 (e0b28a6a) and M134 (8d78f5de) and declares int sample_rate_hz, size_t num_channels, three int bitrates, then allow_comfort_noise = true and supports_network_adaption = false; audio_format.cc differs between them only in includes, and its notice matches src/AudioCodecInfo.cpp byte for byte. At 821b209 guest_webrtc_audio_codec_info built and passed with g++-15 on Linux, and failed when the min and max stores were swapped.

@AlexWhitehouse
AlexWhitehouse force-pushed the feat/libwebrtc-audio-codec-info branch 2 times, most recently from ec54a59 to aa87ad4 Compare November 3, 2026 08:18
@AlexWhitehouse
AlexWhitehouse force-pushed the feat/libwebrtc-audio-codec-info branch from aa87ad4 to 3ea8bc4 Compare November 4, 2026 19:25
@oneandonlydean oneandonlydean self-assigned this Nov 5, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
AlexWhitehouse and others added 2 commits November 6, 2026 03:40
…pstream does

Upstream checks the sample rate, channel count and bitrate bounds only
with RTC_DCHECK, which is compiled out of the release builds titles ship.
Keep the null-object throw and store every argument as given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexWhitehouse
AlexWhitehouse force-pushed the feat/libwebrtc-audio-codec-info branch from 3ea8bc4 to 4569246 Compare November 6, 2026 03:43
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@oneandonlydean
oneandonlydean merged commit 7015a65 into boykopovar:main Nov 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants