| 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_send_stream.h" |
| 12 |
| 13 | #include <utility> |
| 14 |
| 15 | #include "api/crypto/frame_encryptor_interface.h" |
| 16 | #include "rtc_base/strings/string_builder.h" |
| 17 | #include "rtc_base/strings/string_format.h" |
| 18 |
| 19 | namespace webrtc { |
| 20 |
| 21 | namespace { |
| 22 |
| 23 | const char* StreamTypeToString(VideoSendStream::StreamStats::StreamType type) { |
| 24 | switch (type) { |
| 25 | case VideoSendStream::StreamStats::StreamType::kMedia: |
| 26 | return "media"; |
| 27 | case VideoSendStream::StreamStats::StreamType::kRtx: |
| 28 | return "rtx"; |
| 29 | case VideoSendStream::StreamStats::StreamType::kFlexfec: |
| 30 | return "flexfec"; |
| 31 | } |
| 32 | RTC_CHECK_NOTREACHED(); |
| 33 | } |
| 34 |
| 35 | } // namespace |
| 36 |
| 37 | VideoSendStream::StreamStats::StreamStats() = default; |
| 38 | VideoSendStream::StreamStats::~StreamStats() = default; |
| 39 |
| 40 | std::string VideoSendStream::StreamStats::ToString() const { |
| 41 | char buf[1024]; |
| 42 | rtc::SimpleStringBuilder ss(buf); |
| 43 | ss << "type: " << StreamTypeToString(type); |
| 44 | if (referenced_media_ssrc.has_value()) |
| 45 | ss << " (for: " << referenced_media_ssrc.value() << ")"; |
| 46 | ss << ", "; |
| 47 | ss << "width: " << width << ", "; |
| 48 | ss << "height: " << height << ", "; |
| 49 | ss << "key: " << frame_counts.key_frames << ", "; |
| 50 | ss << "delta: " << frame_counts.delta_frames << ", "; |
| 51 | ss << "total_bps: " << total_bitrate_bps << ", "; |
| 52 | ss << "retransmit_bps: " << retransmit_bitrate_bps << ", "; |
| 53 | ss << "avg_delay_ms: " << avg_delay_ms << ", "; |
| 54 | ss << "max_delay_ms: " << max_delay_ms << ", "; |
| 55 | if (report_block_data) { |
| 56 | ss << "cum_loss: " << report_block_data->cumulative_lost() << ", "; |
| 57 | ss << "max_ext_seq: " |
| 58 | << report_block_data->extended_highest_sequence_number() << ", "; |
| 59 | } |
| 60 | ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", "; |
| 61 | ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", "; |
| 62 | ss << "pli: " << rtcp_packet_type_counts.pli_packets; |
| 63 | return ss.str(); |
| 64 | } |
| 65 |
| 66 | VideoSendStream::Stats::Stats() = default; |
| 67 | VideoSendStream::Stats::~Stats() = default; |
| 68 |
| 69 | std::string VideoSendStream::Stats::ToString(int64_t time_ms) const { |
| 70 | char buf[2048]; |
| 71 | rtc::SimpleStringBuilder ss(buf); |
| 72 | ss << "VideoSendStream stats: " << time_ms << ", {"; |
| 73 | ss << "input_fps: " << rtc::StringFormat("%.1f", input_frame_rate) << ", "; |
| 74 | ss << "encode_fps: " << encode_frame_rate << ", "; |
| 75 | ss << "encode_ms: " << avg_encode_time_ms << ", "; |
| 76 | ss << "encode_usage_perc: " << encode_usage_percent << ", "; |
| 77 | ss << "target_bps: " << target_media_bitrate_bps << ", "; |
| 78 | ss << "media_bps: " << media_bitrate_bps << ", "; |
| 79 | ss << "suspended: " << (suspended ? "true" : "false") << ", "; |
| 80 | ss << "bw_adapted_res: " << (bw_limited_resolution ? "true" : "false") |
| 81 | << ", "; |
| 82 | ss << "cpu_adapted_res: " << (cpu_limited_resolution ? "true" : "false") |
| 83 | << ", "; |
| 84 | ss << "bw_adapted_fps: " << (bw_limited_framerate ? "true" : "false") << ", "; |
| 85 | ss << "cpu_adapted_fps: " << (cpu_limited_framerate ? "true" : "false") |
| 86 | << ", "; |
| 87 | ss << "#cpu_adaptations: " << number_of_cpu_adapt_changes << ", "; |
| 88 | ss << "#quality_adaptations: " << number_of_quality_adapt_changes; |
| 89 | ss << '}'; |
| 90 | for (const auto& substream : substreams) { |
| 91 | if (substream.second.type == |
| 92 | VideoSendStream::StreamStats::StreamType::kMedia) { |
| 93 | ss << " {ssrc: " << substream.first << ", "; |
| 94 | ss << substream.second.ToString(); |
| 95 | ss << '}'; |
| 96 | } |
| 97 | } |
| 98 | return ss.str(); |
| 99 | } |
| 100 |
| 101 | VideoSendStream::Config::Config(const Config&) = default; |
| 102 | VideoSendStream::Config::Config(Config&&) = default; |
| 103 | VideoSendStream::Config::Config(Transport* send_transport) |
| 104 | : rtp(), |
| 105 | encoder_settings(VideoEncoder::Capabilities(rtp.lntf.enabled)), |
| 106 | send_transport(send_transport) {} |
| 107 |
| 108 | VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default; |
| 109 | VideoSendStream::Config::Config::~Config() = default; |
| 110 |
| 111 | std::string VideoSendStream::Config::ToString() const { |
| 112 | char buf[2 * 1024]; |
| 113 | rtc::SimpleStringBuilder ss(buf); |
| 114 | ss << "{encoder_settings: { experiment_cpu_load_estimator: " |
| 115 | << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}"; |
| 116 | ss << ", rtp: " << rtp.ToString(); |
| 117 | ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms; |
| 118 | ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr"); |
| 119 | ss << ", render_delay_ms: " << render_delay_ms; |
| 120 | ss << ", target_delay_ms: " << target_delay_ms; |
| 121 | ss << ", suspend_below_min_bitrate: " |
| 122 | << (suspend_below_min_bitrate ? "on" : "off"); |
| 123 | ss << '}'; |
| 124 | return ss.str(); |
| 125 | } |
| 126 |
| 127 | } // namespace webrtc |
| 128 |