Skip to content

Commit

Permalink
awin-dshow: Check for custom placeholder.png file
Browse files Browse the repository at this point in the history
This will enabled the user have a custom placeholder.png file
that will not get replaced every time OBS is updated. A similar
cahnge has already been made to mac-virtualcam. That change plus
this change will make it possible for a UI plugin to pprovide a
simple interface for the user to select a custom PNG file.
https://github.com/pedanticdan/obs-placeholder
  • Loading branch information
pedanticdan committed Apr 11, 2021
1 parent e93632c commit f71c890
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 56 deletions.
3 changes: 2 additions & 1 deletion CI/flatpak/com.obsproject.Studio.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@
"-DUSE_XDG=ON",
"-DDISABLE_ALSA=ON",
"-DENABLE_PULSEAUDIO=ON",
"-DWITH_RTMPS=ON"
"-DWITH_RTMPS=ON",
"-DBUILD_BROWSER=OFF"
],
"sources": [
{
Expand Down
2 changes: 1 addition & 1 deletion UI/context-bar-controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void SourceToolbar::SetUndoProperties(obs_source_t *source)

obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());
main->SetCurrentScene(scene_source);
main->SetCurrentScene(scene_source, true);
obs_source_release(scene_source);

obs_data_release(settings);
Expand Down
4 changes: 2 additions & 2 deletions UI/source-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ void SourceTreeItem::ExitEditMode(bool save)

obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());
main->SetCurrentScene(scene_source);
main->SetCurrentScene(scene_source, true);
obs_source_release(scene_source);
};

Expand All @@ -424,7 +424,7 @@ void SourceTreeItem::ExitEditMode(bool save)

obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());
main->SetCurrentScene(scene_source);
main->SetCurrentScene(scene_source, true);
obs_source_release(scene_source);
};

Expand Down
12 changes: 6 additions & 6 deletions UI/window-basic-filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
obs_source_t *ssource =
obs_get_source_by_name(scene_name.c_str());
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_data_t *dat =
Expand All @@ -599,7 +599,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
obs_source_t *ssource =
obs_get_source_by_name(scene_name.c_str());
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_data_t *dat =
Expand Down Expand Up @@ -829,7 +829,7 @@ void OBSBasicFilters::on_removeEffectFilter_clicked()
scene_name.c_str());
reinterpret_cast<OBSBasic *>(
App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_data_t *dat =
Expand All @@ -854,7 +854,7 @@ void OBSBasicFilters::on_removeEffectFilter_clicked()
scene_name.c_str());
reinterpret_cast<OBSBasic *>(
App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_data_t *dat =
Expand Down Expand Up @@ -1134,7 +1134,7 @@ void OBSBasicFilters::FilterNameEdited(QWidget *editor, QListWidget *list)
obs_source_t *ssource =
obs_get_source_by_name(scene_name.c_str());
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_source_t *source =
Expand All @@ -1151,7 +1151,7 @@ void OBSBasicFilters::FilterNameEdited(QWidget *editor, QListWidget *list)
obs_source_t *ssource =
obs_get_source_by_name(scene_name.c_str());
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(ssource);
->SetCurrentScene(ssource, true);
obs_source_release(ssource);

obs_source_t *source =
Expand Down
2 changes: 2 additions & 0 deletions UI/window-basic-main-transitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ void OBSBasic::SetCurrentScene(OBSSource scene, bool force)
}
}

UpdateContextBar(true);

