fix(asr): normalize origin rejection statuses
| | |
| | | } |
| | | |
| | | impl AudioIngressMetadata { |
| | | pub(crate) const ORIGIN_STATUSES: [&'static str; 8] = [ |
| | | "controlled_fixture_bound", |
| | | "ordinary_mic_absent", |
| | | "participant_attributes_absent", |
| | | "participant_attributes_invalid", |
| | | "sequence_absent", |
| | | "sequence_replayed_or_regressed", |
| | | "wrong_participant_or_track", |
| | | "origin_unprovable", |
| | | ]; |
| | | |
| | | pub(crate) fn origin_status(attributes: &HashMap<String, String>) -> &'static str { |
| | | let source = attributes.get("inputSourceCategory").map(String::as_str); |
| | | let sequence = attributes.get("clientFixtureSequence").map(String::as_str); |
| | |
| | | (Some("controlled_fixture"), None) => "sequence_absent", |
| | | (Some("controlled_fixture"), Some(_)) => "participant_attributes_invalid", |
| | | (Some(_), _) | (None, Some(_)) => "participant_attributes_invalid", |
| | | } |
| | | } |
| | | |
| | | pub(crate) fn rejection_status(reason: &str) -> &'static str { |
| | | match reason { |
| | | "incomplete_metadata" => "participant_attributes_absent", |
| | | "invalid_source_or_sequence" => "participant_attributes_invalid", |
| | | _ => "origin_unprovable", |
| | | } |
| | | } |
| | | |
| | |
| | | "ordinary_mic_absent", |
| | | AudioIngressMetadata::origin_status(&HashMap::new()) |
| | | ); |
| | | assert_eq!( |
| | | "participant_attributes_absent", |
| | | AudioIngressMetadata::rejection_status("incomplete_metadata") |
| | | ); |
| | | assert_eq!( |
| | | "participant_attributes_invalid", |
| | | AudioIngressMetadata::rejection_status("invalid_source_or_sequence") |
| | | ); |
| | | assert_eq!( |
| | | "sequence_replayed_or_regressed", |
| | | AudioIngressMetadata::rejection_status("sequence_replayed") |
| | | ); |
| | | assert_eq!( |
| | | "wrong_participant_or_track", |
| | | AudioIngressMetadata::rejection_status("wrong_participant") |
| | | ); |
| | | assert_eq!( |
| | | "origin_unprovable", |
| | | AudioIngressMetadata::rejection_status("unknown") |
| | | ); |
| | | assert_eq!(8, AudioIngressMetadata::ORIGIN_STATUSES.len()); |
| | | } |
| | | |
| | | #[test] |
| | |
| | | F: FnOnce() -> std::collections::HashMap<String, String>, |
| | | { |
| | | if !is_bound_user_participant(participant_identity, expected_participant) { |
| | | warn!( |
| | | "audioIngressOriginStatus" = "wrong_participant_or_track", |
| | | "runtime helper rejected audio participant before VAD/session" |
| | | ); |
| | | return (vad.in_speech, vad.in_speech, None); |
| | | } |
| | | observe_frame_and_start_session( |
| | |
| | | Ok(metadata) => metadata, |
| | | Err(reason) => { |
| | | warn!(call_id = %call_id, trace_id = %trace_id, turn_id = %turn_id, |
| | | reason, origin_status, "runtime helper asr_realtime_metadata_rejected"); |
| | | reason, audioIngressOriginStatus = %AudioIngressMetadata::rejection_status(reason), |
| | | "runtime helper asr_realtime_metadata_rejected"); |
| | | return; |
| | | } |
| | | }; |
| | |
| | | &metadata.client_fixture_sequence, |
| | | ) { |
| | | warn!(call_id = %call_id, trace_id = %trace_id, turn_id = %turn_id, |
| | | audioIngressOriginStatus = "sequence_replayed_or_regressed", |
| | | "runtime helper asr_realtime_metadata_sequence_rejected"); |
| | | return; |
| | | } |