diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 7c74df1c87..a0cf5b55d3 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -119,7 +119,6 @@ if (is_ios || is_mac) { "objc/base/RTCVideoFrame.mm", "objc/base/RTCVideoFrameBuffer.h", "objc/base/RTCVideoRenderer.h", - "objc/base/RTCAudioRenderer.h", "objc/base/RTCYUVPlanarBuffer.h", ] @@ -141,9 +140,9 @@ if (is_ios || is_mac) { "objc/helpers/AVCaptureSession+DevicePosition.mm", "objc/helpers/NSString+StdString.h", "objc/helpers/NSString+StdString.mm", - "objc/helpers/RTCDispatcher+Private.h", "objc/helpers/RTCDispatcher.h", "objc/helpers/RTCDispatcher.m", + "objc/helpers/RTCDispatcher+Private.h", "objc/helpers/RTCYUVHelper.h", "objc/helpers/RTCYUVHelper.mm", "objc/helpers/scoped_cftyperef.h", @@ -705,15 +704,15 @@ if (is_ios || is_mac) { rtc_library("desktopcapture_objc") { visibility = [ "*" ] sources = [ - "objc/components/capturer/RTCDesktopCapturer+Private.h", "objc/components/capturer/RTCDesktopCapturer.h", "objc/components/capturer/RTCDesktopCapturer.mm", - "objc/components/capturer/RTCDesktopSource+Private.h", - "objc/components/capturer/RTCDesktopSource.h", - "objc/components/capturer/RTCDesktopSource.mm", - "objc/components/capturer/RTCDesktopMediaList+Private.h", + "objc/components/capturer/RTCDesktopCapturer+Private.h", "objc/components/capturer/RTCDesktopMediaList.h", "objc/components/capturer/RTCDesktopMediaList.mm", + "objc/components/capturer/RTCDesktopMediaList+Private.h", + "objc/components/capturer/RTCDesktopSource.h", + "objc/components/capturer/RTCDesktopSource.mm", + "objc/components/capturer/RTCDesktopSource+Private.h", "objc/native/src/objc_desktop_capture.h", "objc/native/src/objc_desktop_capture.mm", "objc/native/src/objc_desktop_media_list.h", @@ -743,9 +742,9 @@ if (is_ios || is_mac) { visibility = [ "*" ] configs += [ "..:no_global_constructors" ] sources = [ - "objc/components/video_codec/RTCCodecSpecificInfoH264+Private.h", "objc/components/video_codec/RTCCodecSpecificInfoH264.h", "objc/components/video_codec/RTCCodecSpecificInfoH264.mm", + "objc/components/video_codec/RTCCodecSpecificInfoH264+Private.h", "objc/components/video_codec/RTCH264ProfileLevelId.h", "objc/components/video_codec/RTCH264ProfileLevelId.mm", ] @@ -882,10 +881,10 @@ if (is_ios || is_mac) { rtc_library("simulcast") { sources = [ - "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h", - "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.mm", "objc/api/video_codec/RTCVideoEncoderSimulcast.h", "objc/api/video_codec/RTCVideoEncoderSimulcast.mm", + "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h", + "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.mm", ] deps = [ @@ -899,9 +898,9 @@ if (is_ios || is_mac) { rtc_library("mediaconstraints_objc") { configs += [ "..:no_global_constructors" ] sources = [ - "objc/api/peerconnection/RTCMediaConstraints+Private.h", "objc/api/peerconnection/RTCMediaConstraints.h", "objc/api/peerconnection/RTCMediaConstraints.mm", + "objc/api/peerconnection/RTCMediaConstraints+Private.h", ] public_configs = [ ":common_config_objc" ] @@ -927,9 +926,9 @@ if (is_ios || is_mac) { visibility = [ "*" ] allow_poison = [ "audio_codecs" ] # TODO(bugs.webrtc.org/8396): Remove. sources = [ - "objc/api/RTCVideoRendererAdapter+Private.h", "objc/api/RTCVideoRendererAdapter.h", "objc/api/RTCVideoRendererAdapter.mm", + "objc/api/RTCVideoRendererAdapter+Private.h", ] configs += [ "..:common_objc" ] @@ -946,9 +945,9 @@ if (is_ios || is_mac) { rtc_library("mediasource_objc") { sources = [ - "objc/api/peerconnection/RTCMediaSource+Private.h", "objc/api/peerconnection/RTCMediaSource.h", "objc/api/peerconnection/RTCMediaSource.mm", + "objc/api/peerconnection/RTCMediaSource+Private.h", ] configs += [ @@ -998,125 +997,141 @@ if (is_ios || is_mac) { configs += [ "..:no_global_constructors" ] sources = [ "objc/api/peerconnection/RTCAudioDeviceModule.h", - "objc/api/peerconnection/RTCAudioDeviceModule+Private.h", "objc/api/peerconnection/RTCAudioDeviceModule.mm", - "objc/api/peerconnection/RTCIODevice.h", - "objc/api/peerconnection/RTCIODevice.mm", - "objc/api/peerconnection/RTCAudioSource+Private.h", + "objc/api/peerconnection/RTCAudioDeviceModule+Private.h", + "objc/api/peerconnection/RTCAudioSource.h", "objc/api/peerconnection/RTCAudioSource.h", "objc/api/peerconnection/RTCAudioSource.mm", - "objc/api/peerconnection/RTCAudioTrack+Private.h", + "objc/api/peerconnection/RTCAudioSource+Private.h", + "objc/api/peerconnection/RTCAudioSource+Private.h", "objc/api/peerconnection/RTCAudioTrack.h", "objc/api/peerconnection/RTCAudioTrack.mm", + "objc/api/peerconnection/RTCAudioTrack+Private.h", "objc/api/peerconnection/RTCCertificate.h", "objc/api/peerconnection/RTCCertificate.mm", - "objc/api/peerconnection/RTCConfiguration+Native.h", - "objc/api/peerconnection/RTCConfiguration+Private.h", "objc/api/peerconnection/RTCConfiguration.h", "objc/api/peerconnection/RTCConfiguration.mm", + "objc/api/peerconnection/RTCConfiguration+Native.h", + "objc/api/peerconnection/RTCConfiguration+Private.h", "objc/api/peerconnection/RTCCryptoOptions.h", "objc/api/peerconnection/RTCCryptoOptions.mm", - "objc/api/peerconnection/RTCDataChannel+Private.h", "objc/api/peerconnection/RTCDataChannel.h", "objc/api/peerconnection/RTCDataChannel.mm", - "objc/api/peerconnection/RTCDataChannelConfiguration+Private.h", + "objc/api/peerconnection/RTCDataChannel+Private.h", "objc/api/peerconnection/RTCDataChannelConfiguration.h", "objc/api/peerconnection/RTCDataChannelConfiguration.mm", - "objc/api/peerconnection/RTCDtmfSender+Private.h", + "objc/api/peerconnection/RTCDataChannelConfiguration+Private.h", "objc/api/peerconnection/RTCDtmfSender.h", "objc/api/peerconnection/RTCDtmfSender.mm", + "objc/api/peerconnection/RTCDtmfSender+Private.h", "objc/api/peerconnection/RTCFieldTrials.h", "objc/api/peerconnection/RTCFieldTrials.mm", - "objc/api/peerconnection/RTCFrameCryptor+Private.h", "objc/api/peerconnection/RTCFrameCryptor.h", "objc/api/peerconnection/RTCFrameCryptor.mm", - "objc/api/peerconnection/RTCFrameCryptorKeyProvider+Private.h", + "objc/api/peerconnection/RTCFrameCryptor+Private.h", "objc/api/peerconnection/RTCFrameCryptorKeyProvider.h", "objc/api/peerconnection/RTCFrameCryptorKeyProvider.mm", - "objc/api/peerconnection/RTCIceCandidate+Private.h", + "objc/api/peerconnection/RTCFrameCryptorKeyProvider+Private.h", "objc/api/peerconnection/RTCIceCandidate.h", "objc/api/peerconnection/RTCIceCandidate.mm", - "objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h", + "objc/api/peerconnection/RTCIceCandidate+Private.h", "objc/api/peerconnection/RTCIceCandidateErrorEvent.h", "objc/api/peerconnection/RTCIceCandidateErrorEvent.mm", - "objc/api/peerconnection/RTCIceServer+Private.h", + "objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h", "objc/api/peerconnection/RTCIceServer.h", "objc/api/peerconnection/RTCIceServer.mm", - "objc/api/peerconnection/RTCLegacyStatsReport+Private.h", + "objc/api/peerconnection/RTCIceServer+Private.h", + "objc/api/peerconnection/RTCIODevice.h", + "objc/api/peerconnection/RTCIODevice.mm", "objc/api/peerconnection/RTCLegacyStatsReport.h", "objc/api/peerconnection/RTCLegacyStatsReport.mm", - "objc/api/peerconnection/RTCMediaStream+Private.h", + "objc/api/peerconnection/RTCLegacyStatsReport+Private.h", "objc/api/peerconnection/RTCMediaStream.h", "objc/api/peerconnection/RTCMediaStream.mm", - "objc/api/peerconnection/RTCMediaStreamTrack+Private.h", + "objc/api/peerconnection/RTCMediaStream+Private.h", "objc/api/peerconnection/RTCMediaStreamTrack.h", "objc/api/peerconnection/RTCMediaStreamTrack.mm", + "objc/api/peerconnection/RTCMediaStreamTrack+Private.h", "objc/api/peerconnection/RTCMetrics.h", "objc/api/peerconnection/RTCMetrics.mm", - "objc/api/peerconnection/RTCMetricsSampleInfo+Private.h", "objc/api/peerconnection/RTCMetricsSampleInfo.h", "objc/api/peerconnection/RTCMetricsSampleInfo.mm", + "objc/api/peerconnection/RTCMetricsSampleInfo+Private.h", + "objc/api/peerconnection/RTCPeerConnection.h", + "objc/api/peerconnection/RTCPeerConnection.mm", "objc/api/peerconnection/RTCPeerConnection+DataChannel.mm", "objc/api/peerconnection/RTCPeerConnection+Private.h", "objc/api/peerconnection/RTCPeerConnection+Stats.mm", - "objc/api/peerconnection/RTCPeerConnection.h", - "objc/api/peerconnection/RTCPeerConnection.mm", - "objc/api/peerconnection/RTCPeerConnectionFactory+Native.h", - "objc/api/peerconnection/RTCPeerConnectionFactory+Private.h", "objc/api/peerconnection/RTCPeerConnectionFactory.h", "objc/api/peerconnection/RTCPeerConnectionFactory.mm", - "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h", - "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm", + "objc/api/peerconnection/RTCPeerConnectionFactory+Native.h", + "objc/api/peerconnection/RTCPeerConnectionFactory+Private.h", "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h", "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm", - "objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h", + "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.h", + "objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.mm", - "objc/api/peerconnection/RTCRtcpParameters+Private.h", + "objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h", "objc/api/peerconnection/RTCRtcpParameters.h", "objc/api/peerconnection/RTCRtcpParameters.mm", + "objc/api/peerconnection/RTCRtcpParameters+Private.h", "objc/api/peerconnection/RTCRtpCapabilities.h", "objc/api/peerconnection/RTCRtpCapabilities.mm", "objc/api/peerconnection/RTCRtpCapabilities+Private.h", "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecCapability.mm", "objc/api/peerconnection/RTCRtpCodecCapability+Private.h", - "objc/api/peerconnection/RTCRtpCodecParameters+Private.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpCodecParameters.mm", - "objc/api/peerconnection/RTCRtpEncodingParameters+Private.h", + "objc/api/peerconnection/RTCRtpCodecParameters+Private.h", "objc/api/peerconnection/RTCRtpEncodingParameters.h", "objc/api/peerconnection/RTCRtpEncodingParameters.mm", - "objc/api/peerconnection/RTCRtpHeaderExtension+Private.h", + "objc/api/peerconnection/RTCRtpEncodingParameters+Private.h", "objc/api/peerconnection/RTCRtpHeaderExtension.h", "objc/api/peerconnection/RTCRtpHeaderExtension.mm", - "objc/api/peerconnection/RTCRtpParameters+Private.h", + "objc/api/peerconnection/RTCRtpHeaderExtension+Private.h", "objc/api/peerconnection/RTCRtpParameters.h", "objc/api/peerconnection/RTCRtpParameters.mm", - "objc/api/peerconnection/RTCRtpReceiver+Native.h", - "objc/api/peerconnection/RTCRtpReceiver+Private.h", + "objc/api/peerconnection/RTCRtpParameters+Private.h", "objc/api/peerconnection/RTCRtpReceiver.h", "objc/api/peerconnection/RTCRtpReceiver.mm", - "objc/api/peerconnection/RTCRtpSender+Native.h", - "objc/api/peerconnection/RTCRtpSender+Private.h", + "objc/api/peerconnection/RTCRtpReceiver+Native.h", + "objc/api/peerconnection/RTCRtpReceiver+Private.h", "objc/api/peerconnection/RTCRtpSender.h", "objc/api/peerconnection/RTCRtpSender.mm", - "objc/api/peerconnection/RTCRtpTransceiver+Private.h", + "objc/api/peerconnection/RTCRtpSender+Native.h", + "objc/api/peerconnection/RTCRtpSender+Private.h", "objc/api/peerconnection/RTCRtpTransceiver.h", "objc/api/peerconnection/RTCRtpTransceiver.mm", - "objc/api/peerconnection/RTCSSLAdapter.h", - "objc/api/peerconnection/RTCSSLAdapter.mm", - "objc/api/peerconnection/RTCSessionDescription+Private.h", + "objc/api/peerconnection/RTCRtpTransceiver+Private.h", "objc/api/peerconnection/RTCSessionDescription.h", "objc/api/peerconnection/RTCSessionDescription.mm", - "objc/api/peerconnection/RTCStatisticsReport+Private.h", + "objc/api/peerconnection/RTCSessionDescription+Private.h", + "objc/api/peerconnection/RTCSSLAdapter.h", + "objc/api/peerconnection/RTCSSLAdapter.mm", "objc/api/peerconnection/RTCStatisticsReport.h", "objc/api/peerconnection/RTCStatisticsReport.mm", + "objc/api/peerconnection/RTCStatisticsReport+Private.h", "objc/api/peerconnection/RTCTracing.h", "objc/api/peerconnection/RTCTracing.mm", - "objc/api/peerconnection/RTCVideoTrack+Private.h", "objc/api/peerconnection/RTCVideoTrack.h", "objc/api/peerconnection/RTCVideoTrack.mm", + "objc/api/peerconnection/RTCVideoTrack+Private.h", + "objc/components/audio/RTCAudioBuffer.h", + "objc/components/audio/RTCAudioBuffer.mm", + "objc/components/audio/RTCAudioBuffer+Private.h", + "objc/components/audio/RTCAudioCustomProcessingAdapter.h", + "objc/components/audio/RTCAudioCustomProcessingAdapter.mm", + "objc/components/audio/RTCAudioCustomProcessingAdapter+Private.h", + "objc/components/audio/RTCAudioCustomProcessingDelegate.h", + "objc/components/audio/RTCAudioProcessingConfig.h", + "objc/components/audio/RTCAudioProcessingConfig.mm", + "objc/components/audio/RTCAudioProcessingConfig+Private.h", + "objc/components/audio/RTCAudioProcessingModule.h", + "objc/components/audio/RTCDefaultAudioProcessingModule.h", + "objc/components/audio/RTCDefaultAudioProcessingModule.mm", + "objc/components/audio/RTCDefaultAudioProcessingModule+Private.h", ] configs += [ @@ -1197,34 +1212,34 @@ if (is_ios || is_mac) { include_dirs = [ "objc/" ] sources = [ + "objc/unittests/frame_buffer_helpers.h", + "objc/unittests/frame_buffer_helpers.mm", + "objc/unittests/nalu_rewriter_xctest.mm", + "objc/unittests/objc_video_decoder_factory_tests.mm", + "objc/unittests/objc_video_encoder_factory_tests.mm", "objc/unittests/ObjCVideoTrackSource_xctest.mm", - "objc/unittests/RTCAudioDeviceModule_xctest.mm", "objc/unittests/RTCAudioDevice_xctest.mm", + "objc/unittests/RTCAudioDeviceModule_xctest.mm", "objc/unittests/RTCAudioSessionTest.mm", - "objc/unittests/RTCCVPixelBuffer_xctest.mm", "objc/unittests/RTCCallbackLogger_xctest.m", "objc/unittests/RTCCameraVideoCapturerTests.mm", "objc/unittests/RTCCertificateTest.mm", "objc/unittests/RTCConfigurationTest.mm", + "objc/unittests/RTCCVPixelBuffer_xctest.mm", "objc/unittests/RTCDataChannelConfigurationTest.mm", "objc/unittests/RTCEncodedImage_xctest.mm", "objc/unittests/RTCFileVideoCapturer_xctest.mm", "objc/unittests/RTCH264ProfileLevelId_xctest.m", "objc/unittests/RTCIceCandidateTest.mm", "objc/unittests/RTCIceServerTest.mm", - "objc/unittests/RTCMTLVideoView_xctest.m", "objc/unittests/RTCMediaConstraintsTest.mm", + "objc/unittests/RTCMTLVideoView_xctest.m", "objc/unittests/RTCNV12TextureCache_xctest.m", - "objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm", "objc/unittests/RTCPeerConnectionFactory_xctest.m", + "objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm", "objc/unittests/RTCPeerConnectionTest.mm", "objc/unittests/RTCSessionDescriptionTest.mm", "objc/unittests/RTCTracingTest.mm", - "objc/unittests/frame_buffer_helpers.h", - "objc/unittests/frame_buffer_helpers.mm", - "objc/unittests/nalu_rewriter_xctest.mm", - "objc/unittests/objc_video_decoder_factory_tests.mm", - "objc/unittests/objc_video_encoder_factory_tests.mm", "objc/unittests/scoped_cftyperef_tests.mm", ] @@ -1318,8 +1333,8 @@ if (is_ios || is_mac) { is_xctest = true info_plist = "//test/ios/Info.plist" sources = [ - "objc/unittests/RTCDoNotPutCPlusPlusInFrameworkHeaders_xctest.m", "objc/unittests/main.mm", + "objc/unittests/RTCDoNotPutCPlusPlusInFrameworkHeaders_xctest.m", ] extra_substitutions = [ "GTEST_BUNDLE_ID_SUFFIX=generic-unit-test" ] @@ -1339,62 +1354,22 @@ if (is_ios || is_mac) { output_name = "WebRTC" common_objc_headers = [ - "objc/base/RTCCodecSpecificInfo.h", - "objc/base/RTCEncodedImage.h", - "objc/base/RTCI420Buffer.h", - "objc/base/RTCLogging.h", - "objc/base/RTCMacros.h", - "objc/base/RTCMutableI420Buffer.h", - "objc/base/RTCMutableYUVPlanarBuffer.h", - "objc/base/RTCSSLCertificateVerifier.h", - "objc/base/RTCVideoCapturer.h", - "objc/base/RTCVideoCodecInfo.h", - "objc/base/RTCVideoDecoder.h", - "objc/base/RTCVideoDecoderFactory.h", - "objc/base/RTCVideoEncoder.h", - "objc/base/RTCVideoEncoderFactory.h", - "objc/base/RTCVideoEncoderQpThresholds.h", - "objc/base/RTCVideoEncoderSettings.h", - "objc/base/RTCVideoFrame.h", - "objc/base/RTCVideoFrameBuffer.h", - "objc/base/RTCVideoRenderer.h", - "objc/base/RTCAudioRenderer.h", - "objc/base/RTCYUVPlanarBuffer.h", - "objc/components/audio/RTCAudioDevice.h", - "objc/components/audio/RTCAudioSession.h", - "objc/components/audio/RTCAudioSessionConfiguration.h", - "objc/components/capturer/RTCCameraVideoCapturer.h", - "objc/components/capturer/RTCFileVideoCapturer.h", - "objc/components/network/RTCNetworkMonitor.h", - "objc/components/renderer/metal/RTCMTLVideoView.h", - "objc/components/renderer/opengl/RTCEAGLVideoView.h", - "objc/components/renderer/opengl/RTCVideoViewShading.h", - "objc/components/video_codec/RTCCodecSpecificInfoH264.h", - "objc/components/video_codec/RTCDefaultVideoDecoderFactory.h", - "objc/components/video_codec/RTCDefaultVideoEncoderFactory.h", - "objc/components/video_codec/RTCH264ProfileLevelId.h", - "objc/components/video_codec/RTCVideoDecoderFactoryH264.h", - "objc/components/video_codec/RTCVideoDecoderH264.h", - "objc/components/video_codec/RTCVideoEncoderFactoryH264.h", - "objc/components/video_codec/RTCVideoEncoderH264.h", - "objc/components/video_frame_buffer/RTCCVPixelBuffer.h", - "objc/helpers/RTCCameraPreviewView.h", - "objc/helpers/RTCDispatcher.h", - "objc/helpers/RTCYUVHelper.h", - "objc/helpers/UIDevice+RTCDevice.h", "objc/api/peerconnection/RTCAudioDeviceModule.h", - "objc/api/peerconnection/RTCIODevice.h", "objc/api/peerconnection/RTCAudioSource.h", "objc/api/peerconnection/RTCAudioTrack.h", + "objc/api/peerconnection/RTCCertificate.h", "objc/api/peerconnection/RTCConfiguration.h", + "objc/api/peerconnection/RTCCryptoOptions.h", "objc/api/peerconnection/RTCDataChannel.h", "objc/api/peerconnection/RTCDataChannelConfiguration.h", + "objc/api/peerconnection/RTCDtmfSender.h", + "objc/api/peerconnection/RTCFieldTrials.h", "objc/api/peerconnection/RTCFrameCryptor.h", "objc/api/peerconnection/RTCFrameCryptorKeyProvider.h", - "objc/api/peerconnection/RTCFieldTrials.h", "objc/api/peerconnection/RTCIceCandidate.h", "objc/api/peerconnection/RTCIceCandidateErrorEvent.h", "objc/api/peerconnection/RTCIceServer.h", + "objc/api/peerconnection/RTCIODevice.h", "objc/api/peerconnection/RTCLegacyStatsReport.h", "objc/api/peerconnection/RTCMediaConstraints.h", "objc/api/peerconnection/RTCMediaSource.h", @@ -1415,27 +1390,71 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCRtpReceiver.h", "objc/api/peerconnection/RTCRtpSender.h", "objc/api/peerconnection/RTCRtpTransceiver.h", - "objc/api/peerconnection/RTCDtmfSender.h", - "objc/api/peerconnection/RTCSSLAdapter.h", "objc/api/peerconnection/RTCSessionDescription.h", + "objc/api/peerconnection/RTCSSLAdapter.h", "objc/api/peerconnection/RTCStatisticsReport.h", "objc/api/peerconnection/RTCTracing.h", - "objc/api/peerconnection/RTCCertificate.h", - "objc/api/peerconnection/RTCCryptoOptions.h", "objc/api/peerconnection/RTCVideoSource.h", "objc/api/peerconnection/RTCVideoTrack.h", "objc/api/video_codec/RTCVideoCodecConstants.h", + "objc/api/video_codec/RTCVideoDecoderAV1.h", "objc/api/video_codec/RTCVideoDecoderVP8.h", "objc/api/video_codec/RTCVideoDecoderVP9.h", - "objc/api/video_codec/RTCVideoDecoderAV1.h", + "objc/api/video_codec/RTCVideoEncoderAV1.h", + "objc/api/video_codec/RTCVideoEncoderSimulcast.h", "objc/api/video_codec/RTCVideoEncoderVP8.h", "objc/api/video_codec/RTCVideoEncoderVP9.h", - "objc/api/video_codec/RTCVideoEncoderAV1.h", "objc/api/video_frame_buffer/RTCNativeI420Buffer.h", "objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h", - # Added for Simulcast support + "objc/base/RTCAudioRenderer.h", + "objc/base/RTCCodecSpecificInfo.h", + "objc/base/RTCEncodedImage.h", + "objc/base/RTCI420Buffer.h", + "objc/base/RTCLogging.h", + "objc/base/RTCMacros.h", + "objc/base/RTCMutableI420Buffer.h", + "objc/base/RTCMutableYUVPlanarBuffer.h", + "objc/base/RTCSSLCertificateVerifier.h", + "objc/base/RTCVideoCapturer.h", + "objc/base/RTCVideoCodecInfo.h", + "objc/base/RTCVideoDecoder.h", + "objc/base/RTCVideoDecoderFactory.h", + "objc/base/RTCVideoEncoder.h", + "objc/base/RTCVideoEncoderFactory.h", + "objc/base/RTCVideoEncoderQpThresholds.h", + "objc/base/RTCVideoEncoderSettings.h", + "objc/base/RTCVideoFrame.h", + "objc/base/RTCVideoFrameBuffer.h", + "objc/base/RTCVideoRenderer.h", + "objc/base/RTCYUVPlanarBuffer.h", + "objc/components/audio/RTCAudioBuffer.h", + "objc/components/audio/RTCAudioCustomProcessingDelegate.h", + "objc/components/audio/RTCAudioDevice.h", + "objc/components/audio/RTCAudioProcessingConfig.h", + "objc/components/audio/RTCAudioProcessingModule.h", + "objc/components/audio/RTCAudioSession.h", + "objc/components/audio/RTCAudioSessionConfiguration.h", + "objc/components/audio/RTCDefaultAudioProcessingModule.h", + "objc/components/capturer/RTCCameraVideoCapturer.h", + "objc/components/capturer/RTCFileVideoCapturer.h", + "objc/components/network/RTCNetworkMonitor.h", + "objc/components/renderer/metal/RTCMTLVideoView.h", + "objc/components/renderer/opengl/RTCEAGLVideoView.h", + "objc/components/renderer/opengl/RTCVideoViewShading.h", + "objc/components/video_codec/RTCCodecSpecificInfoH264.h", + "objc/components/video_codec/RTCDefaultVideoDecoderFactory.h", + "objc/components/video_codec/RTCDefaultVideoEncoderFactory.h", + "objc/components/video_codec/RTCH264ProfileLevelId.h", + "objc/components/video_codec/RTCVideoDecoderFactoryH264.h", + "objc/components/video_codec/RTCVideoDecoderH264.h", + "objc/components/video_codec/RTCVideoEncoderFactoryH264.h", "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h", - "objc/api/video_codec/RTCVideoEncoderSimulcast.h", + "objc/components/video_codec/RTCVideoEncoderH264.h", + "objc/components/video_frame_buffer/RTCCVPixelBuffer.h", + "objc/helpers/RTCCameraPreviewView.h", + "objc/helpers/RTCDispatcher.h", + "objc/helpers/RTCYUVHelper.h", + "objc/helpers/UIDevice+RTCDevice.h", ] if (!build_with_chromium) { @@ -1506,7 +1525,6 @@ if (is_ios || is_mac) { sources = [ "objc/api/peerconnection/RTCAudioDeviceModule.h", - "objc/api/peerconnection/RTCIODevice.h", "objc/api/peerconnection/RTCAudioSource.h", "objc/api/peerconnection/RTCAudioTrack.h", "objc/api/peerconnection/RTCCertificate.h", @@ -1515,12 +1533,13 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCDataChannel.h", "objc/api/peerconnection/RTCDataChannelConfiguration.h", "objc/api/peerconnection/RTCDtmfSender.h", + "objc/api/peerconnection/RTCFieldTrials.h", "objc/api/peerconnection/RTCFrameCryptor.h", "objc/api/peerconnection/RTCFrameCryptorKeyProvider.h", - "objc/api/peerconnection/RTCFieldTrials.h", "objc/api/peerconnection/RTCIceCandidate.h", "objc/api/peerconnection/RTCIceCandidateErrorEvent.h", "objc/api/peerconnection/RTCIceServer.h", + "objc/api/peerconnection/RTCIODevice.h", "objc/api/peerconnection/RTCLegacyStatsReport.h", "objc/api/peerconnection/RTCMediaConstraints.h", "objc/api/peerconnection/RTCMediaSource.h", @@ -1541,8 +1560,8 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCRtpReceiver.h", "objc/api/peerconnection/RTCRtpSender.h", "objc/api/peerconnection/RTCRtpTransceiver.h", - "objc/api/peerconnection/RTCSSLAdapter.h", "objc/api/peerconnection/RTCSessionDescription.h", + "objc/api/peerconnection/RTCSSLAdapter.h", "objc/api/peerconnection/RTCStatisticsReport.h", "objc/api/peerconnection/RTCTracing.h", "objc/api/peerconnection/RTCVideoSource.h", @@ -1551,10 +1570,12 @@ if (is_ios || is_mac) { "objc/api/video_codec/RTCVideoDecoderVP8.h", "objc/api/video_codec/RTCVideoDecoderVP9.h", "objc/api/video_codec/RTCVideoEncoderAV1.h", + "objc/api/video_codec/RTCVideoEncoderSimulcast.h", "objc/api/video_codec/RTCVideoEncoderVP8.h", "objc/api/video_codec/RTCVideoEncoderVP9.h", "objc/api/video_frame_buffer/RTCNativeI420Buffer.h", "objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h", + "objc/base/RTCAudioRenderer.h", "objc/base/RTCCodecSpecificInfo.h", "objc/base/RTCEncodedImage.h", "objc/base/RTCI420Buffer.h", @@ -1574,15 +1595,19 @@ if (is_ios || is_mac) { "objc/base/RTCVideoFrame.h", "objc/base/RTCVideoFrameBuffer.h", "objc/base/RTCVideoRenderer.h", - "objc/base/RTCAudioRenderer.h", "objc/base/RTCYUVPlanarBuffer.h", + "objc/components/audio/RTCAudioBuffer.h", + "objc/components/audio/RTCAudioCustomProcessingDelegate.h", + "objc/components/audio/RTCAudioProcessingConfig.h", + "objc/components/audio/RTCAudioProcessingModule.h", + "objc/components/audio/RTCDefaultAudioProcessingModule.h", "objc/components/capturer/RTCCameraVideoCapturer.h", - "objc/components/capturer/RTCFileVideoCapturer.h", "objc/components/capturer/RTCDesktopCapturer.h", - "objc/components/capturer/RTCDesktopSource.h", "objc/components/capturer/RTCDesktopMediaList.h", - "objc/components/renderer/metal/RTCMTLVideoView.h", + "objc/components/capturer/RTCDesktopSource.h", + "objc/components/capturer/RTCFileVideoCapturer.h", "objc/components/renderer/metal/RTCMTLNSVideoView.h", + "objc/components/renderer/metal/RTCMTLVideoView.h", "objc/components/renderer/opengl/RTCNSGLVideoView.h", "objc/components/renderer/opengl/RTCVideoViewShading.h", "objc/components/video_codec/RTCCodecSpecificInfoH264.h", @@ -1592,13 +1617,11 @@ if (is_ios || is_mac) { "objc/components/video_codec/RTCVideoDecoderFactoryH264.h", "objc/components/video_codec/RTCVideoDecoderH264.h", "objc/components/video_codec/RTCVideoEncoderFactoryH264.h", + "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h", "objc/components/video_codec/RTCVideoEncoderH264.h", "objc/components/video_frame_buffer/RTCCVPixelBuffer.h", "objc/helpers/RTCDispatcher.h", "objc/helpers/RTCYUVHelper.h", - # Added for Simulcast support - "objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h", - "objc/api/video_codec/RTCVideoEncoderSimulcast.h", ] if (!build_with_chromium) { sources += [ @@ -1680,10 +1703,10 @@ if (is_ios || is_mac) { "objc/native/api/video_decoder_factory.mm", "objc/native/api/video_encoder_factory.h", "objc/native/api/video_encoder_factory.mm", - "objc/native/api/video_frame.h", - "objc/native/api/video_frame.mm", "objc/native/api/video_frame_buffer.h", "objc/native/api/video_frame_buffer.mm", + "objc/native/api/video_frame.h", + "objc/native/api/video_frame.mm", "objc/native/api/video_renderer.h", "objc/native/api/video_renderer.mm", ] diff --git a/sdk/objc/api/peerconnection/RTCAudioTrack.mm b/sdk/objc/api/peerconnection/RTCAudioTrack.mm index 065064a1fe..3d3af34893 100644 --- a/sdk/objc/api/peerconnection/RTCAudioTrack.mm +++ b/sdk/objc/api/peerconnection/RTCAudioTrack.mm @@ -209,6 +209,7 @@ - (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)facto NSParameterAssert(type == RTCMediaStreamTrackTypeAudio); if (self = [super initWithFactory:factory nativeTrack:nativeTrack type:type]) { RTC_LOG(LS_INFO) << "RTCAudioTrack init"; + _lock = OS_UNFAIR_LOCK_INIT; _renderers = [NSHashTable weakObjectsHashTable]; _audioConverter = new rtc::RefCountedObject(self, &_lock); } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h index 902925936b..cc45aba1ec 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h @@ -73,12 +73,6 @@ NS_ASSUME_NONNULL_BEGIN initWithEncoderFactory:(nullable id)encoderFactory decoderFactory:(nullable id)decoderFactory; -- (instancetype) - initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing - encoderFactory:(nullable id)encoderFactory - decoderFactory: - (nullable id)decoderFactory; - /** Initialize an RTCPeerConnection with a configuration, constraints, and * dependencies. */ diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index d74b99bd95..439490d370 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -38,6 +38,8 @@ typedef NS_ENUM(NSInteger, RTCRtpMediaType); (RTCSSLCertificateVerifier); @protocol RTC_OBJC_TYPE (RTCAudioDevice); +@protocol RTC_OBJC_TYPE +(RTCAudioProcessingModule); RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE (RTCPeerConnectionFactory) : NSObject @@ -60,8 +62,9 @@ RTC_OBJC_EXPORT - (instancetype) initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing encoderFactory:(nullable id)encoderFactory - decoderFactory: - (nullable id)decoderFactory; + decoderFactory:(nullable id)decoderFactory + audioProcessingModule: + (nullable id)audioProcessingModule; @property(nonatomic, readonly) RTCAudioDeviceModule *audioDeviceModule; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 49ff38161f..5cb4f38c05 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -53,6 +53,9 @@ #include "sdk/objc/native/src/objc_video_decoder_factory.h" #include "sdk/objc/native/src/objc_video_encoder_factory.h" +#import "components/audio/RTCAudioProcessingModule.h" +#import "components/audio/RTCDefaultAudioProcessingModule+Private.h" + #if defined(WEBRTC_IOS) #import "sdk/objc/native/api/audio_device_module.h" #endif @@ -62,6 +65,7 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) { std::unique_ptr _workerThread; std::unique_ptr _signalingThread; rtc::scoped_refptr _nativeAudioDeviceModule; + RTCDefaultAudioProcessingModule *_defaultAudioProcessingModule; BOOL _hasStartedAecDump; } @@ -144,8 +148,9 @@ - (instancetype)init { - (instancetype) initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing encoderFactory:(nullable id)encoderFactory - decoderFactory: - (nullable id)decoderFactory { + decoderFactory:(nullable id)decoderFactory + audioProcessingModule: + (nullable id)audioProcessingModule { #ifdef HAVE_NO_MEDIA return [self initWithNoMedia]; #else @@ -158,12 +163,21 @@ - (instancetype)init { native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory); } rtc::scoped_refptr audio_device_module = [self createAudioDeviceModule:bypassVoiceProcessing]; + + if ([audioProcessingModule isKindOfClass:[RTCDefaultAudioProcessingModule class]]) { + _defaultAudioProcessingModule = (RTCDefaultAudioProcessingModule *)audioProcessingModule; + } else { + _defaultAudioProcessingModule = [[RTCDefaultAudioProcessingModule alloc] init]; + } + + NSLog(@"AudioProcessingModule: %@", _defaultAudioProcessingModule); + return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory() nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory() nativeVideoEncoderFactory:std::move(native_encoder_factory) nativeVideoDecoderFactory:std::move(native_decoder_factory) audioDeviceModule:audio_device_module.get() - audioProcessingModule:nullptr + audioProcessingModule:_defaultAudioProcessingModule.nativeAudioProcessingModule bypassVoiceProcessing:bypassVoiceProcessing]; #endif } diff --git a/sdk/objc/components/audio/RTCAudioBuffer+Private.h b/sdk/objc/components/audio/RTCAudioBuffer+Private.h new file mode 100644 index 0000000000..effd8bb429 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioBuffer+Private.h @@ -0,0 +1,29 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCAudioBuffer.h" + +#include "modules/audio_processing/audio_buffer.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTC_OBJC_TYPE (RTCAudioBuffer)() + +- (instancetype)initWithNativeType: (webrtc::AudioBuffer *) audioBuffer; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioBuffer.h b/sdk/objc/components/audio/RTCAudioBuffer.h new file mode 100644 index 0000000000..8bbd068657 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioBuffer.h @@ -0,0 +1,38 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +RTC_OBJC_EXPORT +@interface RTC_OBJC_TYPE (RTCAudioBuffer) : NSObject + +@property(nonatomic, readonly) size_t channels; +@property(nonatomic, readonly) size_t frames; +@property(nonatomic, readonly) size_t framesPerBand; +@property(nonatomic, readonly) size_t bands; + +// Returns pointer arrays. Index range from 0 to `frames`. +- (float* _Nonnull)rawBufferForChannel:(size_t)channel; + +// TODO: More convenience methods... + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioBuffer.mm b/sdk/objc/components/audio/RTCAudioBuffer.mm new file mode 100644 index 0000000000..e37ea344dd --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioBuffer.mm @@ -0,0 +1,55 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCAudioBuffer.h" + +#include "modules/audio_processing/audio_buffer.h" + +@implementation RTC_OBJC_TYPE (RTCAudioBuffer) { + // Raw + webrtc::AudioBuffer *_audioBuffer; +} + +- (size_t)channels { + return _audioBuffer->num_channels(); +} + +- (size_t)frames { + return _audioBuffer->num_frames(); +} + +- (size_t)framesPerBand { + return _audioBuffer->num_frames_per_band(); +} + +- (size_t)bands { + return _audioBuffer->num_bands(); +} + +- (float *)rawBufferForChannel:(size_t)channel { + return _audioBuffer->channels()[channel]; +} + +#pragma mark - Private + +- (instancetype)initWithNativeType:(webrtc::AudioBuffer *)audioBuffer { + if (self = [super init]) { + _audioBuffer = audioBuffer; + } + return self; +} + +@end diff --git a/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter+Private.h b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter+Private.h new file mode 100644 index 0000000000..a9dc3d8400 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter+Private.h @@ -0,0 +1,43 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCAudioCustomProcessingAdapter.h" +#import "RTCAudioCustomProcessingDelegate.h" +#import "RTCMacros.h" + +#include "modules/audio_processing/include/audio_processing.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTCAudioCustomProcessingAdapter () + +// Thread safe set/get with os_unfair_lock. +@property(nonatomic, weak, nullable) id + audioCustomProcessingDelegate; + +// Direct read access without lock. +@property(nonatomic, readonly, weak, nullable) id + rawAudioCustomProcessingDelegate; + +@property(nonatomic, readonly) std::unique_ptr + nativeAudioCustomProcessingModule; + +- (instancetype)initWithDelegate: + (nullable id)audioCustomProcessingDelegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.h b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.h new file mode 100644 index 0000000000..24239eac2d --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.h @@ -0,0 +1,28 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTCAudioCustomProcessingAdapter : NSObject + +- (instancetype)init NS_UNAVAILABLE; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.mm b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.mm new file mode 100644 index 0000000000..c8d1dfe4f6 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioCustomProcessingAdapter.mm @@ -0,0 +1,139 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import + +#import "RTCAudioBuffer+Private.h" +#import "RTCAudioCustomProcessingAdapter+Private.h" +#import "RTCAudioCustomProcessingAdapter.h" + +#include "rtc_base/logging.h" + +namespace webrtc { + +class AudioCustomProcessingAdapter : public webrtc::CustomProcessing { + public: + bool is_initialized_; + int sample_rate_hz_; + int num_channels_; + + AudioCustomProcessingAdapter(RTCAudioCustomProcessingAdapter *adapter, os_unfair_lock *lock) { + RTC_LOG(LS_INFO) << "RTCAudioCustomProcessingAdapter.AudioCustomProcessingAdapter init"; + + adapter_ = adapter; + lock_ = lock; + is_initialized_ = false; + sample_rate_hz_ = 0; + num_channels_ = 0; + } + + ~AudioCustomProcessingAdapter() { + RTC_LOG(LS_INFO) << "RTCAudioCustomProcessingAdapter.AudioCustomProcessingAdapter dealloc"; + + os_unfair_lock_lock(lock_); + id delegate = adapter_.rawAudioCustomProcessingDelegate; + [delegate audioProcessingRelease]; + os_unfair_lock_unlock(lock_); + } + + void Initialize(int sample_rate_hz, int num_channels) override { + os_unfair_lock_lock(lock_); + id delegate = adapter_.rawAudioCustomProcessingDelegate; + [delegate audioProcessingInitializeWithSampleRate:sample_rate_hz channels:num_channels]; + is_initialized_ = true; + sample_rate_hz_ = sample_rate_hz; + num_channels_ = num_channels; + os_unfair_lock_unlock(lock_); + } + + void Process(AudioBuffer *audio_buffer) override { + bool is_locked = os_unfair_lock_trylock(lock_); + if (!is_locked) { + RTC_LOG(LS_INFO) << "RTCAudioCustomProcessingAdapter.AudioCustomProcessingAdapter Process " + "already locked, skipping..."; + + return; + } + id delegate = adapter_.rawAudioCustomProcessingDelegate; + if (delegate != nil) { + RTCAudioBuffer *audioBuffer = [[RTCAudioBuffer alloc] initWithNativeType:audio_buffer]; + [delegate audioProcessingProcess:audioBuffer]; + } + os_unfair_lock_unlock(lock_); + } + + std::string ToString() const override { return "AudioCustomProcessingAdapter"; } + + private: + __weak RTCAudioCustomProcessingAdapter *adapter_; + os_unfair_lock *lock_; +}; +} // namespace webrtc + +@implementation RTCAudioCustomProcessingAdapter { + webrtc::AudioCustomProcessingAdapter *_adapter; + os_unfair_lock _lock; +} + +@synthesize rawAudioCustomProcessingDelegate = _rawAudioCustomProcessingDelegate; + +- (instancetype)initWithDelegate: + (nullable id)audioCustomProcessingDelegate { + if (self = [super init]) { + _lock = OS_UNFAIR_LOCK_INIT; + _rawAudioCustomProcessingDelegate = audioCustomProcessingDelegate; + _adapter = new webrtc::AudioCustomProcessingAdapter(self, &_lock); + RTC_LOG(LS_INFO) << "RTCAudioCustomProcessingAdapter init"; + } + + return self; +} + +- (void)dealloc { + RTC_LOG(LS_INFO) << "RTCAudioCustomProcessingAdapter dealloc"; +} + +#pragma mark - Getter & Setter for audioCustomProcessingDelegate + +- (nullable id)audioCustomProcessingDelegate { + os_unfair_lock_lock(&_lock); + id delegate = _rawAudioCustomProcessingDelegate; + os_unfair_lock_unlock(&_lock); + return delegate; +} + +- (void)setAudioCustomProcessingDelegate:(nullable id)delegate { + os_unfair_lock_lock(&_lock); + if (_rawAudioCustomProcessingDelegate != nil && _adapter->is_initialized_) { + [_rawAudioCustomProcessingDelegate audioProcessingRelease]; + } + _rawAudioCustomProcessingDelegate = delegate; + if (_adapter->is_initialized_) { + [_rawAudioCustomProcessingDelegate + audioProcessingInitializeWithSampleRate:_adapter->sample_rate_hz_ + channels:_adapter->num_channels_]; + } + os_unfair_lock_unlock(&_lock); +} + +#pragma mark - Private + +- (std::unique_ptr)nativeAudioCustomProcessingModule { + return std::unique_ptr(_adapter); +} + +@end diff --git a/sdk/objc/components/audio/RTCAudioCustomProcessingDelegate.h b/sdk/objc/components/audio/RTCAudioCustomProcessingDelegate.h new file mode 100644 index 0000000000..6a2fec9433 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioCustomProcessingDelegate.h @@ -0,0 +1,52 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +@class RTC_OBJC_TYPE(RTCAudioBuffer); + +RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE (RTCAudioCustomProcessingDelegate) + +/** +* (Re-)initialize the audio processor. +* This method can be invoked multiple times. +*/ +- (void)audioProcessingInitializeWithSampleRate : (size_t)sampleRateHz channels +: (size_t)channels NS_SWIFT_NAME(audioProcessingInitialize(sampleRate:channels:)); + +/** + * Process (read or write) the audio buffer. + * RTCAudioBuffer is a simple wrapper for webrtc::AudioBuffer and the valid scope is only inside + * this method. Do not retain it. + */ +- (void)audioProcessingProcess:(RTCAudioBuffer *)audioBuffer + NS_SWIFT_NAME(audioProcessingProcess(audioBuffer:)); + +// TOOD: +// virtual void SetRuntimeSetting(AudioProcessing::RuntimeSetting setting); + +/** + * Suggests releasing resources allocated by the audio processor. + */ +- (void)audioProcessingRelease; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioProcessingConfig+Private.h b/sdk/objc/components/audio/RTCAudioProcessingConfig+Private.h new file mode 100644 index 0000000000..ed565ee0aa --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioProcessingConfig+Private.h @@ -0,0 +1,29 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCAudioProcessingConfig.h" + +#include "modules/audio_processing/include/audio_processing.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTC_OBJC_TYPE (RTCAudioProcessingConfig)() + +@property(nonatomic, readonly) webrtc::AudioProcessing::Config nativeAudioProcessingConfig; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioProcessingConfig.h b/sdk/objc/components/audio/RTCAudioProcessingConfig.h new file mode 100644 index 0000000000..3c7dce45f1 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioProcessingConfig.h @@ -0,0 +1,31 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +RTC_OBJC_EXPORT +@interface RTC_OBJC_TYPE (RTCAudioProcessingConfig) : NSObject + +@property(nonatomic, assign) BOOL echoCancellerEnabled; +@property(nonatomic, assign) BOOL echoCancellerMobileMode; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCAudioProcessingConfig.mm b/sdk/objc/components/audio/RTCAudioProcessingConfig.mm new file mode 100644 index 0000000000..ca40f16e17 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioProcessingConfig.mm @@ -0,0 +1,51 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCAudioProcessingConfig.h" + +#include "modules/audio_processing/include/audio_processing.h" + +@implementation RTC_OBJC_TYPE (RTCAudioProcessingConfig) { + webrtc::AudioProcessing::Config _config; +} + +// config.echo_canceller.enabled + +- (BOOL)echoCancellerEnabled { + return _config.echo_canceller.enabled; +} + +- (void)setEchoCancellerEnabled:(BOOL)value { + _config.echo_canceller.enabled = value; +} + +// config.echo_canceller.mobile_mode + +- (BOOL)echoCancellerMobileMode { + return _config.echo_canceller.mobile_mode; +} + +- (void)setEchoCancellerMobileMode:(BOOL)value { + _config.echo_canceller.mobile_mode = value; +} + +#pragma mark - Private + +- (webrtc::AudioProcessing::Config)nativeAudioProcessingConfig { + return _config; +} + +@end diff --git a/sdk/objc/components/audio/RTCAudioProcessingModule.h b/sdk/objc/components/audio/RTCAudioProcessingModule.h new file mode 100644 index 0000000000..7bf0402427 --- /dev/null +++ b/sdk/objc/components/audio/RTCAudioProcessingModule.h @@ -0,0 +1,33 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +@class RTC_OBJC_TYPE(RTCAudioProcessingConfig); + +RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE (RTCAudioProcessingModule) + +- (void)applyConfig: (RTCAudioProcessingConfig *)config; + +// TODO: Implement... + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCDefaultAudioProcessingModule+Private.h b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule+Private.h new file mode 100644 index 0000000000..4f8551e372 --- /dev/null +++ b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule+Private.h @@ -0,0 +1,29 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCDefaultAudioProcessingModule.h" + +#include "modules/audio_processing/include/audio_processing.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTC_OBJC_TYPE (RTCDefaultAudioProcessingModule)() + +@property(nonatomic, readonly) rtc::scoped_refptr nativeAudioProcessingModule; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.h b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.h new file mode 100644 index 0000000000..917d584d48 --- /dev/null +++ b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.h @@ -0,0 +1,47 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "RTCAudioProcessingModule.h" +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +@class RTC_OBJC_TYPE(RTCAudioProcessingConfig); +@protocol RTC_OBJC_TYPE +(RTCAudioCustomProcessingDelegate); + +RTC_OBJC_EXPORT +@interface RTC_OBJC_TYPE (RTCDefaultAudioProcessingModule) : NSObject + +- (instancetype)initWithConfig: (nullable RTCAudioProcessingConfig *)config + capturePostProcessingDelegate: (nullable id)capturePostProcessingDelegate + renderPreProcessingDelegate: (nullable id)renderPreProcessingDelegate + NS_SWIFT_NAME(init(config:capturePostProcessingDelegate:renderPreProcessingDelegate:)) NS_DESIGNATED_INITIALIZER; + +- (void)applyConfig:(RTCAudioProcessingConfig *)config; + +// Dynamically update delegates at runtime + +@property(nonatomic, weak, nullable) id + capturePostProcessingDelegate; +@property(nonatomic, weak, nullable) id + renderPreProcessingDelegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.mm b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.mm new file mode 100644 index 0000000000..3875dec533 --- /dev/null +++ b/sdk/objc/components/audio/RTCDefaultAudioProcessingModule.mm @@ -0,0 +1,96 @@ +/* + * Copyright 2023 LiveKit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "RTCDefaultAudioProcessingModule.h" +#import "RTCAudioCustomProcessingAdapter+Private.h" +#import "RTCAudioProcessingConfig+Private.h" + +#include "modules/audio_processing/include/audio_processing.h" + +@implementation RTC_OBJC_TYPE (RTCDefaultAudioProcessingModule) { + rtc::scoped_refptr _nativeAudioProcessingModule; + // Custom processing adapters... + RTCAudioCustomProcessingAdapter *_capturePostProcessingAdapter; + RTCAudioCustomProcessingAdapter *_renderPreProcessingAdapter; +} + +- (instancetype)init { + return [self initWithConfig:nil + capturePostProcessingDelegate:nil + renderPreProcessingDelegate:nil]; +} + +- (instancetype)initWithConfig:(nullable RTCAudioProcessingConfig *)config + capturePostProcessingDelegate: + (nullable id)capturePostProcessingDelegate + renderPreProcessingDelegate:(nullable id) + renderPreProcessingDelegate { + if (self = [super init]) { + webrtc::AudioProcessingBuilder builder = webrtc::AudioProcessingBuilder(); + + // TODO: Custom Config... + + if (config != nil) { + builder.SetConfig(config.nativeAudioProcessingConfig); + } + + _capturePostProcessingAdapter = + [[RTCAudioCustomProcessingAdapter alloc] initWithDelegate:capturePostProcessingDelegate]; + builder.SetCapturePostProcessing( + _capturePostProcessingAdapter.nativeAudioCustomProcessingModule); + + _renderPreProcessingAdapter = + [[RTCAudioCustomProcessingAdapter alloc] initWithDelegate:renderPreProcessingDelegate]; + builder.SetRenderPreProcessing(_renderPreProcessingAdapter.nativeAudioCustomProcessingModule); + + _nativeAudioProcessingModule = builder.Create(); + } + return self; +} + +#pragma mark - Getter & Setters for delegates + +- (nullable id)capturePostProcessingDelegate { + return _capturePostProcessingAdapter.audioCustomProcessingDelegate; +} + +- (void)setCapturePostProcessingDelegate: + (nullable id)delegate { + _capturePostProcessingAdapter.audioCustomProcessingDelegate = delegate; +} + +- (nullable id)renderPreProcessingDelegate { + return _renderPreProcessingAdapter.audioCustomProcessingDelegate; +} + +- (void)setRenderPreProcessingDelegate: + (nullable id)delegate { + _renderPreProcessingAdapter.audioCustomProcessingDelegate = delegate; +} + +#pragma mark - RTCAudioProcessingModule protocol + +- (void)applyConfig:(RTCAudioProcessingConfig *)config { + _nativeAudioProcessingModule->ApplyConfig(config.nativeAudioProcessingConfig); +} + +#pragma mark - Private + +- (rtc::scoped_refptr)nativeAudioProcessingModule { + return _nativeAudioProcessingModule; +} + +@end