tor-browser

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

rtp_packet_send_info.cc (2389B)


      1 /*
      2 *  Copyright (c) 2024 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 <cstdint>
     12 #include <optional>
     13 
     14 #include "api/transport/network_types.h"
     15 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
     16 #include "modules/rtp_rtcp/source/rtp_header_extensions.h"
     17 #include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
     18 #include "rtc_base/checks.h"
     19 
     20 namespace webrtc {
     21 
     22 RtpPacketSendInfo RtpPacketSendInfo::From(const RtpPacketToSend& packet,
     23                                          const PacedPacketInfo& pacing_info) {
     24  RtpPacketSendInfo packet_info;
     25  if (packet.transport_sequence_number()) {
     26    packet_info.transport_sequence_number =
     27        *packet.transport_sequence_number() & 0xFFFF;
     28  } else {
     29    std::optional<uint16_t> packet_id =
     30        packet.GetExtension<TransportSequenceNumber>();
     31    if (packet_id) {
     32      packet_info.transport_sequence_number = *packet_id;
     33    }
     34  }
     35 
     36  packet_info.rtp_timestamp = packet.Timestamp();
     37  packet_info.length = packet.size();
     38  packet_info.pacing_info = pacing_info;
     39  packet_info.packet_type = packet.packet_type();
     40 
     41  switch (*packet_info.packet_type) {
     42    case RtpPacketMediaType::kAudio:
     43    case RtpPacketMediaType::kVideo:
     44      packet_info.media_ssrc = packet.Ssrc();
     45      packet_info.rtp_sequence_number = packet.SequenceNumber();
     46      break;
     47    case RtpPacketMediaType::kRetransmission:
     48      RTC_DCHECK(packet.original_ssrc() &&
     49                 packet.retransmitted_sequence_number());
     50      // For retransmissions, we're want to remove the original media packet
     51      // if the retransmit arrives - so populate that in the packet info.
     52      packet_info.media_ssrc = packet.original_ssrc().value_or(0);
     53      packet_info.rtp_sequence_number =
     54          packet.retransmitted_sequence_number().value_or(0);
     55      break;
     56    case RtpPacketMediaType::kPadding:
     57    case RtpPacketMediaType::kForwardErrorCorrection:
     58      // We're not interested in feedback about these packets being received
     59      // or lost.
     60      break;
     61  }
     62  return packet_info;
     63 }
     64 
     65 }  // namespace webrtc