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