AgoraIO-Extensions / Agora-Unity-Quickstart

MIT License
97 stars 93 forks source link

Screen Sharing with system audio capture Mac/Windows #267

Closed BorisDex closed 1 month ago

BorisDex commented 2 months ago

I can't find a way to capture system audio to share while screen sharing. Is it possible on windows/mac using agora unity SDK? I've tried setting ChannelMediaOptions publishScreenCaptureAudio.SetValue(true) but it seems to work only for android/ios.

BorisDex commented 2 months ago

I've found a method for Windows OS audio capture: RtcEngine.EnableLoopbackRecordingEx(channelConnection, true); and relevant comments for MacOS issue. I think this method should be added to the Screen Share sample code to achieve functional parity with android/ios methods.

///
/// <summary>
/// Enables loopback audio capturing.
/// 
/// If you enable loopback audio capturing, the output of the sound card is mixed into the audio stream sent to the other end.
/// This method applies to the macOS and Windows only.
/// macOS does not support loopback audio capture of the default sound card. If you need to use this function, use a virtual sound card and pass its name to the deviceName parameter. Agora recommends using AgoraALD as the virtual sound card for audio capturing.
/// This method only supports using one sound card for audio capturing.
/// </summary>
///
/// <param name="deviceName">
/// macOS: The device name of the virtual sound card. The default value is set to NULL, which means using AgoraALD for loopback audio capturing.
/// Windows: The device name of the sound card. The default is set to NULL, which means the SDK uses the sound card of your device for loopback audio capturing.
/// </param>
///
/// <param name="connection"> The connection information. See RtcConnection. </param>
///
/// <param name="enabled"> Sets whether to enable loopback audio capture: true : Enable loopback audio capturing. false : (Default) Disable loopback audio capturing. </param>
///
/// <returns>
/// 0: Success.
/// &lt; 0: Failure.
/// </returns>
///
xiayangqun commented 2 months ago

Cool. Thank you for your suggestion