Repository navigation
obs-output: port obs_output_get_video_conversion to Rust (#6104) - #6106
Conversation
Add the safe core for obs_output_get_video_conversion() as a todo!() stub and its Tier 1 tests in the core category binary. They port test_output_input_checks' conversion_with_video, conversion_no_video_* cases over a model output, plus the pointer identity (the answer is the output's own video_conversion), the plans that must write nothing, and the two flag warnings that test cannot see. Refs obs-rust#6104.
Extract obs_output_get_video_conversion() verbatim from obs-output.c.h into its own unit, keep it for the C reference in the ported group libobs.ported-output-video-conversion with the original flag helpers, and swap hybrid libobs to the Rust shim. The safe core refuses an encoded output (log_flag_encoded with inverse_log) and then a non-video one, in the C's short-circuit order, builds obs_output_conversion_sizes from the set conversion, the scaled size and the video's size, and asks the ported conversion plan. A set plan writes its planned width and height. A scaled plan writes the video's format with VIDEO_CS_DEFAULT/VIDEO_RANGE_DEFAULT and the planned size, but a scaled size with no video returns NULL and writes nothing (obs-rust#2127). Any other plan writes nothing. Every success is the address of the output's own video_conversion, never a copy. The private layout, the warnings, the video's size and info and every write stay in C behind obs-output-get-video-conversion-fields.c.h; the shim takes the sizes from obs-media-io's Rust video queries. Register the export fragment, the core group's adapter and the registration contract. Tier 3 runs the original C and the shim on one real-header output: the returned pointer, every conversion field, the whole output and the exact warnings over the flags, a live and a NULL video, stored conversions and scaled sizes. A deliberate width/height swap in the set plan kills both parity tests. The full core category binary passes (7968 tests). Refs obs-rust#6104.
…ic tests Every test_* target linking libobs_rust-static can pull the obs_output_get_video_conversion shim into unrelated source-step tests, so attach the real private-layout adapter next to the test sources, as the device-queries and viewport link support do. The exec fragment is discovered by the existing tests.d glob; no graph or shared list changes. Refs obs-rust#6104.
The standalone adapter's fields header only forward-declares the flag readers, so the link-support translation unit now includes the support header that defines them (MSVC C2129, undefined at link elsewhere). Link the adapter as its own lazy static archive, like the device-query and viewport link support, instead of compiling it into every test target that links libobs_rust-static. The parity probe compares the conversion field by field rather than by memcmp over the whole struct, whose padding is unspecified, and plants a mutant that skips the video-info NULL check so the Tier 3 claim is held by a test. Refs obs-rust#6104.
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: LGTM. It ports obs_output_get_video_conversion with Tier 1 and Tier 3 coverage. The two new memcmp calls compare the output object with a byte snapshot of itself outside the field under test, so padding matches by construction and #6035 isn't repeated. No existing C test, oracle stub or public header is touched, it has a Test cost line, and it merges cleanly. I've approved the held runs. Auto-merge on.
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: clean port of obs_output_get_video_conversion preserving C field-address return and scaling/flag ordering, FFI adapter, rust-exports.d, Tier 1/3 parity tests, RED→GREEN commits, and Test cost. Held CI runs approved.
…acOS -Wmissing-prototypes
…o_conversion_link_support.cmake
|
Pushed mechanical fixups
|
Unit
obs_output_get_video_conversion()fromlibobs/obs-output.c.h(~39 lines). Free: the open PRs on this file touch encoder setters/start-stop/audio/service in separate hunks. Already characterized intest/cmocka/test_output_input_checks.c. Closes #6104.Function
const struct video_scale_info *obs_output_get_video_conversion(struct obs_output *output)log_flag_encoded(output, __func__, true) || !log_flag_video(output, __func__)→ NULL.obs_output_conversion_sizesfromvideo_conversion_set, the currentvideo_conversion.width/height,scaled_width/heightandvideo_output_get_width/height, then ask the already-portedobs_output_conversion_plan().SET: write the plan's width/height intooutput->video_conversionand return its address.SCALED:video_output_get_info(); NULL (scaled size but no video) → NULL; else write format,VIDEO_CS_DEFAULT/VIDEO_RANGE_DEFAULT, plan width/height, return the same address.Design
libobs/obs-output-get-video-conversion.c.h(original body unchanged), with the twolog_flag_*inlines copied into-support.c.hfor the isolated reference unit;obs-output.c.hkeeps its own copies for its other callers. The C reference grouplibobs.ported-output-video-conversioncompiles the extraction; the hybrid group swaps in the adapter.rust/obs-output/src/video_conversion.rswith aHosttrait for the flag gates, the size reads, the plan and the in-place writes.obs-output-get-video-conversion-fields.c.h: the private layout, both warning lines, the read/write fields and the field address.ffi/get_video_conversion.rs; export fragmentobs-output-get_video_conversion.txt;rust/README.mdand naming rows; native registration test.test/cmocka/output-video-conversion-link-support.c+tests.d/output_video_conversion_link_support.cmake.Tests
output::output_video_conversion(obs-tests-core): the cmocka cases plus pointer identity, NULL video with a scaled size, no side effects for other plan kinds, and the flag-gate log lines.output::output_video_conversion_parity: original C vs shim with identical fixtures, comparing the returned pointer, every conversion field, the video-info lookups and exact log lines; a mutation (set-plan width/height swapped) failed both parity tests.test_output_input_checkson hybrid libobs andlibobs-c-reference.Verification
todo!(); GREEN focused 9 passed, 0 failed.obs-tests-core: 7968 passed, 0 failed, 5 ignored.cmake --build --preset windows-x64: success (the hybrid unity group with the adapter include).lint: ok.Unverified on this Windows host (CI covers them): the cmocka Tier 2 run and its link-support fragment (tests disabled in the local preset), the explicit
OBS_BUILD_C_REFERENCE=ONbuild, andlinux-validate.Fixes #6104.
Test cost: new tests: longest 0.01 s, peak RSS 5 MB, no own threads (10 tests added as modules of the existing
obs-tests-corebinary; no new test executable).