Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor configuring the lib #141

Merged
merged 4 commits into from
Sep 25, 2024
Merged

Refactor configuring the lib #141

merged 4 commits into from
Sep 25, 2024

Conversation

shepeliev
Copy link
Owner

In order to make PeerConnectionFactory customization more flexible I've refactored the lib configuration.

Android

PeerConnectionFactory is customized by PeerConnectionFactory.Builder that is passed to WebRtc.configure()

val loggable = Loggable { message, severity, tag ->
    Logger.withTag(tag).also { logger ->
        when (severity) {
            Logging.Severity.LS_VERBOSE -> logger.d { message }
            Logging.Severity.LS_INFO -> logger.i { message }
            Logging.Severity.LS_WARNING -> logger.w { message }
            Logging.Severity.LS_ERROR -> logger.e { message }
            else -> logger.v { message }
         }
    }
}
val severity = if (BuildConfig.DEBUG) Logging.Severity.LS_INFO else Logging.Severity.LS_ERROR

val initializationOptionsBuilder = WebRtc.createInitializationOptionsBuilder()
    .setInjectableLogger(loggable, severity)
val peerConnectionFactoryBuilder WebRtc.createPeerConnectionFactoryBuilder(initializationOptionsBuilder)
    .setAudioDeviceModule(audioDeviceModule)
WebRtc.configure(
     videoProcessorFactory = { videoProcessor },
     peerConnectionFactoryBuilder = peerConnectionFactoryBuilder,
)

iOS

Custom RTCPeerConnectionFactory may be passed to WebRtc.configure()

let audioProcessingModule = RTCDefaultAudioProcessingModule()
audioProcessingModule.renderPreProcessingDelegate = audioProcessor
        
let peerConnectionFactory = RTCPeerConnectionFactory(
    bypassVoiceProcessing: true,
    encoderFactory: RTCDefaultVideoEncoderFactory(),
    decoderFactory: RTCDefaultVideoDecoderFactory(),
    audioProcessingModule: audioProcessingModule
)
WebRtc.shared.configure(
     loggingSeverity: .rtcloggingSeverityWarning,
     videoProcessorFactory: videoProcessor,
     rtcPeerConnectionFactory: peerConnectionFactory
)

@shepeliev shepeliev merged commit 8703f6c into main Sep 25, 2024
4 checks passed
@shepeliev shepeliev deleted the refactor-configuration branch September 25, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant