1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "api/video/builtin_video_bitrate_allocator_factory.h" 12 13 #include <memory> 14 15 #include "absl/base/macros.h" 16 #include "api/video/video_bitrate_allocator.h" 17 #include "api/video_codecs/video_codec.h" 18 #include "modules/video_coding/svc/svc_rate_allocator.h" 19 #include "modules/video_coding/utility/simulcast_rate_allocator.h" 20 21 namespace webrtc { 22 23 namespace { 24 25 class BuiltinVideoBitrateAllocatorFactory 26 : public VideoBitrateAllocatorFactory { 27 public: 28 BuiltinVideoBitrateAllocatorFactory() = default; 29 ~BuiltinVideoBitrateAllocatorFactory() override = default; 30 CreateVideoBitrateAllocator(const VideoCodec & codec)31 std::unique_ptr<VideoBitrateAllocator> CreateVideoBitrateAllocator( 32 const VideoCodec& codec) override { 33 switch (codec.codecType) { 34 case kVideoCodecAV1: 35 case kVideoCodecVP9: 36 return std::make_unique<SvcRateAllocator>(codec); 37 default: 38 return std::make_unique<SimulcastRateAllocator>(codec); 39 } 40 } 41 }; 42 43 } // namespace 44 45 std::unique_ptr<VideoBitrateAllocatorFactory> CreateBuiltinVideoBitrateAllocatorFactory()46CreateBuiltinVideoBitrateAllocatorFactory() { 47 return std::make_unique<BuiltinVideoBitrateAllocatorFactory>(); 48 } 49 50 } // namespace webrtc 51