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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 expected_in_ts_(0xD87F3F9F), | 139 expected_in_ts_(0xD87F3F9F), |
139 receiver_(config), | 140 receiver_(config), |
140 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), | 141 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), |
141 previous_pltype_(255), | 142 previous_pltype_(255), |
142 aux_rtp_header_(NULL), | 143 aux_rtp_header_(NULL), |
143 receiver_initialized_(false), | 144 receiver_initialized_(false), |
144 first_10ms_data_(false), | 145 first_10ms_data_(false), |
145 first_frame_(true), | 146 first_frame_(true), |
146 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 147 callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
147 packetization_callback_(NULL), | 148 packetization_callback_(NULL), |
148 vad_callback_(NULL) { | 149 vad_callback_(NULL), |
| 150 event_log_(nullptr) { |
149 if (InitializeReceiverSafe() < 0) { | 151 if (InitializeReceiverSafe() < 0) { |
150 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 152 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
151 "Cannot initialize receiver"); | 153 "Cannot initialize receiver"); |
152 } | 154 } |
153 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); | 155 WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); |
154 } | 156 } |
155 | 157 |
156 AudioCodingModuleImpl::~AudioCodingModuleImpl() { | 158 AudioCodingModuleImpl::~AudioCodingModuleImpl() { |
157 if (aux_rtp_header_ != NULL) { | 159 if (aux_rtp_header_ != NULL) { |
158 delete aux_rtp_header_; | 160 delete aux_rtp_header_; |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 // Get 10 milliseconds of raw audio data to play out. | 731 // Get 10 milliseconds of raw audio data to play out. |
730 // Automatic resample to the requested frequency. | 732 // Automatic resample to the requested frequency. |
731 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, | 733 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, |
732 AudioFrame* audio_frame) { | 734 AudioFrame* audio_frame) { |
733 // GetAudio always returns 10 ms, at the requested sample rate. | 735 // GetAudio always returns 10 ms, at the requested sample rate. |
734 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { | 736 if (receiver_.GetAudio(desired_freq_hz, audio_frame) != 0) { |
735 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, | 737 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, |
736 "PlayoutData failed, RecOut Failed"); | 738 "PlayoutData failed, RecOut Failed"); |
737 return -1; | 739 return -1; |
738 } | 740 } |
| 741 if (event_log_) |
| 742 event_log_->LogDebugEvent(RtcEventLog::DebugEvent::kAudioPlayout); |
739 | 743 |
740 audio_frame->id_ = id_; | 744 audio_frame->id_ = id_; |
741 return 0; | 745 return 0; |
742 } | 746 } |
743 | 747 |
744 ///////////////////////////////////////// | 748 ///////////////////////////////////////// |
745 // Statistics | 749 // Statistics |
746 // | 750 // |
747 | 751 |
748 // TODO(turajs) change the return value to void. Also change the corresponding | 752 // TODO(turajs) change the return value to void. Also change the corresponding |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } | 968 } |
965 | 969 |
966 int AudioCodingModuleImpl::EnableNack(size_t max_nack_list_size) { | 970 int AudioCodingModuleImpl::EnableNack(size_t max_nack_list_size) { |
967 return receiver_.EnableNack(max_nack_list_size); | 971 return receiver_.EnableNack(max_nack_list_size); |
968 } | 972 } |
969 | 973 |
970 void AudioCodingModuleImpl::DisableNack() { | 974 void AudioCodingModuleImpl::DisableNack() { |
971 receiver_.DisableNack(); | 975 receiver_.DisableNack(); |
972 } | 976 } |
973 | 977 |
| 978 void AudioCodingModuleImpl::SetEventLog(RtcEventLog* event_log) { |
| 979 event_log_ = event_log; |
| 980 } |
| 981 |
974 std::vector<uint16_t> AudioCodingModuleImpl::GetNackList( | 982 std::vector<uint16_t> AudioCodingModuleImpl::GetNackList( |
975 int64_t round_trip_time_ms) const { | 983 int64_t round_trip_time_ms) const { |
976 return receiver_.GetNackList(round_trip_time_ms); | 984 return receiver_.GetNackList(round_trip_time_ms); |
977 } | 985 } |
978 | 986 |
979 int AudioCodingModuleImpl::LeastRequiredDelayMs() const { | 987 int AudioCodingModuleImpl::LeastRequiredDelayMs() const { |
980 return receiver_.LeastRequiredDelayMs(); | 988 return receiver_.LeastRequiredDelayMs(); |
981 } | 989 } |
982 | 990 |
983 void AudioCodingModuleImpl::GetDecodingCallStatistics( | 991 void AudioCodingModuleImpl::GetDecodingCallStatistics( |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 *channels = 1; | 1281 *channels = 1; |
1274 break; | 1282 break; |
1275 #endif | 1283 #endif |
1276 default: | 1284 default: |
1277 FATAL() << "Codec type " << codec_type << " not supported."; | 1285 FATAL() << "Codec type " << codec_type << " not supported."; |
1278 } | 1286 } |
1279 return true; | 1287 return true; |
1280 } | 1288 } |
1281 | 1289 |
1282 } // namespace webrtc | 1290 } // namespace webrtc |
OLD | NEW |