2016-04-28 14:23:32 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_format.h"
|
2016-04-28 14:23:32 -07:00
|
|
|
|
2019-02-04 14:50:38 +01:00
|
|
|
#include <utility>
|
|
|
|
|
|
2018-10-22 09:48:08 +02:00
|
|
|
#include "absl/strings/match.h"
|
2016-09-21 10:55:15 -07:00
|
|
|
|
2016-04-28 14:23:32 -07:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
|
|
|
|
|
SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
|
|
|
|
|
|
2018-08-15 15:23:08 +02:00
|
|
|
SdpAudioFormat::SdpAudioFormat(absl::string_view name,
|
2016-04-28 14:23:32 -07:00
|
|
|
int clockrate_hz,
|
2017-04-06 10:03:21 -07:00
|
|
|
size_t num_channels)
|
2016-04-28 14:23:32 -07:00
|
|
|
: name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
|
|
|
|
|
|
2018-08-15 15:23:08 +02:00
|
|
|
SdpAudioFormat::SdpAudioFormat(absl::string_view name,
|
2017-01-19 07:03:59 -08:00
|
|
|
int clockrate_hz,
|
2017-04-06 10:03:21 -07:00
|
|
|
size_t num_channels,
|
2017-01-19 07:03:59 -08:00
|
|
|
const Parameters& param)
|
2016-05-03 01:39:01 -07:00
|
|
|
: name(name),
|
|
|
|
|
clockrate_hz(clockrate_hz),
|
|
|
|
|
num_channels(num_channels),
|
2017-01-19 07:03:59 -08:00
|
|
|
parameters(param) {}
|
2016-05-03 01:39:01 -07:00
|
|
|
|
2019-02-04 14:50:38 +01:00
|
|
|
SdpAudioFormat::SdpAudioFormat(absl::string_view name,
|
|
|
|
|
int clockrate_hz,
|
|
|
|
|
size_t num_channels,
|
|
|
|
|
Parameters&& param)
|
|
|
|
|
: name(name),
|
|
|
|
|
clockrate_hz(clockrate_hz),
|
|
|
|
|
num_channels(num_channels),
|
|
|
|
|
parameters(std::move(param)) {}
|
|
|
|
|
|
2017-04-26 16:28:42 -07:00
|
|
|
bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const {
|
2018-10-22 09:48:08 +02:00
|
|
|
return absl::EqualsIgnoreCase(name, o.name) &&
|
2017-04-26 16:28:42 -07:00
|
|
|
clockrate_hz == o.clockrate_hz && num_channels == o.num_channels;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 14:23:32 -07:00
|
|
|
SdpAudioFormat::~SdpAudioFormat() = default;
|
|
|
|
|
SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
|
|
|
|
|
SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
|
|
|
|
|
|
2016-09-21 10:55:15 -07:00
|
|
|
bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) {
|
2018-10-22 09:48:08 +02:00
|
|
|
return absl::EqualsIgnoreCase(a.name, b.name) &&
|
2016-09-21 10:55:15 -07:00
|
|
|
a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels &&
|
|
|
|
|
a.parameters == b.parameters;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-06 10:03:21 -07:00
|
|
|
AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
|
|
|
|
|
size_t num_channels,
|
|
|
|
|
int bitrate_bps)
|
|
|
|
|
: AudioCodecInfo(sample_rate_hz,
|
|
|
|
|
num_channels,
|
|
|
|
|
bitrate_bps,
|
|
|
|
|
bitrate_bps,
|
|
|
|
|
bitrate_bps) {}
|
2017-02-09 05:14:32 -08:00
|
|
|
|
2017-04-06 10:03:21 -07:00
|
|
|
AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
|
|
|
|
|
size_t num_channels,
|
|
|
|
|
int default_bitrate_bps,
|
|
|
|
|
int min_bitrate_bps,
|
|
|
|
|
int max_bitrate_bps)
|
|
|
|
|
: sample_rate_hz(sample_rate_hz),
|
|
|
|
|
num_channels(num_channels),
|
|
|
|
|
default_bitrate_bps(default_bitrate_bps),
|
|
|
|
|
min_bitrate_bps(min_bitrate_bps),
|
|
|
|
|
max_bitrate_bps(max_bitrate_bps) {
|
|
|
|
|
RTC_DCHECK_GT(sample_rate_hz, 0);
|
|
|
|
|
RTC_DCHECK_GT(num_channels, 0);
|
|
|
|
|
RTC_DCHECK_GE(min_bitrate_bps, 0);
|
|
|
|
|
RTC_DCHECK_LE(min_bitrate_bps, default_bitrate_bps);
|
|
|
|
|
RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
|
|
|
|
|
}
|
2017-02-09 05:14:32 -08:00
|
|
|
|
2016-04-28 14:23:32 -07:00
|
|
|
} // namespace webrtc
|