From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../libwebrtc/sdk/objc/native/src/audio/audio_device_ios.h | 4 ++++ .../libwebrtc/sdk/objc/native/src/audio/audio_device_ios.mm | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'third_party/libwebrtc/sdk/objc/native/src') diff --git a/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.h b/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.h index a86acb56fe..4ef4d0b5df 100644 --- a/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.h +++ b/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.h @@ -299,6 +299,10 @@ class AudioDeviceIOS : public AudioDeviceGeneric, // Avoids running pending task after `this` is Terminated. rtc::scoped_refptr safety_ = PendingTaskSafetyFlag::Create(); + + // Ratio between mach tick units and nanosecond. Used to change mach tick + // units to nanoseconds. + double machTickUnitsToNanoseconds_; }; } // namespace ios_adm } // namespace webrtc diff --git a/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.mm b/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.mm index dd2c11bdd2..78420ec232 100644 --- a/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.mm +++ b/third_party/libwebrtc/sdk/objc/native/src/audio/audio_device_ios.mm @@ -13,6 +13,7 @@ #include "audio_device_ios.h" +#include #include #include "api/array_view.h" @@ -110,6 +111,9 @@ AudioDeviceIOS::AudioDeviceIOS(bool bypass_voice_processing) thread_ = rtc::Thread::Current(); audio_session_observer_ = [[RTCNativeAudioSessionDelegateAdapter alloc] initWithObserver:this]; + mach_timebase_info_data_t tinfo; + mach_timebase_info(&tinfo); + machTickUnitsToNanoseconds_ = (double)tinfo.numer / tinfo.denom; } AudioDeviceIOS::~AudioDeviceIOS() { @@ -376,6 +380,11 @@ OSStatus AudioDeviceIOS::OnDeliverRecordedData(AudioUnitRenderActionFlags* flags record_audio_buffer_.Clear(); record_audio_buffer_.SetSize(num_frames); + // Get audio timestamp for the audio. + // The timestamp will not have NTP time epoch, but that will be addressed by + // the TimeStampAligner in AudioDeviceBuffer::SetRecordedBuffer(). + SInt64 capture_timestamp_ns = time_stamp->mHostTime * machTickUnitsToNanoseconds_; + // Allocate AudioBuffers to be used as storage for the received audio. // The AudioBufferList structure works as a placeholder for the // AudioBuffer structure, which holds a pointer to the actual data buffer @@ -404,7 +413,8 @@ OSStatus AudioDeviceIOS::OnDeliverRecordedData(AudioUnitRenderActionFlags* flags // Get a pointer to the recorded audio and send it to the WebRTC ADB. // Use the FineAudioBuffer instance to convert between native buffer size // and the 10ms buffer size used by WebRTC. - fine_audio_buffer_->DeliverRecordedData(record_audio_buffer_, kFixedRecordDelayEstimate); + fine_audio_buffer_->DeliverRecordedData( + record_audio_buffer_, kFixedRecordDelayEstimate, capture_timestamp_ns); return noErr; } -- cgit v1.2.3