feat(libwebrtc): implement the webrtc::AudioDecoder PLC and error code defaults #14148

Merged
alvaroelpob merged 18 commits from upstream-pr/14148 into main 2026-11-02 19:46:28 +00:00
alvaroelpob commented 2026-10-31 20:53:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-31T20:53:38Z.


What

Implements these webrtc::AudioDecoder base methods in libwebrtc, which threw and were declared without parameters:

  • HasDecodePlc()
  • DecodePlc(size_t, int16_t*)
  • GeneratePlc(size_t, rtc::BufferT<int16_t>*)
  • ErrorCode()

AudioDecoder is the abstract base of the audio decoders. A decoder that does not override these methods gets the base versions in its vtable, so calls through the vtable reach these exports.

The module's WebRTC revision lies between M127 and M134, as recorded in the debt file by #13687. These methods in api/audio_codecs/audio_decoder.cc are the same at M127 branch-heads/6533 and M134 branch-heads/6998; M134 only comments out the unused parameter names of DecodePlc.

The functions are adapted from audio_decoder.cc and live in src/AudioDecoder.cpp, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's LICENSE. The debt entry says it is adapted from audio_decoder.cc.

As upstream:

  • HasDecodePlc returns false.
  • DecodePlc and ErrorCode return 0.
  • GeneratePlc leaves the concealment buffer untouched.

None of them reads the decoder, the output pointer or the buffer, so their layouts are not needed and null is accepted.

Decode and DecodeRedundant call the virtual PacketDuration and DecodeInternal, and the ParseResult members hold a std::unique_ptr to an encoded frame. Those need the vtable and frame layouts, so they are left throwing. The inventory drops from 379 to 375.

Tested

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

  • New guest_webrtc_audio_decoder test, on a decoder filled with 0xC3, a buffer filled with 0xA5 and samples set to 0x1234:
    • HasDecodePlc returns false.
    • DecodePlc returns 0 for 0 and 3 frames and for a null output.
    • GeneratePlc returns for a buffer and for null.
    • ErrorCode returns 0.
    • No decoder, buffer or sample byte changes.
  • Full ctest -j16 on head 638940eec0: 3038/3038 pass. check_conventions.py --base upstream/main passes. pr_overlap.py reports the open pull requests listed in Depends on.
  • Rebased onto main 1bc97b9527 after #13736 merged; the only conflicts were the include, CMake source and debt count lines. Full ctest -j16 on the top of the stack, #14148 head 0884de5716 (which contains this head, 0884de5716): 3087/3087 pass. check_conventions.py --base upstream/main passes.
  • Rebased onto main dc9dc7eaae after #13764 and #13816 merged. The conflicts were the debt count line and, in the AudioDeviceGeneric commit, the Export.cpp stubs next to the removed VAD stubs; that commit keeps main's side and removes only its own seven stubs. The count is now set from the stubs left in Export.cpp plus the 60 bound by NID (352
    31 on this head, 44e052f6dd). Full ctest -j16 on the top of the stack, #14148 head 44e052f6dd: 3113/3113 pass. check_conventions.py --base upstream/main passes.
  • 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: #14087, #14095, #14116, #14120, #14129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5101436374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14148). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-31T20:53:38Z. --- ### What Implements these `webrtc::AudioDecoder` base methods in libwebrtc, which threw and were declared without parameters: - `HasDecodePlc()` - `DecodePlc(size_t, int16_t*)` - `GeneratePlc(size_t, rtc::BufferT<int16_t>*)` - `ErrorCode()` `AudioDecoder` is the abstract base of the audio decoders. A decoder that does not override these methods gets the base versions in its vtable, so calls through the vtable reach these exports. The module's WebRTC revision lies between M127 and M134, as recorded in the debt file by #13687. These methods in `api/audio_codecs/audio_decoder.cc` are the same at [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/api/audio_codecs/audio_decoder.cc) and [M134 branch-heads/6998](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/audio_codecs/audio_decoder.cc); M134 only comments out the unused parameter names of `DecodePlc`. The functions are adapted from `audio_decoder.cc` and live in `src/AudioDecoder.cpp`, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's `LICENSE`. The debt entry says it is adapted from `audio_decoder.cc`. As upstream: - `HasDecodePlc` returns false. - `DecodePlc` and `ErrorCode` return 0. - `GeneratePlc` leaves the concealment buffer untouched. None of them reads the decoder, the output pointer or the buffer, so their layouts are not needed and null is accepted. `Decode` and `DecodeRedundant` call the virtual `PacketDuration` and `DecodeInternal`, and the `ParseResult` members hold a `std::unique_ptr` to an encoded frame. Those need the vtable and frame layouts, so they are left throwing. The inventory drops from 379 to 375. ### 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_audio_decoder` test, on a decoder filled with 0xC3, a buffer filled with 0xA5 and samples set to 0x1234: - `HasDecodePlc` returns false. - `DecodePlc` returns 0 for 0 and 3 frames and for a null output. - `GeneratePlc` returns for a buffer and for null. - `ErrorCode` returns 0. - No decoder, buffer or sample byte changes. - Full `ctest -j16` on head 638940eec0: 3038/3038 pass. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports the open pull requests listed in Depends on. - Rebased onto main 1bc97b9527 after #13736 merged; the only conflicts were the include, CMake source and debt count lines. Full `ctest -j16` on the top of the stack, #14148 head 0884de5716 (which contains this head, 0884de5716): 3087/3087 pass. `check_conventions.py --base upstream/main` passes. - Rebased onto main dc9dc7eaae after #13764 and #13816 merged. The conflicts were the debt count line and, in the AudioDeviceGeneric commit, the `Export.cpp` stubs next to the removed VAD stubs; that commit keeps `main`'s side and removes only its own seven stubs. The count is now set from the stubs left in `Export.cpp` plus the 60 bound by NID (352 31 on this head, 44e052f6dd). Full `ctest -j16` on the top of the stack, #14148 head 44e052f6dd: 3113/3113 pass. `check_conventions.py --base upstream/main` passes. - 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: #14087, #14095, #14116, #14120, #14129 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:49:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:25Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14148#pullrequestreview-5729922226). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:25Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
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!14148
No description provided.