Reland of Issue 2434073003: Extract bitrate allocation ...
This is a reland of https://codereview.webrtc.org/2434073003/ including some fixes for failing test cases. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 Review-Url: https://codereview.webrtc.org/2488833004 Cr-Commit-Position: refs/heads/master@{#15023}
This commit is contained in:
@ -11,10 +11,14 @@
|
||||
#include "webrtc/modules/video_coding/video_coding_impl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_initializer.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
#include "webrtc/modules/video_coding/encoded_frame.h"
|
||||
#include "webrtc/modules/video_coding/jitter_buffer.h"
|
||||
@ -104,6 +108,21 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
int32_t RegisterSendCodec(const VideoCodec* sendCodec,
|
||||
uint32_t numberOfCores,
|
||||
uint32_t maxPayloadSize) override {
|
||||
if (sendCodec != nullptr && sendCodec->codecType == kVideoCodecVP8) {
|
||||
// Set up a rate allocator and temporal layers factory for this vp8
|
||||
// instance. The codec impl will have a raw pointer to the TL factory,
|
||||
// and will call it when initializing. Since this can happen
|
||||
// asynchronously keep the instance alive until destruction or until a
|
||||
// new send codec is registered.
|
||||
VideoCodec vp8_codec = *sendCodec;
|
||||
std::unique_ptr<TemporalLayersFactory> tl_factory(
|
||||
new TemporalLayersFactory());
|
||||
vp8_codec.VP8()->tl_factory = tl_factory.get();
|
||||
rate_allocator_ = VideoCodecInitializer::CreateBitrateAllocator(
|
||||
vp8_codec, std::move(tl_factory));
|
||||
return sender_.RegisterSendCodec(&vp8_codec, numberOfCores,
|
||||
maxPayloadSize);
|
||||
}
|
||||
return sender_.RegisterSendCodec(sendCodec, numberOfCores, maxPayloadSize);
|
||||
}
|
||||
|
||||
@ -126,7 +145,8 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s.
|
||||
uint8_t lossRate,
|
||||
int64_t rtt) override {
|
||||
return sender_.SetChannelParameters(target_bitrate, lossRate, rtt);
|
||||
return sender_.SetChannelParameters(target_bitrate, lossRate, rtt,
|
||||
rate_allocator_.get());
|
||||
}
|
||||
|
||||
int32_t RegisterProtectionCallback(
|
||||
@ -256,6 +276,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
private:
|
||||
EncodedImageCallbackWrapper post_encode_callback_;
|
||||
vcm::VideoSender sender_;
|
||||
std::unique_ptr<VideoBitrateAllocator> rate_allocator_;
|
||||
vcm::VideoReceiver receiver_;
|
||||
};
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user