diff --git a/source/ffmpeg/tools.cpp b/source/ffmpeg/tools.cpp index 597222c2..4e454177 100644 --- a/source/ffmpeg/tools.cpp +++ b/source/ffmpeg/tools.cpp @@ -209,8 +209,8 @@ bool tools::avoption_exists(const void* obj, std::string_view name) return false; } -void tools::avoption_list_add_entries_unnamed(const void* obj, std::string_view unit, obs_property_t* prop, - std::function filter) +void tools::avoption_list_add_entries(const void* obj, std::string_view unit, + std::function inserter) { for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) { // Skip all irrelevant options. @@ -225,38 +225,11 @@ void tools::avoption_list_add_entries_unnamed(const void* obj, std::string_view if (opt->flags & AV_OPT_FLAG_DEPRECATED) continue; - if (filter && filter(opt)) - continue; - - // Generate name and add to list. - obs_property_list_add_int(prop, opt->name, opt->default_val.i64); - } -} - -void tools::avoption_list_add_entries(const void* obj, std::string_view unit, obs_property_t* prop, - std::string_view prefix, std::function filter) -{ - for (const AVOption* opt = nullptr; (opt = av_opt_next(obj, opt)) != nullptr;) { - // Skip all irrelevant options. - if (!opt->unit) - continue; - if (opt->unit != unit) - continue; - if (opt->name == unit) - continue; - - // Skip any deprecated options. - if (opt->flags & AV_OPT_FLAG_DEPRECATED) - continue; - - // Skip based on filter function. - if (filter && filter(opt)) - continue; - - // Generate name and add to list. - char buffer[1024]; - snprintf(buffer, sizeof(buffer), "%s.%s\0", prefix.data(), opt->name); - obs_property_list_add_int(prop, D_TRANSLATE(buffer), opt->default_val.i64); + if (inserter) { + inserter(opt); + } else { + break; + } } } diff --git a/source/ffmpeg/tools.hpp b/source/ffmpeg/tools.hpp index 51d06e96..584dc7a1 100644 --- a/source/ffmpeg/tools.hpp +++ b/source/ffmpeg/tools.hpp @@ -85,10 +85,7 @@ namespace streamfx::ffmpeg::tools { const char* avoption_name_from_unit_value(const void* obj, std::string_view unit, int64_t value); - void avoption_list_add_entries_unnamed(const void* obj, std::string_view unit, obs_property_t* prop, - std::function filter = nullptr); - - void avoption_list_add_entries(const void* obj, std::string_view unit, obs_property_t* prop, - std::string_view prefix, std::function filter = nullptr); + void avoption_list_add_entries(const void* obj, std::string_view unit, + std::function inserter = nullptr); } // namespace streamfx::ffmpeg::tools