if (scene) {
bool userSwitched = (!force && !disableSaving);
blog(LOG_INFO, "%s to scene '%s'",
Expand Down
8 changes: 4 additions & 4 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3739,7 +3739,7 @@ void OBSBasic::RemoveSelectedScene()

obs_source_t *scene_source = sources.back();
OBSScene scene = obs_scene_from_source(scene_source);
SetCurrentScene(scene);
SetCurrentScene(scene, true);

/* set original index in list box */
ui->scenes->blockSignals(true);
Expand Down Expand Up @@ -4927,7 +4927,7 @@ void OBSBasic::on_actionAddScene_triggered()
auto redo_fn = [this](const std::string &data) {
obs_scene_t *scene = obs_scene_create(data.c_str());
obs_source_t *source = obs_scene_get_source(scene);
SetCurrentScene(source);
SetCurrentScene(source, true);
obs_scene_release(scene);
};
undo_s.add_action(QTStr("Undo.Add").arg(QString(name.c_str())),
Expand All @@ -4952,12 +4952,12 @@ void OBSBasic::ChangeSceneIndex(bool relative, int offset, int invalidIdx)
if (idx == -1 || idx == invalidIdx)
return;

ui->scenes->blockSignals(true);
QListWidgetItem *item = ui->scenes->takeItem(idx);

if (!relative)
idx = 0;

ui->scenes->blockSignals(true);
ui->scenes->insertItem(idx + offset, item);
ui->scenes->setCurrentRow(idx + offset);
item->setSelected(true);
Expand Down Expand Up @@ -7155,7 +7155,7 @@ void undo_redo(const std::string &data)
obs_source_t *source =
obs_get_source_by_name(obs_data_get_string(dat, "scene_name"));
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(source);
->SetCurrentScene(source, true);
obs_source_release(source);
obs_data_release(dat);

Expand Down
2 changes: 1 addition & 1 deletion UI/window-basic-preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
obs_source_t *source = obs_get_source_by_name(
obs_data_get_string(dat, "scene_name"));
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(source);
->SetCurrentScene(source, true);
obs_source_release(source);
obs_data_release(dat);

Expand Down
2 changes: 1 addition & 1 deletion UI/window-basic-properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());

OBSBasic::Get()->SetCurrentScene(source);
OBSBasic::Get()->SetCurrentScene(source, true);

obs_source_release(scene_source);

Expand Down
4 changes: 2 additions & 2 deletions UI/window-basic-source-select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()

obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());
main->SetCurrentScene(scene_source);
main->SetCurrentScene(scene_source, true);
obs_source_release(scene_source);

main->RefreshSources(main->GetCurrentScene());
Expand Down Expand Up @@ -282,7 +282,7 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()

obs_source_t *scene_source =
obs_get_source_by_name(scene_name.c_str());
main->SetCurrentScene(scene_source);
main->SetCurrentScene(scene_source, true);
obs_source_release(scene_source);

main->RefreshSources(main->GetCurrentScene());
Expand Down
5 changes: 3 additions & 2 deletions UI/window-basic-transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ OBSBasicTransform::OBSBasicTransform(OBSBasic *parent)
SetScene(scene);
SetItem(item);

obs_data_t *wrapper = obs_scene_save_transform_states(scene, false);
obs_data_t *wrapper =
obs_scene_save_transform_states(main->GetCurrentScene(), false);
undo_data = std::string(obs_data_get_json(wrapper));

obs_data_release(wrapper);
Expand All @@ -92,7 +93,7 @@ OBSBasicTransform::~OBSBasicTransform()
obs_source_t *source = obs_get_source_by_name(
obs_data_get_string(dat, "scene_name"));
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())
->SetCurrentScene(source);
->SetCurrentScene(source, true);
obs_source_release(source);
obs_data_release(dat);
obs_scene_load_transform_states(data.c_str());
Expand Down
87 changes: 76 additions & 11 deletions libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,7 @@ static void signal_parent(obs_scene_t *parent, const char *command,

struct passthrough {
obs_data_array_t *ids;
obs_data_array_t *scenes_and_groups;
bool all_items;
};

Expand Down Expand Up @@ -2105,22 +2106,60 @@ bool save_transform_states(obs_scene_t *scene, obs_sceneitem_t *item,
obs_data_release(temp);
}

obs_source_t *item_source = obs_sceneitem_get_source(item);

if (obs_source_is_group(item_source)) {
obs_data_t *temp = obs_data_create();
obs_data_array_t *nids = obs_data_array_create();

obs_data_set_string(temp, "scene_name",
obs_source_get_name(item_source));
obs_data_set_bool(temp, "is_group", true);
obs_data_set_string(
temp, "group_parent",
obs_source_get_name(obs_scene_get_source(scene)));

struct passthrough npass = {nids, pass->scenes_and_groups,
pass->all_items};
obs_sceneitem_group_enum_items(item, save_transform_states,
(void *)&npass);

obs_data_set_array(temp, "items", nids);

obs_data_array_push_back(pass->scenes_and_groups, temp);

obs_data_release(temp);
obs_data_array_release(nids);
}

UNUSED_PARAMETER(scene);
return true;
}

obs_data_t *obs_scene_save_transform_states(obs_scene_t *scene, bool all_items)
{
obs_data_t *wrapper = obs_data_create();
obs_data_array_t *scenes_and_groups = obs_data_array_create();
obs_data_array_t *item_ids = obs_data_array_create();
struct passthrough pass = {item_ids, all_items};

obs_scene_enum_items(scene, save_transform_states, (void *)&pass);
obs_data_set_array(wrapper, "item_ids", item_ids);
obs_data_set_string(wrapper, "scene_name",
struct passthrough pass = {item_ids, scenes_and_groups, all_items};

obs_data_t *temp = obs_data_create();

obs_data_set_string(temp, "scene_name",
obs_source_get_name(obs_scene_get_source(scene)));
obs_data_set_bool(temp, "is_group", false);

obs_scene_enum_items(scene, save_transform_states, (void *)&pass);

obs_data_set_array(temp, "items", item_ids);
obs_data_array_push_back(scenes_and_groups, temp);

obs_data_set_array(wrapper, "scenes_and_groups", scenes_and_groups);

obs_data_array_release(item_ids);
obs_data_array_release(scenes_and_groups);
obs_data_release(temp);

return wrapper;
}
Expand Down Expand Up @@ -2155,18 +2194,44 @@ void load_transform_states(obs_data_t *temp, void *vp_scene)
obs_sceneitem_defer_update_end(item);
}

