blob: 06cbc545d9313846b057ed3432e2862c5c8b9b14 [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;
33
34AudioSendStream::Config::Config(Transport* send_transport)
35 : send_transport(send_transport) {}
36
37std::string AudioSendStream::Config::ToString() const {
38 std::stringstream ss;
39 ss << "{rtp: " << rtp.ToString();
40 ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
41 ss << ", voe_channel_id: " << voe_channel_id;
42 ss << ", min_bitrate_kbps: " << min_bitrate_kbps;
43 ss << ", max_bitrate_kbps: " << max_bitrate_kbps;
44 ss << ", send_codec_spec: " << send_codec_spec.ToString();
45 ss << '}';
46 return ss.str();
47}
48
49AudioSendStream::Config::Rtp::Rtp() = default;
50
51AudioSendStream::Config::Rtp::~Rtp() = default;
52
53std::string AudioSendStream::Config::Rtp::ToString() const {
54 std::stringstream ss;
55 ss << "{ssrc: " << ssrc;
56 ss << ", extensions: [";
57 for (size_t i = 0; i < extensions.size(); ++i) {
58 ss << extensions[i].ToString();
59 if (i != extensions.size() - 1) {
60 ss << ", ";
61 }
62 }
63 ss << ']';
64 ss << ", nack: " << nack.ToString();
65 ss << ", c_name: " << c_name;
66 ss << '}';
67 return ss.str();
68}
69
70AudioSendStream::Config::SendCodecSpec::SendCodecSpec() {
71 webrtc::CodecInst empty_inst = {0};
72 codec_inst = empty_inst;
73 codec_inst.pltype = -1;
74}
75
76std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
77 std::stringstream ss;
78 ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
79 ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
80 ss << ", enable_codec_fec: " << (enable_codec_fec ? "true" : "false");
81 ss << ", enable_opus_dtx: " << (enable_opus_dtx ? "true" : "false");
82 ss << ", opus_max_playback_rate: " << opus_max_playback_rate;
83 ss << ", cng_payload_type: " << cng_payload_type;
84 ss << ", cng_plfreq: " << cng_plfreq;
85 ss << ", codec_inst: " << ::ToString(codec_inst);
86 ss << '}';
87 return ss.str();
88}
89
90bool AudioSendStream::Config::SendCodecSpec::operator==(
91 const AudioSendStream::Config::SendCodecSpec& rhs) const {
92 if (nack_enabled != rhs.nack_enabled) {
93 return false;
94 }
95 if (transport_cc_enabled != rhs.transport_cc_enabled) {
96 return false;
97 }
98 if (enable_codec_fec != rhs.enable_codec_fec) {
99 return false;
100 }
101 if (enable_opus_dtx != rhs.enable_opus_dtx) {
102 return false;
103 }
104 if (opus_max_playback_rate != rhs.opus_max_playback_rate) {
105 return false;
106 }
107 if (cng_payload_type != rhs.cng_payload_type) {
108 return false;
109 }
110 if (cng_plfreq != rhs.cng_plfreq) {
111 return false;
112 }
113 if (codec_inst != rhs.codec_inst) {
114 return false;
115 }
116 return true;
117}
118} // namespace webrtc