Skip to content

Commit f7ebe6f

Browse files
committed
chore: Update version to 0.3.4 and add "Save to source settings" option in output mapping
1 parent 9da372d commit f7ebe6f

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

buildspec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
},
3939
"name": "obs-urlsource",
40-
"version": "0.3.3",
40+
"version": "0.3.4",
4141
"author": "Roy Shilkrot",
4242
"website": "https://github.com/occ-ai/obs-urlsource",
4343
"email": "roy.shil@gmail.com",

src/mapping-data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <nlohmann/json.hpp>
88

99
const std::string none_internal_rendering = "None / Internal rendering";
10+
const std::string save_to_setting = "Save to source settings";
1011

1112
struct output_mapping {
1213
std::string name;

src/ui/outputmapping.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ QComboBox *OutputMapping::createSourcesComboBox()
133133
QComboBox *comboBox = new QComboBox(this);
134134
// add "Internal Renderer" to the comboBox
135135
comboBox->addItem(QString::fromStdString(none_internal_rendering));
136+
// add "Save to source settings" to the comboBox
137+
comboBox->addItem(QString::fromStdString(save_to_setting));
136138
// add all text and media sources to the comboBox
137139
obs_enum_sources(add_sources_to_combobox, comboBox);
138140
// connect comboBox to update_handler

src/ui/outputmapping.ui

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>515</width>
10-
<height>398</height>
9+
<width>457</width>
10+
<height>387</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -147,6 +147,19 @@ Use {{body}} variable for unparsed object/array representation of the entire res
147147
</property>
148148
</widget>
149149
</item>
150+
<item>
151+
<widget class="QLabel" name="label_3">
152+
<property name="text">
153+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Learn More about &lt;a href=&quot;https://doc.qt.io/qt-6/richtext-html-subset.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;supported HTML and CSS&lt;/span&gt;&lt;/a&gt;, and &lt;a href=&quot;https://github.com/pantor/inja&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;advanced templating&lt;/span&gt;&lt;/a&gt; functions like loops.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
154+
</property>
155+
<property name="textFormat">
156+
<enum>Qt::RichText</enum>
157+
</property>
158+
<property name="openExternalLinks">
159+
<bool>true</bool>
160+
</property>
161+
</widget>
162+
</item>
150163
<item>
151164
<widget class="QDialogButtonBox" name="buttonBox">
152165
<property name="orientation">

src/url-source-callbacks.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,27 @@ void output_with_mapping(const request_data_handler_response &response, struct u
236236
}
237237

238238
if (is_valid_output_source_name(mapping.output_source.c_str()) &&
239-
mapping.output_source != none_internal_rendering) {
239+
mapping.output_source != none_internal_rendering &&
240+
mapping.output_source != save_to_setting) {
240241
// If an output source is selected - use it for rendering
241242
setTextCallback(text, mapping);
242243
} else {
243-
any_internal_rendering = true;
244-
render_internal(text, usd, mapping);
244+
if (mapping.output_source == save_to_setting) {
245+
// If the output source is set to save to settings - save the text to the source settings
246+
obs_data_t *source_settings = obs_source_get_settings(usd->source);
247+
if (source_settings == nullptr) {
248+
obs_log(LOG_ERROR, "Failed to get settings for source");
249+
} else {
250+
obs_data_set_string(source_settings, "output",
251+
text.c_str());
252+
obs_source_update(usd->source, source_settings);
253+
obs_data_release(source_settings);
254+
}
255+
} else {
256+
// render the text internally
257+
any_internal_rendering = true;
258+
render_internal(text, usd, mapping);
259+
}
245260
} // end if not text source
246261
}
247262

0 commit comments

Comments
 (0)