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 chat API #436

Merged
merged 17 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
/.idea
/.idea
.DS_Store
57 changes: 55 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ members = [
"webrtc-sys",
"webrtc-sys/build",
]
resolver = "2"
5 changes: 5 additions & 0 deletions livekit-api/src/services/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ impl SIPClient {
allowed_addresses: options.allowed_addresses.to_owned(),
auth_username: options.auth_username.to_owned(),
auth_password: options.auth_password.to_owned(),
headers: HashMap::new(), // FIXME Lukas
headers_to_attributes: HashMap::new(), // FIXME Lukas
}),
},
self.base.auth_header(
Expand Down Expand Up @@ -233,6 +235,9 @@ impl SIPClient {

auth_username: options.auth_username.to_owned(),
auth_password: options.auth_password.to_owned(),

headers: HashMap::new(), // FIXME Lukas
headers_to_attributes: HashMap::new(), // FIXME Lukas
lukasIO marked this conversation as resolved.
Show resolved Hide resolved
}),
},
self.base.auth_header(
Expand Down
8 changes: 8 additions & 0 deletions livekit-ffi/protocol/ffi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ message FfiRequest {
GetSessionStatsRequest get_session_stats = 12;
PublishTranscriptionRequest publish_transcription = 13;
PublishSipDtmfRequest publish_sip_dtmf = 14;
SendChatMessageRequest send_chat_message = 33;
EditChatMessageRequest edit_chat_message = 34;

// Track
CreateVideoTrackRequest create_video_track = 15;
Expand All @@ -93,6 +95,8 @@ message FfiRequest {
RemixAndResampleRequest remix_and_resample = 30;
E2eeRequest e2ee = 31;
AudioStreamFromParticipantRequest audio_stream_from_participant = 32;

// next-id 34
}
}

Expand All @@ -114,6 +118,7 @@ message FfiResponse {
GetSessionStatsResponse get_session_stats = 12;
PublishTranscriptionResponse publish_transcription = 13;
PublishSipDtmfResponse publish_sip_dtmf = 14;
SendChatMessageResponse send_chat_message = 33;

// Track
CreateVideoTrackResponse create_video_track = 15;
Expand All @@ -138,6 +143,8 @@ message FfiResponse {
RemixAndResampleResponse remix_and_resample = 30;
AudioStreamFromParticipantResponse audio_stream_from_participant = 31;
E2eeResponse e2ee = 32;

// next-id 34
}
}

Expand Down Expand Up @@ -166,6 +173,7 @@ message FfiEvent {
GetSessionStatsCallback get_session_stats = 19;
Panic panic = 20;
PublishSipDtmfCallback publish_sip_dtmf = 21;
SendChatMessageCallback chat_message = 22;
}
}

Expand Down
37 changes: 37 additions & 0 deletions livekit-ffi/protocol/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ message SetLocalMetadataCallback {
optional string error = 2;
}

message SendChatMessageRequest {
uint64 local_participant_handle = 1;
string message = 2;
repeated string destination_identities = 3;
optional string sender_identity = 4;
}
message EditChatMessageRequest {
uint64 local_participant_handle = 1;
string edit_text = 2;
ChatMessage original_message = 3;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the whole ChatMessage? Is it possible to just use the message_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in an ideal world, yeah, the ID would be enough.
We don't have a central authority for chat messages though. So for an edited message we'd still want to keep the e.g. original timestamp of the message, so passing the whole message seemed like the best idea.
But would be happy about alternative suggestions

repeated string destination_identities = 4;
optional string sender_identity = 5;
}
message SendChatMessageResponse {
uint64 async_id = 1;
}
message SendChatMessageCallback {
uint64 async_id = 1;
optional string error = 2;
optional ChatMessage chat_message = 3;
}

// Change the local participant's attributes
message SetLocalAttributesRequest {
uint64 local_participant_handle = 1;
Expand Down Expand Up @@ -343,6 +365,7 @@ message RoomEvent {
RoomEOS eos = 26; // The stream of room events has ended
DataPacketReceived data_packet_received = 27;
TranscriptionReceived transcription_received = 28;
ChatMessageReceived chat_message = 29;
}
}

Expand Down Expand Up @@ -457,6 +480,20 @@ message UserPacket {
optional string topic = 2;
}

message ChatMessage {
string id = 1;
int64 timestamp = 2;
string message = 3;
optional int64 edit_timestamp = 4;
optional bool deleted = 5;
optional bool generated = 6;
}

message ChatMessageReceived {
ChatMessage message = 1;
string participant_identity = 2;
}

