feat(libwebrtc): implement webrtc::AudioEncoder::Encode #17703
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17703"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-09T10:57:56Z.
What
Implements
webrtc::AudioEncoder::Encodein libwebrtc, adapted from audio_encoder.cc. The WebRTC notice and BSD licence head the file.Encodeis the non-virtual entry point a title calls on its ownAudioEncodersubclass, so this reaches titles that implementEncodeImplthemselves.Encodeis identical at M127 (e0b28a6a81) and M134 (8d78f5de6c).audio_encoder.his the same at both; the headers differ only inabsl::optionalversusstd::optionaland commented-out parameter names.array_view.hdiffers only by an added<cstddef>include and commented-out parameter names.NumChannelsis slot 3,SampleRateHzslot 2 andEncodeImplslot 29, counted after the two destructor entries. #17269 uses slot 21 forOnReceivedUplinkBandwidthby the same count.Encodedoes:NumChannelsand thenSampleRateHz, the left-to-right order Clang uses forNumChannels() * SampleRateHz().EncodeImpl, passing the caller's result storage,this, the timestamp, theArrayViewas pointer and size (asRmsLevel::Analyzetakes it) and thertc::Buffer*.EncodedInfoholds astd::vector, so it is returned through hidden storage and its vector is never touched here.RTC_CHECK_EQs stop the process, this throwsstd::runtime_error:NumChannels() * SampleRateHz() / 100samples;EncodeImplappended to the buffer differ fromencoded_bytes, thesize_tat offset 0 of the result.std::invalid_argument.TRACE_EVENT0.rtc::Bufferis modelled ininclude/Buffer.hpp, byte-identical to the file #17698 adds, so the two merge cleanly in either order.Tested
Windows 11, MinGW GCC Release build.
guest_webrtc_audio_encoder_encodeis new;guest_webrtc_audio_encoderandguest_webrtc_rms_levelstill pass.The new test drives a fake encoder with a 30-slot vtable. It checks:
EncodeImpl;EncodeImpland before the null output buffer is reached;Negative controls: moving
EncodeImplto slot 28, or dividing by 1000, both fail the test.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchreported #15609 and #16381 next to my CMake and include lines. I moved both, and the branch now merges cleanly with each of the 29 open libwebrtc pull requests that merge withmain, and with #17698 in either order.#14212, #15189 and #17691 already conflict with
main:None touches
Encode.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)