Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: webrtc/modules/video_coding/video_coding_impl.cc

Issue 2510583002: Reland #2 of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.h ('k') | webrtc/modules/video_coding/video_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/video_coding_impl.cc
diff --git a/webrtc/modules/video_coding/video_coding_impl.cc b/webrtc/modules/video_coding/video_coding_impl.cc
index 2f709b610c1453a6e8fc9415042189a9f03ddae2..021281bffa07a5d81b8f2a7e479a1bb62543073e 100644
--- a/webrtc/modules/video_coding/video_coding_impl.cc
+++ b/webrtc/modules/video_coding/video_coding_impl.cc
@@ -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
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.h ('k') | webrtc/modules/video_coding/video_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698