From cb16a2e5471186a5c9b7f1d330838accba407e44 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Wed, 16 Sep 2026 16:24:29 +0800 Subject: [PATCH] feat: enable https camera stream mode --- deps/CMakeLists.txt | 7 +++---- deps/FFMPEG/FFMPEG.cmake | 20 +++++++++++++++++-- src/slic3r/GUI/MediaPlayCtrl.cpp | 5 ++++- src/slic3r/Utils/IPrinterAgent.hpp | 5 +++-- .../PrinterAgentPluginCapability.cpp | 1 + tests/slic3rutils/test_printer_agent.cpp | 4 ++++ 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index db80915ddc..b16b45b16d 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -375,10 +375,6 @@ include(libnoise/libnoise.cmake) include(Draco/Draco.cmake) -include(FFMPEG/FFMPEG.cmake) -include(Assimp/Assimp.cmake) - - # I *think* 1.1 is used for *just* md5 hashing? # 3.1 has everything in the right place, but the md5 funcs used are deprecated # a grep across the repo shows it is used for other things @@ -389,6 +385,9 @@ if(NOT OPENSSL_FOUND) set(OPENSSL_PKG dep_OpenSSL) endif() +include(FFMPEG/FFMPEG.cmake) +include(Assimp/Assimp.cmake) + find_package(LibDataChannel QUIET) set(DATACHANNEL_PKG "") if (NOT LibDataChannel_FOUND) diff --git a/deps/FFMPEG/FFMPEG.cmake b/deps/FFMPEG/FFMPEG.cmake index 2b148ae3f7..01b31f14a7 100644 --- a/deps/FFMPEG/FFMPEG.cmake +++ b/deps/FFMPEG/FFMPEG.cmake @@ -1,5 +1,16 @@ set(_conf_cmd ./configure) +set(_ffmpeg_depends) +set(_ffmpeg_configure_command ${_conf_cmd}) +if (TARGET dep_OpenSSL) + set(_ffmpeg_depends DEPENDS dep_OpenSSL) + set(_ffmpeg_configure_command + ${CMAKE_COMMAND} -E env + "PKG_CONFIG_PATH=${DESTDIR}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}" + ${_conf_cmd} + ) +endif() + if (MSVC) set(_source_dir "${CMAKE_BINARY_DIR}/dep_FFMPEG-prefix/src/dep_FFMPEG") @@ -9,6 +20,7 @@ if (MSVC) set(PREBUILD_HASH_x64 "e65916020ddb9ef84b2666dfbcbfc9b1d67f69d15b4a66db53754637bf2d498c") ExternalProject_Add(dep_FFMPEG + ${_ffmpeg_depends} URL ${PREBUILD_URL_${DEPS_ARCH}} URL_HASH SHA256=${PREBUILD_HASH_${DEPS_ARCH}} DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/FFMPEG @@ -21,6 +33,8 @@ if (MSVC) ) else () + set(_openssl_cmd --enable-openssl) + if (APPLE) set(_minos_cmd "--extra-cflags=-mmacosx-version-min=${DEP_OSX_TARGET}" @@ -52,10 +66,11 @@ else () endif() ExternalProject_Add(dep_FFMPEG + ${_ffmpeg_depends} URL https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.0.3.tar.gz URL_HASH SHA256=DEEDCABE339165214A3637DF4C86A507AEF0D793CF8774FF68735F4737E8DDBC DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/FFMPEG - CONFIGURE_COMMAND ${_conf_cmd} + CONFIGURE_COMMAND ${_ffmpeg_configure_command} ${_cross_cmd} ${_pic_cmd} ${_arch_cmd} @@ -63,13 +78,14 @@ else () "--prefix=${DESTDIR}" ${_link_cmd} ${_minos_cmd} + ${_openssl_cmd} --disable-doc --enable-small --disable-outdevs --disable-filters --enable-filter=*null*,afade,*fifo,*format,*resample,aeval,allrgb,allyuv,atempo,pan,*bars,color,*key,crop,draw*,eq*,framerate,*_qsv,*_vaapi,*v4l2*,hw*,scale,volume,test* --disable-protocols - --enable-protocol=file,fd,pipe,http,rtp,tcp,udp + --enable-protocol=file,fd,pipe,http,https,rtp,tcp,udp --disable-muxers --enable-muxer=rtp --disable-encoders diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 6f1499f701..148cff9a8e 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -184,6 +184,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj) switch (mode) { case CameraStreamMode::http: + case CameraStreamMode::https: case CameraStreamMode::http_snapshot: case CameraStreamMode::rtsp: { std::string machine = obj ? obj->get_dev_id() : ""; @@ -346,6 +347,7 @@ void MediaPlayCtrl::Play() SetStatus(_L("Playing..."), false); return; case CameraStreamMode::http: + case CameraStreamMode::https: case CameraStreamMode::rtsp: if (m_next_retry.IsValid() && wxDateTime::Now() < m_next_retry) return; @@ -565,13 +567,14 @@ void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2) } switch (current_mode()) { case CameraStreamMode::http: + case CameraStreamMode::https: case CameraStreamMode::http_snapshot: { const bool snapshot = current_mode() == CameraStreamMode::http_snapshot; if (m_last_state != MEDIASTATE_IDLE) { if (snapshot) { if (m_web_ctrl) m_web_ctrl->Stop(); } else { - // http mode plays through the ffmpeg backend (m_media_ctrl), not + // http/https mode plays through the ffmpeg backend (m_media_ctrl), not // the webview - tear its read thread down too, otherwise it keeps // pulling and painting frames after the UI says "Video Stopped". boost::unique_lock lock(m_mutex); diff --git a/src/slic3r/Utils/IPrinterAgent.hpp b/src/slic3r/Utils/IPrinterAgent.hpp index 242175cb24..ebf1a78a7c 100644 --- a/src/slic3r/Utils/IPrinterAgent.hpp +++ b/src/slic3r/Utils/IPrinterAgent.hpp @@ -50,6 +50,7 @@ enum class FilamentSyncMode { enum class CameraStreamMode { none = 0, http, // LAN or Cloud + https, // LAN or Cloud over TLS rtsp, // LAN only webrtc, // Cloud only http_snapshot // HTTP endpoint returning one image per request @@ -330,7 +331,7 @@ public: /** * Get the camera stream mode for this agent. This value can be deterministic and derived at - * runtime if the printer supports multiple camera stream modes. E.g. LAN => HTTP/RTSP, Cloud => WebRTC. + * runtime if the printer supports multiple camera stream modes. E.g. LAN => HTTP/HTTPS/RTSP, Cloud => WebRTC. * * @return CameraStreamMode indicating how the camera stream is obtained or used: */ @@ -355,7 +356,7 @@ public: /** * Get the current camera stream URL for this agent's active machine. - * Only meaningful when get_camera_stream_mode() returns an HTTP or RTSP mode. + * Only meaningful when get_camera_stream_mode() returns an HTTP, HTTPS, or RTSP mode. */ virtual std::string get_camera_url() const { return {}; } diff --git a/src/slic3r/plugin/pluginTypes/printerAgent/PrinterAgentPluginCapability.cpp b/src/slic3r/plugin/pluginTypes/printerAgent/PrinterAgentPluginCapability.cpp index c9ea52e8bb..21e36e816e 100644 --- a/src/slic3r/plugin/pluginTypes/printerAgent/PrinterAgentPluginCapability.cpp +++ b/src/slic3r/plugin/pluginTypes/printerAgent/PrinterAgentPluginCapability.cpp @@ -26,6 +26,7 @@ void PrinterAgentPluginCapability::RegisterBindings(pybind11::module_& module) py::enum_(printer_agent_module, "CameraStreamMode") .value("None_", CameraStreamMode::none) .value("HTTP", CameraStreamMode::http) + .value("HTTPS", CameraStreamMode::https) .value("HTTP_SNAPSHOT", CameraStreamMode::http_snapshot) .value("RTSP", CameraStreamMode::rtsp) .value("WebRTC", CameraStreamMode::webrtc) diff --git a/tests/slic3rutils/test_printer_agent.cpp b/tests/slic3rutils/test_printer_agent.cpp index 55ba57b253..6767c3cbcf 100644 --- a/tests/slic3rutils/test_printer_agent.cpp +++ b/tests/slic3rutils/test_printer_agent.cpp @@ -92,6 +92,10 @@ TEST_CASE("integration: orca.printer_agent binding surface", "[integration][Pyth CHECK(py::hasattr(mode, "Subscription")); CHECK(py::hasattr(mode, "None_")); + REQUIRE(py::hasattr(pa, "CameraStreamMode")); + py::object camera_mode = pa.attr("CameraStreamMode"); + CHECK(py::hasattr(camera_mode, "HTTPS")); + // Plugin-type enum exposed at module root (host reads it without the GIL). CHECK(py::hasattr(orca, "PluginType")); }