fork/rust-sdks

git clone https://git.julia.blue/fork/rust-sdks

David Zhaofix: pass disconnect reason explicitly (#581)2c627f5

main
17.6 KiB667 linesraw
1// Copyright 2023 LiveKit, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto2";
16
17package livekit.proto;
18option csharp_namespace = "LiveKit.Proto";
19
20import "e2ee.proto";
21import "handle.proto";
22import "participant.proto";
23import "track.proto";
24import "video_frame.proto";
25import "stats.proto";
26
27// Connect to a new LiveKit room
28message ConnectRequest {
29  required string url = 1;
30  required string token = 2;
31  required RoomOptions options = 3;
32}
33message ConnectResponse {
34  required uint64 async_id = 1;
35}
36message ConnectCallback {
37  message ParticipantWithTracks {
38    required OwnedParticipant participant = 1;
39
40    // TrackInfo are not needed here, if we're subscribed to a track, the FfiServer will send
41    // a TrackSubscribed event
42    repeated OwnedTrackPublication publications = 2;
43  }
44
45  message Result {
46    required OwnedRoom room = 1;
47    required OwnedParticipant local_participant = 2;
48    repeated ParticipantWithTracks participants = 3;
49  }
50
51  required uint64 async_id = 1;
52  oneof message {
53    string error = 2;
54    Result result = 3;
55  }
56
57}
58
59// Disconnect from the a room
60message DisconnectRequest { required uint64 room_handle = 1; }
61message DisconnectResponse { required uint64 async_id = 1; }
62message DisconnectCallback { required uint64 async_id = 1; }
63
64// Publish a track to the room
65message PublishTrackRequest {
66  required uint64 local_participant_handle = 1;
67  required uint64 track_handle = 2;
68  required TrackPublishOptions options = 3;
69}
70message PublishTrackResponse {
71  required uint64 async_id = 1;
72}
73message PublishTrackCallback {
74  required uint64 async_id = 1;
75  oneof message {
76    string error = 2;
77    OwnedTrackPublication publication = 3;
78  }
79
80}
81
82// Unpublish a track from the room
83message UnpublishTrackRequest {
84  required uint64 local_participant_handle = 1;
85  required string track_sid = 2;
86  required bool stop_on_unpublish = 3;
87}
88message UnpublishTrackResponse {
89  required uint64 async_id = 1;
90}
91message UnpublishTrackCallback {
92  required uint64 async_id = 1;
93  optional string error = 2;
94}
95
96// Publish data to other participants
97message PublishDataRequest {
98  required uint64 local_participant_handle = 1;
99  required uint64 data_ptr = 2;
100  required uint64 data_len = 3;
101  required bool reliable = 4;
102  repeated string destination_sids = 5 [deprecated=true];
103  optional string topic = 6;
104  repeated string destination_identities = 7;
105}
106message PublishDataResponse {
107  required uint64 async_id = 1;
108}
109message PublishDataCallback {
110  required uint64 async_id = 1;
111  optional string error = 2;
112}
113
114// Publish transcription messages to room
115message PublishTranscriptionRequest {
116  required uint64 local_participant_handle = 1;
117  required string participant_identity = 2;
118  required string track_id = 3;
119  repeated TranscriptionSegment segments = 4;
120}
121message PublishTranscriptionResponse {
122  required uint64 async_id = 1;
123}
124message PublishTranscriptionCallback {
125  required uint64 async_id = 1;
126  optional string error = 2;
127}
128
129// Publish Sip DTMF messages to other participants
130message PublishSipDtmfRequest {
131  required uint64 local_participant_handle = 1;
132  required uint32 code = 2;
133  required string digit = 3;
134  repeated string destination_identities = 4;
135}
136message PublishSipDtmfResponse {
137  required uint64 async_id = 1;
138}
139message PublishSipDtmfCallback {
140  required uint64 async_id = 1;
141  optional string error = 2;
142}
143
144// Change the local participant's metadata
145message SetLocalMetadataRequest {
146  required uint64 local_participant_handle = 1;
147  required string metadata = 2;
148}
149message SetLocalMetadataResponse {
150  required uint64 async_id = 1;
151}
152message SetLocalMetadataCallback {
153  required uint64 async_id = 1;
154  optional string error = 2;
155}
156
157message SendChatMessageRequest {
158  required uint64 local_participant_handle = 1;
159  required string message = 2;
160  repeated string destination_identities = 3;
161  optional string sender_identity = 4;
162}
163message EditChatMessageRequest {
164  required uint64 local_participant_handle = 1;
165  required string edit_text = 2;
166  required ChatMessage original_message = 3;
167  repeated string destination_identities = 4;
168  optional string sender_identity = 5;
169}
170message SendChatMessageResponse {
171  required uint64 async_id = 1;
172}
173message SendChatMessageCallback {
174  required uint64 async_id = 1;
175  oneof message {
176    string error = 2;
177    ChatMessage chat_message = 3;
178  }
179}
180
181// Change the local participant's attributes
182message SetLocalAttributesRequest {
183  required uint64 local_participant_handle = 1;
184  repeated AttributesEntry attributes = 2;
185}
186
187message AttributesEntry {
188  required string key = 1;
189  required string value = 2;
190}
191
192message SetLocalAttributesResponse {
193  required uint64 async_id = 1;
194}
195message SetLocalAttributesCallback {
196  required uint64 async_id = 1;
197  optional string error = 2;
198}
199
200// Change the local participant's name
201message SetLocalNameRequest {
202  required uint64 local_participant_handle = 1;
203  required string name = 2;
204}
205message SetLocalNameResponse {
206  required uint64 async_id = 1;
207}
208message SetLocalNameCallback {
209  required uint64 async_id = 1;
210  optional string error = 2;
211}
212
213// Change the "desire" to subs2ribe to a track
214message SetSubscribedRequest {
215  required bool subscribe = 1;
216  required uint64 publication_handle = 2;
217}
218message SetSubscribedResponse {}
219
220message GetSessionStatsRequest {
221  required uint64 room_handle = 1;
222}
223message GetSessionStatsResponse {
224  required uint64 async_id = 1;
225}
226message GetSessionStatsCallback {
227  message Result {
228    repeated RtcStats publisher_stats = 1;
229    repeated RtcStats subscriber_stats = 2;
230  }
231
232  required uint64 async_id = 1;
233
234  oneof message {
235    string error = 2;
236    Result result = 3;
237  }
238}
239
240//
241// Options
242//
243
244message VideoEncoding {
245  required uint64 max_bitrate = 1;
246  required double max_framerate = 2;
247}
248
249message AudioEncoding {
250  required uint64 max_bitrate = 1;
251}
252
253message TrackPublishOptions {
254  // encodings are optional
255  optional VideoEncoding video_encoding = 1;
256  optional AudioEncoding audio_encoding = 2;
257  optional VideoCodec video_codec = 3;
258  optional bool dtx = 4;
259  optional bool red = 5;
260  optional bool simulcast = 6;
261  optional TrackSource source = 7;
262  optional string stream = 8;
263}
264
265enum IceTransportType {
266  TRANSPORT_RELAY = 0;
267  TRANSPORT_NOHOST = 1;
268  TRANSPORT_ALL = 2;
269}
270
271enum ContinualGatheringPolicy {
272  GATHER_ONCE = 0;
273  GATHER_CONTINUALLY = 1;
274}
275
276message IceServer {
277  repeated string urls = 1;
278  optional string username = 2;
279  optional string password = 3;
280}
281
282message RtcConfig {
283  optional IceTransportType ice_transport_type = 1;
284  optional ContinualGatheringPolicy continual_gathering_policy = 2;
285  repeated IceServer ice_servers = 3; // empty fallback to default
286}
287
288message RoomOptions {
289  optional bool auto_subscribe = 1;
290  optional bool adaptive_stream = 2;
291  optional bool dynacast = 3;
292  optional E2eeOptions e2ee = 4;
293  optional RtcConfig rtc_config = 5; // allow to setup a custom RtcConfiguration
294  optional uint32 join_retries = 6;
295}
296
297//
298// Room
299//
300
301enum ConnectionQuality {
302  QUALITY_POOR = 0;
303  QUALITY_GOOD = 1;
304  QUALITY_EXCELLENT = 2;
305  QUALITY_LOST = 3;
306}
307
308enum ConnectionState {
309  CONN_DISCONNECTED = 0;
310  CONN_CONNECTED = 1;
311  CONN_RECONNECTING = 2;
312}
313
314enum DataPacketKind {
315  KIND_LOSSY = 0;
316  KIND_RELIABLE = 1;
317}
318
319message TranscriptionSegment {
320  required string id = 1;
321  required string text = 2;
322  required uint64 start_time = 3;
323  required uint64 end_time = 4;
324  required bool final = 5;
325  required string language = 6;
326}
327
328message BufferInfo {
329  required uint64 data_ptr = 1;
330  required uint64 data_len = 2;
331}
332
333message OwnedBuffer {
334  required FfiOwnedHandle handle = 1;
335  required BufferInfo data = 2;
336}
337
338message RoomEvent {
339  required uint64 room_handle = 1;
340  oneof message {
341    ParticipantConnected participant_connected = 2;
342    ParticipantDisconnected participant_disconnected = 3;
343    LocalTrackPublished local_track_published = 4;
344    LocalTrackUnpublished local_track_unpublished = 5;
345    LocalTrackSubscribed local_track_subscribed = 6;
346    TrackPublished track_published = 7;
347    TrackUnpublished track_unpublished = 8;
348    TrackSubscribed track_subscribed = 9;
349    TrackUnsubscribed track_unsubscribed = 10;
350    TrackSubscriptionFailed track_subscription_failed = 11;
351    TrackMuted track_muted = 12;
352    TrackUnmuted track_unmuted = 13;
353    ActiveSpeakersChanged active_speakers_changed = 14;
354    RoomMetadataChanged room_metadata_changed = 15;
355    RoomSidChanged room_sid_changed = 16;
356    ParticipantMetadataChanged participant_metadata_changed = 17;
357    ParticipantNameChanged participant_name_changed = 18;
358    ParticipantAttributesChanged participant_attributes_changed = 19;
359    ConnectionQualityChanged connection_quality_changed = 20;
360    ConnectionStateChanged connection_state_changed = 21;
361    // Connected connected = 21;
362    Disconnected disconnected = 22;
363    Reconnecting reconnecting = 23;
364    Reconnected reconnected = 24;
365    E2eeStateChanged e2ee_state_changed = 25;
366    RoomEOS eos = 26; // The stream of room events has ended
367    DataPacketReceived data_packet_received = 27;
368    TranscriptionReceived transcription_received = 28;
369    ChatMessageReceived chat_message = 29;
370    DataStreamHeaderReceived stream_header_received = 30;
371    DataStreamChunkReceived stream_chunk_received = 31;
372    DataStreamTrailerReceived stream_trailer_received = 32;
373    DataChannelBufferedAmountLowThresholdChanged data_channel_low_threshold_changed = 33;
374  }
375}
376
377message RoomInfo {
378  optional string sid = 1;
379  required string name = 2;
380  required string metadata = 3;
381  required uint64 lossy_dc_buffered_amount_low_threshold = 4;
382  required uint64 reliable_dc_buffered_amount_low_threshold = 5;
383}
384
385message OwnedRoom {
386  required FfiOwnedHandle handle = 1;
387  required RoomInfo info = 2;
388}
389
390message ParticipantConnected { required OwnedParticipant info = 1; }
391
392message ParticipantDisconnected {
393  required string participant_identity = 1;
394  required DisconnectReason disconnect_reason = 2;
395}
396
397message LocalTrackPublished {
398  // The TrackPublicationInfo comes from the PublishTrack response
399  // and the FfiClient musts wait for it before firing this event
400  required string track_sid = 1;
401}
402
403message LocalTrackUnpublished {
404  required string publication_sid = 1;
405}
406
407message LocalTrackSubscribed {
408  required string track_sid = 2;
409}
410
411message TrackPublished {
412  required string participant_identity = 1;
413  required OwnedTrackPublication publication = 2;
414}
415
416message TrackUnpublished {
417  required string participant_identity = 1;
418  required string publication_sid = 2;
419}
420
421// Publication isn't needed for subscription events on the FFI
422// The FFI will retrieve the publication using the Track sid
423message TrackSubscribed {
424  required string participant_identity = 1;
425  required OwnedTrack track = 2;
426}
427
428message TrackUnsubscribed {
429  // The FFI language can dispose/remove the VideoSink here
430  required string participant_identity = 1;
431  required string track_sid = 2;
432}
433
434message TrackSubscriptionFailed {
435  required string participant_identity = 1;
436  required string track_sid = 2;
437  required string error = 3;
438}
439
440message TrackMuted {
441  required string participant_identity = 1;
442  required string track_sid = 2;
443}
444
445message TrackUnmuted {
446  required string participant_identity = 1;
447  required string track_sid = 2;
448}
449
450message E2eeStateChanged {
451  required string participant_identity = 1; // Using sid instead of identity for ffi communication
452  required EncryptionState state = 2;
453}
454
455message ActiveSpeakersChanged { repeated string participant_identities = 1; }
456
457message RoomMetadataChanged {
458  required string metadata = 1;
459}
460
461message RoomSidChanged {
462  required string sid = 1;
463}
464
465message ParticipantMetadataChanged {
466  required string participant_identity = 1;
467  required string metadata = 2;
468}
469
470message ParticipantAttributesChanged {
471  required string participant_identity = 1;
472  repeated AttributesEntry attributes = 2;
473  repeated AttributesEntry changed_attributes = 3;
474}
475
476message ParticipantNameChanged {
477  required string participant_identity = 1;
478  required string name = 2;
479}
480
481message ConnectionQualityChanged {
482  required string participant_identity = 1;
483  required ConnectionQuality quality = 2;
484}
485
486message UserPacket {
487  required OwnedBuffer data = 1;
488  optional string topic = 2;
489}
490
491message ChatMessage {
492  required string id = 1;
493  required int64 timestamp = 2;
494  required string message = 3;
495  optional int64 edit_timestamp = 4;
496  optional bool deleted = 5;
497  optional bool generated = 6;
498}
499
500message ChatMessageReceived {
501  required ChatMessage message = 1;
502  required string participant_identity = 2;
503}
504
505message SipDTMF {
506  required uint32 code = 1;
507  optional string digit = 2;
508}
509
510message DataPacketReceived {
511  required DataPacketKind kind = 1;
512  required string participant_identity = 2; // Can be empty if the data is sent a server SDK
513  oneof value {
514    UserPacket user = 4;
515    SipDTMF sip_dtmf = 5;
516  }
517}
518
519message TranscriptionReceived {
520  optional string participant_identity = 1;
521  optional string track_sid = 2;
522  repeated TranscriptionSegment segments = 3;
523}
524
525message ConnectionStateChanged { required ConnectionState state = 1; }
526
527message Connected {}
528message Disconnected {
529  required DisconnectReason reason = 1;
530}
531message Reconnecting {}
532message Reconnected {}
533
534message RoomEOS {}
535
536message DataStream {
537
538  // enum for operation types (specific to TextHeader)
539  enum OperationType {
540    CREATE = 0;
541    UPDATE = 1;
542    DELETE = 2;
543    REACTION = 3;
544  }
545
546  // header properties specific to text streams
547  message TextHeader {
548    required OperationType operation_type = 1;
549    optional int32 version = 2;  // Optional: Version for updates/edits
550    optional string reply_to_stream_id = 3;  // Optional: Reply to specific message
551    repeated string attached_stream_ids = 4; // file attachments for text streams
552    optional bool generated = 5; // true if the text has been generated by an agent from a participant's audio transcription
553
554  }
555
556  // header properties specific to byte or file streams
557  message ByteHeader {
558    required string name = 1;
559  }
560
561  // main DataStream.Header that contains a oneof for specific headers
562  message Header {
563    required string stream_id = 1; // unique identifier for this data stream
564    required int64 timestamp = 2;  // using int64 for Unix timestamp
565    required string mime_type = 3;
566    required string topic = 4;
567    optional uint64 total_length = 5;  // only populated for finite streams, if it's a stream of unknown size this stays empty
568    map<string, string> attributes = 6;  // user defined attributes map that can carry additional info
569
570    // oneof to choose between specific header types
571    oneof content_header {
572      TextHeader text_header = 7;
573      ByteHeader byte_header = 8;
574    }
575  }
576
577  message Chunk {
578    required string stream_id = 1;  // unique identifier for this data stream to map it to the correct header
579    required uint64 chunk_index = 2;
580    required bytes content = 3; // content as binary (bytes)
581    optional int32 version = 4; // a version indicating that this chunk_index has been retroactively modified and the original one needs to be replaced
582    optional bytes iv = 5; // optional, initialization vector for AES-GCM encryption
583  }
584
585  message Trailer {
586    required string stream_id = 1; // unique identifier for this data stream
587    required string reason = 2; // reason why the stream was closed (could contain "error" / "interrupted" / empty for expected end)
588    map<string, string> attributes = 3; // finalizing updates for the stream, can also include additional insights for errors or endTime for transcription
589  }
590}
591
592message DataStreamHeaderReceived {
593  required string participant_identity = 1;
594  required DataStream.Header header = 2;
595}
596
597message DataStreamChunkReceived {
598  required string participant_identity = 1;
599  required DataStream.Chunk chunk = 2;
600}
601
602message DataStreamTrailerReceived {
603  required string participant_identity = 1;
604  required DataStream.Trailer trailer = 2;
605}
606
607message SendStreamHeaderRequest {
608  required uint64 local_participant_handle = 1;
609  required DataStream.Header header = 2;
610  repeated string destination_identities = 3;
611  required string sender_identity = 4;
612}
613
614message SendStreamChunkRequest {
615  required uint64 local_participant_handle = 1;
616  required DataStream.Chunk chunk = 2;
617  repeated string destination_identities = 3;
618  required string sender_identity = 4;
619}
620
621message SendStreamTrailerRequest {
622  required uint64 local_participant_handle = 1;
623  required DataStream.Trailer trailer = 2;
624  repeated string destination_identities = 3;
625  required string sender_identity = 4;
626}
627
628message SendStreamHeaderResponse {
629  required uint64 async_id = 1;
630}
631
632message SendStreamChunkResponse {
633  required uint64 async_id = 1;
634}
635
636message SendStreamTrailerResponse {
637  required uint64 async_id = 1;
638}
639
640message SendStreamHeaderCallback {
641  required uint64 async_id = 1;
642  optional string error = 2;
643}
644
645message SendStreamChunkCallback {
646  required uint64 async_id = 1;
647  optional string error = 2;
648}
649
650message SendStreamTrailerCallback {
651  required uint64 async_id = 1;
652  optional string error = 2;
653}
654
655message SetDataChannelBufferedAmountLowThresholdRequest {
656  required uint64 local_participant_handle = 1;
657  required uint64 threshold = 2;
658  required DataPacketKind kind = 3;
659}
660
661message SetDataChannelBufferedAmountLowThresholdResponse {
662}
663
664message DataChannelBufferedAmountLowThresholdChanged {
665  required DataPacketKind kind = 1;
666  required uint64 threshold = 2;
667}