aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "call/video_send_stream.h" |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 12 | |
| 13 | namespace webrtc { |
| 14 | |
| 15 | VideoSendStream::StreamStats::StreamStats() = default; |
| 16 | VideoSendStream::StreamStats::~StreamStats() = default; |
| 17 | |
| 18 | std::string VideoSendStream::StreamStats::ToString() const { |
| 19 | std::stringstream ss; |
| 20 | ss << "width: " << width << ", "; |
| 21 | ss << "height: " << height << ", "; |
| 22 | ss << "key: " << frame_counts.key_frames << ", "; |
| 23 | ss << "delta: " << frame_counts.delta_frames << ", "; |
| 24 | ss << "total_bps: " << total_bitrate_bps << ", "; |
| 25 | ss << "retransmit_bps: " << retransmit_bitrate_bps << ", "; |
| 26 | ss << "avg_delay_ms: " << avg_delay_ms << ", "; |
| 27 | ss << "max_delay_ms: " << max_delay_ms << ", "; |
| 28 | ss << "cum_loss: " << rtcp_stats.packets_lost << ", "; |
| 29 | ss << "max_ext_seq: " << rtcp_stats.extended_highest_sequence_number << ", "; |
| 30 | ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", "; |
| 31 | ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", "; |
| 32 | ss << "pli: " << rtcp_packet_type_counts.pli_packets; |
| 33 | return ss.str(); |
| 34 | } |
| 35 | |
| 36 | VideoSendStream::Stats::Stats() = default; |
| 37 | VideoSendStream::Stats::~Stats() = default; |
| 38 | |
| 39 | std::string VideoSendStream::Stats::ToString(int64_t time_ms) const { |
| 40 | std::stringstream ss; |
| 41 | ss << "VideoSendStream stats: " << time_ms << ", {"; |
| 42 | ss << "input_fps: " << input_frame_rate << ", "; |
| 43 | ss << "encode_fps: " << encode_frame_rate << ", "; |
| 44 | ss << "encode_ms: " << avg_encode_time_ms << ", "; |
| 45 | ss << "encode_usage_perc: " << encode_usage_percent << ", "; |
| 46 | ss << "target_bps: " << target_media_bitrate_bps << ", "; |
| 47 | ss << "media_bps: " << media_bitrate_bps << ", "; |
| 48 | ss << "preferred_media_bitrate_bps: " << preferred_media_bitrate_bps << ", "; |
| 49 | ss << "suspended: " << (suspended ? "true" : "false") << ", "; |
| 50 | ss << "bw_adapted: " << (bw_limited_resolution ? "true" : "false"); |
| 51 | ss << '}'; |
| 52 | for (const auto& substream : substreams) { |
| 53 | if (!substream.second.is_rtx && !substream.second.is_flexfec) { |
| 54 | ss << " {ssrc: " << substream.first << ", "; |
| 55 | ss << substream.second.ToString(); |
| 56 | ss << '}'; |
| 57 | } |
| 58 | } |
| 59 | return ss.str(); |
| 60 | } |
| 61 | |
| 62 | VideoSendStream::Config::Config(const Config&) = default; |
| 63 | VideoSendStream::Config::Config(Config&&) = default; |
| 64 | VideoSendStream::Config::Config(Transport* send_transport) |
| 65 | : send_transport(send_transport) {} |
| 66 | |
| 67 | VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default; |
| 68 | VideoSendStream::Config::Config::~Config() = default; |
| 69 | |
| 70 | std::string VideoSendStream::Config::ToString() const { |
| 71 | std::stringstream ss; |
| 72 | ss << "{encoder_settings: " << encoder_settings.ToString(); |
| 73 | ss << ", rtp: " << rtp.ToString(); |
Jiawei Ou | 3587b83 | 2018-01-31 22:08:26 -0800 | [diff] [blame] | 74 | ss << ", rtcp: " << rtcp.ToString(); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 75 | ss << ", pre_encode_callback: " |
| 76 | << (pre_encode_callback ? "(VideoSinkInterface)" : "nullptr"); |
| 77 | ss << ", post_encode_callback: " |
| 78 | << (post_encode_callback ? "(EncodedFrameObserver)" : "nullptr"); |
| 79 | ss << ", render_delay_ms: " << render_delay_ms; |
| 80 | ss << ", target_delay_ms: " << target_delay_ms; |
| 81 | ss << ", suspend_below_min_bitrate: " |
| 82 | << (suspend_below_min_bitrate ? "on" : "off"); |
| 83 | ss << '}'; |
| 84 | return ss.str(); |
| 85 | } |
| 86 | |
| 87 | std::string VideoSendStream::Config::EncoderSettings::ToString() const { |
| 88 | std::stringstream ss; |
Niels Möller | 04dd176 | 2018-03-23 16:05:22 +0100 | [diff] [blame] | 89 | ss << "{encoder: " << (encoder ? "(VideoEncoder)" : "nullptr"); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 90 | ss << '}'; |
| 91 | return ss.str(); |
| 92 | } |
| 93 | |
| 94 | VideoSendStream::Config::Rtp::Rtp() = default; |
| 95 | VideoSendStream::Config::Rtp::Rtp(const Rtp&) = default; |
| 96 | VideoSendStream::Config::Rtp::~Rtp() = default; |
| 97 | |
| 98 | VideoSendStream::Config::Rtp::Flexfec::Flexfec() = default; |
| 99 | VideoSendStream::Config::Rtp::Flexfec::Flexfec(const Flexfec&) = default; |
| 100 | VideoSendStream::Config::Rtp::Flexfec::~Flexfec() = default; |
| 101 | |
| 102 | std::string VideoSendStream::Config::Rtp::ToString() const { |
| 103 | std::stringstream ss; |
| 104 | ss << "{ssrcs: ["; |
| 105 | for (size_t i = 0; i < ssrcs.size(); ++i) { |
| 106 | ss << ssrcs[i]; |
| 107 | if (i != ssrcs.size() - 1) |
| 108 | ss << ", "; |
| 109 | } |
| 110 | ss << ']'; |
| 111 | ss << ", rtcp_mode: " |
| 112 | << (rtcp_mode == RtcpMode::kCompound ? "RtcpMode::kCompound" |
| 113 | : "RtcpMode::kReducedSize"); |
| 114 | ss << ", max_packet_size: " << max_packet_size; |
| 115 | ss << ", extensions: ["; |
| 116 | for (size_t i = 0; i < extensions.size(); ++i) { |
| 117 | ss << extensions[i].ToString(); |
| 118 | if (i != extensions.size() - 1) |
| 119 | ss << ", "; |
| 120 | } |
| 121 | ss << ']'; |
| 122 | |
| 123 | ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}'; |
| 124 | ss << ", ulpfec: " << ulpfec.ToString(); |
Niels Möller | 04dd176 | 2018-03-23 16:05:22 +0100 | [diff] [blame] | 125 | ss << ", payload_name: " << payload_name; |
| 126 | ss << ", payload_type: " << payload_type; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 127 | |
| 128 | ss << ", flexfec: {payload_type: " << flexfec.payload_type; |
| 129 | ss << ", ssrc: " << flexfec.ssrc; |
| 130 | ss << ", protected_media_ssrcs: ["; |
| 131 | for (size_t i = 0; i < flexfec.protected_media_ssrcs.size(); ++i) { |
| 132 | ss << flexfec.protected_media_ssrcs[i]; |
| 133 | if (i != flexfec.protected_media_ssrcs.size() - 1) |
| 134 | ss << ", "; |
| 135 | } |
| 136 | ss << "]}"; |
| 137 | |
| 138 | ss << ", rtx: " << rtx.ToString(); |
| 139 | ss << ", c_name: " << c_name; |
| 140 | ss << '}'; |
| 141 | return ss.str(); |
| 142 | } |
| 143 | |
| 144 | VideoSendStream::Config::Rtp::Rtx::Rtx() = default; |
| 145 | VideoSendStream::Config::Rtp::Rtx::Rtx(const Rtx&) = default; |
| 146 | VideoSendStream::Config::Rtp::Rtx::~Rtx() = default; |
| 147 | |
| 148 | std::string VideoSendStream::Config::Rtp::Rtx::ToString() const { |
| 149 | std::stringstream ss; |
| 150 | ss << "{ssrcs: ["; |
| 151 | for (size_t i = 0; i < ssrcs.size(); ++i) { |
| 152 | ss << ssrcs[i]; |
| 153 | if (i != ssrcs.size() - 1) |
| 154 | ss << ", "; |
| 155 | } |
| 156 | ss << ']'; |
| 157 | |
| 158 | ss << ", payload_type: " << payload_type; |
| 159 | ss << '}'; |
| 160 | return ss.str(); |
| 161 | } |
| 162 | |
Jiawei Ou | 3587b83 | 2018-01-31 22:08:26 -0800 | [diff] [blame] | 163 | VideoSendStream::Config::Rtcp::Rtcp() = default; |
| 164 | VideoSendStream::Config::Rtcp::Rtcp(const Rtcp&) = default; |
| 165 | VideoSendStream::Config::Rtcp::~Rtcp() = default; |
| 166 | |
| 167 | std::string VideoSendStream::Config::Rtcp::ToString() const { |
| 168 | std::stringstream ss; |
| 169 | ss << "{video_report_interval_ms: " << video_report_interval_ms; |
| 170 | ss << ", audio_report_interval_ms: " << audio_report_interval_ms; |
| 171 | ss << '}'; |
| 172 | return ss.str(); |
| 173 | } |
| 174 | |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 175 | } // namespace webrtc |