All places when peer connection factory is created

I’m facing a problem where I have a WebRTC build which doesn’t take nullptr for ADM when creating peer connection factory (webrtc_voice_engine.cc:255RTC_CHECK(adm()) – the flag WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE was not enabled on this build). I have no control over this build and have to use it.
I’m getting a crash while calling device.Load(), even though I supply peer connection options with my factory I created earlier. When I enable WebRTC trace logging I see the adm() check mentioned above is triggered. This makes me think that mediasoup might create a factory somewhere internally with nullptr adm… However, I only found one place where factory might be created – inside PeerConnection constructor, and apparently it is invoked with the options supplied.
Could there be any other paths where temporary factory with nullptr adm is created?

Below, you can see the webrtc log output from the modified Device.test.cpp, here’s the code:

	SECTION("device.Load() succeeds")
	{
		mediasoupclient::Logger::SetDefaultHandler();
		mediasoupclient::Logger::SetLogLevel(mediasoupclient::Logger::LogLevel::LOG_TRACE);
		rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);

		routerRtpCapabilities = generateRouterRtpCapabilities();
		mediasoupclient::PeerConnection::Options opt;
		opt.factory = getFactory(); // getFactory() returns factory created in `test/src/MediaStreamTrackFactory.cpp`

		REQUIRE_NOTHROW(device->Load(routerRtpCapabilities, &opt));
		REQUIRE(device->IsLoaded());
	}

Log output:

