Use RequestResponse to report protocol handling errors (#3895)

* Send errors as necessary

* WIP

* WIP

* WIP

* WIP

* deps

* static check

* fix test

* test

* test

* logs
This commit is contained in:
Raja Subramanian
2025-09-04 11:27:07 +05:30
committed by GitHub
parent 98352fd0f9
commit 07c40cf349
16 changed files with 422 additions and 386 deletions
+16 -19
View File
@@ -34,7 +34,6 @@ import (
"github.com/livekit/protocol/observability"
"github.com/livekit/protocol/observability/roomobs"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/signalling"
"github.com/livekit/protocol/utils"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/protocol/utils/must"
@@ -577,7 +576,7 @@ func (r *RoomManager) StartSession(
participant.AddTrack(addTrackRequest)
}
if pi.PublisherOffer != nil {
participant.HandleOffer(signalling.FromProtoSessionDescription(pi.PublisherOffer))
participant.HandleOffer(pi.PublisherOffer)
}
go r.rtcSessionWorker(room, participant, requestSource)
@@ -779,7 +778,10 @@ func (r *RoomManager) MutePublishedTrack(ctx context.Context, req *livekit.MuteR
participant.GetLogger().Errorw("cannot unmute track, remote unmute is disabled", nil)
return nil, ErrRemoteUnmuteNoteEnabled
}
track := participant.SetTrackMuted(livekit.TrackID(req.TrackSid), req.Muted, true)
track := participant.SetTrackMuted(&livekit.MuteTrackRequest{
Sid: req.TrackSid,
Muted: req.Muted,
}, true)
return &livekit.MuteRoomTrackResponse{Track: track}, nil
}
@@ -789,28 +791,23 @@ func (r *RoomManager) UpdateParticipant(ctx context.Context, req *livekit.Update
return nil, err
}
participant.GetLogger().Debugw("updating participant",
"metadata", req.Metadata,
"permission", req.Permission,
"attributes", req.Attributes,
)
if err = participant.CheckMetadataLimits(req.Name, req.Metadata, req.Attributes); err != nil {
if err = participant.UpdateMetadata(&livekit.UpdateParticipantMetadata{
Name: req.Name,
Metadata: req.Metadata,
Attributes: req.Attributes,
}, true); err != nil {
return nil, err
}
if req.Name != "" {
participant.SetName(req.Name)
}
if req.Metadata != "" {
participant.SetMetadata(req.Metadata)
}
if req.Attributes != nil {
participant.SetAttributes(req.Attributes)
}
if req.Permission != nil {
participant.GetLogger().Debugw(
"updating participant permission",
"permission", req.Permission,
)
participant.SetPermission(req.Permission)
}
return participant.ToProto(), nil
}
+5 -1
View File
@@ -53,7 +53,11 @@ func (s whipService) Create(ctx context.Context, req *rpc.WHIPCreateRequest) (*r
return nil, ErrParticipantNotFound
}
if err := lp.HandleOffer(webrtc.SessionDescription{Type: webrtc.SDPTypeOffer, SDP: req.OfferSdp}, 0); err != nil {
if err := lp.HandleOffer(&livekit.SessionDescription{
Type: webrtc.SDPTypeOffer.String(),
Sdp: req.OfferSdp,
Id: 0,
}); err != nil {
lp.GetLogger().Errorw("whip service: could not handle offer", err)
return nil, err
}