Re: [ACTION-49] DataChannel issues

On 06/27/2012 12:04 AM, Randell Jesup wrote:
> On 6/26/2012 5:18 AM, Stefan Hakansson LK wrote:
>> Adding a DataChannel object [ACTION-49]
>>       Proposal written up by Randell
>>       Not clear what the benefits of introducing it is
>
> Options follow.  I prefer option #3 (with default channels in SDP, but
> I'm also ok with them being held internally for creation on connection).
> Note all of these assume the decision made in Stockholm, which was to
> mirror the WebSockets API (channels must wait on onopen before you call
> send()).
>
> The connection object's main advantage is being able to ask it directly
> for global stats, etc, instead of having those be methods on
> PeerConnection - and if for any reason we want to enable DataChannels
> via something other than PeerConnection, you'd have a discrete
> object/interface already defined for it; or you could allow two data
> connections (associations) per PeerConnection (though there are very
> limited reasons I can see why).
>
> I think "keep it simple, optimize only the common cases" is the right
> tack.  Option #3, with the only optimization being to allow default
> channels in the SDP because that's a very common case.

I also like #3 best (or #4 - they do not seem that different to me).

But a couple of questions:

* Is there really a gain in adding "addDataChannel" and 
"closeAllDataChannels"? In the current draft [1] you can do "dc = 
pc.createDataChannel" and then dc.close. Would that not be sufficient? 
For the very first data channel created there is an SDP o/a needed, but 
the app can treat that as opaque, just do the 
createOffer-setLocal-send... thing whenever a "renegotiationneeded" 
event is fired. And likewise, if all data channels have been closed a 
re-negotiation would be needed again, but this could happen as a result 
of the app closing all of them, no need for "closeAll".

* I have never understood why there should just be a limited set of data 
channels signaled in the SDP o/a. If data is added, could not all SCTP 
streams be used? And if the app tries to open more than 64k (or whatever 
the limit is) there would be an error.

Stefan

[1] http://dev.w3.org/2011/webrtc/editor/webrtc.html

>
> #1. Minimal internal state, use onopen for adding initial channels:
>
>          connection = pc.createDataConnection(default_streams,...);
>          connection.onopen = connection_onopen;
>          ...
>          pc.createOffer()/createAnswer();
>          ...
>
>          function connection_onopen() {
>             channel_1  = connection.createDataChannel(....);
>             channel_1.onopen = chan_1_connected;
>             channel_1.onmessage = chan_1_messages;
>          }
>
>          function chan_1_connected() {
>             channel_1.send("foo");
>          }
>          etc
>          ...
>          connection.increaseMaxChannelsTo = 1234; // not really needed
>          ...
>          connection.close();
>
> #2. Connection object, early channel creation -
>       Good for static channels; can add channels later.
>
>          connection = pc.createDataConnection(default_streams,...);
>          connection.onopen = connection_onopen; // optional
>          channel_1 = connection.createDataChannel(....);
>          channel_1.onopen = chan_1_connected;
>          channel_1.onmessage = chan_1_messages;
>          ...
>          pc.createOffer()/createAnswer(); // SDP includes channels
>          ...
>
>          function chan_1_connected() {
>             channel_1.send("foo");
>          }
>          etc
>          ...
>          connection.increaseMaxChannelsTo = 1234; // not really needed
>          ...
>          connection.close();  // disconnects all DataChannels
>
> #3. No connection object, early channel creation -
>       Good for static channels; can add channels later.
>
>
>          pc.addDataChannel(default_streams,...);
>          channel_1 = pc.createDataChannel(....);
>          channel_1.onopen = chan_1_connected;
>          channel_1.onmessage = chan_1_messages;
>          ...
>          pc.createOffer()/createAnswer(); // SDP includes channels
>          // OR the channels are started automatically once the
>          // connection/association is live
>          ...
>
>          function chan_1_connected() {
>             channel_1.send("foo");
>          }
>          etc
>          ...
>          // Don't let user bump channels by hand, leave to automatic
>          ...
>          pc.closeAllDataChannels();  // disconnects all DataChannels
>
> #4. No connection object, no early channel creation -
>       All channels added after pc is connected.
>
>          pc.addDataChannel(default_streams);
>          ...
>          pc.createOffer()/createAnswer(); // SDP just has data connection
>          ...
>
>          function on_pc_connected() {
>             channel_1 = pc.createDataChannel(....);
>             channel_1.onopen = chan_1_connected;
>             channel_1.onmessage = chan_1_messages;
>          }
>
>          function chan_1_connected() {
>             channel_1.send("foo");
>          }
>          etc
>          ...
>          // Don't let user bump channels by hand, leave to automatic
>          ...
>          pc.closeAllDataChannels();  // disconnects all DataChannels
>
>

Received on Wednesday, 27 June 2012 09:00:48 UTC