blob: 7251c6aeaa6569dc0657d73fc6f5d144fd6b9a94 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tommi@webrtc.org851becd2012-04-04 14:57:19 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 WEBRTC_VOICE_ENGINE_SHARED_DATA_H
12#define WEBRTC_VOICE_ENGINE_SHARED_DATA_H
13
kwibergb7f89d62016-02-17 10:04:18 -080014#include <memory>
15
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000016#include "webrtc/modules/audio_device/include/audio_device.h"
17#include "webrtc/modules/audio_processing/include/audio_processing.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018#include "webrtc/modules/utility/include/process_thread.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020019#include "webrtc/rtc_base/criticalsection.h"
20#include "webrtc/rtc_base/scoped_ref_ptr.h"
21#include "webrtc/rtc_base/task_queue.h"
22#include "webrtc/rtc_base/thread_annotations.h"
23#include "webrtc/rtc_base/thread_checker.h"
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000024#include "webrtc/voice_engine/channel_manager.h"
25#include "webrtc/voice_engine/statistics.h"
26#include "webrtc/voice_engine/voice_engine_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28class ProcessThread;
29
30namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000031namespace voe {
32
33class TransmitMixer;
34class OutputMixer;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
tommi@webrtc.org9ff87db2012-01-19 15:05:36 +000036class SharedData
niklase@google.com470e71d2011-07-07 08:21:25 +000037{
tommi@webrtc.org9ff87db2012-01-19 15:05:36 +000038public:
39 // Public accessors.
pbos@webrtc.org6141e132013-04-09 10:09:10 +000040 uint32_t instance_id() const { return _instanceId; }
tommi@webrtc.org9ff87db2012-01-19 15:05:36 +000041 Statistics& statistics() { return _engineStatistics; }
42 ChannelManager& channel_manager() { return _channelManager; }
Peter Boström1d194412016-03-21 16:44:31 +010043 AudioDeviceModule* audio_device() { return _audioDevicePtr.get(); }
44 void set_audio_device(
45 const rtc::scoped_refptr<AudioDeviceModule>& audio_device);
tommi@webrtc.org851becd2012-04-04 14:57:19 +000046 void set_audio_processing(AudioProcessing* audio_processing);
47 TransmitMixer* transmit_mixer() { return _transmitMixerPtr; }
48 OutputMixer* output_mixer() { return _outputMixerPtr; }
tommi31fc21f2016-01-21 10:37:37 -080049 rtc::CriticalSection* crit_sec() { return &_apiCritPtr; }
tommi@webrtc.org0c3e12b2015-02-06 09:44:12 +000050 ProcessThread* process_thread() { return _moduleProcessThreadPtr.get(); }
henrikaec6fbd22017-03-31 05:43:36 -070051 rtc::TaskQueue* encoder_queue();
tommi@webrtc.org9ff87db2012-01-19 15:05:36 +000052
xians@webrtc.org675e2602013-10-17 16:15:34 +000053 int NumOfSendingChannels();
54 int NumOfPlayingChannels();
tommi@webrtc.org9ff87db2012-01-19 15:05:36 +000055
tommi@webrtc.org851becd2012-04-04 14:57:19 +000056 // Convenience methods for calling statistics().SetLastError().
pbos@webrtc.org92135212013-05-14 08:31:39 +000057 void SetLastError(int32_t error) const;
58 void SetLastError(int32_t error, TraceLevel level) const;
59 void SetLastError(int32_t error, TraceLevel level,
tommi@webrtc.org851becd2012-04-04 14:57:19 +000060 const char* msg) const;
61
niklase@google.com470e71d2011-07-07 08:21:25 +000062protected:
henrikaec6fbd22017-03-31 05:43:36 -070063 rtc::ThreadChecker construction_thread_;
64 const uint32_t _instanceId;
65 rtc::CriticalSection _apiCritPtr;
66 ChannelManager _channelManager;
67 Statistics _engineStatistics;
68 rtc::scoped_refptr<AudioDeviceModule> _audioDevicePtr;
69 OutputMixer* _outputMixerPtr;
70 TransmitMixer* _transmitMixerPtr;
henrikaec6fbd22017-03-31 05:43:36 -070071 std::unique_ptr<ProcessThread> _moduleProcessThreadPtr;
72 // |encoder_queue| is defined last to ensure all pending tasks are cancelled
73 // and deleted before any other members.
danilchapa37de392017-09-09 04:17:22 -070074 rtc::TaskQueue encoder_queue_ RTC_ACCESS_ON(construction_thread_);
niklase@google.com470e71d2011-07-07 08:21:25 +000075
henrikaec6fbd22017-03-31 05:43:36 -070076 SharedData();
77 virtual ~SharedData();
niklase@google.com470e71d2011-07-07 08:21:25 +000078};
79
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000080} // namespace voe
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000081} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000082#endif // WEBRTC_VOICE_ENGINE_SHARED_DATA_H