message SipDTMF {
uint32 code = 1;
optional string digit = 2;
Expand Down
85 changes: 81 additions & 4 deletions livekit-ffi/src/livekit.proto.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @generated
// This file is @generated by prost-build.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FrameCryptor {
Expand Down Expand Up @@ -2209,6 +2210,48 @@ pub struct SetLocalMetadataCallback {
#[prost(string, optional, tag="2")]
pub error: ::core::option::Option<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendChatMessageRequest {
#[prost(uint64, tag="1")]
pub local_participant_handle: u64,
#[prost(string, tag="2")]
pub message: ::prost::alloc::string::String,
#[prost(string, repeated, tag="3")]
pub destination_identities: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag="4")]
pub sender_identity: ::core::option::Option<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EditChatMessageRequest {
#[prost(uint64, tag="1")]
pub local_participant_handle: u64,
#[prost(string, tag="2")]
pub edit_text: ::prost::alloc::string::String,
#[prost(message, optional, tag="3")]
pub original_message: ::core::option::Option<ChatMessage>,
#[prost(string, repeated, tag="4")]
pub destination_identities: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag="5")]
pub sender_identity: ::core::option::Option<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendChatMessageResponse {
#[prost(uint64, tag="1")]
pub async_id: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SendChatMessageCallback {
#[prost(uint64, tag="1")]
pub async_id: u64,
#[prost(string, optional, tag="2")]
pub error: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag="3")]
pub chat_message: ::core::option::Option<ChatMessage>,
}
/// Change the local participant's attributes
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -2406,7 +2449,7 @@ pub struct OwnedBuffer {
pub struct RoomEvent {
#[prost(uint64, 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")]
#[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")]
pub message: ::core::option::Option<room_event::Message>,
}
/// Nested message and enum types in `RoomEvent`.
Expand Down Expand Up @@ -2470,6 +2513,8 @@ pub mod room_event {
DataPacketReceived(super::DataPacketReceived),
#[prost(message, tag="28")]
TranscriptionReceived(super::TranscriptionReceived),
#[prost(message, tag="29")]
ChatMessage(super::ChatMessageReceived),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -2654,6 +2699,30 @@ pub struct UserPacket {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChatMessage {
#[prost(string, tag="1")]
pub id: ::prost::alloc::string::String,
#[prost(int64, tag="2")]
pub timestamp: i64,
#[prost(string, tag="3")]
pub message: ::prost::alloc::string::String,
#[prost(int64, optional, tag="4")]
pub edit_timestamp: ::core::option::Option<i64>,
#[prost(bool, optional, tag="5")]
pub deleted: ::core::option::Option<bool>,
#[prost(bool, optional, tag="6")]
pub generated: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChatMessageReceived {
#[prost(message, optional, tag="1")]
pub message: ::core::option::Option<ChatMessage>,
#[prost(string, tag="2")]
pub participant_identity: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SipDtmf {
#[prost(uint32, tag="1")]
pub code: u32,
Expand Down Expand Up @@ -3250,7 +3319,7 @@ impl AudioSourceType {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiRequest {
#[prost(oneof="ffi_request::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")]
#[prost(oneof="ffi_request::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 33, 34, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32")]
pub message: ::core::option::Option<ffi_request::Message>,
}
/// Nested message and enum types in `FfiRequest`.
Expand Down Expand Up @@ -3285,6 +3354,10 @@ pub mod ffi_request {
PublishTranscription(super::PublishTranscriptionRequest),
#[prost(message, tag="14")]
PublishSipDtmf(super::PublishSipDtmfRequest),
#[prost(message, tag="33")]
SendChatMessage(super::SendChatMessageRequest),
#[prost(message, tag="34")]
EditChatMessage(super::EditChatMessageRequest),
/// Track
#[prost(message, tag="15")]
CreateVideoTrack(super::CreateVideoTrackRequest),
Expand Down Expand Up @@ -3330,7 +3403,7 @@ pub mod ffi_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiResponse {
#[prost(oneof="ffi_response::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")]
#[prost(oneof="ffi_response::Message", tags="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 33, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32")]
pub message: ::core::option::Option<ffi_response::Message>,
}
/// Nested message and enum types in `FfiResponse`.
Expand Down Expand Up @@ -3365,6 +3438,8 @@ pub mod ffi_response {
PublishTranscription(super::PublishTranscriptionResponse),
#[prost(message, tag="14")]
PublishSipDtmf(super::PublishSipDtmfResponse),
#[prost(message, tag="33")]
SendChatMessage(super::SendChatMessageResponse),
/// Track
#[prost(message, tag="15")]
CreateVideoTrack(super::CreateVideoTrackResponse),
Expand Down Expand Up @@ -3412,7 +3487,7 @@ pub mod ffi_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FfiEvent {
#[prost(oneof="ffi_event::Message", tags="1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21")]
#[prost(oneof="ffi_event::Message", tags="1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22")]
pub message: ::core::option::Option<ffi_event::Message>,
}
/// Nested message and enum types in `FfiEvent`.
Expand Down Expand Up @@ -3460,6 +3535,8 @@ pub mod ffi_event {
Panic(super::Panic),
#[prost(message, tag="21")]
PublishSipDtmf(super::PublishSipDtmfCallback),
#[prost(message, tag="22")]
ChatMessage(super::SendChatMessageCallback),
}
}
/// Stop all rooms synchronously (Do we need async here?).
Expand Down
Loading
Loading