Committed by
GitHub
Allow injection of PeerConnectionFactory.Options (#382)
* Allow injection of PeerConnectionFactory.Options * Spotless
正在显示
4 个修改的文件
包含
18 行增加
和
0 行删除
| @@ -24,6 +24,7 @@ import io.livekit.android.audio.AudioSwitchHandler | @@ -24,6 +24,7 @@ import io.livekit.android.audio.AudioSwitchHandler | ||
| 24 | import io.livekit.android.audio.NoAudioHandler | 24 | import io.livekit.android.audio.NoAudioHandler |
| 25 | import io.livekit.android.room.Room | 25 | import io.livekit.android.room.Room |
| 26 | import livekit.org.webrtc.EglBase | 26 | import livekit.org.webrtc.EglBase |
| 27 | +import livekit.org.webrtc.PeerConnectionFactory | ||
| 27 | import livekit.org.webrtc.VideoDecoderFactory | 28 | import livekit.org.webrtc.VideoDecoderFactory |
| 28 | import livekit.org.webrtc.VideoEncoderFactory | 29 | import livekit.org.webrtc.VideoEncoderFactory |
| 29 | import livekit.org.webrtc.audio.AudioDeviceModule | 30 | import livekit.org.webrtc.audio.AudioDeviceModule |
| @@ -63,6 +64,11 @@ data class LiveKitOverrides( | @@ -63,6 +64,11 @@ data class LiveKitOverrides( | ||
| 63 | * with it to prevent memory leaks. | 64 | * with it to prevent memory leaks. |
| 64 | */ | 65 | */ |
| 65 | val eglBase: EglBase? = null, | 66 | val eglBase: EglBase? = null, |
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * Override the options passed into the PeerConnectionFactory when building it. | ||
| 70 | + */ | ||
| 71 | + val peerConnectionFactoryOptions: PeerConnectionFactory.Options? = null, | ||
| 66 | ) | 72 | ) |
| 67 | 73 | ||
| 68 | /** | 74 | /** |
| @@ -54,4 +54,5 @@ internal object InjectionNames { | @@ -54,4 +54,5 @@ internal object InjectionNames { | ||
| 54 | internal const val OVERRIDE_AUDIO_OUTPUT_TYPE = "override_audio_output_type" | 54 | internal const val OVERRIDE_AUDIO_OUTPUT_TYPE = "override_audio_output_type" |
| 55 | internal const val OVERRIDE_DISABLE_COMMUNICATION_WORKAROUND = "override_disable_communication_workaround" | 55 | internal const val OVERRIDE_DISABLE_COMMUNICATION_WORKAROUND = "override_disable_communication_workaround" |
| 56 | internal const val OVERRIDE_EGL_BASE = "override_egl_base" | 56 | internal const val OVERRIDE_EGL_BASE = "override_egl_base" |
| 57 | + internal const val OVERRIDE_PEER_CONNECTION_FACTORY_OPTIONS = "override_peer_connection_factory_options" | ||
| 57 | } | 58 | } |
| @@ -62,6 +62,10 @@ internal class OverridesModule(private val overrides: LiveKitOverrides) { | @@ -62,6 +62,10 @@ internal class OverridesModule(private val overrides: LiveKitOverrides) { | ||
| 62 | fun audioOutputType() = overrides.audioOptions?.audioOutputType | 62 | fun audioOutputType() = overrides.audioOptions?.audioOutputType |
| 63 | 63 | ||
| 64 | @Provides | 64 | @Provides |
| 65 | + @Named(InjectionNames.OVERRIDE_PEER_CONNECTION_FACTORY_OPTIONS) | ||
| 66 | + fun peerConnectionFactoryOptions() = overrides.peerConnectionFactoryOptions | ||
| 67 | + | ||
| 68 | + @Provides | ||
| 65 | @Named(InjectionNames.OVERRIDE_DISABLE_COMMUNICATION_WORKAROUND) | 69 | @Named(InjectionNames.OVERRIDE_DISABLE_COMMUNICATION_WORKAROUND) |
| 66 | fun disableCommunicationWorkAround() = overrides.audioOptions?.disableCommunicationModeWorkaround ?: false | 70 | fun disableCommunicationWorkAround() = overrides.audioOptions?.disableCommunicationModeWorkaround ?: false |
| 67 | 71 |
| @@ -243,12 +243,19 @@ internal object RTCModule { | @@ -243,12 +243,19 @@ internal object RTCModule { | ||
| 243 | audioDeviceModule: AudioDeviceModule, | 243 | audioDeviceModule: AudioDeviceModule, |
| 244 | videoEncoderFactory: VideoEncoderFactory, | 244 | videoEncoderFactory: VideoEncoderFactory, |
| 245 | videoDecoderFactory: VideoDecoderFactory, | 245 | videoDecoderFactory: VideoDecoderFactory, |
| 246 | + @Named(InjectionNames.OVERRIDE_PEER_CONNECTION_FACTORY_OPTIONS) | ||
| 247 | + peerConnectionFactoryOptions: PeerConnectionFactory.Options?, | ||
| 246 | memoryManager: CloseableManager, | 248 | memoryManager: CloseableManager, |
| 247 | ): PeerConnectionFactory { | 249 | ): PeerConnectionFactory { |
| 248 | return PeerConnectionFactory.builder() | 250 | return PeerConnectionFactory.builder() |
| 249 | .setAudioDeviceModule(audioDeviceModule) | 251 | .setAudioDeviceModule(audioDeviceModule) |
| 250 | .setVideoEncoderFactory(videoEncoderFactory) | 252 | .setVideoEncoderFactory(videoEncoderFactory) |
| 251 | .setVideoDecoderFactory(videoDecoderFactory) | 253 | .setVideoDecoderFactory(videoDecoderFactory) |
| 254 | + .apply { | ||
| 255 | + if (peerConnectionFactoryOptions != null) { | ||
| 256 | + setOptions(peerConnectionFactoryOptions) | ||
| 257 | + } | ||
| 258 | + } | ||
| 252 | .createPeerConnectionFactory() | 259 | .createPeerConnectionFactory() |
| 253 | .apply { memoryManager.registerClosable { dispose() } } | 260 | .apply { memoryManager.registerClosable { dispose() } } |
| 254 | } | 261 | } |
-
请 注册 或 登录 后发表评论