blob: 4b4a23ed242a30e1825549129c551f7577be7826 [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 Chapovalov4b18e242020-10-16 16:14:58 +020015#include "modules/video_coding/svc/scalability_structure_key_svc.h"
Danil Chapovalovda7fe392020-10-15 15:57:17 +020016#include "modules/video_coding/svc/scalability_structure_l1t2.h"
17#include "modules/video_coding/svc/scalability_structure_l1t3.h"
18#include "modules/video_coding/svc/scalability_structure_l2t1.h"
Danil Chapovalovda7fe392020-10-15 15:57:17 +020019#include "modules/video_coding/svc/scalability_structure_l2t1h.h"
20#include "modules/video_coding/svc/scalability_structure_l2t2.h"
Danil Chapovalovda7fe392020-10-15 15:57:17 +020021#include "modules/video_coding/svc/scalability_structure_l2t2_key_shift.h"
22#include "modules/video_coding/svc/scalability_structure_l3t1.h"
23#include "modules/video_coding/svc/scalability_structure_l3t3.h"
24#include "modules/video_coding/svc/scalability_structure_s2t1.h"
25#include "modules/video_coding/svc/scalable_video_controller.h"
26#include "modules/video_coding/svc/scalable_video_controller_no_layering.h"
Danil Chapovalova13e7a12020-07-14 12:34:36 +020027#include "rtc_base/checks.h"
28
29namespace webrtc {
30namespace {
31
32struct NamedStructureFactory {
33 absl::string_view name;
34 // Use function pointer to make NamedStructureFactory trivally destructable.
35 std::unique_ptr<ScalableVideoController> (*factory)();
36};
37
38// Wrap std::make_unique function to have correct return type.
39template <typename T>
40std::unique_ptr<ScalableVideoController> Create() {
41 return std::make_unique<T>();
42}
43
44constexpr NamedStructureFactory kFactories[] = {
45 {"NONE", Create<ScalableVideoControllerNoLayering>},
46 {"L1T2", Create<ScalabilityStructureL1T2>},
47 {"L1T3", Create<ScalabilityStructureL1T3>},
48 {"L2T1", Create<ScalabilityStructureL2T1>},
49 {"L2T1h", Create<ScalabilityStructureL2T1h>},
50 {"L2T1_KEY", Create<ScalabilityStructureL2T1Key>},
51 {"L2T2", Create<ScalabilityStructureL2T2>},
52 {"L2T2_KEY", Create<ScalabilityStructureL2T2Key>},
53 {"L2T2_KEY_SHIFT", Create<ScalabilityStructureL2T2KeyShift>},
54 {"L3T1", Create<ScalabilityStructureL3T1>},
55 {"L3T3", Create<ScalabilityStructureL3T3>},
Danil Chapovalov4b18e242020-10-16 16:14:58 +020056 {"L3T3_KEY", Create<ScalabilityStructureL3T3Key>},
Danil Chapovalova13e7a12020-07-14 12:34:36 +020057 {"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