Skip to content

Commit

Permalink
Unmarshal RoomEgress
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed May 28, 2024
1 parent 592e9e0 commit 9903c97
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
15 changes: 15 additions & 0 deletions livekit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

package livekit

import (
"github.com/bufbuild/protoyaml-go"

Check failure on line 18 in livekit/types.go

View workflow job for this annotation

GitHub Actions / test

no required module provides package github.com/bufbuild/protoyaml-go; to add it:
"gopkg.in/yaml.v3"
)

type TrackID string
type ParticipantID string
type ParticipantIdentity string
Expand Down Expand Up @@ -66,3 +71,13 @@ func (p *SipDTMF) ToProto() *DataPacket {
},
}
}

func (r *RoomEgress) UnmarshalYAML(value *yaml.Node) error {
// Marshall the Node back to yaml to pass it to the protobuf specific unmarshaller
str, err := yaml.Marshal(value)
if err != nil {
return err
}

return protoyaml.Unmarshal(str, r)
}
40 changes: 40 additions & 0 deletions livekit/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package livekit

import (
fmt "fmt"
"testing"

"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)

func TestUnmarshallRoomEgress(t *testing.T) {
y := `
a:
room:
room_name: room name
b:
participant:
file_outputs:
- s3:
access_key: key
`

obj := make(map[string]*RoomEgress)

err := yaml.Unmarshal([]byte(y), &obj)

fmt.Println(obj)

require.NoError(t, err)
require.Equal(t, 2, len(obj))

re := obj["a"]
require.NotNil(t, re)
require.Equal(t, re.Room.RoomName, "room name")

re = obj["b"]
require.NotNil(t, re)
require.Equal(t, 1, len(re.Participant.FileOutputs))
require.Equal(t, "key", re.Participant.FileOutputs[0].Output.(*EncodedFileOutput_S3).S3.AccessKey)
}
41 changes: 0 additions & 41 deletions protobufs/livekit_room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ service RoomService {

// Update room metadata, will cause updates to be broadcasted to everyone in the room, Requires `roomAdmin`
rpc UpdateRoomMetadata (UpdateRoomMetadataRequest) returns (Room);

// Create a room configuration.
rpc CreateRoomConfiguration(CreateRoomConfigurationRequest) returns (RoomConfiguration);

// Update a room configuration
rpc UpdateRoomConfiguration(UpdateRoomConfigurationRequest) returns (RoomConfiguration);

// List configurations
rpc ListRoomConfiguration(ListRoomConfigurationRequest) returns (ListRoomConfigurationResponse);
}

message CreateRoomRequest {
Expand Down Expand Up @@ -210,38 +201,6 @@ message UpdateRoomMetadataRequest {
string metadata = 2;
}

message CreateRoomConfigurationRequest {
RoomConfiguration configuration = 1;
}

message UpdateRoomConfigurationRequest {
string name = 1; // configuration to update
// number of seconds to keep the room open if no one joins
optional uint32 empty_timeout = 2;
// number of seconds to keep the room open after everyone leaves
optional uint32 departure_timeout = 3;
// limit number of participants that can be in a room
optional uint32 max_participants = 4;
// egress
optional RoomEgress egress = 5;
// agent
optional RoomAgent agent = 6;
// playout delay of subscriber
optional uint32 min_playout_delay = 7;
optional uint32 max_playout_delay = 8;
// improves A/V sync when playout_delay set to a value larger than 200ms. It will disables transceiver re-use
// so not recommended for rooms with frequent subscription changes
optional bool sync_streams = 9;
}

message ListRoomConfigurationRequest {
string name = 1; // If non empty, return only the configurartion with this name
}

message ListRoomConfigurationResponse {
repeated RoomConfiguration configurations = 1;
}

message RoomConfiguration {
string name = 1; // Used as ID, must be unique
// number of seconds to keep the room open if no one joins
Expand Down

0 comments on commit 9903c97

Please sign in to comment.