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" |
30 | 31 |
31 namespace webrtc { | 32 namespace webrtc { |
32 | 33 |
33 namespace acm2 { | 34 namespace acm2 { |
34 | 35 |
35 enum { | 36 enum { |
36 kACMToneEnd = 999 | 37 kACMToneEnd = 999 |
37 }; | 38 }; |
38 | 39 |
39 // Maximum number of bytes in one packet (PCM16B, 20 ms packets, stereo). | 40 // 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... |
139 expected_codec_ts_(0xD87F3F9F), | 140 expected_codec_ts_(0xD87F3F9F), |
140 expected_in_ts_(0xD87F3F9F), | 141 expected_in_ts_(0xD87F3F9F), |
141 receiver_(config), | 142 receiver_(config), |
142 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), | 143 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), |
143 previous_pltype_(255), | 144 previous_pltype_(255), |
144 receiver_initialized_(false), | 145 receiver_initialized_(false), |
145 first_10ms_data_(false), | 146 first_10ms_data_(false), |
146 first_frame_(true), | 147 first_frame_(true), |
147 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 148 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
148 packetization_callback_(NULL), | 149 packetization_callback_(NULL), |
149 vad_callback_(NULL) { | 150 vad_callback_(NULL), |
| 151 event_log_(config.event_log) { |
150 if (InitializeReceiverSafe() < 0) { | 152 if (InitializeReceiverSafe() < 0) { |
151 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 153 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
152 "Cannot initialize receiver"); | 154 "Cannot initialize receiver"); |
153 } | 155 } |
154 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); | 156 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); |
155 } | 157 } |
156 | 158 |
157 AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; | 159 AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; |
158 | 160 |
159 int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { | 161 int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // Get 10 milliseconds of raw audio data to play out. | 675 // Get 10 milliseconds of raw audio data to play out. |
674 // Automatic resample to the requested frequency. | 676 // Automatic resample to the requested frequency. |
675 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, | 677 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, |
676 AudioFrame* audio_frame) { | 678 AudioFrame* audio_frame) { |
677 // GetAudio always returns 10 ms, at the requested sample rate. | 679 // GetAudio always returns 10 ms, at the requested sample rate. |
678 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { | 680 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { |
679 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 681 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
680 "PlayoutData failed, RecOut Failed"); | 682 "PlayoutData failed, RecOut Failed"); |
681 return -1; | 683 return -1; |
682 } | 684 } |
| 685 { |
| 686 if (event_log_) |
| 687 event_log_->LogDebugEvent(RtcEventLog::DebugEvent::kAudioPlayout); |
| 688 } |
683 | 689 |
684 audio_frame->id_ = id_; | 690 audio_frame->id_ = id_; |
685 return 0; | 691 return 0; |
686 } | 692 } |
687 | 693 |
688 ///////////////////////////////////////// | 694 ///////////////////////////////////////// |
689 // Statistics | 695 // Statistics |
690 // | 696 // |
691 | 697 |
692 // TODO(turajs) change the return value to void. Also change the corresponding | 698 // TODO(turajs) change the return value to void. Also change the corresponding |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 *channels = 1; | 1163 *channels = 1; |
1158 break; | 1164 break; |
1159 #endif | 1165 #endif |
1160 default: | 1166 default: |
1161 FATAL() << "Codec type " << codec_type << " not supported."; | 1167 FATAL() << "Codec type " << codec_type << " not supported."; |
1162 } | 1168 } |
1163 return true; | 1169 return true; |
1164 } | 1170 } |
1165 | 1171 |
1166 } // namespace webrtc | 1172 } // namespace webrtc |
OLD | NEW |