1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef VOICE_ENGINE_SHARED_DATA_H_ 12 #define VOICE_ENGINE_SHARED_DATA_H_ 13 14 #include <memory> 15 16 #include "modules/audio_device/include/audio_device.h" 17 #include "modules/audio_processing/include/audio_processing.h" 18 #include "modules/utility/include/process_thread.h" 19 #include "rtc_base/criticalsection.h" 20 #include "rtc_base/scoped_ref_ptr.h" 21 #include "rtc_base/task_queue.h" 22 #include "rtc_base/thread_annotations.h" 23 #include "rtc_base/thread_checker.h" 24 #include "voice_engine/channel_manager.h" 25 26 class ProcessThread; 27 28 namespace webrtc { 29 namespace voe { 30 31 class TransmitMixer; 32 33 class SharedData 34 { 35 public: 36 // Public accessors. instance_id()37 uint32_t instance_id() const { return _instanceId; } channel_manager()38 ChannelManager& channel_manager() { return _channelManager; } audio_device()39 AudioDeviceModule* audio_device() { return _audioDevicePtr.get(); } 40 void set_audio_device( 41 const rtc::scoped_refptr<AudioDeviceModule>& audio_device); 42 void set_audio_processing(AudioProcessing* audio_processing); transmit_mixer()43 TransmitMixer* transmit_mixer() { return _transmitMixerPtr; } crit_sec()44 rtc::CriticalSection* crit_sec() { return &_apiCritPtr; } process_thread()45 ProcessThread* process_thread() { return _moduleProcessThreadPtr.get(); } 46 rtc::TaskQueue* encoder_queue(); 47 48 int NumOfSendingChannels(); 49 int NumOfPlayingChannels(); 50 51 protected: 52 rtc::ThreadChecker construction_thread_; 53 const uint32_t _instanceId; 54 rtc::CriticalSection _apiCritPtr; 55 ChannelManager _channelManager; 56 rtc::scoped_refptr<AudioDeviceModule> _audioDevicePtr; 57 TransmitMixer* _transmitMixerPtr; 58 std::unique_ptr<ProcessThread> _moduleProcessThreadPtr; 59 // |encoder_queue| is defined last to ensure all pending tasks are cancelled 60 // and deleted before any other members. 61 rtc::TaskQueue encoder_queue_ RTC_ACCESS_ON(construction_thread_); 62 63 SharedData(); 64 virtual ~SharedData(); 65 }; 66 67 } // namespace voe 68 } // namespace webrtc 69 #endif // VOICE_ENGINE_SHARED_DATA_H_ 70