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/strings/audio_format_to_string.h"
16 #include "rtc_base/strings/string_builder.h"
17
18 namespace webrtc {
19
20 AudioSendStream::Stats::Stats() = default;
21 AudioSendStream::Stats::~Stats() = default;
22
Config(Transport * send_transport)23 AudioSendStream::Config::Config(Transport* send_transport)
24 : send_transport(send_transport) {}
25
26 AudioSendStream::Config::~Config() = default;
27
ToString() const28 std::string AudioSendStream::Config::ToString() const {
29 rtc::StringBuilder ss;
30 ss << "{rtp: " << rtp.ToString();
31 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
32 ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
33 ss << ", min_bitrate_bps: " << min_bitrate_bps;
34 ss << ", max_bitrate_bps: " << max_bitrate_bps;
35 ss << ", has audio_network_adaptor_config: "
36 << (audio_network_adaptor_config ? "true" : "false");
37 ss << ", has_dscp: " << (has_dscp ? "true" : "false");
38 ss << ", send_codec_spec: "
39 << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
40 ss << "}";
41 return ss.Release();
42 }
43
44 AudioSendStream::Config::Rtp::Rtp() = default;
45
46 AudioSendStream::Config::Rtp::~Rtp() = default;
47
ToString() const48 std::string AudioSendStream::Config::Rtp::ToString() const {
49 char buf[1024];
50 rtc::SimpleStringBuilder ss(buf);
51 ss << "{ssrc: " << ssrc;
52 if (!rid.empty()) {
53 ss << ", rid: " << rid;
54 }
55 if (!mid.empty()) {
56 ss << ", mid: " << mid;
57 }
58 ss << ", extmap-allow-mixed: " << (extmap_allow_mixed ? "true" : "false");
59 ss << ", extensions: [";
60 for (size_t i = 0; i < extensions.size(); ++i) {
61 ss << extensions[i].ToString();
62 if (i != extensions.size() - 1) {
63 ss << ", ";
64 }
65 }
66 ss << ']';
67 ss << ", c_name: " << c_name;
68 ss << '}';
69 return ss.str();
70 }
71
SendCodecSpec(int payload_type,const SdpAudioFormat & format)72 AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
73 int payload_type,
74 const SdpAudioFormat& format)
75 : payload_type(payload_type), format(format) {}
76 AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
77
ToString() const78 std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
79 char buf[1024];
80 rtc::SimpleStringBuilder ss(buf);
81 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
82 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
83 ss << ", enable_non_sender_rtt: "
84 << (enable_non_sender_rtt ? "true" : "false");
85 ss << ", cng_payload_type: "
86 << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
87 ss << ", red_payload_type: "
88 << (red_payload_type ? rtc::ToString(*red_payload_type) : "<unset>");
89 ss << ", payload_type: " << payload_type;
90 ss << ", format: " << rtc::ToString(format);
91 ss << '}';
92 return ss.str();
93 }
94
operator ==(const AudioSendStream::Config::SendCodecSpec & rhs) const95 bool AudioSendStream::Config::SendCodecSpec::operator==(
96 const AudioSendStream::Config::SendCodecSpec& rhs) const {
97 if (nack_enabled == rhs.nack_enabled &&
98 transport_cc_enabled == rhs.transport_cc_enabled &&
99 enable_non_sender_rtt == rhs.enable_non_sender_rtt &&
100 cng_payload_type == rhs.cng_payload_type &&
101 red_payload_type == rhs.red_payload_type &&
102 payload_type == rhs.payload_type && format == rhs.format &&
103 target_bitrate_bps == rhs.target_bitrate_bps) {
104 return true;
105 }
106 return false;
107 }
108 } // namespace webrtc
109