service: start room composite egress configured in a room preset (#4926)
* service: start room composite egress configured in a room preset StandardRoomAllocator.CreateRoom merged a room preset into a copy of the request and discarded it. RoomInternal has no field for room composite egress, and getOrCreateRoom started it from the caller's original request, so a room composite egress from a preset was never started. RoomAllocator.CreateRoom now also returns the request with the preset applied, and getOrCreateRoom starts the egress from it. * service: return ErrEgressNotConnected instead of calling a nil egress launcher getOrCreateRoom started a room composite egress without checking that an egress launcher exists. RoomService.CreateRoom rejects egress on the request when there is none, but not egress from a room preset or a token's roomConfig.
This commit is contained in:
@@ -39,12 +39,44 @@ func TestCreateRoom(t *testing.T) {
|
||||
|
||||
ra, conf := newTestRoomAllocator(t, conf, node.Clone())
|
||||
|
||||
room, _, _, err := ra.CreateRoom(context.Background(), &livekit.CreateRoomRequest{Name: "myroom"}, true)
|
||||
room, _, _, _, err := ra.CreateRoom(context.Background(), &livekit.CreateRoomRequest{Name: "myroom"}, true)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, conf.Room.EmptyTimeout, room.EmptyTimeout)
|
||||
require.Equal(t, conf.Room.DepartureTimeout, room.DepartureTimeout)
|
||||
require.NotEmpty(t, room.EnabledCodecs)
|
||||
})
|
||||
|
||||
t.Run("return the request with the room preset applied", func(t *testing.T) {
|
||||
conf, err := config.NewConfig(`
|
||||
room:
|
||||
room_configurations:
|
||||
record:
|
||||
egress:
|
||||
room:
|
||||
layout: grid
|
||||
`, true, nil, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
node, err := routing.NewLocalNode(conf)
|
||||
require.NoError(t, err)
|
||||
|
||||
ra, conf := newTestRoomAllocator(t, conf, node.Clone())
|
||||
|
||||
// without a preset, the request itself is returned
|
||||
req := &livekit.CreateRoomRequest{Name: "myroom"}
|
||||
_, _, applied, _, err := ra.CreateRoom(context.Background(), req, true)
|
||||
require.NoError(t, err)
|
||||
require.Same(t, req, applied)
|
||||
|
||||
// with a preset, a copy with the preset applied is returned,
|
||||
// leaving both the request and the preset unchanged
|
||||
req = &livekit.CreateRoomRequest{Name: "myroom", RoomPreset: "record"}
|
||||
_, _, applied, _, err = ra.CreateRoom(context.Background(), req, true)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, req.Egress)
|
||||
require.Equal(t, "grid", applied.GetEgress().GetRoom().GetLayout())
|
||||
require.NotSame(t, conf.Room.RoomConfigurations["record"].Egress.Room, applied.Egress.Room)
|
||||
})
|
||||
}
|
||||
|
||||
func SelectRoomNode(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user