| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 11 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
| 17 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" | 17 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" | 18 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" |
| 19 #ifdef WEBRTC_CODEC_G722 | 19 #ifdef WEBRTC_CODEC_G722 |
| 20 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h" | 20 #include "webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.h" |
| 21 #endif | 21 #endif |
| 22 #ifdef WEBRTC_CODEC_ILBC | 22 #ifdef WEBRTC_CODEC_ILBC |
| 23 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" | 23 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" |
| 24 #endif | 24 #endif |
| 25 #ifdef WEBRTC_CODEC_ISACFX | 25 #ifdef WEBRTC_CODEC_ISACFX |
| 26 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" | 26 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isac
fix.h" // nogncheck |
| 27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" | 27 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isac
fix.h" // nogncheck |
| 28 #endif | 28 #endif |
| 29 #ifdef WEBRTC_CODEC_ISAC | 29 #ifdef WEBRTC_CODEC_ISAC |
| 30 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" | 30 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isa
c.h" // nogncheck |
| 31 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" | 31 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" // nogncheck |
| 32 #endif | 32 #endif |
| 33 #ifdef WEBRTC_CODEC_OPUS | 33 #ifdef WEBRTC_CODEC_OPUS |
| 34 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" | 34 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" |
| 35 #endif | 35 #endif |
| 36 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" | 36 #include "webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" |
| 37 #ifdef WEBRTC_CODEC_RED | 37 #ifdef WEBRTC_CODEC_RED |
| 38 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" | 38 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" |
| 39 #endif | 39 #endif |
| 40 #include "webrtc/modules/audio_coding/acm2/acm_codec_database.h" | 40 #include "webrtc/modules/audio_coding/acm2/acm_codec_database.h" |
| 41 #include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" | |
| 42 | 41 |
| 43 #if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC) | 42 #if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC) |
| 44 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" | 43 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" |
| 45 #endif | 44 #endif |
| 46 | 45 |
| 47 namespace webrtc { | 46 namespace webrtc { |
| 48 namespace acm2 { | 47 namespace acm2 { |
| 49 | 48 |
| 50 rtc::Optional<SdpAudioFormat> RentACodec::NetEqDecoderToSdpAudioFormat( | |
| 51 NetEqDecoder nd) { | |
| 52 switch (nd) { | |
| 53 case NetEqDecoder::kDecoderPCMu: | |
| 54 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcmu", 8000, 1)); | |
| 55 case NetEqDecoder::kDecoderPCMa: | |
| 56 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcma", 8000, 1)); | |
| 57 case NetEqDecoder::kDecoderPCMu_2ch: | |
| 58 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcmu", 8000, 2)); | |
| 59 case NetEqDecoder::kDecoderPCMa_2ch: | |
| 60 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcma", 8000, 2)); | |
| 61 case NetEqDecoder::kDecoderILBC: | |
| 62 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("ilbc", 8000, 1)); | |
| 63 case NetEqDecoder::kDecoderISAC: | |
| 64 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("isac", 16000, 1)); | |
| 65 case NetEqDecoder::kDecoderISACswb: | |
| 66 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("isac", 32000, 1)); | |
| 67 case NetEqDecoder::kDecoderPCM16B: | |
| 68 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 1)); | |
| 69 case NetEqDecoder::kDecoderPCM16Bwb: | |
| 70 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 16000, 1)); | |
| 71 case NetEqDecoder::kDecoderPCM16Bswb32kHz: | |
| 72 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 32000, 1)); | |
| 73 case NetEqDecoder::kDecoderPCM16Bswb48kHz: | |
| 74 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 48000, 1)); | |
| 75 case NetEqDecoder::kDecoderPCM16B_2ch: | |
| 76 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 2)); | |
| 77 case NetEqDecoder::kDecoderPCM16Bwb_2ch: | |
| 78 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 16000, 2)); | |
| 79 case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch: | |
| 80 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 32000, 2)); | |
| 81 case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: | |
| 82 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 48000, 2)); | |
| 83 case NetEqDecoder::kDecoderPCM16B_5ch: | |
| 84 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 5)); | |
| 85 case NetEqDecoder::kDecoderG722: | |
| 86 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("g722", 8000, 1)); | |
| 87 case NetEqDecoder::kDecoderG722_2ch: | |
| 88 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("g722", 8000, 2)); | |
| 89 case NetEqDecoder::kDecoderOpus: | |
| 90 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("opus", 48000, 2)); | |
| 91 case NetEqDecoder::kDecoderOpus_2ch: | |
| 92 return rtc::Optional<SdpAudioFormat>( | |
| 93 SdpAudioFormat("opus", 48000, 2, | |
| 94 std::map<std::string, std::string>{{"stereo", "1"}})); | |
| 95 case NetEqDecoder::kDecoderRED: | |
| 96 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("red", 8000, 1)); | |
| 97 case NetEqDecoder::kDecoderAVT: | |
| 98 return rtc::Optional<SdpAudioFormat>( | |
| 99 SdpAudioFormat("telephone-event", 8000, 1)); | |
| 100 case NetEqDecoder::kDecoderAVT16kHz: | |
| 101 return rtc::Optional<SdpAudioFormat>( | |
| 102 SdpAudioFormat("telephone-event", 16000, 1)); | |
| 103 case NetEqDecoder::kDecoderAVT32kHz: | |
| 104 return rtc::Optional<SdpAudioFormat>( | |
| 105 SdpAudioFormat("telephone-event", 32000, 1)); | |
| 106 case NetEqDecoder::kDecoderAVT48kHz: | |
| 107 return rtc::Optional<SdpAudioFormat>( | |
| 108 SdpAudioFormat("telephone-event", 48000, 1)); | |
| 109 case NetEqDecoder::kDecoderCNGnb: | |
| 110 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 8000, 1)); | |
| 111 case NetEqDecoder::kDecoderCNGwb: | |
| 112 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 16000, 1)); | |
| 113 case NetEqDecoder::kDecoderCNGswb32kHz: | |
| 114 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 32000, 1)); | |
| 115 case NetEqDecoder::kDecoderCNGswb48kHz: | |
| 116 return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 48000, 1)); | |
| 117 default: | |
| 118 return rtc::Optional<SdpAudioFormat>(); | |
| 119 } | |
| 120 } | |
| 121 | |
| 122 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams( | 49 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams( |
| 123 const char* payload_name, | 50 const char* payload_name, |
| 124 int sampling_freq_hz, | 51 int sampling_freq_hz, |
| 125 size_t channels) { | 52 size_t channels) { |
| 126 return CodecIdFromIndex( | 53 return CodecIdFromIndex( |
| 127 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels)); | 54 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels)); |
| 128 } | 55 } |
| 129 | 56 |
| 130 rtc::Optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) { | 57 rtc::Optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) { |
| 131 rtc::Optional<int> mi = CodecIndexFromId(codec_id); | 58 rtc::Optional<int> mi = CodecIndexFromId(codec_id); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 305 } |
| 379 return encoder_stack; | 306 return encoder_stack; |
| 380 } | 307 } |
| 381 | 308 |
| 382 std::unique_ptr<AudioDecoder> RentACodec::RentIsacDecoder(int sample_rate_hz) { | 309 std::unique_ptr<AudioDecoder> RentACodec::RentIsacDecoder(int sample_rate_hz) { |
| 383 return CreateIsacDecoder(sample_rate_hz, isac_bandwidth_info_); | 310 return CreateIsacDecoder(sample_rate_hz, isac_bandwidth_info_); |
| 384 } | 311 } |
| 385 | 312 |
| 386 } // namespace acm2 | 313 } // namespace acm2 |
| 387 } // namespace webrtc | 314 } // namespace webrtc |
| OLD | NEW |