Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 1 | /* |
| 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 | #include "api/rtp_packet_info.h" |
| 12 | |
| 13 | #include <algorithm> |
| 14 | #include <utility> |
| 15 | |
| 16 | namespace webrtc { |
| 17 | |
| 18 | RtpPacketInfo::RtpPacketInfo() |
Johannes Kron | f7de74c | 2021-04-30 13:10:56 +0200 | [diff] [blame] | 19 | : ssrc_(0), rtp_timestamp_(0), receive_time_(Timestamp::MinusInfinity()) {} |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 20 | |
Alessio Bazzica | a1d0356 | 2022-09-19 18:05:29 +0200 | [diff] [blame] | 21 | RtpPacketInfo::RtpPacketInfo(uint32_t ssrc, |
| 22 | std::vector<uint32_t> csrcs, |
| 23 | uint32_t rtp_timestamp, |
| 24 | Timestamp receive_time) |
| 25 | : ssrc_(ssrc), |
| 26 | csrcs_(std::move(csrcs)), |
| 27 | rtp_timestamp_(rtp_timestamp), |
| 28 | receive_time_(receive_time) {} |
| 29 | |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 30 | RtpPacketInfo::RtpPacketInfo(const RTPHeader& rtp_header, |
Johannes Kron | f7de74c | 2021-04-30 13:10:56 +0200 | [diff] [blame] | 31 | Timestamp receive_time) |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 32 | : ssrc_(rtp_header.ssrc), |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 33 | rtp_timestamp_(rtp_header.timestamp), |
Johannes Kron | f7de74c | 2021-04-30 13:10:56 +0200 | [diff] [blame] | 34 | receive_time_(receive_time) { |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 35 | const auto& extension = rtp_header.extension; |
| 36 | const auto csrcs_count = std::min<size_t>(rtp_header.numCSRCs, kRtpCsrcSize); |
| 37 | |
| 38 | csrcs_.assign(&rtp_header.arrOfCSRCs[0], &rtp_header.arrOfCSRCs[csrcs_count]); |
| 39 | |
| 40 | if (extension.hasAudioLevel) { |
| 41 | audio_level_ = extension.audioLevel; |
| 42 | } |
Chen Xing | e08648d | 2019-08-05 16:29:13 +0200 | [diff] [blame] | 43 | |
| 44 | absolute_capture_time_ = extension.absolute_capture_time; |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs) { |
| 48 | return (lhs.ssrc() == rhs.ssrc()) && (lhs.csrcs() == rhs.csrcs()) && |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 49 | (lhs.rtp_timestamp() == rhs.rtp_timestamp()) && |
Alessio Bazzica | a1d0356 | 2022-09-19 18:05:29 +0200 | [diff] [blame] | 50 | (lhs.receive_time() == rhs.receive_time()) && |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 51 | (lhs.audio_level() == rhs.audio_level()) && |
Chen Xing | e08648d | 2019-08-05 16:29:13 +0200 | [diff] [blame] | 52 | (lhs.absolute_capture_time() == rhs.absolute_capture_time()) && |
Alessio Bazzica | a1d0356 | 2022-09-19 18:05:29 +0200 | [diff] [blame] | 53 | (lhs.local_capture_clock_offset() == rhs.local_capture_clock_offset()); |
Chen Xing | d2a6686 | 2019-06-03 14:53:42 +0200 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } // namespace webrtc |