Skip to content

Commit

Permalink
Allow accessing to the camera and microphones #49
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Apr 5, 2024
1 parent 33f7120 commit a47b4b9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addons/gdcef/demos/2D/CEF.gd
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ func _ready():
# {log_severity", "warning"}
# {"remote_debugging_port", 7777}
# {"exception_stack_size", 5}
# {"enable_media_stream", false}
#
# Configurate CEF. In incognito mode cache directories not used and in-memory
# caches are used instead and no data is persisted to disk.
Expand All @@ -288,7 +289,12 @@ func _ready():
# will use ProjectSettings.globalize_path but exported projects don't support globalize_path:
# https://docs.godotengine.org/en/3.5/classes/class_projectsettings.html#class-projectsettings-method-globalize-path
var resource_path = "res://cef_artifacts/"
if !$CEF.initialize({"artifacts":resource_path, "incognito":true, "locale":"en-US"}):
if !$CEF.initialize({
"artifacts":resource_path,
"incognito":true,
"locale":"en-US",
"enable_media_stream": true
}):
$Panel/VBox/HBox2/Info.set_text($CEF.get_error())
push_error($CEF.get_error())
return
Expand Down
1 change: 1 addition & 0 deletions addons/gdcef/demos/3D/GUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func _ready():
# {log_severity", "warning"}
# {"remote_debugging_port", 7777}
# {"exception_stack_size", 5}
# {"enable_media_stream", false}
#
# Configurate CEF. In incognito mode cache directories not used and in-memory
# caches are used instead and no data is persisted to disk.
Expand Down
1 change: 1 addition & 0 deletions addons/gdcef/demos/HelloCEF/Control.gd
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func _ready():
# {log_severity", "warning"}
# {"remote_debugging_port", 7777}
# {"exception_stack_size", 5}
# {"enable_media_stream", false}
#
# Configurate CEF. In incognito mode cache directories not used and in-memory
# caches are used instead and no data is persisted to disk.
Expand Down
1 change: 1 addition & 0 deletions addons/gdcef/doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ the behavior for CEF. Default values are:
- `{"remote_debugging_port":7777}` : the port for debbuging CEF.
- `{"exception_stack_size":5}`
- `{"locale":"en-US"}` : Select your language.
- `{"enable_media_stream", false}` : allow CEF to access to your camera and microphones.

See [cef_types.h](../thirdparty/cef_binary/include/internal/cef_types.h) for more information about settings.

Expand Down
9 changes: 9 additions & 0 deletions addons/gdcef/gdcef/src/gdcef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ bool GDCef::initialize(godot::Dictionary config)
// Since we cannot configure CEF from the command line main(argc, argv)
// because we cannot access to it, we have to configure CEF directly.
configureCEF(folder, m_cef_settings, m_window_info, config);
m_enable_media_stream = getConfig(config, "enable_media_stream", false);

// This function should be called on the main application thread to
// initialize the CEF browser process. A return value of true indicates
Expand Down Expand Up @@ -541,4 +542,12 @@ void GDCef::Impl::OnBeforeCommandLineProcessing(const CefString& ProcessType,

if (command_line == nullptr)
return ;

// Allow accessing to the camera and microphones.
// See https://github.com/Lecrapouille/gdcef/issues/49
if (m_owner.m_enable_media_stream)
{
GDCEF_DEBUG_VAL("Allow enable-media-stream");
command_line->AppendSwitch("enable-media-stream");
}
}
2 changes: 2 additions & 0 deletions addons/gdcef/gdcef/src/gdcef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ class GDCef : public godot::Node
bool m_initialized = false;
//! \brief Hold last error messages
mutable std::stringstream m_error;
//! \brief Allow accessing to camera and microphones
bool m_enable_media_stream = false;
};

# if !defined(_WIN32)
Expand Down

0 comments on commit a47b4b9

Please sign in to comment.