Alex Loiko | 44c21f4 | 2019-04-25 13:09:32 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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/opus/audio_encoder_multi_channel_opus.h" |
| 12 | |
| 13 | #include <utility> |
| 14 | |
| 15 | #include "modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | absl::optional<AudioEncoderMultiChannelOpusConfig> |
| 20 | AudioEncoderMultiChannelOpus::SdpToConfig(const SdpAudioFormat& format) { |
| 21 | return AudioEncoderMultiChannelOpusImpl::SdpToConfig(format); |
| 22 | } |
| 23 | |
| 24 | void AudioEncoderMultiChannelOpus::AppendSupportedEncoders( |
| 25 | std::vector<AudioCodecSpec>* specs) { |
| 26 | // To get full utilization of the surround support of the Opus lib, we can |
| 27 | // mark which channel is the low frequency effects (LFE). But that is not done |
| 28 | // ATM. |
| 29 | { |
| 30 | AudioCodecInfo surround_5_1_opus_info{48000, 6, |
| 31 | /* default_bitrate_bps= */ 128000}; |
| 32 | surround_5_1_opus_info.allow_comfort_noise = false; |
| 33 | surround_5_1_opus_info.supports_network_adaption = false; |
| 34 | SdpAudioFormat opus_format({"multiopus", |
| 35 | 48000, |
| 36 | 6, |
| 37 | {{"minptime", "10"}, |
| 38 | {"useinbandfec", "1"}, |
| 39 | {"channel_mapping", "0,4,1,2,3,5"}, |
| 40 | {"num_streams", "4"}, |
| 41 | {"coupled_streams", "2"}}}); |
| 42 | specs->push_back({std::move(opus_format), surround_5_1_opus_info}); |
| 43 | } |
| 44 | { |
| 45 | AudioCodecInfo surround_7_1_opus_info{48000, 8, |
| 46 | /* default_bitrate_bps= */ 200000}; |
| 47 | surround_7_1_opus_info.allow_comfort_noise = false; |
| 48 | surround_7_1_opus_info.supports_network_adaption = false; |
| 49 | SdpAudioFormat opus_format({"multiopus", |
| 50 | 48000, |
| 51 | 8, |
| 52 | {{"minptime", "10"}, |
| 53 | {"useinbandfec", "1"}, |
| 54 | {"channel_mapping", "0,6,1,2,3,4,5,7"}, |
| 55 | {"num_streams", "5"}, |
| 56 | {"coupled_streams", "3"}}}); |
| 57 | specs->push_back({std::move(opus_format), surround_7_1_opus_info}); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | AudioCodecInfo AudioEncoderMultiChannelOpus::QueryAudioEncoder( |
| 62 | const AudioEncoderMultiChannelOpusConfig& config) { |
| 63 | return AudioEncoderMultiChannelOpusImpl::QueryAudioEncoder(config); |
| 64 | } |
| 65 | |
| 66 | std::unique_ptr<AudioEncoder> AudioEncoderMultiChannelOpus::MakeAudioEncoder( |
| 67 | const AudioEncoderMultiChannelOpusConfig& config, |
| 68 | int payload_type, |
| 69 | absl::optional<AudioCodecPairId> /*codec_pair_id*/) { |
| 70 | return AudioEncoderMultiChannelOpusImpl::MakeAudioEncoder(config, |
| 71 | payload_type); |
| 72 | } |
| 73 | |
| 74 | } // namespace webrtc |