blob: b96be9e343138c352916a95b825da44f80232334 [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(
Fredrik Solenbergd3195342017-11-21 20:33:05 +010028 AudioDeviceModule* audio_device,
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;
solenberg76377c52017-02-21 00:54:31 -080031 voe::TransmitMixer* transmit_mixer() override {
32 return shared_->transmit_mixer();
33 }
Fredrik Solenberg55900fd2017-11-23 20:22:55 +010034 void Terminate() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
Jelena Marusic2dd6a272015-04-14 09:47:00 +020036 int CreateChannel() override;
solenberg88499ec2016-09-07 07:34:41 -070037 int CreateChannel(const ChannelConfig& config) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020038 int DeleteChannel(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
Jelena Marusic2dd6a272015-04-14 09:47:00 +020040 int StartPlayout(int channel) override;
41 int StartSend(int channel) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020042 int StopPlayout(int channel) override;
43 int StopSend(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000044
henrika5f6bf242017-11-01 11:06:56 +010045 int SetPlayout(bool enabled) override;
46 int SetRecording(bool enabled) override;
47
Jelena Marusic2dd6a272015-04-14 09:47:00 +020048 AudioTransport* audio_transport() override { return this; }
niklase@google.com470e71d2011-07-07 08:21:25 +000049
Jelena Marusic2dd6a272015-04-14 09:47:00 +020050 // AudioTransport
henrikaec6fbd22017-03-31 05:43:36 -070051 int32_t RecordedDataIsAvailable(const void* audio_data,
52 const size_t number_of_frames,
53 const size_t bytes_per_sample,
54 const size_t number_of_channels,
55 const uint32_t sample_rate,
56 const uint32_t audio_delay_milliseconds,
57 const int32_t clock_drift,
58 const uint32_t volume,
59 const bool key_pressed,
60 uint32_t& new_mic_volume) override;
solenberg2397b9a2017-09-22 06:48:10 -070061 RTC_DEPRECATED int32_t NeedMorePlayData(const size_t nSamples,
62 const size_t nBytesPerSample,
63 const size_t nChannels,
64 const uint32_t samplesPerSec,
65 void* audioSamples,
66 size_t& nSamplesOut,
67 int64_t* elapsed_time_ms,
68 int64_t* ntp_time_ms) override;
solenberg13725082015-11-25 08:16:52 -080069 void PushCaptureData(int voe_channel,
70 const void* audio_data,
71 int bits_per_sample,
72 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080073 size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070074 size_t number_of_frames) override;
solenberg2397b9a2017-09-22 06:48:10 -070075 RTC_DEPRECATED void PullRenderData(int bits_per_sample,
76 int sample_rate,
77 size_t number_of_channels,
78 size_t number_of_frames,
79 void* audio_data,
80 int64_t* elapsed_time_ms,
81 int64_t* ntp_time_ms) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000082
Jelena Marusic2dd6a272015-04-14 09:47:00 +020083 protected:
84 VoEBaseImpl(voe::SharedData* shared);
85 ~VoEBaseImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
Jelena Marusic2dd6a272015-04-14 09:47:00 +020087 private:
88 int32_t StartPlayout();
89 int32_t StopPlayout();
90 int32_t StartSend();
91 int32_t StopSend();
Fredrik Solenberg55900fd2017-11-23 20:22:55 +010092 void TerminateInternal();
niklase@google.com470e71d2011-07-07 08:21:25 +000093
Peter Kasting69558702016-01-12 16:26:35 -080094 void GetPlayoutData(int sample_rate, size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070095 size_t number_of_frames, bool feed_data_to_apm,
Jelena Marusic2dd6a272015-04-14 09:47:00 +020096 void* audio_data, int64_t* elapsed_time_ms,
97 int64_t* ntp_time_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +000098
Jelena Marusic2dd6a272015-04-14 09:47:00 +020099 // Initialize channel by setting Engine Information then initializing
100 // channel.
101 int InitializeChannel(voe::ChannelOwner* channel_owner);
ossu5f7cfa52016-05-30 08:11:28 -0700102 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200104 AudioFrame audioFrame_;
105 voe::SharedData* shared_;
henrika5f6bf242017-11-01 11:06:56 +0100106 bool playout_enabled_ = true;
107 bool recording_enabled_ = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108};
109
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000110} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200112#endif // VOICE_ENGINE_VOE_BASE_IMPL_H_