diff --git a/video/encoder_rtcp_feedback.cc b/video/encoder_rtcp_feedback.cc index 5a1194f966..9e0227403d 100644 --- a/video/encoder_rtcp_feedback.cc +++ b/video/encoder_rtcp_feedback.cc @@ -60,7 +60,8 @@ void EncoderRtcpFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) { time_last_intra_request_ms_[index] = now_ms; } - video_stream_encoder_->OnReceivedIntraFrameRequest(index); + // Always produce key frame for all streams. + video_stream_encoder_->SendKeyFrame(); } } // namespace webrtc diff --git a/video/encoder_rtcp_feedback_unittest.cc b/video/encoder_rtcp_feedback_unittest.cc index cf9d62e70c..07e89781da 100644 --- a/video/encoder_rtcp_feedback_unittest.cc +++ b/video/encoder_rtcp_feedback_unittest.cc @@ -33,7 +33,7 @@ class MockVideoStreamEncoder : public VideoStreamEncoder { CpuOveruseOptions(), nullptr)) {} ~MockVideoStreamEncoder() { Stop(); } - MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t)); + MOCK_METHOD0(SendKeyFrame, void()); }; class VieKeyRequestTest : public ::testing::Test { @@ -59,18 +59,18 @@ class VieKeyRequestTest : public ::testing::Test { }; TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { - EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); + EXPECT_CALL(encoder_, SendKeyFrame()).Times(1); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); } TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) { - EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); + EXPECT_CALL(encoder_, SendKeyFrame()).Times(1); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); simulated_clock_.AdvanceTimeMilliseconds(10); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); - EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); + EXPECT_CALL(encoder_, SendKeyFrame()).Times(1); simulated_clock_.AdvanceTimeMilliseconds(300); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 340bbf4419..575f7d3b4d 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -815,6 +815,7 @@ void VideoStreamEncoder::SendKeyFrame() { return; } RTC_DCHECK_RUN_ON(&encoder_queue_); + TRACE_EVENT0("webrtc", "OnKeyFrameRequest"); video_sender_.IntraFrameRequest(0); } @@ -873,18 +874,6 @@ void VideoStreamEncoder::OnDroppedFrame(DropReason reason) { } } -void VideoStreamEncoder::OnReceivedIntraFrameRequest(size_t stream_index) { - if (!encoder_queue_.IsCurrent()) { - encoder_queue_.PostTask( - [this, stream_index] { OnReceivedIntraFrameRequest(stream_index); }); - return; - } - RTC_DCHECK_RUN_ON(&encoder_queue_); - // Key frame request from remote side, signal to VCM. - TRACE_EVENT0("webrtc", "OnKeyFrameRequest"); - video_sender_.IntraFrameRequest(stream_index); -} - void VideoStreamEncoder::OnBitrateUpdated(uint32_t bitrate_bps, uint8_t fraction_lost, int64_t round_trip_time_ms) { diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index d8679bd3c7..9a0e4c1ddf 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -99,10 +99,8 @@ class VideoStreamEncoder : public rtc::VideoSinkInterface, // guaranteed that no encoded frames will be delivered to the sink. void Stop(); - void SendKeyFrame(); - - // virtual to test EncoderStateFeedback with mocks. - virtual void OnReceivedIntraFrameRequest(size_t stream_index); + // virtual to test EncoderRtcpFeedback with mocks. + virtual void SendKeyFrame(); void OnBitrateUpdated(uint32_t bitrate_bps, uint8_t fraction_lost,