Improvements to RTCPeerConnection’s spec compliance in Firefox 24

You may have noticed that Firefox’s RTCPeerConnection API (the WebRTC API that enables real-time audio/video calls) has changed in Firefox 24.  We made improvements to our spec compliance in Firefox 24 (largely by moving more of our code to use webidl directly).  Hopefully this makes using WebRTC across different browsers easier.  We’ll be making more improvements, both to our API and the implementation underlying it, in future Firefox releases.

The main benefit of the changes in Firefox 24 is that RTCPeerConnection is now an EventTarget, so you can register for notification-events rather than using callbacks.

The notifications themselves are also to spec now (RTCSignalingState, RTCIceGatheringState and RTCIceConnectionState), though the old ones will still work, with warnings (see below).

Also, RTCDataChannel, with its more declarative API, is updated to more closely match the spec. It too is an EventTarget.

Things to watch out for:
– failureCallbacks are no longer optional (as decreed by the spec).
– Inline JS {} in place of new mozRTCIceCandidate() or new mozRTCSessionDescription() no longer works.

PS: Due to Bug 903741, you may have to look in Firefox 24’s new Browser Console (Ctrl(Command)+Shift+J) to see all RTCPeerConnection API errors. This will be addressed in the next version (Firefox 25).

Co-authored with Jan-Ivar Bruaroey, who made all the code improvements discussed in this post.