Niels Möller | 79d566b | 2022-04-29 11:03:13 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2022 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 "modules/video_coding/svc/scalability_mode_util.h" |
| 12 | |
| 13 | #include "absl/strings/string_view.h" |
| 14 | #include "absl/types/optional.h" |
| 15 | #include "api/video_codecs/scalability_mode.h" |
| 16 | #include "rtc_base/checks.h" |
| 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | absl::optional<ScalabilityMode> ScalabilityModeFromString( |
| 21 | absl::string_view mode_string) { |
| 22 | if (mode_string == "L1T1") |
| 23 | return ScalabilityMode::kL1T1; |
| 24 | if (mode_string == "L1T2") |
| 25 | return ScalabilityMode::kL1T2; |
| 26 | if (mode_string == "L1T3") |
| 27 | return ScalabilityMode::kL1T3; |
| 28 | |
| 29 | if (mode_string == "L2T1") |
| 30 | return ScalabilityMode::kL2T1; |
| 31 | if (mode_string == "L2T1h") |
| 32 | return ScalabilityMode::kL2T1h; |
| 33 | if (mode_string == "L2T1_KEY") |
| 34 | return ScalabilityMode::kL2T1_KEY; |
| 35 | |
| 36 | if (mode_string == "L2T2") |
| 37 | return ScalabilityMode::kL2T2; |
| 38 | if (mode_string == "L2T2_KEY") |
| 39 | return ScalabilityMode::kL2T2_KEY; |
| 40 | if (mode_string == "L2T2_KEY_SHIFT") |
| 41 | return ScalabilityMode::kL2T2_KEY_SHIFT; |
| 42 | if (mode_string == "L2T3_KEY") |
| 43 | return ScalabilityMode::kL2T3_KEY; |
| 44 | |
| 45 | if (mode_string == "L3T1") |
| 46 | return ScalabilityMode::kL3T1; |
| 47 | if (mode_string == "L3T3") |
| 48 | return ScalabilityMode::kL3T3; |
| 49 | if (mode_string == "L3T3_KEY") |
| 50 | return ScalabilityMode::kL3T3_KEY; |
| 51 | |
| 52 | if (mode_string == "S2T1") |
| 53 | return ScalabilityMode::kS2T1; |
| 54 | if (mode_string == "S3T3") |
| 55 | return ScalabilityMode::kS3T3; |
| 56 | |
| 57 | return absl::nullopt; |
| 58 | } |
| 59 | |
| 60 | absl::string_view ScalabilityModeToString(ScalabilityMode scalability_mode) { |
| 61 | switch (scalability_mode) { |
| 62 | case ScalabilityMode::kL1T1: |
| 63 | return "L1T1"; |
| 64 | case ScalabilityMode::kL1T2: |
| 65 | return "L1T2"; |
| 66 | case ScalabilityMode::kL1T3: |
| 67 | return "L1T3"; |
| 68 | case ScalabilityMode::kL2T1: |
| 69 | return "L2T1"; |
| 70 | case ScalabilityMode::kL2T1h: |
| 71 | return "L2T1h"; |
| 72 | case ScalabilityMode::kL2T1_KEY: |
| 73 | return "L2T1_KEY"; |
| 74 | case ScalabilityMode::kL2T2: |
| 75 | return "L2T2"; |
| 76 | case ScalabilityMode::kL2T2_KEY: |
| 77 | return "L2T2_KEY"; |
| 78 | case ScalabilityMode::kL2T2_KEY_SHIFT: |
| 79 | return "L2T2_KEY_SHIFT"; |
| 80 | case ScalabilityMode::kL2T3_KEY: |
| 81 | return "L2T3_KEY"; |
| 82 | case ScalabilityMode::kL3T1: |
| 83 | return "L3T1"; |
| 84 | case ScalabilityMode::kL3T3: |
| 85 | return "L3T3"; |
| 86 | case ScalabilityMode::kL3T3_KEY: |
| 87 | return "L3T3_KEY"; |
| 88 | case ScalabilityMode::kS2T1: |
| 89 | return "S2T1"; |
| 90 | case ScalabilityMode::kS3T3: |
| 91 | return "S3T3"; |
| 92 | } |
| 93 | RTC_CHECK_NOTREACHED(); |
| 94 | } |
| 95 | |
| 96 | } // namespace webrtc |