andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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 WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 12 | #define WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 13 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 | [diff] [blame] | 14 | #include "webrtc/voice_engine/include/voe_base.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 15 | |
Henrik Kjellander | 36a14b5 | 2015-11-04 07:31:52 | [diff] [blame] | 16 | #include "webrtc/modules/include/module_common_types.h" |
Edward Lemur | 76de83e | 2017-07-06 17:44:34 | [diff] [blame] | 17 | #include "webrtc/rtc_base/criticalsection.h" |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 | [diff] [blame] | 18 | #include "webrtc/voice_engine/shared_data.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 19 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 20 | namespace webrtc { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 21 | |
| 22 | class ProcessThread; |
| 23 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [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; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 30 | |
peah | 588f761 | 2017-06-29 15:32:09 | [diff] [blame] | 31 | int Init( |
| 32 | AudioDeviceModule* external_adm, |
peah | b7b8932 | 2017-07-07 11:25:11 | [diff] [blame] | 33 | AudioProcessing* audio_processing, |
peah | 588f761 | 2017-06-29 15:32:09 | [diff] [blame] | 34 | const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override; |
solenberg | d25cdbb | 2016-03-31 06:28:51 | [diff] [blame] | 35 | AudioDeviceModule* audio_device_module() override { |
| 36 | return shared_->audio_device(); |
| 37 | } |
solenberg | 71e8df9 | 2017-02-21 08:54:31 | [diff] [blame] | 38 | voe::TransmitMixer* transmit_mixer() override { |
| 39 | return shared_->transmit_mixer(); |
| 40 | } |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 41 | int Terminate() override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 42 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 43 | int CreateChannel() override; |
solenberg | a686d5e | 2016-09-07 14:34:41 | [diff] [blame] | 44 | int CreateChannel(const ChannelConfig& config) override; |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 45 | int DeleteChannel(int channel) override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 46 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 47 | int StartReceive(int channel) override; |
| 48 | int StartPlayout(int channel) override; |
| 49 | int StartSend(int channel) override; |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 50 | int StopPlayout(int channel) override; |
| 51 | int StopSend(int channel) override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 52 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 53 | int GetVersion(char version[1024]) override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 54 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 55 | int LastError() override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 56 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 57 | AudioTransport* audio_transport() override { return this; } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 58 | |
Minyue | 1103af5 | 2015-05-13 12:14:42 | [diff] [blame] | 59 | int AssociateSendChannel(int channel, int accociate_send_channel) override; |
| 60 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 61 | // AudioTransport |
henrika | ab2deb1 | 2017-03-31 12:43:36 | [diff] [blame] | 62 | int32_t RecordedDataIsAvailable(const void* audio_data, |
| 63 | const size_t number_of_frames, |
| 64 | const size_t bytes_per_sample, |
| 65 | const size_t number_of_channels, |
| 66 | const uint32_t sample_rate, |
| 67 | const uint32_t audio_delay_milliseconds, |
| 68 | const int32_t clock_drift, |
| 69 | const uint32_t volume, |
| 70 | const bool key_pressed, |
| 71 | uint32_t& new_mic_volume) override; |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 72 | int32_t NeedMorePlayData(const size_t nSamples, |
| 73 | const size_t nBytesPerSample, |
Peter Kasting | 80590d9 | 2016-01-13 00:26:35 | [diff] [blame] | 74 | const size_t nChannels, |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 75 | const uint32_t samplesPerSec, |
| 76 | void* audioSamples, |
| 77 | size_t& nSamplesOut, |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 78 | int64_t* elapsed_time_ms, |
| 79 | int64_t* ntp_time_ms) override; |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 80 | void PushCaptureData(int voe_channel, |
| 81 | const void* audio_data, |
| 82 | int bits_per_sample, |
| 83 | int sample_rate, |
Peter Kasting | 80590d9 | 2016-01-13 00:26:35 | [diff] [blame] | 84 | size_t number_of_channels, |
Peter Kasting | a0ad248 | 2015-08-24 21:52:23 | [diff] [blame] | 85 | size_t number_of_frames) override; |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 86 | void PullRenderData(int bits_per_sample, |
| 87 | int sample_rate, |
Peter Kasting | 80590d9 | 2016-01-13 00:26:35 | [diff] [blame] | 88 | size_t number_of_channels, |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 89 | size_t number_of_frames, |
| 90 | void* audio_data, |
| 91 | int64_t* elapsed_time_ms, |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 92 | int64_t* ntp_time_ms) override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 93 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 94 | // AudioDeviceObserver |
solenberg | 5bbf7f9 | 2015-11-25 16:16:52 | [diff] [blame] | 95 | void OnErrorIsReported(const ErrorCode error) override; |
| 96 | void OnWarningIsReported(const WarningCode warning) override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 97 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 98 | protected: |
| 99 | VoEBaseImpl(voe::SharedData* shared); |
| 100 | ~VoEBaseImpl() override; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 101 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 102 | private: |
| 103 | int32_t StartPlayout(); |
| 104 | int32_t StopPlayout(); |
| 105 | int32_t StartSend(); |
| 106 | int32_t StopSend(); |
| 107 | int32_t TerminateInternal(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 108 | |
Peter Kasting | 80590d9 | 2016-01-13 00:26:35 | [diff] [blame] | 109 | void GetPlayoutData(int sample_rate, size_t number_of_channels, |
Peter Kasting | a0ad248 | 2015-08-24 21:52:23 | [diff] [blame] | 110 | size_t number_of_frames, bool feed_data_to_apm, |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 111 | void* audio_data, int64_t* elapsed_time_ms, |
| 112 | int64_t* ntp_time_ms); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 113 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 114 | // Initialize channel by setting Engine Information then initializing |
| 115 | // channel. |
| 116 | int InitializeChannel(voe::ChannelOwner* channel_owner); |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 117 | VoiceEngineObserver* voiceEngineObserverPtr_; |
tommi | c8e8cb0 | 2016-01-21 18:37:37 | [diff] [blame] | 118 | rtc::CriticalSection callbackCritSect_; |
ossu | 1ac1c3f | 2016-05-30 15:11:28 | [diff] [blame] | 119 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 120 | |
Jelena Marusic | 53b9b9d | 2015-04-14 07:47:00 | [diff] [blame] | 121 | AudioFrame audioFrame_; |
| 122 | voe::SharedData* shared_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 123 | }; |
| 124 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 | [diff] [blame] | 125 | } // namespace webrtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 126 | |
| 127 | #endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |