rtp_packet_info.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef API_RTP_PACKET_INFO_H_
  11. #define API_RTP_PACKET_INFO_H_
  12. #include <cstdint>
  13. #include <utility>
  14. #include <vector>
  15. #include "absl/types/optional.h"
  16. #include "api/rtp_headers.h"
  17. #include "rtc_base/system/rtc_export.h"
  18. namespace webrtc {
  19. //
  20. // Structure to hold information about a received |RtpPacket|. It is primarily
  21. // used to carry per-packet information from when a packet is received until
  22. // the information is passed to |SourceTracker|.
  23. //
  24. class RTC_EXPORT RtpPacketInfo {
  25. public:
  26. RtpPacketInfo();
  27. RtpPacketInfo(uint32_t ssrc,
  28. std::vector<uint32_t> csrcs,
  29. uint32_t rtp_timestamp,
  30. absl::optional<uint8_t> audio_level,
  31. absl::optional<AbsoluteCaptureTime> absolute_capture_time,
  32. int64_t receive_time_ms);
  33. RtpPacketInfo(const RTPHeader& rtp_header, int64_t receive_time_ms);
  34. RtpPacketInfo(const RtpPacketInfo& other) = default;
  35. RtpPacketInfo(RtpPacketInfo&& other) = default;
  36. RtpPacketInfo& operator=(const RtpPacketInfo& other) = default;
  37. RtpPacketInfo& operator=(RtpPacketInfo&& other) = default;
  38. uint32_t ssrc() const { return ssrc_; }
  39. void set_ssrc(uint32_t value) { ssrc_ = value; }
  40. const std::vector<uint32_t>& csrcs() const { return csrcs_; }
  41. void set_csrcs(std::vector<uint32_t> value) { csrcs_ = std::move(value); }
  42. uint32_t rtp_timestamp() const { return rtp_timestamp_; }
  43. void set_rtp_timestamp(uint32_t value) { rtp_timestamp_ = value; }
  44. absl::optional<uint8_t> audio_level() const { return audio_level_; }
  45. void set_audio_level(absl::optional<uint8_t> value) { audio_level_ = value; }
  46. const absl::optional<AbsoluteCaptureTime>& absolute_capture_time() const {
  47. return absolute_capture_time_;
  48. }
  49. void set_absolute_capture_time(
  50. const absl::optional<AbsoluteCaptureTime>& value) {
  51. absolute_capture_time_ = value;
  52. }
  53. int64_t receive_time_ms() const { return receive_time_ms_; }
  54. void set_receive_time_ms(int64_t value) { receive_time_ms_ = value; }
  55. private:
  56. // Fields from the RTP header:
  57. // https://tools.ietf.org/html/rfc3550#section-5.1
  58. uint32_t ssrc_;
  59. std::vector<uint32_t> csrcs_;
  60. uint32_t rtp_timestamp_;
  61. // Fields from the Audio Level header extension:
  62. // https://tools.ietf.org/html/rfc6464#section-3
  63. absl::optional<uint8_t> audio_level_;
  64. // Fields from the Absolute Capture Time header extension:
  65. // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time
  66. absl::optional<AbsoluteCaptureTime> absolute_capture_time_;
  67. // Local |webrtc::Clock|-based timestamp of when the packet was received.
  68. int64_t receive_time_ms_;
  69. };
  70. bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs);
  71. inline bool operator!=(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs) {
  72. return !(lhs == rhs);
  73. }
  74. } // namespace webrtc
  75. #endif // API_RTP_PACKET_INFO_H_