(video_codec: String)
| 1465 | } |
| 1466 | |
| 1467 | fn current_stream_quality_state(video_codec: String) -> ActiveStreamQualityState { |
| 1468 | let configured_profile = env::var("SIMDECK_STREAM_QUALITY_PROFILE") |
| 1469 | .ok() |
| 1470 | .and_then(|value| stream_quality_profile(value.trim()).ok()); |
| 1471 | let fallback = configured_profile.unwrap_or(StreamQualityProfile { |
| 1472 | id: "custom", |
| 1473 | label: "Custom", |
| 1474 | max_edge: 1440, |
| 1475 | fps: 30, |
| 1476 | min_bitrate: 3_000_000, |
| 1477 | bits_per_pixel: 4, |
| 1478 | }); |
| 1479 | let max_edge = env_u32("SIMDECK_REALTIME_MAX_EDGE", fallback.max_edge, 320, 4096); |
| 1480 | let fps = env_u32("SIMDECK_REALTIME_FPS", fallback.fps, 10, 240); |
| 1481 | let min_bitrate = env_u32( |
| 1482 | "SIMDECK_REALTIME_MIN_BITRATE", |
| 1483 | fallback.min_bitrate, |
| 1484 | 200_000, |
| 1485 | 60_000_000, |
| 1486 | ); |
| 1487 | let bits_per_pixel = env_u32( |
| 1488 | "SIMDECK_REALTIME_BITS_PER_PIXEL", |
| 1489 | fallback.bits_per_pixel, |
| 1490 | 1, |
| 1491 | 10, |
| 1492 | ); |
| 1493 | let profile = env::var("SIMDECK_STREAM_QUALITY_PROFILE") |
| 1494 | .ok() |
| 1495 | .filter(|value| !value.trim().is_empty()) |
| 1496 | .unwrap_or_else(|| { |
| 1497 | STREAM_QUALITY_PROFILES |
| 1498 | .iter() |
| 1499 | .find(|candidate| { |
| 1500 | candidate.max_edge == max_edge |
| 1501 | && candidate.fps == fps |
| 1502 | && candidate.min_bitrate == min_bitrate |
| 1503 | && candidate.bits_per_pixel == bits_per_pixel |
| 1504 | }) |
| 1505 | .map(|candidate| candidate.id.to_owned()) |
| 1506 | .unwrap_or_else(|| "custom".to_owned()) |
| 1507 | }); |
| 1508 | ActiveStreamQualityState { |
| 1509 | profile, |
| 1510 | max_edge, |
| 1511 | fps, |
| 1512 | min_bitrate, |
| 1513 | bits_per_pixel, |
| 1514 | video_codec, |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | fn stream_quality_state_value(state: &ActiveStreamQualityState) -> Value { |
| 1519 | json_value!({ |
no test coverage detected