| 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/codec_manager.h" | 11 #include "webrtc/modules/audio_coding/acm2/codec_manager.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/format_macros.h" |
| 14 #include "webrtc/engine_configurations.h" | 15 #include "webrtc/engine_configurations.h" |
| 15 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 16 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
| 16 #include "webrtc/system_wrappers/include/trace.h" | 17 #include "webrtc/system_wrappers/include/trace.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 namespace acm2 { | 20 namespace acm2 { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Check if the given codec is a valid to be registered as send codec. | 24 // Check if the given codec is a valid to be registered as send codec. |
| 24 int IsValidSendCodec(const CodecInst& send_codec) { | 25 int IsValidSendCodec(const CodecInst& send_codec) { |
| 25 int dummy_id = 0; | 26 int dummy_id = 0; |
| 26 if ((send_codec.channels != 1) && (send_codec.channels != 2)) { | 27 if ((send_codec.channels != 1) && (send_codec.channels != 2)) { |
| 27 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, | 28 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, |
| 28 "Wrong number of channels (%d, only mono and stereo are " | 29 "Wrong number of channels (%" PRIuS ", only mono and stereo " |
| 29 "supported)", | 30 "are supported)", |
| 30 send_codec.channels); | 31 send_codec.channels); |
| 31 return -1; | 32 return -1; |
| 32 } | 33 } |
| 33 | 34 |
| 34 auto maybe_codec_id = RentACodec::CodecIdByInst(send_codec); | 35 auto maybe_codec_id = RentACodec::CodecIdByInst(send_codec); |
| 35 if (!maybe_codec_id) { | 36 if (!maybe_codec_id) { |
| 36 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, | 37 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, |
| 37 "Invalid codec setting for the send codec."); | 38 "Invalid codec setting for the send codec."); |
| 38 return -1; | 39 return -1; |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Telephone-event cannot be a send codec. | 42 // Telephone-event cannot be a send codec. |
| 42 if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) { | 43 if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) { |
| 43 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, | 44 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, |
| 44 "telephone-event cannot be a send codec"); | 45 "telephone-event cannot be a send codec"); |
| 45 return -1; | 46 return -1; |
| 46 } | 47 } |
| 47 | 48 |
| 48 if (!RentACodec::IsSupportedNumChannels(*maybe_codec_id, send_codec.channels) | 49 if (!RentACodec::IsSupportedNumChannels(*maybe_codec_id, send_codec.channels) |
| 49 .value_or(false)) { | 50 .value_or(false)) { |
| 50 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, | 51 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, |
| 51 "%d number of channels not supportedn for %s.", | 52 "%" PRIuS " number of channels not supportedn for %s.", |
| 52 send_codec.channels, send_codec.plname); | 53 send_codec.channels, send_codec.plname); |
| 53 return -1; | 54 return -1; |
| 54 } | 55 } |
| 55 return RentACodec::CodecIndexFromId(*maybe_codec_id).value_or(-1); | 56 return RentACodec::CodecIndexFromId(*maybe_codec_id).value_or(-1); |
| 56 } | 57 } |
| 57 | 58 |
| 58 bool IsOpus(const CodecInst& codec) { | 59 bool IsOpus(const CodecInst& codec) { |
| 59 return | 60 return |
| 60 #ifdef WEBRTC_CODEC_OPUS | 61 #ifdef WEBRTC_CODEC_OPUS |
| 61 !STR_CASE_CMP(codec.plname, "opus") || | 62 !STR_CASE_CMP(codec.plname, "opus") || |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 "Codec internal FEC and RED cannot be co-enabled."); | 185 "Codec internal FEC and RED cannot be co-enabled."); |
| 185 return false; | 186 return false; |
| 186 } | 187 } |
| 187 | 188 |
| 188 codec_stack_params_.use_codec_fec = enable_codec_fec; | 189 codec_stack_params_.use_codec_fec = enable_codec_fec; |
| 189 return true; | 190 return true; |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace acm2 | 193 } // namespace acm2 |
| 193 } // namespace webrtc | 194 } // namespace webrtc |
| OLD | NEW |