tor-browser

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

rtcp_transceiver_config.cc (2840B)


      1 /*
      2 *  Copyright (c) 2017 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 "modules/rtp_rtcp/source/rtcp_transceiver_config.h"
     12 
     13 #include "api/rtp_headers.h"
     14 #include "api/units/time_delta.h"
     15 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
     16 #include "rtc_base/logging.h"
     17 
     18 namespace webrtc {
     19 
     20 RtcpTransceiverConfig::RtcpTransceiverConfig() = default;
     21 RtcpTransceiverConfig::RtcpTransceiverConfig(const RtcpTransceiverConfig&) =
     22    default;
     23 RtcpTransceiverConfig& RtcpTransceiverConfig::operator=(
     24    const RtcpTransceiverConfig&) = default;
     25 RtcpTransceiverConfig::~RtcpTransceiverConfig() = default;
     26 
     27 bool RtcpTransceiverConfig::Validate() const {
     28  if (feedback_ssrc == 0) {
     29    RTC_LOG(LS_WARNING)
     30        << debug_id
     31        << "Ssrc 0 may be treated by some implementation as invalid.";
     32  }
     33  if (cname.size() > 255) {
     34    RTC_LOG(LS_ERROR) << debug_id << "cname can be maximum 255 characters.";
     35    return false;
     36  }
     37  if (max_packet_size < 100) {
     38    RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
     39                      << " is too small.";
     40    return false;
     41  }
     42  if (max_packet_size > IP_PACKET_SIZE) {
     43    RTC_LOG(LS_ERROR) << debug_id << "max packet size " << max_packet_size
     44                      << " more than " << IP_PACKET_SIZE << " is unsupported.";
     45    return false;
     46  }
     47  if (clock == nullptr) {
     48    RTC_LOG(LS_ERROR) << debug_id << "clock must be set";
     49    return false;
     50  }
     51  if (initial_report_delay < TimeDelta::Zero()) {
     52    RTC_LOG(LS_ERROR) << debug_id << "delay " << initial_report_delay.ms()
     53                      << "ms before first report shouldn't be negative.";
     54    return false;
     55  }
     56  if (report_period <= TimeDelta::Zero()) {
     57    RTC_LOG(LS_ERROR) << debug_id << "period " << report_period.ms()
     58                      << "ms between reports should be positive.";
     59    return false;
     60  }
     61  if (schedule_periodic_compound_packets && task_queue == nullptr) {
     62    RTC_LOG(LS_ERROR) << debug_id
     63                      << "missing task queue for periodic compound packets";
     64    return false;
     65  }
     66  if (rtcp_mode != RtcpMode::kCompound && rtcp_mode != RtcpMode::kReducedSize) {
     67    RTC_LOG(LS_ERROR) << debug_id << "unsupported rtcp mode";
     68    return false;
     69  }
     70  if (non_sender_rtt_measurement && !network_link_observer) {
     71    RTC_LOG(LS_WARNING) << debug_id
     72                        << "Enabled special feature to calculate rtt, but no "
     73                           "rtt observer is provided.";
     74  }
     75  return true;
     76 }
     77 
     78 }  // namespace webrtc