rtp_packet_received.h (3037B)
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 13 #include <stdint.h> 14 15 #include <utility> 16 17 #include "api/ref_counted_base.h" 18 #include "api/rtp_headers.h" 19 #include "api/scoped_refptr.h" 20 #include "api/transport/ecn_marking.h" 21 #include "api/units/timestamp.h" 22 #include "modules/rtp_rtcp/source/rtp_packet.h" 23 24 namespace webrtc { 25 // Class to hold rtp packet with metadata for receiver side. 26 // The metadata is not parsed from the rtp packet, but may be derived from the 27 // data that is parsed from the rtp packet. 28 class RtpPacketReceived : public RtpPacket { 29 public: 30 RtpPacketReceived(); 31 explicit RtpPacketReceived( 32 const ExtensionManager* extensions, 33 webrtc::Timestamp arrival_time = Timestamp::MinusInfinity()); 34 RtpPacketReceived(const RtpPacketReceived& packet); 35 RtpPacketReceived(RtpPacketReceived&& packet); 36 37 RtpPacketReceived& operator=(const RtpPacketReceived& packet); 38 RtpPacketReceived& operator=(RtpPacketReceived&& packet); 39 40 ~RtpPacketReceived(); 41 42 // TODO(bugs.webrtc.org/15054): Remove this function when all code is updated 43 // to use RtpPacket directly. 44 void GetHeader(RTPHeader* header) const; 45 46 // Time in local time base as close as it can to packet arrived on the 47 // network. 48 webrtc::Timestamp arrival_time() const { return arrival_time_; } 49 void set_arrival_time(webrtc::Timestamp time) { arrival_time_ = time; } 50 51 // Explicit Congestion Notification (ECN), RFC-3168, Section 5. 52 // Used by L4S: https://www.rfc-editor.org/rfc/rfc9331.html 53 EcnMarking ecn() const { return ecn_; } 54 void set_ecn(EcnMarking ecn) { ecn_ = ecn; } 55 56 // Flag if packet was recovered via RTX or FEC. 57 bool recovered() const { return recovered_; } 58 void set_recovered(bool value) { recovered_ = value; } 59 60 int payload_type_frequency() const { return payload_type_frequency_; } 61 void set_payload_type_frequency(int value) { 62 payload_type_frequency_ = value; 63 } 64 65 // An application can attach arbitrary data to an RTP packet using 66 // `additional_data`. The additional data does not affect WebRTC processing. 67 scoped_refptr<RefCountedBase> additional_data() const { 68 return additional_data_; 69 } 70 void set_additional_data(scoped_refptr<RefCountedBase> data) { 71 additional_data_ = std::move(data); 72 } 73 74 private: 75 webrtc::Timestamp arrival_time_ = Timestamp::MinusInfinity(); 76 EcnMarking ecn_ = EcnMarking::kNotEct; 77 int payload_type_frequency_ = 0; 78 bool recovered_ = false; 79 scoped_refptr<RefCountedBase> additional_data_; 80 }; 81 82 } // namespace webrtc 83 #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_