1 /*
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
11 #include "call/video_receive_stream.h"
12
13 #include "rtc_base/strings/string_builder.h"
14
15 namespace webrtc {
16
Decoder()17 VideoReceiveStream::Decoder::Decoder() : video_format("Unset") {}
18 VideoReceiveStream::Decoder::Decoder(const Decoder&) = default;
19 VideoReceiveStream::Decoder::~Decoder() = default;
20
ToString() const21 std::string VideoReceiveStream::Decoder::ToString() const {
22 char buf[1024];
23 rtc::SimpleStringBuilder ss(buf);
24 ss << "{payload_type: " << payload_type;
25 ss << ", payload_name: " << video_format.name;
26 ss << ", codec_params: {";
27 for (auto it = video_format.parameters.begin();
28 it != video_format.parameters.end(); ++it) {
29 if (it != video_format.parameters.begin()) {
30 ss << ", ";
31 }
32 ss << it->first << ": " << it->second;
33 }
34 ss << '}';
35 ss << '}';
36
37 return ss.str();
38 }
39
40 VideoReceiveStream::Stats::Stats() = default;
41 VideoReceiveStream::Stats::~Stats() = default;
42
ToString(int64_t time_ms) const43 std::string VideoReceiveStream::Stats::ToString(int64_t time_ms) const {
44 char buf[2048];
45 rtc::SimpleStringBuilder ss(buf);
46 ss << "VideoReceiveStream stats: " << time_ms << ", {ssrc: " << ssrc << ", ";
47 ss << "total_bps: " << total_bitrate_bps << ", ";
48 ss << "width: " << width << ", ";
49 ss << "height: " << height << ", ";
50 ss << "key: " << frame_counts.key_frames << ", ";
51 ss << "delta: " << frame_counts.delta_frames << ", ";
52 ss << "frames_dropped: " << frames_dropped << ", ";
53 ss << "network_fps: " << network_frame_rate << ", ";
54 ss << "decode_fps: " << decode_frame_rate << ", ";
55 ss << "render_fps: " << render_frame_rate << ", ";
56 ss << "decode_ms: " << decode_ms << ", ";
57 ss << "max_decode_ms: " << max_decode_ms << ", ";
58 ss << "first_frame_received_to_decoded_ms: "
59 << first_frame_received_to_decoded_ms << ", ";
60 ss << "cur_delay_ms: " << current_delay_ms << ", ";
61 ss << "targ_delay_ms: " << target_delay_ms << ", ";
62 ss << "jb_delay_ms: " << jitter_buffer_ms << ", ";
63 ss << "jb_cumulative_delay_seconds: " << jitter_buffer_delay_seconds << ", ";
64 ss << "jb_emitted_count: " << jitter_buffer_emitted_count << ", ";
65 ss << "min_playout_delay_ms: " << min_playout_delay_ms << ", ";
66 ss << "sync_offset_ms: " << sync_offset_ms << ", ";
67 ss << "cum_loss: " << rtp_stats.packets_lost << ", ";
68 ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", ";
69 ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", ";
70 ss << "pli: " << rtcp_packet_type_counts.pli_packets;
71 ss << '}';
72 return ss.str();
73 }
74
75 VideoReceiveStream::Config::Config(const Config&) = default;
76 VideoReceiveStream::Config::Config(Config&&) = default;
Config(Transport * rtcp_send_transport)77 VideoReceiveStream::Config::Config(Transport* rtcp_send_transport)
78 : rtcp_send_transport(rtcp_send_transport) {}
79
80 VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) =
81 default;
82 VideoReceiveStream::Config::Config::~Config() = default;
83
ToString() const84 std::string VideoReceiveStream::Config::ToString() const {
85 char buf[4 * 1024];
86 rtc::SimpleStringBuilder ss(buf);
87 ss << "{decoders: [";
88 for (size_t i = 0; i < decoders.size(); ++i) {
89 ss << decoders[i].ToString();
90 if (i != decoders.size() - 1)
91 ss << ", ";
92 }
93 ss << ']';
94 ss << ", rtp: " << rtp.ToString();
95 ss << ", renderer: " << (renderer ? "(renderer)" : "nullptr");
96 ss << ", render_delay_ms: " << render_delay_ms;
97 if (!sync_group.empty())
98 ss << ", sync_group: " << sync_group;
99 ss << ", target_delay_ms: " << target_delay_ms;
100 ss << '}';
101
102 return ss.str();
103 }
104
105 VideoReceiveStream::Config::Rtp::Rtp() = default;
106 VideoReceiveStream::Config::Rtp::Rtp(const Rtp&) = default;
107 VideoReceiveStream::Config::Rtp::~Rtp() = default;
108
ToString() const109 std::string VideoReceiveStream::Config::Rtp::ToString() const {
110 char buf[2 * 1024];
111 rtc::SimpleStringBuilder ss(buf);
112 ss << "{remote_ssrc: " << remote_ssrc;
113 ss << ", local_ssrc: " << local_ssrc;
114 ss << ", rtcp_mode: "
115 << (rtcp_mode == RtcpMode::kCompound ? "RtcpMode::kCompound"
116 : "RtcpMode::kReducedSize");
117 ss << ", rtcp_xr: ";
118 ss << "{receiver_reference_time_report: "
119 << (rtcp_xr.receiver_reference_time_report ? "on" : "off");
120 ss << '}';
121 ss << ", transport_cc: " << (transport_cc ? "on" : "off");
122 ss << ", lntf: {enabled: " << (lntf.enabled ? "true" : "false") << '}';
123 ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}';
124 ss << ", ulpfec_payload_type: " << ulpfec_payload_type;
125 ss << ", red_type: " << red_payload_type;
126 ss << ", rtx_ssrc: " << rtx_ssrc;
127 ss << ", rtx_payload_types: {";
128 for (auto& kv : rtx_associated_payload_types) {
129 ss << kv.first << " (pt) -> " << kv.second << " (apt), ";
130 }
131 ss << '}';
132 ss << ", raw_payload_types: {";
133 for (const auto& pt : raw_payload_types) {
134 ss << pt << ", ";
135 }
136 ss << '}';
137 ss << ", extensions: [";
138 for (size_t i = 0; i < extensions.size(); ++i) {
139 ss << extensions[i].ToString();
140 if (i != extensions.size() - 1)
141 ss << ", ";
142 }
143 ss << ']';
144 ss << '}';
145 return ss.str();
146 }
147
148 } // namespace webrtc
149