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