SDP Offer not generating

138 views
Skip to first unread message

Pavel

unread,
Jun 23, 2020, 6:35:53 PM6/23/20
to discuss-webrtc
I'm trying to add WebRTC native (M84.4147) into my existing Qt GUI application. 
By now most of my code is based on peerconnection_client example's code. However I'm stuck with generating sdp offer, which does not fire nor CreateSessionDescriptionObserver::OnSuccess nor CreateSessionDescriptionObserver::OnFailure.

In my MainWindow  form I create websocket, which is used for signalling, and conductor

Messanger *rtc = new Messanger(this);
Conductor *conductor = new Conductor(rtc);
rtc
->Connect();

Messanger::Connect triggers creating peer_connection by callback. Conductor inherited from webrtc::CreateSessionDescriptionObserver so I expect getting some result in Conductor::OnSuccess or Conductor::OnFailure but this does not happens

void Conductor::OnSignedIn()
{
    peer_connection_factory_ = 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 */);

    /* some checks not nullptrs
    ...
    */ 

    webrtc::PeerConnectionInterface::RTCConfiguration config;
    config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
    config.enable_dtls_srtp = dtls;
    webrtc::PeerConnectionInterface::IceServer server;
    server.uri = "stun:stun.l.google.com:19302";
    config.servers.push_back(server);

    peer_connection_ = peer_connection_factory_->CreatePeerConnection(config, nullptr, nullptr, this);
    peer_connection_->CreateOffer(this, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}

What i'm doing wrong? Is it really threading-related problem? If 
I'll be grateful for any help

Alexandre GOUAILLARD

unread,
Jun 23, 2020, 7:14:01 PM6/23/20
to discuss...@googlegroups.com
what do your callbacks (the observer::OnSuccess/OnFailure overridden method) look like?
I suppose you are using the new m84 signature which takes the RTCError as an argument?

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/b27fcb97-0bda-459a-bcbd-03130dc0eceao%40googlegroups.com.


--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Pavel

unread,
Jun 24, 2020, 5:50:14 AM6/24/20
to discuss-webrtc
I suppose you are using the new m84 signature which takes the RTCError as an argument?
Yes, I'm.

Here is my callbasks

void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc)
{
  qDebug
() << "OnSuccess";
 
  peer_connection_
->SetLocalDescription(DummySetSessionDescriptionObserver::Create(), desc);

  std
::string sdp;
  desc
->ToString(&sdp);

  Q_EMIT
SDPGen(sdp);
}

void Conductor::OnFailure(webrtc::RTCError error) {
  qDebug
() << ToString(error.type()) << ": " << error.message();
}

Actually, I already fix part of my problem. It was tied to threading. Adding new signaling thread for webrtc::CreatePeerConnectionFactory was a solution

But I still have some problems. For now, my offer looks like this:
v=0
o
=- 5454879051792501191 2 IN IP4 127.0.0.1
s
=-
t
=0 0
a
=group:BUNDLE 0 1
a
=msid-semantic: WMS stream_id

But there is no media info, nor ICE candidates. I add tracks before creating offer.


void Conductor::AddTracks() {
    rtc
::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
                peer_connection_factory_
->CreateAudioTrack(
                    kAudioLabel
, peer_connection_factory_->CreateAudioSource(
                        cricket
::AudioOptions())));
   
auto result_or_error = peer_connection_->AddTrack(audio_track, {kStreamId});
   
if (!result_or_error.ok()) {
        qDebug
() <<  "Failed to add audio track to PeerConnection: " << result_or_error.error().message();
   
}

    rtc
::scoped_refptr<CapturerTrackSource> video_device = CapturerTrackSource::Create();
   
if (video_device) {
        rtc
::scoped_refptr<webrtc::VideoTrackInterface> video_track_(
                    peer_connection_factory_
->CreateVideoTrack(kVideoLabel, video_device));
       
       
// TODO start rendering

        result_or_error
= peer_connection_->AddTrack(video_track_, {kStreamId});

       
if (!result_or_error.ok()) {
            qDebug
() << "Failed to add video track to PeerConnection: " << result_or_error.error().message();
       
}
   
} else {
        qDebug
() << "OpenVideoCaptureDevice failed";
   
}
}



среда, 24 июня 2020 г., 2:14:01 UTC+3 пользователь Alexandre GOUAILLARD написал:
To unsubscribe from this group and stop receiving emails from it, send an email to discuss...@googlegroups.com.

Alexandre GOUAILLARD

unread,
Jun 24, 2020, 8:42:52 AM6/24/20
to discuss...@googlegroups.com
It is normal not to have ICE candidate in the offer / answer by default.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/30fae1b6-faa8-4bc5-8c6a-0fb0f142ff67o%40googlegroups.com.

Pavel

unread,
Jun 24, 2020, 10:14:10 AM6/24/20
to discuss-webrtc
As I found out Ice candidates can be obtained in PeerConnectionObserver::OnIceCandidate callback.
I continue my experiments and notice that sometimes my offer looks like that

v=0

o=- 99157163530396358 2 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDLE 0 1

a=msid-semantic: WMS stream_id

m=audio 9

 or like that

v=0

o=- 99157163530396358 5 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDL


So, what leeds to this behavior? What I have to do?




среда, 24 июня 2020 г., 15:42:52 UTC+3 пользователь Alexandre GOUAILLARD написал:

Pavel

unread,
Jun 24, 2020, 6:42:03 PM6/24/20
to discuss-webrtc
I add more logging and find out that PeerConnectionObserver and CreateSessionDescriptionObserver callbacks works in same thread, while condictor runs in another.

Is it correct behavior? How can I make my callback to not interrupt each other?

среда, 24 июня 2020 г., 17:14:10 UTC+3 пользователь Pavel написал:

gfield

unread,
Aug 31, 2021, 12:00:28 PMAug 31
to discuss-webrtc
I am having the same problem.. Did you figure out what was happening ?

V I

unread,
Aug 31, 2021, 11:05:20 PMAug 31
to discuss...@googlegroups.com
These issues usually appear when you try to squeeze peerconnection_client into your own threading model. Those callbacks work via tasks posted on the current thread, so to make things work you need to use rtc::Thread::Run (https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/examples/peerconnection/client/linux/main.cc;l=109) as your work loop or do what Thread::Run() does yourself - call rtc::Thread::Current()->ProcessMessages() on a regular basis to get those callbacks dispatched.
In general people should give peerconnection_client a wide berth - figuring out quirks of this buggy, poorly maintained contraption takes too much time imo.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/01f0e97b-d5b1-4da8-b655-99d289294ad3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages