kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 <map> |
| 12 | #include <string> |
| 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/audio_coding/neteq/neteq_decoder_enum.h" |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
| 17 | |
| 18 | rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) { |
| 19 | switch (nd) { |
| 20 | case NetEqDecoder::kDecoderPCMu: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 21 | return SdpAudioFormat("pcmu", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 22 | case NetEqDecoder::kDecoderPCMa: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 23 | return SdpAudioFormat("pcma", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 24 | case NetEqDecoder::kDecoderPCMu_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 25 | return SdpAudioFormat("pcmu", 8000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 26 | case NetEqDecoder::kDecoderPCMa_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 27 | return SdpAudioFormat("pcma", 8000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 28 | case NetEqDecoder::kDecoderILBC: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 29 | return SdpAudioFormat("ilbc", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 30 | case NetEqDecoder::kDecoderISAC: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 31 | return SdpAudioFormat("isac", 16000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 32 | case NetEqDecoder::kDecoderISACswb: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 33 | return SdpAudioFormat("isac", 32000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 34 | case NetEqDecoder::kDecoderPCM16B: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 35 | return SdpAudioFormat("l16", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 36 | case NetEqDecoder::kDecoderPCM16Bwb: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 37 | return SdpAudioFormat("l16", 16000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 38 | case NetEqDecoder::kDecoderPCM16Bswb32kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 39 | return SdpAudioFormat("l16", 32000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 40 | case NetEqDecoder::kDecoderPCM16Bswb48kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 41 | return SdpAudioFormat("l16", 48000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 42 | case NetEqDecoder::kDecoderPCM16B_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 43 | return SdpAudioFormat("l16", 8000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 44 | case NetEqDecoder::kDecoderPCM16Bwb_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 45 | return SdpAudioFormat("l16", 16000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 46 | case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 47 | return SdpAudioFormat("l16", 32000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 48 | case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 49 | return SdpAudioFormat("l16", 48000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 50 | case NetEqDecoder::kDecoderPCM16B_5ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 51 | return SdpAudioFormat("l16", 8000, 5); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 52 | case NetEqDecoder::kDecoderG722: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 53 | return SdpAudioFormat("g722", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 54 | case NetEqDecoder::kDecoderG722_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 55 | return SdpAudioFormat("g722", 8000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 56 | case NetEqDecoder::kDecoderOpus: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 57 | return SdpAudioFormat("opus", 48000, 2); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 58 | case NetEqDecoder::kDecoderOpus_2ch: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 59 | return SdpAudioFormat( |
| 60 | "opus", 48000, 2, |
| 61 | std::map<std::string, std::string>{{"stereo", "1"}}); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 62 | case NetEqDecoder::kDecoderRED: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 63 | return SdpAudioFormat("red", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 64 | case NetEqDecoder::kDecoderAVT: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 65 | return SdpAudioFormat("telephone-event", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 66 | case NetEqDecoder::kDecoderAVT16kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 67 | return SdpAudioFormat("telephone-event", 16000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 68 | case NetEqDecoder::kDecoderAVT32kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 69 | return SdpAudioFormat("telephone-event", 32000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 70 | case NetEqDecoder::kDecoderAVT48kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 71 | return SdpAudioFormat("telephone-event", 48000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 72 | case NetEqDecoder::kDecoderCNGnb: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 73 | return SdpAudioFormat("cn", 8000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 74 | case NetEqDecoder::kDecoderCNGwb: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 75 | return SdpAudioFormat("cn", 16000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 76 | case NetEqDecoder::kDecoderCNGswb32kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 77 | return SdpAudioFormat("cn", 32000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 78 | case NetEqDecoder::kDecoderCNGswb48kHz: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 79 | return SdpAudioFormat("cn", 48000, 1); |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 80 | default: |
Oskar Sundbom | 12ab00b | 2017-11-16 15:31:38 +0100 | [diff] [blame^] | 81 | return rtc::nullopt; |
kwiberg | 65cb70d | 2017-03-03 06:16:28 -0800 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
| 85 | } // namespace webrtc |