| 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/modules/audio_coding/main/acm2/audio_coding_module_impl.h" | 11 #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <stdlib.h> | 14 #include <stdlib.h> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/safe_conversions.h" | 18 #include "webrtc/base/safe_conversions.h" |
| 19 #include "webrtc/engine_configurations.h" | 19 #include "webrtc/engine_configurations.h" |
| 20 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" | 20 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" |
| 21 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" | 21 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" |
| 22 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" | 22 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" |
| 23 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" | 23 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" |
| 24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 25 #include "webrtc/system_wrappers/interface/logging.h" | 25 #include "webrtc/system_wrappers/interface/logging.h" |
| 26 #include "webrtc/system_wrappers/interface/metrics.h" | 26 #include "webrtc/system_wrappers/interface/metrics.h" |
| 27 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" | 27 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" |
| 28 #include "webrtc/system_wrappers/interface/trace.h" | 28 #include "webrtc/system_wrappers/interface/trace.h" |
| 29 #include "webrtc/typedefs.h" | 29 #include "webrtc/typedefs.h" |
| 30 #include "webrtc/video/rtc_event_log.h" | |
| 31 | 30 |
| 32 namespace webrtc { | 31 namespace webrtc { |
| 33 | 32 |
| 34 namespace acm2 { | 33 namespace acm2 { |
| 35 | 34 |
| 36 enum { | 35 enum { |
| 37 kACMToneEnd = 999 | 36 kACMToneEnd = 999 |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 // Maximum number of bytes in one packet (PCM16B, 20 ms packets, stereo). | 39 // Maximum number of bytes in one packet (PCM16B, 20 ms packets, stereo). |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 expected_codec_ts_(0xD87F3F9F), | 139 expected_codec_ts_(0xD87F3F9F), |
| 141 expected_in_ts_(0xD87F3F9F), | 140 expected_in_ts_(0xD87F3F9F), |
| 142 receiver_(config), | 141 receiver_(config), |
| 143 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), | 142 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), |
| 144 previous_pltype_(255), | 143 previous_pltype_(255), |
| 145 receiver_initialized_(false), | 144 receiver_initialized_(false), |
| 146 first_10ms_data_(false), | 145 first_10ms_data_(false), |
| 147 first_frame_(true), | 146 first_frame_(true), |
| 148 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 147 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 149 packetization_callback_(NULL), | 148 packetization_callback_(NULL), |
| 150 vad_callback_(NULL), | 149 vad_callback_(NULL) { |
| 151 event_log_(config.event_log) { | |
| 152 if (InitializeReceiverSafe() < 0) { | 150 if (InitializeReceiverSafe() < 0) { |
| 153 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 151 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
| 154 "Cannot initialize receiver"); | 152 "Cannot initialize receiver"); |
| 155 } | 153 } |
| 156 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); | 154 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); |
| 157 } | 155 } |
| 158 | 156 |
| 159 AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; | 157 AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; |
| 160 | 158 |
| 161 int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { | 159 int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 // Get 10 milliseconds of raw audio data to play out. | 673 // Get 10 milliseconds of raw audio data to play out. |
| 676 // Automatic resample to the requested frequency. | 674 // Automatic resample to the requested frequency. |
| 677 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, | 675 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, |
| 678 AudioFrame* audio_frame) { | 676 AudioFrame* audio_frame) { |
| 679 // GetAudio always returns 10 ms, at the requested sample rate. | 677 // GetAudio always returns 10 ms, at the requested sample rate. |
| 680 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { | 678 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { |
| 681 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 679 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
| 682 "PlayoutData failed, RecOut Failed"); | 680 "PlayoutData failed, RecOut Failed"); |
| 683 return -1; | 681 return -1; |
| 684 } | 682 } |
| 685 { | |
| 686 if (event_log_) | |
| 687 event_log_->LogDebugEvent(RtcEventLog::DebugEvent::kAudioPlayout); | |
| 688 } | |
| 689 | |
| 690 audio_frame->id_ = id_; | 683 audio_frame->id_ = id_; |
| 691 return 0; | 684 return 0; |
| 692 } | 685 } |
| 693 | 686 |
| 694 ///////////////////////////////////////// | 687 ///////////////////////////////////////// |
| 695 // Statistics | 688 // Statistics |
| 696 // | 689 // |
| 697 | 690 |
| 698 // TODO(turajs) change the return value to void. Also change the corresponding | 691 // TODO(turajs) change the return value to void. Also change the corresponding |
| 699 // NetEq function. | 692 // NetEq function. |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 *sample_rate_hz = 8000; | 1128 *sample_rate_hz = 8000; |
| 1136 *channels = 1; | 1129 *channels = 1; |
| 1137 break; | 1130 break; |
| 1138 default: | 1131 default: |
| 1139 FATAL() << "Codec type " << codec_type << " not supported."; | 1132 FATAL() << "Codec type " << codec_type << " not supported."; |
| 1140 } | 1133 } |
| 1141 return true; | 1134 return true; |
| 1142 } | 1135 } |
| 1143 | 1136 |
| 1144 } // namespace webrtc | 1137 } // namespace webrtc |
| OLD | NEW |