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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef VOICE_ENGINE_VOE_BASE_IMPL_H_ |
| 12 | #define VOICE_ENGINE_VOE_BASE_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "voice_engine/include/voe_base.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/include/module_common_types.h" |
| 17 | #include "rtc_base/criticalsection.h" |
| 18 | #include "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, |
Fredrik Solenberg | a32dd01 | 2017-10-04 13:27:21 +0200 | [diff] [blame] | 25 | public AudioTransport { |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 26 | public: |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 27 | int Init( |
| 28 | AudioDeviceModule* external_adm, |
peah | e67bedb | 2017-07-07 04:25:11 -0700 | [diff] [blame] | 29 | AudioProcessing* audio_processing, |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 30 | const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override; |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 31 | AudioDeviceModule* audio_device_module() override { |
| 32 | return shared_->audio_device(); |
| 33 | } |
solenberg | 76377c5 | 2017-02-21 00:54:31 -0800 | [diff] [blame] | 34 | voe::TransmitMixer* transmit_mixer() override { |
| 35 | return shared_->transmit_mixer(); |
| 36 | } |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 37 | int Terminate() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 39 | int CreateChannel() override; |
solenberg | 88499ec | 2016-09-07 07:34:41 -0700 | [diff] [blame] | 40 | int CreateChannel(const ChannelConfig& config) override; |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 41 | int DeleteChannel(int channel) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 43 | int StartPlayout(int channel) override; |
| 44 | int StartSend(int channel) override; |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 45 | int StopPlayout(int channel) override; |
| 46 | int StopSend(int channel) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [diff] [blame^] | 48 | int SetPlayout(bool enabled) override; |
| 49 | int SetRecording(bool enabled) override; |
| 50 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 51 | AudioTransport* audio_transport() override { return this; } |
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 | // AudioTransport |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 54 | int32_t RecordedDataIsAvailable(const void* audio_data, |
| 55 | const size_t number_of_frames, |
| 56 | const size_t bytes_per_sample, |
| 57 | const size_t number_of_channels, |
| 58 | const uint32_t sample_rate, |
| 59 | const uint32_t audio_delay_milliseconds, |
| 60 | const int32_t clock_drift, |
| 61 | const uint32_t volume, |
| 62 | const bool key_pressed, |
| 63 | uint32_t& new_mic_volume) override; |
solenberg | 2397b9a | 2017-09-22 06:48:10 -0700 | [diff] [blame] | 64 | RTC_DEPRECATED int32_t NeedMorePlayData(const size_t nSamples, |
| 65 | const size_t nBytesPerSample, |
| 66 | const size_t nChannels, |
| 67 | const uint32_t samplesPerSec, |
| 68 | void* audioSamples, |
| 69 | size_t& nSamplesOut, |
| 70 | int64_t* elapsed_time_ms, |
| 71 | int64_t* ntp_time_ms) override; |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 72 | void PushCaptureData(int voe_channel, |
| 73 | const void* audio_data, |
| 74 | int bits_per_sample, |
| 75 | int sample_rate, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 76 | size_t number_of_channels, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 77 | size_t number_of_frames) override; |
solenberg | 2397b9a | 2017-09-22 06:48:10 -0700 | [diff] [blame] | 78 | RTC_DEPRECATED void PullRenderData(int bits_per_sample, |
| 79 | int sample_rate, |
| 80 | size_t number_of_channels, |
| 81 | size_t number_of_frames, |
| 82 | void* audio_data, |
| 83 | int64_t* elapsed_time_ms, |
| 84 | int64_t* ntp_time_ms) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 86 | protected: |
| 87 | VoEBaseImpl(voe::SharedData* shared); |
| 88 | ~VoEBaseImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 90 | private: |
| 91 | int32_t StartPlayout(); |
| 92 | int32_t StopPlayout(); |
| 93 | int32_t StartSend(); |
| 94 | int32_t StopSend(); |
| 95 | int32_t TerminateInternal(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 97 | void GetPlayoutData(int sample_rate, size_t number_of_channels, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 98 | size_t number_of_frames, bool feed_data_to_apm, |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 99 | void* audio_data, int64_t* elapsed_time_ms, |
| 100 | int64_t* ntp_time_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 102 | // Initialize channel by setting Engine Information then initializing |
| 103 | // channel. |
| 104 | int InitializeChannel(voe::ChannelOwner* channel_owner); |
ossu | 5f7cfa5 | 2016-05-30 08:11:28 -0700 | [diff] [blame] | 105 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
Jelena Marusic | 2dd6a27 | 2015-04-14 09:47:00 +0200 | [diff] [blame] | 107 | AudioFrame audioFrame_; |
| 108 | voe::SharedData* shared_; |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [diff] [blame^] | 109 | bool playout_enabled_ = true; |
| 110 | bool recording_enabled_ = true; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 113 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 115 | #endif // VOICE_ENGINE_VOE_BASE_IMPL_H_ |