blob: d0ef4215a985254b309a5716aca8138c90262539 [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
24AudioSendStream::Config::Config(Transport* send_transport)
25 : send_transport(send_transport) {}
26
minyue6b825df2016-10-31 04:08:32 -070027AudioSendStream::Config::~Config() = default;
28
solenberg940b6d62016-10-25 11:19:07 -070029std::string AudioSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020030 char buf[1024];
31 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070032 ss << "{rtp: " << rtp.ToString();
deadbeef922246a2017-02-26 04:18:12 -080033 ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
minyue10cbb462016-11-07 09:29:22 -080034 ss << ", min_bitrate_bps: " << min_bitrate_bps;
35 ss << ", max_bitrate_bps: " << max_bitrate_bps;
ossu20a4b3f2017-04-27 02:08:52 -070036 ss << ", send_codec_spec: "
37 << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
solenberg940b6d62016-10-25 11:19:07 -070038 ss << '}';
39 return ss.str();
40}
41
42AudioSendStream::Config::Rtp::Rtp() = default;
43
44AudioSendStream::Config::Rtp::~Rtp() = default;
45
46std::string AudioSendStream::Config::Rtp::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020047 char buf[1024];
48 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070049 ss << "{ssrc: " << ssrc;
50 ss << ", extensions: [";
51 for (size_t i = 0; i < extensions.size(); ++i) {
52 ss << extensions[i].ToString();
53 if (i != extensions.size() - 1) {
54 ss << ", ";
55 }
56 }
57 ss << ']';
58 ss << ", nack: " << nack.ToString();
59 ss << ", c_name: " << c_name;
60 ss << '}';
61 return ss.str();
62}
63
ossu20a4b3f2017-04-27 02:08:52 -070064AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
65 int payload_type,
66 const SdpAudioFormat& format)
67 : payload_type(payload_type), format(format) {}
68AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
solenberg940b6d62016-10-25 11:19:07 -070069
70std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020071 char buf[1024];
72 rtc::SimpleStringBuilder ss(buf);
solenberg940b6d62016-10-25 11:19:07 -070073 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
74 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
ossu20a4b3f2017-04-27 02:08:52 -070075 ss << ", cng_payload_type: "
Jiawei Oudee91912018-01-28 22:40:54 -080076 << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
ossu20a4b3f2017-04-27 02:08:52 -070077 ss << ", payload_type: " << payload_type;
Jonas Olssonabbe8412018-04-03 13:40:05 +020078 ss << ", format: " << rtc::ToString(format);
solenberg940b6d62016-10-25 11:19:07 -070079 ss << '}';
80 return ss.str();
81}
82
83bool AudioSendStream::Config::SendCodecSpec::operator==(
84 const AudioSendStream::Config::SendCodecSpec& rhs) const {
minyue6b825df2016-10-31 04:08:32 -070085 if (nack_enabled == rhs.nack_enabled &&
86 transport_cc_enabled == rhs.transport_cc_enabled &&
minyue6b825df2016-10-31 04:08:32 -070087 cng_payload_type == rhs.cng_payload_type &&
ossu20a4b3f2017-04-27 02:08:52 -070088 payload_type == rhs.payload_type && format == rhs.format &&
89 target_bitrate_bps == rhs.target_bitrate_bps) {
minyue6b825df2016-10-31 04:08:32 -070090 return true;
solenberg940b6d62016-10-25 11:19:07 -070091 }
minyue6b825df2016-10-31 04:08:32 -070092 return false;
solenberg940b6d62016-10-25 11:19:07 -070093}
94} // namespace webrtc