blob: 6fdb39c4aaef06115d8844e5a7caba2704ffaa2f [file] [log] [blame]
solenberg940b6d62016-10-25 11:19:07 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "call/audio_send_stream.h"
Yves Gerey988cc082018-10-23 12:03:01 +020012
13#include <stddef.h>
14
Steve Anton10542f22019-01-11 09:11:00 -080015#include "rtc_base/string_encode.h"
Jonas Olssonabbe8412018-04-03 13:40:05 +020016#include "rtc_base/strings/audio_format_to_string.h"
Jonas Olsson0a713b62018-04-04 15:49:32 +020017#include "rtc_base/strings/string_builder.h"
solenberg940b6d62016-10-25 11:19:07 -070018
solenberg940b6d62016-10-25 11:19:07 -070019namespace webrtc {
20
21AudioSendStream::Stats::Stats() = default;
hbos1acfbd22016-11-17 23:43:29 -080022AudioSendStream::Stats::~Stats() = default;
solenberg940b6d62016-10-25 11:19:07 -070023
Anton Sukhanov4f08faa2019-05-21 11:12:57 -070024AudioSendStream::Config::Config(
25 Transport* send_transport,
26 const MediaTransportConfig& media_transport_config)
27 : send_transport(send_transport),
28 media_transport_config(media_transport_config) {}
Niels Möller7d76a312018-10-26 12:57:07 +020029
solenberg940b6d62016-10-25 11:19:07 -070030AudioSendStream::Config::Config(Transport* send_transport)
Anton Sukhanov4f08faa2019-05-21 11:12:57 -070031 : Config(send_transport, MediaTransportConfig()) {}
solenberg940b6d62016-10-25 11:19:07 -070032
minyue6b825df2016-10-31 04:08:32 -070033AudioSendStream::Config::~Config() = default;
34
solenberg940b6d62016-10-25 11:19:07 -070035std::string AudioSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020036 char buf[1024];
37 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070038 ss << "{rtp: " << rtp.ToString();
Jiawei Ou55718122018-11-09 13:17:39 -080039 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
deadbeef922246a2017-02-26 04:18:12 -080040 ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
Anton Sukhanov4f08faa2019-05-21 11:12:57 -070041 ss << ", media_transport_config: " << media_transport_config.DebugString();
minyue10cbb462016-11-07 09:29:22 -080042 ss << ", min_bitrate_bps: " << min_bitrate_bps;
43 ss << ", max_bitrate_bps: " << max_bitrate_bps;
ossu20a4b3f2017-04-27 02:08:52 -070044 ss << ", send_codec_spec: "
45 << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
solenberg940b6d62016-10-25 11:19:07 -070046 ss << '}';
47 return ss.str();
48}
49
50AudioSendStream::Config::Rtp::Rtp() = default;
51
52AudioSendStream::Config::Rtp::~Rtp() = default;
53
54std::string AudioSendStream::Config::Rtp::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020055 char buf[1024];
56 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070057 ss << "{ssrc: " << ssrc;
Johannes Kron9190b822018-10-29 11:22:05 +010058 ss << ", extmap-allow-mixed: " << (extmap_allow_mixed ? "true" : "false");
solenberg940b6d62016-10-25 11:19:07 -070059 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 << ']';
solenberg940b6d62016-10-25 11:19:07 -070067 ss << ", c_name: " << c_name;
68 ss << '}';
69 return ss.str();
70}
71
ossu20a4b3f2017-04-27 02:08:52 -070072AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
73 int payload_type,
74 const SdpAudioFormat& format)
75 : payload_type(payload_type), format(format) {}
76AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
solenberg940b6d62016-10-25 11:19:07 -070077
78std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020079 char buf[1024];
80 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070081 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
82 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
ossu20a4b3f2017-04-27 02:08:52 -070083 ss << ", cng_payload_type: "
Jiawei Oudee91912018-01-28 22:40:54 -080084 << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
ossu20a4b3f2017-04-27 02:08:52 -070085 ss << ", payload_type: " << payload_type;
Jonas Olssonabbe8412018-04-03 13:40:05 +020086 ss << ", format: " << rtc::ToString(format);
solenberg940b6d62016-10-25 11:19:07 -070087 ss << '}';
88 return ss.str();
89}
90
91bool AudioSendStream::Config::SendCodecSpec::operator==(
92 const AudioSendStream::Config::SendCodecSpec& rhs) const {
minyue6b825df2016-10-31 04:08:32 -070093 if (nack_enabled == rhs.nack_enabled &&
94 transport_cc_enabled == rhs.transport_cc_enabled &&
minyue6b825df2016-10-31 04:08:32 -070095 cng_payload_type == rhs.cng_payload_type &&
ossu20a4b3f2017-04-27 02:08:52 -070096 payload_type == rhs.payload_type && format == rhs.format &&
97 target_bitrate_bps == rhs.target_bitrate_bps) {
minyue6b825df2016-10-31 04:08:32 -070098 return true;
solenberg940b6d62016-10-25 11:19:07 -070099 }
minyue6b825df2016-10-31 04:08:32 -0700100 return false;
solenberg940b6d62016-10-25 11:19:07 -0700101}
102} // namespace webrtc