Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Sep 23, 2023
1 parent a7740ab commit d6e6484
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 76 deletions.
59 changes: 34 additions & 25 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions livekit/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl Room {
let dispatcher = dispatcher.clone();
let e2ee_manager = e2ee_manager.clone();
move |participant, publication| {
log::info!("local track published: {:?}", publication);
let track = publication.track().unwrap();
let event = RoomEvent::LocalTrackPublished {
participant: participant.clone(),
Expand All @@ -236,6 +237,7 @@ impl Room {
let dispatcher = dispatcher.clone();
let e2ee_manager = e2ee_manager.clone();
move |participant, publication| {
log::info!("local track unpublished: {:?}", publication);
let event = RoomEvent::LocalTrackUnpublished {
participant: participant.clone(),
publication: publication.clone(),
Expand Down Expand Up @@ -442,19 +444,18 @@ impl RoomSession {
) {
loop {
tokio::select! {
res = engine_events.recv() => {
if let Some(event) = res {
if let Err(err) = self.on_engine_event(event).await {
log::error!("failed to handle engine event: {:?}", err);
}
Some(event) = engine_events.recv() => {
if let Err(err) = self.on_engine_event(event).await {
log::error!("failed to handle engine event: {:?}", err);
}
},
_ = &mut close_receiver => {
log::trace!("closing room_task");
break;
}
}
}

log::debug!("room_task closed");
}

async fn on_engine_event(self: &Arc<Self>, event: EngineEvent) -> RoomResult<()> {
Expand Down Expand Up @@ -564,7 +565,6 @@ impl RoomSession {
if let Some(remote_participant) = remote_participant {
if pi.state == proto::participant_info::State::Disconnected as i32 {
// Participant disconnected
log::info!("Participant disconnected: {:?}", participant_sid);
self.clone()
.handle_participant_disconnect(remote_participant)
} else {
Expand All @@ -573,7 +573,7 @@ impl RoomSession {
}
} else {
// Create a new participant
log::info!("Participant connected: {:?}", participant_sid);
log::info!("new participant: {:?}", pi);
let remote_participant = {
let pi = pi.clone();
self.create_participant(
Expand Down Expand Up @@ -781,7 +781,7 @@ impl RoomSession {
}

fn handle_disconnected(&self, reason: DisconnectReason) {
log::info!("disconnected from room,: {:?}", reason);
log::info!("disconnected from room: {:?}", reason);
if self.update_connection_state(ConnectionState::Disconnected) {
self.dispatcher
.dispatch(&RoomEvent::Disconnected { reason });
Expand Down Expand Up @@ -830,6 +830,7 @@ impl RoomSession {
let dispatcher = self.dispatcher.clone();
let e2ee_manager = self.e2ee_manager.clone();
move |participant, publication, track| {
log::info!("track subscribed: {:?}", track);
let event = RoomEvent::TrackSubscribed {
participant: participant.clone(),
track: track.clone(),
Expand All @@ -844,6 +845,7 @@ impl RoomSession {
let dispatcher = self.dispatcher.clone();
let e2ee_manager = self.e2ee_manager.clone();
move |participant, publication, track| {
log::info!("track unsubscribed: {:?}", track);
let event = RoomEvent::TrackUnsubscribed {
participant: participant.clone(),
track: track.clone(),
Expand Down Expand Up @@ -888,13 +890,13 @@ impl RoomSession {
});

self.participants.write().insert(sid, participant.clone());

participant
}

/// A participant has disconnected
/// Cleanup the participant and emit an event
fn handle_participant_disconnect(self: Arc<Self>, remote_participant: RemoteParticipant) {
log::info!("handle_participant_disconnect: {:?}", remote_participant);
for (sid, _) in remote_participant.tracks() {
remote_participant.unpublish_track(&sid);
}
Expand Down
1 change: 0 additions & 1 deletion livekit/src/room/participant/local_participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ impl LocalParticipant {
let publication = LocalTrackPublication::new(track_info.clone(), track.clone());
track.update_info(track_info); // Update sid + source

log::debug!("publishing track with cid {:?}", track.rtc_track().id());
let transceiver = self
.inner
.rtc_engine
Expand Down
2 changes: 0 additions & 2 deletions livekit/src/room/participant/remote_participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ impl RemoteParticipant {

track.set_transceiver(Some(transceiver));

log::debug!("starting track: {:?}", sid);

//track.set_muted(remote_publication.is_muted());
track.update_info(proto::TrackInfo {
sid: remote_publication.sid().to_string(),
Expand Down
1 change: 0 additions & 1 deletion livekit/src/room/track/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ pub(super) fn new_inner(
/// This is only called for local tracks
pub(super) fn set_muted(inner: &Arc<TrackInner>, track: &Track, muted: bool) {
let info = inner.info.read();
log::debug!("set_muted: {:?} {:?}", info.sid, muted);
if info.muted == muted {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions livekit/src/rtc_engine/lk_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl LkRuntime {
if let Some(lk_runtime) = lk_runtime_ref.upgrade() {
lk_runtime
} else {
log::trace!("LkRuntime::new()");
log::debug!("LkRuntime::new()");
let new_runtime = Arc::new(Self {
pc_factory: PeerConnectionFactory::default(),
});
Expand All @@ -54,6 +54,6 @@ impl LkRuntime {

impl Drop for LkRuntime {
fn drop(&mut self) {
log::trace!("LkRuntime::drop()");
log::debug!("LkRuntime::drop()");
}
}
13 changes: 6 additions & 7 deletions livekit/src/rtc_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,18 @@ impl EngineInner {
) {
loop {
tokio::select! {
res = session_events.recv() => {
if let Some(event) = res {
if let Err(err) = self.on_session_event(event).await {
log::error!("failed to handle session event: {:?}", err);
}
Some(event) = session_events.recv() => {
if let Err(err) = self.on_session_event(event).await {
log::error!("failed to handle session event: {:?}", err);
}
},
_ = &mut close_receiver => {
log::trace!("closing engine task");
break;
}
}
}

log::debug!("engine task closed");
}

async fn on_session_event(self: &Arc<Self>, event: SessionEvent) -> EngineResult<()> {
Expand Down Expand Up @@ -492,7 +491,7 @@ impl EngineInner {
inner.reconnecting.store(false, Ordering::Release);

if res.is_ok() {
log::info!("RtcEngine successfully reconnected")
log::info!("RtcEngine successfully recovered")
} else {
log::error!("failed to reconnect after {} attempts", RECONNECT_ATTEMPTS);
inner.close(DisconnectReason::UnknownReason).await;
Expand Down
1 change: 0 additions & 1 deletion livekit/src/rtc_engine/peer_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl PeerTransport {
let mut inner = self.inner.lock().await;

if options.ice_restart {
log::debug!("restarting ICE");
inner.restarting_ice = true;
}

Expand Down
Loading

0 comments on commit d6e6484

Please sign in to comment.