You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
4.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #include "call/video_send_stream.h"
  11. #include <utility>
  12. #include "api/crypto/frame_encryptor_interface.h"
  13. #include "rtc_base/strings/string_builder.h"
  14. namespace webrtc {
  15. VideoSendStream::StreamStats::StreamStats() = default;
  16. VideoSendStream::StreamStats::~StreamStats() = default;
  17. std::string VideoSendStream::StreamStats::ToString() const {
  18. char buf[1024];
  19. rtc::SimpleStringBuilder ss(buf);
  20. ss << "width: " << width << ", ";
  21. ss << "height: " << height << ", ";
  22. ss << "key: " << frame_counts.key_frames << ", ";
  23. ss << "delta: " << frame_counts.delta_frames << ", ";
  24. ss << "total_bps: " << total_bitrate_bps << ", ";
  25. ss << "retransmit_bps: " << retransmit_bitrate_bps << ", ";
  26. ss << "avg_delay_ms: " << avg_delay_ms << ", ";
  27. ss << "max_delay_ms: " << max_delay_ms << ", ";
  28. ss << "cum_loss: " << rtcp_stats.packets_lost << ", ";
  29. ss << "max_ext_seq: " << rtcp_stats.extended_highest_sequence_number << ", ";
  30. ss << "nack: " << rtcp_packet_type_counts.nack_packets << ", ";
  31. ss << "fir: " << rtcp_packet_type_counts.fir_packets << ", ";
  32. ss << "pli: " << rtcp_packet_type_counts.pli_packets;
  33. return ss.str();
  34. }
  35. VideoSendStream::Stats::Stats() = default;
  36. VideoSendStream::Stats::~Stats() = default;
  37. std::string VideoSendStream::Stats::ToString(int64_t time_ms) const {
  38. char buf[2048];
  39. rtc::SimpleStringBuilder ss(buf);
  40. ss << "VideoSendStream stats: " << time_ms << ", {";
  41. ss << "input_fps: " << input_frame_rate << ", ";
  42. ss << "encode_fps: " << encode_frame_rate << ", ";
  43. ss << "encode_ms: " << avg_encode_time_ms << ", ";
  44. ss << "encode_usage_perc: " << encode_usage_percent << ", ";
  45. ss << "target_bps: " << target_media_bitrate_bps << ", ";
  46. ss << "media_bps: " << media_bitrate_bps << ", ";
  47. ss << "suspended: " << (suspended ? "true" : "false") << ", ";
  48. ss << "bw_adapted_res: " << (bw_limited_resolution ? "true" : "false")
  49. << ", ";
  50. ss << "cpu_adapted_res: " << (cpu_limited_resolution ? "true" : "false")
  51. << ", ";
  52. ss << "bw_adapted_fps: " << (bw_limited_framerate ? "true" : "false") << ", ";
  53. ss << "cpu_adapted_fps: " << (cpu_limited_framerate ? "true" : "false")
  54. << ", ";
  55. ss << "#cpu_adaptations: " << number_of_cpu_adapt_changes << ", ";
  56. ss << "#quality_adaptations: " << number_of_quality_adapt_changes;
  57. ss << '}';
  58. for (const auto& substream : substreams) {
  59. if (!substream.second.is_rtx && !substream.second.is_flexfec) {
  60. ss << " {ssrc: " << substream.first << ", ";
  61. ss << substream.second.ToString();
  62. ss << '}';
  63. }
  64. }
  65. return ss.str();
  66. }
  67. VideoSendStream::Config::Config(const Config&) = default;
  68. VideoSendStream::Config::Config(Config&&) = default;
  69. VideoSendStream::Config::Config(Transport* send_transport,
  70. MediaTransportInterface* media_transport)
  71. : rtp(),
  72. encoder_settings(VideoEncoder::Capabilities(rtp.lntf.enabled)),
  73. send_transport(send_transport),
  74. media_transport(media_transport) {}
  75. VideoSendStream::Config::Config(Transport* send_transport)
  76. : Config(send_transport, nullptr) {}
  77. VideoSendStream::Config& VideoSendStream::Config::operator=(Config&&) = default;
  78. VideoSendStream::Config::Config::~Config() = default;
  79. std::string VideoSendStream::Config::ToString() const {
  80. char buf[2 * 1024];
  81. rtc::SimpleStringBuilder ss(buf);
  82. ss << "{encoder_settings: { experiment_cpu_load_estimator: "
  83. << (encoder_settings.experiment_cpu_load_estimator ? "on" : "off") << "}}";
  84. ss << ", rtp: " << rtp.ToString();
  85. ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
  86. ss << ", send_transport: " << (send_transport ? "(Transport)" : "nullptr");
  87. ss << ", media_transport: " << (media_transport ? "(Transport)" : "nullptr");
  88. ss << ", render_delay_ms: " << render_delay_ms;
  89. ss << ", target_delay_ms: " << target_delay_ms;
  90. ss << ", suspend_below_min_bitrate: "
  91. << (suspend_below_min_bitrate ? "on" : "off");
  92. ss << '}';
  93. return ss.str();
  94. }
  95. } // namespace webrtc