feat(libwebrtc): implement webrtc::AudioFrame::UpdateFrame and data_view #15196
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15196"
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 alvaroelpob on 2026-11-02T20:26:18Z.
What
Implements
webrtc::AudioFrame::UpdateFrame(uint32_t, const int16_t*, size_t, int, SpeechType, VADActivity, size_t)andAudioFrame::data_view() constin libwebrtc, which threw and were declared without parameters. Both use theWebRtcAudioFramelayout and zeroed buffer already onmain.The module's WebRTC revision lies between M127 and M134, as recorded in the debt file. Both functions in
audio_frame.cc(M127, M134), andGuessChannelLayoutinchannel_layout.cc(M127, M134), are the same at both. They are added tosrc/AudioFrame.cpp, which already carriesaudio_frame.cc's notice and licence.UpdateFrame:RTC_CHECKs do, before setting any field when the frame has more thankMaxConcurrentChannels(8) channels, and after setting the fields when it has more than 7680 samples.data_viewreturns the 32-byteInterleavedView<const int16_t>ofaudio_view.h: channels, samples per channel, then anArrayViewwhose pointer is the zeroed buffer when muted, the frame's data otherwise, and null when the size is 0.CopyFromstays unimplemented: it copiespacket_infos_, a reference to a guest object. A null frame throws. It removes 2 exports from the inventory.Tested
Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with
BUILD_TESTING=ON.guest_webrtc_audio_frametest:UpdateFramewith 480 stereo samples sets every field, copies exactly 960 samples and leaves the profiling fields; null data mutes the frame and keeps the samples.data_viewreturns the data, the zeroed buffer when muted, and a null pointer when either count is 0.ctest -j16on head 86116773cd: 3595/3595 pass.check_conventions.py --base upstream/mainpasses.pr_overlap.py: no open pull request implements these functions. The shared lines are the pending-export count indocs/dev/debt/libwebrtc.mdand the source, test and declaration lists inCMakeLists.txtandApi.hpp.main4f41f4c375, head 881e69af04, to resolve the conflicts on the sharedCMakeLists.txt,Export.cppand debt-file lines; both sides are kept and the debt count is recomputed fromExport.cpp. Full build andctest -j16: 3795/3799 pass;guest_sce_net,guest_poll,guest_select_waitandguest_memoryfailed under that load, pass when run alone, andmain4f41f4c375passes all 3799 with-j16on the same machine.check_conventions.py --base upstream/mainpasses.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)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T19:12:50Z.
Review: APPROVED
Reviewed — approved
webrtc::AudioFrame::UpdateFrameanddata_viewfollow upstreamaudio_frame.ccandchannel_layout.ccand fit the existingWebRtcAudioFramelayout. The extended test passes, and it fails againstmain's production files and against two behaviour mutations.What I ran
Head
881e69af0446d93ca4cb1ab744cbbe4f4085c830,main1e658521a0a599872612bb91949311e2956b5283, merged tree3bd1c5cd0de5999702d74c9eacfb249aef4642ae.Results
git diff --checkcheck_conventions.pymain(unwrap_self_..._inherits_the_destination_directory_group); no new failures, no timeoutsguest_webrtc_audio_framepublic_headerstests andguest_webrtc_audio_frame(66 tests)Export.cpphas 289NotImplemented_nid_no_patch(__func__)stubs on the merged tree and 291 onmain. Adding the 60 NID-bound exports gives 349 (was 351), which matches the debt fileNegative control
Export.cpp,include/Api.hpp,include/AudioFrame.hppandsrc/AudioFrame.cppfrommain. The test executable then does not compile:too many arguments to function ... UpdateFrame...(), andWebRtcChannelLayoutStereowas not declared.size == 0 ? nullptr :branch indata_view. The test aborts.GuessChannelLayout. The test aborts.After restoring the merged files and rebuilding, the test passes and
git status --porcelainis empty.Findings
I compared the code with upstream:
UpdateFrame: checksnum_channelsbefore storing anything, stores the fields, guesses the layout, checks the length against the buffer after storing the fields, then copies or mutes. This is the upstream order.ChannelLayout(UNSUPPORTED 1, MONO 2, STEREO 3, SURROUND 5, QUAD 8, 5_0 9, 5_1 10, 7_1 14, 6_1 23).data_view: reproducesInterleavedView{num_channels_, samples_per_channel_, ArrayView{data, size}}, includingArrayView's null pointer for size 0.thisin the second register, which the host prototype reproduces.UpdateFramekeeps its 8 arguments in SysV order:numChannelsandvadActivitygo on the stack.Blocking
None.
Non-blocking
docs/dev/debt/libwebrtc.md:24says that more than 8 channels "or 7680 samples ... throw after the same fields are set". That is true for the sample-count check. The channel-count check atcore/libs/prx/libwebrtc/src/AudioFrame.cpp:130-131throws before any field is written, as upstream's firstRTC_CHECK_LEdoes, and the test checks thatnumChannelsstays 8. Suggested wording: "more thankMaxConcurrentChannels(8) channels throw before any field is set; more than 7680 samples throw after the fields are set."Not verified
I did not repeat the PR's own full
ctest -j16claims.