// Client compatibility contracts for an optional Opus upstream audio transport. // // Scope: inspect client capture/bundle/install seams without requiring a live // audio stack. // Targets: `client/src/input/microphone.rs`, // `client/src/app/uplink_media/uplink_queue_metadata.rs`, and // `scripts/install/client.sh`. // Why: Opus is now the optimized microphone transport, while raw PCM remains // one click away as the known-good fallback. const MICROPHONE: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/client/src/input/microphone.rs" )); const AUDIO_CODEC: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/client/src/input/audio_codec.rs" )); const UPLINK_QUEUE_METADATA: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/client/src/app/uplink_media/uplink_queue_metadata.rs" )); const CLIENT_INSTALL: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/scripts/install/client.sh" )); #[test] fn client_microphone_path_preserves_pcm_fallback_and_opus_selection() { for expected in [ "audio_transport::mark_packet_pcm_s16le", "OpusPacketEncoder", "requested_upstream_audio_codec_from_env", "LESAVKA_UPLINK_AUDIO_CODEC", "LESAVKA_MIC_NOISE_SUPPRESSION", "webrtcdsp", "frame_duration_us", "MIC_SAMPLE_RATE", "MIC_CHANNELS", "MIC_PACKET_TARGET_DURATION_ENV", "DEFAULT_MIC_PACKET_TARGET_DURATION_US: u64 = 20_000", ] { assert!( MICROPHONE.contains(expected) || AUDIO_CODEC.contains(expected), "microphone capture should preserve audio transport marker {expected}" ); } assert!( AUDIO_CODEC.contains("mark_packet_opus") && AUDIO_CODEC.contains("Opus by default"), "client Opus encoder should stamp packets while documenting the default" ); } #[test] fn bundled_uplink_envelope_carries_audio_codec_metadata_with_video() { for expected in [ "packet_audio_profile", "mark_bundle_audio_profile", "has_audio", "UpstreamMediaBundle", "attach_bundle_queue_metadata", ] { assert!( UPLINK_QUEUE_METADATA.contains(expected), "bundled uplink should preserve audio profile marker {expected}" ); } assert!( UPLINK_QUEUE_METADATA .find("mark_bundle_audio_profile") .unwrap() < UPLINK_QUEUE_METADATA .find("attach_bundle_queue_metadata") .unwrap(), "bundle audio codec metadata should be available before queue metadata is attached" ); } #[test] fn client_installer_reports_optional_opus_gstreamer_route() { for expected in [ "Opus upstream audio transport route", "opusenc", "opusdec", "microphone noise suppression route", "webrtcdsp", "fall back to PCM", ] { assert!( CLIENT_INSTALL.contains(expected), "client installer should keep Opus diagnostic marker {expected}" ); } }