aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "call/video_receive_stream.h" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 12 | |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 13 | #include "rtc_base/strings/string_builder.h" |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
Niels Möller | cb7e1d2 | 2018-09-11 15:56:04 +0200 | [diff] [blame] | 17 | VideoReceiveStream::Decoder::Decoder() : video_format("Unset") {} |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 18 | VideoReceiveStream::Decoder::Decoder(const Decoder&) = default; |
| 19 | VideoReceiveStream::Decoder::~Decoder() = default; |
| 20 | |
| 21 | std::string VideoReceiveStream::Decoder::ToString() const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 22 | char buf[1024]; |
| 23 | rtc::SimpleStringBuilder ss(buf); |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 24 | ss << "{payload_type: " << payload_type; |
| 25 | ss << ", payload_name: " << video_format.name; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 26 | ss << ", codec_params: {"; |
Taylor Brandstetter | 39be828 | 2020-03-05 14:23:21 -0800 | [diff] [blame] | 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 | } |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 34 | ss << '}'; |
| 35 | ss << '}'; |
| 36 | |
| 37 | return ss.str(); |
| 38 | } |
| 39 | |
| 40 | VideoReceiveStream::Stats::Stats() = default; |
| 41 | VideoReceiveStream::Stats::~Stats() = default; |
| 42 | |
| 43 | std::string VideoReceiveStream::Stats::ToString(int64_t time_ms) const { |
Benjamin Wright | 514f084 | 2018-12-10 09:55:17 -0800 | [diff] [blame] | 44 | char buf[2048]; |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 45 | rtc::SimpleStringBuilder ss(buf); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 << ", "; |
Johannes Kron | 0c141c5 | 2019-08-26 15:04:43 +0200 | [diff] [blame] | 52 | ss << "frames_dropped: " << frames_dropped << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 << ", "; |
Benjamin Wright | 514f084 | 2018-12-10 09:55:17 -0800 | [diff] [blame] | 58 | ss << "first_frame_received_to_decoded_ms: " |
| 59 | << first_frame_received_to_decoded_ms << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 60 | ss << "cur_delay_ms: " << current_delay_ms << ", "; |
| 61 | ss << "targ_delay_ms: " << target_delay_ms << ", "; |
| 62 | ss << "jb_delay_ms: " << jitter_buffer_ms << ", "; |
Guido Urdaneta | 6737841 | 2019-05-28 17:38:08 +0200 | [diff] [blame] | 63 | ss << "jb_cumulative_delay_seconds: " << jitter_buffer_delay_seconds << ", "; |
| 64 | ss << "jb_emitted_count: " << jitter_buffer_emitted_count << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 65 | ss << "min_playout_delay_ms: " << min_playout_delay_ms << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 66 | ss << "sync_offset_ms: " << sync_offset_ms << ", "; |
Niels Möller | d77cc24 | 2019-08-22 09:40:25 +0200 | [diff] [blame] | 67 | ss << "cum_loss: " << rtp_stats.packets_lost << ", "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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; |
| 77 | VideoReceiveStream::Config::Config(Transport* rtcp_send_transport) |
Bjorn A Mellem | 7a9a092 | 2019-11-26 09:19:40 -0800 | [diff] [blame] | 78 | : rtcp_send_transport(rtcp_send_transport) {} |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 79 | |
| 80 | VideoReceiveStream::Config& VideoReceiveStream::Config::operator=(Config&&) = |
| 81 | default; |
| 82 | VideoReceiveStream::Config::Config::~Config() = default; |
| 83 | |
| 84 | std::string VideoReceiveStream::Config::ToString() const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 85 | char buf[4 * 1024]; |
| 86 | rtc::SimpleStringBuilder ss(buf); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 | |
| 109 | std::string VideoReceiveStream::Config::Rtp::ToString() const { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 110 | char buf[2 * 1024]; |
| 111 | rtc::SimpleStringBuilder ss(buf); |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 << '}'; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 121 | ss << ", transport_cc: " << (transport_cc ? "on" : "off"); |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 122 | ss << ", lntf: {enabled: " << (lntf.enabled ? "true" : "false") << '}'; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 123 | ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}'; |
nisse | 3b3622f | 2017-09-26 02:49:21 -0700 | [diff] [blame] | 124 | ss << ", ulpfec_payload_type: " << ulpfec_payload_type; |
| 125 | ss << ", red_type: " << red_payload_type; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 126 | ss << ", rtx_ssrc: " << rtx_ssrc; |
| 127 | ss << ", rtx_payload_types: {"; |
nisse | 26e3abb | 2017-08-25 04:44:25 -0700 | [diff] [blame] | 128 | for (auto& kv : rtx_associated_payload_types) { |
| 129 | ss << kv.first << " (pt) -> " << kv.second << " (apt), "; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 130 | } |
| 131 | ss << '}'; |
Mirta Dvornicic | fe68daa | 2019-05-23 13:21:12 +0200 | [diff] [blame] | 132 | ss << ", raw_payload_types: {"; |
| 133 | for (const auto& pt : raw_payload_types) { |
| 134 | ss << pt << ", "; |
| 135 | } |
| 136 | ss << '}'; |
aleloi | 440b6d9 | 2017-08-22 05:43:23 -0700 | [diff] [blame] | 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 |