diff --git a/webrtc.html b/webrtc.html index 8778423cf..e2594789f 100644 --- a/webrtc.html +++ b/webrtc.html @@ -3976,11 +3976,6 @@

Updating the Negotiation-Needed flag

If any implementation-specific negotiation is required, as described at the start of this section, return true.

- -
  • -

    If the [[RTCWEB-IP-HANDLING]] mode has been altered since the - last time this algorithm has been invoked, return - true.

  • Let description be @@ -10978,7 +10973,18 @@

    RTCPeerConnection Interface Extensions

    partial interface RTCPeerConnection {
         static void registerDirectConnectionInterest ();
    +    attribute EventHandler onconnectionupgradable;
     };
    +
    +

    Attributes

    +
    +
    onconnectionupgradable of type + EventHandler
    +
    The event type of this event handler is + connectionupgradable.
    +
    +

    Methods

    Update Direct Connection Permission Algorithm
  • Let connection be the RTCPeerConnection.
  • If connection's [[\IsClosed]] slot is true, then abort these steps.
  • Update the connection's [[RTCWEB-IP-HANDLING]] mode with mode.
  • -
  • If connection's ICE gathering state is "connected", then update the -negotiation-needed flag for connection.
  • +
  • Fire an event named connectionupgradable at connection and abort these steps.
  • +
    If the mode is being upgraded, the event will be fired. However, if the mode has been downgraded, the event will not fire and the downgrade will not be effective for the lifetime of the RTCPeerConnection.

    Direct Connection Permission Usage Examples

    @@ -11029,8 +11035,11 @@

    Upgrade connection

    The following mechanism can be used for applications that want to establish a connection as soon as possible, albeit potentially not as direct as possible. In this example, the application tries to upgrade as soon as a connection has been established that is not considered ideal (or the connection could not be established).

    -pc.onnegotiationneeded = async () => {
    -  // Exchange new offer/answer via the signalling channel...
    +pc.onconnectionupgradable = async () => {
    +  // Initiate an ICE restart
    +  const offer = await pc.createOffer({iceRestart: true});
    +
    +  // Exchange offer/answer via the signalling channel...
     };
     
     pc.onconnectionstatechange = async () => {
    @@ -11045,7 +11054,7 @@ 

    Upgrade connection

    // Check if requesting a direct connection would be useful const pair = iceTransport.getSelectedCandidatePair(); if (pair.local.type !== 'host') { - // Once granted, this will fire the 'negotiationneeded' event + // Once granted, this will fire the 'connectionupgradable' event RTCPeerConnection.registerDirectConnectionInterest(); } } @@ -11059,8 +11068,11 @@

    Joining a session

    Voice and video chats usually have the concept of a room that is being joined. When a user joins such a room, the permission could be requested which would provide sufficient context to the user.

    -pc.onnegotiationneeded = async () => {
    -  // Exchange new offer/answer via the signalling channel...
    +pc.onconnectionupgradable = async () => {
    +  // Initiate an ICE restart
    +  const offer = await pc.createOffer({iceRestart: true});
    +
    +  // Exchange offer/answer via the signalling channel...
     };
     
     async function joinRoom() {
    @@ -11072,7 +11084,7 @@ 

    Joining a session

    console.error(err); } - // Once granted, this will fire the 'negotiationneeded' event if needed + // Once granted, this will fire the 'connectionupgradable' event if needed RTCPeerConnection.registerDirectConnectionInterest(); // Now, create the peer-to-peer connection @@ -11085,12 +11097,15 @@

    Sending a file

    A file sharing application will eventually have to let the user choose a file to be transmitted. Once that selection has been made, requesting a direct connection should provide sufficient context to the user.

    -pc.onnegotiationneeded = async () => {
    -  // Exchange new offer/answer via the signalling channel...
    +pc.onconnectionupgradable = async () => {
    +  // Initiate an ICE restart
    +  const offer = await pc.createOffer({iceRestart: true});
    +
    +  // Exchange offer/answer via the signalling channel...
     };
     
     async function onFileSelected(file) {
    -  // Once granted, this will fire the 'negotiationneeded' event if needed
    +  // Once granted, this will fire the 'connectionupgradable' event if needed
       RTCPeerConnection.registerDirectConnectionInterest();
     
       // Now, create the peer-to-peer connection
    @@ -12155,6 +12170,12 @@ 

    Event summary

    A new RTCStatsEvent is dispatched to the script in response to one or more monitored objects being deleted at the same time. + + + connectionupgradable + Event + The [[RTCWEB-IP-HANDLING]] mode for the RTCPeerConnection has been upgraded. The application needs to do an ICE restart if it wants to upgrade its connection to be potentially more direct. +

    The following events fire on RTCDTMFSender