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.

72 lines
2.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2019 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 "api/rtp_packet_info.h"
  11. #include <algorithm>
  12. #include <utility>
  13. namespace webrtc {
  14. RtpPacketInfo::RtpPacketInfo()
  15. : ssrc_(0), rtp_timestamp_(0), receive_time_ms_(-1) {}
  16. RtpPacketInfo::RtpPacketInfo(
  17. uint32_t ssrc,
  18. std::vector<uint32_t> csrcs,
  19. uint32_t rtp_timestamp,
  20. absl::optional<uint8_t> audio_level,
  21. absl::optional<AbsoluteCaptureTime> absolute_capture_time,
  22. int64_t receive_time_ms)
  23. : ssrc_(ssrc),
  24. csrcs_(std::move(csrcs)),
  25. rtp_timestamp_(rtp_timestamp),
  26. audio_level_(audio_level),
  27. absolute_capture_time_(absolute_capture_time),
  28. receive_time_ms_(receive_time_ms) {}
  29. RtpPacketInfo::RtpPacketInfo(uint32_t ssrc,
  30. std::vector<uint32_t> csrcs,
  31. uint32_t rtp_timestamp,
  32. absl::optional<uint8_t> audio_level,
  33. int64_t receive_time_ms)
  34. : RtpPacketInfo(ssrc,
  35. std::move(csrcs),
  36. rtp_timestamp,
  37. audio_level,
  38. /*absolute_capture_time=*/absl::nullopt,
  39. receive_time_ms) {}
  40. RtpPacketInfo::RtpPacketInfo(const RTPHeader& rtp_header,
  41. int64_t receive_time_ms)
  42. : ssrc_(rtp_header.ssrc),
  43. rtp_timestamp_(rtp_header.timestamp),
  44. receive_time_ms_(receive_time_ms) {
  45. const auto& extension = rtp_header.extension;
  46. const auto csrcs_count = std::min<size_t>(rtp_header.numCSRCs, kRtpCsrcSize);
  47. csrcs_.assign(&rtp_header.arrOfCSRCs[0], &rtp_header.arrOfCSRCs[csrcs_count]);
  48. if (extension.hasAudioLevel) {
  49. audio_level_ = extension.audioLevel;
  50. }
  51. absolute_capture_time_ = extension.absolute_capture_time;
  52. }
  53. bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs) {
  54. return (lhs.ssrc() == rhs.ssrc()) && (lhs.csrcs() == rhs.csrcs()) &&
  55. (lhs.rtp_timestamp() == rhs.rtp_timestamp()) &&
  56. (lhs.audio_level() == rhs.audio_level()) &&
  57. (lhs.absolute_capture_time() == rhs.absolute_capture_time()) &&
  58. (lhs.receive_time_ms() == rhs.receive_time_ms());
  59. }
  60. } // namespace webrtc