blob: e6471243a11ea1495f9fc38e270b6f4c53542787 [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,
Fredrik Solenberga32dd012017-10-04 13:27:21 +020025 public AudioTransport {
Jelena Marusic2dd6a272015-04-14 09:47:00 +020026 public:
peaha9cc40b2017-06-29 08:32:09 -070027 int Init(
28 AudioDeviceModule* external_adm,
peahe67bedb2017-07-07 04:25:11 -070029 AudioProcessing* audio_processing,
peaha9cc40b2017-06-29 08:32:09 -070030 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override;
solenbergff976312016-03-30 23:28:51 -070031 AudioDeviceModule* audio_device_module() override {
32 return shared_->audio_device();
33 }
solenberg76377c52017-02-21 00:54:31 -080034 voe::TransmitMixer* transmit_mixer() override {
35 return shared_->transmit_mixer();
36 }
Jelena Marusic2dd6a272015-04-14 09:47:00 +020037 int Terminate() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000038
Jelena Marusic2dd6a272015-04-14 09:47:00 +020039 int CreateChannel() override;
solenberg88499ec2016-09-07 07:34:41 -070040 int CreateChannel(const ChannelConfig& config) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020041 int DeleteChannel(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000042
Jelena Marusic2dd6a272015-04-14 09:47:00 +020043 int StartPlayout(int channel) override;
44 int StartSend(int channel) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020045 int StopPlayout(int channel) override;
46 int StopSend(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000047
henrika5f6bf242017-11-01 11:06:56 +010048 int SetPlayout(bool enabled) override;
49 int SetRecording(bool enabled) override;
50
Jelena Marusic2dd6a272015-04-14 09:47:00 +020051 AudioTransport* audio_transport() override { return this; }
niklase@google.com470e71d2011-07-07 08:21:25 +000052
Jelena Marusic2dd6a272015-04-14 09:47:00 +020053 // AudioTransport
henrikaec6fbd22017-03-31 05:43:36 -070054 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;
solenberg2397b9a2017-09-22 06:48:10 -070064 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;
solenberg13725082015-11-25 08:16:52 -080072 void PushCaptureData(int voe_channel,
73 const void* audio_data,
74 int bits_per_sample,
75 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080076 size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070077 size_t number_of_frames) override;
solenberg2397b9a2017-09-22 06:48:10 -070078 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.com470e71d2011-07-07 08:21:25 +000085
Jelena Marusic2dd6a272015-04-14 09:47:00 +020086 protected:
87 VoEBaseImpl(voe::SharedData* shared);
88 ~VoEBaseImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
Jelena Marusic2dd6a272015-04-14 09:47:00 +020090 private:
91 int32_t StartPlayout();
92 int32_t StopPlayout();
93 int32_t StartSend();
94 int32_t StopSend();
95 int32_t TerminateInternal();
niklase@google.com470e71d2011-07-07 08:21:25 +000096
Peter Kasting69558702016-01-12 16:26:35 -080097 void GetPlayoutData(int sample_rate, size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070098 size_t number_of_frames, bool feed_data_to_apm,
Jelena Marusic2dd6a272015-04-14 09:47:00 +020099 void* audio_data, int64_t* elapsed_time_ms,
100 int64_t* ntp_time_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200102 // Initialize channel by setting Engine Information then initializing
103 // channel.
104 int InitializeChannel(voe::ChannelOwner* channel_owner);
ossu5f7cfa52016-05-30 08:11:28 -0700105 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200107 AudioFrame audioFrame_;
108 voe::SharedData* shared_;
henrika5f6bf242017-11-01 11:06:56 +0100109 bool playout_enabled_ = true;
110 bool recording_enabled_ = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111};
112
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000113} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000114
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200115#endif // VOICE_ENGINE_VOE_BASE_IMPL_H_