0

I would like to add an interface in AppRTCMobile, this interface can start webrtc Call module, in order to achieve the audio call between two phones (LAN, already know both the IP address and port number), but when I run successfully , The software crashes every time an exception occurs when the method is called by RtcEventLog. I do not know if Calling Call is reasonable or not. I sincerely thank you for your help in the absence of a solution. Below the source code, please help me find the problem.

    std::unique_ptr<RtcEventLog> event_log = webrtc::RtcEventLog::Create();
    webrtc::Call::Config callConfig = webrtc::Call::Config(event_log.get());
    callConfig.bitrate_config.max_bitrate_bps = 500*1000;
    callConfig.bitrate_config.min_bitrate_bps = 100*1000;
    callConfig.bitrate_config.start_bitrate_bps = 250*1000;

    webrtc::AudioState::Config audio_state_config = webrtc::AudioState::Config();
    cricket::VoEWrapper* g_voe  = nullptr;
    rtc::scoped_refptr<webrtc::AudioDecoderFactory> g_audioDecoderFactory;
    g_audioDecoderFactory = webrtc::CreateBuiltinAudioDecoderFactory();
    g_voe = new cricket::VoEWrapper();
    audio_state_config.audio_processing = webrtc::AudioProcessing::Create();
    g_voe->base()->Init(NULL,audio_state_config.audio_processing,g_audioDecoderFactory);
    audio_state_config.voice_engine = g_voe->engine();

    audio_state_config.audio_mixer = webrtc::AudioMixerImpl::Create();
    callConfig.audio_state = AudioState::Create(audio_state_config);
    std::unique_ptr<RtcEventLog> event_logg = webrtc::RtcEventLog::Create();
    callConfig.event_log = event_logg.get();
    g_call = webrtc::Call::Create(callConfig);



    g_audioSendTransport = new AudioLoopbackTransport();
    webrtc::AudioSendStream::Config config(g_audioSendTransport);
    g_audioSendChannelId = g_voe->base()->CreateChannel();
    config.voe_channel_id = g_audioSendChannelId;
    g_audioSendStream = g_call->CreateAudioSendStream(config);


    webrtc::AudioReceiveStream::Config AudioReceiveConfig;
    AudioReceiveConfig.decoder_factory = g_audioDecoderFactory;
    g_audioReceiveChannelId = g_voe->base()->CreateChannel();
    AudioReceiveConfig.voe_channel_id = g_audioReceiveChannelId;
    g_audioReceiveStream = g_call->CreateAudioReceiveStream(AudioReceiveConfig);

    g_audioSendStream->Start();
    g_audioReceiveStream->Start();

Here's a screenshot of the error that occurred when the crash occurred. Please tell me if you want to know more.

docMan
  • 11
  • 3

1 Answers1

0

Your code crashed at event_log_->LogAudioPlayout()... It's obviously that event_log_ object is already released.

Objects which are managed by unique_ptr or scoped_refptr will be released after execution, but these objects may still be used in your case, that will lead to crash problem. So put these objects in global memory or retain them.

Ray
  • 272
  • 2
  • 13
  • Thank you, I follow the information you prompted to change, but still encountered the same problem. I defined a global variable, this is the way: webrtc :: RtcEventLog * envlog. I have to call the initialization method inside is like this: std :: unique_ptr CreateRtcEventLogFactory (); std :: unique_ptr < : Config (envlog); In addition, the event_log object is not released at the point where it crashed. I do not think event_log caused any memory corruption due to that method because event_log has many virtual functions. – docMan Jan 31 '18 at 06:00