• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/codecs/vp9/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     std::unique_ptr<VideoBitrateAllocator> rate_allocator;
34     switch (codec.codecType) {
35       case kVideoCodecVP9:
36         rate_allocator.reset(new SvcRateAllocator(codec));
37         break;
38       default:
39         rate_allocator.reset(new SimulcastRateAllocator(codec));
40     }
41     return rate_allocator;
42   }
43 };
44 
45 }  // namespace
46 
47 std::unique_ptr<VideoBitrateAllocatorFactory>
CreateBuiltinVideoBitrateAllocatorFactory()48 CreateBuiltinVideoBitrateAllocatorFactory() {
49   return std::make_unique<BuiltinVideoBitrateAllocatorFactory>();
50 }
51 
52 }  // namespace webrtc
53