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.

102 lines
3.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2015 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/audio_send_stream.h"
  11. #include <stddef.h>
  12. #include "rtc_base/string_encode.h"
  13. #include "rtc_base/strings/audio_format_to_string.h"
  14. #include "rtc_base/strings/string_builder.h"
  15. namespace webrtc {
  16. AudioSendStream::Stats::Stats() = default;
  17. AudioSendStream::Stats::~Stats() = default;
  18. AudioSendStream::Config::Config(
  19. Transport* send_transport,
  20. const MediaTransportConfig& media_transport_config)
  21. : send_transport(send_transport),
  22. media_transport_config(media_transport_config) {}
  23. AudioSendStream::Config::Config(Transport* send_transport)
  24. : Config(send_transport, MediaTransportConfig()) {}
  25. AudioSendStream::Config::~Config() = default;
  26. std::string AudioSendStream::Config::ToString() const {
  27. char buf[1024];
  28. rtc::SimpleStringBuilder ss(buf);
  29. ss << "{rtp: " << rtp.ToString();
  30. ss << ", rtcp_report_interval_ms: " << rtcp_report_interval_ms;
  31. ss << ", send_transport: " << (send_transport ? "(Transport)" : "null");
  32. ss << ", media_transport_config: " << media_transport_config.DebugString();
  33. ss << ", min_bitrate_bps: " << min_bitrate_bps;
  34. ss << ", max_bitrate_bps: " << max_bitrate_bps;
  35. ss << ", send_codec_spec: "
  36. << (send_codec_spec ? send_codec_spec->ToString() : "<unset>");
  37. ss << '}';
  38. return ss.str();
  39. }
  40. AudioSendStream::Config::Rtp::Rtp() = default;
  41. AudioSendStream::Config::Rtp::~Rtp() = default;
  42. std::string AudioSendStream::Config::Rtp::ToString() const {
  43. char buf[1024];
  44. rtc::SimpleStringBuilder ss(buf);
  45. ss << "{ssrc: " << ssrc;
  46. ss << ", extmap-allow-mixed: " << (extmap_allow_mixed ? "true" : "false");
  47. ss << ", extensions: [";
  48. for (size_t i = 0; i < extensions.size(); ++i) {
  49. ss << extensions[i].ToString();
  50. if (i != extensions.size() - 1) {
  51. ss << ", ";
  52. }
  53. }
  54. ss << ']';
  55. ss << ", c_name: " << c_name;
  56. ss << '}';
  57. return ss.str();
  58. }
  59. AudioSendStream::Config::SendCodecSpec::SendCodecSpec(
  60. int payload_type,
  61. const SdpAudioFormat& format)
  62. : payload_type(payload_type), format(format) {}
  63. AudioSendStream::Config::SendCodecSpec::~SendCodecSpec() = default;
  64. std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
  65. char buf[1024];
  66. rtc::SimpleStringBuilder ss(buf);
  67. ss << "{nack_enabled: " << (nack_enabled ? "true" : "false");
  68. ss << ", transport_cc_enabled: " << (transport_cc_enabled ? "true" : "false");
  69. ss << ", cng_payload_type: "
  70. << (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
  71. ss << ", payload_type: " << payload_type;
  72. ss << ", format: " << rtc::ToString(format);
  73. ss << '}';
  74. return ss.str();
  75. }
  76. bool AudioSendStream::Config::SendCodecSpec::operator==(
  77. const AudioSendStream::Config::SendCodecSpec& rhs) const {
  78. if (nack_enabled == rhs.nack_enabled &&
  79. transport_cc_enabled == rhs.transport_cc_enabled &&
  80. cng_payload_type == rhs.cng_payload_type &&
  81. payload_type == rhs.payload_type && format == rhs.format &&
  82. target_bitrate_bps == rhs.target_bitrate_bps) {
  83. return true;
  84. }
  85. return false;
  86. }
  87. } // namespace webrtc