Bug 1833854 - Part 6: Round requested nursery before checking range when changing...
[gecko.git] / third_party / libwebrtc / api / audio_codecs / audio_format.cc
blob2a529a49ee5b5a87def17f1ffd7481d2340511da
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
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 */
11 #include "api/audio_codecs/audio_format.h"
13 #include <utility>
15 #include "absl/strings/match.h"
17 namespace webrtc {
19 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
20 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
22 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
23 int clockrate_hz,
24 size_t num_channels)
25 : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
27 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
28 int clockrate_hz,
29 size_t num_channels,
30 const Parameters& param)
31 : name(name),
32 clockrate_hz(clockrate_hz),
33 num_channels(num_channels),
34 parameters(param) {}
36 SdpAudioFormat::SdpAudioFormat(absl::string_view name,
37 int clockrate_hz,
38 size_t num_channels,
39 Parameters&& param)
40 : name(name),
41 clockrate_hz(clockrate_hz),
42 num_channels(num_channels),
43 parameters(std::move(param)) {}
45 bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const {
46 return absl::EqualsIgnoreCase(name, o.name) &&
47 clockrate_hz == o.clockrate_hz && num_channels == o.num_channels;
50 SdpAudioFormat::~SdpAudioFormat() = default;
51 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
52 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
54 bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) {
55 return absl::EqualsIgnoreCase(a.name, b.name) &&
56 a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels &&
57 a.parameters == b.parameters;
60 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
61 size_t num_channels,
62 int bitrate_bps)
63 : AudioCodecInfo(sample_rate_hz,
64 num_channels,
65 bitrate_bps,
66 bitrate_bps,
67 bitrate_bps) {}
69 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
70 size_t num_channels,
71 int default_bitrate_bps,
72 int min_bitrate_bps,
73 int max_bitrate_bps)
74 : sample_rate_hz(sample_rate_hz),
75 num_channels(num_channels),
76 default_bitrate_bps(default_bitrate_bps),
77 min_bitrate_bps(min_bitrate_bps),
78 max_bitrate_bps(max_bitrate_bps) {
79 RTC_DCHECK_GT(sample_rate_hz, 0);
80 RTC_DCHECK_GT(num_channels, 0);
81 RTC_DCHECK_GE(min_bitrate_bps, 0);
82 RTC_DCHECK_LE(min_bitrate_bps, default_bitrate_bps);
83 RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
86 } // namespace webrtc