W3C home > Mailing lists > Public > public-webrtc@w3.org > April 2015

Re: Question: how should addTrack work in relation to createOffer et. al.?

From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Thu, 30 Apr 2015 12:48:38 -0400
Message-ID: <55425CE6.3070407@mozilla.com>
To: Stefan Håkansson LK <stefan.lk.hakansson@ericsson.com>, "public-webrtc@w3.org" <public-webrtc@w3.org>
On 4/30/15 2:42 AM, Stefan Håkansson LK wrote:
> On 24/04/15 17:38, Jan-Ivar Bruaroey wrote:
>> Since JavaScript is a run-to-completion language, another (common?)
>> approach would be to queue a (micro) task to execute the asynchronous
>> operation, as I've just proposed today here in another thread.
>>
>> Not only would this unify behavior between when something is on the
>> queue vs. when nothing is on the queue, but it would make the following
>> deterministic:
>>
>>     var senderX = pc.addTrack(trackX);
>>     pc.createOffer();
>>     var senderY = pc.addTrack(trackY);
>>     // Both trackX and trackY will always be in the offer.
> How does that work?

See my answer to Justin's post in this thread (tl;dr because 
createOffer() is queued to run later).

>   And what determines if trackY is represented in the
> offer or not (in the example it is added right after createOffer is
> called, but there can be many scenarios here, like a bit later or in
> another context)?

As I show in my other post, we need to be careful to not conflate when 
queued functions are called with when they execute:

function received(offer) {

   log(pc.signalingState); // stable

   pc.setRemoteDescription(offer);

   log(pc.signalingState); // stable

   pc.createAnswer().then(answer => {

     log(pc.signalingState); // have-remote-offer

     pc.setLocalDescription(answer);

     log(pc.signalingState); // have-remote-offer

     pc.addTrack(trackX); // added in have-remote-offer
     pc.createOffer(); // queued until stable state!
     pc.addTrack(trackY); // added in have-remote-offer
   });
}

(Note that I haven't answered your question. Will post more a bit later)

.: Jan-Ivar :.
Received on Thursday, 30 April 2015 16:49:08 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:44 UTC