rtp_packet_received.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2016 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 MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_
  11. #define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_
  12. #include <stdint.h>
  13. #include <vector>
  14. #include "api/array_view.h"
  15. #include "api/rtp_headers.h"
  16. #include "modules/rtp_rtcp/source/rtp_packet.h"
  17. #include "system_wrappers/include/ntp_time.h"
  18. namespace webrtc {
  19. // Class to hold rtp packet with metadata for receiver side.
  20. class RtpPacketReceived : public RtpPacket {
  21. public:
  22. RtpPacketReceived();
  23. explicit RtpPacketReceived(const ExtensionManager* extensions);
  24. RtpPacketReceived(const RtpPacketReceived& packet);
  25. RtpPacketReceived(RtpPacketReceived&& packet);
  26. RtpPacketReceived& operator=(const RtpPacketReceived& packet);
  27. RtpPacketReceived& operator=(RtpPacketReceived&& packet);
  28. ~RtpPacketReceived();
  29. // TODO(danilchap): Remove this function when all code update to use RtpPacket
  30. // directly. Function is there just for easier backward compatibilty.
  31. void GetHeader(RTPHeader* header) const;
  32. // Time in local time base as close as it can to packet arrived on the
  33. // network.
  34. int64_t arrival_time_ms() const { return arrival_time_ms_; }
  35. void set_arrival_time_ms(int64_t time) { arrival_time_ms_ = time; }
  36. // Estimated from Timestamp() using rtcp Sender Reports.
  37. NtpTime capture_ntp_time() const { return capture_time_; }
  38. void set_capture_ntp_time(NtpTime time) { capture_time_ = time; }
  39. // Flag if packet was recovered via RTX or FEC.
  40. bool recovered() const { return recovered_; }
  41. void set_recovered(bool value) { recovered_ = value; }
  42. int payload_type_frequency() const { return payload_type_frequency_; }
  43. void set_payload_type_frequency(int value) {
  44. payload_type_frequency_ = value;
  45. }
  46. // Additional data bound to the RTP packet for use in application code,
  47. // outside of WebRTC.
  48. rtc::ArrayView<const uint8_t> application_data() const {
  49. return application_data_;
  50. }
  51. void set_application_data(rtc::ArrayView<const uint8_t> data) {
  52. application_data_.assign(data.begin(), data.end());
  53. }
  54. private:
  55. NtpTime capture_time_;
  56. int64_t arrival_time_ms_ = 0;
  57. int payload_type_frequency_ = 0;
  58. bool recovered_ = false;
  59. std::vector<uint8_t> application_data_;
  60. };
  61. } // namespace webrtc
  62. #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_