diff --git a/addons/gdcef/demos/2D/CEF.gd b/addons/gdcef/demos/2D/CEF.gd index ec7f12d..5e37745 100644 --- a/addons/gdcef/demos/2D/CEF.gd +++ b/addons/gdcef/demos/2D/CEF.gd @@ -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. @@ -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 diff --git a/addons/gdcef/demos/3D/GUI.gd b/addons/gdcef/demos/3D/GUI.gd index dc61440..7eeb2ba 100644 --- a/addons/gdcef/demos/3D/GUI.gd +++ b/addons/gdcef/demos/3D/GUI.gd @@ -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. diff --git a/addons/gdcef/demos/HelloCEF/Control.gd b/addons/gdcef/demos/HelloCEF/Control.gd index 10919bb..185025d 100644 --- a/addons/gdcef/demos/HelloCEF/Control.gd +++ b/addons/gdcef/demos/HelloCEF/Control.gd @@ -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. diff --git a/addons/gdcef/doc/API.md b/addons/gdcef/doc/API.md index 8484120..105983c 100644 --- a/addons/gdcef/doc/API.md +++ b/addons/gdcef/doc/API.md @@ -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. diff --git a/addons/gdcef/gdcef/src/gdcef.cpp b/addons/gdcef/gdcef/src/gdcef.cpp index c181426..73d765b 100644 --- a/addons/gdcef/gdcef/src/gdcef.cpp +++ b/addons/gdcef/gdcef/src/gdcef.cpp @@ -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 @@ -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"); + } } diff --git a/addons/gdcef/gdcef/src/gdcef.hpp b/addons/gdcef/gdcef/src/gdcef.hpp index 54b6403..176d1d4 100644 --- a/addons/gdcef/gdcef/src/gdcef.hpp +++ b/addons/gdcef/gdcef/src/gdcef.hpp @@ -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)