Emit Frame
event when new frames are generated for a remote track
This commit is contained in:
parent
8c6de99159
commit
46635956f4
4 changed files with 27 additions and 12 deletions
|
@ -41,7 +41,7 @@ pub struct RemoteParticipant {
|
||||||
pub user: Arc<User>,
|
pub user: Arc<User>,
|
||||||
pub projects: Vec<proto::ParticipantProject>,
|
pub projects: Vec<proto::ParticipantProject>,
|
||||||
pub location: ParticipantLocation,
|
pub location: ParticipantLocation,
|
||||||
pub tracks: HashMap<String, RemoteVideoTrack>,
|
pub tracks: HashMap<live_kit_client::Sid, RemoteVideoTrack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -15,6 +15,10 @@ use util::ResultExt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
|
Frame {
|
||||||
|
participant_id: PeerId,
|
||||||
|
track_id: live_kit_client::Sid,
|
||||||
|
},
|
||||||
RemoteProjectShared {
|
RemoteProjectShared {
|
||||||
owner: Arc<User>,
|
owner: Arc<User>,
|
||||||
project_id: u64,
|
project_id: u64,
|
||||||
|
@ -390,7 +394,6 @@ impl Room {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match change {
|
match change {
|
||||||
RemoteVideoTrackUpdate::Subscribed(track) => {
|
RemoteVideoTrackUpdate::Subscribed(track) => {
|
||||||
dbg!(track.publisher_id(), track.sid());
|
|
||||||
let peer_id = PeerId(track.publisher_id().parse()?);
|
let peer_id = PeerId(track.publisher_id().parse()?);
|
||||||
let track_id = track.sid().to_string();
|
let track_id = track.sid().to_string();
|
||||||
let participant = self
|
let participant = self
|
||||||
|
@ -413,14 +416,16 @@ impl Room {
|
||||||
};
|
};
|
||||||
|
|
||||||
let done = this.update(&mut cx, |this, cx| {
|
let done = this.update(&mut cx, |this, cx| {
|
||||||
// TODO: replace this with an emit.
|
|
||||||
cx.notify();
|
|
||||||
if let Some(track) =
|
if let Some(track) =
|
||||||
this.remote_participants.get_mut(&peer_id).and_then(
|
this.remote_participants.get_mut(&peer_id).and_then(
|
||||||
|participant| participant.tracks.get_mut(&track_id),
|
|participant| participant.tracks.get_mut(&track_id),
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
track.frame = frame;
|
track.frame = frame;
|
||||||
|
cx.emit(Event::Frame {
|
||||||
|
participant_id: peer_id,
|
||||||
|
track_id: track_id.clone(),
|
||||||
|
});
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
|
|
@ -62,6 +62,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.remove_window(window_id);
|
cx.remove_window(window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,9 +980,8 @@ pub struct Workspace {
|
||||||
follower_states_by_leader: FollowerStatesByLeader,
|
follower_states_by_leader: FollowerStatesByLeader,
|
||||||
last_leaders_by_pane: HashMap<WeakViewHandle<Pane>, PeerId>,
|
last_leaders_by_pane: HashMap<WeakViewHandle<Pane>, PeerId>,
|
||||||
window_edited: bool,
|
window_edited: bool,
|
||||||
active_call: Option<ModelHandle<ActiveCall>>,
|
active_call: Option<(ModelHandle<ActiveCall>, Vec<gpui::Subscription>)>,
|
||||||
_observe_current_user: Task<()>,
|
_observe_current_user: Task<()>,
|
||||||
_active_call_observation: Option<gpui::Subscription>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -1092,11 +1091,18 @@ impl Workspace {
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut active_call = None;
|
let mut active_call = None;
|
||||||
let mut active_call_observation = None;
|
|
||||||
if cx.has_global::<ModelHandle<ActiveCall>>() {
|
if cx.has_global::<ModelHandle<ActiveCall>>() {
|
||||||
let call = cx.global::<ModelHandle<ActiveCall>>().clone();
|
let call = cx.global::<ModelHandle<ActiveCall>>().clone();
|
||||||
active_call_observation = Some(cx.observe(&call, |_, _, cx| cx.notify()));
|
let mut subscriptions = Vec::new();
|
||||||
active_call = Some(call);
|
subscriptions.push(cx.observe(&call, |_, _, cx| cx.notify()));
|
||||||
|
subscriptions.push(cx.subscribe(&call, |this, _, event, cx| {
|
||||||
|
if let call::room::Event::Frame { participant_id, .. } = event {
|
||||||
|
if this.follower_states_by_leader.contains_key(&participant_id) {
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
active_call = Some((call, subscriptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut this = Workspace {
|
let mut this = Workspace {
|
||||||
|
@ -1127,7 +1133,6 @@ impl Workspace {
|
||||||
window_edited: false,
|
window_edited: false,
|
||||||
active_call,
|
active_call,
|
||||||
_observe_current_user,
|
_observe_current_user,
|
||||||
_active_call_observation: active_call_observation,
|
|
||||||
};
|
};
|
||||||
this.project_remote_id_changed(this.project.read(cx).remote_id(), cx);
|
this.project_remote_id_changed(this.project.read(cx).remote_id(), cx);
|
||||||
cx.defer(|this, cx| this.update_window_title(cx));
|
cx.defer(|this, cx| this.update_window_title(cx));
|
||||||
|
@ -1262,7 +1267,7 @@ impl Workspace {
|
||||||
quitting: bool,
|
quitting: bool,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Task<Result<bool>> {
|
) -> Task<Result<bool>> {
|
||||||
let active_call = self.active_call.clone();
|
let active_call = self.active_call().cloned();
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
let workspace_count = cx
|
let workspace_count = cx
|
||||||
.window_ids()
|
.window_ids()
|
||||||
|
@ -2549,6 +2554,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn active_call(&self) -> Option<&ModelHandle<ActiveCall>> {
|
||||||
|
self.active_call.as_ref().map(|(call, _)| call)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Entity for Workspace {
|
impl Entity for Workspace {
|
||||||
|
@ -2590,7 +2599,7 @@ impl View for Workspace {
|
||||||
&project,
|
&project,
|
||||||
&theme,
|
&theme,
|
||||||
&self.follower_states_by_leader,
|
&self.follower_states_by_leader,
|
||||||
self.active_call.as_ref(),
|
self.active_call(),
|
||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
.flex(1., true)
|
.flex(1., true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue