1 /*
2 * Copyright (c) 2015 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/audio_send_stream.h"
12
13 #include <stddef.h>
14
15 #include "rtc_base/string_encode.h"
16 #include "rtc_base/strings/audio_format_to_string.h"
17 #include "rtc_base/strings/string_builder.h"
18
19 namespace webrtc {
20
21 AudioSendStream::Stats::Stats() = default;
22 AudioSendStream::Stats::~Stats() = default;
23
Config(Transport * send_transport)24 AudioSendStream::Config::Config(Transport* send_transport)
25 : send_transport(send_transport) {}
26
27 AudioSendStream::Config::~Config() = default;
28
ToString() const29 std::string AudioSendStream::Config::ToString() const {
30 char buf[1024];
31 rtc::SimpleStringBuilder ss(buf);
32 ss << "{rtp: " << rtp.ToString();
33 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
34 ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
35 ss << ", min_bitrate_bps: " << min_bitrate_bps;
36 ss << ", max_bitrate_bps: " << max_bitrate_bps;
37 ss << ", send_codec_spec: "
38 << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
39 ss << '}';
40 return ss.str();
41 }
42
43 AudioSendStream::Config::Rtp::Rtp() = default;
44
45 AudioSendStream::Config::Rtp::~Rtp() = default;
46
ToString() const47 std::string AudioSendStream::Config::Rtp::ToString() const {
48 char buf[1024];
49 rtc::SimpleStringBuilder ss(buf);
50 ss << "{ssrc: " << ssrc;
51 ss << ", extmap-allow-mixed: " << (extmap_allow_mixed ? "true" : "false");
52 ss << ", extensions: [";
53 for (size_t i = 0; i < extensions.size(); ++i) {
54 ss << extensions[i].ToString();
55 if (i != extensions.size() - 1) {
56 ss << ", ";
57 }
58 }
59 ss << ']';
60 ss << ", c_name: " << c_name;
61 ss << '}';
62 return ss.str();
63 }
64
SendCodecSpec(int payload_type,const SdpAudioFormat & format)65 AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
66 int payload_type,
67 const SdpAudioFormat& format)
68 : payload_type(payload_type), format(format) {}
69 AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
70
ToString() const71 std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
72 char buf[1024];
73 rtc::SimpleStringBuilder ss(buf);
74 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
75 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
76 ss << ", cng_payload_type: "
77 << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
78 ss << ", red_payload_type: "
79 << (red_payload_type ? rtc::ToString(*red_payload_type) : "<unset>");
80 ss << ", payload_type: " << payload_type;
81 ss << ", format: " << rtc::ToString(format);
82 ss << '}';
83 return ss.str();
84 }
85
operator ==(const AudioSendStream::Config::SendCodecSpec & rhs) const86 bool AudioSendStream::Config::SendCodecSpec::operator==(
87 const AudioSendStream::Config::SendCodecSpec& rhs) const {
88 if (nack_enabled == rhs.nack_enabled &&
89 transport_cc_enabled == rhs.transport_cc_enabled &&
90 cng_payload_type == rhs.cng_payload_type &&
91 payload_type == rhs.payload_type && format == rhs.format &&
92 target_bitrate_bps == rhs.target_bitrate_bps) {
93 return true;
94 }
95 return false;
96 }
97 } // namespace webrtc
98