<div dir="ltr">Wow, thanks for the quick reply. <div><br></div><div>However, I can assure you that I am setting the offer on the correct instance. </div><div><br></div><div>Excerpt of actual code (rust; it emits the create-offer signal, and in the promise, takes the offer and uses it via set-local-description):</div><div>let promise = gst::Promise::with_change_func(move |reply| {<br>        let webrtcbin = match webrtc_ref.upgrade() {<br>            Some(w) => w,<br>            _ => return,<br>        };<br><br>        match reply {<br>            Ok(Some(reply)) => {<br>                let offer = reply<br>                    .get_value("offer")<br>                    .unwrap()<br>                    .get::<gst_webrtc::WebRTCSessionDescription>()<br>                    .expect("Invalid argument")<br>                    .unwrap();<br><br>                let raw_offer = offer.get_sdp().as_text().unwrap();<br>                info!(<br>                    "Setting renegotiated offer for {}/{}: {}",<br>                    session_id, epid, raw_offer<br>                );<br><br>                webrtcbin<br>                    .emit("set-local-description", &[&offer, &None::<gst::Promise>])<br>                    .unwrap();<br><br>                if tx.send(Ok(raw_offer)).is_err() {<br>                    error!("Could not send offer to receiving channel");<br>                }<br>            }<br>            _ => {<br>                if tx.send(Err(anyhow!("Could not generate offer."))).is_err() {<br>                    error!("Could not send error to receiving channel.");<br>                }<br>            }<br>        };<br>    });<br><br>    webrtcbin<br>        .emit("create-offer", &[&None::<gst::Structure>, &promise])<br>        .unwrap();<br></div><div><br></div><div><br></div><div><br></div><div>And actual log messages:</div><div>2020-12-04T14:20:17.185953907-06:00 [unnamed][src/<a href="http://gstlib_webrtc.rs:568">gstlib_webrtc.rs:568</a>] - Setting renegotiated offer for b41be2aa-40db-4e5b-981e-8f78cbf7dc5e/ep1: v=0<br></div><div>...</div><div>0:00:13.224684399 93456 0x7fffb400c6a0 INFO               webrtcbin gstwebrtcbin.c:4311:_set_description_task:<webrtcbin> Attempting to set local offer in the stable state<br>0:00:13.224699818 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:4313:_set_description_task:<webrtcbin> SDP contents<br>v=0<br></div><div>...</div><div>0:00:13.224759621 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:4478:_set_description_task:<webrtcbin> we are in ice controlling mode: true<br></div><div>0:00:13.224770732 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br></div><div>0:00:13.224844291 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br></div><div>0:00:13.224910856 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:4639:_set_description_task:<webrtcbin> notify signaling-state from have-local-offer to have-local-offer<br></div><div>...</div><div>...</div><div>0:00:13.354347283 93456 0x7fffb400c6a0 INFO               webrtcbin gstwebrtcbin.c:4311:_set_description_task:<webrtcbin> Attempting to set remote answer in the have-local-offer state<br></div><div>0:00:13.354358154 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:4313:_set_description_task:<webrtcbin> SDP contents<br></div><div>0:00:13.354396677 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:4478:_set_description_task:<webrtcbin> we are in ice controlling mode: true<br>0:00:13.354405533 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br></div><div>0:00:13.354466028 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3718:_update_transport_ptmap_from_media:<webrtcbin> mapping sdp session level attributes to caps<br>0:00:13.354473852 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3720:_update_transport_ptmap_from_media:<webrtcbin> mapping sdp media level attributes to caps<br>0:00:13.354484603 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3733:_update_transport_ptmap_from_media:<webrtcbin>  looking at 0 pt: 111<br>0:00:13.354504270 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3718:_update_transport_ptmap_from_media:<webrtcbin> mapping sdp session level attributes to caps<br>0:00:13.354508387 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3720:_update_transport_ptmap_from_media:<webrtcbin> mapping sdp media level attributes to caps<br>0:00:13.354515601 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3733:_update_transport_ptmap_from_media:<webrtcbin>  looking at 0 pt: 111<br>0:00:13.354526882 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br>0:00:13.354531281 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:3438:_find_transceiver_for_sdp_media:<webrtcbin> Found transceiver <webrtctransceiver0><br>0:00:13.354535188 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br>0:00:13.354586475 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:3863:_update_transceiver_from_sdp_media:<webrtcbin> marking stream 0x7fffbc04cb30 as active<br>0:00:13.354612033 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:3438:_find_transceiver_for_sdp_media:<webrtcbin> Found transceiver <webrtctransceiver3><br>0:00:13.354615970 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br>0:00:13.354648762 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:3863:_update_transceiver_from_sdp_media:<webrtcbin> marking stream 0x7fffbc04cb30 as active<br>0:00:13.354653852 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3878:_update_transceiver_from_sdp_media:<webrtcbin> transceiver <webrtctransceiver3> direction change from none to sendonly<br>0:00:13.354658451 93456 0x7fffb400c6a0 DEBUG              webrtcbin gstwebrtcbin.c:3911:_update_transceiver_from_sdp_media:<webrtcbin> found existing send pad <webrtcbin:sink_1> for transceiver <webrtctransceiver3><br>0:00:13.354668630 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:4532:_set_description_task:<webrtcbin:sink_1> Connecting input stream to rtpbin with transceiver <webrtctransceiver3> and caps application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)OPUS, payload=(int)111, encoding-params=(string)2, ssrc=(uint)1462191880, timestamp-offset=(uint)573074706, seqnum-offset=(uint)19451<br>0:00:13.354672998 93456 0x7fffb400c6a0 INFO               webrtcbin gstwebrtcbin.c:3482:_connect_input_stream:<webrtcbin:sink_1> linking input stream 1<br>0:00:13.354739644 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br>0:00:13.354781844 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:507:_find_transport_for_session:<webrtcbin> Found transport <transportstream0> for session 0<br>0:00:13.354817250 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:393:_find_ice_stream_for_session:<webrtcbin> Found ice stream id <webrtcicestream0> for session 0<br>0:00:13.354822230 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:3627:_add_ice_candidates_from_sdp:<webrtcbin> adding ICE candidate with mline:0, a=candidate:3885250869 1 UDP 2122260223 172.17.0.1 47390 typ host generation 0 network-id 1<br>0:00:13.354835575 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:3627:_add_ice_candidates_from_sdp:<webrtcbin> adding ICE candidate with mline:0, a=candidate:3719404024 1 UDP 2122194687 192.168.0.91 47330 typ host generation 0 network-cost 10 network-id 2<br>0:00:13.354843510 93456 0x7fffb400c6a0 TRACE              webrtcbin gstwebrtcbin.c:4639:_set_description_task:<webrtcbin> notify signaling-state from stable to stable<br>0:00:13.354849862 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:1341:_check_if_negotiation_is_needed:<webrtcbin> checking if negotiation is needed<br>0:00:13.354851695 93456 0x7fff1000d2a0 DEBUG              webrtcbin gstwebrtcbin.c:277:gst_webrtcbin_sink_event:<webrtcbin> On <webrtcbin:sink_1> checking negotiation? 1, caps application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)OPUS, payload=(int)111, encoding-params=(string)2, seqnum-offset=(uint)19451, timestamp-offset=(uint)573074706, ssrc=(uint)1462191880<br>0:00:13.354855112 93456 0x7fffb400c6a0 LOG                webrtcbin gstwebrtcbin.c:1491:_check_if_negotiation_is_needed:<webrtcbin> no negotiation needed<br>0:00:13.354865982 93456 0x7fffa00f74c0 INFO               webrtcbin gstwebrtcbin.c:5618:on_rtpbin_new_sender_ssrc:<webrtcbin> session 0 ssrc 1462191880 new sender ssrc<br>0:00:13.354889787 93456 0x7fff1000d2a0 LOG                webrtcbin gstwebrtcbin.c:1341:_check_if_negotiation_is_needed:<webrtcbin> checking if negotiation is needed<br>0:00:13.354916548 93456 0x7fff1000d2a0 LOG                webrtcbin gstwebrtcbin.c:1491:_check_if_negotiation_is_needed:<webrtcbin> no negotiation needed<br></div><div><br></div><div>It's difficult to discern messages from one webrtcbin instance to another. But the code is following the same flow through renegotiation as the original negotiation:</div><div>* create offer</div><div>* set-local-description</div><div>* (receive answer)</div><div>* set-remote-description</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 4, 2020 at 2:14 PM Matthew Waters <<a href="mailto:ystreet00@gmail.com">ystreet00@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 5/12/20 7:02 am, Trey Hutcheson wrote:<br>
> I know SDP renegotiation is something that saw lots of improvements <br>
> from 1.16->1.18, but I'm currently stuck.<br>
><br>
> Here's my workflow:<br>
> * create webrtcbin instance for peer 1. Initialize with one audio <br>
> source. Create offer (sdp contains one audio m= line), <br>
> set-local-description, send to remote peer. Remote peer responds with <br>
> answer, then set-remote-description.<br>
> * Create another webrtcbin instance for peer 2. Same workflow. <br>
> Exchange sdp, with webrtcbin generating the offer.<br>
> * Media (audio) flows from remote peer 2. Dynamically connect audio <br>
> (opus, opusdepay then opuspay  to re-payload the rtp) from webrtcbin2 <br>
> to webrtcbin1.<br>
> * Ask webrtcbin1 to create a new offer, then set-local-description. <br>
> Offer now has two audio m= lines. Send offer to remote peer, peer <br>
> responds with new answer (with two m= lines). set-remote-description <br>
> on webrtcbin1<br>
><br>
> When I call set-remote-description with the updated answer, webrtcbin <br>
> complains:<br>
><br>
> ERROR              webrtcbin <br>
> gstwebrtcbin.c:4320:_set_description_task:<webrtcbin> Not in the <br>
> correct state (stable) for setting remote answer description<br>
><br>
> And that's because sdp was previously negotiated, and the signalling <br>
> state had achieved stable. But I want to re-negotiate, and I assumed <br>
> invoking create-offer a second time (after connecting a new sink pad <br>
> and verifying caps) would change the signalling state?<br>
><br>
<br>
If you have completed a full SDP negotiation, then the state of <br>
webrtcbin will be 'stable'.  This specific line: 'Not in the correct <br>
state (stable) for setting remote answer description' probably means <br>
that you didn't actually 'set-local-description' on this webrtcbin <br>
instance (or you're confusing which webrtcbin instance you're calling <br>
against).<br>
<br>
Calling 'create-offer' does not change any of the state properties. They <br>
are only changed with the 'set-*-description' calls as specified in the <br>
JSEP specification.<br>
<br>
Cheers<br>
-Matt<br>
<br>
</blockquote></div>