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/array_view.h" 18 #include "api/ref_counted_base.h" 19 #include "api/rtp_headers.h" 20 #include "api/scoped_refptr.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 = webrtc::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(danilchap): Remove this function when all code update to use RtpPacket 43 // directly. Function is there just for easier backward compatibilty. 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. arrival_time()48 webrtc::Timestamp arrival_time() const { return arrival_time_; } set_arrival_time(webrtc::Timestamp time)49 void set_arrival_time(webrtc::Timestamp time) { arrival_time_ = time; } 50 51 // Flag if packet was recovered via RTX or FEC. recovered()52 bool recovered() const { return recovered_; } set_recovered(bool value)53 void set_recovered(bool value) { recovered_ = value; } 54 payload_type_frequency()55 int payload_type_frequency() const { return payload_type_frequency_; } set_payload_type_frequency(int value)56 void set_payload_type_frequency(int value) { 57 payload_type_frequency_ = value; 58 } 59 60 // An application can attach arbitrary data to an RTP packet using 61 // `additional_data`. The additional data does not affect WebRTC processing. additional_data()62 rtc::scoped_refptr<rtc::RefCountedBase> additional_data() const { 63 return additional_data_; 64 } set_additional_data(rtc::scoped_refptr<rtc::RefCountedBase> data)65 void set_additional_data(rtc::scoped_refptr<rtc::RefCountedBase> data) { 66 additional_data_ = std::move(data); 67 } 68 69 private: 70 webrtc::Timestamp arrival_time_ = Timestamp::MinusInfinity(); 71 int payload_type_frequency_ = 0; 72 bool recovered_ = false; 73 rtc::scoped_refptr<rtc::RefCountedBase> additional_data_; 74 }; 75 76 } // namespace webrtc 77 #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_ 78