blob: 398b722e61c53f58c7ee1a089b7c0eda0e0619c8 [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
Jiawei Oudee91912018-01-28 22:40:54 -080015#include "rtc_base/stringencode.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
Niels Möller7d76a312018-10-26 12:57:07 +020024AudioSendStream::Config::Config(Transport* send_transport,
25 MediaTransportInterface* media_transport)
26 : send_transport(send_transport), media_transport(media_transport) {}
27
solenberg940b6d62016-10-25 11:19:07 -070028AudioSendStream::Config::Config(Transport* send_transport)
Niels Möller7d76a312018-10-26 12:57:07 +020029 : Config(send_transport, nullptr) {}
solenberg940b6d62016-10-25 11:19:07 -070030
minyue6b825df2016-10-31 04:08:32 -070031AudioSendStream::Config::~Config() = default;
32
solenberg940b6d62016-10-25 11:19:07 -070033std::string AudioSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020034 char buf[1024];
35 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070036 ss << "{rtp: " << rtp.ToString();
deadbeef922246a2017-02-26 04:18:12 -080037 ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
Niels Möller7d76a312018-10-26 12:57:07 +020038 ss << ", media_transport: " << (media_transport ? "(Transport)" : "null");
minyue10cbb462016-11-07 09:29:22 -080039 ss << ", min_bitrate_bps: " << min_bitrate_bps;
40 ss << ", max_bitrate_bps: " << max_bitrate_bps;
ossu20a4b3f2017-04-27 02:08:52 -070041 ss << ", send_codec_spec: "
42 << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
solenberg940b6d62016-10-25 11:19:07 -070043 ss << '}';
44 return ss.str();
45}
46
47AudioSendStream::Config::Rtp::Rtp() = default;
48
49AudioSendStream::Config::Rtp::~Rtp() = default;
50
51std::string AudioSendStream::Config::Rtp::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020052 char buf[1024];
53 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070054 ss << "{ssrc: " << ssrc;
55 ss << ", extensions: [";
56 for (size_t i = 0; i < extensions.size(); ++i) {
57 ss << extensions[i].ToString();
58 if (i != extensions.size() - 1) {
59 ss << ", ";
60 }
61 }
62 ss << ']';
63 ss << ", nack: " << nack.ToString();
64 ss << ", c_name: " << c_name;
65 ss << '}';
66 return ss.str();
67}
68
ossu20a4b3f2017-04-27 02:08:52 -070069AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
70 int payload_type,
71 const SdpAudioFormat& format)
72 : payload_type(payload_type), format(format) {}
73AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
solenberg940b6d62016-10-25 11:19:07 -070074
75std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020076 char buf[1024];
77 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070078 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
79 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
ossu20a4b3f2017-04-27 02:08:52 -070080 ss << ", cng_payload_type: "
Jiawei Oudee91912018-01-28 22:40:54 -080081 << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
ossu20a4b3f2017-04-27 02:08:52 -070082 ss << ", payload_type: " << payload_type;
Jonas Olssonabbe8412018-04-03 13:40:05 +020083 ss << ", format: " << rtc::ToString(format);
solenberg940b6d62016-10-25 11:19:07 -070084 ss << '}';
85 return ss.str();
86}
87
88bool AudioSendStream::Config::SendCodecSpec::operator==(
89 const AudioSendStream::Config::SendCodecSpec& rhs) const {
minyue6b825df2016-10-31 04:08:32 -070090 if (nack_enabled == rhs.nack_enabled &&
91 transport_cc_enabled == rhs.transport_cc_enabled &&
minyue6b825df2016-10-31 04:08:32 -070092 cng_payload_type == rhs.cng_payload_type &&
ossu20a4b3f2017-04-27 02:08:52 -070093 payload_type == rhs.payload_type && format == rhs.format &&
94 target_bitrate_bps == rhs.target_bitrate_bps) {
minyue6b825df2016-10-31 04:08:32 -070095 return true;
solenberg940b6d62016-10-25 11:19:07 -070096 }
minyue6b825df2016-10-31 04:08:32 -070097 return false;
solenberg940b6d62016-10-25 11:19:07 -070098}
99} // namespace webrtc