blob: b0156fc17eba803a525c0899ae02d5a2ccd57393 [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_receive_stream.h"
Jonas Olsson0a713b62018-04-04 15:49:32 +020012#include "rtc_base/strings/string_builder.h"
aleloi440b6d92017-08-22 05:43:23 -070013
14namespace webrtc {
15
Niels Möllercb7e1d22018-09-11 15:56:04 +020016VideoReceiveStream::Decoder::Decoder() : video_format("Unset") {}
aleloi440b6d92017-08-22 05:43:23 -070017VideoReceiveStream::Decoder::Decoder(const Decoder&) = default;
18VideoReceiveStream::Decoder::~Decoder() = default;
19
20std::string VideoReceiveStream::Decoder::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020021 char buf[1024];
22 rtc::SimpleStringBuilder ss(buf);
Niels Möllercbcbc222018-09-28 09:07:24 +020023 ss << "{payload_type: " << payload_type;
24 ss << ", payload_name: " << video_format.name;
aleloi440b6d92017-08-22 05:43:23 -070025 ss << ", codec_params: {";
Niels Möllercb7e1d22018-09-11 15:56:04 +020026 for (const auto& it : video_format.parameters)
aleloi440b6d92017-08-22 05:43:23 -070027 ss << it.first << ": " << it.second;
28 ss << '}';
29 ss << '}';
30
31 return ss.str();
32}
33
34VideoReceiveStream::Stats::Stats() = default;
35VideoReceiveStream::Stats::~Stats() = default;
36
37std::string VideoReceiveStream::Stats::ToString(int64_t time_ms) const {
Benjamin Wright514f0842018-12-10 09:55:17 -080038 char buf[2048];
Jonas Olsson0a713b62018-04-04 15:49:32 +020039 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 05:43:23 -070040 ss << "VideoReceiveStream stats: " << time_ms << ", {ssrc: " << ssrc << ", ";
41 ss << "total_bps: " << total_bitrate_bps << ", ";
42 ss << "width: " << width << ", ";
43 ss << "height: " << height << ", ";
44 ss << "key: " << frame_counts.key_frames << ", ";
45 ss << "delta: " << frame_counts.delta_frames << ", ";
46 ss << "network_fps: " << network_frame_rate << ", ";
47 ss << "decode_fps: " << decode_frame_rate << ", ";
48 ss << "render_fps: " << render_frame_rate << ", ";
49 ss << "decode_ms: " << decode_ms << ", ";
50 ss << "max_decode_ms: " << max_decode_ms << ", ";
Benjamin Wright514f0842018-12-10 09:55:17 -080051 ss << "first_frame_received_to_decoded_ms: "
52 << first_frame_received_to_decoded_ms << ", ";
aleloi440b6d92017-08-22 05:43:23 -070053 ss << "cur_delay_ms: " << current_delay_ms << ", ";
54 ss << "targ_delay_ms: " << target_delay_ms << ", ";
55 ss << "jb_delay_ms: " << jitter_buffer_ms << ", ";
56 ss << "min_playout_delay_ms: " << min_playout_delay_ms << ", ";
57 ss << "discarded: " << discarded_packets << ", ";
58 ss << "sync_offset_ms: " << sync_offset_ms << ", ";
59 ss << "cum_loss: " << rtcp_stats.packets_lost << ", ";
60 ss << "max_ext_seq: " << rtcp_stats.extended_highest_sequence_number << ", ";
61 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 ss << '}';
65 return ss.str();
66}
67
68VideoReceiveStream::Config::Config(const Config&) = default;
69VideoReceiveStream::Config::Config(Config&&) = default;
Niels Möller46879152019-01-07 15:54:47 +010070VideoReceiveStream::Config::Config(Transport* rtcp_send_transport,
71 MediaTransportInterface* media_transport)
72 : rtcp_send_transport(rtcp_send_transport),
73 media_transport(media_transport) {}
aleloi440b6d92017-08-22 05:43:23 -070074VideoReceiveStream::Config::Config(Transport* rtcp_send_transport)
Niels Möller46879152019-01-07 15:54:47 +010075 : Config(rtcp_send_transport, nullptr) {}
aleloi440b6d92017-08-22 05:43:23 -070076
77VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) =
78 default;
79VideoReceiveStream::Config::Config::~Config() = default;
80
81std::string VideoReceiveStream::Config::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +020082 char buf[4 * 1024];
83 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 05:43:23 -070084 ss << "{decoders: [";
85 for (size_t i = 0; i < decoders.size(); ++i) {
86 ss << decoders[i].ToString();
87 if (i != decoders.size() - 1)
88 ss << ", ";
89 }
90 ss << ']';
91 ss << ", rtp: " << rtp.ToString();
92 ss << ", renderer: " << (renderer ? "(renderer)" : "nullptr");
93 ss << ", render_delay_ms: " << render_delay_ms;
94 if (!sync_group.empty())
95 ss << ", sync_group: " << sync_group;
aleloi440b6d92017-08-22 05:43:23 -070096 ss << ", target_delay_ms: " << target_delay_ms;
97 ss << '}';
98
99 return ss.str();
100}
101
102VideoReceiveStream::Config::Rtp::Rtp() = default;
103VideoReceiveStream::Config::Rtp::Rtp(const Rtp&) = default;
104VideoReceiveStream::Config::Rtp::~Rtp() = default;
105
106std::string VideoReceiveStream::Config::Rtp::ToString() const {
Jonas Olsson0a713b62018-04-04 15:49:32 +0200107 char buf[2 * 1024];
108 rtc::SimpleStringBuilder ss(buf);
aleloi440b6d92017-08-22 05:43:23 -0700109 ss << "{remote_ssrc: " << remote_ssrc;
110 ss << ", local_ssrc: " << local_ssrc;
111 ss << ", rtcp_mode: "
112 << (rtcp_mode == RtcpMode::kCompound ? "RtcpMode::kCompound"
113 : "RtcpMode::kReducedSize");
114 ss << ", rtcp_xr: ";
115 ss << "{receiver_reference_time_report: "
116 << (rtcp_xr.receiver_reference_time_report ? "on" : "off");
117 ss << '}';
118 ss << ", remb: " << (remb ? "on" : "off");
119 ss << ", transport_cc: " << (transport_cc ? "on" : "off");
120 ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}';
nisse3b3622f2017-09-26 02:49:21 -0700121 ss << ", ulpfec_payload_type: " << ulpfec_payload_type;
122 ss << ", red_type: " << red_payload_type;
aleloi440b6d92017-08-22 05:43:23 -0700123 ss << ", rtx_ssrc: " << rtx_ssrc;
124 ss << ", rtx_payload_types: {";
nisse26e3abb2017-08-25 04:44:25 -0700125 for (auto& kv : rtx_associated_payload_types) {
126 ss << kv.first << " (pt) -> " << kv.second << " (apt), ";
aleloi440b6d92017-08-22 05:43:23 -0700127 }
128 ss << '}';
129 ss << ", extensions: [";
130 for (size_t i = 0; i < extensions.size(); ++i) {
131 ss << extensions[i].ToString();
132 if (i != extensions.size() - 1)
133 ss << ", ";
134 }
135 ss << ']';
136 ss << '}';
137 return ss.str();
138}
139
140} // namespace webrtc