mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-04 22:56:11 -05:00
UI: Just use json directly for service lookups
This commit accomplishes three different things: - Makes it much less difficult to communicate service settings between the UI and the plugin. - Refactors some code and makes it cleaner and easier to modify to our needs (although there is still a lot of work to do on that front because of heavy code duplication issues between auto-config and the stream settings pane). - Significantly reatly reduces the number of times the json file has to be opened and parsed. This also kind of denotes a bit of a failure on the plugin communication aspect. The properties system is too limited and jank for a lot of things we would like to do at times.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "window-basic-auto-config.hpp"
|
||||
#include "window-basic-main.hpp"
|
||||
#include "streaming-helpers.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "obs-app.hpp"
|
||||
|
||||
@@ -19,6 +20,7 @@
|
||||
#define wiz reinterpret_cast<AutoConfig *>(wizard())
|
||||
|
||||
using namespace std;
|
||||
using namespace json11;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -119,28 +121,19 @@ void AutoConfigTestPage::StartRecordingEncoderStage()
|
||||
|
||||
void AutoConfigTestPage::GetServers(std::vector<ServerInfo> &servers)
|
||||
{
|
||||
OBSDataAutoRelease settings = obs_data_create();
|
||||
obs_data_set_string(settings, "service", wiz->serviceName.c_str());
|
||||
Json root = get_services_json();
|
||||
Json service = get_service_from_json(root, wiz->serviceName.c_str());
|
||||
|
||||
obs_properties_t *ppts = obs_get_service_properties("rtmp_common");
|
||||
obs_property_t *p = obs_properties_get(ppts, "service");
|
||||
obs_property_modified(p, settings);
|
||||
auto &json_services = service["servers"].array_items();
|
||||
for (const Json &server : json_services) {
|
||||
const std::string &name = server["name"].string_value();
|
||||
const std::string &url = server["url"].string_value();
|
||||
|
||||
p = obs_properties_get(ppts, "server");
|
||||
size_t count = obs_property_list_item_count(p);
|
||||
servers.reserve(count);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const char *name = obs_property_list_item_name(p, i);
|
||||
const char *server = obs_property_list_item_string(p, i);
|
||||
|
||||
if (wiz->CanTestServer(name)) {
|
||||
ServerInfo info(name, server);
|
||||
if (wiz->CanTestServer(name.c_str())) {
|
||||
ServerInfo info(name, url);
|
||||
servers.push_back(info);
|
||||
}
|
||||
}
|
||||
|
||||
obs_properties_destroy(ppts);
|
||||
}
|
||||
|
||||
static inline void string_depad_key(string &key)
|
||||
|
||||
Reference in New Issue
Block a user