void iterate_scenes_and_groups_transform_states(obs_data_t *data, void *vp)
{
obs_data_array_t *items = obs_data_get_array(data, "items");
obs_source_t *scene_source =
obs_get_source_by_name(obs_data_get_string(data, "scene_name"));
obs_scene_t *scene = obs_scene_from_source(scene_source);

if (obs_data_get_bool(data, "is_group")) {
obs_source_t *parent_source = obs_get_source_by_name(
obs_data_get_string(data, "group_parent"));
obs_scene_t *parent = obs_scene_from_source(parent_source);
obs_sceneitem_t *group = obs_scene_get_group(
parent, obs_data_get_string(data, "scene_name"));
scene = obs_sceneitem_group_get_scene(group);

obs_source_release(parent_source);
}

obs_data_array_enum(items, load_transform_states, (void *)scene);

UNUSED_PARAMETER(vp);

obs_data_array_release(items);
obs_source_release(scene_source);
}

void obs_scene_load_transform_states(const char *data)
{
obs_data_t *dat = obs_data_create_from_json(data);
obs_data_array_t *item_ids = obs_data_get_array(dat, "item_ids");
obs_source_t *source =
obs_get_source_by_name(obs_data_get_string(dat, "scene_name"));
obs_scene_t *scene = obs_scene_from_source(source);
obs_data_array_enum(item_ids, load_transform_states, (void *)scene);

obs_data_array_t *scenes_and_groups =
obs_data_get_array(dat, "scenes_and_groups");

obs_data_array_enum(scenes_and_groups,
iterate_scenes_and_groups_transform_states, NULL);

obs_data_release(dat);
obs_data_array_release(item_ids);
obs_source_release(source);
obs_data_array_release(scenes_and_groups);
}

void obs_sceneitem_select(obs_sceneitem_t *item, bool select)
Expand Down
15 changes: 8 additions & 7 deletions plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@ static bool nvenc_update(void *data, obs_data_t *settings)
"\theight: %d\n"
"\t2-pass: %s\n"
"\tb-frames: %d\n"
"\tpsycho-aq: %d\n"
"\tGPU: %d\n",
rc, bitrate, cqp, enc->context->gop_size, preset, profile,
enc->context->width, enc->context->height,
twopass ? "true" : "false", enc->context->max_b_frames, gpu);
twopass ? "true" : "false", enc->context->max_b_frames, psycho_aq,
gpu);

return nvenc_init_codec(enc);
}
Expand Down Expand Up @@ -578,16 +580,15 @@ obs_properties_t *nvenc_properties_internal(bool ffmpeg)
obs_module_text("NVENC.LookAhead"));
obs_property_set_long_description(
p, obs_module_text("NVENC.LookAhead.ToolTip"));

p = obs_properties_add_bool(
props, "psycho_aq",
obs_module_text("NVENC.PsychoVisualTuning"));
obs_property_set_long_description(
p, obs_module_text("NVENC.PsychoVisualTuning.ToolTip"));
p = obs_properties_add_bool(props, "repeat_headers",
"repeat_headers");
obs_property_set_visible(p, false);
}
p = obs_properties_add_bool(
props, "psycho_aq",
obs_module_text("NVENC.PsychoVisualTuning"));
obs_property_set_long_description(
p, obs_module_text("NVENC.PsychoVisualTuning.ToolTip"));

obs_properties_add_int(props, "gpu", obs_module_text("GPU"), 0, 8, 1);

Expand Down
4 changes: 2 additions & 2 deletions plugins/rtmp-services/data/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"url": "https://obsproject.com/obs2_update/rtmp-services",
"version": 172,
"version": 173,
"files": [
{
"name": "services.json",
"version": 172
"version": 173
}
]
}
6 changes: 6 additions & 0 deletions plugins/rtmp-services/data/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,12 @@
"keyint": 2,
"max video bitrate": 6000,
"max audio bitrate": 320,
"supported resolutions": [
"1280x720",
"852x480",
"480x360"
],
"max fps": 30,
"x264opts": "scenecut=0"
}
},
Expand Down
Loading

0 comments on commit f71c890

Please sign in to comment.