github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/protobufs/livekit_rtc.proto (about)

     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  
    15  syntax = "proto3";
    16  
    17  package livekit;
    18  option go_package = "github.com/livekit/protocol/livekit";
    19  option csharp_namespace = "LiveKit.Proto";
    20  option ruby_package = "LiveKit::Proto";
    21  
    22  import "livekit_models.proto";
    23  
    24  message SignalRequest {
    25    oneof message {
    26      // initial join exchange, for publisher
    27      SessionDescription offer = 1;
    28      // participant answering publisher offer
    29      SessionDescription answer = 2;
    30      TrickleRequest trickle = 3;
    31      AddTrackRequest add_track = 4;
    32      // mute the participant's published tracks
    33      MuteTrackRequest mute = 5;
    34      // Subscribe or unsubscribe from tracks
    35      UpdateSubscription subscription = 6;
    36      // Update settings of subscribed tracks
    37      UpdateTrackSettings track_setting = 7;
    38      // Immediately terminate session
    39      LeaveRequest leave = 8;
    40      // Update published video layers
    41      UpdateVideoLayers update_layers = 10 [deprecated = true];
    42      // Update subscriber permissions
    43      SubscriptionPermission subscription_permission = 11;
    44      // sync client's subscribe state to server during reconnect
    45      SyncState sync_state = 12;
    46      // Simulate conditions, for client validations
    47      SimulateScenario simulate = 13;
    48      // client triggered ping to server
    49      int64 ping = 14; // deprecated by ping_req (message Ping)
    50      // update a participant's own metadata and/or name
    51      UpdateParticipantMetadata update_metadata = 15;
    52      Ping ping_req = 16;
    53      // Update local audio track settings
    54      UpdateLocalAudioTrack update_audio_track = 17;
    55      // Update local video track settings
    56      UpdateLocalVideoTrack update_video_track = 18;
    57    }
    58  }
    59  
    60  message SignalResponse {
    61    oneof message {
    62      // sent when join is accepted
    63      JoinResponse join = 1;
    64      // sent when server answers publisher
    65      SessionDescription answer = 2;
    66      // sent when server is sending subscriber an offer
    67      SessionDescription offer = 3;
    68      // sent when an ICE candidate is available
    69      TrickleRequest trickle = 4;
    70      // sent when participants in the room has changed
    71      ParticipantUpdate update = 5;
    72      // sent to the participant when their track has been published
    73      TrackPublishedResponse track_published = 6;
    74      // Immediately terminate session
    75      LeaveRequest leave = 8;
    76      // server initiated mute
    77      MuteTrackRequest mute = 9;
    78      // indicates changes to speaker status, including when they've gone to not speaking
    79      SpeakersChanged speakers_changed = 10;
    80      // sent when metadata of the room has changed
    81      RoomUpdate room_update = 11;
    82      // when connection quality changed
    83      ConnectionQualityUpdate connection_quality = 12;
    84      // when streamed tracks state changed, used to notify when any of the streams were paused due to
    85      // congestion
    86      StreamStateUpdate stream_state_update = 13;
    87      // when max subscribe quality changed, used by dynamic broadcasting to disable unused layers
    88      SubscribedQualityUpdate subscribed_quality_update = 14;
    89      // when subscription permission changed
    90      SubscriptionPermissionUpdate subscription_permission_update = 15;
    91      // update the token the client was using, to prevent an active client from using an expired token
    92      string refresh_token = 16;
    93      // server initiated track unpublish
    94      TrackUnpublishedResponse track_unpublished = 17;
    95      // respond to ping
    96      int64 pong = 18; // deprecated by pong_resp (message Pong)
    97      // sent when client reconnects
    98      ReconnectResponse reconnect = 19;
    99      // respond to Ping
   100      Pong pong_resp = 20;
   101      // Subscription response, client should not expect any media from this subscription if it fails
   102      SubscriptionResponse subscription_response = 21;
   103    }
   104  }
   105  
   106  enum SignalTarget {
   107    PUBLISHER = 0;
   108    SUBSCRIBER = 1;
   109  }
   110  
   111  message SimulcastCodec {
   112    string codec = 1;
   113    string cid = 2;
   114    
   115    // NEXT-ID: 4
   116  }
   117  
   118  message AddTrackRequest {
   119    // client ID of track, to match it when RTC track is received
   120    string cid = 1;
   121    string name = 2;
   122    TrackType type = 3;
   123    // to be deprecated in favor of layers
   124    uint32 width = 4;
   125    uint32 height = 5;
   126    // true to add track and initialize to muted
   127    bool muted = 6;
   128    // true if DTX (Discontinuous Transmission) is disabled for audio
   129    bool disable_dtx = 7;
   130    TrackSource source = 8;
   131    repeated VideoLayer layers = 9;
   132  
   133    repeated SimulcastCodec simulcast_codecs = 10;
   134  
   135    // server ID of track, publish new codec to exist track
   136    string sid = 11;
   137  
   138    bool stereo = 12;
   139    // true if RED (Redundant Encoding) is disabled for audio
   140    bool disable_red = 13;
   141  
   142    Encryption.Type encryption = 14;
   143    // which stream the track belongs to, used to group tracks together.
   144    // if not specified, server will infer it from track source to bundle camera/microphone, screenshare/audio together
   145    string stream = 15;
   146  }
   147  
   148  message TrickleRequest {
   149    string candidateInit = 1;
   150    SignalTarget target = 2;
   151  }
   152  
   153  message MuteTrackRequest {
   154    string sid = 1;
   155    bool muted = 2;
   156  }
   157  
   158  message JoinResponse {
   159    Room room = 1;
   160    ParticipantInfo participant = 2;
   161    repeated ParticipantInfo other_participants = 3;
   162    // deprecated. use server_info.version instead.
   163    string server_version = 4;
   164    repeated ICEServer ice_servers = 5;
   165    // use subscriber as the primary PeerConnection
   166    bool subscriber_primary = 6;
   167    // when the current server isn't available, return alternate url to retry connection
   168    // when this is set, the other fields will be largely empty
   169    string alternative_url = 7;
   170    ClientConfiguration client_configuration = 8;
   171    // deprecated. use server_info.region instead.
   172    string server_region = 9;
   173    int32 ping_timeout = 10;
   174    int32 ping_interval = 11;
   175    ServerInfo server_info = 12;
   176    // Server-Injected-Frame byte trailer, used to identify unencrypted frames when e2ee is enabled
   177    bytes sif_trailer = 13;
   178  }
   179  
   180  message ReconnectResponse {
   181    repeated ICEServer ice_servers = 1;
   182    ClientConfiguration client_configuration = 2;
   183  }
   184  
   185  message TrackPublishedResponse {
   186    string cid = 1;
   187    TrackInfo track = 2;
   188  }
   189  
   190  message TrackUnpublishedResponse {
   191    string track_sid = 1;
   192  }
   193  
   194  message SessionDescription {
   195    string type = 1; // "answer" | "offer" | "pranswer" | "rollback"
   196    string sdp = 2;
   197  }
   198  
   199  message ParticipantUpdate {
   200    repeated ParticipantInfo participants = 1;
   201  }
   202  
   203  message UpdateSubscription {
   204    repeated string track_sids = 1;
   205    bool subscribe = 2;
   206    repeated ParticipantTracks participant_tracks = 3;
   207  }
   208  
   209  message UpdateTrackSettings {
   210    repeated string track_sids = 1;
   211    // when true, the track is placed in a paused state, with no new data returned
   212    bool disabled = 3;
   213    // deprecated in favor of width & height
   214    VideoQuality quality = 4;
   215    // for video, width to receive
   216    uint32 width = 5;
   217    // for video, height to receive
   218    uint32 height = 6;
   219    uint32 fps = 7;
   220    // subscription priority. 1 being the highest (0 is unset)
   221    // when unset, server sill assign priority based on the order of subscription
   222    // server will use priority in the following ways:
   223    // 1. when subscribed tracks exceed per-participant subscription limit, server will
   224    //    pause the lowest priority tracks
   225    // 2. when the network is congested, server will assign available bandwidth to
   226    //    higher priority tracks first. lowest priority tracks can be paused
   227    uint32 priority = 8;
   228  }
   229  
   230  
   231  
   232  message UpdateLocalAudioTrack {
   233    string track_sid = 1;
   234    repeated AudioTrackFeature features = 2;
   235  }
   236  
   237  message UpdateLocalVideoTrack {
   238    string track_sid = 1;
   239    uint32 width = 2;
   240    uint32 height = 3;
   241  }
   242  
   243  message LeaveRequest {
   244    // indicates action clients should take on receiving this message
   245    enum Action {
   246      DISCONNECT = 0;  // should disconnect
   247      RESUME = 1;      // should attempt a resume with `reconnect=1` in join URL
   248      RECONNECT = 2;   // should attempt a reconnect, i. e. no `reconnect=1`
   249    }
   250  
   251    // sent when server initiates the disconnect due to server-restart
   252    // indicates clients should attempt full-reconnect sequence
   253    // NOTE: `can_reconnect` obsoleted by `action` starting in protocol version 13
   254    bool can_reconnect = 1;
   255    DisconnectReason reason = 2;
   256    Action action = 3;
   257    RegionSettings regions = 4;
   258  }
   259  
   260  // message to indicate published video track dimensions are changing
   261  message UpdateVideoLayers {
   262    option deprecated = true;
   263    string track_sid = 1;
   264    repeated VideoLayer layers = 2;
   265  }
   266  
   267  message UpdateParticipantMetadata {
   268    string metadata = 1;
   269    string name = 2;
   270  }
   271  
   272  message ICEServer {
   273    repeated string urls = 1;
   274    string username = 2;
   275    string credential = 3;
   276  }
   277  
   278  message SpeakersChanged {
   279    repeated SpeakerInfo speakers = 1;
   280  }
   281  
   282  message RoomUpdate {
   283    Room room = 1;
   284  }
   285  
   286  message ConnectionQualityInfo {
   287    string participant_sid = 1;
   288    ConnectionQuality quality = 2;
   289    float score = 3;
   290  }
   291  
   292  message ConnectionQualityUpdate {
   293    repeated ConnectionQualityInfo updates = 1;
   294  }
   295  
   296  enum StreamState {
   297    ACTIVE = 0;
   298    PAUSED = 1;
   299  }
   300  
   301  message StreamStateInfo {
   302    string participant_sid = 1;
   303    string track_sid = 2;
   304    StreamState state = 3;
   305  }
   306  
   307  message StreamStateUpdate {
   308    repeated StreamStateInfo stream_states = 1;
   309  }
   310  
   311  message SubscribedQuality {
   312    VideoQuality quality = 1;
   313    bool enabled = 2;
   314  }
   315  
   316  message SubscribedCodec {
   317    string codec = 1;
   318    repeated SubscribedQuality qualities = 2;
   319  }
   320  
   321  message SubscribedQualityUpdate {
   322    string track_sid = 1;
   323    repeated SubscribedQuality subscribed_qualities = 2;
   324    repeated SubscribedCodec subscribed_codecs = 3;
   325  }
   326  
   327  message TrackPermission {
   328    // permission could be granted either by participant sid or identity
   329    string participant_sid = 1;
   330    bool all_tracks = 2;
   331    repeated string track_sids = 3;
   332    string participant_identity = 4;
   333  }
   334  
   335  message SubscriptionPermission {
   336    bool all_participants = 1;
   337    repeated TrackPermission track_permissions = 2;
   338  }
   339  
   340  message SubscriptionPermissionUpdate {
   341    string participant_sid = 1;
   342    string track_sid = 2;
   343    bool allowed = 3;
   344  }
   345  
   346  message SyncState {
   347    // last subscribe answer before reconnecting
   348    SessionDescription answer = 1;
   349    UpdateSubscription subscription = 2;
   350    repeated TrackPublishedResponse publish_tracks = 3;
   351    repeated DataChannelInfo data_channels = 4;
   352    // last received server side offer before reconnecting
   353    SessionDescription offer = 5;
   354    repeated string track_sids_disabled = 6;
   355  }
   356  
   357  message DataChannelInfo {
   358    string label = 1;
   359    uint32 id = 2;
   360    SignalTarget target = 3;
   361  }
   362  
   363  enum CandidateProtocol {
   364    UDP = 0;
   365    TCP = 1;
   366    TLS = 2;
   367  }
   368  
   369  message SimulateScenario {
   370    oneof scenario {
   371      // simulate N seconds of speaker activity
   372      int32 speaker_update = 1;
   373      // simulate local node failure
   374      bool node_failure = 2;
   375      // simulate migration
   376      bool migration = 3;
   377      // server to send leave
   378      bool server_leave = 4;
   379      // switch candidate protocol to tcp
   380      CandidateProtocol switch_candidate_protocol = 5;
   381      // maximum bandwidth for subscribers, in bps
   382      // when zero, clears artificial bandwidth limit
   383      int64 subscriber_bandwidth = 6;
   384      // disconnect signal on resume
   385      bool disconnect_signal_on_resume = 7;
   386      // disconnect signal on resume before sending any messages from server
   387      bool disconnect_signal_on_resume_no_messages = 8;
   388      // full reconnect leave request
   389      bool leave_request_full_reconnect = 9;
   390    }
   391  }
   392  
   393  message Ping {
   394    int64 timestamp = 1;
   395    // rtt in milliseconds calculated by client
   396    int64 rtt = 2;
   397  }
   398  
   399  message Pong {
   400    // timestamp field of last received ping request
   401    int64 last_ping_timestamp = 1;
   402    int64 timestamp = 2;
   403  }
   404  
   405  message RegionSettings {
   406    repeated RegionInfo regions = 1;
   407  }
   408  
   409  message RegionInfo {
   410    string region = 1;
   411    string url = 2;
   412    int64 distance = 3;
   413  }
   414  
   415  message SubscriptionResponse {
   416    string track_sid = 1;
   417    SubscriptionError err = 2;
   418  }