Skip to content

Commit a95e156

Browse files
authored
Multiple inputs option (#100)
* Add multiple inputs dialogs and widgets * Add data for inputs * chore: Refactor UI components and fix URL source callbacks * Refactor UI components and add mapping data * Refactor UI components and fix URL source callbacks * chore: Bump version to 0.3.2
1 parent a665e26 commit a95e156

21 files changed

+866
-489
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ target_sources(
8080
src/ui/RequestBuilder.cpp
8181
src/ui/text-render-helper.cpp
8282
src/ui/outputmapping.cpp
83+
src/ui/InputsDialog.cpp
84+
src/ui/InputWidget.cpp
85+
src/ui/obs-ui-utils.cpp
8386
src/url-source-callbacks.cpp
8487
src/url-source-info.c
8588
src/url-source-thread.cpp

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}
4646
},
4747
"name": "obs-urlsource",
48-
"version": "0.3.1",
48+
"version": "0.3.2",
4949
"author": "Roy Shilkrot",
5050
"website": "https://github.com/occ-ai/obs-urlsource",
5151
"email": "roy.shil@gmail.com",

src/mapping-data.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,36 @@ output_mapping_data deserialize_output_mapping_data(const std::string &data)
3232
}
3333
return result;
3434
}
35+
36+
nlohmann::json serialize_input_mapping_data(const inputs_data &data)
37+
{
38+
nlohmann::json j;
39+
for (const auto &input : data) {
40+
nlohmann::json j_input;
41+
j_input["source"] = input.source;
42+
j_input["no_empty"] = input.no_empty;
43+
j_input["no_same"] = input.no_same;
44+
j_input["aggregate"] = input.aggregate;
45+
j_input["agg_method"] = input.agg_method;
46+
j_input["resize_method"] = input.resize_method;
47+
j.push_back(j_input);
48+
}
49+
return j;
50+
}
51+
52+
inputs_data deserialize_input_mapping_data(const std::string &data)
53+
{
54+
inputs_data result;
55+
nlohmann::json j = nlohmann::json::parse(data);
56+
for (const auto &j_input : j) {
57+
input_data input;
58+
input.source = j_input.value("source", "");
59+
input.no_empty = j_input.value("no_empty", false);
60+
input.no_same = j_input.value("no_same", false);
61+
input.aggregate = j_input.value("aggregate", false);
62+
input.agg_method = j_input.value("agg_method", -1);
63+
input.resize_method = j_input.value("resize_method", "");
64+
result.push_back(input);
65+
}
66+
return result;
67+
}

src/mapping-data.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <string>
55
#include <vector>
66

7+
#include <nlohmann/json.hpp>
8+
79
const std::string none_internal_rendering = "None / Internal rendering";
810

911
struct output_mapping {
@@ -21,4 +23,21 @@ struct output_mapping_data {
2123
std::string serialize_output_mapping_data(const output_mapping_data &data);
2224
output_mapping_data deserialize_output_mapping_data(const std::string &data);
2325

26+
struct input_data {
27+
std::string source;
28+
bool no_empty = false;
29+
bool no_same = false;
30+
bool aggregate = false;
31+
int agg_method = -1;
32+
std::string resize_method;
33+
std::string last_obs_text_source_value;
34+
std::string aggregate_to_empty_buffer;
35+
uint64_t agg_buffer_begin_ts;
36+
};
37+
38+
typedef std::vector<input_data> inputs_data;
39+
40+
nlohmann::json serialize_input_mapping_data(const inputs_data &data);
41+
inputs_data deserialize_input_mapping_data(const std::string &data);
42+
2443
#endif // MAPPING_DATA_H

src/obs-source-util.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,14 @@ std::string convert_rgba_buffer_to_png_base64(const std::vector<uint8_t> &rgba,
131131

132132
return escaped;
133133
}
134+
135+
std::string get_source_name_without_prefix(const std::string &source_name)
136+
{
137+
if (source_name.size() > 0 && source_name[0] == '(') {
138+
size_t end = source_name.find(')');
139+
if (end != std::string::npos && end + 2 < source_name.size()) {
140+
return source_name.substr(end + 2);
141+
}
142+
}
143+
return source_name;
144+
}

src/obs-source-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ inline bool is_valid_output_source_name(const char *output_source_name)
4747
strcmp(output_source_name, "(null)") != 0 && strcmp(output_source_name, "") != 0;
4848
}
4949

50+
std::string get_source_name_without_prefix(const std::string &source_name);
51+
5052
#endif // OBS_SOURCE_UTIL_H

0 commit comments

Comments
 (0)