OnIceConnectionChange not invoked on PeerConnectionObserver implementation for subsequent calls

179 views
Skip to first unread message

sho...@bionics.co.uk

unread,
May 3, 2019, 2:55:58 PM5/3/19
to discuss-webrtc
I'm working on an application where calls are made via webrtc. Each time a call comes into our application, the following happens:
  • Create a peer connection factory with a custom audio device module for capturing audio from our application. New threads are created for each peer.
  • Create a peer connection.
  • Provide an offer that comes from a browser, sending back an answer, and then performing ice candidate exchange.
For single calls, this seems to work fine and we see full 2 way audio. However, once I try to start 2 calls around the same time issues begin to emerge.
  • OnIceConnectionChange is only invoked for the first call that is started (I see this jump straight to connected, there is no "checking" state reported).
  • Once each peer is torn down, OnIceConnectionChange is invoked for both calls, show the closed status.
Does anyone have any idea why this might be the case? I've been attempting to debug this, but the asynchronous nature of this issue makes the issue difficult to pin down. 
  1. Could something be incorrect with the way we are using threading? Not that I have also tried using Thread::Current() for all threads and invoking thread->ProcessMessages(delay) periodically, and different permutations of thread creation methods.
  2. Is there something fundamentally incorrect about the way we are using the library?

Thanks, I will attach some code details below:


Conductor implements the PeerConnectionObserver:

class Conductor : public webrtc::PeerConnectionObserver,
    public webrtc::CreateSessionDescriptionObserver,
    public webrtc::SetSessionDescriptionObserver,
    public webrtc::DataChannelObserver,
    public AudioCallback

OnIceConnectionChange invokes an external callback. We have a breakpoint set in here so that we can see when this calls.

void Conductor::OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state)
{
    if (onIceConnectionStateChange != nullptr) {
        onIceConnectionStateChange(static_cast<char>(new_state));
    }
}

This shows how we are creating the peer connection factory, not the threads we are creating such that each call runs entirely in it's own threads.

// Create 
signaling_thread = rtc::Thread::Create();
if (!signaling_thread->Start()) {
    return false;
}

network_thread = rtc::Thread::CreateWithSocketServer();
if (!network_thread->Start()) {
    return false;
}

worker_thread = rtc::Thread::Create();
if (!worker_thread->Start()) {
    return false;
}

// Create peer connection factory.
pc_factory_ = webrtc::CreatePeerConnectionFactory(
    network_thread.get(),
    worker_thread.get(),
    signaling_thread.get(),
    audio_capture.get() /* default_adm */,
    webrtc::CreateBuiltinAudioEncoderFactory(),
    webrtc::CreateBuiltinAudioDecoderFactory(),
    nullptr, /* video encoder factory */
    nullptr, /* video decoder factory */
    nullptr /* audio_mixer */,
    nullptr /* audio_processing */
);

New peer connections are created, not that one of these is created per factory (required to be this way, since we have to pass in a different audio device module for each call).

peer_connection_ = pc_factory_->CreatePeerConnection(config, NULL, NULL, this);





This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the Broadcast Bionics unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.

Please note that Broadcast Bionics monitors e-mails sent or received.
Further communication will signify your consent to this.
Broadcast Bionics is a trading division of Bionics Corporation Ltd.  Company Reg No: 3241053.

Reply all
Reply to author
Forward
0 new messages