blob: 608292ce086c710110f7e01ca1a575b183a360e3 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
kma@webrtc.orgde66b912012-02-01 18:39:44 +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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef VOICE_ENGINE_VOE_BASE_IMPL_H_
12#define VOICE_ENGINE_VOE_BASE_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "voice_engine/include/voe_base.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/include/module_common_types.h"
17#include "rtc_base/criticalsection.h"
18#include "voice_engine/shared_data.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
Jelena Marusic2dd6a272015-04-14 09:47:00 +020020namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22class ProcessThread;
23
Jelena Marusic2dd6a272015-04-14 09:47:00 +020024class VoEBaseImpl : public VoEBase,
25 public AudioTransport,
26 public AudioDeviceObserver {
27 public:
28 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override;
29 int DeRegisterVoiceEngineObserver() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000030
peaha9cc40b2017-06-29 08:32:09 -070031 int Init(
32 AudioDeviceModule* external_adm,
peahe67bedb2017-07-07 04:25:11 -070033 AudioProcessing* audio_processing,
peaha9cc40b2017-06-29 08:32:09 -070034 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override;
solenbergff976312016-03-30 23:28:51 -070035 AudioDeviceModule* audio_device_module() override {
36 return shared_->audio_device();
37 }
solenberg76377c52017-02-21 00:54:31 -080038 voe::TransmitMixer* transmit_mixer() override {
39 return shared_->transmit_mixer();
40 }
Jelena Marusic2dd6a272015-04-14 09:47:00 +020041 int Terminate() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000042
Jelena Marusic2dd6a272015-04-14 09:47:00 +020043 int CreateChannel() override;
solenberg88499ec2016-09-07 07:34:41 -070044 int CreateChannel(const ChannelConfig& config) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020045 int DeleteChannel(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000046
Jelena Marusic2dd6a272015-04-14 09:47:00 +020047 int StartPlayout(int channel) override;
48 int StartSend(int channel) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020049 int StopPlayout(int channel) override;
50 int StopSend(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000051
Jelena Marusic2dd6a272015-04-14 09:47:00 +020052 AudioTransport* audio_transport() override { return this; }
niklase@google.com470e71d2011-07-07 08:21:25 +000053
Jelena Marusic2dd6a272015-04-14 09:47:00 +020054 // AudioTransport
henrikaec6fbd22017-03-31 05:43:36 -070055 int32_t RecordedDataIsAvailable(const void* audio_data,
56 const size_t number_of_frames,
57 const size_t bytes_per_sample,
58 const size_t number_of_channels,
59 const uint32_t sample_rate,
60 const uint32_t audio_delay_milliseconds,
61 const int32_t clock_drift,
62 const uint32_t volume,
63 const bool key_pressed,
64 uint32_t& new_mic_volume) override;
solenberg13725082015-11-25 08:16:52 -080065 int32_t NeedMorePlayData(const size_t nSamples,
66 const size_t nBytesPerSample,
Peter Kasting69558702016-01-12 16:26:35 -080067 const size_t nChannels,
solenberg13725082015-11-25 08:16:52 -080068 const uint32_t samplesPerSec,
69 void* audioSamples,
70 size_t& nSamplesOut,
Jelena Marusic2dd6a272015-04-14 09:47:00 +020071 int64_t* elapsed_time_ms,
72 int64_t* ntp_time_ms) override;
solenberg13725082015-11-25 08:16:52 -080073 void PushCaptureData(int voe_channel,
74 const void* audio_data,
75 int bits_per_sample,
76 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080077 size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070078 size_t number_of_frames) override;
solenberg13725082015-11-25 08:16:52 -080079 void PullRenderData(int bits_per_sample,
80 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080081 size_t number_of_channels,
solenberg13725082015-11-25 08:16:52 -080082 size_t number_of_frames,
83 void* audio_data,
84 int64_t* elapsed_time_ms,
Jelena Marusic2dd6a272015-04-14 09:47:00 +020085 int64_t* ntp_time_ms) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
Jelena Marusic2dd6a272015-04-14 09:47:00 +020087 // AudioDeviceObserver
solenberg13725082015-11-25 08:16:52 -080088 void OnErrorIsReported(const ErrorCode error) override;
89 void OnWarningIsReported(const WarningCode warning) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000090
Jelena Marusic2dd6a272015-04-14 09:47:00 +020091 protected:
92 VoEBaseImpl(voe::SharedData* shared);
93 ~VoEBaseImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000094
Jelena Marusic2dd6a272015-04-14 09:47:00 +020095 private:
96 int32_t StartPlayout();
97 int32_t StopPlayout();
98 int32_t StartSend();
99 int32_t StopSend();
100 int32_t TerminateInternal();
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
Peter Kasting69558702016-01-12 16:26:35 -0800102 void GetPlayoutData(int sample_rate, size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700103 size_t number_of_frames, bool feed_data_to_apm,
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200104 void* audio_data, int64_t* elapsed_time_ms,
105 int64_t* ntp_time_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200107 // Initialize channel by setting Engine Information then initializing
108 // channel.
109 int InitializeChannel(voe::ChannelOwner* channel_owner);
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200110 VoiceEngineObserver* voiceEngineObserverPtr_;
tommi31fc21f2016-01-21 10:37:37 -0800111 rtc::CriticalSection callbackCritSect_;
ossu5f7cfa52016-05-30 08:11:28 -0700112 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200114 AudioFrame audioFrame_;
115 voe::SharedData* shared_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000116};
117
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000118} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000119
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200120#endif // VOICE_ENGINE_VOE_BASE_IMPL_H_