2017-07-31 11:34:57 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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
|
|
|
#ifndef API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
|
|
|
|
|
#define API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
|
2017-07-31 11:34:57 -07:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-06-21 13:32:56 +02:00
|
|
|
#include "absl/types/optional.h"
|
2018-03-01 15:13:27 +01:00
|
|
|
#include "api/audio_codecs/audio_codec_pair_id.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_format.h"
|
2022-03-15 14:29:00 +01:00
|
|
|
#include "api/webrtc_key_value_config.h"
|
2018-10-15 17:15:12 +02:00
|
|
|
#include "rtc_base/system/rtc_export.h"
|
2017-07-31 11:34:57 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// G711 decoder API for use as a template parameter to
|
|
|
|
|
// CreateAudioDecoderFactory<...>().
|
2018-10-15 17:15:12 +02:00
|
|
|
struct RTC_EXPORT AudioDecoderG711 {
|
2017-07-31 11:34:57 -07:00
|
|
|
struct Config {
|
|
|
|
|
enum class Type { kPcmU, kPcmA };
|
|
|
|
|
bool IsOk() const {
|
2021-11-16 15:11:28 +00:00
|
|
|
return (type == Type::kPcmU || type == Type::kPcmA) &&
|
|
|
|
|
num_channels >= 1 &&
|
|
|
|
|
num_channels <= AudioDecoder::kMaxNumberOfChannels;
|
2017-07-31 11:34:57 -07:00
|
|
|
}
|
|
|
|
|
Type type;
|
|
|
|
|
int num_channels;
|
|
|
|
|
};
|
2018-06-21 13:32:56 +02:00
|
|
|
static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
|
2017-07-31 11:34:57 -07:00
|
|
|
static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
|
2018-03-01 15:13:27 +01:00
|
|
|
static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
|
|
|
|
const Config& config,
|
2022-03-15 14:29:00 +01:00
|
|
|
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
|
|
|
|
const WebRtcKeyValueConfig* field_trials = nullptr);
|
2017-07-31 11:34:57 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
|