solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | namespace { |
| 16 | |
| 17 | std::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 | |
| 30 | namespace webrtc { |
| 31 | |
| 32 | AudioSendStream::Stats::Stats() = default; |
| 33 | |
| 34 | AudioSendStream::Config::Config(Transport* send_transport) |
| 35 | : send_transport(send_transport) {} |
| 36 | |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame^] | 37 | AudioSendStream::Config::~Config() = default; |
| 38 | |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 39 | std::string AudioSendStream::Config::ToString() const { |
| 40 | std::stringstream ss; |
| 41 | ss << "{rtp: " << rtp.ToString(); |
| 42 | ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr"); |
| 43 | ss << ", voe_channel_id: " << voe_channel_id; |
| 44 | ss << ", min_bitrate_kbps: " << min_bitrate_kbps; |
| 45 | ss << ", max_bitrate_kbps: " << max_bitrate_kbps; |
| 46 | ss << ", send_codec_spec: " << send_codec_spec.ToString(); |
| 47 | ss << '}'; |
| 48 | return ss.str(); |
| 49 | } |
| 50 | |
| 51 | AudioSendStream::Config::Rtp::Rtp() = default; |
| 52 | |
| 53 | AudioSendStream::Config::Rtp::~Rtp() = default; |
| 54 | |
| 55 | std::string AudioSendStream::Config::Rtp::ToString() const { |
| 56 | std::stringstream ss; |
| 57 | ss << "{ssrc: " << ssrc; |
| 58 | ss << ", extensions: ["; |
| 59 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 60 | ss << extensions[i].ToString(); |
| 61 | if (i != extensions.size() - 1) { |
| 62 | ss << ", "; |
| 63 | } |
| 64 | } |
| 65 | ss << ']'; |
| 66 | ss << ", nack: " << nack.ToString(); |
| 67 | ss << ", c_name: " << c_name; |
| 68 | ss << '}'; |
| 69 | return ss.str(); |
| 70 | } |
| 71 | |
| 72 | AudioSendStream::Config::SendCodecSpec::SendCodecSpec() { |
| 73 | webrtc::CodecInst empty_inst = {0}; |
| 74 | codec_inst = empty_inst; |
| 75 | codec_inst.pltype = -1; |
| 76 | } |
| 77 | |
| 78 | std::string AudioSendStream::Config::SendCodecSpec::ToString() const { |
| 79 | std::stringstream ss; |
| 80 | ss << "{nack_enabled: " << (nack_enabled ? "true" : "false"); |
| 81 | ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false"); |
| 82 | ss << ", enable_codec_fec: " << (enable_codec_fec ? "true" : "false"); |
| 83 | ss << ", enable_opus_dtx: " << (enable_opus_dtx ? "true" : "false"); |
| 84 | ss << ", opus_max_playback_rate: " << opus_max_playback_rate; |
| 85 | ss << ", cng_payload_type: " << cng_payload_type; |
| 86 | ss << ", cng_plfreq: " << cng_plfreq; |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame^] | 87 | ss << ", min_ptime: " << min_ptime_ms; |
| 88 | ss << ", max_ptime: " << max_ptime_ms; |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 89 | ss << ", codec_inst: " << ::ToString(codec_inst); |
| 90 | ss << '}'; |
| 91 | return ss.str(); |
| 92 | } |
| 93 | |
| 94 | bool AudioSendStream::Config::SendCodecSpec::operator==( |
| 95 | const AudioSendStream::Config::SendCodecSpec& rhs) const { |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame^] | 96 | if (nack_enabled == rhs.nack_enabled && |
| 97 | transport_cc_enabled == rhs.transport_cc_enabled && |
| 98 | enable_codec_fec == rhs.enable_codec_fec && |
| 99 | enable_opus_dtx == rhs.enable_opus_dtx && |
| 100 | opus_max_playback_rate == rhs.opus_max_playback_rate && |
| 101 | cng_payload_type == rhs.cng_payload_type && |
| 102 | cng_plfreq == rhs.cng_plfreq && max_ptime_ms == rhs.max_ptime_ms && |
| 103 | min_ptime_ms == rhs.min_ptime_ms && codec_inst == rhs.codec_inst) { |
| 104 | return true; |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 105 | } |
minyue | 6b825df | 2016-10-31 04:08:32 -0700 | [diff] [blame^] | 106 | return false; |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 107 | } |
| 108 | } // namespace webrtc |