use crate::client::Client;
use crate::propagate::Propagated;
pub(crate) fn fanout(p: &Propagated, clients: &mut [Client]) {
#[cfg(feature = "active-speaker")]
if let Propagated::ActiveSpeakerChanged { peer_id, .. } = p {
for client in clients.iter_mut() {
if *client.id == *peer_id {
continue;
}
client.handle_active_speaker_changed(*peer_id);
}
return;
}
let Some(origin) = p.client_id() else {
return;
};
for client in clients.iter_mut() {
if client.id == origin {
continue;
}
match p {
Propagated::TrackOpen(_, track_in) => client.handle_track_open(track_in.clone()),
Propagated::MediaData(_, data) => client.handle_media_data_out(origin, data),
Propagated::KeyframeRequest(_, req, source, mid_in) => {
if *source == client.id {
client.handle_keyframe_request(*req, *mid_in);
}
}
Propagated::Noop
| Propagated::Timeout(_)
| Propagated::BandwidthEstimate { .. }
| Propagated::ClientBudgetHint(..)
| Propagated::RtcpStats { .. }
| Propagated::PublisherLayerHint { .. }
| Propagated::PublisherLayerHintForUpstream { .. }
| Propagated::AudioCodecHint { .. }
| Propagated::UpstreamKeyframeRequest { .. } => {}
#[cfg(feature = "active-speaker")]
Propagated::ActiveSpeakerChanged { .. } => {}
#[cfg(feature = "pacer")]
Propagated::AudioOnlyMode { .. } | Propagated::SuspendVideo { .. } => {}
}
}
}
#[cfg(any(test, feature = "test-utils"))]
#[doc(hidden)]
pub fn fanout_for_tests(p: &Propagated, clients: &mut [Client]) {
fanout(p, clients);
}