blob: cb857b1371fcd2ab8b5b1c5f3264e21cb7c80bac [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"
aleloi440b6d92017-08-22 05:43:23 -070012
13namespace webrtc {
14
15VideoSendStream::StreamStats::StreamStats() = default;
16VideoSendStream::StreamStats::~StreamStats() = default;
17
18std::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
36VideoSendStream::Stats::Stats() = default;
37VideoSendStream::Stats::~Stats() = default;
38
39std::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
62VideoSendStream::Config::Config(const Config&) = default;
63VideoSendStream::Config::Config(Config&&) = default;
64VideoSendStream::Config::Config(Transport* send_transport)
65 : send_transport(send_transport) {}
66
67VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default;
68VideoSendStream::Config::Config::~Config() = default;
69
70std::string VideoSendStream::Config::ToString() const {
71 std::stringstream ss;
72 ss << "{encoder_settings: " << encoder_settings.ToString();
73 ss << ", rtp: " << rtp.ToString();
Jiawei Ou3587b832018-01-31 22:08:26 -080074 ss << ", rtcp: " << rtcp.ToString();
aleloi440b6d92017-08-22 05:43:23 -070075 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
87std::string VideoSendStream::Config::EncoderSettings::ToString() const {
88 std::stringstream ss;
Niels Möller04dd1762018-03-23 16:05:22 +010089 ss << "{encoder: " << (encoder ? "(VideoEncoder)" : "nullptr");
aleloi440b6d92017-08-22 05:43:23 -070090 ss << '}';
91 return ss.str();
92}
93
94VideoSendStream::Config::Rtp::Rtp() = default;
95VideoSendStream::Config::Rtp::Rtp(const Rtp&) = default;
96VideoSendStream::Config::Rtp::~Rtp() = default;
97
98VideoSendStream::Config::Rtp::Flexfec::Flexfec() = default;
99VideoSendStream::Config::Rtp::Flexfec::Flexfec(const Flexfec&) = default;
100VideoSendStream::Config::Rtp::Flexfec::~Flexfec() = default;
101
102std::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öller04dd1762018-03-23 16:05:22 +0100125 ss << ", payload_name: " << payload_name;
126 ss << ", payload_type: " << payload_type;
aleloi440b6d92017-08-22 05:43:23 -0700127
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
144VideoSendStream::Config::Rtp::Rtx::Rtx() = default;
145VideoSendStream::Config::Rtp::Rtx::Rtx(const Rtx&) = default;
146VideoSendStream::Config::Rtp::Rtx::~Rtx() = default;
147
148std::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 Ou3587b832018-01-31 22:08:26 -0800163VideoSendStream::Config::Rtcp::Rtcp() = default;
164VideoSendStream::Config::Rtcp::Rtcp(const Rtcp&) = default;
165VideoSendStream::Config::Rtcp::~Rtcp() = default;
166
167std::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
aleloi440b6d92017-08-22 05:43:23 -0700175} // namespace webrtc