Skip to content
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
1 change: 1 addition & 0 deletions livekit-api/src/services/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ impl SIPClient {
// TODO: support these attributes
include_headers: Default::default(),
media_encryption: Default::default(),
destination_country: Default::default(),
}),
},
self.base.auth_header(
Expand Down
2 changes: 1 addition & 1 deletion livekit-api/src/signal_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub type SignalEvents = mpsc::UnboundedReceiver<SignalEvent>;
pub type SignalResult<T> = Result<T, SignalError>;

pub const JOIN_RESPONSE_TIMEOUT: Duration = Duration::from_secs(5);
pub const PROTOCOL_VERSION: u32 = 15;
pub const PROTOCOL_VERSION: u32 = 16;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PROTOCOL_VERSION defined in the cloud side as well? I just wanted to know how we manage this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's defined here


#[derive(Error, Debug)]
pub enum SignalError {
Expand Down
1 change: 1 addition & 0 deletions livekit-ffi/protocol/participant.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ enum DisconnectReason {
// SIP protocol failure or unexpected response
SIP_TRUNK_FAILURE = 13;
CONNECTION_TIMEOUT = 14;
MEDIA_FAILURE = 15;
}
17 changes: 17 additions & 0 deletions livekit-ffi/protocol/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ message RoomEvent {
// Data stream (high level)
ByteStreamOpened byte_stream_opened = 34;
TextStreamOpened text_stream_opened = 35;
// Room info updated
RoomInfo room_updated = 36;
// Participant moved to new room
RoomInfo moved = 37;
// carry over all participant info updates, including sid
ParticipantsUpdated participants_updated = 38;
}
}

Expand All @@ -385,13 +391,24 @@ message RoomInfo {
required string metadata = 3;
required uint64 lossy_dc_buffered_amount_low_threshold = 4;
required uint64 reliable_dc_buffered_amount_low_threshold = 5;
required uint32 empty_timeout = 6;
required uint32 departure_timeout = 7;
required uint32 max_participants = 8;
required int64 creation_time = 9;
required uint32 num_participants = 10;
required uint32 num_publishers = 11;
required bool active_recording = 12;
}

message OwnedRoom {
required FfiOwnedHandle handle = 1;
required RoomInfo info = 2;
}

message ParticipantsUpdated {
repeated ParticipantInfo participants = 1;
}

message ParticipantConnected { required OwnedParticipant info = 1; }

message ParticipantDisconnected {
Expand Down
9 changes: 8 additions & 1 deletion livekit-ffi/src/conversion/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
// limitations under the License.

use crate::{proto, server::participant::FfiParticipant};
use livekit::prelude::*;
use livekit::DisconnectReason;
use livekit::ParticipantKind;

impl From<&FfiParticipant> for proto::ParticipantInfo {
fn from(value: &FfiParticipant) -> Self {
let participant = &value.participant;
From::<&Participant>::from(&value.participant)
}
}

impl From<&Participant> for proto::ParticipantInfo {
fn from(participant: &Participant) -> Self {
Self {
sid: participant.sid().into(),
name: participant.name(),
Expand Down Expand Up @@ -62,6 +68,7 @@ impl From<DisconnectReason> for proto::DisconnectReason {
DisconnectReason::UserRejected => proto::DisconnectReason::UserRejected,
DisconnectReason::SipTrunkFailure => proto::DisconnectReason::SipTrunkFailure,
DisconnectReason::ConnectionTimeout => proto::DisconnectReason::ConnectionTimeout,
DisconnectReason::MediaFailure => proto::DisconnectReason::MediaFailure,
}
}
}
34 changes: 33 additions & 1 deletion livekit-ffi/src/conversion/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use livekit::{
native::frame_cryptor::EncryptionState,
prelude::{ContinualGatheringPolicy, IceServer, IceTransportsType, RtcConfiguration},
},
RoomInfo,
};

impl From<EncryptionState> for proto::EncryptionState {
Expand Down Expand Up @@ -99,6 +100,7 @@ impl From<DisconnectReason> for proto::DisconnectReason {
DisconnectReason::UserRejected => Self::UserRejected,
DisconnectReason::SipTrunkFailure => Self::SipTrunkFailure,
DisconnectReason::ConnectionTimeout => Self::ConnectionTimeout,
DisconnectReason::MediaFailure => Self::MediaFailure,
}
}
}
Expand Down Expand Up @@ -249,7 +251,7 @@ impl From<proto::AudioEncoding> for AudioEncoding {
impl From<&FfiRoom> for proto::RoomInfo {
fn from(value: &FfiRoom) -> Self {
let room = &value.inner.room;
Self {
proto::RoomInfo {
sid: room.maybe_sid().map(|x| x.to_string()),
name: room.name(),
metadata: room.metadata(),
Expand All @@ -259,6 +261,36 @@ impl From<&FfiRoom> for proto::RoomInfo {
reliable_dc_buffered_amount_low_threshold: room
.data_channel_options(DataPacketKind::Reliable)
.buffered_amount_low_threshold,
empty_timeout: room.empty_timeout(),
departure_timeout: room.departure_timeout(),
max_participants: room.max_participants(),
creation_time: room.creation_time(),
num_participants: room.num_participants(),
num_publishers: room.num_publishers(),
active_recording: room.active_recording(),
}
}
}

impl From<RoomInfo> for proto::RoomInfo {
fn from(room: RoomInfo) -> Self {
proto::RoomInfo {
sid: room.sid.map(|x| x.to_string()),
name: room.name,
metadata: room.metadata,
lossy_dc_buffered_amount_low_threshold: room
.lossy_dc_options
.buffered_amount_low_threshold,
reliable_dc_buffered_amount_low_threshold: room
.reliable_dc_options
.buffered_amount_low_threshold,
empty_timeout: room.empty_timeout,
departure_timeout: room.departure_timeout,
max_participants: room.max_participants,
creation_time: room.creation_time,
num_participants: room.num_participants,
num_publishers: room.num_publishers,
active_recording: room.active_recording,
}
}
}
Expand Down
34 changes: 33 additions & 1 deletion livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ pub enum DisconnectReason {
/// SIP protocol failure or unexpected response
SipTrunkFailure = 13,
ConnectionTimeout = 14,
MediaFailure = 15,
}
impl DisconnectReason {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -1762,6 +1763,7 @@ impl DisconnectReason {
DisconnectReason::UserRejected => "USER_REJECTED",
DisconnectReason::SipTrunkFailure => "SIP_TRUNK_FAILURE",
DisconnectReason::ConnectionTimeout => "CONNECTION_TIMEOUT",
DisconnectReason::MediaFailure => "MEDIA_FAILURE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand All @@ -1782,6 +1784,7 @@ impl DisconnectReason {
"USER_REJECTED" => Some(Self::UserRejected),
"SIP_TRUNK_FAILURE" => Some(Self::SipTrunkFailure),
"CONNECTION_TIMEOUT" => Some(Self::ConnectionTimeout),
"MEDIA_FAILURE" => Some(Self::MediaFailure),
_ => None,
}
}
Expand Down Expand Up @@ -3329,7 +3332,7 @@ pub struct OwnedBuffer {
pub struct RoomEvent {
#[prost(uint64, required, tag="1")]
pub room_handle: u64,
#[prost(oneof="room_event::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35")]
#[prost(oneof="room_event::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38")]
pub message: ::core::option::Option<room_event::Message>,
}
/// Nested message and enum types in `RoomEvent`.
Expand Down Expand Up @@ -3409,6 +3412,15 @@ pub mod room_event {
ByteStreamOpened(super::ByteStreamOpened),
#[prost(message, tag="35")]
TextStreamOpened(super::TextStreamOpened),
/// Room info updated
#[prost(message, tag="36")]
RoomUpdated(super::RoomInfo),
/// Participant moved to new room
#[prost(message, tag="37")]
Moved(super::RoomInfo),
/// carry over all participant info updates, including sid
#[prost(message, tag="38")]
ParticipantsUpdated(super::ParticipantsUpdated),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -3424,6 +3436,20 @@ pub struct RoomInfo {
pub lossy_dc_buffered_amount_low_threshold: u64,
#[prost(uint64, required, tag="5")]
pub reliable_dc_buffered_amount_low_threshold: u64,
#[prost(uint32, required, tag="6")]
pub empty_timeout: u32,
#[prost(uint32, required, tag="7")]
pub departure_timeout: u32,
#[prost(uint32, required, tag="8")]
pub max_participants: u32,
#[prost(int64, required, tag="9")]
pub creation_time: i64,
#[prost(uint32, required, tag="10")]
pub num_participants: u32,
#[prost(uint32, required, tag="11")]
pub num_publishers: u32,
#[prost(bool, required, tag="12")]
pub active_recording: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -3435,6 +3461,12 @@ pub struct OwnedRoom {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantsUpdated {
#[prost(message, repeated, tag="1")]
pub participants: ::prost::alloc::vec::Vec<ParticipantInfo>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParticipantConnected {
#[prost(message, required, tag="1")]
pub info: OwnedParticipant,
Expand Down
27 changes: 23 additions & 4 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ impl RoomInner {
));
}
}
sent_message;
drop(sent_message);
});
server.watch_panic(handle);
proto::SendChatMessageResponse { async_id }
Expand Down Expand Up @@ -699,7 +699,7 @@ impl RoomInner {
));
}
}
sent_message;
drop(sent_message);
});
server.watch_panic(handle);
proto::SendChatMessageResponse { async_id }
Expand All @@ -720,6 +720,7 @@ impl RoomInner {
send_stream_header.header.into(),
)
.into(),
..Default::default()
};
let async_id = server.next_id();
let inner = self.clone();
Expand Down Expand Up @@ -748,6 +749,7 @@ impl RoomInner {
send_stream_chunk.chunk.into(),
)
.into(),
..Default::default()
};
let async_id = server.next_id();
let inner = self.clone();
Expand Down Expand Up @@ -777,6 +779,7 @@ impl RoomInner {
send_stream_trailer.trailer.into(),
)
.into(),
..Default::default()
};
let async_id = server.next_id();
let inner = self.clone();
Expand Down Expand Up @@ -1248,7 +1251,7 @@ async fn forward_event(
));
}
RoomEvent::SipDTMFReceived { code, digit, participant } => {
let (sid, identity) = match participant {
let (_sid, identity) = match participant {
Some(p) => (Some(p.sid().to_string()), p.identity().to_string()),
None => (None, String::new()),
};
Expand All @@ -1265,7 +1268,7 @@ async fn forward_event(
}

RoomEvent::ChatMessage { message, participant } => {
let (sid, identity) = match participant {
let (_sid, identity) = match participant {
Some(p) => (Some(p.sid().to_string()), p.identity().to_string()),
None => (None, String::new()),
};
Expand Down Expand Up @@ -1359,6 +1362,22 @@ async fn forward_event(
},
));
}
RoomEvent::RoomUpdated { room } => {
let _ = send_event(proto::room_event::Message::RoomUpdated(room.into()));
}
RoomEvent::Moved { room } => {
let _ = send_event(proto::room_event::Message::Moved(room.into()));
}
RoomEvent::ParticipantsUpdated { participants } => {
let _ = send_event(proto::room_event::Message::ParticipantsUpdated(
proto::ParticipantsUpdated {
participants: participants
.into_iter()
.map(|p| proto::ParticipantInfo::from(&p))
.collect(),
},
));
}
_ => {
log::warn!("unhandled room event: {:?}", event);
}
Expand Down
2 changes: 1 addition & 1 deletion livekit-protocol/protocol
Submodule protocol updated 64 files
+0 −5 .changeset/angry-seas-beg.md
+0 −5 .changeset/five-pumas-love.md
+0 −5 .changeset/little-panthers-leave.md
+0 −5 .changeset/pretty-planets-impress.md
+20 −0 CHANGELOG.md
+6 −0 auth/accesstoken.go
+113 −0 auth/grants.go
+292 −0 auth/grants_test.go
+37 −37 go.mod
+88 −88 go.sum
+12 −3 livekit/livekit_agent.pb.go
+66 −42 livekit/livekit_cloud_agent.pb.go
+74 −72 livekit/livekit_cloud_agent.twirp.go
+32 −7 livekit/livekit_models.pb.go
+234 −136 livekit/livekit_rtc.pb.go
+53 −23 livekit/livekit_sip.pb.go
+280 −278 livekit/livekit_sip.twirp.go
+1 −0 livekit/sip.go
+12 −0 livekit/types.go
+6 −2 logger/logger.go
+1 −0 magefile.go
+19 −0 observability/reporter.go
+140 −0 observability/roomobs/gen_reporter.go
+157 −0 observability/roomobs/gen_reporter_noop.go
+91 −0 observability/roomobs/gen_source.go
+40 −0 observability/roomobs/participantrecorder.go
+98 −0 observability/roomobs/room.go
+17 −0 observability/roomobs/room_test.go
+26 −0 observability/sessiontimer.go
+6 −4 package.json
+40 −0 packages/javascript/CHANGELOG.md
+2 −2 packages/javascript/package.json
+622 −268 pnpm-lock.yaml
+2 −0 protobufs/livekit_agent.proto
+16 −16 protobufs/livekit_cloud_agent.proto
+8 −1 protobufs/livekit_models.proto
+12 −1 protobufs/livekit_rtc.proto
+12 −1 protobufs/livekit_sip.proto
+104 −0 protobufs/rpc/rest_signal.proto
+2 −1 protobufs/rpc/sip.proto
+11 −11 replay/cloud_replay.pb.go
+576 −0 rpc/rest_signal.pb.go
+362 −0 rpc/rest_signal.psrpc.go
+13 −9 rpc/sip.go
+13 −4 rpc/sip.pb.go
+65 −63 rpc/sip.psrpc.go
+9 −5 rpc/sip_test.go
+12 −0 rpc/typed_api.go
+33 −3 sdp/sdp.go
+2 −1 sdp/sdp_test.go
+121 −71 sip/sip.go
+137 −0 sip/sip_test.go
+2 −4 utils/configutil/atomic.go
+27 −0 utils/configutil/atomic_test.go
+23 −22 utils/guid/id.go
+23 −22 utils/id.go
+7 −0 utils/must/must.go
+107 −0 utils/time_size_cache.go
+91 −0 utils/time_size_cache_test.go
+7 −6 webhook/resource_queue.go
+23 −5 webhook/resource_url_notifier.go
+66 −0 webhook/stats.go
+3 −0 webhook/url_notifier.go
+9 −1 webhook/webhook_test.go
Loading
Loading