deps (#3829)
This commit is contained in:
@@ -17,14 +17,14 @@ import (
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
type rtcRestService struct {
|
||||
type whipService struct {
|
||||
*RoomManager
|
||||
}
|
||||
|
||||
func (s rtcRestService) Create(ctx context.Context, req *rpc.RTCRestCreateRequest) (*rpc.RTCRestCreateResponse, error) {
|
||||
func (s whipService) Create(ctx context.Context, req *rpc.WHIPCreateRequest) (*rpc.WHIPCreateResponse, error) {
|
||||
pi, err := routing.ParticipantInitFromStartSession(req.StartSession, s.RoomManager.currentNode.Region())
|
||||
if err != nil {
|
||||
logger.Errorw("rtcRest service: could not create participant init", err)
|
||||
logger.Errorw("whip service: could not create participant init", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -37,28 +37,31 @@ func (s rtcRestService) Create(ctx context.Context, req *rpc.RTCRestCreateReques
|
||||
routing.NewNullMessageSink(livekit.ConnectionID(req.StartSession.ConnectionId)), // no responseSink
|
||||
true, // useOneShotSignallingMode
|
||||
); err != nil {
|
||||
logger.Errorw("rtcRest service: could not start session", err)
|
||||
logger.Errorw("whip service: could not start session", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
room := s.RoomManager.GetRoom(ctx, livekit.RoomName(req.StartSession.RoomName))
|
||||
if room == nil {
|
||||
logger.Errorw("rtcRest service: could not find room", nil, "room", req.StartSession.RoomName)
|
||||
logger.Errorw("whip service: could not find room", nil, "room", req.StartSession.RoomName)
|
||||
return nil, ErrRoomNotFound
|
||||
}
|
||||
|
||||
lp := room.GetParticipant(pi.Identity)
|
||||
if lp == nil {
|
||||
room.Logger().Errorw("rtcRest service: could not find local participant", nil, "participant", pi.Identity)
|
||||
room.Logger().Errorw("whip service: could not find local participant", nil, "participant", pi.Identity)
|
||||
return nil, ErrParticipantNotFound
|
||||
}
|
||||
|
||||
if err := lp.HandleOffer(webrtc.SessionDescription{Type: webrtc.SDPTypeOffer, SDP: req.OfferSdp}, 0); err != nil {
|
||||
lp.GetLogger().Errorw("rtcRest service: could not handle offer", err)
|
||||
lp.GetLogger().Errorw("whip service: could not handle offer", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wait for subscriptions to resolve
|
||||
// NOTE: this is outside the WHIP spec, but added as a convenience for clients doing
|
||||
// one-shot signalling (i. e. send an offer and get an answer once) to publish and subscribe to
|
||||
// well-known tracks (i. e. remote participant identity and track names are well known)
|
||||
eg, _ := errgroup.WithContext(ctx)
|
||||
for publisherIdentity, trackList := range req.SubscribedParticipantTracks {
|
||||
for _, trackName := range trackList.TrackNames {
|
||||
@@ -74,19 +77,19 @@ func (s rtcRestService) Create(ctx context.Context, req *rpc.RTCRestCreateReques
|
||||
}
|
||||
err = eg.Wait()
|
||||
if err != nil {
|
||||
lp.GetLogger().Errorw("rtcRest service: could not subscribe to tracks", err)
|
||||
lp.GetLogger().Errorw("whip service: could not subscribe to tracks", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
answer, _, err := lp.GetAnswer()
|
||||
if err != nil {
|
||||
lp.GetLogger().Errorw("rtcRest service: could not get answer", err)
|
||||
lp.GetLogger().Errorw("whip service: could not get answer", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iceSessionID, err := lp.GetPublisherICESessionUfrag()
|
||||
if err != nil {
|
||||
lp.GetLogger().Errorw("rtcRest service: could not get ICE session ID", err)
|
||||
lp.GetLogger().Errorw("whip service: could not get ICE session ID", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -99,7 +102,7 @@ func (s rtcRestService) Create(ctx context.Context, req *rpc.RTCRestCreateReques
|
||||
false,
|
||||
)
|
||||
}
|
||||
return &rpc.RTCRestCreateResponse{
|
||||
return &rpc.WHIPCreateResponse{
|
||||
AnswerSdp: answer.SDP,
|
||||
ParticipantId: string(lp.ID()),
|
||||
IceServers: iceServers,
|
||||
@@ -109,11 +112,11 @@ func (s rtcRestService) Create(ctx context.Context, req *rpc.RTCRestCreateReques
|
||||
|
||||
// -------------------------------------------
|
||||
|
||||
type rtcRestParticipantService struct {
|
||||
type whipParticipantService struct {
|
||||
*RoomManager
|
||||
}
|
||||
|
||||
func (r rtcRestParticipantService) ICETrickle(ctx context.Context, req *rpc.RTCRestParticipantICETrickleRequest) (*emptypb.Empty, error) {
|
||||
func (r whipParticipantService) ICETrickle(ctx context.Context, req *rpc.WHIPParticipantICETrickleRequest) (*emptypb.Empty, error) {
|
||||
room := r.RoomManager.GetRoom(ctx, livekit.RoomName(req.Room))
|
||||
if room == nil {
|
||||
return nil, ErrRoomNotFound
|
||||
@@ -126,7 +129,7 @@ func (r rtcRestParticipantService) ICETrickle(ctx context.Context, req *rpc.RTCR
|
||||
|
||||
iceSessionID, err := lp.GetPublisherICESessionUfrag()
|
||||
if err != nil {
|
||||
lp.GetLogger().Warnw("rtcRestParticipant service ice-trickle: could not get ICE session ufrag", err)
|
||||
lp.GetLogger().Warnw("whipParticipant service ice-trickle: could not get ICE session ufrag", err)
|
||||
return nil, psrpc.NewError(psrpc.Internal, err)
|
||||
}
|
||||
|
||||
@@ -144,7 +147,7 @@ func (r rtcRestParticipantService) ICETrickle(ctx context.Context, req *rpc.RTCR
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
func (r rtcRestParticipantService) ICERestart(ctx context.Context, req *rpc.RTCRestParticipantICERestartRequest) (*rpc.RTCRestParticipantICERestartResponse, error) {
|
||||
func (r whipParticipantService) ICERestart(ctx context.Context, req *rpc.WHIPParticipantICERestartRequest) (*rpc.WHIPParticipantICERestartResponse, error) {
|
||||
room := r.RoomManager.GetRoom(ctx, livekit.RoomName(req.Room))
|
||||
if room == nil {
|
||||
return nil, ErrRoomNotFound
|
||||
@@ -162,17 +165,17 @@ func (r rtcRestParticipantService) ICERestart(ctx context.Context, req *rpc.RTCR
|
||||
|
||||
iceSessionID, err := lp.GetPublisherICESessionUfrag()
|
||||
if err != nil {
|
||||
lp.GetLogger().Warnw("rtcRestParticipant service ice-restart: could not get ICE session ufrag", err)
|
||||
lp.GetLogger().Warnw("whipParticipant service ice-restart: could not get ICE session ufrag", err)
|
||||
return nil, psrpc.NewError(psrpc.Internal, err)
|
||||
}
|
||||
|
||||
return &rpc.RTCRestParticipantICERestartResponse{
|
||||
return &rpc.WHIPParticipantICERestartResponse{
|
||||
IceSessionId: iceSessionID,
|
||||
SdpFragment: sdpFragment,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r rtcRestParticipantService) DeleteSession(ctx context.Context, req *rpc.RTCRestParticipantDeleteSessionRequest) (*emptypb.Empty, error) {
|
||||
func (r whipParticipantService) DeleteSession(ctx context.Context, req *rpc.WHIPParticipantDeleteSessionRequest) (*emptypb.Empty, error) {
|
||||
room := r.RoomManager.GetRoom(ctx, livekit.RoomName(req.Room))
|
||||
if room == nil {
|
||||
return nil, ErrRoomNotFound
|
||||
|
||||
Reference in New Issue
Block a user