WebRTC native, ICE callbaks not triggered.

87 views
Skip to first unread message

chen chen

unread,
Sep 19, 2018, 11:25:56 AM9/19/18
to discuss-webrtc
Hi,
    I'm developing a WebRTC native demo client, using the master brach of WebRTC (I pulled webrtc yesterday), but I am suffering that the ICE callbacks are not triggered.

    By referening to the example in the WebRTC strunk, my code is roughly like this (I hope it is not too long), I got the offer sdp but no ICE candidate:


class MockClient: public webrtc::PeerConnectionObserver,
public webrtc::CreateSessionDescriptionObserver,
public rtc::Runnable {
MockClient(): mServer(), mSignalingThread(&mServer)
{
mSignalingThread.SetName("SignalingThread", nullptr);
mSignalingThread.Start(this);
}

void Run(rtc::Thread* thread) override
{
mPcf = webrtc::CreatePeerConnectionFactory(
nullptr /* network_thread */, nullptr /* worker_thread */,
nullptr /* signaling_thread */, nullptr /* default_adm */,
webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::CreateBuiltinAudioDecoderFactory(),
webrtc::CreateBuiltinVideoEncoderFactory(),
webrtc::CreateBuiltinVideoDecoderFactory(), nullptr /* audio_mixer */,
nullptr /* audio_processing */);

assert(mPcf != nullptr);

webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
config.enable_dtls_srtp = true;
webrtc::PeerConnectionInterface::IceServer server;
server.uri = "stun:address.of.my.stun.server";
config.servers.push_back(server);

mPc = mPcf->CreatePeerConnection(
config, nullptr, nullptr, this);

assert(mPc != nullptr);

std::unique_ptr<cricket::VideoCapturer> videoDevice = OpenVideoCaptureDevice();
rtc::scoped_refptr<webrtc::VideoTrackInterface> videoTrack(
mPc->CreateVideoTrack(
kVideoLabel,
mPcf->CreateVideoSource(std::move(videoDevice), nullptr)
)
);
auto res = mPc->AddTrack(videoTrack, { "videoStreamId-123" });
assert(res.ok());

mPc->CreateOffer(this, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());

thread->Run();
}

// other interface callbacks

private:
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPcf;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> mPc;

rtc::PhysicalSocketServer mServer;
rtc::Thread mSignalingThread;
}

int main()
{
rtc::InitializeSSL();

MockClient client;

sleep(10000000);
rtc::CleanupSSL();
return 0;
}

Regards.

chen chen

unread,
Sep 20, 2018, 2:11:21 AM9/20/18
to discuss-webrtc
After I modified the example, I finally find out, the ice procedure will not start until the local sdp is set.
Reply all
Reply to author
Forward
0 new messages