| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/voice_engine/voe_codec_impl.h" | 11 #include "webrtc/voice_engine/voe_codec_impl.h" |
| 12 | 12 |
| 13 #include "webrtc/base/format_macros.h" |
| 13 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" | 14 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
| 14 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 15 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 15 #include "webrtc/system_wrappers/interface/trace.h" | 16 #include "webrtc/system_wrappers/interface/trace.h" |
| 16 #include "webrtc/voice_engine/channel.h" | 17 #include "webrtc/voice_engine/channel.h" |
| 17 #include "webrtc/voice_engine/include/voe_errors.h" | 18 #include "webrtc/voice_engine/include/voe_errors.h" |
| 18 #include "webrtc/voice_engine/voice_engine_impl.h" | 19 #include "webrtc/voice_engine/voice_engine_impl.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 VoECodec* VoECodec::GetInterface(VoiceEngine* voiceEngine) { | 23 VoECodec* VoECodec::GetInterface(VoiceEngine* voiceEngine) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 "GetCodec(index=%d, codec=?)", index); | 62 "GetCodec(index=%d, codec=?)", index); |
| 62 CodecInst acmCodec; | 63 CodecInst acmCodec; |
| 63 if (AudioCodingModule::Codec(index, &acmCodec) == -1) { | 64 if (AudioCodingModule::Codec(index, &acmCodec) == -1) { |
| 64 _shared->SetLastError(VE_INVALID_LISTNR, kTraceError, | 65 _shared->SetLastError(VE_INVALID_LISTNR, kTraceError, |
| 65 "GetCodec() invalid index"); | 66 "GetCodec() invalid index"); |
| 66 return -1; | 67 return -1; |
| 67 } | 68 } |
| 68 ACMToExternalCodecRepresentation(codec, acmCodec); | 69 ACMToExternalCodecRepresentation(codec, acmCodec); |
| 69 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | 70 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 70 "GetCodec() => plname=%s, pacsize=%d, plfreq=%d, pltype=%d, " | 71 "GetCodec() => plname=%s, pacsize=%d, plfreq=%d, pltype=%d, " |
| 71 "channels=%d, rate=%d", | 72 "channels=%" PRIuS ", rate=%d", |
| 72 codec.plname, codec.pacsize, codec.plfreq, codec.pltype, | 73 codec.plname, codec.pacsize, codec.plfreq, codec.pltype, |
| 73 codec.channels, codec.rate); | 74 codec.channels, codec.rate); |
| 74 return 0; | 75 return 0; |
| 75 } | 76 } |
| 76 | 77 |
| 77 int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec) { | 78 int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec) { |
| 78 CodecInst copyCodec; | 79 CodecInst copyCodec; |
| 79 ExternalToACMCodecRepresentation(copyCodec, codec); | 80 ExternalToACMCodecRepresentation(copyCodec, codec); |
| 80 | 81 |
| 81 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 82 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 82 "SetSendCodec(channel=%d, codec)", channel); | 83 "SetSendCodec(channel=%d, codec)", channel); |
| 83 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | 84 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 84 "codec: plname=%s, pacsize=%d, plfreq=%d, pltype=%d, " | 85 "codec: plname=%s, pacsize=%d, plfreq=%d, pltype=%d, " |
| 85 "channels=%d, rate=%d", | 86 "channels=%" PRIuS ", rate=%d", |
| 86 codec.plname, codec.pacsize, codec.plfreq, codec.pltype, | 87 codec.plname, codec.pacsize, codec.plfreq, codec.pltype, |
| 87 codec.channels, codec.rate); | 88 codec.channels, codec.rate); |
| 88 if (!_shared->statistics().Initialized()) { | 89 if (!_shared->statistics().Initialized()) { |
| 89 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 90 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 90 return -1; | 91 return -1; |
| 91 } | 92 } |
| 92 // External sanity checks performed outside the ACM | 93 // External sanity checks performed outside the ACM |
| 93 if ((STR_CASE_CMP(copyCodec.plname, "L16") == 0) && | 94 if ((STR_CASE_CMP(copyCodec.plname, "L16") == 0) && |
| 94 (copyCodec.pacsize >= 960)) { | 95 (copyCodec.pacsize >= 960)) { |
| 95 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, | 96 _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 146 } |
| 146 CodecInst acmCodec; | 147 CodecInst acmCodec; |
| 147 if (channelPtr->GetSendCodec(acmCodec) != 0) { | 148 if (channelPtr->GetSendCodec(acmCodec) != 0) { |
| 148 _shared->SetLastError(VE_CANNOT_GET_SEND_CODEC, kTraceError, | 149 _shared->SetLastError(VE_CANNOT_GET_SEND_CODEC, kTraceError, |
| 149 "GetSendCodec() failed to get send codec"); | 150 "GetSendCodec() failed to get send codec"); |
| 150 return -1; | 151 return -1; |
| 151 } | 152 } |
| 152 ACMToExternalCodecRepresentation(codec, acmCodec); | 153 ACMToExternalCodecRepresentation(codec, acmCodec); |
| 153 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | 154 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 154 "GetSendCodec() => plname=%s, pacsize=%d, plfreq=%d, " | 155 "GetSendCodec() => plname=%s, pacsize=%d, plfreq=%d, " |
| 155 "channels=%d, rate=%d", | 156 "channels=%" PRIuS ", rate=%d", |
| 156 codec.plname, codec.pacsize, codec.plfreq, codec.channels, | 157 codec.plname, codec.pacsize, codec.plfreq, codec.channels, |
| 157 codec.rate); | 158 codec.rate); |
| 158 return 0; | 159 return 0; |
| 159 } | 160 } |
| 160 | 161 |
| 161 int VoECodecImpl::SetBitRate(int channel, int bitrate_bps) { | 162 int VoECodecImpl::SetBitRate(int channel, int bitrate_bps) { |
| 162 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 163 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 163 "SetBitRate(bitrate_bps=%d)", bitrate_bps); | 164 "SetBitRate(bitrate_bps=%d)", bitrate_bps); |
| 164 if (!_shared->statistics().Initialized()) { | 165 if (!_shared->statistics().Initialized()) { |
| 165 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 166 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 186 } | 187 } |
| 187 CodecInst acmCodec; | 188 CodecInst acmCodec; |
| 188 if (channelPtr->GetRecCodec(acmCodec) != 0) { | 189 if (channelPtr->GetRecCodec(acmCodec) != 0) { |
| 189 _shared->SetLastError(VE_CANNOT_GET_REC_CODEC, kTraceError, | 190 _shared->SetLastError(VE_CANNOT_GET_REC_CODEC, kTraceError, |
| 190 "GetRecCodec() failed to get received codec"); | 191 "GetRecCodec() failed to get received codec"); |
| 191 return -1; | 192 return -1; |
| 192 } | 193 } |
| 193 ACMToExternalCodecRepresentation(codec, acmCodec); | 194 ACMToExternalCodecRepresentation(codec, acmCodec); |
| 194 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | 195 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 195 "GetRecCodec() => plname=%s, pacsize=%d, plfreq=%d, " | 196 "GetRecCodec() => plname=%s, pacsize=%d, plfreq=%d, " |
| 196 "channels=%d, rate=%d", | 197 "channels=%" PRIuS ", rate=%d", |
| 197 codec.plname, codec.pacsize, codec.plfreq, codec.channels, | 198 codec.plname, codec.pacsize, codec.plfreq, codec.channels, |
| 198 codec.rate); | 199 codec.rate); |
| 199 return 0; | 200 return 0; |
| 200 } | 201 } |
| 201 | 202 |
| 202 int VoECodecImpl::SetRecPayloadType(int channel, const CodecInst& codec) { | 203 int VoECodecImpl::SetRecPayloadType(int channel, const CodecInst& codec) { |
| 203 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 204 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 204 "SetRecPayloadType(channel=%d, codec)", channel); | 205 "SetRecPayloadType(channel=%d, codec)", channel); |
| 205 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), | 206 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_shared->instance_id(), -1), |
| 206 "codec: plname=%s, plfreq=%d, pltype=%d, channels=%u, " | 207 "codec: plname=%s, plfreq=%d, pltype=%d, channels=%" PRIuS ", " |
| 207 "pacsize=%d, rate=%d", | 208 "pacsize=%d, rate=%d", |
| 208 codec.plname, codec.plfreq, codec.pltype, codec.channels, | 209 codec.plname, codec.plfreq, codec.pltype, codec.channels, |
| 209 codec.pacsize, codec.rate); | 210 codec.pacsize, codec.rate); |
| 210 if (!_shared->statistics().Initialized()) { | 211 if (!_shared->statistics().Initialized()) { |
| 211 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 212 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
| 212 return -1; | 213 return -1; |
| 213 } | 214 } |
| 214 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 215 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
| 215 voe::Channel* channelPtr = ch.channel(); | 216 voe::Channel* channelPtr = ch.channel(); |
| 216 if (channelPtr == NULL) { | 217 if (channelPtr == NULL) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } else if (fromInst.pacsize == 1440) { | 470 } else if (fromInst.pacsize == 1440) { |
| 470 toInst.pacsize = 1920; | 471 toInst.pacsize = 1920; |
| 471 } | 472 } |
| 472 } | 473 } |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 | 476 |
| 476 #endif // WEBRTC_VOICE_ENGINE_CODEC_API | 477 #endif // WEBRTC_VOICE_ENGINE_CODEC_API |
| 477 | 478 |
| 478 } // namespace webrtc | 479 } // namespace webrtc |
| OLD | NEW |