| 1479 | } |
| 1480 | |
| 1481 | bool PipelineParser::parse_screencap(const json::value& input, Action::ScreencapParam& output, const Action::ScreencapParam& default_value) |
| 1482 | { |
| 1483 | if (!get_and_check_value(input, "filename", output.filename, default_value.filename)) { |
| 1484 | LogError << "failed to get_and_check_value filename" << VAR(input); |
| 1485 | return false; |
| 1486 | } |
| 1487 | |
| 1488 | if (!get_and_check_value(input, "format", output.format, default_value.format)) { |
| 1489 | LogError << "failed to get_and_check_value format" << VAR(input); |
| 1490 | return false; |
| 1491 | } |
| 1492 | |
| 1493 | static const std::unordered_set<std::string> kValidFormats = { "png", "jpg", "jpeg" }; |
| 1494 | if (kValidFormats.find(output.format) == kValidFormats.end()) { |
| 1495 | LogError << "invalid screencap format, expected png|jpg|jpeg" << VAR(output.format) << VAR(input); |
| 1496 | return false; |
| 1497 | } |
| 1498 | |
| 1499 | if (!get_and_check_value(input, "quality", output.quality, default_value.quality)) { |
| 1500 | LogError << "failed to get_and_check_value quality" << VAR(input); |
| 1501 | return false; |
| 1502 | } |
| 1503 | |
| 1504 | if (output.quality < 0 || output.quality > 100) { |
| 1505 | LogWarn << "screencap quality out of range [0, 100], clamping" << VAR(output.quality); |
| 1506 | output.quality = std::clamp(output.quality, 0, 100); |
| 1507 | } |
| 1508 | |
| 1509 | return true; |
| 1510 | } |
| 1511 | |
| 1512 | bool PipelineParser::parse_custom_action_param( |
| 1513 | const json::value& input, |