blob: a21fab27038498b65a634c98d0db9f2aa8c0ba83 [file] [log] [blame]
Danil Chapovalova13e7a12020-07-14 12:34:36 +02001/*
2 * Copyright (c) 2020 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 */
Danil Chapovalovda7fe392020-10-15 15:57:17 +020010#include "modules/video_coding/svc/create_scalability_structure.h"
Danil Chapovalova13e7a12020-07-14 12:34:36 +020011
12#include <memory>
13
14#include "absl/strings/string_view.h"
Danil Chapovalovda7fe392020-10-15 15:57:17 +020015#include "modules/video_coding/svc/scalability_structure_l1t2.h"
16#include "modules/video_coding/svc/scalability_structure_l1t3.h"
17#include "modules/video_coding/svc/scalability_structure_l2t1.h"
18#include "modules/video_coding/svc/scalability_structure_l2t1_key.h"
19#include "modules/video_coding/svc/scalability_structure_l2t1h.h"
20#include "modules/video_coding/svc/scalability_structure_l2t2.h"
21#include "modules/video_coding/svc/scalability_structure_l2t2_key.h"
22#include "modules/video_coding/svc/scalability_structure_l2t2_key_shift.h"
23#include "modules/video_coding/svc/scalability_structure_l3t1.h"
24#include "modules/video_coding/svc/scalability_structure_l3t3.h"
25#include "modules/video_coding/svc/scalability_structure_s2t1.h"
26#include "modules/video_coding/svc/scalable_video_controller.h"
27#include "modules/video_coding/svc/scalable_video_controller_no_layering.h"
Danil Chapovalova13e7a12020-07-14 12:34:36 +020028#include "rtc_base/checks.h"
29
30namespace webrtc {
31namespace {
32
33struct NamedStructureFactory {
34 absl::string_view name;
35 // Use function pointer to make NamedStructureFactory trivally destructable.
36 std::unique_ptr<ScalableVideoController> (*factory)();
37};
38
39// Wrap std::make_unique function to have correct return type.
40template <typename T>
41std::unique_ptr<ScalableVideoController> Create() {
42 return std::make_unique<T>();
43}
44
45constexpr NamedStructureFactory kFactories[] = {
46 {"NONE", Create<ScalableVideoControllerNoLayering>},
47 {"L1T2", Create<ScalabilityStructureL1T2>},
48 {"L1T3", Create<ScalabilityStructureL1T3>},
49 {"L2T1", Create<ScalabilityStructureL2T1>},
50 {"L2T1h", Create<ScalabilityStructureL2T1h>},
51 {"L2T1_KEY", Create<ScalabilityStructureL2T1Key>},
52 {"L2T2", Create<ScalabilityStructureL2T2>},
53 {"L2T2_KEY", Create<ScalabilityStructureL2T2Key>},
54 {"L2T2_KEY_SHIFT", Create<ScalabilityStructureL2T2KeyShift>},
55 {"L3T1", Create<ScalabilityStructureL3T1>},
56 {"L3T3", Create<ScalabilityStructureL3T3>},
57 {"S2T1", Create<ScalabilityStructureS2T1>},
58};
59
60} // namespace
61
62std::unique_ptr<ScalableVideoController> CreateScalabilityStructure(
63 absl::string_view name) {
64 RTC_DCHECK(!name.empty());
65 for (const auto& entry : kFactories) {
66 if (entry.name == name) {
67 return entry.factory();
68 }
69 }
70 return nullptr;
71}
72
73} // namespace webrtc