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" |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 12 | |
| 13 | #include <utility> |
| 14 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 15 | #include "api/crypto/frame_encryptor_interface.h" |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 16 | #include "rtc_base/strings/string_builder.h" |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | VideoSendStream::StreamStats::StreamStats() = default; |
| 21 | VideoSendStream::StreamStats::~StreamStats() = default; |
| 22 | |
| 23 | std::string VideoSendStream::StreamStats::ToString() const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 24 | char buf[1024]; |
| 25 | rtc::SimpleStringBuilder ss(buf); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 26 | ss << "width: " << width << ", "; |
| 27 | ss << "height: " << height << ", "; |
| 28 | ss << "key: " << frame_counts.key_frames << ", "; |
| 29 | ss << "delta: " << frame_counts.delta_frames << ", "; |
| 30 | ss << "total_bps: " << total_bitrate_bps << ", "; |
| 31 | ss << "retransmit_bps: " << retransmit_bitrate_bps << ", "; |
| 32 | ss << "avg_delay_ms: " << avg_delay_ms << ", "; |
| 33 | ss << "max_delay_ms: " << max_delay_ms << ", "; |
| 34 | ss << "cum_loss: " << rtcp_stats.packets_lost << ", "; |
| 35 | ss << "max_ext_seq: " << rtcp_stats.extended_highest_sequence_number << ", "; |
| 36 | ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", "; |
| 37 | ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", "; |
| 38 | ss << "pli: " << rtcp_packet_type_counts.pli_packets; |
| 39 | return ss.str(); |
| 40 | } |
| 41 | |
| 42 | VideoSendStream::Stats::Stats() = default; |
| 43 | VideoSendStream::Stats::~Stats() = default; |
| 44 | |
| 45 | std::string VideoSendStream::Stats::ToString(int64_t time_ms) const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 46 | char buf[1024]; |
| 47 | rtc::SimpleStringBuilder ss(buf); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 48 | ss << "VideoSendStream stats: " << time_ms << ", {"; |
| 49 | ss << "input_fps: " << input_frame_rate << ", "; |
| 50 | ss << "encode_fps: " << encode_frame_rate << ", "; |
| 51 | ss << "encode_ms: " << avg_encode_time_ms << ", "; |
| 52 | ss << "encode_usage_perc: " << encode_usage_percent << ", "; |
| 53 | ss << "target_bps: " << target_media_bitrate_bps << ", "; |
| 54 | ss << "media_bps: " << media_bitrate_bps << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 55 | ss << "suspended: " << (suspended ? "true" : "false") << ", "; |
Rasmus Brandt | 034f191 | 2019-04-16 14:46:49 +0000 | [diff] [blame] | 56 | ss << "bw_adapted: " << (bw_limited_resolution ? "true" : "false"); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 57 | ss << '}'; |
| 58 | for (const auto& substream : substreams) { |
| 59 | if (!substream.second.is_rtx && !substream.second.is_flexfec) { |
| 60 | ss << " {ssrc: " << substream.first << ", "; |
| 61 | ss << substream.second.ToString(); |
| 62 | ss << '}'; |
| 63 | } |
| 64 | } |
| 65 | return ss.str(); |
| 66 | } |
| 67 | |
| 68 | VideoSendStream::Config::Config(const Config&) = default; |
| 69 | VideoSendStream::Config::Config(Config&&) = default; |
Niels Möller | 4687915 | 2019-01-07 15:54:47 +0100 | [diff] [blame] | 70 | VideoSendStream::Config::Config(Transport* send_transport, |
| 71 | MediaTransportInterface* media_transport) |
| 72 | : send_transport(send_transport), media_transport(media_transport) {} |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 73 | VideoSendStream::Config::Config(Transport* send_transport) |
Niels Möller | 4687915 | 2019-01-07 15:54:47 +0100 | [diff] [blame] | 74 | : Config(send_transport, nullptr) {} |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 75 | |
| 76 | VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default; |
| 77 | VideoSendStream::Config::Config::~Config() = default; |
| 78 | |
| 79 | std::string VideoSendStream::Config::ToString() const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 80 | char buf[2 * 1024]; |
| 81 | rtc::SimpleStringBuilder ss(buf); |
Niels Möller | 213618e | 2018-07-24 09:29:58 +0200 | [diff] [blame] | 82 | ss << "{encoder_settings: { experiment_cpu_load_estimator: " |
| 83 | << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}"; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 84 | ss << ", rtp: " << rtp.ToString(); |
Jiawei Ou | 5571812 | 2018-11-09 13:17:39 -0800 | [diff] [blame] | 85 | ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms; |
Niels Möller | 4687915 | 2019-01-07 15:54:47 +0100 | [diff] [blame] | 86 | ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr"); |
| 87 | ss << ", media_transport: " << (media_transport ? "(Transport)" : "nullptr"); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 88 | ss << ", render_delay_ms: " << render_delay_ms; |
| 89 | ss << ", target_delay_ms: " << target_delay_ms; |
| 90 | ss << ", suspend_below_min_bitrate: " |
| 91 | << (suspend_below_min_bitrate ? "on" : "off"); |
| 92 | ss << '}'; |
| 93 | return ss.str(); |
| 94 | } |
| 95 | |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 96 | } // namespace webrtc |