blob: b6190073c188746753c0a4730c39af0d70eb1392 [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
11#include "webrtc/api/call/audio_send_stream.h"
12
13#include <string>
14
15namespace {
16
17std::string ToString(const webrtc::CodecInst& codec_inst) {
18 std::stringstream ss;
19 ss << "{pltype: " << codec_inst.pltype;
20 ss << ", plname: \"" << codec_inst.plname << "\"";
21 ss << ", plfreq: " << codec_inst.plfreq;
22 ss << ", pacsize: " << codec_inst.pacsize;
23 ss << ", channels: " << codec_inst.channels;
24 ss << ", rate: " << codec_inst.rate;
25 ss << '}';
26 return ss.str();
27}
28} // namespace
29
30namespace webrtc {
31
32AudioSendStream::Stats::Stats() = default;
hbos1acfbd22016-11-17 23:43:29 -080033AudioSendStream::Stats::~Stats() = default;
solenberg940b6d62016-10-25 11:19:07 -070034
35AudioSendStream::Config::Config(Transport* send_transport)
36 : send_transport(send_transport) {}
37
minyue6b825df2016-10-31 04:08:32 -070038AudioSendStream::Config::~Config() = default;
39
solenberg940b6d62016-10-25 11:19:07 -070040std::string AudioSendStream::Config::ToString() const {
41 std::stringstream ss;
42 ss << "{rtp: " << rtp.ToString();
43 ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
44 ss << ", voe_channel_id: " << voe_channel_id;
minyue10cbb462016-11-07 09:29:22 -080045 ss << ", min_bitrate_bps: " << min_bitrate_bps;
46 ss << ", max_bitrate_bps: " << max_bitrate_bps;
solenberg940b6d62016-10-25 11:19:07 -070047 ss << ", send_codec_spec: " << send_codec_spec.ToString();
48 ss << '}';
49 return ss.str();
50}
51
52AudioSendStream::Config::Rtp::Rtp() = default;
53
54AudioSendStream::Config::Rtp::~Rtp() = default;
55
56std::string AudioSendStream::Config::Rtp::ToString() const {
57 std::stringstream ss;
58 ss << "{ssrc: " << ssrc;
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 << ", nack: " << nack.ToString();
68 ss << ", c_name: " << c_name;
69 ss << '}';
70 return ss.str();
71}
72
73AudioSendStream::Config::SendCodecSpec::SendCodecSpec() {
74 webrtc::CodecInst empty_inst = {0};
75 codec_inst = empty_inst;
76 codec_inst.pltype = -1;
77}
78
79std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
80 std::stringstream ss;
81 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
82 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
83 ss << ", enable_codec_fec: " << (enable_codec_fec ? "true" : "false");
84 ss << ", enable_opus_dtx: " << (enable_opus_dtx ? "true" : "false");
85 ss << ", opus_max_playback_rate: " << opus_max_playback_rate;
86 ss << ", cng_payload_type: " << cng_payload_type;
87 ss << ", cng_plfreq: " << cng_plfreq;
minyue6b825df2016-10-31 04:08:32 -070088 ss << ", min_ptime: " << min_ptime_ms;
89 ss << ", max_ptime: " << max_ptime_ms;
solenberg940b6d62016-10-25 11:19:07 -070090 ss << ", codec_inst: " << ::ToString(codec_inst);
91 ss << '}';
92 return ss.str();
93}
94
95bool AudioSendStream::Config::SendCodecSpec::operator==(
96 const AudioSendStream::Config::SendCodecSpec& rhs) const {
minyue6b825df2016-10-31 04:08:32 -070097 if (nack_enabled == rhs.nack_enabled &&
98 transport_cc_enabled == rhs.transport_cc_enabled &&
99 enable_codec_fec == rhs.enable_codec_fec &&
100 enable_opus_dtx == rhs.enable_opus_dtx &&
101 opus_max_playback_rate == rhs.opus_max_playback_rate &&
102 cng_payload_type == rhs.cng_payload_type &&
103 cng_plfreq == rhs.cng_plfreq && max_ptime_ms == rhs.max_ptime_ms &&
104 min_ptime_ms == rhs.min_ptime_ms && codec_inst == rhs.codec_inst) {
105 return true;
solenberg940b6d62016-10-25 11:19:07 -0700106 }
minyue6b825df2016-10-31 04:08:32 -0700107 return false;
solenberg940b6d62016-10-25 11:19:07 -0700108}
109} // namespace webrtc