tor-browser

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

audio_format.cc (3340B)


      1 /*
      2 *  Copyright (c) 2016 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/audio_codecs/audio_format.h"
     12 
     13 #include <cstddef>
     14 #include <utility>
     15 
     16 #include "absl/strings/match.h"
     17 #include "absl/strings/string_view.h"
     18 #include "api/rtp_parameters.h"
     19 #include "rtc_base/checks.h"
     20 
     21 namespace webrtc {
     22 
     23 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
     24 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
     25 
     26 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
     27                               int clockrate_hz,
     28                               size_t num_channels)
     29    : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
     30 
     31 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
     32                               int clockrate_hz,
     33                               size_t num_channels,
     34                               const CodecParameterMap& param)
     35    : name(name),
     36      clockrate_hz(clockrate_hz),
     37      num_channels(num_channels),
     38      parameters(param) {}
     39 
     40 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
     41                               int clockrate_hz,
     42                               size_t num_channels,
     43                               CodecParameterMap&& param)
     44    : name(name),
     45      clockrate_hz(clockrate_hz),
     46      num_channels(num_channels),
     47      parameters(std::move(param)) {}
     48 
     49 bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const {
     50  return absl::EqualsIgnoreCase(name, o.name) &&
     51         clockrate_hz == o.clockrate_hz && num_channels == o.num_channels;
     52 }
     53 
     54 SdpAudioFormat::~SdpAudioFormat() = default;
     55 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
     56 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
     57 
     58 bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) {
     59  return absl::EqualsIgnoreCase(a.name, b.name) &&
     60         a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels &&
     61         a.parameters == b.parameters;
     62 }
     63 
     64 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
     65                               size_t num_channels,
     66                               int bitrate_bps)
     67    : AudioCodecInfo(sample_rate_hz,
     68                     num_channels,
     69                     bitrate_bps,
     70                     bitrate_bps,
     71                     bitrate_bps) {}
     72 
     73 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
     74                               size_t num_channels,
     75                               int default_bitrate_bps,
     76                               int min_bitrate_bps,
     77                               int max_bitrate_bps)
     78    : sample_rate_hz(sample_rate_hz),
     79      num_channels(num_channels),
     80      default_bitrate_bps(default_bitrate_bps),
     81      min_bitrate_bps(min_bitrate_bps),
     82      max_bitrate_bps(max_bitrate_bps) {
     83  RTC_DCHECK_GT(sample_rate_hz, 0);
     84  RTC_DCHECK_GT(num_channels, 0);
     85  RTC_DCHECK_GE(min_bitrate_bps, 0);
     86  RTC_DCHECK_LE(min_bitrate_bps, default_bitrate_bps);
     87  RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
     88 }
     89 
     90 }  // namespace webrtc