1 /*
2  *  Copyright 2018 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 "rtc_base/strings/audio_format_to_string.h"
12 
13 #include <utility>
14 
15 #include "rtc_base/strings/string_builder.h"
16 
17 namespace rtc {
ToString(const webrtc::SdpAudioFormat & saf)18 std::string ToString(const webrtc::SdpAudioFormat& saf) {
19   char sb_buf[1024];
20   rtc::SimpleStringBuilder sb(sb_buf);
21   sb << "{name: " << saf.name;
22   sb << ", clockrate_hz: " << saf.clockrate_hz;
23   sb << ", num_channels: " << saf.num_channels;
24   sb << ", parameters: {";
25   const char* sep = "";
26   for (const auto& kv : saf.parameters) {
27     sb << sep << kv.first << ": " << kv.second;
28     sep = ", ";
29   }
30   sb << "}}";
31   return sb.str();
32 }
ToString(const webrtc::AudioCodecInfo & aci)33 std::string ToString(const webrtc::AudioCodecInfo& aci) {
34   char sb_buf[1024];
35   rtc::SimpleStringBuilder sb(sb_buf);
36   sb << "{sample_rate_hz: " << aci.sample_rate_hz;
37   sb << ", num_channels: " << aci.num_channels;
38   sb << ", default_bitrate_bps: " << aci.default_bitrate_bps;
39   sb << ", min_bitrate_bps: " << aci.min_bitrate_bps;
40   sb << ", max_bitrate_bps: " << aci.max_bitrate_bps;
41   sb << ", allow_comfort_noise: " << aci.allow_comfort_noise;
42   sb << ", supports_network_adaption: " << aci.supports_network_adaption;
43   sb << "}";
44   return sb.str();
45 }
ToString(const webrtc::AudioCodecSpec & acs)46 std::string ToString(const webrtc::AudioCodecSpec& acs) {
47   char sb_buf[1024];
48   rtc::SimpleStringBuilder sb(sb_buf);
49   sb << "{format: " << ToString(acs.format);
50   sb << ", info: " << ToString(acs.info);
51   sb << "}";
52   return sb.str();
53 }
54 }  // namespace rtc
55