SimulcastEncoderAdapter: In passthrough mode set correct lenght for frame_types parameter

If in simulcast case some streams are disabled (especially the first one), the key-frame
requests might be ignorred by e.g. libvpx vp8 encoder wrapper.

Before this CL SimulcastEncoderAdapter always passes single frame type in Encode() call.
However, if underlying encoder used simulcast, it would've expected as many frame types
as there are streams.

Bug: none
Change-Id: I7f56a6540b67273b7d3cf9fa86dc76015b92d271
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165681
Reviewed-by: Evan Shrubsole <eshr@google.com>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30210}
This commit is contained in:
Ilya Nikolaevskiy 2020-01-10 11:56:31 +01:00 committed by Commit Bot
parent 4b07059139
commit 27064adc34

View File

@ -384,16 +384,22 @@ int SimulcastEncoderAdapter::Encode(
const uint32_t frame_timestamp_ms =
1000 * input_image.timestamp() / 90000; // kVideoPayloadTypeFrequency;
std::vector<VideoFrameType> stream_frame_types;
// If adapter is passed through and only one sw encoder does simulcast,
// frame types for all streams should be passed to the encoder unchanged.
// Otherwise a single per-encoder frame type is passed.
std::vector<VideoFrameType> stream_frame_types(
streaminfos_.size() == 1 ? NumberOfStreams(codec_) : 1);
if (send_key_frame) {
stream_frame_types.push_back(VideoFrameType::kVideoFrameKey);
std::fill(stream_frame_types.begin(), stream_frame_types.end(),
VideoFrameType::kVideoFrameKey);
streaminfos_[stream_idx].key_frame_request = false;
} else {
if (streaminfos_[stream_idx].framerate_controller->DropFrame(
frame_timestamp_ms)) {
continue;
}
stream_frame_types.push_back(VideoFrameType::kVideoFrameDelta);
std::fill(stream_frame_types.begin(), stream_frame_types.end(),
VideoFrameType::kVideoFrameDelta);
}
streaminfos_[stream_idx].framerate_controller->AddFrame(frame_timestamp_ms);