Starter Deal! First 3 month from only  $9.9 /month!
Starter Deal! First 3 month from only  $9.9 /month!
Grab It Now 
RTC Engine
Overview
  • Web
    • Run Sample Demo
    • SDK Quickstart
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Beauty and Effects
      • Data Messages
      • Custom Capturing and Rendering
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
      • Others
  • Android
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Newwork Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • Tencent RTC Quickplay: Experience Ultimate Real-Time Audio and Video Interaction!
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

9.Sharing Computer Audio

Pain Point and Solution

It is often necessary to share system audio in scenarios such as screen sharing, but the sound cards of Mac computers do not allow the capturing of system audio, making it impossible to share system audio on Mac computers. To solve this problem, TRTC has introduced a feature that records system audio on Mac computers. See below for details on how to enable the feature.

Directions



Step 1. Integrate the TRTCPrivilegedTask library

The TRTC SDK uses the TRTCPrivilegedTask library to get root access and install the virtual sound card plugin TRTCAudioPlugin.driver in the system directory /Library/Audio/Plug-Ins/HAL.
Integration via CocoaPods
Manual integration
1. Open the Podfile file in the root directory of your project and add the following content:
platform :osx, '10.10'

target 'Your Target' do
pod 'TRTCPrivilegedTask', :podspec => 'https://pod-1252463788.cos.ap-guangzhou.myqcloud.com/liteavsdkspec/TRTCPrivilegedTask.podspec'
end

2. Run the pod install command to install the TRTCPrivilegedTask library.
explain:
If you cannot find a Podfile file in the directory, run the pod init command to create one and then add the above content.
For how to install CocoaPods, see CocoaPods' official installation document.

1. Download the TRTCPrivilegedTask library.
2. Decompress the downloaded file, open your Xcode project, and import the file to the project.
3. Select the target to run, select Build Phases, expand Link Binary with Libraries, click +, and add the dependent library libPrivilegedTask.a.
libPrivilegedTask.a




Step 2. Disable App Sandbox

In the entitlements file of the app, delete App Sandbox.
Sandbox




Step 3. Package the virtual sound card plugin

After you integrate the TRTCPrivilegedTask library and disable App Sandbox, when you use the system audio recording feature for the first time, the SDK will download the virtual sound card plugin from the internet and install it. To accelerate this process, you can package the virtual sound card plugin TRTCAudioPlugin.driver in the PlugIns directory of TXLiteAVSDK_TRTC_Mac.framework to the resources directory of the app's bundle, as shown below.
Packaging plugin

Alternatively, copy the file to the PlugIns directory of the app's bundle.
Packaging plugin 2




Step 4. Start capturing system audio

Call the startSystemAudioLoopback API to start system audio capturing and mix the audio into the upstream audio stream. The result is called back via onSystemAudioLoopbackError.
TRTCCloud *trtcCloud = [TRTCCloud sharedInstance];
[_trtc startLocalAudio];
[trtcCloud startSystemAudioLoopback];
notice
After the TRTCPrivilegedTask library is integrated and App Sandbox disabled, when you call startSystemAudioLoopback for the first time, the SDK will request root access.After being granted root access, the SDK will start installing the virtual sound card plugin to the computer automatically.


Step 5. Stop capturing system audio

Call the stopSystemAudioLoopback API to stop capturing system audio.
TRTCCloud *trtcCloud = [TRTCCloud sharedInstance];
[trtcCloud stopSystemAudioLoopback];


Step 6. Set the volume of system audio capturing

Call the setSystemAudioLoopbackVolume API to set the volume of system audio capturing.
TRTCCloud *trtcCloud = [TRTCCloud sharedInstance];
[trtcCloud setSystemAudioLoopbackVolume:80];

Summary

TRTC records system audio on Mac computers using the virtual sound card plugin TRTCAudioPlugin.driver. For the plugin to work, you need to copy it to the system directory /Library/Audio/Plug-Ins/HAL and restart the audio service. You can check whether the plugin is installed successfully using the Audio MIDI Setup app, which can be found in the Other folder of Launchpad. The presence of a device named "TRTC Audio Device" in the device list of the app indicates that the plugin is installed successfully.
The purpose of integrating the TRTCPrivilegedTask library and disabling App Sandbox is for the SDK to get root access so as to install the virtual sound card plugin; otherwise it cannot automatically install the plugin. However, if a virtual sound card is already installed in the system, you can use the system audio recording feature without integrating the TRTCPrivilegedTask library or disabling App Sandbox.
explain
You can also manually install a virtual sound card to enable the feature.
1. Copy TRTCAudioPlugin.driver in the PlugIns directory of TXLiteAVSDK_TRTC_Mac.framework to the system directory /Library/Audio/Plug-Ins/HAL.
2. Restart the system audio service.

sudo cp -R TXLiteAVSDK_TRTC_Mac.framework/PlugIns/TRTCAudioPlugin.driver /Library/Audio/Plug-Ins/HAL
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'`



Notes

Disabling App Sandbox will change the user paths obtained in your app.Directories returned via methods such as the calling of NSSearchPathForDirectoriesInDomainswill change from sandbox directories to user directories. For example, ~/Documents and ~/Library will become /Users/UsernameDocuments and /Users/Username/Library.
You may be unable to release your app to the Mac App Store after integrating the TRTCPrivilegedTask library.App Sandbox must be disabled for the SDK to get root access and automatically install a virtual sound card. This may cause your app to be rejected by the Mac App Store. For details, see App Store Review Guidelines.If you need to release your app to the Mac App Store or want to use the Sandbox feature, consider manually installing a virtual sound card.