Henrik Boström | b04b2a1 | 2019-12-10 14:14:09 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019 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 "call/adaptation/resource.h" |
| 12 | |
| 13 | #include "rtc_base/strings/string_builder.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | namespace { |
| 18 | |
| 19 | const char* ResourceUsageStateToString(ResourceUsageState usage_state) { |
| 20 | switch (usage_state) { |
| 21 | case ResourceUsageState::kOveruse: |
| 22 | return "overuse"; |
| 23 | case ResourceUsageState::kStable: |
| 24 | return "stable"; |
| 25 | case ResourceUsageState::kUnderuse: |
| 26 | return "underuse"; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | } // namespace |
| 31 | |
| 32 | Resource::~Resource() {} |
| 33 | |
| 34 | std::string Resource::ToString() const { |
| 35 | rtc::StringBuilder sb; |
| 36 | sb << Name() << ": " << CurrentUsage() << " " << UsageUnitsOfMeasurement(); |
| 37 | sb << " (" << ResourceUsageStateToString(CurrentUsageState()) << ")"; |
| 38 | return sb.str(); |
| 39 | } |
| 40 | |
| 41 | } // namespace webrtc |