mirror of
https://github.com/pion/mediadevices.git
synced 2025-10-17 22:21:42 +08:00
Unify codec params type/func naming
This commit is contained in:
@@ -58,7 +58,7 @@ func main() {
|
|||||||
c.FrameRate = 30
|
c.FrameRate = 30
|
||||||
|
|
||||||
// Load default parameters.
|
// Load default parameters.
|
||||||
cp, err := vaapi.NewVP8Param()
|
cp, err := vaapi.NewVP8Params()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/pion/webrtc/v2"
|
"github.com/pion/webrtc/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParamVP8 stores VP8 encoding parameters.
|
// ParamsVP8 stores VP8 encoding parameters.
|
||||||
type ParamVP8 struct {
|
type ParamsVP8 struct {
|
||||||
codec.BaseParams
|
codec.BaseParams
|
||||||
Sequence SequenceParamVP8
|
Sequence SequenceParamVP8
|
||||||
RateControlMode RateControlMode
|
RateControlMode RateControlMode
|
||||||
@@ -24,9 +24,9 @@ type SequenceParamVP8 struct {
|
|||||||
ClampQindexLow uint
|
ClampQindexLow uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVP8Param returns default parameters of VP8 codec.
|
// NewVP8Params returns default parameters of VP8 codec.
|
||||||
func NewVP8Param() (ParamVP8, error) {
|
func NewVP8Params() (ParamsVP8, error) {
|
||||||
return ParamVP8{
|
return ParamsVP8{
|
||||||
BaseParams: codec.BaseParams{
|
BaseParams: codec.BaseParams{
|
||||||
BitRate: 320000,
|
BitRate: 320000,
|
||||||
KeyFrameInterval: 30,
|
KeyFrameInterval: 30,
|
||||||
@@ -47,17 +47,17 @@ func NewVP8Param() (ParamVP8, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name represents the codec name
|
// Name represents the codec name
|
||||||
func (p *ParamVP8) Name() string {
|
func (p *ParamsVP8) Name() string {
|
||||||
return webrtc.VP8
|
return webrtc.VP8
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildVideoEncoder builds VP8 encoder with given params
|
// BuildVideoEncoder builds VP8 encoder with given params
|
||||||
func (p *ParamVP8) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
func (p *ParamsVP8) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
||||||
return newVP8Encoder(r, property, *p)
|
return newVP8Encoder(r, property, *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParamVP9 represents VAEncSequenceParameterBufferVP9 and other parameter buffers.
|
// ParamsVP9 represents VAEncSequenceParameterBufferVP9 and other parameter buffers.
|
||||||
type ParamVP9 struct {
|
type ParamsVP9 struct {
|
||||||
codec.BaseParams
|
codec.BaseParams
|
||||||
RateControlMode RateControlMode
|
RateControlMode RateControlMode
|
||||||
RateControl RateControlParam
|
RateControl RateControlParam
|
||||||
@@ -97,9 +97,9 @@ const (
|
|||||||
RateControlAVBR RateControlMode = 0x00000800
|
RateControlAVBR RateControlMode = 0x00000800
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewVP9Param returns default parameters of VP9 codec.
|
// NewVP9Params returns default parameters of VP9 codec.
|
||||||
func NewVP9Param() (ParamVP9, error) {
|
func NewVP9Params() (ParamsVP9, error) {
|
||||||
return ParamVP9{
|
return ParamsVP9{
|
||||||
BaseParams: codec.BaseParams{
|
BaseParams: codec.BaseParams{
|
||||||
BitRate: 320000,
|
BitRate: 320000,
|
||||||
KeyFrameInterval: 30,
|
KeyFrameInterval: 30,
|
||||||
@@ -116,11 +116,11 @@ func NewVP9Param() (ParamVP9, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name represents the codec name
|
// Name represents the codec name
|
||||||
func (p *ParamVP9) Name() string {
|
func (p *ParamsVP9) Name() string {
|
||||||
return webrtc.VP9
|
return webrtc.VP9
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildVideoEncoder builds VP9 encoder with given params
|
// BuildVideoEncoder builds VP9 encoder with given params
|
||||||
func (p *ParamVP9) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
func (p *ParamsVP9) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
||||||
return newVP9Encoder(r, property, *p)
|
return newVP9Encoder(r, property, *p)
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ type encoderVP8 struct {
|
|||||||
|
|
||||||
frameCnt int
|
frameCnt int
|
||||||
prop prop.Media
|
prop prop.Media
|
||||||
params ParamVP8
|
params ParamsVP8
|
||||||
|
|
||||||
rate *framerateDetector
|
rate *framerateDetector
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ type encoderVP8 struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newVP8Encoder creates new VP8 encoder
|
// newVP8Encoder creates new VP8 encoder
|
||||||
func newVP8Encoder(r video.Reader, p prop.Media, params ParamVP8) (io.ReadCloser, error) {
|
func newVP8Encoder(r video.Reader, p prop.Media, params ParamsVP8) (io.ReadCloser, error) {
|
||||||
if p.Width%16 != 0 || p.Width == 0 {
|
if p.Width%16 != 0 || p.Width == 0 {
|
||||||
return nil, errors.New("width must be 16*n")
|
return nil, errors.New("width must be 16*n")
|
||||||
}
|
}
|
||||||
|
@@ -87,7 +87,7 @@ type encoderVP9 struct {
|
|||||||
|
|
||||||
frameCnt int
|
frameCnt int
|
||||||
prop prop.Media
|
prop prop.Media
|
||||||
params ParamVP9
|
params ParamsVP9
|
||||||
|
|
||||||
rate *framerateDetector
|
rate *framerateDetector
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ type encoderVP9 struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newVP9Encoder creates new VP9 encoder
|
// newVP9Encoder creates new VP9 encoder
|
||||||
func newVP9Encoder(r video.Reader, p prop.Media, params ParamVP9) (io.ReadCloser, error) {
|
func newVP9Encoder(r video.Reader, p prop.Media, params ParamsVP9) (io.ReadCloser, error) {
|
||||||
if p.Width%16 != 0 || p.Width == 0 {
|
if p.Width%16 != 0 || p.Width == 0 {
|
||||||
return nil, errors.New("width must be 16*n")
|
return nil, errors.New("width must be 16*n")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user