update protocol
This commit is contained in:
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/google/wire v0.5.0
|
github.com/google/wire v0.5.0
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b
|
github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b
|
||||||
github.com/livekit/protocol v0.6.0
|
github.com/livekit/protocol v0.6.1
|
||||||
github.com/magefile/mage v1.11.0
|
github.com/magefile/mage v1.11.0
|
||||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|||||||
@@ -237,8 +237,8 @@ github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY
|
|||||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||||
github.com/livekit/ion-sfu v1.20.5 h1:2PltjaVWd4y3gUcBssHwa/V3jIp92z5vC0+6CzB7rz8=
|
github.com/livekit/ion-sfu v1.20.5 h1:2PltjaVWd4y3gUcBssHwa/V3jIp92z5vC0+6CzB7rz8=
|
||||||
github.com/livekit/ion-sfu v1.20.5/go.mod h1:dEdOG4KSqIftr5HxxqciNKBIdu0v3OD0ZYL7A3J09KA=
|
github.com/livekit/ion-sfu v1.20.5/go.mod h1:dEdOG4KSqIftr5HxxqciNKBIdu0v3OD0ZYL7A3J09KA=
|
||||||
github.com/livekit/protocol v0.6.0 h1:1tTwGMuA2WLwIaOXZHiuBZTjZMYY/t3TMK1zjQBvn7o=
|
github.com/livekit/protocol v0.6.1 h1:+AwPkBNZoUYCoGwmwGxsdNQN7bickSyVt1p1jQi3m2U=
|
||||||
github.com/livekit/protocol v0.6.0/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0=
|
github.com/livekit/protocol v0.6.1/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0=
|
||||||
github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ=
|
github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ=
|
||||||
github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE=
|
github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE=
|
||||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||||
|
|||||||
@@ -16,13 +16,6 @@ type RoomRecorder struct {
|
|||||||
rc *redis.Client
|
rc *redis.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
ReservationChannel = "RESERVE_RECORDER"
|
|
||||||
recorderTimeout = time.Second * 3
|
|
||||||
// used by livekit-recorder
|
|
||||||
ReservationTimeout = time.Second * 2
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewRoomRecorder(rc *redis.Client) *RoomRecorder {
|
func NewRoomRecorder(rc *redis.Client) *RoomRecorder {
|
||||||
if rc == nil {
|
if rc == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -43,10 +36,10 @@ func (s *RoomRecorder) ReserveRecorder(ctx context.Context, req *livekit.RecordR
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
sub := s.rc.Subscribe(ctx, ResponseChannel(id))
|
sub := s.rc.Subscribe(ctx, utils.ReservationResponseChannel(id))
|
||||||
defer sub.Close()
|
defer sub.Close()
|
||||||
|
|
||||||
err = s.rc.Publish(ctx, ReservationChannel, string(b)).Err()
|
err = s.rc.Publish(ctx, utils.ReservationChannel, string(b)).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -54,27 +47,15 @@ func (s *RoomRecorder) ReserveRecorder(ctx context.Context, req *livekit.RecordR
|
|||||||
select {
|
select {
|
||||||
case <-sub.Channel():
|
case <-sub.Channel():
|
||||||
return id, nil
|
return id, nil
|
||||||
case <-time.After(recorderTimeout):
|
case <-time.After(utils.RecorderTimeout):
|
||||||
return "", errors.New("no recorders available")
|
return "", errors.New("no recorders available")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RoomRecorder) StartRecording(ctx context.Context, recordingID string) error {
|
func (s *RoomRecorder) StartRecording(ctx context.Context, recordingID string) error {
|
||||||
return s.rc.Publish(ctx, StartRecordingChannel(recordingID), nil).Err()
|
return s.rc.Publish(ctx, utils.StartRecordingChannel(recordingID), nil).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RoomRecorder) EndRecording(ctx context.Context, recordingID string) error {
|
func (s *RoomRecorder) EndRecording(ctx context.Context, recordingID string) error {
|
||||||
return s.rc.Publish(ctx, EndRecordingChannel(recordingID), nil).Err()
|
return s.rc.Publish(ctx, utils.EndRecordingChannel(recordingID), nil).Err()
|
||||||
}
|
|
||||||
|
|
||||||
func ResponseChannel(id string) string {
|
|
||||||
return "RESPONSE_" + id
|
|
||||||
}
|
|
||||||
|
|
||||||
func StartRecordingChannel(id string) string {
|
|
||||||
return "START_RECORDING_" + id
|
|
||||||
}
|
|
||||||
|
|
||||||
func EndRecordingChannel(id string) string {
|
|
||||||
return "END_RECORDING_" + id
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user