MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / current_stream_quality_state

Function current_stream_quality_state

packages/server/src/api/routes.rs:1467–1516  ·  view source on GitHub ↗
(video_codec: String)

Source from the content-addressed store, hash-verified

1465}
1466
1467fn 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
1518fn stream_quality_state_value(state: &ActiveStreamQualityState) -> Value {
1519 json_value!({

Callers 3

healthFunction · 0.85
stream_quality_responseFunction · 0.85

Calls 3

stream_quality_profileFunction · 0.85
env_u32Function · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected