| 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 "voice_engine/shared_data.h" | 11 #include "voice_engine/shared_data.h" |
| 12 | 12 |
| 13 #include "modules/audio_processing/include/audio_processing.h" | 13 #include "modules/audio_processing/include/audio_processing.h" |
| 14 #include "system_wrappers/include/trace.h" | 14 #include "system_wrappers/include/trace.h" |
| 15 #include "voice_engine/channel.h" | 15 #include "voice_engine/channel.h" |
| 16 #include "voice_engine/output_mixer.h" | |
| 17 #include "voice_engine/transmit_mixer.h" | 16 #include "voice_engine/transmit_mixer.h" |
| 18 | 17 |
| 19 namespace webrtc { | 18 namespace webrtc { |
| 20 | 19 |
| 21 namespace voe { | 20 namespace voe { |
| 22 | 21 |
| 23 static int32_t _gInstanceCounter = 0; | 22 static int32_t _gInstanceCounter = 0; |
| 24 | 23 |
| 25 SharedData::SharedData() | 24 SharedData::SharedData() |
| 26 : _instanceId(++_gInstanceCounter), | 25 : _instanceId(++_gInstanceCounter), |
| 27 _channelManager(_gInstanceCounter), | 26 _channelManager(_gInstanceCounter), |
| 28 _engineStatistics(_gInstanceCounter), | 27 _engineStatistics(_gInstanceCounter), |
| 29 _audioDevicePtr(NULL), | 28 _audioDevicePtr(NULL), |
| 30 _moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")), | 29 _moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")), |
| 31 encoder_queue_("AudioEncoderQueue") { | 30 encoder_queue_("AudioEncoderQueue") { |
| 32 Trace::CreateTrace(); | 31 Trace::CreateTrace(); |
| 33 if (OutputMixer::Create(_outputMixerPtr, _gInstanceCounter) == 0) { | |
| 34 _outputMixerPtr->SetEngineInformation(_engineStatistics); | |
| 35 } | |
| 36 if (TransmitMixer::Create(_transmitMixerPtr, _gInstanceCounter) == 0) { | 32 if (TransmitMixer::Create(_transmitMixerPtr, _gInstanceCounter) == 0) { |
| 37 _transmitMixerPtr->SetEngineInformation(*_moduleProcessThreadPtr, | 33 _transmitMixerPtr->SetEngineInformation(*_moduleProcessThreadPtr, |
| 38 _engineStatistics, _channelManager); | 34 _engineStatistics, _channelManager); |
| 39 } | 35 } |
| 40 } | 36 } |
| 41 | 37 |
| 42 SharedData::~SharedData() | 38 SharedData::~SharedData() |
| 43 { | 39 { |
| 44 OutputMixer::Destroy(_outputMixerPtr); | |
| 45 TransmitMixer::Destroy(_transmitMixerPtr); | 40 TransmitMixer::Destroy(_transmitMixerPtr); |
| 46 if (_audioDevicePtr) { | 41 if (_audioDevicePtr) { |
| 47 _audioDevicePtr->Release(); | 42 _audioDevicePtr->Release(); |
| 48 } | 43 } |
| 49 _moduleProcessThreadPtr->Stop(); | 44 _moduleProcessThreadPtr->Stop(); |
| 50 Trace::ReturnTrace(); | 45 Trace::ReturnTrace(); |
| 51 } | 46 } |
| 52 | 47 |
| 53 rtc::TaskQueue* SharedData::encoder_queue() { | 48 rtc::TaskQueue* SharedData::encoder_queue() { |
| 54 RTC_DCHECK_RUN_ON(&construction_thread_); | 49 RTC_DCHECK_RUN_ON(&construction_thread_); |
| 55 return &encoder_queue_; | 50 return &encoder_queue_; |
| 56 } | 51 } |
| 57 | 52 |
| 58 void SharedData::set_audio_device( | 53 void SharedData::set_audio_device( |
| 59 const rtc::scoped_refptr<AudioDeviceModule>& audio_device) { | 54 const rtc::scoped_refptr<AudioDeviceModule>& audio_device) { |
| 60 _audioDevicePtr = audio_device; | 55 _audioDevicePtr = audio_device; |
| 61 } | 56 } |
| 62 | 57 |
| 63 void SharedData::set_audio_processing(AudioProcessing* audioproc) { | 58 void SharedData::set_audio_processing(AudioProcessing* audioproc) { |
| 64 _transmitMixerPtr->SetAudioProcessingModule(audioproc); | 59 _transmitMixerPtr->SetAudioProcessingModule(audioproc); |
| 65 _outputMixerPtr->SetAudioProcessingModule(audioproc); | |
| 66 } | 60 } |
| 67 | 61 |
| 68 int SharedData::NumOfSendingChannels() { | 62 int SharedData::NumOfSendingChannels() { |
| 69 ChannelManager::Iterator it(&_channelManager); | 63 ChannelManager::Iterator it(&_channelManager); |
| 70 int sending_channels = 0; | 64 int sending_channels = 0; |
| 71 | 65 |
| 72 for (ChannelManager::Iterator it(&_channelManager); it.IsValid(); | 66 for (ChannelManager::Iterator it(&_channelManager); it.IsValid(); |
| 73 it.Increment()) { | 67 it.Increment()) { |
| 74 if (it.GetChannel()->Sending()) | 68 if (it.GetChannel()->Sending()) |
| 75 ++sending_channels; | 69 ++sending_channels; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 } | 95 } |
| 102 | 96 |
| 103 void SharedData::SetLastError(int32_t error, TraceLevel level, | 97 void SharedData::SetLastError(int32_t error, TraceLevel level, |
| 104 const char* msg) const { | 98 const char* msg) const { |
| 105 _engineStatistics.SetLastError(error, level, msg); | 99 _engineStatistics.SetLastError(error, level, msg); |
| 106 } | 100 } |
| 107 | 101 |
| 108 } // namespace voe | 102 } // namespace voe |
| 109 | 103 |
| 110 } // namespace webrtc | 104 } // namespace webrtc |
| OLD | NEW |