blob: 25513e4e4c0fcee8a0a4bc485c4ebc6507f4ebb4 [file] [log] [blame]
aleloi440b6d92017-08-22 12:43:231/*
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 Bonadei92ea95e2017-09-15 04:47:3111#include "call/video_send_stream.h"
Yves Gerey988cc082018-10-23 10:03:0112
13#include <utility>
14
Steve Anton10542f22019-01-11 17:11:0015#include "api/crypto/frame_encryptor_interface.h"
Jonas Olsson0a713b62018-04-04 13:49:3216#include "rtc_base/strings/string_builder.h"
aleloi440b6d92017-08-22 12:43:2317
18namespace webrtc {
19
Henrik Boströmf45ca372020-03-24 12:30:5020namespace {
21
22const char* StreamTypeToString(VideoSendStream::StreamStats::StreamType type) {
23 switch (type) {
24 case VideoSendStream::StreamStats::StreamType::kMedia:
25 return "media";
26 case VideoSendStream::StreamStats::StreamType::kRtx:
27 return "rtx";
28 case VideoSendStream::StreamStats::StreamType::kFlexfec:
29 return "flexfec";
30 }
Karl Wibergc95b9392020-11-07 23:49:3731 RTC_CHECK_NOTREACHED();
Henrik Boströmf45ca372020-03-24 12:30:5032}
33
34} // namespace
35
aleloi440b6d92017-08-22 12:43:2336VideoSendStream::StreamStats::StreamStats() = default;
37VideoSendStream::StreamStats::~StreamStats() = default;
38
39std::string VideoSendStream::StreamStats::ToString() const {
Jonas Olsson0a713b62018-04-04 13:49:3240 char buf[1024];
41 rtc::SimpleStringBuilder ss(buf);
Henrik Boströmf45ca372020-03-24 12:30:5042 ss << "type: " << StreamTypeToString(type);
43 if (referenced_media_ssrc.has_value())
44 ss << " (for: " << referenced_media_ssrc.value() << ")";
45 ss << ", ";
aleloi440b6d92017-08-22 12:43:2346 ss << "width: " << width << ", ";
47 ss << "height: " << height << ", ";
48 ss << "key: " << frame_counts.key_frames << ", ";
49 ss << "delta: " << frame_counts.delta_frames << ", ";
50 ss << "total_bps: " << total_bitrate_bps << ", ";
51 ss << "retransmit_bps: " << retransmit_bitrate_bps << ", ";
52 ss << "avg_delay_ms: " << avg_delay_ms << ", ";
53 ss << "max_delay_ms: " << max_delay_ms << ", ";
Danil Chapovalovea7474e2021-05-18 10:48:1254 if (report_block_data) {
55 ss << "cum_loss: " << report_block_data->report_block().packets_lost
56 << ", ";
57 ss << "max_ext_seq: "
58 << report_block_data->report_block().extended_highest_sequence_number
59 << ", ";
60 }
aleloi440b6d92017-08-22 12:43:2361 ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", ";
62 ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", ";
63 ss << "pli: " << rtcp_packet_type_counts.pli_packets;
64 return ss.str();
65}
66
67VideoSendStream::Stats::Stats() = default;
68VideoSendStream::Stats::~Stats() = default;
69
70std::string VideoSendStream::Stats::ToString(int64_t time_ms) const {
Rasmus Brandtd42a4492019-04-16 14:51:2471 char buf[2048];
Jonas Olsson0a713b62018-04-04 13:49:3272 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 12:43:2373 ss << "VideoSendStream stats: " << time_ms << ", {";
74 ss << "input_fps: " << input_frame_rate << ", ";
75 ss << "encode_fps: " << encode_frame_rate << ", ";
76 ss << "encode_ms: " << avg_encode_time_ms << ", ";
77 ss << "encode_usage_perc: " << encode_usage_percent << ", ";
78 ss << "target_bps: " << target_media_bitrate_bps << ", ";
79 ss << "media_bps: " << media_bitrate_bps << ", ";
aleloi440b6d92017-08-22 12:43:2380 ss << "suspended: " << (suspended ? "true" : "false") << ", ";
Rasmus Brandtd42a4492019-04-16 14:51:2481 ss << "bw_adapted_res: " << (bw_limited_resolution ? "true" : "false")
82 << ", ";
83 ss << "cpu_adapted_res: " << (cpu_limited_resolution ? "true" : "false")
84 << ", ";
85 ss << "bw_adapted_fps: " << (bw_limited_framerate ? "true" : "false") << ", ";
86 ss << "cpu_adapted_fps: " << (cpu_limited_framerate ? "true" : "false")
87 << ", ";
88 ss << "#cpu_adaptations: " << number_of_cpu_adapt_changes << ", ";
89 ss << "#quality_adaptations: " << number_of_quality_adapt_changes;
aleloi440b6d92017-08-22 12:43:2390 ss << '}';
91 for (const auto& substream : substreams) {
Henrik Boströmf45ca372020-03-24 12:30:5092 if (substream.second.type ==
93 VideoSendStream::StreamStats::StreamType::kMedia) {
aleloi440b6d92017-08-22 12:43:2394 ss << " {ssrc: " << substream.first << ", ";
95 ss << substream.second.ToString();
96 ss << '}';
97 }
98 }
99 return ss.str();
100}
101
102VideoSendStream::Config::Config(const Config&) = default;
103VideoSendStream::Config::Config(Config&&) = default;
Bjorn A Mellem7a9a0922019-11-26 17:19:40104VideoSendStream::Config::Config(Transport* send_transport)
Elad Alon370f93a2019-06-11 12:57:57105 : rtp(),
106 encoder_settings(VideoEncoder::Capabilities(rtp.lntf.enabled)),
Bjorn A Mellem7a9a0922019-11-26 17:19:40107 send_transport(send_transport) {}
aleloi440b6d92017-08-22 12:43:23108
109VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default;
110VideoSendStream::Config::Config::~Config() = default;
111
112std::string VideoSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 13:49:32113 char buf[2 * 1024];
114 rtc::SimpleStringBuilder ss(buf);
Niels Möller213618e2018-07-24 07:29:58115 ss << "{encoder_settings: { experiment_cpu_load_estimator: "
116 << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}";
aleloi440b6d92017-08-22 12:43:23117 ss << ", rtp: " << rtp.ToString();
Jiawei Ou55718122018-11-09 21:17:39118 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
Niels Möller46879152019-01-07 14:54:47119 ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
aleloi440b6d92017-08-22 12:43:23120 ss << ", render_delay_ms: " << render_delay_ms;
121 ss << ", target_delay_ms: " << target_delay_ms;
122 ss << ", suspend_below_min_bitrate: "
123 << (suspend_below_min_bitrate ? "on" : "off");
124 ss << '}';
125 return ss.str();
126}
127
aleloi440b6d92017-08-22 12:43:23128} // namespace webrtc