Chromium Code Reviews| 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_mixer/audio_mixer_impl.h" | 11 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 
| 12 | 12 | 
| 13 #include <algorithm> | 13 #include <algorithm> | 
| 14 #include <functional> | 14 #include <functional> | 
| 15 | 15 | 
| 16 #include "webrtc/base/thread_annotations.h" | 16 #include "webrtc/base/thread_annotations.h" | 
| 17 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h" | 17 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h" | 
| 18 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 18 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 
| 
 
aleloi
2016/09/01 14:12:22
Duplicate between .cc and .h
 
 | |
| 19 #include "webrtc/modules/audio_processing/include/audio_processing.h" | |
| 20 #include "webrtc/modules/utility/include/audio_frame_operations.h" | 19 #include "webrtc/modules/utility/include/audio_frame_operations.h" | 
| 21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 
 
aleloi
2016/09/01 14:12:21
Shouldn't include headers in .cc file that are dup
 
 | |
| 22 #include "webrtc/system_wrappers/include/trace.h" | 20 #include "webrtc/system_wrappers/include/trace.h" | 
| 23 | 21 | 
| 24 namespace webrtc { | 22 namespace webrtc { | 
| 25 namespace { | 23 namespace { | 
| 26 | 24 | 
| 27 class SourceFrame { | 25 class SourceFrame { | 
| 28 public: | 26 public: | 
| 29 SourceFrame(MixerAudioSource* p, AudioFrame* a, bool m, bool was_mixed_before) | 27 SourceFrame(MixerAudioSource* p, AudioFrame* a, bool m, bool was_mixed_before) | 
| 30 : audio_source_(p), | 28 : audio_source_(p), | 
| 31 audio_frame_(a), | 29 audio_frame_(a), | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 const bool is_mixed = source_frame.audio_source_->mix_history_->IsMixed(); | 88 const bool is_mixed = source_frame.audio_source_->mix_history_->IsMixed(); | 
| 91 // Ramp out currently unmixed. | 89 // Ramp out currently unmixed. | 
| 92 if (source_frame.was_mixed_before_ && !is_mixed) { | 90 if (source_frame.was_mixed_before_ && !is_mixed) { | 
| 93 NewMixerRampOut(source_frame.audio_frame_); | 91 NewMixerRampOut(source_frame.audio_frame_); | 
| 94 } | 92 } | 
| 95 } | 93 } | 
| 96 } | 94 } | 
| 97 | 95 | 
| 98 } // namespace | 96 } // namespace | 
| 99 | 97 | 
| 100 MixerAudioSource::MixerAudioSource() : mix_history_(new NewMixHistory()) {} | |
| 101 | |
| 102 MixerAudioSource::~MixerAudioSource() { | |
| 103 delete mix_history_; | |
| 104 } | |
| 105 | |
| 106 bool MixerAudioSource::IsMixed() const { | |
| 107 return mix_history_->IsMixed(); | |
| 108 } | |
| 109 | |
| 110 NewMixHistory::NewMixHistory() : is_mixed_(0) {} | |
| 111 | |
| 112 NewMixHistory::~NewMixHistory() {} | |
| 113 | |
| 114 bool NewMixHistory::IsMixed() const { | |
| 115 return is_mixed_; | |
| 116 } | |
| 117 | |
| 118 bool NewMixHistory::WasMixed() const { | |
| 119 // Was mixed is the same as is mixed depending on perspective. This function | |
| 120 // is for the perspective of NewAudioConferenceMixerImpl. | |
| 121 return IsMixed(); | |
| 122 } | |
| 123 | |
| 124 int32_t NewMixHistory::SetIsMixed(const bool mixed) { | |
| 125 is_mixed_ = mixed; | |
| 126 return 0; | |
| 127 } | |
| 128 | |
| 129 void NewMixHistory::ResetMixedStatus() { | |
| 130 is_mixed_ = false; | |
| 131 } | |
| 132 | |
| 133 std::unique_ptr<AudioMixer> AudioMixer::Create(int id) { | 98 std::unique_ptr<AudioMixer> AudioMixer::Create(int id) { | 
| 134 AudioMixerImpl* mixer = new AudioMixerImpl(id); | 99 AudioMixerImpl* mixer = new AudioMixerImpl(id); | 
| 135 if (!mixer->Init()) { | 100 if (!mixer->Init()) { | 
| 136 delete mixer; | 101 delete mixer; | 
| 137 return NULL; | 102 return NULL; | 
| 138 } | 103 } | 
| 139 return std::unique_ptr<AudioMixer>(mixer); | 104 return std::unique_ptr<AudioMixer>(mixer); | 
| 140 } | 105 } | 
| 141 | 106 | 
| 142 AudioMixerImpl::AudioMixerImpl(int id) | 107 AudioMixerImpl::AudioMixerImpl(int id) | 
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 } | 525 } | 
| 561 | 526 | 
| 562 int AudioMixerImpl::GetOutputAudioLevelFullRange() { | 527 int AudioMixerImpl::GetOutputAudioLevelFullRange() { | 
| 563 RTC_DCHECK_RUN_ON(&thread_checker_); | 528 RTC_DCHECK_RUN_ON(&thread_checker_); | 
| 564 const int level = audio_level_.LevelFullRange(); | 529 const int level = audio_level_.LevelFullRange(); | 
| 565 WEBRTC_TRACE(kTraceStateInfo, kTraceAudioMixerServer, id_, | 530 WEBRTC_TRACE(kTraceStateInfo, kTraceAudioMixerServer, id_, | 
| 566 "GetAudioOutputLevelFullRange() => level=%d", level); | 531 "GetAudioOutputLevelFullRange() => level=%d", level); | 
| 567 return level; | 532 return level; | 
| 568 } | 533 } | 
| 569 } // namespace webrtc | 534 } // namespace webrtc | 
| OLD | NEW |