blob: 3c85eba26c58f8544a12eaacb8e81ca68d904b05 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
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.org471ae722013-05-21 13:52:3214#include "webrtc/voice_engine/include/voe_base.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2315
Henrik Kjellander36a14b52015-11-04 07:31:5216#include "webrtc/modules/include/module_common_types.h"
Edward Lemur76de83e2017-07-06 17:44:3417#include "webrtc/rtc_base/criticalsection.h"
pbos@webrtc.org471ae722013-05-21 13:52:3218#include "webrtc/voice_engine/shared_data.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2319
Jelena Marusic53b9b9d2015-04-14 07:47:0020namespace webrtc {
andrew@webrtc.orgb015cbe2012-10-22 18:19:2321
22class ProcessThread;
23
Jelena Marusic53b9b9d2015-04-14 07:47:0024class VoEBaseImpl : public VoEBase,
25 public AudioTransport,
26 public AudioDeviceObserver {
27 public:
28 int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override;
29 int DeRegisterVoiceEngineObserver() override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2330
peah588f7612017-06-29 15:32:0931 int Init(
32 AudioDeviceModule* external_adm,
peahb7b89322017-07-07 11:25:1133 AudioProcessing* audio_processing,
peah588f7612017-06-29 15:32:0934 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) override;
solenbergd25cdbb2016-03-31 06:28:5135 AudioDeviceModule* audio_device_module() override {
36 return shared_->audio_device();
37 }
solenberg71e8df92017-02-21 08:54:3138 voe::TransmitMixer* transmit_mixer() override {
39 return shared_->transmit_mixer();
40 }
Jelena Marusic53b9b9d2015-04-14 07:47:0041 int Terminate() override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2342
Jelena Marusic53b9b9d2015-04-14 07:47:0043 int CreateChannel() override;
solenberga686d5e2016-09-07 14:34:4144 int CreateChannel(const ChannelConfig& config) override;
Jelena Marusic53b9b9d2015-04-14 07:47:0045 int DeleteChannel(int channel) override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2346
Jelena Marusic53b9b9d2015-04-14 07:47:0047 int StartReceive(int channel) override;
48 int StartPlayout(int channel) override;
49 int StartSend(int channel) override;
Jelena Marusic53b9b9d2015-04-14 07:47:0050 int StopPlayout(int channel) override;
51 int StopSend(int channel) override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2352
Jelena Marusic53b9b9d2015-04-14 07:47:0053 int GetVersion(char version[1024]) override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2354
Jelena Marusic53b9b9d2015-04-14 07:47:0055 int LastError() override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2356
Jelena Marusic53b9b9d2015-04-14 07:47:0057 AudioTransport* audio_transport() override { return this; }
andrew@webrtc.orgb015cbe2012-10-22 18:19:2358
Minyue1103af52015-05-13 12:14:4259 int AssociateSendChannel(int channel, int accociate_send_channel) override;
60
Jelena Marusic53b9b9d2015-04-14 07:47:0061 // AudioTransport
henrikaab2deb12017-03-31 12:43:3662 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;
solenberg5bbf7f92015-11-25 16:16:5272 int32_t NeedMorePlayData(const size_t nSamples,
73 const size_t nBytesPerSample,
Peter Kasting80590d92016-01-13 00:26:3574 const size_t nChannels,
solenberg5bbf7f92015-11-25 16:16:5275 const uint32_t samplesPerSec,
76 void* audioSamples,
77 size_t& nSamplesOut,
Jelena Marusic53b9b9d2015-04-14 07:47:0078 int64_t* elapsed_time_ms,
79 int64_t* ntp_time_ms) override;
solenberg5bbf7f92015-11-25 16:16:5280 void PushCaptureData(int voe_channel,
81 const void* audio_data,
82 int bits_per_sample,
83 int sample_rate,
Peter Kasting80590d92016-01-13 00:26:3584 size_t number_of_channels,
Peter Kastinga0ad2482015-08-24 21:52:2385 size_t number_of_frames) override;
solenberg5bbf7f92015-11-25 16:16:5286 void PullRenderData(int bits_per_sample,
87 int sample_rate,
Peter Kasting80590d92016-01-13 00:26:3588 size_t number_of_channels,
solenberg5bbf7f92015-11-25 16:16:5289 size_t number_of_frames,
90 void* audio_data,
91 int64_t* elapsed_time_ms,
Jelena Marusic53b9b9d2015-04-14 07:47:0092 int64_t* ntp_time_ms) override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2393
Jelena Marusic53b9b9d2015-04-14 07:47:0094 // AudioDeviceObserver
solenberg5bbf7f92015-11-25 16:16:5295 void OnErrorIsReported(const ErrorCode error) override;
96 void OnWarningIsReported(const WarningCode warning) override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2397
Jelena Marusic53b9b9d2015-04-14 07:47:0098 protected:
99 VoEBaseImpl(voe::SharedData* shared);
100 ~VoEBaseImpl() override;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23101
Jelena Marusic53b9b9d2015-04-14 07:47:00102 private:
103 int32_t StartPlayout();
104 int32_t StopPlayout();
105 int32_t StartSend();
106 int32_t StopSend();
107 int32_t TerminateInternal();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23108
Peter Kasting80590d92016-01-13 00:26:35109 void GetPlayoutData(int sample_rate, size_t number_of_channels,
Peter Kastinga0ad2482015-08-24 21:52:23110 size_t number_of_frames, bool feed_data_to_apm,
Jelena Marusic53b9b9d2015-04-14 07:47:00111 void* audio_data, int64_t* elapsed_time_ms,
112 int64_t* ntp_time_ms);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23113
Jelena Marusic53b9b9d2015-04-14 07:47:00114 // Initialize channel by setting Engine Information then initializing
115 // channel.
116 int InitializeChannel(voe::ChannelOwner* channel_owner);
Jelena Marusic53b9b9d2015-04-14 07:47:00117 VoiceEngineObserver* voiceEngineObserverPtr_;
tommic8e8cb02016-01-21 18:37:37118 rtc::CriticalSection callbackCritSect_;
ossu1ac1c3f2016-05-30 15:11:28119 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23120
Jelena Marusic53b9b9d2015-04-14 07:47:00121 AudioFrame audioFrame_;
122 voe::SharedData* shared_;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23123};
124
pbos@webrtc.org3b89e102013-07-03 15:12:26125} // namespace webrtc
andrew@webrtc.orgb015cbe2012-10-22 18:19:23126
127#endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H