(options: StudioExposeOptions)
| 2926 | } |
| 2927 | |
| 2928 | fn expose_to_studio(options: StudioExposeOptions) -> anyhow::Result<()> { |
| 2929 | let stream_quality_profile = studio_stream_quality_profile( |
| 2930 | options.video_codec, |
| 2931 | options.low_latency, |
| 2932 | options.stream_quality, |
| 2933 | ); |
| 2934 | let metadata = ensure_project_service(ServiceLaunchOptions { |
| 2935 | port: options.port, |
| 2936 | bind: options.bind, |
| 2937 | advertise_host: None, |
| 2938 | client_root: None, |
| 2939 | video_codec: options.video_codec, |
| 2940 | android_gpu: AndroidGpuMode::Host, |
| 2941 | low_latency: options.low_latency, |
| 2942 | realtime_stream: true, |
| 2943 | allow_port_probe: false, |
| 2944 | stream_quality_profile: stream_quality_profile.clone(), |
| 2945 | local_stream_fps: options.local_stream_fps, |
| 2946 | })?; |
| 2947 | let selected = if let Some(selector) = options.simulator.as_deref() { |
| 2948 | select_studio_simulator(&metadata.http_url, selector) |
| 2949 | .ok() |
| 2950 | .flatten() |
| 2951 | } else { |
| 2952 | select_default_studio_simulator(&metadata.http_url) |
| 2953 | .ok() |
| 2954 | .flatten() |
| 2955 | }; |
| 2956 | if let Some(simulator) = selected.as_ref() { |
| 2957 | if !simulator.is_booted { |
| 2958 | service_post_ok(&metadata.http_url, &simulator.udid, "boot", &Value::Null) |
| 2959 | .with_context(|| format!("boot simulator {}", simulator.name))?; |
| 2960 | } |
| 2961 | } |
| 2962 | let health = service_get_json(&metadata.http_url, "/api/health").ok(); |
| 2963 | let active_codec = health |
| 2964 | .as_ref() |
| 2965 | .and_then(|value| value.get("videoCodec")) |
| 2966 | .and_then(Value::as_str) |
| 2967 | .unwrap_or_else(|| options.video_codec.as_env_value()); |
| 2968 | let active_stream_quality = health |
| 2969 | .as_ref() |
| 2970 | .and_then(|value| value.get("streamQuality")) |
| 2971 | .and_then(|value| value.get("profile")) |
| 2972 | .and_then(Value::as_str) |
| 2973 | .or(stream_quality_profile.as_deref()); |
| 2974 | let realtime_stream = health |
| 2975 | .as_ref() |
| 2976 | .and_then(|value| value.get("realtimeStream")) |
| 2977 | .and_then(Value::as_bool) |
| 2978 | .unwrap_or(true); |
| 2979 | |
| 2980 | let bridge_script = studio_provider_bridge_script()?; |
| 2981 | let executable = env::current_exe().context("resolve simdeck executable")?; |
| 2982 | let restart_args = studio_service_restart_args(&options); |
| 2983 | let status_args = vec!["service".to_owned(), "status".to_owned()]; |
| 2984 | println!( |
| 2985 | "Exposing {} through SimDeck Studio...", |
no test coverage detected