Revert "Use the factory instead of using the builtin code path in VideoCodecInitializer."

This reverts commit be142178aaf6ab4089b4d81c88c3d59c12cca567.

Reason for revert: breaking internal projects

Original change's description:
> Use the factory instead of using the builtin code path in `VideoCodecInitializer`.
> 
> Bug: webrtc:9513
> Change-Id: Ia299ae1044a3ff4c91e208200938cba540bdcea6
> Reviewed-on: https://webrtc-review.googlesource.com/c/94782
> Commit-Queue: Jiawei Ou <ouj@fb.com>
> Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Anders Carlsson <andersc@webrtc.org>
> Reviewed-by: Seth Hampson <shampson@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25456}

TBR=brandtr@webrtc.org,magjed@webrtc.org,sakal@webrtc.org,nisse@webrtc.org,andersc@webrtc.org,tommi@webrtc.org,kthelgason@webrtc.org,sprang@webrtc.org,srte@webrtc.org,perkj@webrtc.org,tkchin@webrtc.org,shampson@webrtc.org,glaznev@webrtc.org,ouj@fb.com,qingsi@webrtc.org

Change-Id: I8040ccabe3ae6464d72c7696adb663c1dd275b63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9513
Reviewed-on: https://webrtc-review.googlesource.com/c/108980
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25459}
This commit is contained in:
Qingsi Wang
2018-11-01 04:45:53 +00:00
committed by Commit Bot
parent 7852d291c9
commit 59844ce57e
57 changed files with 137 additions and 389 deletions

View File

@ -24,13 +24,15 @@
namespace webrtc {
bool VideoCodecInitializer::SetupCodec(const VideoEncoderConfig& config,
const std::vector<VideoStream>& streams,
VideoCodec* codec) {
bool VideoCodecInitializer::SetupCodec(
const VideoEncoderConfig& config,
const std::vector<VideoStream>& streams,
VideoCodec* codec,
std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
if (config.codec_type == kVideoCodecMultiplex) {
VideoEncoderConfig associated_config = config.Copy();
associated_config.codec_type = kVideoCodecVP9;
if (!SetupCodec(associated_config, streams, codec)) {
if (!SetupCodec(associated_config, streams, codec, bitrate_allocator)) {
RTC_LOG(LS_ERROR) << "Failed to create stereo encoder configuration.";
return false;
}
@ -39,9 +41,31 @@ bool VideoCodecInitializer::SetupCodec(const VideoEncoderConfig& config,
}
*codec = VideoEncoderConfigToVideoCodec(config, streams);
*bitrate_allocator = CreateBitrateAllocator(*codec);
return true;
}
std::unique_ptr<VideoBitrateAllocator>
VideoCodecInitializer::CreateBitrateAllocator(const VideoCodec& codec) {
std::unique_ptr<VideoBitrateAllocator> rate_allocator;
switch (codec.codecType) {
case kVideoCodecVP8:
RTC_FALLTHROUGH();
case kVideoCodecH264:
rate_allocator.reset(new SimulcastRateAllocator(codec));
break;
case kVideoCodecVP9:
rate_allocator.reset(new SvcRateAllocator(codec));
break;
default:
rate_allocator.reset(new DefaultVideoBitrateAllocator(codec));
}
return rate_allocator;
}
// TODO(sprang): Split this up and separate the codec specific parts.
VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
const VideoEncoderConfig& config,