From a7d5c05321a5bc96ef032707abff1a2859192e73 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Fri, 11 Apr 2025 14:41:27 +0200 Subject: [PATCH 1/4] Add subscription permission by source and name --- protobufs/livekit_rtc.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protobufs/livekit_rtc.proto b/protobufs/livekit_rtc.proto index 26c6aeaed..8bd2ef91c 100644 --- a/protobufs/livekit_rtc.proto +++ b/protobufs/livekit_rtc.proto @@ -353,8 +353,10 @@ message SubscriptionPermission { message SubscriptionPermissionUpdate { string participant_sid = 1; - string track_sid = 2; + string track_sid = 2 [deprecated = true]; bool allowed = 3; + optional TrackSource track_source = 4; + optional string track_name = 5; } message SyncState { From 3f5874c00a504276d6b669dafe8876c2cbf3d01d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 12:42:55 +0000 Subject: [PATCH 2/4] generated protobuf --- livekit/livekit_rtc.pb.go | 71 ++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/livekit/livekit_rtc.pb.go b/livekit/livekit_rtc.pb.go index 5845bbd58..a2d47629f 100644 --- a/livekit/livekit_rtc.pb.go +++ b/livekit/livekit_rtc.pb.go @@ -2901,10 +2901,13 @@ func (x *SubscriptionPermission) GetTrackPermissions() []*TrackPermission { type SubscriptionPermissionUpdate struct { state protoimpl.MessageState `protogen:"open.v1"` ParticipantSid string `protobuf:"bytes,1,opt,name=participant_sid,json=participantSid,proto3" json:"participant_sid,omitempty"` - TrackSid string `protobuf:"bytes,2,opt,name=track_sid,json=trackSid,proto3" json:"track_sid,omitempty"` - Allowed bool `protobuf:"varint,3,opt,name=allowed,proto3" json:"allowed,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // Deprecated: Marked as deprecated in livekit_rtc.proto. + TrackSid string `protobuf:"bytes,2,opt,name=track_sid,json=trackSid,proto3" json:"track_sid,omitempty"` + Allowed bool `protobuf:"varint,3,opt,name=allowed,proto3" json:"allowed,omitempty"` + TrackSource *TrackSource `protobuf:"varint,4,opt,name=track_source,json=trackSource,proto3,enum=livekit.TrackSource,oneof" json:"track_source,omitempty"` + TrackName *string `protobuf:"bytes,5,opt,name=track_name,json=trackName,proto3,oneof" json:"track_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SubscriptionPermissionUpdate) Reset() { @@ -2944,6 +2947,7 @@ func (x *SubscriptionPermissionUpdate) GetParticipantSid() string { return "" } +// Deprecated: Marked as deprecated in livekit_rtc.proto. func (x *SubscriptionPermissionUpdate) GetTrackSid() string { if x != nil { return x.TrackSid @@ -2958,6 +2962,20 @@ func (x *SubscriptionPermissionUpdate) GetAllowed() bool { return false } +func (x *SubscriptionPermissionUpdate) GetTrackSource() TrackSource { + if x != nil && x.TrackSource != nil { + return *x.TrackSource + } + return TrackSource_UNKNOWN +} + +func (x *SubscriptionPermissionUpdate) GetTrackName() string { + if x != nil && x.TrackName != nil { + return *x.TrackName + } + return "" +} + type SyncState struct { state protoimpl.MessageState `protogen:"open.v1"` // last subscribe answer before reconnecting @@ -3880,11 +3898,16 @@ const file_livekit_rtc_proto_rawDesc = "" + "\x14participant_identity\x18\x04 \x01(\tR\x13participantIdentity\"\x8a\x01\n" + "\x16SubscriptionPermission\x12)\n" + "\x10all_participants\x18\x01 \x01(\bR\x0fallParticipants\x12E\n" + - "\x11track_permissions\x18\x02 \x03(\v2\x18.livekit.TrackPermissionR\x10trackPermissions\"~\n" + + "\x11track_permissions\x18\x02 \x03(\v2\x18.livekit.TrackPermissionR\x10trackPermissions\"\x84\x02\n" + "\x1cSubscriptionPermissionUpdate\x12'\n" + - "\x0fparticipant_sid\x18\x01 \x01(\tR\x0eparticipantSid\x12\x1b\n" + - "\ttrack_sid\x18\x02 \x01(\tR\btrackSid\x12\x18\n" + - "\aallowed\x18\x03 \x01(\bR\aallowed\"\xeb\x02\n" + + "\x0fparticipant_sid\x18\x01 \x01(\tR\x0eparticipantSid\x12\x1f\n" + + "\ttrack_sid\x18\x02 \x01(\tB\x02\x18\x01R\btrackSid\x12\x18\n" + + "\aallowed\x18\x03 \x01(\bR\aallowed\x12<\n" + + "\ftrack_source\x18\x04 \x01(\x0e2\x14.livekit.TrackSourceH\x00R\vtrackSource\x88\x01\x01\x12\"\n" + + "\n" + + "track_name\x18\x05 \x01(\tH\x01R\ttrackName\x88\x01\x01B\x0f\n" + + "\r_track_sourceB\r\n" + + "\v_track_name\"\xeb\x02\n" + "\tSyncState\x123\n" + "\x06answer\x18\x01 \x01(\v2\x1b.livekit.SessionDescriptionR\x06answer\x12?\n" + "\fsubscription\x18\x02 \x01(\v2\x1b.livekit.UpdateSubscriptionR\fsubscription\x12F\n" + @@ -4106,21 +4129,22 @@ var file_livekit_rtc_proto_depIdxs = []int32{ 31, // 70: livekit.SubscribedQualityUpdate.subscribed_qualities:type_name -> livekit.SubscribedQuality 32, // 71: livekit.SubscribedQualityUpdate.subscribed_codecs:type_name -> livekit.SubscribedCodec 34, // 72: livekit.SubscriptionPermission.track_permissions:type_name -> livekit.TrackPermission - 15, // 73: livekit.SyncState.answer:type_name -> livekit.SessionDescription - 17, // 74: livekit.SyncState.subscription:type_name -> livekit.UpdateSubscription - 13, // 75: livekit.SyncState.publish_tracks:type_name -> livekit.TrackPublishedResponse - 38, // 76: livekit.SyncState.data_channels:type_name -> livekit.DataChannelInfo - 15, // 77: livekit.SyncState.offer:type_name -> livekit.SessionDescription - 0, // 78: livekit.DataChannelInfo.target:type_name -> livekit.SignalTarget - 2, // 79: livekit.SimulateScenario.switch_candidate_protocol:type_name -> livekit.CandidateProtocol - 43, // 80: livekit.RegionSettings.regions:type_name -> livekit.RegionInfo - 65, // 81: livekit.SubscriptionResponse.err:type_name -> livekit.SubscriptionError - 4, // 82: livekit.RequestResponse.reason:type_name -> livekit.RequestResponse.Reason - 83, // [83:83] is the sub-list for method output_type - 83, // [83:83] is the sub-list for method input_type - 83, // [83:83] is the sub-list for extension type_name - 83, // [83:83] is the sub-list for extension extendee - 0, // [0:83] is the sub-list for field type_name + 49, // 73: livekit.SubscriptionPermissionUpdate.track_source:type_name -> livekit.TrackSource + 15, // 74: livekit.SyncState.answer:type_name -> livekit.SessionDescription + 17, // 75: livekit.SyncState.subscription:type_name -> livekit.UpdateSubscription + 13, // 76: livekit.SyncState.publish_tracks:type_name -> livekit.TrackPublishedResponse + 38, // 77: livekit.SyncState.data_channels:type_name -> livekit.DataChannelInfo + 15, // 78: livekit.SyncState.offer:type_name -> livekit.SessionDescription + 0, // 79: livekit.DataChannelInfo.target:type_name -> livekit.SignalTarget + 2, // 80: livekit.SimulateScenario.switch_candidate_protocol:type_name -> livekit.CandidateProtocol + 43, // 81: livekit.RegionSettings.regions:type_name -> livekit.RegionInfo + 65, // 82: livekit.SubscriptionResponse.err:type_name -> livekit.SubscriptionError + 4, // 83: livekit.RequestResponse.reason:type_name -> livekit.RequestResponse.Reason + 84, // [84:84] is the sub-list for method output_type + 84, // [84:84] is the sub-list for method input_type + 84, // [84:84] is the sub-list for extension type_name + 84, // [84:84] is the sub-list for extension extendee + 0, // [0:84] is the sub-list for field type_name } func init() { file_livekit_rtc_proto_init() } @@ -4172,6 +4196,7 @@ func file_livekit_rtc_proto_init() { (*SignalResponse_RequestResponse)(nil), (*SignalResponse_TrackSubscribed)(nil), } + file_livekit_rtc_proto_msgTypes[31].OneofWrappers = []any{} file_livekit_rtc_proto_msgTypes[34].OneofWrappers = []any{ (*SimulateScenario_SpeakerUpdate)(nil), (*SimulateScenario_NodeFailure)(nil), From 7ef2003603f9b34c858944331f4beeceba3e464a Mon Sep 17 00:00:00 2001 From: lukasIO Date: Fri, 11 Apr 2025 14:45:52 +0200 Subject: [PATCH 3/4] change fields on TrackPermission --- protobufs/livekit_rtc.proto | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protobufs/livekit_rtc.proto b/protobufs/livekit_rtc.proto index 8bd2ef91c..8e372b19b 100644 --- a/protobufs/livekit_rtc.proto +++ b/protobufs/livekit_rtc.proto @@ -340,10 +340,12 @@ message SubscribedQualityUpdate { message TrackPermission { // permission could be granted either by participant sid or identity - string participant_sid = 1; + string participant_sid = 1 [deprecated = true]; bool all_tracks = 2; - repeated string track_sids = 3; + repeated string track_sids = 3 [deprecated = true]; string participant_identity = 4; + repeated TrackSource track_sources = 5; + repeated string track_names = 6; } message SubscriptionPermission { From db50077aaa7d3e53852f55ccfc9bfaafb89963fb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 12:46:55 +0000 Subject: [PATCH 4/4] generated protobuf --- livekit/livekit_rtc.pb.go | 79 ++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/livekit/livekit_rtc.pb.go b/livekit/livekit_rtc.pb.go index a2d47629f..9a6d89fb1 100644 --- a/livekit/livekit_rtc.pb.go +++ b/livekit/livekit_rtc.pb.go @@ -2780,10 +2780,15 @@ func (x *SubscribedQualityUpdate) GetSubscribedCodecs() []*SubscribedCodec { type TrackPermission struct { state protoimpl.MessageState `protogen:"open.v1"` // permission could be granted either by participant sid or identity - ParticipantSid string `protobuf:"bytes,1,opt,name=participant_sid,json=participantSid,proto3" json:"participant_sid,omitempty"` - AllTracks bool `protobuf:"varint,2,opt,name=all_tracks,json=allTracks,proto3" json:"all_tracks,omitempty"` - TrackSids []string `protobuf:"bytes,3,rep,name=track_sids,json=trackSids,proto3" json:"track_sids,omitempty"` - ParticipantIdentity string `protobuf:"bytes,4,opt,name=participant_identity,json=participantIdentity,proto3" json:"participant_identity,omitempty"` + // + // Deprecated: Marked as deprecated in livekit_rtc.proto. + ParticipantSid string `protobuf:"bytes,1,opt,name=participant_sid,json=participantSid,proto3" json:"participant_sid,omitempty"` + AllTracks bool `protobuf:"varint,2,opt,name=all_tracks,json=allTracks,proto3" json:"all_tracks,omitempty"` + // Deprecated: Marked as deprecated in livekit_rtc.proto. + TrackSids []string `protobuf:"bytes,3,rep,name=track_sids,json=trackSids,proto3" json:"track_sids,omitempty"` + ParticipantIdentity string `protobuf:"bytes,4,opt,name=participant_identity,json=participantIdentity,proto3" json:"participant_identity,omitempty"` + TrackSources []TrackSource `protobuf:"varint,5,rep,packed,name=track_sources,json=trackSources,proto3,enum=livekit.TrackSource" json:"track_sources,omitempty"` + TrackNames []string `protobuf:"bytes,6,rep,name=track_names,json=trackNames,proto3" json:"track_names,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -2818,6 +2823,7 @@ func (*TrackPermission) Descriptor() ([]byte, []int) { return file_livekit_rtc_proto_rawDescGZIP(), []int{29} } +// Deprecated: Marked as deprecated in livekit_rtc.proto. func (x *TrackPermission) GetParticipantSid() string { if x != nil { return x.ParticipantSid @@ -2832,6 +2838,7 @@ func (x *TrackPermission) GetAllTracks() bool { return false } +// Deprecated: Marked as deprecated in livekit_rtc.proto. func (x *TrackPermission) GetTrackSids() []string { if x != nil { return x.TrackSids @@ -2846,6 +2853,20 @@ func (x *TrackPermission) GetParticipantIdentity() string { return "" } +func (x *TrackPermission) GetTrackSources() []TrackSource { + if x != nil { + return x.TrackSources + } + return nil +} + +func (x *TrackPermission) GetTrackNames() []string { + if x != nil { + return x.TrackNames + } + return nil +} + type SubscriptionPermission struct { state protoimpl.MessageState `protogen:"open.v1"` AllParticipants bool `protobuf:"varint,1,opt,name=all_participants,json=allParticipants,proto3" json:"all_participants,omitempty"` @@ -3888,14 +3909,17 @@ const file_livekit_rtc_proto_rawDesc = "" + "\x17SubscribedQualityUpdate\x12\x1b\n" + "\ttrack_sid\x18\x01 \x01(\tR\btrackSid\x12M\n" + "\x14subscribed_qualities\x18\x02 \x03(\v2\x1a.livekit.SubscribedQualityR\x13subscribedQualities\x12E\n" + - "\x11subscribed_codecs\x18\x03 \x03(\v2\x18.livekit.SubscribedCodecR\x10subscribedCodecs\"\xab\x01\n" + - "\x0fTrackPermission\x12'\n" + - "\x0fparticipant_sid\x18\x01 \x01(\tR\x0eparticipantSid\x12\x1d\n" + + "\x11subscribed_codecs\x18\x03 \x03(\v2\x18.livekit.SubscribedCodecR\x10subscribedCodecs\"\x8f\x02\n" + + "\x0fTrackPermission\x12+\n" + + "\x0fparticipant_sid\x18\x01 \x01(\tB\x02\x18\x01R\x0eparticipantSid\x12\x1d\n" + "\n" + - "all_tracks\x18\x02 \x01(\bR\tallTracks\x12\x1d\n" + + "all_tracks\x18\x02 \x01(\bR\tallTracks\x12!\n" + "\n" + - "track_sids\x18\x03 \x03(\tR\ttrackSids\x121\n" + - "\x14participant_identity\x18\x04 \x01(\tR\x13participantIdentity\"\x8a\x01\n" + + "track_sids\x18\x03 \x03(\tB\x02\x18\x01R\ttrackSids\x121\n" + + "\x14participant_identity\x18\x04 \x01(\tR\x13participantIdentity\x129\n" + + "\rtrack_sources\x18\x05 \x03(\x0e2\x14.livekit.TrackSourceR\ftrackSources\x12\x1f\n" + + "\vtrack_names\x18\x06 \x03(\tR\n" + + "trackNames\"\x8a\x01\n" + "\x16SubscriptionPermission\x12)\n" + "\x10all_participants\x18\x01 \x01(\bR\x0fallParticipants\x12E\n" + "\x11track_permissions\x18\x02 \x03(\v2\x18.livekit.TrackPermissionR\x10trackPermissions\"\x84\x02\n" + @@ -4128,23 +4152,24 @@ var file_livekit_rtc_proto_depIdxs = []int32{ 31, // 69: livekit.SubscribedCodec.qualities:type_name -> livekit.SubscribedQuality 31, // 70: livekit.SubscribedQualityUpdate.subscribed_qualities:type_name -> livekit.SubscribedQuality 32, // 71: livekit.SubscribedQualityUpdate.subscribed_codecs:type_name -> livekit.SubscribedCodec - 34, // 72: livekit.SubscriptionPermission.track_permissions:type_name -> livekit.TrackPermission - 49, // 73: livekit.SubscriptionPermissionUpdate.track_source:type_name -> livekit.TrackSource - 15, // 74: livekit.SyncState.answer:type_name -> livekit.SessionDescription - 17, // 75: livekit.SyncState.subscription:type_name -> livekit.UpdateSubscription - 13, // 76: livekit.SyncState.publish_tracks:type_name -> livekit.TrackPublishedResponse - 38, // 77: livekit.SyncState.data_channels:type_name -> livekit.DataChannelInfo - 15, // 78: livekit.SyncState.offer:type_name -> livekit.SessionDescription - 0, // 79: livekit.DataChannelInfo.target:type_name -> livekit.SignalTarget - 2, // 80: livekit.SimulateScenario.switch_candidate_protocol:type_name -> livekit.CandidateProtocol - 43, // 81: livekit.RegionSettings.regions:type_name -> livekit.RegionInfo - 65, // 82: livekit.SubscriptionResponse.err:type_name -> livekit.SubscriptionError - 4, // 83: livekit.RequestResponse.reason:type_name -> livekit.RequestResponse.Reason - 84, // [84:84] is the sub-list for method output_type - 84, // [84:84] is the sub-list for method input_type - 84, // [84:84] is the sub-list for extension type_name - 84, // [84:84] is the sub-list for extension extendee - 0, // [0:84] is the sub-list for field type_name + 49, // 72: livekit.TrackPermission.track_sources:type_name -> livekit.TrackSource + 34, // 73: livekit.SubscriptionPermission.track_permissions:type_name -> livekit.TrackPermission + 49, // 74: livekit.SubscriptionPermissionUpdate.track_source:type_name -> livekit.TrackSource + 15, // 75: livekit.SyncState.answer:type_name -> livekit.SessionDescription + 17, // 76: livekit.SyncState.subscription:type_name -> livekit.UpdateSubscription + 13, // 77: livekit.SyncState.publish_tracks:type_name -> livekit.TrackPublishedResponse + 38, // 78: livekit.SyncState.data_channels:type_name -> livekit.DataChannelInfo + 15, // 79: livekit.SyncState.offer:type_name -> livekit.SessionDescription + 0, // 80: livekit.DataChannelInfo.target:type_name -> livekit.SignalTarget + 2, // 81: livekit.SimulateScenario.switch_candidate_protocol:type_name -> livekit.CandidateProtocol + 43, // 82: livekit.RegionSettings.regions:type_name -> livekit.RegionInfo + 65, // 83: livekit.SubscriptionResponse.err:type_name -> livekit.SubscriptionError + 4, // 84: livekit.RequestResponse.reason:type_name -> livekit.RequestResponse.Reason + 85, // [85:85] is the sub-list for method output_type + 85, // [85:85] is the sub-list for method input_type + 85, // [85:85] is the sub-list for extension type_name + 85, // [85:85] is the sub-list for extension extendee + 0, // [0:85] is the sub-list for field type_name } func init() { file_livekit_rtc_proto_init() }