mirror of
https://github.com/pion/mediadevices.git
synced 2025-10-06 17:16:56 +08:00
Redesign codec
Resolves https://github.com/pion/mediadevices/issues/114 * Remove codec registrar * Completely redesign how codec is being discovered, tuned, and built * Update examples * Update unit tests
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
package vaapi
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/pion/mediadevices/pkg/codec"
|
||||
"github.com/pion/mediadevices/pkg/io/video"
|
||||
"github.com/pion/mediadevices/pkg/prop"
|
||||
"github.com/pion/webrtc/v2"
|
||||
)
|
||||
|
||||
// ParamVP8 stores VP8 encoding parameters.
|
||||
type ParamVP8 struct {
|
||||
codec.BaseParams
|
||||
Sequence SequenceParamVP8
|
||||
RateControlMode RateControlMode
|
||||
RateControl RateControlParam
|
||||
@@ -14,8 +24,38 @@ type SequenceParamVP8 struct {
|
||||
ClampQindexLow uint
|
||||
}
|
||||
|
||||
// NewVP8Param returns default parameters of VP8 codec.
|
||||
func NewVP8Param() (ParamVP8, error) {
|
||||
return ParamVP8{
|
||||
Sequence: SequenceParamVP8{
|
||||
ClampQindexLow: 9,
|
||||
ClampQindexHigh: 127,
|
||||
},
|
||||
RateControlMode: RateControlVBR,
|
||||
RateControl: RateControlParam{
|
||||
BitsPerSecond: 400000,
|
||||
TargetPercentage: 80,
|
||||
WindowSize: 1500,
|
||||
InitialQP: 60,
|
||||
MinQP: 9,
|
||||
MaxQP: 127,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Name represents the codec name
|
||||
func (p *ParamVP8) Name() string {
|
||||
return webrtc.VP8
|
||||
}
|
||||
|
||||
// BuildVideoEncoder builds VP8 encoder with given params
|
||||
func (p *ParamVP8) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
||||
return newVP8Encoder(r, property, *p)
|
||||
}
|
||||
|
||||
// ParamVP9 represents VAEncSequenceParameterBufferVP9 and other parameter buffers.
|
||||
type ParamVP9 struct {
|
||||
codec.BaseParams
|
||||
RateControlMode RateControlMode
|
||||
RateControl RateControlParam
|
||||
}
|
||||
@@ -52,3 +92,28 @@ const (
|
||||
RateControlQVBR RateControlMode = 0x00000400
|
||||
RateControlAVBR RateControlMode = 0x00000800
|
||||
)
|
||||
|
||||
// NewVP9Param returns default parameters of VP9 codec.
|
||||
func NewVP9Param() (ParamVP9, error) {
|
||||
return ParamVP9{
|
||||
RateControlMode: RateControlVBR,
|
||||
RateControl: RateControlParam{
|
||||
BitsPerSecond: 400000,
|
||||
TargetPercentage: 80,
|
||||
WindowSize: 1500,
|
||||
InitialQP: 60,
|
||||
MinQP: 9,
|
||||
MaxQP: 127,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Name represents the codec name
|
||||
func (p *ParamVP9) Name() string {
|
||||
return webrtc.VP9
|
||||
}
|
||||
|
||||
// BuildVideoEncoder builds VP9 encoder with given params
|
||||
func (p *ParamVP9) BuildVideoEncoder(r video.Reader, property prop.Media) (io.ReadCloser, error) {
|
||||
return newVP9Encoder(r, property, *p)
|
||||
}
|
||||
|
Reference in New Issue
Block a user