blob: dac4029876688c2c7f756efc8f6b9540b4c995b7 [file] [log] [blame]
aleloi440b6d92017-08-22 05:43:23 -07001/*
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 06:47:31 +020011#include "call/video_send_stream.h"
Yves Gerey988cc082018-10-23 12:03:01 +020012
13#include <utility>
14
Steve Anton10542f22019-01-11 09:11:00 -080015#include "api/crypto/frame_encryptor_interface.h"
Jonas Olsson0a713b62018-04-04 15:49:32 +020016#include "rtc_base/strings/string_builder.h"
aleloi440b6d92017-08-22 05:43:23 -070017
18namespace webrtc {
19
20VideoSendStream::StreamStats::StreamStats() = default;
21VideoSendStream::StreamStats::~StreamStats() = default;
22
23std::string VideoSendStream::StreamStats::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020024 char buf[1024];
25 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 05:43:23 -070026 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
42VideoSendStream::Stats::Stats() = default;
43VideoSendStream::Stats::~Stats() = default;
44
45std::string VideoSendStream::Stats::ToString(int64_t time_ms) const {
Rasmus Brandtd42a4492019-04-16 16:51:24 +020046 char buf[2048];
Jonas Olsson0a713b62018-04-04 15:49:32 +020047 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 05:43:23 -070048 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 << ", ";
aleloi440b6d92017-08-22 05:43:23 -070055 ss << "suspended: " << (suspended ? "true" : "false") << ", ";
Rasmus Brandtd42a4492019-04-16 16:51:24 +020056 ss << "bw_adapted_res: " << (bw_limited_resolution ? "true" : "false")
57 << ", ";
58 ss << "cpu_adapted_res: " << (cpu_limited_resolution ? "true" : "false")
59 << ", ";
60 ss << "bw_adapted_fps: " << (bw_limited_framerate ? "true" : "false") << ", ";
61 ss << "cpu_adapted_fps: " << (cpu_limited_framerate ? "true" : "false")
62 << ", ";
63 ss << "#cpu_adaptations: " << number_of_cpu_adapt_changes << ", ";
64 ss << "#quality_adaptations: " << number_of_quality_adapt_changes;
aleloi440b6d92017-08-22 05:43:23 -070065 ss << '}';
66 for (const auto& substream : substreams) {
67 if (!substream.second.is_rtx && !substream.second.is_flexfec) {
68 ss << " {ssrc: " << substream.first << ", ";
69 ss << substream.second.ToString();
70 ss << '}';
71 }
72 }
73 return ss.str();
74}
75
76VideoSendStream::Config::Config(const Config&) = default;
77VideoSendStream::Config::Config(Config&&) = default;
Niels Möller46879152019-01-07 15:54:47 +010078VideoSendStream::Config::Config(Transport* send_transport,
79 MediaTransportInterface* media_transport)
Elad Alon370f93a2019-06-11 14:57:57 +020080 : rtp(),
81 encoder_settings(VideoEncoder::Capabilities(rtp.lntf.enabled)),
82 send_transport(send_transport),
83 media_transport(media_transport) {}
aleloi440b6d92017-08-22 05:43:23 -070084VideoSendStream::Config::Config(Transport* send_transport)
Niels Möller46879152019-01-07 15:54:47 +010085 : Config(send_transport, nullptr) {}
aleloi440b6d92017-08-22 05:43:23 -070086
87VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default;
88VideoSendStream::Config::Config::~Config() = default;
89
90std::string VideoSendStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020091 char buf[2 * 1024];
92 rtc::SimpleStringBuilder ss(buf);
Niels Möller213618e2018-07-24 09:29:58 +020093 ss << "{encoder_settings: { experiment_cpu_load_estimator: "
94 << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}";
aleloi440b6d92017-08-22 05:43:23 -070095 ss << ", rtp: " << rtp.ToString();
Jiawei Ou55718122018-11-09 13:17:39 -080096 ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
Niels Möller46879152019-01-07 15:54:47 +010097 ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
98 ss << ", media_transport: " << (media_transport ? "(Transport)" : "nullptr");
aleloi440b6d92017-08-22 05:43:23 -070099 ss << ", render_delay_ms: " << render_delay_ms;
100 ss << ", target_delay_ms: " << target_delay_ms;
101 ss << ", suspend_below_min_bitrate: "
102 << (suspend_below_min_bitrate ? "on" : "off");
103 ss << '}';
104 return ss.str();
105}
106
aleloi440b6d92017-08-22 05:43:23 -0700107} // namespace webrtc