tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rtp_packet_info.cc (2146B)


      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 <cstddef>
     15 #include <cstdint>
     16 #include <utility>
     17 #include <vector>
     18 
     19 #include "api/rtp_headers.h"
     20 #include "api/units/timestamp.h"
     21 
     22 namespace webrtc {
     23 
     24 RtpPacketInfo::RtpPacketInfo()
     25    : ssrc_(0), rtp_timestamp_(0), receive_time_(Timestamp::MinusInfinity()) {}
     26 
     27 RtpPacketInfo::RtpPacketInfo(uint32_t ssrc,
     28                             std::vector<uint32_t> csrcs,
     29                             uint32_t rtp_timestamp,
     30                             Timestamp receive_time)
     31    : ssrc_(ssrc),
     32      csrcs_(std::move(csrcs)),
     33      rtp_timestamp_(rtp_timestamp),
     34      receive_time_(receive_time) {}
     35 
     36 RtpPacketInfo::RtpPacketInfo(const RTPHeader& rtp_header,
     37                             Timestamp receive_time)
     38    : ssrc_(rtp_header.ssrc),
     39      rtp_timestamp_(rtp_header.timestamp),
     40      receive_time_(receive_time) {
     41  const auto& extension = rtp_header.extension;
     42  const auto csrcs_count = std::min<size_t>(rtp_header.numCSRCs, kRtpCsrcSize);
     43 
     44  csrcs_.assign(&rtp_header.arrOfCSRCs[0], &rtp_header.arrOfCSRCs[csrcs_count]);
     45 
     46  if (extension.audio_level()) {
     47    audio_level_ = extension.audio_level()->level();
     48  }
     49 
     50  absolute_capture_time_ = extension.absolute_capture_time;
     51 }
     52 
     53 bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs) {
     54  return (lhs.ssrc() == rhs.ssrc()) && (lhs.csrcs() == rhs.csrcs()) &&
     55         (lhs.rtp_timestamp() == rhs.rtp_timestamp()) &&
     56         (lhs.receive_time() == rhs.receive_time()) &&
     57         (lhs.audio_level() == rhs.audio_level()) &&
     58         (lhs.absolute_capture_time() == rhs.absolute_capture_time()) &&
     59         (lhs.local_capture_clock_offset() == rhs.local_capture_clock_offset());
     60 }
     61 
     62 }  // namespace webrtc