1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-30 04:39:03 +01:00

Merge remote-tracking branch 'upstream/public' into public

This commit is contained in:
Fela Ameghino 2017-05-15 17:29:44 +02:00
commit efdb2a51f3
5 changed files with 30 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include "EchoCanceller.h"
#include "audio/AudioOutput.h"
#include "audio/AudioInput.h"
#include "logging.h"
#include <string.h>
#include <stdio.h>
@ -263,13 +264,13 @@ void EchoCanceller::ProcessInput(unsigned char* data, unsigned char* out, size_t
lock_mutex(aecMutex);
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], _nsOut[0], samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, _nsOut[0]+160, samplesOut+160, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, _nsOut[0]+160, samplesOut+160, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay());
unlock_mutex(aecMutex);
memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2);
}else if(enableAEC){
lock_mutex(aecMutex);
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], NULL, samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, NULL, samplesOut+160, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, NULL, samplesOut+160, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay());
unlock_mutex(aecMutex);
memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2);
}else if(enableNS){
@ -339,12 +340,12 @@ void EchoCanceller::ProcessInput(unsigned char* data, unsigned char* out, size_t
aecIn[i]=bufOut->fbuf_const()->bands(0)[i];
aecOut[i]=_aecOut[i];
}
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay(), 0);
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0);
for(i=0;i<3;i++){
aecOut[i]+=160;
aecIn[i]+=160;
}
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay(), 0);
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0);
memcpy(bufOut->fbuf()->bands(0)[0], _aecOut[0], 320*4);
memcpy(bufOut->fbuf()->bands(0)[1], _aecOut[1], 320*4);

View File

@ -2098,7 +2098,10 @@ Endpoint::Endpoint(int64_t id, uint16_t port, IPv4Address& _address, IPv6Address
}
Endpoint::Endpoint() : address(0), v6address("::0") {
lastPingSeq=0;
lastPingTime=0;
averageRTT=0;
memset(rtts, 0, sizeof(rtts));
}
#if defined(__APPLE__) && TARGET_OS_IPHONE

View File

@ -29,6 +29,8 @@
using namespace tgvoip;
using namespace tgvoip::audio;
int32_t AudioInput::estimatedDelay=60;
AudioInput::AudioInput() : currentDevice("default"){
failed=false;
}
@ -99,3 +101,7 @@ std::string AudioInput::GetCurrentDevice(){
void AudioInput::SetCurrentDevice(std::string deviceID){
}
int32_t AudioInput::GetEstimatedDelay(){
return estimatedDelay;
}

View File

@ -30,10 +30,12 @@ public:
virtual void SetCurrentDevice(std::string deviceID);
static AudioInput* Create(std::string deviceID);
static void EnumerateDevices(std::vector<AudioInputDevice>& devs);
static int32_t GetEstimatedDelay();
protected:
std::string currentDevice;
bool failed;
static int32_t estimatedDelay;
};
}}

View File

@ -284,6 +284,19 @@ void AudioInputAudioUnit::SetCurrentDevice(std::string deviceID){
LOGD("Switched capture device, new sample rate %d", hardwareSampleRate);
this->currentDevice=deviceID;
AudioObjectPropertyAddress propertyAddress = {
kAudioDevicePropertyBufferFrameSize,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
size=4;
UInt32 bufferFrameSize;
status=AudioObjectGetPropertyData(inputDevice, &propertyAddress, 0, NULL, &size, &bufferFrameSize);
if(status==noErr){
estimatedDelay=bufferFrameSize/48;
LOGD("CoreAudio buffer size for output device is %u frames (%u ms)", bufferFrameSize, estimatedDelay);
}
}
OSStatus AudioInputAudioUnit::DefaultDeviceChangedCallback(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *inClientData){