github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/livekit_rtc.proto (about)

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