2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 18:01:48 +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_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H
|
|
|
|
|
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H
|
|
|
|
|
|
2013-07-11 13:24:38 +00:00
|
|
|
#include "webrtc/modules/audio_device/include/audio_device.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
2013-07-11 13:24:38 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
class CriticalSectionWrapper;
|
|
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
const uint32_t kPulsePeriodMs = 1000;
|
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
|
|
|
const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
class AudioDeviceObserver;
|
|
|
|
|
|
|
|
|
|
class AudioDeviceBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-09-10 18:24:07 +00:00
|
|
|
AudioDeviceBuffer();
|
|
|
|
|
virtual ~AudioDeviceBuffer();
|
|
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
void SetId(uint32_t id);
|
|
|
|
|
int32_t RegisterAudioCallback(AudioTransport* audioCallback);
|
|
|
|
|
|
|
|
|
|
int32_t InitPlayout();
|
|
|
|
|
int32_t InitRecording();
|
|
|
|
|
|
2013-10-02 14:58:19 +00:00
|
|
|
virtual int32_t SetRecordingSampleRate(uint32_t fsHz);
|
|
|
|
|
virtual int32_t SetPlayoutSampleRate(uint32_t fsHz);
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t RecordingSampleRate() const;
|
|
|
|
|
int32_t PlayoutSampleRate() const;
|
|
|
|
|
|
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
|
|
|
virtual int32_t SetRecordingChannels(size_t channels);
|
|
|
|
|
virtual int32_t SetPlayoutChannels(size_t channels);
|
|
|
|
|
size_t RecordingChannels() const;
|
|
|
|
|
size_t PlayoutChannels() const;
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t SetRecordingChannel(
|
2012-03-01 18:01:48 +00:00
|
|
|
const AudioDeviceModule::ChannelType channel);
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t RecordingChannel(
|
2012-03-01 18:01:48 +00:00
|
|
|
AudioDeviceModule::ChannelType& channel) const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-10-02 14:58:19 +00:00
|
|
|
virtual int32_t SetRecordedBuffer(const void* audioBuffer,
|
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 nSamples);
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t SetCurrentMicLevel(uint32_t level);
|
2013-10-02 14:58:19 +00:00
|
|
|
virtual void SetVQEData(int playDelayMS,
|
|
|
|
|
int recDelayMS,
|
|
|
|
|
int clockDrift);
|
|
|
|
|
virtual int32_t DeliverRecordedData();
|
2013-04-09 10:30:35 +00:00
|
|
|
uint32_t NewMicLevel() const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
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
|
|
|
virtual int32_t RequestPlayoutData(size_t nSamples);
|
2013-09-10 18:24:07 +00:00
|
|
|
virtual int32_t GetPlayoutData(void* audioBuffer);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t StartInputFileRecording(
|
2012-03-01 18:01:48 +00:00
|
|
|
const char fileName[kAdmMaxFileNameSize]);
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t StopInputFileRecording();
|
|
|
|
|
int32_t StartOutputFileRecording(
|
2012-03-01 18:01:48 +00:00
|
|
|
const char fileName[kAdmMaxFileNameSize]);
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t StopOutputFileRecording();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-07 21:04:24 +00:00
|
|
|
int32_t SetTypingStatus(bool typingStatus);
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t _id;
|
2011-07-07 08:21:25 +00:00
|
|
|
CriticalSectionWrapper& _critSect;
|
|
|
|
|
CriticalSectionWrapper& _critSectCb;
|
|
|
|
|
|
|
|
|
|
AudioTransport* _ptrCbAudioTransport;
|
|
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
uint32_t _recSampleRate;
|
|
|
|
|
uint32_t _playSampleRate;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
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 _recChannels;
|
|
|
|
|
size_t _playChannels;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// selected recording channel (left/right/both)
|
|
|
|
|
AudioDeviceModule::ChannelType _recChannel;
|
|
|
|
|
|
|
|
|
|
// 2 or 4 depending on mono or stereo
|
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 _recBytesPerSample;
|
|
|
|
|
size_t _playBytesPerSample;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-11-25 02:45:39 +00:00
|
|
|
// 10ms in stereo @ 96kHz
|
2012-03-09 08:59:19 +00:00
|
|
|
int8_t _recBuffer[kMaxBufferSizeBytes];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// one sample <=> 2 or 4 bytes
|
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 _recSamples;
|
|
|
|
|
size_t _recSize; // in bytes
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-11-25 02:45:39 +00:00
|
|
|
// 10ms in stereo @ 96kHz
|
2012-03-09 08:59:19 +00:00
|
|
|
int8_t _playBuffer[kMaxBufferSizeBytes];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// one sample <=> 2 or 4 bytes
|
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 _playSamples;
|
|
|
|
|
size_t _playSize; // in bytes
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
FileWrapper& _recFile;
|
|
|
|
|
FileWrapper& _playFile;
|
|
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
uint32_t _currentMicLevel;
|
|
|
|
|
uint32_t _newMicLevel;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-07 21:04:24 +00:00
|
|
|
bool _typingStatus;
|
|
|
|
|
|
2013-09-12 01:01:42 +00:00
|
|
|
int _playDelayMS;
|
|
|
|
|
int _recDelayMS;
|
|
|
|
|
int _clockDrift;
|
2013-09-11 22:35:00 +00:00
|
|
|
int high_delay_counter_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H
|