-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,28 +14,28 @@ Signed-off-by: Antti Tapaninen <[email protected]> | |
.../peerconnection/RTCPeerConnectionFactory.h | 6 + | ||
.../RTCPeerConnectionFactory.mm | 26 ++++ | ||
sdk/objc/native/src/audio/audio_device_ios.h | 11 +- | ||
sdk/objc/native/src/audio/audio_device_ios.mm | 147 +++++++++++++++--- | ||
sdk/objc/native/src/audio/audio_device_ios.mm | 145 +++++++++++++++--- | ||
.../src/audio/audio_device_module_ios.h | 4 + | ||
.../src/audio/audio_device_module_ios.mm | 5 + | ||
.../src/audio/voice_processing_audio_unit.mm | 114 +++++++++----- | ||
11 files changed, 314 insertions(+), 67 deletions(-) | ||
11 files changed, 313 insertions(+), 66 deletions(-) | ||
create mode 100644 sdk/objc/api/peerconnection/RTCAudioDeviceModule+Private.h | ||
create mode 100644 sdk/objc/api/peerconnection/RTCAudioDeviceModule.h | ||
create mode 100644 sdk/objc/api/peerconnection/RTCAudioDeviceModule.mm | ||
|
||
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn | ||
index ff89b21721..b80bfaa6ca 100644 | ||
index a044c469e0..383176b082 100644 | ||
--- a/sdk/BUILD.gn | ||
+++ b/sdk/BUILD.gn | ||
@@ -943,6 +943,7 @@ if (is_ios || is_mac) { | ||
@@ -924,6 +924,7 @@ if (is_ios || is_mac) { | ||
] | ||
configs += [ "..:no_global_constructors" ] | ||
sources = [ | ||
+ "objc/api/peerconnection/RTCAudioDeviceModule.h", | ||
"objc/api/peerconnection/RTCAudioSource+Private.h", | ||
"objc/api/peerconnection/RTCAudioSource.h", | ||
"objc/api/peerconnection/RTCAudioSource.mm", | ||
@@ -1114,6 +1115,10 @@ if (is_ios || is_mac) { | ||
@@ -1104,6 +1105,10 @@ if (is_ios || is_mac) { | ||
] | ||
|
||
if (is_ios) { | ||
|
@@ -46,15 +46,15 @@ index ff89b21721..b80bfaa6ca 100644 | |
deps += [ ":native_api_audio_device_module" ] | ||
} | ||
} | ||
@@ -1308,6 +1313,7 @@ if (is_ios || is_mac) { | ||
@@ -1298,6 +1303,7 @@ if (is_ios || is_mac) { | ||
"objc/helpers/RTCCameraPreviewView.h", | ||
"objc/helpers/RTCDispatcher.h", | ||
"objc/helpers/UIDevice+RTCDevice.h", | ||
+ "objc/api/peerconnection/RTCAudioDeviceModule.h", | ||
"objc/api/peerconnection/RTCAudioSource.h", | ||
"objc/api/peerconnection/RTCAudioTrack.h", | ||
"objc/api/peerconnection/RTCConfiguration.h", | ||
@@ -1422,6 +1428,7 @@ if (is_ios || is_mac) { | ||
@@ -1412,6 +1418,7 @@ if (is_ios || is_mac) { | ||
output_name = "WebRTC" | ||
|
||
sources = [ | ||
|
@@ -145,7 +145,7 @@ index 0000000000..531bac8eda | |
+@end | ||
\ No newline at end of file | ||
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h | ||
index 5575af98c9..e3774af4a4 100644 | ||
index 17777f6d5d..8533c08efe 100644 | ||
--- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h | ||
+++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h | ||
@@ -10,6 +10,7 @@ | ||
|
@@ -156,7 +156,7 @@ index 5575af98c9..e3774af4a4 100644 | |
#import "RTCMacros.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@@ -51,6 +52,11 @@ RTC_OBJC_EXPORT | ||
@@ -52,6 +53,11 @@ RTC_OBJC_EXPORT | ||
decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory | ||
audioDevice:(nullable id<RTC_OBJC_TYPE(RTCAudioDevice)>)audioDevice; | ||
|
||
|
@@ -165,22 +165,22 @@ index 5575af98c9..e3774af4a4 100644 | |
+ audioDeviceModule:(RTCAudioDeviceModule *)audioDeviceModule | ||
+ NS_AVAILABLE_IOS(2_0); | ||
+ | ||
/** Initialize an RTCAudioSource with constraints. */ | ||
- (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: | ||
(nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints; | ||
/** | ||
* Valid kind values are kRTCMediaStreamTrackKindAudio and | ||
* kRTCMediaStreamTrackKindVideo. | ||
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm | ||
index 62b55543d4..387624dcca 100644 | ||
index 64be41ae15..c6006d5055 100644 | ||
--- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm | ||
+++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm | ||
@@ -14,6 +14,7 @@ | ||
#import "RTCPeerConnectionFactory+Private.h" | ||
@@ -15,6 +15,7 @@ | ||
#import "RTCPeerConnectionFactoryOptions+Private.h" | ||
#import "RTCRtpCapabilities+Private.h" | ||
|
||
+#import "RTCAudioDeviceModule+Private.h" | ||
#import "RTCAudioSource+Private.h" | ||
#import "RTCAudioTrack+Private.h" | ||
#import "RTCMediaConstraints+Private.h" | ||
@@ -116,6 +117,31 @@ - (instancetype)init { | ||
@@ -118,6 +119,31 @@ - (instancetype)init { | ||
#endif | ||
} | ||
|
||
|
@@ -213,7 +213,7 @@ index 62b55543d4..387624dcca 100644 | |
if (self = [super init]) { | ||
_networkThread = rtc::Thread::CreateWithSocketServer(); | ||
diff --git a/sdk/objc/native/src/audio/audio_device_ios.h b/sdk/objc/native/src/audio/audio_device_ios.h | ||
index a86acb56fe..615eec47ee 100644 | ||
index 4ef4d0b5df..2e5f0a0358 100644 | ||
--- a/sdk/objc/native/src/audio/audio_device_ios.h | ||
+++ b/sdk/objc/native/src/audio/audio_device_ios.h | ||
@@ -11,6 +11,8 @@ | ||
|
@@ -256,7 +256,7 @@ index a86acb56fe..615eec47ee 100644 | |
// Counts number of playout callbacks per call. | ||
// The value is updated on the native I/O thread and later read on the | ||
diff --git a/sdk/objc/native/src/audio/audio_device_ios.mm b/sdk/objc/native/src/audio/audio_device_ios.mm | ||
index dd2c11bdd2..2c551922c3 100644 | ||
index 78420ec232..1419fbe9cf 100644 | ||
--- a/sdk/objc/native/src/audio/audio_device_ios.mm | ||
+++ b/sdk/objc/native/src/audio/audio_device_ios.mm | ||
@@ -8,11 +8,11 @@ | ||
|
@@ -270,10 +270,10 @@ index dd2c11bdd2..2c551922c3 100644 | |
|
||
-#include "audio_device_ios.h" | ||
- | ||
#include <mach/mach_time.h> | ||
#include <cmath> | ||
|
||
#include "api/array_view.h" | ||
@@ -106,7 +106,7 @@ static void LogDeviceInfo() { | ||
@@ -107,7 +107,7 @@ static void LogDeviceInfo() { | ||
last_output_volume_change_time_(0) { | ||
LOGI() << "ctor" << ios::GetCurrentThreadDescription() | ||
<< ",bypass_voice_processing=" << bypass_voice_processing_; | ||
|
@@ -282,7 +282,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
thread_ = rtc::Thread::Current(); | ||
|
||
audio_session_observer_ = [[RTCNativeAudioSessionDelegateAdapter alloc] initWithObserver:this]; | ||
@@ -129,7 +129,7 @@ static void LogDeviceInfo() { | ||
@@ -133,7 +133,7 @@ static void LogDeviceInfo() { | ||
|
||
AudioDeviceGeneric::InitStatus AudioDeviceIOS::Init() { | ||
LOGI() << "Init"; | ||
|
@@ -291,7 +291,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
|
||
RTC_DCHECK_RUN_ON(thread_); | ||
if (initialized_) { | ||
@@ -360,12 +360,71 @@ static void LogDeviceInfo() { | ||
@@ -364,12 +364,71 @@ static void LogDeviceInfo() { | ||
thread_->PostTask(SafeTask(safety_, [this] { HandleOutputVolumeChange(); })); | ||
} | ||
|
||
|
@@ -364,19 +364,17 @@ index dd2c11bdd2..2c551922c3 100644 | |
OSStatus result = noErr; | ||
// Simply return if recording is not enabled. | ||
if (!recording_.load(std::memory_order_acquire)) return result; | ||
@@ -413,8 +472,9 @@ static void LogDeviceInfo() { | ||
@@ -423,7 +482,8 @@ static void LogDeviceInfo() { | ||
UInt32 bus_number, | ||
UInt32 num_frames, | ||
AudioBufferList* io_data) { | ||
- RTC_DCHECK_RUN_ON(&io_thread_checker_); | ||
- // Verify 16-bit, noninterleaved mono PCM signal format. | ||
+ // RTC_DCHECK_RUN_ON(&io_thread_checker_); | ||
+ // Verify 16-bit, noninterleaved mono PCM signal format. | ||
+ MutexLock scoped_lock(&io_mutex_); | ||
// Verify 16-bit, noninterleaved mono PCM signal format. | ||
RTC_DCHECK_EQ(1, io_data->mNumberBuffers); | ||
AudioBuffer* audio_buffer = &io_data->mBuffers[0]; | ||
RTC_DCHECK_EQ(1, audio_buffer->mNumberChannels); | ||
@@ -638,15 +698,26 @@ static void LogDeviceInfo() { | ||
@@ -648,15 +708,26 @@ static void LogDeviceInfo() { | ||
// AttachAudioBuffer() is called at construction by the main class but check | ||
// just in case. | ||
RTC_DCHECK(audio_device_buffer_) << "AttachAudioBuffer must be called first"; | ||
|
@@ -412,7 +410,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
} | ||
|
||
void AudioDeviceIOS::SetupAudioBuffersForActiveAudioSession() { | ||
@@ -683,9 +754,13 @@ static void LogDeviceInfo() { | ||
@@ -693,9 +764,13 @@ static void LogDeviceInfo() { | ||
// number of audio frames. | ||
// Example: IO buffer size = 0.008 seconds <=> 128 audio frames at 16kHz. | ||
// Hence, 128 is the size we expect to see in upcoming render callbacks. | ||
|
@@ -428,7 +426,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
RTC_DCHECK(record_parameters_.is_complete()); | ||
RTC_LOG(LS_INFO) << " frames per I/O buffer: " << playout_parameters_.frames_per_buffer(); | ||
RTC_LOG(LS_INFO) << " bytes per I/O buffer: " << playout_parameters_.GetBytesPerBuffer(); | ||
@@ -729,7 +804,12 @@ static void LogDeviceInfo() { | ||
@@ -739,7 +814,12 @@ static void LogDeviceInfo() { | ||
if (!audio_is_initialized_) return; | ||
|
||
// If we're initialized, we must have an audio unit. | ||
|
@@ -442,20 +440,20 @@ index dd2c11bdd2..2c551922c3 100644 | |
|
||
bool should_initialize_audio_unit = false; | ||
bool should_uninitialize_audio_unit = false; | ||
@@ -859,9 +939,9 @@ static void LogDeviceInfo() { | ||
@@ -869,9 +949,9 @@ static void LogDeviceInfo() { | ||
RTC_DCHECK_RUN_ON(thread_); | ||
|
||
// There should be no audio unit at this point. | ||
- if (!CreateAudioUnit()) { | ||
- return false; | ||
- } | ||
+ // if (!CreateAudioUnit()) { | ||
+ // return false; | ||
+ //} | ||
+ // return false; | ||
+ // } | ||
|
||
RTC_OBJC_TYPE(RTCAudioSession)* session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; | ||
// Subscribe to audio session events. | ||
@@ -881,6 +961,25 @@ static void LogDeviceInfo() { | ||
@@ -891,6 +971,25 @@ static void LogDeviceInfo() { | ||
// If we are ready to play or record, and if the audio session can be | ||
// configured, then initialize the audio unit. | ||
if (session.canPlayOrRecord) { | ||
|
@@ -481,7 +479,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
if (!ConfigureAudioSessionLocked()) { | ||
// One possible reason for failure is if an attempt was made to use the | ||
// audio session during or after a Media Services failure. | ||
@@ -910,7 +1009,7 @@ static void LogDeviceInfo() { | ||
@@ -920,7 +1019,7 @@ static void LogDeviceInfo() { | ||
|
||
// Detach thread checker for the AURemoteIO::IOThread to ensure that the | ||
// next session uses a fresh thread id. | ||
|
@@ -490,7 +488,7 @@ index dd2c11bdd2..2c551922c3 100644 | |
|
||
// Remove audio session notification observers. | ||
RTC_OBJC_TYPE(RTCAudioSession)* session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; | ||
@@ -927,7 +1026,7 @@ static void LogDeviceInfo() { | ||
@@ -937,7 +1036,7 @@ static void LogDeviceInfo() { | ||
// restart. It will result in audio callbacks from a new native I/O thread | ||
// which means that we must detach thread checkers here to be prepared for an | ||
// upcoming new audio stream. | ||
|
@@ -682,9 +680,9 @@ index 3905b6857a..665d790336 100644 | |
|
||
// Set the format on the input scope of the output element/bus. | ||
-- | ||
2.39.3 (Apple Git-145) | ||
2.39.3 (Apple Git-146) | ||
|
||
From b8a74f487081b40cc8d0f38ce17e2288300fa212 Mon Sep 17 00:00:00 2001 | ||
From 0f5fb89953bae1025733688c0a24330372af4852 Mon Sep 17 00:00:00 2001 | ||
From: mekya <[email protected]> | ||
Date: Sat, 26 Nov 2022 15:44:59 +0300 | ||
Subject: [PATCH 2/2] Enable/disable external audio for audio device | ||
|
@@ -737,7 +735,7 @@ index 531bac8eda..542aeb31cc 100644 | |
\ No newline at end of file | ||
+@end | ||
diff --git a/sdk/objc/native/src/audio/audio_device_ios.h b/sdk/objc/native/src/audio/audio_device_ios.h | ||
index 615eec47ee..1aa42a4844 100644 | ||
index 2e5f0a0358..fc3d691e7b 100644 | ||
--- a/sdk/objc/native/src/audio/audio_device_ios.h | ||
+++ b/sdk/objc/native/src/audio/audio_device_ios.h | ||
@@ -158,6 +158,9 @@ class AudioDeviceIOS : public AudioDeviceGeneric, | ||
|
@@ -762,18 +760,18 @@ index 615eec47ee..1aa42a4844 100644 | |
RTCNativeAudioSessionDelegateAdapter* audio_session_observer_ | ||
RTC_GUARDED_BY(thread_); | ||
diff --git a/sdk/objc/native/src/audio/audio_device_ios.mm b/sdk/objc/native/src/audio/audio_device_ios.mm | ||
index 2c551922c3..f91ad208e2 100644 | ||
index 1419fbe9cf..174d4593d7 100644 | ||
--- a/sdk/objc/native/src/audio/audio_device_ios.mm | ||
+++ b/sdk/objc/native/src/audio/audio_device_ios.mm | ||
@@ -99,6 +99,7 @@ static void LogDeviceInfo() { | ||
@@ -100,6 +100,7 @@ static void LogDeviceInfo() { | ||
initialized_(false), | ||
audio_is_initialized_(false), | ||
is_interrupted_(false), | ||
+ externalAudio_(false), | ||
has_configured_session_(false), | ||
num_detected_playout_glitches_(0), | ||
last_playout_time_(0), | ||
@@ -360,11 +361,15 @@ static void LogDeviceInfo() { | ||
@@ -364,11 +365,15 @@ static void LogDeviceInfo() { | ||
thread_->PostTask(SafeTask(safety_, [this] { HandleOutputVolumeChange(); })); | ||
} | ||
|
||
|
@@ -791,7 +789,7 @@ index 2c551922c3..f91ad208e2 100644 | |
return; | ||
} | ||
|
||
@@ -423,6 +428,10 @@ static void LogDeviceInfo() { | ||
@@ -427,6 +432,10 @@ static void LogDeviceInfo() { | ||
UInt32 bus_number, | ||
UInt32 num_frames, | ||
AudioBufferList* /* io_data */) { | ||
|
@@ -858,5 +856,5 @@ index 1753e0820d..30ee6cb0ad 100644 | |
|
||
int AudioDeviceModuleIOS::GetPlayoutAudioParameters( | ||
-- | ||
2.39.3 (Apple Git-145) | ||
2.39.3 (Apple Git-146) | ||
|