diff --git a/docs/HLSD/mcp-server.md b/docs/HLSD/mcp-server.md index 8b4939fcb6..5033d39154 100644 --- a/docs/HLSD/mcp-server.md +++ b/docs/HLSD/mcp-server.md @@ -352,7 +352,7 @@ the UI thread. | View | `set_view` | tab (Design included), 3D view (Prepare, preview, assemble), camera (the Design view's on the Design tab), preview layers (by number or height), color scheme as the legend's combo picks it, legend rows and time estimate, window size | | | `screenshot` | window, the 3D view shown (the Design view on the Design tab), topmost dialog or one widget: a downscaled image and a full-size PNG | | | `get_preview` | a sliced plate's summary, time and grams per feature type, per-layer Z, height, time and grams (paged), grams per object instance, and the Preview's legend state and colour ranges | -| Recording | `start_recording` | record the main window with its modal dialogs, or the 3D view shown, into an MJPEG `.mkv`, with the current tool call as a caption and the pointer highlighted | +| Recording | `start_recording` | record the main window with its modal dialogs, or the 3D view shown, into an MJPEG `.mkv`, with the current tool call as a caption and the pointer highlighted when asked for | | | `stop_recording` | capture the last state, end the recording and report its file once written: length, frames, drops, the mean UI time of a capture, size and why it ended | | | `encode_recording` | encode a recording into an H.265 or H.264 MP4 with the system ffmpeg; cancellable | | GUI | `ui_snapshot` | widgets, rows of lists, trees and tables, popups, menus, GL toolbar items, gizmos, the Prepare view's plates and plate icons, and ImGui items, with refs | @@ -1750,10 +1750,10 @@ recording counts as active until its file is closed, for the one-at-a-time rule **From the app.** The Speed Dial commands `take_screenshot`, `start_recording` and `stop_recording`, which the Help menu also has, give a person screenshots and recordings without an agent: a PNG of the main window, -and a recording of it for up to an hour with the pointer highlighted and any tool call captioned (a Run -Script run's steps, say). Both go in the person's Downloads folder unless they chose another. Start -Recording opens `RecordingDialog`, which splits its settings by the file they make. Record holds the JPEG -quality of the `.mkv`. Encode to MP4 holds whether ffmpeg encodes it once it ends, with a built-in preset or +and a recording of it for up to an hour. Both go in the person's Downloads folder unless they chose another. +Start Recording opens `RecordingDialog`, which splits its settings by the file they make. Record holds the +JPEG quality of the `.mkv` and a switch for each overlay, the pointer and the caption, both off unless the +person turns them on. Encode to MP4 holds whether ffmpeg encodes it once it ends, with a built-in preset or codec, CRF, speed and profile; it is off and disabled when no ffmpeg is found, and says how to get one. A rail joins the two stages and shows whether the second runs. The dialog remembers what it starts with in AppConfig's `recording` section (`RecordingSettings`). The command's parameter overrides those settings for @@ -1782,8 +1782,8 @@ captioned. With `pointer`, a `wxEventFilter` sees every mouse and click-type com and the ones the GUI tools synthesize alike: mouse events move the pointer, presses add a ripple, and a button, checkbox, toggle or radio command with no press on it just before is a click made without the mouse (`ui_click`), shown at the control's centre. Events in windows the frame doesn't show, and in -windows hidden from automation, are ignored. `overlays: false` turns off the caption and the pointer -both, and installs no filter. +windows hidden from automation, are ignored. Both are off unless asked for, `captions` and `pointer` +turning on one each; without the pointer no filter is installed. The overlays annotate the app without competing with it. They are drawn at the app's own scale: `overlay_scale()` is video pixels per app pixel at 100 %, from `em_unit()`, the content scale and the diff --git a/src/slic3r/GUI/Mcp/McpRecorder.hpp b/src/slic3r/GUI/Mcp/McpRecorder.hpp index bf8826ce52..fcde7c7b67 100644 --- a/src/slic3r/GUI/Mcp/McpRecorder.hpp +++ b/src/slic3r/GUI/Mcp/McpRecorder.hpp @@ -49,8 +49,8 @@ struct RecordingOptions int max_dim = 1920; int quality = 80; int max_seconds = 600; - bool captions = true; // the current tool call's caption - bool pointer = true; // the pointer highlighted, its clicks rippling + bool captions = false; // the current tool call's caption + bool pointer = false; // the pointer highlighted, its clicks rippling boost::filesystem::path path; std::string owner; // the job of the script that started it, "" for a client, kPersonOwner // Runs on the UI thread once the recording ends, while its file is still being closed, with the reason it @@ -63,7 +63,7 @@ struct RecordingOptions inline constexpr const char* kPersonOwner = "person"; // Records what OrcaSlicer shows into an MJPEG Matroska file, with the current tool call as a caption and -// the pointer highlighted. At most one recording at a time. The UI thread captures a frame +// the pointer highlighted when asked for. At most one recording at a time. The UI thread captures a frame // per tick of a timer (the main window with the modal dialogs on it, or the 3D view shown); everything // after that, scaling, drawing the captions, JPEG and the file, runs on a RecordingSink's threads. A // recording ends when stopped, at its time limit, when the script that started it ends, when the diff --git a/src/slic3r/GUI/Mcp/McpService.cpp b/src/slic3r/GUI/Mcp/McpService.cpp index 3ba24bee73..c0233c50f5 100644 --- a/src/slic3r/GUI/Mcp/McpService.cpp +++ b/src/slic3r/GUI/Mcp/McpService.cpp @@ -146,7 +146,8 @@ const char* kInstructions = "or cancel.\n" "- Paths are absolute. Outputs never overwrite an existing file unless overwrite is true.\n" "- screenshot returns a downscaled image plus the full-size PNG path; target \"canvas\" is the 3D view.\n" - "- start_recording / stop_recording record a video (MJPEG .mkv) with the tool calls, clicks and keys as captions; " + "- start_recording / stop_recording record a video (MJPEG .mkv), with the tool calls as captions and the pointer " + "highlighted when captions and pointer ask for them; " "encode_recording turns it into an H.265 MP4 with the system ffmpeg.\n" "- export_script saves this session's calls as a replayable script; run_script replays one."; diff --git a/src/slic3r/GUI/Mcp/McpToolsRecord.cpp b/src/slic3r/GUI/Mcp/McpToolsRecord.cpp index 1d93d15418..7c970fe039 100644 --- a/src/slic3r/GUI/Mcp/McpToolsRecord.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsRecord.cpp @@ -1,5 +1,5 @@ -// start_recording, stop_recording and encode_recording: a video of what OrcaSlicer shows, captioned with the -// current tool call and its pointer highlighted, and its encode to MP4. +// start_recording, stop_recording and encode_recording: a video of what OrcaSlicer shows, optionally captioned +// with the current tool call and its pointer highlighted, and its encode to MP4. #include "McpPaths.hpp" #include "McpRecorder.hpp" @@ -95,9 +95,9 @@ void register_record_tools(McpService& service) reg.add(record_tool( "start_recording", L("Start a recording"), "Record a video of OrcaSlicer until stop_recording: the main window with any modal dialog on it (target window), or " - "the 3D view shown (canvas). Frames are MJPEG in a Matroska (.mkv) file with their real timestamps. The tool call " - "acting on the app shows as a caption at the bottom (secret setting values never show), and the pointer is " - "highlighted, its clicks rippling; overlays false draws neither. Capture takes at most about a third of the UI thread, so " + "the 3D view shown (canvas). Frames are MJPEG in a Matroska (.mkv) file with their real timestamps. With captions, " + "the tool call acting on the app shows as a caption at the bottom (secret setting values never show); with pointer, " + "the pointer is highlighted, its clicks rippling. Capture takes at most about a third of the UI thread, so " "the frame rate drops where capturing is slow. One recording at a time: one a script starts ends with the script, a " "client's when the server is turned off. encode_recording makes an MP4 of it.", object_schema({{"target", enum_prop({"window", "canvas"}, "window (default): the main window and its dialogs; canvas: the 3D view shown.")}, @@ -105,9 +105,8 @@ void register_record_tools(McpService& service) {"max_dim", int_prop(320, 3840, "Long edge of the video in pixels (default 1920).")}, {"quality", int_prop(30, 95, "JPEG quality of the frames (default 80).")}, {"max_seconds", int_prop(1, 3600, "The recording ends on its own after this long (default 600).")}, - {"captions", prop("boolean", "Caption the tool call acting on the app (default true).")}, - {"pointer", prop("boolean", "Highlight the pointer and show its clicks (default true).")}, - {"overlays", prop("boolean", "false: no caption and no pointer, whatever captions and pointer say (default true).")}, + {"captions", prop("boolean", "Caption the tool call acting on the app (default false).")}, + {"pointer", prop("boolean", "Highlight the pointer and show its clicks (default false).")}, {"save_path", prop("string", "Absolute .mkv path; default the session's output folder.")}, {"overwrite", prop("boolean", "Replace an existing save_path.")}}), [&service](const json& args, ToolContext& ctx) { @@ -117,9 +116,8 @@ void register_record_tools(McpService& service) o.max_dim = arg_int(args, "max_dim", 1920); o.quality = arg_int(args, "quality", 80); o.max_seconds = arg_int(args, "max_seconds", 600); - const bool overlays = arg_bool(args, "overlays", true); - o.captions = overlays && arg_bool(args, "captions", true); - o.pointer = overlays && arg_bool(args, "pointer", true); + o.captions = arg_bool(args, "captions", false); + o.pointer = arg_bool(args, "pointer", false); if (args.contains("save_path")) { const std::string path = arg_string(args, "save_path"); if (!boost::algorithm::iends_with(path, ".mkv")) diff --git a/src/slic3r/GUI/Mcp/RecordingSettings.cpp b/src/slic3r/GUI/Mcp/RecordingSettings.cpp index 1398f6f1fc..7af549ee37 100644 --- a/src/slic3r/GUI/Mcp/RecordingSettings.cpp +++ b/src/slic3r/GUI/Mcp/RecordingSettings.cpp @@ -89,7 +89,9 @@ RecordingSettings load_recording_settings(const AppConfig& config) }; number("quality", kMinQuality, kMaxQuality, s.quality); number("crf", 0, kMaxCrf, s.crf); - s.encode = config.get(kSection, "encode") == "true"; + s.captions = config.get(kSection, "captions") == "true"; + s.pointer = config.get(kSection, "pointer") == "true"; + s.encode = config.get(kSection, "encode") == "true"; if (const std::string codec = config.get(kSection, "codec"); !encoder_for(codec).empty()) s.codec = codec; if (const std::string speed = config.get(kSection, "speed"); listed(encoder_speeds(), speed)) @@ -104,6 +106,8 @@ RecordingSettings load_recording_settings(const AppConfig& config) void save_recording_settings(AppConfig& config, const RecordingSettings& settings) { config.set(kSection, "quality", std::to_string(settings.quality)); + config.set(kSection, "captions", settings.captions); + config.set(kSection, "pointer", settings.pointer); config.set(kSection, "encode", settings.encode); config.set(kSection, "codec", settings.codec); config.set(kSection, "crf", std::to_string(settings.crf)); @@ -116,10 +120,12 @@ std::string apply_recording_overrides(RecordingSettings& settings, const json& o { if (!overrides.is_object()) return "the parameter must be a JSON object"; - static const std::vector keys{"quality", "encode", "encode_preset", "codec", "crf", "speed", "profile", "folder", "silent"}; + static const std::vector keys{"quality", "captions", "pointer", "encode", "encode_preset", "codec", + "crf", "speed", "profile", "folder", "silent"}; for (const auto& [key, value] : overrides.items()) if (!listed(keys, key)) - return "unknown key \"" + key + "\": quality, encode, encode_preset, codec, crf, speed, profile, folder or silent"; + return "unknown key \"" + key + + "\": quality, captions, pointer, encode, encode_preset, codec, crf, speed, profile, folder or silent"; const auto integer = [&](const char* key, int min, int max, int& out) -> std::string { if (!overrides.contains(key)) return {}; @@ -161,7 +167,8 @@ std::string apply_recording_overrides(RecordingSettings& settings, const json& o } apply_encode_preset(s, *p); } - if (!(err = integer("quality", kMinQuality, kMaxQuality, s.quality)).empty() || !(err = flag("encode", s.encode)).empty() || + if (!(err = integer("quality", kMinQuality, kMaxQuality, s.quality)).empty() || !(err = flag("captions", s.captions)).empty() || + !(err = flag("pointer", s.pointer)).empty() || !(err = flag("encode", s.encode)).empty() || !(err = text("codec", {"h265", "h264"}, s.codec)).empty() || !(err = integer("crf", 0, kMaxCrf, s.crf)).empty() || !(err = text("speed", encoder_speeds(), s.speed)).empty() || !(err = flag("silent", quiet)).empty()) return err; diff --git a/src/slic3r/GUI/Mcp/RecordingSettings.hpp b/src/slic3r/GUI/Mcp/RecordingSettings.hpp index df50cfd344..b756573efb 100644 --- a/src/slic3r/GUI/Mcp/RecordingSettings.hpp +++ b/src/slic3r/GUI/Mcp/RecordingSettings.hpp @@ -11,13 +11,16 @@ class AppConfig; namespace Slic3r { namespace GUI { namespace Mcp { -// What the person's Start Recording asks for: the frames' JPEG quality, whether and how the recording is -// encoded to MP4 once it ends, and the folder both go in. The Start Recording dialog shows them and -// AppConfig's "recording" section remembers them; the command's parameter overrides them for one recording. +// What the person's Start Recording asks for: the frames' JPEG quality, whether they show captions and the +// pointer, whether and how the recording is encoded to MP4 once it ends, and the folder both go in. The Start +// Recording dialog shows them and AppConfig's "recording" section remembers them; the command's parameter +// overrides them for one recording. struct RecordingSettings { - int quality = 80; // the frames' JPEG quality, 30-95, as start_recording's - bool encode = false; + int quality = 80; // the frames' JPEG quality, 30-95, as start_recording's + bool captions = false; // the overlays, as start_recording's + bool pointer = false; + bool encode = false; std::string codec = "h265"; // and the rest as encode_recording takes them int crf = 28; std::string speed = "medium"; @@ -26,8 +29,8 @@ struct RecordingSettings bool operator==(const RecordingSettings& o) const { - return quality == o.quality && encode == o.encode && codec == o.codec && crf == o.crf && speed == o.speed && profile == o.profile && - folder == o.folder; + return quality == o.quality && captions == o.captions && pointer == o.pointer && encode == o.encode && codec == o.codec && + crf == o.crf && speed == o.speed && profile == o.profile && folder == o.folder; } }; @@ -53,8 +56,8 @@ std::string matching_encode_preset(const RecordingSettings& settings); RecordingSettings load_recording_settings(const AppConfig& config); void save_recording_settings(AppConfig& config, const RecordingSettings& settings); -// Applies Start Recording's parameter, an object with any of quality, encode, encode_preset, codec, crf, -// speed, profile, folder (an existing directory, absolute) and silent: encode_preset's fields first, then the +// Applies Start Recording's parameter, an object with any of quality, captions, pointer, encode, encode_preset, +// codec, crf, speed, profile, folder (an existing directory, absolute) and silent: encode_preset's fields first, then the // fields it names. A codec named without a profile takes the codec's default profile when the one it had does // not fit. Returns what is wrong, "" when nothing; `settings` is then unchanged. `silent` is true when the // parameter says so. diff --git a/src/slic3r/GUI/NativeCommands.cpp b/src/slic3r/GUI/NativeCommands.cpp index 51ea4297b6..dc90d1aed1 100644 --- a/src/slic3r/GUI/NativeCommands.cpp +++ b/src/slic3r/GUI/NativeCommands.cpp @@ -293,9 +293,9 @@ bool encode_when_closed(const boost::filesystem::path& path, const Mcp::Recordin }); } -// The person's recording: the main window, its pointer highlighted and any tool call captioned, for up to an -// hour, into the folder the settings name. The dialog shows the remembered settings, with what `param` -// overrides, and remembers what it starts with; a silent `param` starts with them at once and remembers +// The person's recording: the main window, with the overlays the settings ask for, for up to an hour, +// into the folder the settings name. The dialog shows the remembered settings, with what `param` overrides, +// and remembers what it starts with; a silent `param` starts with them at once and remembers // nothing. Encoding needs an ffmpeg: the dialog says so and records without encoding, and a silent start that // would encode is refused. Neither a script's end nor the server turning off ends the recording. Whatever does // end it says where it went: Stop Recording itself, or the recording's `ended` for an agent's stop_recording, @@ -334,6 +334,8 @@ AppActionRunResult start_recording(const std::string& param) Mcp::McpRecorder& recorder = service->recorder(); Mcp::RecordingOptions options; options.quality = settings.quality; + options.captions = settings.captions; + options.pointer = settings.pointer; options.max_seconds = 3600; options.path = Mcp::timestamped_path(capture_folder(settings), "recording", ".mkv", {".mp4"}); options.owner = Mcp::kPersonOwner; @@ -355,6 +357,8 @@ AppActionRunResult start_recording(const std::string& param) } nlohmann::json reply = Mcp::encode_arguments(settings, Mcp::path_to_utf8(options.path)); reply["quality"] = settings.quality; + reply["captions"] = settings.captions; + reply["pointer"] = settings.pointer; reply["encode"] = settings.encode; // TRN "Stop Recording" is the command that ends the recording. return {AppActionRunResult::Level::Success, _L("Recording started. Stop Recording saves it."), true, reply.dump()}; @@ -497,7 +501,8 @@ void describe_commands(std::vector& commands) "they chose another) and show the person a notification naming it; the reply has its path. Agents use " "the screenshot tool, which returns the image."}, {"start_recording", "Start the person's recording of the main window, for up to an hour, with the settings the Start " - "Recording dialog remembers: JPEG quality, whether and how it is encoded to MP4 once it ends, and the " + "Recording dialog remembers: JPEG quality, whether tool calls are captioned and the pointer highlighted, " + "whether and how it is encoded to MP4 once it ends, and the " "folder both go in (the person's Downloads unless they chose another). Without silent, the dialog opens " "with them (the param's values filled in): set its controls with ui_input (each is named after its " "param key) and answer it with dialog_respond \"Start recording\"; it remembers what it starts with. " @@ -505,9 +510,10 @@ void describe_commands(std::vector& commands) "when no ffmpeg is found. The reply has the path and the settings used. Neither a script's end nor the " "server turning off ends it. Agents record with start_recording instead.", CommandParamType::Text, - "JSON object, all optional: quality (30-95), encode (bool), encode_preset (small, balanced, quality, compatible; " - "applied before the fields), codec (h265, h264), crf (0-51), speed (ultrafast ... veryslow), profile (h264: high, " - "main, baseline; h265: main, main10), folder (absolute path of an existing directory), silent (bool)"}, + "JSON object, all optional: quality (30-95), captions (bool), pointer (bool), encode (bool), encode_preset (small, " + "balanced, quality, compatible; applied before the fields), codec (h265, h264), crf (0-51), speed (ultrafast ... " + "veryslow), profile (h264: high, main, baseline; h265: main, main10), folder (absolute path of an existing " + "directory), silent (bool)"}, {"stop_recording", "Stop the running recording, whoever started it, without waiting for its file, and show the person a " "notification naming it; the reply has its path. A later stop_recording reports it as ended " "stopped_in_app. Agents stop their own recordings with stop_recording, which waits and reports."}, diff --git a/src/slic3r/GUI/RecordingDialog.cpp b/src/slic3r/GUI/RecordingDialog.cpp index 2124da0402..27f94303b5 100644 --- a/src/slic3r/GUI/RecordingDialog.cpp +++ b/src/slic3r/GUI/RecordingDialog.cpp @@ -235,6 +235,24 @@ RecordingDialog::RecordingDialog(wxWindow* parent, const Mcp::RecordingSettings& auto* quality_hint = field_label(_L("30 to 95. Higher is sharper and makes a larger file.")); quality_row->Add(quality_hint, 0, wxALIGN_BOTTOM | wxLEFT | wxBOTTOM, FromDIP(8)); record->Add(quality_row, 0, wxTOP | wxBOTTOM, FromDIP(8)); + // The overlays, each switched at its row's end as encoding is in its stage's header. + const auto overlay = [&](const char* name, bool on, const wxString& title, const wxString& hint) { + auto* toggle = new ::SwitchButton(this); + toggle->SetName(name); + toggle->SetValue(on); + auto* text = new wxBoxSizer(wxVERTICAL); + text->Add(new ::Label(this, Label::Body_14, title), 0); + text->Add(field_label(hint), 0, wxTOP, FromDIP(2)); + auto* row = new wxBoxSizer(wxHORIZONTAL); + row->Add(text, 1, wxALIGN_CENTER_VERTICAL); + row->Add(toggle, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(12)); + record->Add(row, 0, wxEXPAND | wxTOP, FromDIP(8)); + return toggle; + }; + m_pointer = overlay("pointer", settings.pointer, _L("Highlight the pointer"), + _L("A ring follows the pointer, and its clicks ripple.")); + m_captions = overlay("captions", settings.captions, _L("Caption each step"), + _L("Names each step an agent or script takes, at the bottom.")); record->AddSpacer(FromDIP(14)); auto* record_row = new wxBoxSizer(wxHORIZONTAL); record_row->Add(m_record_rail, 0, wxEXPAND | wxRIGHT, FromDIP(14)); @@ -389,8 +407,10 @@ RecordingDialog::RecordingDialog(wxWindow* parent, const Mcp::RecordingSettings& Mcp::RecordingSettings RecordingDialog::settings() const { Mcp::RecordingSettings s; - s.quality = typed_value(m_quality); - s.encode = m_encode_on; + s.quality = typed_value(m_quality); + s.captions = m_captions->GetValue(); + s.pointer = m_pointer->GetValue(); + s.encode = m_encode_on; s.codec = codecs()[std::size_t(std::max(0, m_codec->GetSelection()))].first; s.crf = typed_value(m_crf); s.speed = Mcp::encoder_speeds()[std::size_t(std::max(0, m_speed->GetSelection()))]; @@ -462,7 +482,8 @@ void RecordingDialog::on_dpi_changed(const wxRect&) c->Rescale(); c->SetMinSize(wxSize(FromDIP(200), -1)); } - m_encode->Rescale(); + for (::SwitchButton* toggle : {m_pointer, m_captions, m_encode}) + toggle->Rescale(); m_folder_text->Rescale(); m_change_folder->Rescale(); for (StageRail* rail : {m_record_rail, m_encode_rail}) diff --git a/src/slic3r/GUI/RecordingDialog.hpp b/src/slic3r/GUI/RecordingDialog.hpp index 13740362b9..bff8cf8f6c 100644 --- a/src/slic3r/GUI/RecordingDialog.hpp +++ b/src/slic3r/GUI/RecordingDialog.hpp @@ -30,10 +30,11 @@ boost::filesystem::path default_capture_folder(); boost::filesystem::path capture_folder(const Mcp::RecordingSettings& settings); // Start Recording's dialog. Its two stages say which settings make which file: Record, the JPEG quality of -// the .mkv the frames go into, and Encode to MP4, which ffmpeg runs once the recording ends, from a built-in -// preset or field by field. A rail joins them, showing whether the second runs; it can't without an ffmpeg, -// and the stage then says how to get one. Below them is the folder both files go in. Each control is named -// after the key of the command's parameter it sets, so an agent can set it with ui_input. +// the .mkv the frames go into and whether they show the pointer and captions, and Encode to MP4, which ffmpeg +// runs once the recording ends, from a built-in preset or field by field. A rail joins them, showing whether +// the second runs; it can't without an ffmpeg, and the stage then says how to get one. Below them is the +// folder both files go in. Each control is named after the key of the command's parameter it sets, so an +// agent can set it with ui_input. class RecordingDialog : public DPIDialog { public: @@ -60,6 +61,8 @@ private: std::string m_folder; // "" for the default folder SpinInput* m_quality = nullptr; + ::SwitchButton* m_pointer = nullptr; + ::SwitchButton* m_captions = nullptr; StageRail* m_record_rail = nullptr; StageRail* m_encode_rail = nullptr; ::SwitchButton* m_encode = nullptr; diff --git a/tests/slic3rutils/test_mcp_recording.cpp b/tests/slic3rutils/test_mcp_recording.cpp index cfb26deb35..e4ab8ab254 100644 --- a/tests/slic3rutils/test_mcp_recording.cpp +++ b/tests/slic3rutils/test_mcp_recording.cpp @@ -1181,9 +1181,11 @@ TEST_CASE("each encode preset is matched by its own fields, and a changed field s.crf += 1; CHECK(matching_encode_preset(s) == "custom"); } - // The defaults are the Balanced preset, with encoding off until the person turns it on. + // The defaults are the Balanced preset, with the overlays and encoding off until the person turns them on. const RecordingSettings defaults; CHECK(matching_encode_preset(defaults) == "balanced"); + CHECK_FALSE(defaults.captions); + CHECK_FALSE(defaults.pointer); CHECK_FALSE(defaults.encode); CHECK(defaults.folder.empty()); } @@ -1192,13 +1194,15 @@ TEST_CASE("remembered recording settings come back, and a bad value keeps its de { Slic3r::AppConfig config; RecordingSettings s; - s.quality = 90; - s.encode = true; - s.codec = "h264"; - s.crf = 20; - s.speed = "slow"; - s.profile = "baseline"; - s.folder = "/somewhere/videos"; + s.quality = 90; + s.captions = true; + s.pointer = true; + s.encode = true; + s.codec = "h264"; + s.crf = 20; + s.speed = "slow"; + s.profile = "baseline"; + s.folder = "/somewhere/videos"; save_recording_settings(config, s); CHECK(load_recording_settings(config) == s); @@ -1220,11 +1224,14 @@ TEST_CASE("Start Recording's parameter overrides the settings, a preset before t { RecordingSettings s; bool silent = false; - CHECK(apply_recording_overrides(s, json{{"encode_preset", "compatible"}, {"crf", 18}, {"quality", 60}, {"silent", true}}, silent).empty()); + const json overrides{{"encode_preset", "compatible"}, {"crf", 18}, {"quality", 60}, {"pointer", true}, {"silent", true}}; + CHECK(apply_recording_overrides(s, overrides, silent).empty()); CHECK(s.codec == "h264"); CHECK(s.profile == "high"); CHECK(s.crf == 18); CHECK(s.quality == 60); + CHECK(s.pointer); + CHECK_FALSE(s.captions); CHECK(silent); // A codec without a profile takes the codec's default when the one it had doesn't fit. @@ -1239,6 +1246,8 @@ TEST_CASE("Start Recording's parameter overrides the settings, a preset before t CHECK_FALSE(apply_recording_overrides(s, json{{"codec", "h264"}, {"profile", "main10"}}, silent).empty()); CHECK_FALSE(apply_recording_overrides(s, json{{"crf", 52}}, silent).empty()); CHECK_FALSE(apply_recording_overrides(s, json{{"quality", "high"}}, silent).empty()); + CHECK_FALSE(apply_recording_overrides(s, json{{"captions", "yes"}}, silent).empty()); + CHECK_FALSE(apply_recording_overrides(s, json{{"overlays", true}}, silent).empty()); CHECK_FALSE(apply_recording_overrides(s, json{{"encode_preset", "tiny"}}, silent).empty()); CHECK_FALSE(apply_recording_overrides(s, json{{"fps", 30}}, silent).empty()); CHECK_FALSE(apply_recording_overrides(s, json::array(), silent).empty()); diff --git a/tools/mcp/README.md b/tools/mcp/README.md index 317e889092..e89e5c6314 100644 --- a/tools/mcp/README.md +++ b/tools/mcp/README.md @@ -121,8 +121,8 @@ filament change, a 3MF round trip, and `clear`. `tests/recording.json` records while it drives the GUI: clicks on the 3D view, a setting typed, the Preferences dialog opened and closed, a slice. It stops the recording (frames, length, size) and encodes it to H.265, then has a nested script start a recording of the 3D view that it never stops, checks the -script's end closed it, and encodes that to H.264. Short recordings check what `overlays`, `captions` and -`pointer` turn off. The encodes need an ffmpeg with libx265 and libx264 +script's end closed it, and encodes that to H.264. Short recordings check that a recording has no overlays +unless `captions` or `pointer` turns one on. The encodes need an ffmpeg with libx265 and libx264 (`ORCA_FFMPEG`, or `ffmpeg` on `PATH`) and are optional without one. Look at the videos, or at frames `ffmpeg -i session.mkv -vf fps=1 frame%02d.png` extracts, for the caption, the pointer and the dialog. diff --git a/tools/mcp/tests/recording.json b/tools/mcp/tests/recording.json index 05f8062b6d..db71c01593 100644 --- a/tools/mcp/tests/recording.json +++ b/tools/mcp/tests/recording.json @@ -13,8 +13,9 @@ {"match": "restore", "button": "no"}]}}, {"tool": "new_project"}, {"tool": "set_view", "args": {"window_size": [1600, 1000], "tab": "prepare"}}, - {"tool": "start_recording", "args": {"save_path": "${out_dir}/session.mkv", "overwrite": true}, - "expect": {"/width": {"ge": 320}, "/fps": {"eq": 10}}}, + {"tool": "start_recording", "args": {"save_path": "${out_dir}/session.mkv", "overwrite": true, "captions": true, + "pointer": true}, + "expect": {"/width": {"ge": 320}, "/fps": {"eq": 10}, "/captions": {"eq": true}, "/pointer": {"eq": true}}}, {"tool": "get_state", "expect": {"/recording/path": {"regex": "session\\.mkv$"}}}, {"tool": "open_files", "args": {"paths": ["${vars.model}"]}, "expect": {"/added": {"eq": 1}}}, {"tool": "ui_mouse", "args": {"action": "click", "x": 300, "y": 200}}, @@ -48,20 +49,16 @@ {"tool": "stop_recording", "expect": {"/ended": {"eq": "script_ended"}, "/path": {"regex": "inner\\.mkv$"}}}, {"tool": "encode_recording", "args": {"overwrite": true, "codec": "h264"}, "optional": true, "expect": {"/path": {"regex": "inner\\.mp4$"}, "/encoder": {"eq": "libx264"}}}, - // The script's end released the file: recording to it again starts at once, with both overlays. + // The script's end released the file: recording to it again starts at once, with no overlays by default. {"tool": "start_recording", "args": {"save_path": "${out_dir}/inner.mkv", "overwrite": true}, - "expect": {"/captions": {"eq": true}, "/pointer": {"eq": true}}}, - {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}}}, - - // overlays false turns off both, whatever they say; each can also be turned off alone. - {"tool": "start_recording", "args": {"save_path": "${out_dir}/plain.mkv", "overwrite": true, "overlays": false, - "captions": true, "pointer": true}, "expect": {"/captions": {"eq": false}, "/pointer": {"eq": false}}}, {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}}}, - {"tool": "start_recording", "args": {"save_path": "${out_dir}/plain.mkv", "overwrite": true, "captions": false}, + + // captions and pointer each turn on one. + {"tool": "start_recording", "args": {"save_path": "${out_dir}/plain.mkv", "overwrite": true, "pointer": true}, "expect": {"/captions": {"eq": false}, "/pointer": {"eq": true}}}, {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}}}, - {"tool": "start_recording", "args": {"save_path": "${out_dir}/plain.mkv", "overwrite": true, "pointer": false}, + {"tool": "start_recording", "args": {"save_path": "${out_dir}/plain.mkv", "overwrite": true, "captions": true}, "expect": {"/captions": {"eq": true}, "/pointer": {"eq": false}}}, {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}}} ]