blob: f5d317668ceb7e5ec91c051874d8bebca8a8b2fa [file] [log] [blame]
danilchap1edb7ab2016-04-20 05:25:10 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_
11#define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_
danilchap1edb7ab2016-04-20 05:25:10 -070012
Yves Gerey988cc082018-10-23 12:03:01 +020013#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020014
Dino Radaković21360eb2017-10-24 15:40:40 +020015#include <vector>
16
Yves Gerey988cc082018-10-23 12:03:01 +020017#include "api/array_view.h"
18#include "api/rtp_headers.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/rtp_rtcp/source/rtp_packet.h"
20#include "system_wrappers/include/ntp_time.h"
danilchap1edb7ab2016-04-20 05:25:10 -070021
22namespace webrtc {
23// Class to hold rtp packet with metadata for receiver side.
Danil Chapovalov8769e172017-09-14 14:08:22 +020024class RtpPacketReceived : public RtpPacket {
danilchap1edb7ab2016-04-20 05:25:10 -070025 public:
Dino Radaković21360eb2017-10-24 15:40:40 +020026 RtpPacketReceived();
27 explicit RtpPacketReceived(const ExtensionManager* extensions);
Dino Radaković9e24cb32018-02-26 13:22:48 +010028 RtpPacketReceived(const RtpPacketReceived& packet);
29 RtpPacketReceived(RtpPacketReceived&& packet);
30
31 RtpPacketReceived& operator=(const RtpPacketReceived& packet);
32 RtpPacketReceived& operator=(RtpPacketReceived&& packet);
Dino Radaković21360eb2017-10-24 15:40:40 +020033
34 ~RtpPacketReceived();
danilchap1edb7ab2016-04-20 05:25:10 -070035
danilchapce251812017-09-11 12:24:41 -070036 // 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;
danilchap1edb7ab2016-04-20 05:25:10 -070039
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
nissed2ef3142017-05-11 08:00:58 -070049 // Flag if packet was recovered via RTX or FEC.
50 bool recovered() const { return recovered_; }
51 void set_recovered(bool value) { recovered_ = value; }
danilchap1edb7ab2016-04-20 05:25:10 -070052
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ć21360eb2017-10-24 15:40:40 +020058 // 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
danilchap1edb7ab2016-04-20 05:25:10 -070067 private:
68 NtpTime capture_time_;
69 int64_t arrival_time_ms_ = 0;
70 int payload_type_frequency_ = 0;
nissed2ef3142017-05-11 08:00:58 -070071 bool recovered_ = false;
Dino Radaković21360eb2017-10-24 15:40:40 +020072 std::vector<uint8_t> application_data_;
danilchap1edb7ab2016-04-20 05:25:10 -070073};
74
75} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020076#endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_RECEIVED_H_