blob: d03a1997c46f2d75bf96bbc54a6c83d50c0532ed [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 Solenbergd4404c22017-10-02 15:08:56 +000025 public AudioTransport,
26 public AudioDeviceObserver {
Jelena Marusic2dd6a272015-04-14 09:47:00 +020027 public:
peaha9cc40b2017-06-29 08:32:09 -070028 int Init(
29 AudioDeviceModule* external_adm,
peahe67bedb2017-07-07 04:25:11 -070030 AudioProcessing* audio_processing,
peaha9cc40b2017-06-29 08:32:09 -070031 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override;
solenbergff976312016-03-30 23:28:51 -070032 AudioDeviceModule* audio_device_module() override {
33 return shared_->audio_device();
34 }
solenberg76377c52017-02-21 00:54:31 -080035 voe::TransmitMixer* transmit_mixer() override {
36 return shared_->transmit_mixer();
37 }
Jelena Marusic2dd6a272015-04-14 09:47:00 +020038 int Terminate() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
Jelena Marusic2dd6a272015-04-14 09:47:00 +020040 int CreateChannel() override;
solenberg88499ec2016-09-07 07:34:41 -070041 int CreateChannel(const ChannelConfig& config) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020042 int DeleteChannel(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000043
Jelena Marusic2dd6a272015-04-14 09:47:00 +020044 int StartPlayout(int channel) override;
45 int StartSend(int channel) override;
Jelena Marusic2dd6a272015-04-14 09:47:00 +020046 int StopPlayout(int channel) override;
47 int StopSend(int channel) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
Jelena Marusic2dd6a272015-04-14 09:47:00 +020049 AudioTransport* audio_transport() override { return this; }
niklase@google.com470e71d2011-07-07 08:21:25 +000050
Jelena Marusic2dd6a272015-04-14 09:47:00 +020051 // AudioTransport
henrikaec6fbd22017-03-31 05:43:36 -070052 int32_t RecordedDataIsAvailable(const void* audio_data,
53 const size_t number_of_frames,
54 const size_t bytes_per_sample,
55 const size_t number_of_channels,
56 const uint32_t sample_rate,
57 const uint32_t audio_delay_milliseconds,
58 const int32_t clock_drift,
59 const uint32_t volume,
60 const bool key_pressed,
61 uint32_t& new_mic_volume) override;
solenberg2397b9a2017-09-22 06:48:10 -070062 RTC_DEPRECATED int32_t NeedMorePlayData(const size_t nSamples,
63 const size_t nBytesPerSample,
64 const size_t nChannels,
65 const uint32_t samplesPerSec,
66 void* audioSamples,
67 size_t& nSamplesOut,
68 int64_t* elapsed_time_ms,
69 int64_t* ntp_time_ms) override;
solenberg13725082015-11-25 08:16:52 -080070 void PushCaptureData(int voe_channel,
71 const void* audio_data,
72 int bits_per_sample,
73 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080074 size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -070075 size_t number_of_frames) override;
solenberg2397b9a2017-09-22 06:48:10 -070076 RTC_DEPRECATED void PullRenderData(int bits_per_sample,
77 int sample_rate,
78 size_t number_of_channels,
79 size_t number_of_frames,
80 void* audio_data,
81 int64_t* elapsed_time_ms,
82 int64_t* ntp_time_ms) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Fredrik Solenbergd4404c22017-10-02 15:08:56 +000084 // AudioDeviceObserver
85 void OnErrorIsReported(const ErrorCode error) override;
86 void OnWarningIsReported(const WarningCode warning) override;
87
Jelena Marusic2dd6a272015-04-14 09:47:00 +020088 protected:
89 VoEBaseImpl(voe::SharedData* shared);
90 ~VoEBaseImpl() override;
niklase@google.com470e71d2011-07-07 08:21:25 +000091
Jelena Marusic2dd6a272015-04-14 09:47:00 +020092 private:
93 int32_t StartPlayout();
94 int32_t StopPlayout();
95 int32_t StartSend();
96 int32_t StopSend();
97 int32_t TerminateInternal();
niklase@google.com470e71d2011-07-07 08:21:25 +000098
Peter Kasting69558702016-01-12 16:26:35 -080099 void GetPlayoutData(int sample_rate, size_t number_of_channels,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700100 size_t number_of_frames, bool feed_data_to_apm,
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200101 void* audio_data, int64_t* elapsed_time_ms,
102 int64_t* ntp_time_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200104 // Initialize channel by setting Engine Information then initializing
105 // channel.
106 int InitializeChannel(voe::ChannelOwner* channel_owner);
ossu5f7cfa52016-05-30 08:11:28 -0700107 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
Jelena Marusic2dd6a272015-04-14 09:47:00 +0200109 AudioFrame audioFrame_;
110 voe::SharedData* shared_;
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_