Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data_stream trailer event #549

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions livekit/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ pub enum RoomEvent {
chunk: proto::data_stream::Chunk,
participant_identity: String,
},
StreamTrailerReceived {
trailer: proto::data_stream::Trailer,
participant_identity: String,
},
E2eeStateChanged {
participant: Participant,
state: EncryptionState,
Expand Down Expand Up @@ -734,6 +738,9 @@ impl RoomSession {
EngineEvent::DataStreamChunk { chunk, participant_identity } => {
self.handle_data_stream_chunk(chunk, participant_identity);
}
EngineEvent::DataStreamTrailer { trailer, participant_identity } => {
self.handle_data_stream_trailer(chunk, participant_identity);
}
_ => {}
}

Expand Down Expand Up @@ -1262,6 +1269,15 @@ impl RoomSession {
self.dispatcher.dispatch(&event);
}

fn handle_data_stream_trailer(
&self,
trailer: proto::data_stream::Trailer,
participant_identity: String,
) {
let event = RoomEvent::StreamTrailerReceived { trailer, participant_identity };
self.dispatcher.dispatch(&event);
}

/// Create a new participant
/// Also add it to the participants list
fn create_participant(
Expand Down
9 changes: 9 additions & 0 deletions livekit/src/rtc_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ pub enum EngineEvent {
chunk: proto::data_stream::Chunk,
participant_identity: String,
},
DataStreamTrailer {
trailer: proto::data_stream::Trailer,
participant_identity: String,
},
}

/// Represents a running RtcSession with the ability to close the session
Expand Down Expand Up @@ -542,6 +546,11 @@ impl EngineInner {
.engine_tx
.send(EngineEvent::DataStreamChunk { chunk, participant_identity });
}
SessionEvent::DataStreamTrailer { trailer, participant_identity } => {
let _ = self
.engine_tx
.send(EngineEvent::DataStreamTrailer { trailer, participant_identity });
}
}
Ok(())
}
Expand Down
10 changes: 10 additions & 0 deletions livekit/src/rtc_engine/rtc_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ pub enum SessionEvent {
chunk: proto::data_stream::Chunk,
participant_identity: String,
},
DataStreamTrailer {
trailer: proto::data_stream::Trailer,
participant_identity: String,
},
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -743,6 +747,12 @@ impl SessionInner {
participant_identity: data.participant_identity.clone(),
});
}
proto::data_packet::Value::StreamTrailer(message) => {
let _ = self.emitter.send(SessionEvent::DataStreamTrailer {
trailer: message.clone(),
participant_identity: data.participant_identity.clone(),
});
}
_ => {}
}
}
Expand Down
Loading