2018-04-13 13:56:17 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-05-08 10:43:18 +02:00
|
|
|
#include "api/units/data_rate.h"
|
2018-04-13 13:56:17 +02:00
|
|
|
|
2024-08-14 07:29:04 -07:00
|
|
|
#include <string>
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/array_view.h"
|
2018-04-13 13:56:17 +02:00
|
|
|
#include "rtc_base/strings/string_builder.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2018-11-19 11:17:12 +01:00
|
|
|
std::string ToString(DataRate value) {
|
2018-04-13 13:56:17 +02:00
|
|
|
char buf[64];
|
2025-02-19 10:06:32 +00:00
|
|
|
SimpleStringBuilder sb(buf);
|
2019-03-05 09:14:02 +01:00
|
|
|
if (value.IsPlusInfinity()) {
|
|
|
|
|
sb << "+inf bps";
|
|
|
|
|
} else if (value.IsMinusInfinity()) {
|
|
|
|
|
sb << "-inf bps";
|
2018-04-13 13:56:17 +02:00
|
|
|
} else {
|
2018-08-23 14:44:05 +02:00
|
|
|
if (value.bps() == 0 || value.bps() % 1000 != 0) {
|
|
|
|
|
sb << value.bps() << " bps";
|
|
|
|
|
} else {
|
|
|
|
|
sb << value.kbps() << " kbps";
|
|
|
|
|
}
|
2018-04-13 13:56:17 +02:00
|
|
|
}
|
|
|
|
|
return sb.str();
|
|
|
|
|
}
|
|
|
|
|
} // namespace webrtc
|