mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-26 20:41:46 +08:00
force key frame implementation for vaapi
This commit is contained in:

committed by
Eric Daniels

parent
b14ce7987c
commit
afb2f78e3c
@@ -100,6 +100,8 @@ type encoderVP8 struct {
|
||||
|
||||
rate *framerateDetector
|
||||
|
||||
forceKeyFrame bool
|
||||
|
||||
mu sync.Mutex
|
||||
closed bool
|
||||
}
|
||||
@@ -316,7 +318,7 @@ func (e *encoderVP8) Read() ([]byte, func(), error) {
|
||||
|
||||
e.frParam.data.framerate = C.uint(e.rate.Calc())
|
||||
|
||||
if kf {
|
||||
if kf || e.forceKeyFrame {
|
||||
// Key frame
|
||||
C.setForceKFFlagVP8(&e.picParam, 1)
|
||||
C.setFrameTypeFlagVP8(&e.picParam, 0)
|
||||
@@ -546,6 +548,10 @@ func (e *encoderVP8) Controller() codec.EncoderController {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *encoderVP8) ForceKeyFrame() error {
|
||||
e.forceKeyFrame = true
|
||||
}
|
||||
|
||||
func (e *encoderVP8) Close() error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
@@ -18,8 +18,6 @@ func TestVP8ShouldImplementBitRateControl(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVP8ShouldImplementKeyFrameControl(t *testing.T) {
|
||||
t.SkipNow() // TODO: Implement key frame control
|
||||
|
||||
e := &encoderVP8{}
|
||||
if _, ok := e.Controller().(codec.KeyFrameController); !ok {
|
||||
t.Error()
|
||||
|
@@ -92,6 +92,8 @@ type encoderVP9 struct {
|
||||
|
||||
rate *framerateDetector
|
||||
|
||||
forceKeyFrame bool
|
||||
|
||||
mu sync.Mutex
|
||||
closed bool
|
||||
}
|
||||
@@ -305,7 +307,7 @@ func (e *encoderVP9) Read() ([]byte, func(), error) {
|
||||
|
||||
e.frParam.data.framerate = C.uint(e.rate.Calc())
|
||||
|
||||
if kf {
|
||||
if kf || e.forceKeyFrame {
|
||||
C.setForceKFFlag9(&e.picParam, 1)
|
||||
C.setFrameTypeFlagVP9(&e.picParam, 0)
|
||||
e.picParam.refresh_frame_flags = 0
|
||||
@@ -481,6 +483,10 @@ func (e *encoderVP9) Controller() codec.EncoderController {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *encoderVP9) ForceKeyFrame() {
|
||||
e.forceKeyFrame = true
|
||||
}
|
||||
|
||||
func (e *encoderVP9) Close() error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
@@ -18,8 +18,6 @@ func TestVP9ShouldImplementBitRateControl(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVP9ShouldImplementKeyFrameControl(t *testing.T) {
|
||||
t.SkipNow() // TODO: Implement key frame control
|
||||
|
||||
e := &encoderVP9{}
|
||||
if _, ok := e.Controller().(codec.KeyFrameController); !ok {
|
||||
t.Error()
|
||||
|
Reference in New Issue
Block a user