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/output_mixer.h" | 11 #include "webrtc/voice_engine/output_mixer.h" |
12 | 12 |
13 #include "webrtc/audio/utility/audio_frame_operations.h" | 13 #include "webrtc/audio/utility/audio_frame_operations.h" |
14 #include "webrtc/base/format_macros.h" | 14 #include "webrtc/base/format_macros.h" |
15 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 15 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
16 #include "webrtc/system_wrappers/include/file_wrapper.h" | 16 #include "webrtc/system_wrappers/include/file_wrapper.h" |
17 #include "webrtc/system_wrappers/include/trace.h" | 17 #include "webrtc/system_wrappers/include/trace.h" |
18 #include "webrtc/voice_engine/include/voe_external_media.h" | |
19 #include "webrtc/voice_engine/statistics.h" | 18 #include "webrtc/voice_engine/statistics.h" |
20 #include "webrtc/voice_engine/utility.h" | 19 #include "webrtc/voice_engine/utility.h" |
21 | 20 |
22 namespace webrtc { | 21 namespace webrtc { |
23 namespace voe { | 22 namespace voe { |
24 | 23 |
25 void | 24 void |
26 OutputMixer::NewMixedAudio(int32_t id, | 25 OutputMixer::NewMixedAudio(int32_t id, |
27 const AudioFrame& generalAudioFrame, | 26 const AudioFrame& generalAudioFrame, |
28 const AudioFrame** uniqueAudioFrames, | 27 const AudioFrame** uniqueAudioFrames, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 "mixer"); | 86 "mixer"); |
88 return -1; | 87 return -1; |
89 } | 88 } |
90 return 0; | 89 return 0; |
91 } | 90 } |
92 | 91 |
93 OutputMixer::OutputMixer(uint32_t instanceId) : | 92 OutputMixer::OutputMixer(uint32_t instanceId) : |
94 _mixerModule(*AudioConferenceMixer::Create(instanceId)), | 93 _mixerModule(*AudioConferenceMixer::Create(instanceId)), |
95 _audioLevel(), | 94 _audioLevel(), |
96 _instanceId(instanceId), | 95 _instanceId(instanceId), |
97 _externalMediaCallbackPtr(NULL), | |
98 _externalMedia(false), | |
99 _panLeft(1.0f), | 96 _panLeft(1.0f), |
100 _panRight(1.0f), | 97 _panRight(1.0f), |
101 _mixingFrequencyHz(8000), | 98 _mixingFrequencyHz(8000), |
102 _outputFileRecording(false) | 99 _outputFileRecording(false) |
103 { | 100 { |
104 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 101 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), |
105 "OutputMixer::OutputMixer() - ctor"); | 102 "OutputMixer::OutputMixer() - ctor"); |
106 | 103 |
107 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) | 104 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) |
108 { | 105 { |
(...skipping 10 matching lines...) Expand all Loading... |
119 { | 116 { |
120 delete mixer; | 117 delete mixer; |
121 mixer = NULL; | 118 mixer = NULL; |
122 } | 119 } |
123 } | 120 } |
124 | 121 |
125 OutputMixer::~OutputMixer() | 122 OutputMixer::~OutputMixer() |
126 { | 123 { |
127 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 124 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), |
128 "OutputMixer::~OutputMixer() - dtor"); | 125 "OutputMixer::~OutputMixer() - dtor"); |
129 if (_externalMedia) | |
130 { | |
131 DeRegisterExternalMediaProcessing(); | |
132 } | |
133 { | 126 { |
134 rtc::CritScope cs(&_fileCritSect); | 127 rtc::CritScope cs(&_fileCritSect); |
135 if (output_file_recorder_) { | 128 if (output_file_recorder_) { |
136 output_file_recorder_->RegisterModuleFileCallback(NULL); | 129 output_file_recorder_->RegisterModuleFileCallback(NULL); |
137 output_file_recorder_->StopRecording(); | 130 output_file_recorder_->StopRecording(); |
138 } | 131 } |
139 } | 132 } |
140 _mixerModule.UnRegisterMixedStreamCallback(); | 133 _mixerModule.UnRegisterMixedStreamCallback(); |
141 delete &_mixerModule; | 134 delete &_mixerModule; |
142 } | 135 } |
(...skipping 10 matching lines...) Expand all Loading... |
153 int32_t | 146 int32_t |
154 OutputMixer::SetAudioProcessingModule(AudioProcessing* audioProcessingModule) | 147 OutputMixer::SetAudioProcessingModule(AudioProcessing* audioProcessingModule) |
155 { | 148 { |
156 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | 149 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), |
157 "OutputMixer::SetAudioProcessingModule(" | 150 "OutputMixer::SetAudioProcessingModule(" |
158 "audioProcessingModule=0x%x)", audioProcessingModule); | 151 "audioProcessingModule=0x%x)", audioProcessingModule); |
159 _audioProcessingModulePtr = audioProcessingModule; | 152 _audioProcessingModulePtr = audioProcessingModule; |
160 return 0; | 153 return 0; |
161 } | 154 } |
162 | 155 |
163 int OutputMixer::RegisterExternalMediaProcessing( | |
164 VoEMediaProcess& proccess_object) | |
165 { | |
166 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | |
167 "OutputMixer::RegisterExternalMediaProcessing()"); | |
168 | |
169 rtc::CritScope cs(&_callbackCritSect); | |
170 _externalMediaCallbackPtr = &proccess_object; | |
171 _externalMedia = true; | |
172 | |
173 return 0; | |
174 } | |
175 | |
176 int OutputMixer::DeRegisterExternalMediaProcessing() | |
177 { | |
178 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | |
179 "OutputMixer::DeRegisterExternalMediaProcessing()"); | |
180 | |
181 rtc::CritScope cs(&_callbackCritSect); | |
182 _externalMedia = false; | |
183 _externalMediaCallbackPtr = NULL; | |
184 | |
185 return 0; | |
186 } | |
187 | |
188 int32_t | 156 int32_t |
189 OutputMixer::SetMixabilityStatus(MixerParticipant& participant, | 157 OutputMixer::SetMixabilityStatus(MixerParticipant& participant, |
190 bool mixable) | 158 bool mixable) |
191 { | 159 { |
192 return _mixerModule.SetMixabilityStatus(&participant, mixable); | 160 return _mixerModule.SetMixabilityStatus(&participant, mixable); |
193 } | 161 } |
194 | 162 |
195 int32_t | 163 int32_t |
196 OutputMixer::SetAnonymousMixabilityStatus(MixerParticipant& participant, | 164 OutputMixer::SetAnonymousMixabilityStatus(MixerParticipant& participant, |
197 bool mixable) | 165 bool mixable) |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 440 |
473 // --- Far-end Voice Quality Enhancement (AudioProcessing Module) | 441 // --- Far-end Voice Quality Enhancement (AudioProcessing Module) |
474 if (feed_data_to_apm) { | 442 if (feed_data_to_apm) { |
475 if (_audioProcessingModulePtr->ProcessReverseStream(&_audioFrame) != 0) { | 443 if (_audioProcessingModulePtr->ProcessReverseStream(&_audioFrame) != 0) { |
476 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), | 444 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), |
477 "AudioProcessingModule::ProcessReverseStream() => error"); | 445 "AudioProcessingModule::ProcessReverseStream() => error"); |
478 RTC_NOTREACHED(); | 446 RTC_NOTREACHED(); |
479 } | 447 } |
480 } | 448 } |
481 | 449 |
482 // --- External media processing | |
483 { | |
484 rtc::CritScope cs(&_callbackCritSect); | |
485 if (_externalMedia) | |
486 { | |
487 const bool is_stereo = (_audioFrame.num_channels_ == 2); | |
488 if (_externalMediaCallbackPtr) | |
489 { | |
490 _externalMediaCallbackPtr->Process( | |
491 -1, | |
492 kPlaybackAllChannelsMixed, | |
493 (int16_t*)_audioFrame.data_, | |
494 _audioFrame.samples_per_channel_, | |
495 _audioFrame.sample_rate_hz_, | |
496 is_stereo); | |
497 } | |
498 } | |
499 } | |
500 | |
501 // --- Measure audio level (0-9) for the combined signal | 450 // --- Measure audio level (0-9) for the combined signal |
502 _audioLevel.ComputeLevel(_audioFrame); | 451 _audioLevel.ComputeLevel(_audioFrame); |
503 | 452 |
504 return 0; | 453 return 0; |
505 } | 454 } |
506 } // namespace voe | 455 } // namespace voe |
507 } // namespace webrtc | 456 } // namespace webrtc |
OLD | NEW |