mirror of
https://github.com/ratspeak/rsLXST
synced 2026-11-22 23:10:37 +00:00
embedded: accept matching media as profile convergence
This commit is contained in:
1 parent
49d6607eed
commit
ba573034d4
2 files changed
+47
No files matched your search
@@ -274,6 +274,25 @@ impl Session {
|
||||
events.transitions(self.call.receive_signal(signal));
|
||||
events
|
||||
}
|
||||
/// Matching authenticated media confirms adoption of a suggested profile.
|
||||
/// Some standard peers change codec without echoing PreferredProfile. The
|
||||
/// embedder must validate codec, mode and complete native packet size first.
|
||||
/// This does not open audio, answer a call, or start the microphone.
|
||||
pub fn receive_profile_media(&mut self, profile: Profile, now_ms: u64) -> Events {
|
||||
if self.ended.is_none()
|
||||
&& self.linked
|
||||
&& self.verified
|
||||
&& self.call.status() == SignallingStatus::Established
|
||||
&& self.call.profile() == Some(profile)
|
||||
&& self.config.allowed.contains(profile)
|
||||
&& self
|
||||
.profile_deadline
|
||||
.is_some_and(|deadline| now_ms < deadline)
|
||||
{
|
||||
self.profile_deadline = None;
|
||||
}
|
||||
Events::new()
|
||||
}
|
||||
/// A successfully configured device/codec is necessary but never starts capture.
|
||||
pub fn audio_ready(&mut self, generation: u32, success: bool) -> Events {
|
||||
if self.ended.is_some() || generation != self.audio_generation {
|
||||
|
||||
@@ -213,3 +213,31 @@ fn adversarial_event_sequences_remain_bounded() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn authenticated_matching_media_confirms_standard_profile_fallback_without_echo() {
|
||||
let mut session = connect(CallRole::Outgoing);
|
||||
session.receive_signal(Profile::QualityMedium.into(), 100);
|
||||
assert!(!session.media_ready());
|
||||
session.receive_profile_media(Profile::BandwidthLow, 200);
|
||||
assert!(!session.media_ready());
|
||||
session.receive_profile_media(Profile::BandwidthVeryLow, 201);
|
||||
assert!(session.media_ready());
|
||||
assert!(!session.transmitting());
|
||||
session.tick(6000);
|
||||
assert_eq!(session.ended(), None);
|
||||
|
||||
let mut late = connect(CallRole::Outgoing);
|
||||
late.receive_signal(Profile::QualityMedium.into(), 100);
|
||||
late.receive_profile_media(Profile::BandwidthVeryLow, 5100);
|
||||
late.tick(5100);
|
||||
assert_eq!(late.ended(), Some(EndReason::ProfileUnsupported));
|
||||
|
||||
let mut ringing = Session::new(CallRole::Incoming, config(), 0).unwrap();
|
||||
ringing.link_established();
|
||||
ringing.peer_verified(1);
|
||||
ringing.receive_signal(Profile::QualityMedium.into(), 100);
|
||||
ringing.receive_profile_media(Profile::BandwidthVeryLow, 200);
|
||||
ringing.tick(5100);
|
||||
assert_eq!(ringing.ended(), Some(EndReason::ProfileUnsupported));
|
||||
}
|
||||
Reference in new issue
Block a user