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/channel.h" | 11 #include "webrtc/voice_engine/channel.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <utility> |
14 | 15 |
15 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/format_macros.h" | 17 #include "webrtc/base/format_macros.h" |
17 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/thread_checker.h" | 19 #include "webrtc/base/thread_checker.h" |
19 #include "webrtc/base/timeutils.h" | 20 #include "webrtc/base/timeutils.h" |
20 #include "webrtc/common.h" | 21 #include "webrtc/common.h" |
21 #include "webrtc/config.h" | 22 #include "webrtc/config.h" |
22 #include "webrtc/modules/audio_device/include/audio_device.h" | 23 #include "webrtc/modules/audio_device/include/audio_device.h" |
23 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 24 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 ChannelState::State state = channel_state_.Get(); | 554 ChannelState::State state = channel_state_.Get(); |
554 | 555 |
555 if (state.rx_apm_is_enabled) { | 556 if (state.rx_apm_is_enabled) { |
556 int err = rx_audioproc_->ProcessStream(audioFrame); | 557 int err = rx_audioproc_->ProcessStream(audioFrame); |
557 if (err) { | 558 if (err) { |
558 LOG(LS_ERROR) << "ProcessStream() error: " << err; | 559 LOG(LS_ERROR) << "ProcessStream() error: " << err; |
559 assert(false); | 560 assert(false); |
560 } | 561 } |
561 } | 562 } |
562 | 563 |
| 564 { |
| 565 // Pass the audio buffers to an optional sink callback, before applying |
| 566 // scaling/panning, as that applies to the mix operation. |
| 567 // External recipients of the audio (e.g. via AudioTrack), will do their |
| 568 // own mixing/dynamic processing. |
| 569 CriticalSectionScoped cs(&_callbackCritSect); |
| 570 if (audio_sink_) { |
| 571 AudioSinkInterface::Data data( |
| 572 &audioFrame->data_[0], |
| 573 audioFrame->samples_per_channel_, audioFrame->sample_rate_hz_, |
| 574 audioFrame->num_channels_, audioFrame->timestamp_); |
| 575 audio_sink_->OnData(data); |
| 576 } |
| 577 } |
| 578 |
563 float output_gain = 1.0f; | 579 float output_gain = 1.0f; |
564 float left_pan = 1.0f; | 580 float left_pan = 1.0f; |
565 float right_pan = 1.0f; | 581 float right_pan = 1.0f; |
566 { | 582 { |
567 CriticalSectionScoped cs(&volume_settings_critsect_); | 583 CriticalSectionScoped cs(&volume_settings_critsect_); |
568 output_gain = _outputGain; | 584 output_gain = _outputGain; |
569 left_pan = _panLeft; | 585 left_pan = _panLeft; |
570 right_pan= _panRight; | 586 right_pan= _panRight; |
571 } | 587 } |
572 | 588 |
(...skipping 28 matching lines...) Expand all Loading... |
601 MixAudioWithFile(*audioFrame, audioFrame->sample_rate_hz_); | 617 MixAudioWithFile(*audioFrame, audioFrame->sample_rate_hz_); |
602 } | 618 } |
603 | 619 |
604 // External media | 620 // External media |
605 if (_outputExternalMedia) | 621 if (_outputExternalMedia) |
606 { | 622 { |
607 CriticalSectionScoped cs(&_callbackCritSect); | 623 CriticalSectionScoped cs(&_callbackCritSect); |
608 const bool isStereo = (audioFrame->num_channels_ == 2); | 624 const bool isStereo = (audioFrame->num_channels_ == 2); |
609 if (_outputExternalMediaCallbackPtr) | 625 if (_outputExternalMediaCallbackPtr) |
610 { | 626 { |
611 _outputExternalMediaCallbackPtr->Process( | 627 _outputExternalMediaCallbackPtr->Process( |
612 _channelId, | 628 _channelId, kPlaybackPerChannel, (int16_t*)audioFrame->data_, |
613 kPlaybackPerChannel, | 629 audioFrame->samples_per_channel_, audioFrame->sample_rate_hz_, |
614 (int16_t*)audioFrame->data_, | 630 isStereo); |
615 audioFrame->samples_per_channel_, | |
616 audioFrame->sample_rate_hz_, | |
617 isStereo); | |
618 } | 631 } |
619 } | 632 } |
620 | 633 |
621 // Record playout if enabled | 634 // Record playout if enabled |
622 { | 635 { |
623 CriticalSectionScoped cs(&_fileCritSect); | 636 CriticalSectionScoped cs(&_fileCritSect); |
624 | 637 |
625 if (_outputFileRecording && _outputFileRecorderPtr) | 638 if (_outputFileRecording && _outputFileRecorderPtr) |
626 { | 639 { |
627 _outputFileRecorderPtr->RecordAudioToFile(*audioFrame); | 640 _outputFileRecorderPtr->RecordAudioToFile(*audioFrame); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 } | 1178 } |
1166 | 1179 |
1167 int32_t | 1180 int32_t |
1168 Channel::UpdateLocalTimeStamp() | 1181 Channel::UpdateLocalTimeStamp() |
1169 { | 1182 { |
1170 | 1183 |
1171 _timeStamp += static_cast<uint32_t>(_audioFrame.samples_per_channel_); | 1184 _timeStamp += static_cast<uint32_t>(_audioFrame.samples_per_channel_); |
1172 return 0; | 1185 return 0; |
1173 } | 1186 } |
1174 | 1187 |
| 1188 void Channel::SetSink(rtc::scoped_ptr<AudioSinkInterface> sink) { |
| 1189 CriticalSectionScoped cs(&_callbackCritSect); |
| 1190 audio_sink_ = std::move(sink); |
| 1191 } |
| 1192 |
1175 int32_t | 1193 int32_t |
1176 Channel::StartPlayout() | 1194 Channel::StartPlayout() |
1177 { | 1195 { |
1178 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 1196 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
1179 "Channel::StartPlayout()"); | 1197 "Channel::StartPlayout()"); |
1180 if (channel_state_.Get().playing) | 1198 if (channel_state_.Get().playing) |
1181 { | 1199 { |
1182 return 0; | 1200 return 0; |
1183 } | 1201 } |
1184 | 1202 |
(...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4086 int64_t min_rtt = 0; | 4104 int64_t min_rtt = 0; |
4087 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4105 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
4088 != 0) { | 4106 != 0) { |
4089 return 0; | 4107 return 0; |
4090 } | 4108 } |
4091 return rtt; | 4109 return rtt; |
4092 } | 4110 } |
4093 | 4111 |
4094 } // namespace voe | 4112 } // namespace voe |
4095 } // namespace webrtc | 4113 } // namespace webrtc |
OLD | NEW |