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