PeerConnection Error Callback now Mandatory

 Highlights

 Impact on my application

 Standardization status

 Details

 

 Highlights

On March 22nd, 2016 Google released the release notes of Chrome 50 that is available in Beta Channel. There are several important items there to relate to. One of them is related to the support of H.264 (currently behind a flag). While we will not have a dedicated post about this on WebRTCStandards.info as technically it is pretty clear, it does impact the need for transcoding. You can find more about it in this post.

In this and following posts we will relate to some of the topics included in the release notes.

In this post we will talk about the decision to make the Error Callback of PeerConnection createOffer and createAnswer mandatory.

Quoting from the release notes:

For the PeerConnection createOffer and createAnswer methods, we’ve made the error handler argument mandatory. This is part of clearing the way for introducing promise-based versions of these functions

 

 Impact on my application

This impacts Chrome 50 (Beta) and will make its way into the stable channel. It has the capacity to break existing code. For those not using adapter.js and already relying on promise-based APIs, you need to make sure an error callback is passed to the corresponding methods.

 

 Standardization status

The standard is listing the callback version of peerConnection only for backward compatibility and recommend using the new, promise-based, version of the API instead. Users of adapter.js get a shim that implements the promise base version on top of the callback based version of the API already to facilitate writing spec compliant code, independently of the spec compliance status of the browser.

 

 

 Details

The new callback API declare the success and failure callbacks as mandatory (i.e. does not declare them optional)

partial interface RTCPeerConnection {
void createOffer (RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, optional RTCOfferOptions options); 
void createAnswer (RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback); 
};

The goal, and what the applications should aim at supporting through either in house shim or adapter.js by wrapping callbacks in promises, is defined below.

interface RTCPeerConnection : EventTarget {
Promise<RTCSessionDescription> createOffer (optional RTCOfferOptions options); 
Promise<RTCSessionDescription> createAnswer (optional RTCAnswerOptions options); 
}