blob: 8d66c2a25ca46796f8a8be9d3c84d793a53dd8f1 [file] [log] [blame]
kwiberg65cb70d2017-03-03 06:16:28 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020014#include "modules/audio_coding/neteq/neteq_decoder_enum.h"
kwiberg65cb70d2017-03-03 06:16:28 -080015
16namespace webrtc {
17
18rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
19 switch (nd) {
20 case NetEqDecoder::kDecoderPCMu:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010021 return SdpAudioFormat("pcmu", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080022 case NetEqDecoder::kDecoderPCMa:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010023 return SdpAudioFormat("pcma", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080024 case NetEqDecoder::kDecoderPCMu_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010025 return SdpAudioFormat("pcmu", 8000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080026 case NetEqDecoder::kDecoderPCMa_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010027 return SdpAudioFormat("pcma", 8000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080028 case NetEqDecoder::kDecoderILBC:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010029 return SdpAudioFormat("ilbc", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080030 case NetEqDecoder::kDecoderISAC:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010031 return SdpAudioFormat("isac", 16000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080032 case NetEqDecoder::kDecoderISACswb:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010033 return SdpAudioFormat("isac", 32000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080034 case NetEqDecoder::kDecoderPCM16B:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010035 return SdpAudioFormat("l16", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080036 case NetEqDecoder::kDecoderPCM16Bwb:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010037 return SdpAudioFormat("l16", 16000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080038 case NetEqDecoder::kDecoderPCM16Bswb32kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010039 return SdpAudioFormat("l16", 32000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080040 case NetEqDecoder::kDecoderPCM16Bswb48kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010041 return SdpAudioFormat("l16", 48000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080042 case NetEqDecoder::kDecoderPCM16B_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010043 return SdpAudioFormat("l16", 8000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080044 case NetEqDecoder::kDecoderPCM16Bwb_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010045 return SdpAudioFormat("l16", 16000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080046 case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010047 return SdpAudioFormat("l16", 32000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080048 case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010049 return SdpAudioFormat("l16", 48000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080050 case NetEqDecoder::kDecoderPCM16B_5ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010051 return SdpAudioFormat("l16", 8000, 5);
kwiberg65cb70d2017-03-03 06:16:28 -080052 case NetEqDecoder::kDecoderG722:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010053 return SdpAudioFormat("g722", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080054 case NetEqDecoder::kDecoderG722_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010055 return SdpAudioFormat("g722", 8000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080056 case NetEqDecoder::kDecoderOpus:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010057 return SdpAudioFormat("opus", 48000, 2);
kwiberg65cb70d2017-03-03 06:16:28 -080058 case NetEqDecoder::kDecoderOpus_2ch:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010059 return SdpAudioFormat(
60 "opus", 48000, 2,
61 std::map<std::string, std::string>{{"stereo", "1"}});
kwiberg65cb70d2017-03-03 06:16:28 -080062 case NetEqDecoder::kDecoderRED:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010063 return SdpAudioFormat("red", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080064 case NetEqDecoder::kDecoderAVT:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010065 return SdpAudioFormat("telephone-event", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080066 case NetEqDecoder::kDecoderAVT16kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010067 return SdpAudioFormat("telephone-event", 16000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080068 case NetEqDecoder::kDecoderAVT32kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010069 return SdpAudioFormat("telephone-event", 32000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080070 case NetEqDecoder::kDecoderAVT48kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010071 return SdpAudioFormat("telephone-event", 48000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080072 case NetEqDecoder::kDecoderCNGnb:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010073 return SdpAudioFormat("cn", 8000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080074 case NetEqDecoder::kDecoderCNGwb:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010075 return SdpAudioFormat("cn", 16000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080076 case NetEqDecoder::kDecoderCNGswb32kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010077 return SdpAudioFormat("cn", 32000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080078 case NetEqDecoder::kDecoderCNGswb48kHz:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010079 return SdpAudioFormat("cn", 48000, 1);
kwiberg65cb70d2017-03-03 06:16:28 -080080 default:
Oskar Sundbom12ab00b2017-11-16 15:31:38 +010081 return rtc::nullopt;
kwiberg65cb70d2017-03-03 06:16:28 -080082 }
83}
84
85} // namespace webrtc