Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple inputs option #100

Merged
merged 6 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ target_sources(
src/ui/RequestBuilder.cpp
src/ui/text-render-helper.cpp
src/ui/outputmapping.cpp
src/ui/InputsDialog.cpp
src/ui/InputWidget.cpp
src/ui/obs-ui-utils.cpp
src/url-source-callbacks.cpp
src/url-source-info.c
src/url-source-thread.cpp
Expand Down
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}
},
"name": "obs-urlsource",
"version": "0.3.1",
"version": "0.3.2",
"author": "Roy Shilkrot",
"website": "https://github.com/occ-ai/obs-urlsource",
"email": "[email protected]",
Expand Down
33 changes: 33 additions & 0 deletions src/mapping-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,36 @@ output_mapping_data deserialize_output_mapping_data(const std::string &data)
}
return result;
}

nlohmann::json serialize_input_mapping_data(const inputs_data &data)
{
nlohmann::json j;
for (const auto &input : data) {
nlohmann::json j_input;
j_input["source"] = input.source;
j_input["no_empty"] = input.no_empty;
j_input["no_same"] = input.no_same;
j_input["aggregate"] = input.aggregate;
j_input["agg_method"] = input.agg_method;
j_input["resize_method"] = input.resize_method;
j.push_back(j_input);
}
return j;
}

inputs_data deserialize_input_mapping_data(const std::string &data)
{
inputs_data result;
nlohmann::json j = nlohmann::json::parse(data);
for (const auto &j_input : j) {
input_data input;
input.source = j_input.value("source", "");
input.no_empty = j_input.value("no_empty", false);
input.no_same = j_input.value("no_same", false);
input.aggregate = j_input.value("aggregate", false);
input.agg_method = j_input.value("agg_method", -1);
input.resize_method = j_input.value("resize_method", "");
result.push_back(input);
}
return result;
}
19 changes: 19 additions & 0 deletions src/mapping-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <string>
#include <vector>

#include <nlohmann/json.hpp>

const std::string none_internal_rendering = "None / Internal rendering";

struct output_mapping {
Expand All @@ -21,4 +23,21 @@ struct output_mapping_data {
std::string serialize_output_mapping_data(const output_mapping_data &data);
output_mapping_data deserialize_output_mapping_data(const std::string &data);

struct input_data {
std::string source;
bool no_empty = false;
bool no_same = false;
bool aggregate = false;
int agg_method = -1;
std::string resize_method;
std::string last_obs_text_source_value;
std::string aggregate_to_empty_buffer;
uint64_t agg_buffer_begin_ts;
};

typedef std::vector<input_data> inputs_data;

nlohmann::json serialize_input_mapping_data(const inputs_data &data);
inputs_data deserialize_input_mapping_data(const std::string &data);

#endif // MAPPING_DATA_H
11 changes: 11 additions & 0 deletions src/obs-source-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,14 @@ std::string convert_rgba_buffer_to_png_base64(const std::vector<uint8_t> &rgba,

return escaped;
}

std::string get_source_name_without_prefix(const std::string &source_name)
{
if (source_name.size() > 0 && source_name[0] == '(') {
size_t end = source_name.find(')');
if (end != std::string::npos && end + 2 < source_name.size()) {
return source_name.substr(end + 2);
}
}
return source_name;
}
2 changes: 2 additions & 0 deletions src/obs-source-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ inline bool is_valid_output_source_name(const char *output_source_name)
strcmp(output_source_name, "(null)") != 0 && strcmp(output_source_name, "") != 0;
}

std::string get_source_name_without_prefix(const std::string &source_name);

#endif // OBS_SOURCE_UTIL_H
Loading
Loading