Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This repository is a fork of the WebRTC project. The original README can be foun

### Fork Specifics

#### Features

- Stereo playout/recording on iOS [#58](https://github.com/GetStream/webrtc/pull/58)

#### `.gitignore`

Due to the fork specifics, the repo's `.gitignore` has been updated to match the fork's requirements.
Expand Down
3 changes: 2 additions & 1 deletion sdk/objc/native/api/audio_device_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace webrtc {

// If `bypass_voice_processing` is true, WebRTC will attempt to disable hardware
// audio processing on iOS.
// audio processing on iOS. Stereo capture is automatically configured to bypass
// voice processing even if this parameter is left as false.
// Warning: Setting `bypass_voice_processing` will have unpredictable
// consequences for the audio path in the device. It is not advisable to use in
// most scenarios.
Expand Down
36 changes: 33 additions & 3 deletions sdk/objc/native/src/audio/audio_device_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class AudioDeviceIOS : public AudioDeviceGeneric,
int32_t SetStereoPlayout(bool enable) override;
int32_t StereoPlayout(bool& enabled) const override;
int32_t StereoRecordingIsAvailable(bool& available) override;
// Enabling stereo recording automatically bypasses the hardware voice
// processing (AEC/AGC) stage since the Voice Processing I/O unit only
// supports mono processing. See UpdateVoiceProcessingBypassRequirement().
int32_t SetStereoRecording(bool enable) override;
int32_t StereoRecording(bool& enabled) const override;

Expand Down Expand Up @@ -195,14 +198,38 @@ class AudioDeviceIOS : public AudioDeviceGeneric,
// This method asks for the current hardware parameters and takes actions
// if they should differ from what we have asked for initially. It also
// defines `playout_parameters_` and `record_parameters_`.
void SetupAudioBuffersForActiveAudioSession();
void SetupAudioBuffersForActiveAudioSession() RTC_RUN_ON(thread_);

// Creates the audio unit.
bool CreateAudioUnit();
bool CreateAudioUnit() RTC_RUN_ON(thread_);

// Updates the audio unit state based on current state.
void UpdateAudioUnit(bool can_play_or_record);

// Ensures the hardware voice-processing stage is bypassed when multi-channel
// playout or recording is requested. If the audio unit is already running,
// the updated state will be applied on the next initialization.
void UpdateVoiceProcessingBypassRequirement() RTC_RUN_ON(thread_);

// Updates the preferred channel counts stored in
// RTCAudioSessionConfiguration so forthcoming session activations request
// the desired layout.
void UpdateAudioSessionChannelPreferences() RTC_RUN_ON(thread_);

// Reconfigures the audio session and restarts the audio unit to apply
// updated channel counts while streaming. Returns true on success or when no
// reconfiguration is required.
bool ApplyChannelConfigurationChange() RTC_RUN_ON(thread_);

// Applies a channel configuration change and rolls back to the previous
// state if the update fails. Returns true when the change is successful.
bool ApplyChannelConfigurationChangeOrRollback(
const char* failure_log_message,
size_t previous_desired_playout,
size_t previous_desired_record,
const AudioParameters& previous_playout_parameters,
const AudioParameters& previous_record_parameters) RTC_RUN_ON(thread_);

// Configures the audio session for WebRTC.
bool ConfigureAudioSession();

Expand All @@ -223,7 +250,10 @@ class AudioDeviceIOS : public AudioDeviceGeneric,
void PrepareForNewStart();

// Determines whether voice processing should be enabled or disabled.
const bool bypass_voice_processing_;
const bool default_bypass_voice_processing_;
bool bypass_voice_processing_ RTC_GUARDED_BY(thread_);
size_t desired_playout_channels_ RTC_GUARDED_BY(thread_);
size_t desired_record_channels_ RTC_GUARDED_BY(thread_);

// Handle a user speaking during muted event
AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler_;
Expand Down
Loading