feat(libwebrtc): implement the EncodedImage constructor and destructor and EncodedImageBuffer::Create #20042
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20042"
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 Krille2004zzz on 2026-11-14T13:21:34Z.
What
libwebrtc
webrtc::EncodedImage::EncodedImage()(_ZN6webrtc12EncodedImageC1Ev),webrtc::EncodedImage::~EncodedImage()(_ZN6webrtc12EncodedImageD1Ev) andwebrtc::EncodedImageBuffer::Create(const uint8_t*, size_t)(_ZN6webrtc18EncodedImageBuffer6CreateEPKhm) threwnot implemented. This PR ports them from M134 (8d78f5de)encoded_image.ccandencoded_image.h, with the reference counting fromref_counted_object.hand thertc::Bufferconstructor frombuffer.h. The newsrc/EncodedImage.cppstarts with their notices. The copy and move constructors and assignments are not exported, so they are left out.Layout: Clang 19 + libc++ probes of the real M134 headers give a 344-byte object:
Timingat 40, thestd::optional<VideoPlayoutDelay>at 112, the bufferscoped_refptrat 136,size_at 144,std::map<int, size_t>at 200,std::optional<ColorSpace>at 224,RtpPacketInfosat 304 and the corruption-detection settings at 320.RefCountedObject<EncodedImageBuffer>is 40 bytes: vtable,rtc::Bufferat 8, count at 32.encoded_image.ccis the same in M132, M133 and M134, and the header is the same in M133. M132 has nocorruption_detection_filter_settings_, which would make the object 320 bytes. The module is at least M132, since it exportsBuiltinAudioProcessingBuilder::Build, but its exact revision isn't known. Like #20031 and #20036, this assumes the module's standard library is libc++.Constructor: writes the upstream defaults:
kVideoFrameDelta,qp_−1, timing flagskInvalid,retransmission_allowed_true, an empty map whose begin node points at its own end node, and everything else zero or not set.Destructor: follows upstream's member order:
RtpPacketInfos::Data, and on the last one frees each entry's CSRC vector, the entry vector and the data;Release), so a buffer the title implements itself is released by its own code.Before anything is freed, it checks the map's node count and begin node and the bounds of the vectors. A null object, a malformed vector or map, or a buffer without a
Releaseslot throws.EncodedImageBuffer::Create: allocates the 40-byte object with guestoperator newand the copy of the bytes withoperator new[], with capacity equal to size and no array when size is 0. If the array allocation fails, the object is freed. It returns the reference through the hidden result pointer with count 1. The host vtable follows Clang's dump:AddRef,Release, complete and deleting destructors, bothdata(),size(),HasOneRef. A null result, or null data with a non-zero size, throws.Debt: the three stubs are removed, the libwebrtc unknown-export count drops from 222 to 219, and a debt entry records the layout, the M132 difference and that nothing has been checked on the console.
Tested
guest_webrtc_encoded_image_default,_bufferand_destructor(core/libs/prx/libwebrtc/tests/EncodedImage.cpp) cover:Create's copy, every vtable slot, shared references, zero-size and allocation-failure paths;encoded_image.cc,rtp_packet_info.ccandcolor_space.ccwith this implementation:Creatematched upstream in allocation sizes, fields and virtual calls, and upstreamEncodedImagecopies released these buffers with no leak.qp_to 0, and a wrong buffer capacity.ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Ee]ncoded|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt': 249/249 passed. Not tested on a console, a title or Windows.python3 tools/check_conventions.py --base origin/main: all checks passed.python3 tools/pr_overlap.py: no open PR implements these exports. #17009, #17722, #18495, #18503 and #18798 couldn't be compared automatically, so I compared them by hand: they implement other functions and only share the libwebrtc files. My #20025, #20031 and #20036 change the same debt count line, so whichever merges later needs a recount.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 MarcZX10 on 2026-11-14T13:33:46Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code establishes a verified defect; the implementation is plausible, but material ABI and console behavior remain unverified.
What I ran
Reviewed head
931b759201b4fd75e5d0d78c3343930084634405. No tests or builds were run; author-reported checks are not treated as checks performed here. Readdescription.md,commits.md,manifest.json,diff.patch, and all seven changed files listed as included in the manifest.files.jsonwas unavailable through the reader; the file listing confirmed the changed-file set. Targeted context read:Buffer.hpp,StdioExtras.cpp,Api.hpp, and the relevant CMake test-registration section. Searched for the guest-memory helper and matching export stubs; the helper implementation was not located.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The review-folder exclusion report was not available. Console ABI and behavior, title behavior, Windows behavior, the implementation of
GuestCopyIn_nid_no_patch, and the author-reported test and differential runs were not independently verified. No claims are made about excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T13:43:02Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
931b759201:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_encoded_image_testsbuilt cleanly.guest_webrtc_encoded_image_default,guest_webrtc_encoded_image_buffer,guest_webrtc_encoded_image_destructor):core/libs/prx/libwebrtc/Export.cpp,core/libs/prx/libwebrtc/include/Api.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T15:07:00Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected changes blocks merging; however, the target module revision and console ABI remain unverified.
What I ran
Reviewed head
b2237ab5c776001a80e8bfadae9f008dc18634feusing the prepared review artifacts and pinned repository reader. No commands or tests were run by me.Results
Findings
Blocking
None.
Non-blocking
Not verified
Did not run tests, inspect a merged preview, or verify behavior on console, title, Windows, or other host environments. The implementation's compatibility with the module's actual revision remains uncertain. The PR reports Linux x86-64 tests and differential checks, but these were not run by me.
To get this to a good state
Nothing is required. Optional: confirm the object layout and ABI against the target console module.
Files read
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,core/libs/prx/libwebrtc/include/EncodedImage.hpp(requested lines were outside the file), andcore/libs/prx/libwebrtc/tests/EncodedImage.cpp(search results only).Files excluded
No excluded files were identified by the manifest search; manifest completeness was not checked beyond the first 200 lines.
Continued review (pass 2)
This continuation reviewed the listed added lines at head
b2237ab5c776001a80e8bfadae9f008dc18634fe; I found no verified blocking defect in them. This draft covers only this continuation pass and does not repeat earlier findings.What I ran
core/libs/prx/libwebrtc/CMakeLists.txt,core/libs/prx/libwebrtc/include/Api.hpp,core/libs/prx/libwebrtc/include/EncodedImage.hpp,core/libs/prx/libwebrtc/src/EncodedImage.cpp,core/libs/prx/libwebrtc/tests/EncodedImage.cpp, anddocs/dev/debt/libwebrtc.md.Results
Findings
Blocking
None in the lines reviewed in this continuation.
Non-blocking
None.
Not verified
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T15:31:41Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
dbafc970f8:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_encoded_image_testsbuilt cleanly.guest_webrtc_encoded_image_default,guest_webrtc_encoded_image_buffer,guest_webrtc_encoded_image_destructor):core/libs/prx/libwebrtc/Export.cpp,core/libs/prx/libwebrtc/include/Api.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T16:24:32Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2804f3b03c:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_encoded_image_testsbuilt cleanly.guest_webrtc_encoded_image_default,guest_webrtc_encoded_image_buffer,guest_webrtc_encoded_image_destructor):core/libs/prx/libwebrtc/Export.cpp,core/libs/prx/libwebrtc/include/Api.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me