blob: e8532a7a2669e717e79c49a1fd45020ca07dbced [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"
Byoungchan Leeefe46b62021-11-10 02:23:5617#include "rtc_base/strings/string_format.h"
aleloi440b6d92017-08-22 12:43:2318
19namespace webrtc {
20
Henrik Boströmf45ca372020-03-24 12:30:5021namespace {
22
23const char* StreamTypeToString(VideoSendStream::StreamStats::StreamType type) {
24 switch (type) {
25 case VideoSendStream::StreamStats::StreamType::kMedia:
26 return "media";
27 case VideoSendStream::StreamStats::StreamType::kRtx:
28 return "rtx";
29 case VideoSendStream::StreamStats::StreamType::kFlexfec:
30 return "flexfec";
31 }
Karl Wibergc95b9392020-11-07 23:49:3732 RTC_CHECK_NOTREACHED();
Henrik Boströmf45ca372020-03-24 12:30:5033}
34
35} // namespace
36
aleloi440b6d92017-08-22 12:43:2337VideoSendStream::StreamStats::StreamStats() = default;
38VideoSendStream::StreamStats::~StreamStats() = default;
39
40std::string VideoSendStream::StreamStats::ToString() const {
Jonas Olsson0a713b62018-04-04 13:49:3241 char buf[1024];
42 rtc::SimpleStringBuilder ss(buf);
Henrik Boströmf45ca372020-03-24 12:30:5043 ss << "type: " << StreamTypeToString(type);
44 if (referenced_media_ssrc.has_value())
45 ss << " (for: " << referenced_media_ssrc.value() << ")";
46 ss << ", ";
aleloi440b6d92017-08-22 12:43:2347 ss << "width: " << width << ", ";
48 ss << "height: " << height << ", ";
49 ss << "key: " << frame_counts.key_frames << ", ";
50 ss << "delta: " << frame_counts.delta_frames << ", ";
51 ss << "total_bps: " << total_bitrate_bps << ", ";
52 ss << "retransmit_bps: " << retransmit_bitrate_bps << ", ";
53 ss << "avg_delay_ms: " << avg_delay_ms << ", ";
54 ss << "max_delay_ms: " << max_delay_ms << ", ";
Danil Chapovalovea7474e2021-05-18 10:48:1255 if (report_block_data) {
Danil Chapovalovea33f7f2023-05-04 10:12:3356 ss << "cum_loss: " << report_block_data->cumulative_lost() << ", ";
Danil Chapovalovea7474e2021-05-18 10:48:1257 ss << "max_ext_seq: "
Danil Chapovalovea33f7f2023-05-04 10:12:3358 << report_block_data->extended_highest_sequence_number() << ", ";
Danil Chapovalovea7474e2021-05-18 10:48:1259 }
aleloi440b6d92017-08-22 12:43:2360 ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", ";
61 ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", ";
62 ss << "pli: " << rtcp_packet_type_counts.pli_packets;
63 return ss.str();
64}
65
66VideoSendStream::Stats::Stats() = default;
67VideoSendStream::Stats::~Stats() = default;
68
69std::string VideoSendStream::Stats::ToString(int64_t time_ms) const {
Rasmus Brandtd42a4492019-04-16 14:51:2470 char buf[2048];
Jonas Olsson0a713b62018-04-04 13:49:3271 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 12:43:2372 ss << "VideoSendStream stats: " << time_ms << ", {";
Byoungchan Leeefe46b62021-11-10 02:23:5673 ss << "input_fps: " << rtc::StringFormat("%.1f", input_frame_rate) << ", ";
aleloi440b6d92017-08-22 12:43:2374 ss << "encode_fps: " << encode_frame_rate << ", ";
75 ss << "encode_ms: " << avg_encode_time_ms << ", ";
76 ss << "encode_usage_perc: " << encode_usage_percent << ", ";
77 ss << "target_bps: " << target_media_bitrate_bps << ", ";
78 ss << "media_bps: " << media_bitrate_bps << ", ";
aleloi440b6d92017-08-22 12:43:2379 ss << "suspended: " << (suspended ? "true" : "false") << ", ";
Rasmus Brandtd42a4492019-04-16 14:51:2480 ss << "bw_adapted_res: " << (bw_limited_resolution ? "true" : "false")
81 << ", ";
82 ss << "cpu_adapted_res: " << (cpu_limited_resolution ? "true" : "false")
83 << ", ";
84 ss << "bw_adapted_fps: " << (bw_limited_framerate ? "true" : "false") << ", ";
85 ss << "cpu_adapted_fps: " << (cpu_limited_framerate ? "true" : "false")
86 << ", ";
87 ss << "#cpu_adaptations: " << number_of_cpu_adapt_changes << ", ";
88 ss << "#quality_adaptations: " << number_of_quality_adapt_changes;
aleloi440b6d92017-08-22 12:43:2389 ss << '}';
90 for (const auto& substream : substreams) {
Henrik Boströmf45ca372020-03-24 12:30:5091 if (substream.second.type ==
92 VideoSendStream::StreamStats::StreamType::kMedia) {
aleloi440b6d92017-08-22 12:43:2393 ss << " {ssrc: " << substream.first << ", ";
94 ss << substream.second.ToString();
95 ss << '}';
96 }
97 }
98 return ss.str();
99}
100
101VideoSendStream::Config::Config(const Config&) = default;
102VideoSendStream::Config::Config(Config&&) = default;
Bjorn A Mellem7a9a0922019-11-26 17:19:40103VideoSendStream::Config::Config(Transport* send_transport)
Elad Alon370f93a2019-06-11 12:57:57104 : rtp(),
105 encoder_settings(VideoEncoder::Capabilities(rtp.lntf.enabled)),
Bjorn A Mellem7a9a0922019-11-26 17:19:40106 send_transport(send_transport) {}
aleloi440b6d92017-08-22 12:43:23107
108VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default;
109VideoSendStream::Config::Config::~Config() = default;
110
111std::string VideoSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 13:49:32112 char buf[2 * 1024];
113 rtc::SimpleStringBuilder ss(buf);
Niels Möller213618e2018-07-24 07:29:58114 ss << "{encoder_settings: { experiment_cpu_load_estimator: "
115 << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}";
aleloi440b6d92017-08-22 12:43:23116 ss << ", rtp: " << rtp.ToString();
Jiawei Ou55718122018-11-09 21:17:39117 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
Niels Möller46879152019-01-07 14:54:47118 ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
aleloi440b6d92017-08-22 12:43:23119 ss << ", render_delay_ms: " << render_delay_ms;
120 ss << ", target_delay_ms: " << target_delay_ms;
121 ss << ", suspend_below_min_bitrate: "
122 << (suspend_below_min_bitrate ? "on" : "off");
123 ss << '}';
124 return ss.str();
125}
126
aleloi440b6d92017-08-22 12:43:23127} // namespace webrtc