c:\workspace\libmediasoupclient>C:\workspace\libmediasoupclient\debug\test\Release\test_mediasoupclient.exe
(audio_processing_impl.cc:272): Injected APM submodules:
Echo control factory: 0
Echo detector: 0
Capture analyzer: 0
Capture post processor: 0
Render pre processor: 0
(webrtc_voice_engine.cc:206): WebRtcVoiceEngine::WebRtcVoiceEngine
(webrtc_video_engine.cc:572): WebRtcVideoEngine::WebRtcVideoEngine()
(webrtc_voice_engine.cc:228): WebRtcVoiceEngine::Init
(webrtc_voice_engine.cc:230): The 'rtc-low-prio' thread is created only by demand for aecdumping
(webrtc_voice_engine.cc:233): Supported send codecs in order of preference:
(webrtc_voice_engine.cc:236): opus/48000/2 { minptime=10 useinbandfec=1 } (111)
(webrtc_voice_engine.cc:236): ISAC/16000/1 (103)
(webrtc_voice_engine.cc:236): ISAC/32000/1 (104)
(webrtc_voice_engine.cc:236): G722/8000/1 (9)
(webrtc_voice_engine.cc:236): PCMU/8000/1 (0)
(webrtc_voice_engine.cc:236): PCMA/8000/1 (8)
(webrtc_voice_engine.cc:236): CN/32000/1 (106)
(webrtc_voice_engine.cc:236): CN/16000/1 (105)
(webrtc_voice_engine.cc:236): CN/8000/1 (13)
(webrtc_voice_engine.cc:236): telephone-event/48000/1 (110)
(webrtc_voice_engine.cc:236): telephone-event/32000/1 (112)
(webrtc_voice_engine.cc:236): telephone-event/16000/1 (113)
(webrtc_voice_engine.cc:236): telephone-event/8000/1 (126)
(webrtc_voice_engine.cc:239): Supported recv codecs in order of preference:
(webrtc_voice_engine.cc:242): opus/48000/2 { minptime=10 useinbandfec=1 } (111)
(webrtc_voice_engine.cc:242): ISAC/16000/1 (103)
(webrtc_voice_engine.cc:242): ISAC/32000/1 (104)
(webrtc_voice_engine.cc:242): G722/8000/1 (9)
(webrtc_voice_engine.cc:242): PCMU/8000/1 (0)
(webrtc_voice_engine.cc:242): PCMA/8000/1 (8)
(webrtc_voice_engine.cc:242): CN/32000/1 (106)
(webrtc_voice_engine.cc:242): CN/16000/1 (105)
(webrtc_voice_engine.cc:242): CN/8000/1 (13)
(webrtc_voice_engine.cc:242): telephone-event/48000/1 (110)
(webrtc_voice_engine.cc:242): telephone-event/32000/1 (112)
(webrtc_voice_engine.cc:242): telephone-event/16000/1 (113)
(webrtc_voice_engine.cc:242): telephone-event/8000/1 (126)
(webrtc_voice_engine.cc:312): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, swap: 0, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, audio_jitter_buffer_enable_rtx_handling: 0, typing: 1, experimental_agc: 0, experimental_ns: 0, residual_echo_detector: 1, }
(webrtc_voice_engine.cc:428): Stereo swapping enabled? 0
(webrtc_voice_engine.cc:433): NetEq capacity is 200
(webrtc_voice_engine.cc:439): NetEq fast mode? 0
(webrtc_voice_engine.cc:445): NetEq minimum delay is 0
(webrtc_voice_engine.cc:451): NetEq handle reordered packets? 0
(webrtc_voice_engine.cc:471): Experimental ns is enabled? 0
(webrtc_voice_engine.cc:524): NS set to 1
(webrtc_voice_engine.cc:528): Typing detection is enabled? 1
(audio_processing_impl.cc:526): AudioProcessing::ApplyConfig: AudioProcessing::Config{ pipeline: {maximum_internal_processing_rate: 48000, multi_channel_render: 0, , multi_channel_capture: 0}, pre_amplifier: { enabled: 0, fixed_gain_factor: 1 }, high_pass_filter: { enabled: 1 }, echo_canceller: { enabled: 1, mobile_mode: 0, enforce_high_pass_filtering: 1 }, noise_suppression: { enabled: 1, level: High }, transient_suppression: { enabled: 0 }, voice_detection: { enabled: 1 }, gain_controller1: { enabled: 1, mode: FixedDigital, target_level_dbfs: 3, compression_gain_db: 9, enable_limiter: 1, analog_level_minimum: 0, analog_level_maximum: 255 }, gain_controller2: { enabled: 0, fixed_digital: { gain_db: 0 }, adaptive_digital: { enabled: 0, level_estimator: Rms, use_saturation_protector: 1, extra_saturation_margin_db: 2 } }, residual_echo_detector: { enabled: 1 }, level_estimation: { enabled: 0 } }
(render_delay_buffer.cc:362): Applying total delay of 5 blocks.
(matched_filter.cc:450): Filter 0: start: 0 ms, end: 128 ms.
(matched_filter.cc:450): Filter 1: start: 96 ms, end: 224 ms.
(matched_filter.cc:450): Filter 2: start: 192 ms, end: 320 ms.
(matched_filter.cc:450): Filter 3: start: 288 ms, end: 416 ms.
(matched_filter.cc:450): Filter 4: start: 384 ms, end: 512 ms.
(agc_manager_direct.cc:69): [agc] GetMinMicLevel
(agc_manager_direct.cc:73): [agc] Using default min mic level: 12
(rtc_event_log_impl.cc:43): Creating legacy encoder for RTC event log.
(peer_connection_factory.cc:391): Using default network controller factory
(bitrate_prober.cc:69): Bandwidth probing enabled, set to inactive
(pacing_controller.cc:222): bwe:pacer_updated pacing_kbps=300 padding_budget_kbps=0
(paced_sender.cc:176): ProcessThreadAttached 0x68ccf3b0
(cpu_info.cc:53): Available number of cores: 16
(aimd_rate_control.cc:113): Using aimd rate control with back off factor 0.85
(remote_bitrate_estimator_single_stream.cc:72): RemoteBitrateEstimatorSingleStream: Instantiating.
(remote_estimator_proxy.cc:50): Maximum interval between transport feedback RTCP messages (ms): 250
(webrtc_session_description_factory.cc:179): DTLS-SRTP enabled; sending DTLS identity request (key type: 1).
(openssl_identity.cc:43): Making key pair
(peer_connection.cc:1829): Adding audio transceiver in response to a call to AddTransceiver.
(peer_connection.cc:1829): Adding video transceiver in response to a call to AddTransceiver.
(openssl_identity.cc:91): Returning key pair
(openssl_certificate.cc:66): Making certificate for WebRTC
(openssl_certificate.cc:116): Returning certificate
(webrtc_session_description_factory.cc:481): Setting new certificate.
(used_ids.h:55): Duplicate id found. Reassigning from 104 to 127
(used_ids.h:55): Duplicate id found. Reassigning from 103 to 125
(used_ids.h:55): Duplicate id found. Reassigning from 1 to 14
(used_ids.h:55): Duplicate id found. Reassigning from 3 to 13
(used_ids.h:55): Duplicate id found. Reassigning from 5 to 12
(used_ids.h:55): Duplicate id found. Reassigning from 6 to 11
(peer_connection.cc:1077): Session: 3365870695444625548 is destroyed.
(paced_sender.cc:176): ProcessThreadAttached 0x0
(paced_sender.cc:176): ProcessThreadAttached 0x0
(dtmf_sender.cc:225): The Dtmf provider is deleted. Clear the sending queue.
(audio_processing_impl.cc:272): Injected APM submodules:
Echo control factory: 0
Echo detector: 0
Capture analyzer: 0
Capture post processor: 0
Render pre processor: 0
(webrtc_voice_engine.cc:206): WebRtcVoiceEngine::WebRtcVoiceEngine
(webrtc_video_engine.cc:572): WebRtcVideoEngine::WebRtcVideoEngine()
(webrtc_voice_engine.cc:228): WebRtcVoiceEngine::Init
(webrtc_voice_engine.cc:230): The 'rtc-low-prio' thread is created only by demand for aecdumping
(webrtc_voice_engine.cc:233): Supported send codecs in order of preference:
(webrtc_voice_engine.cc:236): opus/48000/2 { minptime=10 useinbandfec=1 } (111)
(webrtc_voice_engine.cc:236): ISAC/16000/1 (103)
(webrtc_voice_engine.cc:236): ISAC/32000/1 (104)
(webrtc_voice_engine.cc:236): G722/8000/1 (9)
(webrtc_voice_engine.cc:236): PCMU/8000/1 (0)
(webrtc_voice_engine.cc:236): PCMA/8000/1 (8)
(webrtc_voice_engine.cc:236): CN/32000/1 (106)
(webrtc_voice_engine.cc:236): CN/16000/1 (105)
(webrtc_voice_engine.cc:236): CN/8000/1 (13)
(webrtc_voice_engine.cc:236): telephone-event/48000/1 (110)
(webrtc_voice_engine.cc:236): telephone-event/32000/1 (112)
(webrtc_voice_engine.cc:236): telephone-event/16000/1 (113)
(webrtc_voice_engine.cc:236): telephone-event/8000/1 (126)
(webrtc_voice_engine.cc:239): Supported recv codecs in order of preference:
(webrtc_voice_engine.cc:242): opus/48000/2 { minptime=10 useinbandfec=1 } (111)
(webrtc_voice_engine.cc:242): ISAC/16000/1 (103)
(webrtc_voice_engine.cc:242): ISAC/32000/1 (104)
(webrtc_voice_engine.cc:242): G722/8000/1 (9)
(webrtc_voice_engine.cc:242): PCMU/8000/1 (0)
(webrtc_voice_engine.cc:242): PCMA/8000/1 (8)
(webrtc_voice_engine.cc:242): CN/32000/1 (106)
(webrtc_voice_engine.cc:242): CN/16000/1 (105)
(webrtc_voice_engine.cc:242): CN/8000/1 (13)
(webrtc_voice_engine.cc:242): telephone-event/48000/1 (110)
(webrtc_voice_engine.cc:242): telephone-event/32000/1 (112)
(webrtc_voice_engine.cc:242): telephone-event/16000/1 (113)
(webrtc_voice_engine.cc:242): telephone-event/8000/1 (126)


#
# Fatal error in: ../../../media/engine/webrtc_voice_engine.cc, line 252
# last system error: 87
# Check failed: adm()
#

Hi,

If you are already creating the PeerConnection with your own PeerConnectionFactory providing an ADM, there’s no much we can do here. We just pass it to libwebrtc.

I’d suggest you get the stack trace and start from there.