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.
11 #include "api/audio_codecs/audio_format.h"
15 #include "absl/strings/match.h"
19 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat
&) = default;
20 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat
&&) = default;
22 SdpAudioFormat::SdpAudioFormat(absl::string_view name
,
25 : name(name
), clockrate_hz(clockrate_hz
), num_channels(num_channels
) {}
27 SdpAudioFormat::SdpAudioFormat(absl::string_view name
,
30 const Parameters
& param
)
32 clockrate_hz(clockrate_hz
),
33 num_channels(num_channels
),
36 SdpAudioFormat::SdpAudioFormat(absl::string_view 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
,
63 : AudioCodecInfo(sample_rate_hz
,
69 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz
,
71 int default_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
);