blob: a9e86553d429a55fb42a1801135a0acdd9ac3b95 [file] [log] [blame]
Chen Xingd2a66862019-06-03 14:53:42 +02001/*
2 * Copyright (c) 2019 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
11#ifndef API_RTP_PACKET_INFO_H_
12#define API_RTP_PACKET_INFO_H_
13
14#include <cstdint>
15#include <utility>
16#include <vector>
17
18#include "absl/types/optional.h"
19#include "api/rtp_headers.h"
20
21namespace webrtc {
22
Chen Xing12d64de2019-06-13 20:36:12 +020023//
24// Structure to hold information about a received |RtpPacket|. It is primarily
25// used to carry per-packet information from when a packet is received until
26// the information is passed to |SourceTracker|.
27//
Chen Xingd2a66862019-06-03 14:53:42 +020028class RtpPacketInfo {
29 public:
30 RtpPacketInfo();
31
32 RtpPacketInfo(uint32_t ssrc,
33 std::vector<uint32_t> csrcs,
Chen Xingd2a66862019-06-03 14:53:42 +020034 uint32_t rtp_timestamp,
35 absl::optional<uint8_t> audio_level,
36 int64_t receive_time_ms);
37
38 RtpPacketInfo(const RTPHeader& rtp_header, int64_t receive_time_ms);
39
40 RtpPacketInfo(const RtpPacketInfo& other) = default;
41 RtpPacketInfo(RtpPacketInfo&& other) = default;
42 RtpPacketInfo& operator=(const RtpPacketInfo& other) = default;
43 RtpPacketInfo& operator=(RtpPacketInfo&& other) = default;
44
45 uint32_t ssrc() const { return ssrc_; }
46 void set_ssrc(uint32_t value) { ssrc_ = value; }
47
48 const std::vector<uint32_t>& csrcs() const { return csrcs_; }
49 void set_csrcs(std::vector<uint32_t> value) { csrcs_ = std::move(value); }
50
Chen Xingd2a66862019-06-03 14:53:42 +020051 uint32_t rtp_timestamp() const { return rtp_timestamp_; }
52 void set_rtp_timestamp(uint32_t value) { rtp_timestamp_ = value; }
53
54 absl::optional<uint8_t> audio_level() const { return audio_level_; }
55 void set_audio_level(absl::optional<uint8_t> value) { audio_level_ = value; }
56
57 int64_t receive_time_ms() const { return receive_time_ms_; }
58 void set_receive_time_ms(int64_t value) { receive_time_ms_ = value; }
59
60 private:
61 // Fields from the RTP header:
62 // https://tools.ietf.org/html/rfc3550#section-5.1
63 uint32_t ssrc_;
64 std::vector<uint32_t> csrcs_;
Chen Xingd2a66862019-06-03 14:53:42 +020065 uint32_t rtp_timestamp_;
66
67 // Fields from the Audio Level header extension:
68 // https://tools.ietf.org/html/rfc6464#section-3
69 absl::optional<uint8_t> audio_level_;
70
71 // Local |webrtc::Clock|-based timestamp of when the packet was received.
72 int64_t receive_time_ms_;
73};
74
75bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs);
76
77inline bool operator!=(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs) {
78 return !(lhs == rhs);
79}
80
81} // namespace webrtc
82
83#endif // API_RTP_PACKET_INFO_H_