danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 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 | */ |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_ |
| 11 | #define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_ |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 12 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 13 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 14 | |
Dino Radaković | 21360eb | 2017-10-24 15:40:40 +0200 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 17 | #include "api/array_view.h" |
| 18 | #include "api/rtp_headers.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "modules/rtp_rtcp/source/rtp_packet.h" |
| 20 | #include "system_wrappers/include/ntp_time.h" |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | // Class to hold rtp packet with metadata for receiver side. |
Danil Chapovalov | 8769e17 | 2017-09-14 14:08:22 +0200 | [diff] [blame] | 24 | class RtpPacketReceived : public RtpPacket { |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 25 | public: |
Dino Radaković | 21360eb | 2017-10-24 15:40:40 +0200 | [diff] [blame] | 26 | RtpPacketReceived(); |
| 27 | explicit RtpPacketReceived(const ExtensionManager* extensions); |
Dino Radaković | 9e24cb3 | 2018-02-26 13:22:48 +0100 | [diff] [blame] | 28 | RtpPacketReceived(const RtpPacketReceived& packet); |
| 29 | RtpPacketReceived(RtpPacketReceived&& packet); |
| 30 | |
| 31 | RtpPacketReceived& operator=(const RtpPacketReceived& packet); |
| 32 | RtpPacketReceived& operator=(RtpPacketReceived&& packet); |
Dino Radaković | 21360eb | 2017-10-24 15:40:40 +0200 | [diff] [blame] | 33 | |
| 34 | ~RtpPacketReceived(); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 35 | |
danilchap | ce25181 | 2017-09-11 12:24:41 -0700 | [diff] [blame] | 36 | // TODO(danilchap): Remove this function when all code update to use RtpPacket |
| 37 | // directly. Function is there just for easier backward compatibilty. |
| 38 | void GetHeader(RTPHeader* header) const; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 39 | |
| 40 | // Time in local time base as close as it can to packet arrived on the |
| 41 | // network. |
| 42 | int64_t arrival_time_ms() const { return arrival_time_ms_; } |
| 43 | void set_arrival_time_ms(int64_t time) { arrival_time_ms_ = time; } |
| 44 | |
| 45 | // Estimated from Timestamp() using rtcp Sender Reports. |
| 46 | NtpTime capture_ntp_time() const { return capture_time_; } |
| 47 | void set_capture_ntp_time(NtpTime time) { capture_time_ = time; } |
| 48 | |
nisse | d2ef314 | 2017-05-11 08:00:58 -0700 | [diff] [blame] | 49 | // Flag if packet was recovered via RTX or FEC. |
| 50 | bool recovered() const { return recovered_; } |
| 51 | void set_recovered(bool value) { recovered_ = value; } |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 52 | |
| 53 | int payload_type_frequency() const { return payload_type_frequency_; } |
| 54 | void set_payload_type_frequency(int value) { |
| 55 | payload_type_frequency_ = value; |
| 56 | } |
| 57 | |
Dino Radaković | 21360eb | 2017-10-24 15:40:40 +0200 | [diff] [blame] | 58 | // Additional data bound to the RTP packet for use in application code, |
| 59 | // outside of WebRTC. |
| 60 | rtc::ArrayView<const uint8_t> application_data() const { |
| 61 | return application_data_; |
| 62 | } |
| 63 | void set_application_data(rtc::ArrayView<const uint8_t> data) { |
| 64 | application_data_.assign(data.begin(), data.end()); |
| 65 | } |
| 66 | |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 67 | private: |
| 68 | NtpTime capture_time_; |
| 69 | int64_t arrival_time_ms_ = 0; |
| 70 | int payload_type_frequency_ = 0; |
nisse | d2ef314 | 2017-05-11 08:00:58 -0700 | [diff] [blame] | 71 | bool recovered_ = false; |
Dino Radaković | 21360eb | 2017-10-24 15:40:40 +0200 | [diff] [blame] | 72 | std::vector<uint8_t> application_data_; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 76 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_ |