niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
kma@webrtc.org | de66b91 | 2012-02-01 18:39:44 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 12 | #define WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 13 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 14 | #include "webrtc/voice_engine/include/voe_base.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 16 | #include "webrtc/modules/include/module_common_types.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame^] | 17 | #include "webrtc/rtc_base/criticalsection.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 18 | #include "webrtc/voice_engine/shared_data.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 20 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | class ProcessThread; |
| 23 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 24 | class VoEBaseImpl : public VoEBase, |
| 25 | public AudioTransport, |
| 26 | public AudioDeviceObserver { |
| 27 | public: |
| 28 | int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override; |
| 29 | int DeRegisterVoiceEngineObserver() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 31 | int Init( |
| 32 | AudioDeviceModule* external_adm, |
| 33 | AudioProcessing* external_apm, |
| 34 | const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override; |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 35 | AudioProcessing* audio_processing() override { |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 36 | // TODO(peah): Remove this when downstream dependencies have properly been |
| 37 | // resolved. |
| 38 | RTC_DCHECK(audio_processing_); |
| 39 | return audio_processing_.get(); |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 40 | } |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 41 | AudioDeviceModule* audio_device_module() override { |
| 42 | return shared_->audio_device(); |
| 43 | } |
solenberg | 76377c5 | 2017-02-21 00:54:31 -0800 | [diff] [blame] | 44 | voe::TransmitMixer* transmit_mixer() override { |
| 45 | return shared_->transmit_mixer(); |
| 46 | } |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 47 | int Terminate() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 49 | int CreateChannel() override; |
solenberg | 88499ec | 2016-09-07 07:34:41 -0700 | [diff] [blame] | 50 | int CreateChannel(const ChannelConfig& config) override; |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 51 | int DeleteChannel(int channel) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 53 | int StartReceive(int channel) override; |
| 54 | int StartPlayout(int channel) override; |
| 55 | int StartSend(int channel) override; |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 56 | int StopPlayout(int channel) override; |
| 57 | int StopSend(int channel) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 59 | int GetVersion(char version[1024]) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 61 | int LastError() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 63 | AudioTransport* audio_transport() override { return this; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 65 | int AssociateSendChannel(int channel, int accociate_send_channel) override; |
| 66 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 67 | // AudioTransport |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 68 | int32_t RecordedDataIsAvailable(const void* audio_data, |
| 69 | const size_t number_of_frames, |
| 70 | const size_t bytes_per_sample, |
| 71 | const size_t number_of_channels, |
| 72 | const uint32_t sample_rate, |
| 73 | const uint32_t audio_delay_milliseconds, |
| 74 | const int32_t clock_drift, |
| 75 | const uint32_t volume, |
| 76 | const bool key_pressed, |
| 77 | uint32_t& new_mic_volume) override; |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 78 | int32_t NeedMorePlayData(const size_t nSamples, |
| 79 | const size_t nBytesPerSample, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 80 | const size_t nChannels, |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 81 | const uint32_t samplesPerSec, |
| 82 | void* audioSamples, |
| 83 | size_t& nSamplesOut, |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 84 | int64_t* elapsed_time_ms, |
| 85 | int64_t* ntp_time_ms) override; |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 86 | void PushCaptureData(int voe_channel, |
| 87 | const void* audio_data, |
| 88 | int bits_per_sample, |
| 89 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 90 | size_t number_of_channels, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 91 | size_t number_of_frames) override; |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 92 | void PullRenderData(int bits_per_sample, |
| 93 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 94 | size_t number_of_channels, |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 95 | size_t number_of_frames, |
| 96 | void* audio_data, |
| 97 | int64_t* elapsed_time_ms, |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 98 | int64_t* ntp_time_ms) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 100 | // AudioDeviceObserver |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 101 | void OnErrorIsReported(const ErrorCode error) override; |
| 102 | void OnWarningIsReported(const WarningCode warning) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 104 | protected: |
| 105 | VoEBaseImpl(voe::SharedData* shared); |
| 106 | ~VoEBaseImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 108 | private: |
| 109 | int32_t StartPlayout(); |
| 110 | int32_t StopPlayout(); |
| 111 | int32_t StartSend(); |
| 112 | int32_t StopSend(); |
| 113 | int32_t TerminateInternal(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 115 | void GetPlayoutData(int sample_rate, size_t number_of_channels, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 116 | size_t number_of_frames, bool feed_data_to_apm, |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 117 | void* audio_data, int64_t* elapsed_time_ms, |
| 118 | int64_t* ntp_time_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 120 | // Initialize channel by setting Engine Information then initializing |
| 121 | // channel. |
| 122 | int InitializeChannel(voe::ChannelOwner* channel_owner); |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 123 | VoiceEngineObserver* voiceEngineObserverPtr_; |
tommi | 31fc21f | 2016-01-21 10:37:37 -0800 | [diff] [blame] | 124 | rtc::CriticalSection callbackCritSect_; |
ossu | 5f7cfa5 | 2016-05-30 08:11:28 -0700 | [diff] [blame] | 125 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 127 | // TODO(peah): Remove this when upstream dependencies have properly been |
| 128 | // resolved. |
| 129 | rtc::scoped_refptr<AudioProcessing> audio_processing_; |
| 130 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 131 | AudioFrame audioFrame_; |
| 132 | voe::SharedData* shared_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | }; |
| 134 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 135 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
| 137 | #endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |