From a3770c7a0484648fff280d36a97769e3ced2282c Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 25 Nov 2026 07:10:39 -0800 Subject: [PATCH 1/3] test: characterize obs_encoder_update (Refs #5687) Client-Checks: {"checks":{"base":"8a8e7b63feb4fce649904a2bd30152463438d087","coverage":"all-tracked-applicable-files","diff":["test/cmocka/build/test-graph.json","test/cmocka/test_encoder_update.c"],"head":"fd659982466e44b2e3af0757a4a3cfda5f8ea98b","tools":{"orchestrator-python":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]","schema-dependencies":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21503\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Regexps Automata RelaxNG Schemas Modules Debug"},"tracked-digest":"a39f2121353dad8c3aa0f7d555bab36d53e3d7897d9f2022328a0317d7956237","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431"}} Ci-Attestation: {"at":1795677468,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":87,"stamp":"d90fb88caf5656c87eec1af74b67ab84","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} Ci-Attestation: {"at":1795677468,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":87,"stamp":"45cf06ac45ec05c5a40cb9f4d89380c0","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} Ci-Attestation: {"at":1795677468,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":87,"stamp":"8b11395846800021269a7546c981f166","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} Ci-Attestation: {"at":1795677468,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":87,"stamp":"6a481c175ddd88924b905351d3b1823f","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} Ci-Attestation: {"at":1796411258,"gate":"general/all/client-lint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"fa1544497dc1a658832948148feac9e0","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1795677468,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":87,"stamp":"5a015ddc74c3a60bcd757104988d9138","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} Ci-Attestation: {"at":1796411264,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"ab68f7353e57c9d37d881ec4b0b128c9","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411264,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"4ef5fb6adfce15c0d4669aa609e3e6f4","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411262,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"3f2e73ba310ca41576e6cb7653e14075","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411262,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"15fe9ae0a66336d0ccc3aec63a5d12a2","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411259,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"4c27267dce9e4f7563346bbe61516f0b","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411260,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"c27d128bd9c28fec40766637a15156d3","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411263,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"13c3f8899aacdac1699fb3b754899018","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411263,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"9cb81ed0a23ac5efa01119a68518c8e5","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411260,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"d8888bf244712be55ebb20753887ee3a","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411261,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"6229123b292117fda6769e7b04517579","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411258,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"5fed272559417cefd54ce47f232109b9","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1796411259,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c88fd4c187b2c0f737a2440efd7b3a74d686a38bec1ff600e6115e220ed82b0d","lane":"client-lint","parents":["f4b266b71bab7a58eac7e2cad3f1c1a6e4e0231b"],"secs":53,"stamp":"03d2dccf2452461749f91693f6353fa9","tree":"e744da2e4be07bd511d64d97a140b6f7d51ec7e7","v":1,"via":"run"} Ci-Attestation: {"at":1795677740,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"727cb117ae3e2f84c617b6b9067405c184efb10ec496801900144a776f4c2ddc","lane":"client-test-x86_64-unknown-linux-gnu","parents":["8a8e7b63feb4fce649904a2bd30152463438d087"],"secs":271,"stamp":"fd19b6a4988b28bd3c2af4621789385a","tree":"aa9d0c7a119e9e1c9c88040355b6dd25b3ce0431","v":1,"via":"run"} --- .../test-graph.d/test_encoder_update.json | 29 +++ test/cmocka/test_encoder_update.c | 219 ++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 test/cmocka/build/test-graph.d/test_encoder_update.json create mode 100644 test/cmocka/test_encoder_update.c diff --git a/test/cmocka/build/test-graph.d/test_encoder_update.json b/test/cmocka/build/test-graph.d/test_encoder_update.json new file mode 100644 index 0000000000..8e5f2e783e --- /dev/null +++ b/test/cmocka/build/test-graph.d/test_encoder_update.json @@ -0,0 +1,29 @@ +{ + "schema": 1, + "targets": { + "test_encoder_update": { + "sources": [ + "test/cmocka/test_encoder_update.c" + ], + "libraries": [ + "OBS::libobs", + "OBS::caption", + "Uthash::Uthash", + "SIMDe::SIMDe", + { + "name": "OBS::w32-pthreads", + "requires": "OS_WINDOWS" + }, + "OBS::native-test-cmocka" + ] + } + }, + "tests": { + "test_encoder_update": { + "target": "test_encoder_update", + "command": [ + "${target}" + ] + } + } +} diff --git a/test/cmocka/test_encoder_update.c b/test/cmocka/test_encoder_update.c new file mode 100644 index 0000000000..219aa84979 --- /dev/null +++ b/test/cmocka/test_encoder_update.c @@ -0,0 +1,219 @@ +/* Characterize the real obs_encoder_update API without live media or codec threads. */ +#include +#include +#include +#include +#include +#include +#include "obs-internal.h" + +struct fixture { + struct obs_encoder encoder; + struct obs_encoder_group group; + unsigned calls; + bool reenter; + long long observed_bitrate; +}; + +static bool update(void *data, obs_data_t *settings) +{ + struct fixture *f = data; + assert_ptr_equal(settings, f->encoder.context.settings); + f->calls++; + f->observed_bitrate = obs_data_get_int(settings, "bitrate"); + if (f->reenter) { + f->reenter = false; + obs_data_t *nested = obs_data_create(); + obs_data_set_int(nested, "bitrate", 3000); + obs_encoder_update(&f->encoder, nested); + obs_data_release(nested); + } + /* obs_encoder_update ignores the codec callback's success result. */ + return false; +} + +static int setup(void **state) +{ + struct fixture *f = calloc(1, sizeof(*f)); + assert_non_null(f); + f->encoder.context.settings = obs_data_create(); + assert_non_null(f->encoder.context.settings); + obs_data_set_int(f->encoder.context.settings, "bitrate", 1000); + obs_data_set_string(f->encoder.context.settings, "retained", "original"); + f->encoder.context.data = f; + f->encoder.info.update = update; + assert_int_equal(pthread_mutex_init(&f->group.mutex, NULL), 0); + *state = f; + return 0; +} + +static int teardown(void **state) +{ + struct fixture *f = *state; + /* Only settings and the group mutex were allocated; no media, registry or codec owns this fixture. */ + obs_data_release(f->encoder.context.settings); + assert_int_equal(pthread_mutex_destroy(&f->group.mutex), 0); + free(f); + return 0; +} + +static void apply(struct fixture *f, long long bitrate) +{ + obs_data_t *settings = obs_data_create(); + obs_data_set_int(settings, "bitrate", bitrate); + obs_data_set_string(settings, "added", "new"); + obs_encoder_update(&f->encoder, settings); + obs_data_release(settings); + assert_int_equal(obs_data_get_int(f->encoder.context.settings, "bitrate"), bitrate); + assert_string_equal(obs_data_get_string(f->encoder.context.settings, "retained"), "original"); + assert_string_equal(obs_data_get_string(f->encoder.context.settings, "added"), "new"); +} + +static void null_encoder(void **state) +{ + struct fixture *f = *state; + obs_encoder_update(NULL, f->encoder.context.settings); + obs_encoder_update(NULL, NULL); + assert_int_equal(f->calls, 0); + assert_int_equal(obs_data_get_int(f->encoder.context.settings, "bitrate"), 1000); +} + +static void settings_only_without_codec_data(void **state) +{ + struct fixture *f = *state; + f->encoder.context.data = NULL; + f->encoder.active = true; + f->encoder.encoder_group = &f->group; + apply(f, 2000); + assert_int_equal(f->calls, 0); + assert_false(f->encoder.reconfigure_requested); + assert_int_equal(f->group.reconfigure_request, 0); + obs_encoder_update(&f->encoder, NULL); + assert_int_equal(obs_data_get_int(f->encoder.context.settings, "bitrate"), 2000); +} + +static void settings_only_without_update_callback(void **state) +{ + struct fixture *f = *state; + f->encoder.info.update = NULL; + f->encoder.active = true; + f->encoder.encoder_group = &f->group; + apply(f, 2000); + assert_int_equal(f->calls, 0); + assert_false(f->encoder.reconfigure_requested); + assert_int_equal(f->group.reconfigure_request, 0); +} + +static void inactive_callback_and_null_settings(void **state) +{ + struct fixture *f = *state; + obs_data_t *original = f->encoder.context.settings; + f->encoder.encoder_group = &f->group; + f->encoder.reconfigure_requested = true; + apply(f, 2000); + assert_int_equal(f->calls, 1); + assert_int_equal(f->observed_bitrate, 2000); + assert_ptr_equal(f->encoder.context.settings, original); + assert_int_equal(f->group.reconfigure_request, 0); + /* Existing pending state is preserved even though the inactive update is immediate. */ + assert_true(f->encoder.reconfigure_requested); + obs_encoder_update(&f->encoder, NULL); + assert_int_equal(f->calls, 2); + assert_int_equal(f->observed_bitrate, 2000); +} + +static void active_ungrouped_defers_and_coalesces(void **state) +{ + struct fixture *f = *state; + f->encoder.active = true; + apply(f, 2000); + assert_true(f->encoder.reconfigure_requested); + apply(f, 2500); + assert_true(f->encoder.reconfigure_requested); + assert_true(f->encoder.active); + assert_int_equal(f->calls, 0); +} + +static void active_group_first_request(void **state) +{ + struct fixture *f = *state; + f->encoder.active = true; + f->encoder.encoder_group = &f->group; + f->group.encoders.num = 2; + f->group.next_pts = 123; + f->group.encoders_updated_next_pts = 1; + f->group.encoders_reconfigured = 1; + f->group.reconfigure_again = true; + apply(f, 2000); + assert_int_equal(f->group.reconfigure_request, 1); + assert_int_equal(f->group.encoders_updated_next_pts, 0); + assert_int_equal(f->group.encoders_reconfigured, 0); + assert_false(f->group.reconfigure_again); + assert_int_equal(f->group.next_pts, 123); + assert_int_equal(f->encoder.last_handled_reconfigure_request, 0); + assert_false(f->encoder.reconfigure_requested); + assert_int_equal(f->calls, 0); + assert_int_equal(pthread_mutex_trylock(&f->group.mutex), 0); + assert_int_equal(pthread_mutex_unlock(&f->group.mutex), 0); +} + +static void active_group_pending_then_completed(void **state) +{ + struct fixture *f = *state; + f->encoder.active = true; + f->encoder.encoder_group = &f->group; + f->group.encoders.num = 2; + f->group.reconfigure_request = 4; + f->group.next_pts = 456; + f->group.encoders_updated_next_pts = 2; + f->group.encoders_reconfigured = 1; + f->encoder.last_handled_reconfigure_request = 3; + apply(f, 2000); + assert_int_equal(f->group.reconfigure_request, 4); + assert_int_equal(f->group.encoders_updated_next_pts, 2); + assert_int_equal(f->group.encoders_reconfigured, 1); + assert_false(f->group.reconfigure_again); + f->encoder.last_handled_reconfigure_request = 4; + apply(f, 2100); + assert_int_equal(f->group.reconfigure_request, 4); + assert_true(f->group.reconfigure_again); + f->group.encoders_reconfigured = 2; + apply(f, 2200); + assert_int_equal(f->group.reconfigure_request, 5); + assert_int_equal(f->group.encoders_updated_next_pts, 0); + assert_int_equal(f->group.encoders_reconfigured, 0); + assert_false(f->group.reconfigure_again); + assert_int_equal(f->group.next_pts, 456); + assert_int_equal(f->encoder.last_handled_reconfigure_request, 4); + assert_false(f->encoder.reconfigure_requested); + assert_int_equal(f->calls, 0); +} + +static void inactive_callback_can_reenter(void **state) +{ + struct fixture *f = *state; + f->reenter = true; + obs_data_t *settings = obs_data_create(); + obs_data_set_int(settings, "bitrate", 2000); + obs_encoder_update(&f->encoder, settings); + obs_data_release(settings); + assert_int_equal(f->calls, 2); + assert_int_equal(f->observed_bitrate, 3000); + assert_int_equal(obs_data_get_int(f->encoder.context.settings, "bitrate"), 3000); + assert_false(f->encoder.reconfigure_requested); +} + +int main(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(null_encoder, setup, teardown), + cmocka_unit_test_setup_teardown(settings_only_without_codec_data, setup, teardown), + cmocka_unit_test_setup_teardown(settings_only_without_update_callback, setup, teardown), + cmocka_unit_test_setup_teardown(inactive_callback_and_null_settings, setup, teardown), + cmocka_unit_test_setup_teardown(active_ungrouped_defers_and_coalesces, setup, teardown), + cmocka_unit_test_setup_teardown(active_group_first_request, setup, teardown), + cmocka_unit_test_setup_teardown(active_group_pending_then_completed, setup, teardown), + cmocka_unit_test_setup_teardown(inactive_callback_can_reenter, setup, teardown), + }; + return cmocka_run_group_tests(tests, NULL, NULL); +} From 21a56db47220724ce2644047a156c2e5fcc9ba34 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 25 Nov 2026 07:13:26 -0800 Subject: [PATCH 2/3] libobs: extract encoder update before group registration (RED, Refs #5687) --- libobs/obs-encoder-update.c.h | 51 +++++++++++++++++++++++++++++++++++ libobs/obs-encoder.c.h | 51 +++++------------------------------ 2 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 libobs/obs-encoder-update.c.h diff --git a/libobs/obs-encoder-update.c.h b/libobs/obs-encoder-update.c.h new file mode 100644 index 0000000000..16b4654efe --- /dev/null +++ b/libobs/obs-encoder-update.c.h @@ -0,0 +1,51 @@ +#include "libobs/build/libobs.pch.h" + +#define encoder_active(encoder) os_atomic_load_bool(&encoder->active) + +/* Private group-state copy seams; the encoder core owns their implementations. */ +struct obs_encoder_group_reconfig group_reconfig_get(const struct obs_encoder_group *group); +void group_reconfig_set(struct obs_encoder_group *group, const struct obs_encoder_group_reconfig *reconfig); + +void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings) +{ + if (!obs_encoder_valid(encoder, "obs_encoder_update")) + return; + + obs_data_apply(encoder->context.settings, settings); + + // Encoder isn't initialized yet, only apply changes to settings + if (!encoder->context.data) + return; + + // Encoder doesn't support updates + if (!encoder->info.update) + return; + + if (!encoder_active(encoder)) { + /* Timed for the source profiler (#6085) */ + const uint64_t start = obs_settings_profiler_begin(); + encoder->info.update(encoder->context.data, encoder->context.settings); + obs_encoder_settings_profiler_end(encoder, SOURCE_PROFILER_SETTINGS_UPDATE, start); + return; + } + + /* If the encoder is active we defer the update as it may not be reentrant. Setting reconfigure_requested to + * true makes the changes apply at the next possible moment in the encoder / GPU encoder thread. + */ + if (!encoder->encoder_group) { + encoder->reconfigure_requested = true; + return; + } + + /* Encoder groups need slightly more special handling since encoders generally start new GOPs/insert IDR frames + * when reconfigured, so we need to reconfigure them all on the same frame. + */ + struct obs_encoder_group *group = encoder->encoder_group; + pthread_mutex_lock(&group->mutex); + struct obs_encoder_group_reconfig reconfig = group_reconfig_get(group); + obs_encoder_group_reconfig_update(&reconfig, group->encoders.num, encoder->last_handled_reconfigure_request); + group_reconfig_set(group, &reconfig); + pthread_mutex_unlock(&group->mutex); +} + +#undef encoder_active diff --git a/libobs/obs-encoder.c.h b/libobs/obs-encoder.c.h index 6a64f50b92..e1a5b699a2 100644 --- a/libobs/obs-encoder.c.h +++ b/libobs/obs-encoder.c.h @@ -308,7 +308,11 @@ static void maybe_set_up_gpu_rescale(struct obs_encoder *encoder) /* The reconfigure fields of the group and the encoder, copied in and out * around the obs-encoder-group-reconfig.h calls under the group mutex. */ -static inline struct obs_encoder_group_reconfig group_reconfig_get(const struct obs_encoder_group *group) +/* Private seams shared with the extracted update operation. */ +struct obs_encoder_group_reconfig group_reconfig_get(const struct obs_encoder_group *group); +void group_reconfig_set(struct obs_encoder_group *group, const struct obs_encoder_group_reconfig *reconfig); + +struct obs_encoder_group_reconfig group_reconfig_get(const struct obs_encoder_group *group) { struct obs_encoder_group_reconfig reconfig; @@ -320,8 +324,7 @@ static inline struct obs_encoder_group_reconfig group_reconfig_get(const struct return reconfig; } -static inline void group_reconfig_set(struct obs_encoder_group *group, - const struct obs_encoder_group_reconfig *reconfig) +void group_reconfig_set(struct obs_encoder_group *group, const struct obs_encoder_group_reconfig *reconfig) { group->reconfigure_request = reconfig->reconfigure_request; group->next_pts = reconfig->next_pts; @@ -468,48 +471,6 @@ struct obs_encoder_interleave_info obs_encoder_interleave_info(const obs_encoder return info; } -void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings) -{ - if (!obs_encoder_valid(encoder, "obs_encoder_update")) - return; - - obs_data_apply(encoder->context.settings, settings); - - // Encoder isn't initialized yet, only apply changes to settings - if (!encoder->context.data) - return; - - // Encoder doesn't support updates - if (!encoder->info.update) - return; - - if (!encoder_active(encoder)) { - /* Timed for the source profiler (#6085) */ - const uint64_t start = obs_settings_profiler_begin(); - encoder->info.update(encoder->context.data, encoder->context.settings); - obs_encoder_settings_profiler_end(encoder, SOURCE_PROFILER_SETTINGS_UPDATE, start); - return; - } - - /* If the encoder is active we defer the update as it may not be reentrant. Setting reconfigure_requested to - * true makes the changes apply at the next possible moment in the encoder / GPU encoder thread. - */ - if (!encoder->encoder_group) { - encoder->reconfigure_requested = true; - return; - } - - /* Encoder groups need slightly more special handling since encoders generally start new GOPs/insert IDR frames - * when reconfigured, so we need to reconfigure them all on the same frame. - */ - struct obs_encoder_group *group = encoder->encoder_group; - pthread_mutex_lock(&group->mutex); - struct obs_encoder_group_reconfig reconfig = group_reconfig_get(group); - obs_encoder_group_reconfig_update(&reconfig, group->encoders.num, encoder->last_handled_reconfigure_request); - group_reconfig_set(group, &reconfig); - pthread_mutex_unlock(&group->mutex); -} - static THREAD_LOCAL bool can_reroute = false; static inline bool obs_encoder_initialize_internal(obs_encoder_t *encoder) From 3c52269288d3fa871effdd8475f7002e985a8573 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 25 Nov 2026 07:13:29 -0800 Subject: [PATCH 3/3] libobs: register encoder update extraction (GREEN, Refs #5687) Client-Checks: {"checks":{"base":"8a8e7b63feb4fce649904a2bd30152463438d087","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-output+.h.c","libobs/obs-encoder-update.c.h","libobs/obs-encoder.c.h","test/cmocka/build/test-graph.json","test/cmocka/test_encoder_update.c"],"head":"bf9a196dbb15fd057a16e86fa6482f4837e92f36","tools":{"orchestrator-python":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]","schema-dependencies":"3.13.15 (main, Aug 14 2026, 15:34:59) [Clang 22.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21503\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ISO8859X Regexps Automata RelaxNG Schemas Modules Debug"},"tracked-digest":"c1708ae86e7e2e36645ca0d08bdb844812457a29de8b7f8a7f45ad0504c0c8ee","tree":"1eb5d9eec784183a20179da822779e6f094ec21a"}} Ci-Attestation: {"at":1795677944,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":145,"stamp":"6f0686633ba47f88dcba049161eaa2f9","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} Ci-Attestation: {"at":1795677944,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":145,"stamp":"71a962dedf2e81748edde43b654f0635","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} Ci-Attestation: {"at":1795677944,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":145,"stamp":"bb758ed3be16529f462dca1f1ba11e57","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} Ci-Attestation: {"at":1795677944,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":145,"stamp":"7c72111a0bdfbccd5fba4447e3e18f03","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} Ci-Attestation: {"at":1796411309,"gate":"general/all/client-lint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"906d7ae50b712736b61589cdd0e086ae","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1795677944,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":145,"stamp":"fa69562ef3b5518dd318d612bc7819e6","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} Ci-Attestation: {"at":1796411311,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"349abecbdbd6364cba03071b0939003b","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411311,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"b7a5b18925d95b641d6f8b162ddc00ef","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411310,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"a4c65dbcbc35a9a8bc1c48bcd7e0c806","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411310,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"579fa7882227b5ab226d956ebfeca0b9","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411309,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"4316ac0da9bea2f23f05069b210b21ab","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411310,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"e09c2b7f4da3be2a7d4b171274d240ef","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411311,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"508dfd4fe94c6dae334b1fe998ef7052","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411311,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"33a1aca5c28d01eb3c3e7ad4a4b62554","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411310,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"1727dc2494011b108984eed3ff42dcb7","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411310,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"0392b5c0cd884189696d4b0bd09fcdfe","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411309,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"23a7296a55ea12313eded34bd3b42b0f","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1796411309,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"bc53665c4e519b701ae9d7d20a71445e3c74bc46919e6e4a72bd7a10dc483ea9","lane":"client-lint","parents":["21a56db47220724ce2644047a156c2e5fcc9ba34"],"secs":28,"stamp":"aa68337482ad2933b7de21fd94a732b2","tree":"4ed4fb76ef96c9332c53d92f0cdc7f9b41178c5b","v":1,"via":"run"} Ci-Attestation: {"at":1795678316,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"fe1e579e4ffe0014056c27f5bdbe98539e1e2cedc17a3dbcf7ae2bd1d2e446d4","lane":"client-test-x86_64-unknown-linux-gnu","parents":["1151c383cd7aecab9f8636be845c97488f8e1781"],"secs":370,"stamp":"759550568c84729feeb54ed2915f9cf1","tree":"1eb5d9eec784183a20179da822779e6f094ec21a","v":1,"via":"run"} --- libobs/build/libobs.core-output+.h.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libobs/build/libobs.core-output+.h.c b/libobs/build/libobs.core-output+.h.c index e7b5233e1b..d1c8c726fe 100644 --- a/libobs/build/libobs.core-output+.h.c +++ b/libobs/build/libobs.core-output+.h.c @@ -43,6 +43,7 @@ #include "libobs/obs-encoder-settings-fields.c.h" #include "libobs/obs-encoder-state-queries-fields.c.h" #include "libobs/obs-encoder-type-info-fields.c.h" +#include "libobs/obs-encoder-update.c.h" #include "libobs/obs-encoder-video-tex-active-fields.c.h" #include "libobs/obs-encoder-weak-refs-fields.c.h" #include "libobs/obs-encoder.c.h"