Skip to content

Commit

Permalink
Implement all presets defined in protocol (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben authored Mar 22, 2023
1 parent 2ea44ec commit 8a4e927
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/frostbyte73/core v0.0.5
github.com/livekit/go-rtmp v0.0.0-20230317185657-6e9cfa387c7e
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/protocol v1.5.1-0.20230316165531-6b747fe252cf
github.com/livekit/protocol v1.5.1-0.20230322011329-e78c5b18c0f3
github.com/livekit/psrpc v0.2.10-0.20230303054701-5853a56b4643
github.com/livekit/server-sdk-go v1.0.9-0.20230314192457-52c28d42b5d4
github.com/pion/rtcp v1.2.10
Expand All @@ -19,7 +19,7 @@ require (
github.com/urfave/cli/v2 v2.24.4
github.com/yutopp/go-flv v0.2.0
go.uber.org/atomic v1.10.0
google.golang.org/protobuf v1.29.1
google.golang.org/protobuf v1.30.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20230130133657-96cfb115473a h1:5UkGQpskXp7HcBmyrCwWtO7ygDWbqtjN09Yva4l/nyE=
github.com/livekit/mediatransportutil v0.0.0-20230130133657-96cfb115473a/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
github.com/livekit/protocol v1.5.1-0.20230316165531-6b747fe252cf h1:V8jSXH/6x4hXfN08+a2jgCwT2zMzcs75J1zEzxSLpII=
github.com/livekit/protocol v1.5.1-0.20230316165531-6b747fe252cf/go.mod h1:1aepmVXRS/Uh3QpenQ7Fzxejt1GjhTzyWh0Y6EPDzmE=
github.com/livekit/protocol v1.5.1-0.20230322011329-e78c5b18c0f3 h1:4MG8Wmnjohhjl6EWaxv6DfYQ47yY197TbSTQ8Eq1fcA=
github.com/livekit/protocol v1.5.1-0.20230322011329-e78c5b18c0f3/go.mod h1:m5PkhcDT0EWdhatB0MpjmMaxyySjfE5NyZQC/LJWfEM=
github.com/livekit/psrpc v0.2.10-0.20230303054701-5853a56b4643 h1:ftDwqesgXMu0hUXFxf4KWAqqDIXz8BBdNnit3xc6RQA=
github.com/livekit/psrpc v0.2.10-0.20230303054701-5853a56b4643/go.mod h1:K0j8f1PgLShR7Lx80KbmwFkDH2BvOnycXGV0OSRURKc=
github.com/livekit/server-sdk-go v1.0.9-0.20230314192457-52c28d42b5d4 h1:fSm7wr75fh6NcTtLKa6nsyFKb7z+kRt6YzgxpyFrym4=
Expand Down Expand Up @@ -301,8 +301,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM=
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
50 changes: 50 additions & 0 deletions pkg/media/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,50 @@ func getOptionsForVideoPreset(preset livekit.IngressVideoEncodingPreset) (*livek
Bitrate: 1700000,
}, 3),
}, nil
case livekit.IngressVideoEncodingPreset_H264_1080P_30FPS_3_LAYERS:
return &livekit.IngressVideoEncodingOptions{
VideoCodec: livekit.VideoCodec_H264_BASELINE,
FrameRate: 30,
Layers: computeVideoLayers(&livekit.VideoLayer{
Quality: livekit.VideoQuality_HIGH,
Width: 1920,
Height: 1080,
Bitrate: 3000000,
}, 3),
}, nil
case livekit.IngressVideoEncodingPreset_H264_540P_25FPS_2_LAYERS:
return &livekit.IngressVideoEncodingOptions{
VideoCodec: livekit.VideoCodec_H264_BASELINE,
FrameRate: 25,
Layers: computeVideoLayers(&livekit.VideoLayer{
Quality: livekit.VideoQuality_HIGH,
Width: 960,
Height: 540,
Bitrate: 600000,
}, 2),
}, nil
case livekit.IngressVideoEncodingPreset_H264_720P_30FPS_1_LAYER:
return &livekit.IngressVideoEncodingOptions{
VideoCodec: livekit.VideoCodec_H264_BASELINE,
FrameRate: 25,
Layers: computeVideoLayers(&livekit.VideoLayer{
Quality: livekit.VideoQuality_HIGH,
Width: 1280,
Height: 720,
Bitrate: 1700000,
}, 1),
}, nil
case livekit.IngressVideoEncodingPreset_H264_1080P_30FPS_1_LAYER:
return &livekit.IngressVideoEncodingOptions{
VideoCodec: livekit.VideoCodec_H264_BASELINE,
FrameRate: 25,
Layers: computeVideoLayers(&livekit.VideoLayer{
Quality: livekit.VideoQuality_HIGH,
Width: 1920,
Height: 1080,
Bitrate: 3000000,
}, 1),
}, nil
default:
return nil, errors.ErrInvalidVideoPreset
}
Expand Down Expand Up @@ -53,6 +97,12 @@ func getOptionsForAudioPreset(preset livekit.IngressAudioEncodingPreset) (*livek
Channels: 2,
Bitrate: 96000,
}, nil
case livekit.IngressAudioEncodingPreset_OPUS_MONO_64KBS:
return &livekit.IngressAudioEncodingOptions{
AudioCodec: livekit.AudioCodec_OPUS,
Channels: 1,
Bitrate: 64000,
}, nil
default:
return nil, errors.ErrInvalidAudioPreset
}
Expand Down

0 comments on commit 8a4e927

Please sign in to comment.