2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-01 18:39:44 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H
|
|
|
|
|
#define WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H
|
|
|
|
|
|
2013-05-21 13:52:32 +00:00
|
|
|
#include "webrtc/voice_engine/include/voe_base.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-01-21 10:37:37 -08:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/include/module_common_types.h"
|
2013-05-21 13:52:32 +00:00
|
|
|
#include "webrtc/voice_engine/shared_data.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-04-14 09:47:00 +02:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
class ProcessThread;
|
|
|
|
|
|
2015-04-14 09:47:00 +02:00
|
|
|
class VoEBaseImpl : public VoEBase,
|
|
|
|
|
public AudioTransport,
|
|
|
|
|
public AudioDeviceObserver {
|
|
|
|
|
public:
|
|
|
|
|
int RegisterVoiceEngineObserver(VoiceEngineObserver& observer) override;
|
|
|
|
|
int DeRegisterVoiceEngineObserver() override;
|
|
|
|
|
|
|
|
|
|
int Init(AudioDeviceModule* external_adm = nullptr,
|
2016-05-30 08:11:28 -07:00
|
|
|
AudioProcessing* audioproc = nullptr,
|
|
|
|
|
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory =
|
|
|
|
|
nullptr) override;
|
2015-04-14 09:47:00 +02:00
|
|
|
AudioProcessing* audio_processing() override {
|
|
|
|
|
return shared_->audio_processing();
|
|
|
|
|
}
|
2016-03-30 23:28:51 -07:00
|
|
|
AudioDeviceModule* audio_device_module() override {
|
|
|
|
|
return shared_->audio_device();
|
|
|
|
|
}
|
2015-04-14 09:47:00 +02:00
|
|
|
int Terminate() override;
|
|
|
|
|
|
|
|
|
|
int CreateChannel() override;
|
2016-09-07 07:34:41 -07:00
|
|
|
int CreateChannel(const ChannelConfig& config) override;
|
2015-04-14 09:47:00 +02:00
|
|
|
int DeleteChannel(int channel) override;
|
|
|
|
|
|
|
|
|
|
int StartReceive(int channel) override;
|
|
|
|
|
int StartPlayout(int channel) override;
|
|
|
|
|
int StartSend(int channel) override;
|
|
|
|
|
int StopPlayout(int channel) override;
|
|
|
|
|
int StopSend(int channel) override;
|
|
|
|
|
|
|
|
|
|
int GetVersion(char version[1024]) override;
|
|
|
|
|
|
|
|
|
|
int LastError() override;
|
|
|
|
|
|
|
|
|
|
AudioTransport* audio_transport() override { return this; }
|
|
|
|
|
|
2015-05-13 14:14:42 +02:00
|
|
|
int AssociateSendChannel(int channel, int accociate_send_channel) override;
|
|
|
|
|
|
2015-04-14 09:47:00 +02:00
|
|
|
// AudioTransport
|
2015-11-25 08:16:52 -08:00
|
|
|
int32_t RecordedDataIsAvailable(const void* audioSamples,
|
|
|
|
|
const size_t nSamples,
|
|
|
|
|
const size_t nBytesPerSample,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t nChannels,
|
2015-11-25 08:16:52 -08:00
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
const uint32_t totalDelayMS,
|
|
|
|
|
const int32_t clockDrift,
|
|
|
|
|
const uint32_t currentMicLevel,
|
|
|
|
|
const bool keyPressed,
|
2015-04-14 09:47:00 +02:00
|
|
|
uint32_t& newMicLevel) override;
|
2015-11-25 08:16:52 -08:00
|
|
|
int32_t NeedMorePlayData(const size_t nSamples,
|
|
|
|
|
const size_t nBytesPerSample,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t nChannels,
|
2015-11-25 08:16:52 -08:00
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
void* audioSamples,
|
|
|
|
|
size_t& nSamplesOut,
|
2015-04-14 09:47:00 +02:00
|
|
|
int64_t* elapsed_time_ms,
|
|
|
|
|
int64_t* ntp_time_ms) override;
|
2015-11-25 08:16:52 -08:00
|
|
|
void PushCaptureData(int voe_channel,
|
|
|
|
|
const void* audio_data,
|
|
|
|
|
int bits_per_sample,
|
|
|
|
|
int sample_rate,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t number_of_channels,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t number_of_frames) override;
|
2015-11-25 08:16:52 -08:00
|
|
|
void PullRenderData(int bits_per_sample,
|
|
|
|
|
int sample_rate,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t number_of_channels,
|
2015-11-25 08:16:52 -08:00
|
|
|
size_t number_of_frames,
|
|
|
|
|
void* audio_data,
|
|
|
|
|
int64_t* elapsed_time_ms,
|
2015-04-14 09:47:00 +02:00
|
|
|
int64_t* ntp_time_ms) override;
|
|
|
|
|
|
|
|
|
|
// AudioDeviceObserver
|
2015-11-25 08:16:52 -08:00
|
|
|
void OnErrorIsReported(const ErrorCode error) override;
|
|
|
|
|
void OnWarningIsReported(const WarningCode warning) override;
|
2015-04-14 09:47:00 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
VoEBaseImpl(voe::SharedData* shared);
|
|
|
|
|
~VoEBaseImpl() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int32_t StartPlayout();
|
|
|
|
|
int32_t StopPlayout();
|
|
|
|
|
int32_t StartSend();
|
|
|
|
|
int32_t StopSend();
|
|
|
|
|
int32_t TerminateInternal();
|
|
|
|
|
|
|
|
|
|
// Helper function to process the recorded data with AudioProcessing Module,
|
|
|
|
|
// demultiplex the data to specific voe channels, encode and send to the
|
|
|
|
|
// network. When |number_of_VoE_channels| is 0, it will demultiplex the
|
|
|
|
|
// data to all the existing VoE channels.
|
|
|
|
|
// It returns new AGC microphone volume or 0 if no volume changes
|
|
|
|
|
// should be done.
|
|
|
|
|
int ProcessRecordedDataWithAPM(
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const int voe_channels[], size_t number_of_voe_channels,
|
|
|
|
|
const void* audio_data, uint32_t sample_rate, size_t number_of_channels,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t number_of_frames, uint32_t audio_delay_milliseconds,
|
2015-04-14 09:47:00 +02:00
|
|
|
int32_t clock_drift, uint32_t volume, bool key_pressed);
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
void GetPlayoutData(int sample_rate, size_t number_of_channels,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t number_of_frames, bool feed_data_to_apm,
|
2015-04-14 09:47:00 +02:00
|
|
|
void* audio_data, int64_t* elapsed_time_ms,
|
|
|
|
|
int64_t* ntp_time_ms);
|
|
|
|
|
|
|
|
|
|
// Initialize channel by setting Engine Information then initializing
|
|
|
|
|
// channel.
|
|
|
|
|
int InitializeChannel(voe::ChannelOwner* channel_owner);
|
|
|
|
|
VoiceEngineObserver* voiceEngineObserverPtr_;
|
2016-01-21 10:37:37 -08:00
|
|
|
rtc::CriticalSection callbackCritSect_;
|
2016-05-30 08:11:28 -07:00
|
|
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-04-14 09:47:00 +02:00
|
|
|
AudioFrame audioFrame_;
|
|
|
|
|
voe::SharedData* shared_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H
|