Bug 798825: Add DataChannel DOM interfaces to RTCPeerConnection; r=smaug
authorAnant Narayanan <anant@kix.in>
Sun, 07 Oct 2012 01:34:30 -0400
changeset 109565 884757053d1d799ad60a2b2b322ac5f2b1fd3e27
parent 109564 86aef70706f94982d178146c7e3851064af9846f
child 109566 1c1cd655dfe5b4426eef73309bb381ac208feea4
push id23632
push userphilringnalda@gmail.com
push dateSun, 07 Oct 2012 19:14:37 +0000
treeherdermozilla-central@83d38854c21e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs798825
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 798825: Add DataChannel DOM interfaces to RTCPeerConnection; r=smaug
dom/media/PeerConnection.js
dom/media/bridge/IPeerConnection.idl
dom/media/nsIDOMRTCPeerConnection.idl
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
netwerk/sctp/datachannel/DataChannel.cpp
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -141,16 +141,21 @@ function PeerConnection() {
 
   // Public attributes.
   this.onaddstream = null;
   this.onremovestream = null;
   this.onicecandidate = null;
   this.onstatechange = null;
   this.ongatheringchange = null;
   this.onicechange = null;
+
+  // Data channel.
+  this.ondatachannel = null;
+  this.onconnection = null;
+  this.onclosedconnection = null;
 }
 PeerConnection.prototype = {
   classID: PC_CID,
 
   classInfo: XPCOMUtils.generateCI({classID: PC_CID,
                                     contractID: PC_CONTRACT,
                                     classDescription: "PeerConnection",
                                     interfaces: [
@@ -392,16 +397,52 @@ PeerConnection.prototype = {
   },
 
   close: function() {
     this._queueOrRun({
       func: this._pc.close,
       args: [],
       wait: false
     });
+  },
+
+  createDataChannel: function(label, dict) {
+    if (dict &&
+        dict.maxRetransmitTime != undefined &&
+        dict.maxRetransmitNum != undefined) {
+      throw new Error("Both maxRetransmitTime and maxRetransmitNum cannot be provided");
+    }
+
+    // Must determine the type where we still know if entries are undefined.
+    let type;
+    if (dict.maxRetransmitTime != undefined) {
+      type = Ci.IPeerConnection.DATACHANNEL_PARTIAL_RELIABLE_TIMED;
+    } else if (dict.maxRetransmitNum != undefined) {
+      type = Ci.IPeerConnection.DATACHANNEL_PARTIAL_RELIABLE_REXMIT;
+    } else {
+      type = Ci.IPeerConnection.DATACHANNEL_RELIABLE;
+    }
+
+    // Synchronous since it doesn't block.
+    let channel = this._pc.createDataChannel(
+      label, type, dict.outOfOrderAllowed, dict.maxRetransmitTime,
+      dict.maxRetransmitNum
+    );
+    return channel;
+  },
+
+  connectDataConnection: function(localport, remoteport, numstreams) {
+    if (numstreams == undefined || numstreams <= 0) {
+      numstreams = 16;
+    }
+    this._queueOrRun({
+      func: this._pc.connectDataConnection,
+      args: [localport, remoteport, numstreams],
+      wait: false
+    });
   }
 };
 
 // This is a seperate object because we don't want to expose it to DOM.
 function PeerConnectionObserver(dompc) {
   this._dompc = dompc;
 }
 PeerConnectionObserver.prototype = {
@@ -562,14 +603,41 @@ PeerConnectionObserver.prototype = {
       try {
         this._dompc.onicecandidate.onCallback({
           candidate: cand,
           __exposedProps__: { candidate: "rw" }
         });
       } catch(e) {}
     }
     this._dompc._executeNext();
+  },
+
+  notifyDataChannel: function(channel) {
+    if (this._dompc.ondatachannel) {
+      try {
+        this._dompc.ondatachannel.onCallback(channel);
+      } catch(e) {}
+    }
+    this._dompc._executeNext();
+  },
+
+  notifyConnection: function() {
+    if (this._dompc.onconnection) {
+      try {
+        this._dompc.onconnection.onCallback();
+      } catch(e) {}
+    }
+    this._dompc._executeNext();
+  },
+
+  notifyClosedConnection: function() {
+    if (this._dompc.onclosedconnection) {
+      try {
+        this._dompc.onclosedconnection.onCallback();
+      } catch(e) {}
+    }
+    this._dompc._executeNext();
   }
 };
 
 let NSGetFactory = XPCOMUtils.generateNSGetFactory(
   [IceCandidate, SessionDescription, PeerConnection]
 );
--- a/dom/media/bridge/IPeerConnection.idl
+++ b/dom/media/bridge/IPeerConnection.idl
@@ -1,20 +1,21 @@
 #include "nsIThread.idl"
 #include "nsIDOMWindow.idl"
 
 interface nsIDOMMediaStream;
+interface nsIDOMDataChannel;
 
 /* Do not confuse with nsIDOMRTCPeerConnection. This interface is purely for
  * communication between the PeerConnection JS DOM binding and the C++
  * implementation in SIPCC.
  *
  * See media/webrtc/signaling/include/PeerConnectionImpl.h
  */
-[scriptable, uuid(84efc76f-41d9-496a-9444-2965d179d419)]
+[scriptable, uuid(e61821ba-7772-4973-b583-1715e4bbaeed)]
 interface IPeerConnectionObserver : nsISupports
 {
   /* Constants */
   const long kReadyState = 0x1;
   const long kIceState = 0x2;
   const long kSdpState = 0x3;
   const long kSipccState = 0x4;
 
@@ -23,16 +24,21 @@ interface IPeerConnectionObserver : nsIS
   void onCreateOfferError(in unsigned long code);
   void onCreateAnswerSuccess(in string answer);
   void onCreateAnswerError(in unsigned long code);
   void onSetLocalDescriptionSuccess(in unsigned long code);
   void onSetRemoteDescriptionSuccess(in unsigned long code);
   void onSetLocalDescriptionError(in unsigned long code);
   void onSetRemoteDescriptionError(in unsigned long code);
 
+  /* Data channel callbacks */
+  void notifyDataChannel(in nsIDOMDataChannel channel);
+  void notifyConnection();
+  void notifyClosedConnection();
+
   /* Notification of one of several types of state changed */
   void onStateChange(in unsigned long state);
 
   /* Changes to MediaStreams */
   void onAddStream(in nsIDOMMediaStream stream, in string type);
   void onRemoveStream();
   void onAddTrack();
   void onRemoveTrack();
@@ -40,17 +46,17 @@ interface IPeerConnectionObserver : nsIS
   /* When SDP is parsed and a candidate line is found this method is called.
    * It should hook back into the media transport to notify it of ICE candidates
    * listed in the SDP PeerConnectionImpl does not parse ICE candidates, just
    * pulls them out of the SDP.
    */
   void foundIceCandidate(in string candidate);
 };
 
-[scriptable, uuid(942366a9-80fe-4cac-ac97-4fbca45bcbff)]
+[scriptable, uuid(cb3f0048-1009-11e2-b822-87ee49eface7)]
 interface IPeerConnection : nsISupports
 {
   const unsigned long kHintAudio = 0x00000001;
   const unsigned long kHintVideo = 0x00000002;
 
   const long kActionNone = -1;
   const long kActionOffer = 0;
   const long kActionAnswer = 1;
@@ -89,9 +95,16 @@ interface IPeerConnection : nsISupports
 
   /* Attributes */
   readonly attribute string localDescription;
   readonly attribute string remoteDescription;
 
   readonly attribute unsigned long iceState;
   readonly attribute unsigned long readyState;
   readonly attribute unsigned long sipccState;
+
+  /* Data channels */
+  nsIDOMDataChannel createDataChannel(in ACString label,
+    in unsigned short type, in boolean outOfOrderAllowed,
+    in unsigned short maxTime, in unsigned short maxNum);
+  void connectDataConnection(in unsigned short localport,
+    in unsigned short remoteport, in unsigned short numstreams);
 };
--- a/dom/media/nsIDOMRTCPeerConnection.idl
+++ b/dom/media/nsIDOMRTCPeerConnection.idl
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIDOMMediaStream.idl"
 
+interface nsIDOMDataChannel;
+
 [scriptable, function, uuid(eb9c563c-3b09-4565-9317-eca96ae0c538)]
 interface RTCPeerConnectionCallback : nsISupports
 {
   void onCallback(in jsval value);
 };
 
 [scriptable, function, uuid(55546efd-287b-4460-8283-0592875b890f)]
 interface RTCPeerConnectionCallbackVoid : nsISupports
@@ -28,17 +30,17 @@ interface nsIDOMRTCSessionDescription : 
 interface nsIDOMRTCIceCandidate : nsISupports
 {
   attribute DOMString candidate;
   attribute DOMString sdpMid;
   attribute unsigned short sdpMLineIndex;
 };
 
 /* See http://dev.w3.org/2011/webrtc/editor/webrtc.html */
-[scriptable, uuid(94628e70-e96f-4170-871c-f993a49f065a)]
+[scriptable, uuid(807b9b54-25a1-421e-9133-27ae6efcfcfd)]
 interface nsIDOMRTCPeerConnection : nsISupports
 {
   void createOffer(in RTCPeerConnectionCallback successCallback,
     [optional] in RTCPeerConnectionCallback failureCallback,
     [optional] in jsval constraints);
 
   void createAnswer(in nsIDOMRTCSessionDescription offer,
     in RTCPeerConnectionCallback successCallback,
@@ -79,9 +81,18 @@ interface nsIDOMRTCPeerConnection : nsIS
 
   /* Event handlers. TODO: Use real EventTarget */
   attribute RTCPeerConnectionCallback onaddstream;
   attribute RTCPeerConnectionCallback onremovestream;
   attribute RTCPeerConnectionCallback onicecandidate;
   attribute RTCPeerConnectionCallback onstatechange;
   attribute RTCPeerConnectionCallback ongatheringchange;
   attribute RTCPeerConnectionCallback onicechange;
+
+  /* Data channels */
+  nsIDOMDataChannel createDataChannel([optional] in ACString label,
+    [optional] in jsval options);
+  void connectDataConnection(in unsigned short localport,
+    in unsigned short remoteport, [optional] in unsigned short numstreams);
+  attribute RTCPeerConnectionCallback ondatachannel;
+  attribute RTCPeerConnectionCallbackVoid onconnection;
+  attribute RTCPeerConnectionCallbackVoid onclosedconnection;
 };
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -61,31 +61,31 @@ typedef enum {
   PC_OBSERVER_ICE,
   PC_OBSERVER_READYSTATE
 } PeerConnectionObserverType;
 
 // TODO: Refactor this.
 class PeerConnectionObserverDispatch : public nsRunnable {
 
 public:
-  PeerConnectionObserverDispatch(CSF::CC_CallInfoPtr info,
-                                 nsRefPtr<PeerConnectionImpl> pc,
-                                 IPeerConnectionObserver* observer) :
-    mType(PC_OBSERVER_CALLBACK), mInfo(info), mChannel(nullptr), mPC(pc), mObserver(observer) {}
+  PeerConnectionObserverDispatch(CSF::CC_CallInfoPtr aInfo,
+                                 nsRefPtr<PeerConnectionImpl> aPC,
+                                 IPeerConnectionObserver* aObserver) :
+    mType(PC_OBSERVER_CALLBACK), mInfo(aInfo), mChannel(nullptr), mPC(aPC), mObserver(aObserver) {}
 
-  PeerConnectionObserverDispatch(PeerConnectionObserverType type,
-                                 nsRefPtr<nsIDOMDataChannel> channel,
-                                 nsRefPtr<PeerConnectionImpl> pc,
-                                 IPeerConnectionObserver* observer) :
-    mType(type), mInfo(nullptr), mChannel(channel), mPC(pc), mObserver(observer) {}
+  PeerConnectionObserverDispatch(PeerConnectionObserverType aType,
+                                 nsRefPtr<nsIDOMDataChannel> aChannel,
+                                 nsRefPtr<PeerConnectionImpl> aPC,
+                                 IPeerConnectionObserver* aObserver) :
+    mType(aType), mInfo(nullptr), mChannel(aChannel), mPC(aPC), mObserver(aObserver) {}
 
-  PeerConnectionObserverDispatch(PeerConnectionObserverType type,
-                                 nsRefPtr<PeerConnectionImpl> pc,
-                                 IPeerConnectionObserver* observer) :
-    mType(type), mInfo(nullptr), mPC(pc), mObserver(observer) {}
+  PeerConnectionObserverDispatch(PeerConnectionObserverType aType,
+                                 nsRefPtr<PeerConnectionImpl> aPC,
+                                 IPeerConnectionObserver* aObserver) :
+    mType(aType), mInfo(nullptr), mPC(aPC), mObserver(aObserver) {}
 
   ~PeerConnectionObserverDispatch(){}
 
   NS_IMETHOD Run()
   {
     switch (mType) {
       case PC_OBSERVER_CALLBACK:
         {
@@ -168,25 +168,25 @@ public:
             default:
               CSFLogDebugS(logTag, ": **** UNHANDLED CALL STATE : " << statestr);
               break;
           }
           break;
         }
       case PC_OBSERVER_CONNECTION:
         CSFLogDebugS(logTag, __FUNCTION__ << ": Delivering PeerConnection onconnection");
-        //mObserver->NotifyConnection();
+        mObserver->NotifyConnection();
         break;
       case PC_OBSERVER_CLOSEDCONNECTION:
         CSFLogDebugS(logTag, __FUNCTION__ << ": Delivering PeerConnection onclosedconnection");
-        //mObserver->NotifyClosedConnection();
+        mObserver->NotifyClosedConnection();
         break;
       case PC_OBSERVER_DATACHANNEL:
         CSFLogDebugS(logTag, __FUNCTION__ << ": Delivering PeerConnection ondatachannel");
-        //mObserver->NotifyDataChannel(mChannel);
+        mObserver->NotifyDataChannel(mChannel);
 #ifdef MOZILLA_INTERNAL_API
         NS_DataChannelAppReady(mChannel);
 #endif
         break;
       case PC_OBSERVER_ICE:
         CSFLogDebugS(logTag, __FUNCTION__ << ": Delivering PeerConnection ICE callback ");
         mObserver->OnStateChange(IPeerConnectionObserver::kIceState);
         break;
@@ -357,32 +357,32 @@ PeerConnectionImpl::CreateRemoteSourceSt
   if (NS_FAILED(res)) {
     return res;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::Initialize(IPeerConnectionObserver* observer,
+PeerConnectionImpl::Initialize(IPeerConnectionObserver* aObserver,
                                nsIDOMWindow* aWindow,
-                               nsIThread* thread) {
-  MOZ_ASSERT(observer);
-  mPCObserver = observer;
+                               nsIThread* aThread) {
+  MOZ_ASSERT(aObserver);
+  mPCObserver = aObserver;
 
 #ifdef MOZILLA_INTERNAL_API
   // Currently no standalone unit tests for DataChannel,
   // which is the user of mWindow
   MOZ_ASSERT(aWindow);
   mWindow = do_QueryInterface(aWindow);
   NS_ENSURE_STATE(mWindow);
 #endif
 
   // The thread parameter can be passed in as NULL
-  mThread = thread;
+  mThread = aThread;
 
   PeerConnectionCtx *pcctx = PeerConnectionCtx::GetInstance();
   MOZ_ASSERT(pcctx);
 
   mCall = pcctx->createCall();
   if(!mCall.get()) {
     CSFLogErrorS(logTag, __FUNCTION__ << ": Couldn't Create Call Object");
     return NS_ERROR_FAILURE;
@@ -504,54 +504,115 @@ PeerConnectionImpl::Initialize(IPeerConn
     PR_Sleep(100);
   }
 #endif
 
   return NS_OK;
 }
 
 nsresult
-PeerConnectionImpl::CreateFakeMediaStream(PRUint32 hint, nsIDOMMediaStream** retval)
+PeerConnectionImpl::CreateFakeMediaStream(PRUint32 aHint, nsIDOMMediaStream** aRetval)
 {
-  MOZ_ASSERT(retval);
+  MOZ_ASSERT(aRetval);
 
   bool mute = false;
 
   // Hack to allow you to mute the stream
-  if (hint & MEDIA_STREAM_MUTE) {
+  if (aHint & MEDIA_STREAM_MUTE) {
     mute = true;
-    hint &= ~MEDIA_STREAM_MUTE;
+    aHint &= ~MEDIA_STREAM_MUTE;
   }
 
   nsresult res;
   if (!mThread || NS_IsMainThread()) {
-    res = MakeMediaStream(hint, retval);
+    res = MakeMediaStream(aHint, aRetval);
   } else {
     mThread->Dispatch(WrapRunnableRet(
-      this, &PeerConnectionImpl::MakeMediaStream, hint, retval, &res
+      this, &PeerConnectionImpl::MakeMediaStream, aHint, aRetval, &res
     ), NS_DISPATCH_SYNC);
   }
 
   if (NS_FAILED(res)) {
     return res;
   }
 
   if (!mute) {
-    if (hint & nsDOMMediaStream::HINT_CONTENTS_AUDIO) {
-      new Fake_AudioGenerator(static_cast<nsDOMMediaStream*>(*retval));
+    if (aHint & nsDOMMediaStream::HINT_CONTENTS_AUDIO) {
+      new Fake_AudioGenerator(static_cast<nsDOMMediaStream*>(*aRetval));
     } else {
 #ifdef MOZILLA_INTERNAL_API
-    new Fake_VideoGenerator(static_cast<nsDOMMediaStream*>(*retval));
+    new Fake_VideoGenerator(static_cast<nsDOMMediaStream*>(*aRetval));
 #endif
     }
   }
 
   return NS_OK;
 }
 
+// Data channels won't work without a window, so in order for the C++ unit
+// tests to work (it doesn't have a window available) we ifdef the following
+// two implementations.
+NS_IMETHODIMP
+PeerConnectionImpl::ConnectDataConnection(PRUint16 aLocalport,
+                                          PRUint16 aRemoteport,
+                                          PRUint16 aNumstreams)
+{
+#ifdef MOZILLA_INTERNAL_API
+  mDataConnection = new mozilla::DataChannelConnection(this);
+  NS_ENSURE_TRUE(mDataConnection,NS_ERROR_FAILURE);
+  if (!mDataConnection->Init(aLocalport, aNumstreams, true)) {
+    CSFLogError(logTag,"%s DataConnection Init Failed",__FUNCTION__);
+    return NS_ERROR_FAILURE;
+  }
+  // XXX Fix! Get the correct flow for DataChannel. Also error handling.
+  nsRefPtr<TransportFlow> flow = GetTransportFlow(1,false).get();
+  CSFLogDebugS(logTag, "Transportflow[1] = " << flow.get());
+  if (!mDataConnection->ConnectDTLS(flow, aLocalport, aRemoteport)) {
+    return NS_ERROR_FAILURE;
+  }
+  return NS_OK;
+#else
+    return NS_ERROR_FAILURE;
+#endif
+}
+
+NS_IMETHODIMP
+PeerConnectionImpl::CreateDataChannel(const nsACString& aLabel,
+                                      PRUint16 aType,
+                                      bool outOfOrderAllowed,
+                                      PRUint16 aMaxTime,
+                                      PRUint16 aMaxNum,
+                                      nsIDOMDataChannel** aRetval)
+{
+  MOZ_ASSERT(aRetval);
+
+#ifdef MOZILLA_INTERNAL_API
+  mozilla::DataChannel* dataChannel;
+  mozilla::DataChannelConnection::Type theType =
+    static_cast<mozilla::DataChannelConnection::Type>(aType);
+
+  if (!mDataConnection) {
+    return NS_ERROR_FAILURE;
+  }
+  dataChannel = mDataConnection->Open(
+    aLabel, theType, !outOfOrderAllowed,
+    aType == mozilla::DataChannelConnection::PARTIAL_RELIABLE_REXMIT ? aMaxNum :
+    (aType == mozilla::DataChannelConnection::PARTIAL_RELIABLE_TIMED ? aMaxTime : 0),
+    nullptr, nullptr
+  );
+  NS_ENSURE_TRUE(dataChannel,NS_ERROR_FAILURE);
+
+  CSFLogDebugS(logTag, __FUNCTION__ << ": making DOMDataChannel");
+
+  return NS_NewDOMDataChannel(dataChannel, mWindow, aRetval);
+#else
+  return NS_OK;
+#endif
+}
+
 void
 PeerConnectionImpl::NotifyConnection()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   CSFLogDebugS(logTag, __FUNCTION__);
 
 #ifdef MOZILLA_INTERNAL_API
@@ -614,52 +675,52 @@ PeerConnectionImpl::NotifyDataChannel(mo
   }
 #endif
 }
 
 /*
  * CC_SDP_DIRECTION_SENDRECV will not be used when Constraints are implemented
  */
 NS_IMETHODIMP
-PeerConnectionImpl::CreateOffer(const char* hints) {
-  MOZ_ASSERT(hints);
+PeerConnectionImpl::CreateOffer(const char* aHints) {
+  MOZ_ASSERT(aHints);
 
   CheckIceState();
   mRole = kRoleOfferer;  // TODO(ekr@rtfm.com): Interrogate SIPCC here?
-  mCall->createOffer(hints);
+  mCall->createOffer(aHints);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::CreateAnswer(const char* hints, const char* offer) {
-  MOZ_ASSERT(hints);
-  MOZ_ASSERT(offer);
+PeerConnectionImpl::CreateAnswer(const char* aHints, const char* aOffer) {
+  MOZ_ASSERT(aHints);
+  MOZ_ASSERT(aOffer);
 
   CheckIceState();
   mRole = kRoleAnswerer;  // TODO(ekr@rtfm.com): Interrogate SIPCC here?
-  mCall->createAnswer(hints, offer);
+  mCall->createAnswer(aHints, aOffer);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::SetLocalDescription(PRInt32 action, const char* sdp) {
-  MOZ_ASSERT(sdp);
+PeerConnectionImpl::SetLocalDescription(PRInt32 aAction, const char* aSDP) {
+  MOZ_ASSERT(aSDP);
 
   CheckIceState();
-  mLocalRequestedSDP = sdp;
-  mCall->setLocalDescription((cc_jsep_action_t)action, mLocalRequestedSDP);
+  mLocalRequestedSDP = aSDP;
+  mCall->setLocalDescription((cc_jsep_action_t)aAction, mLocalRequestedSDP);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::SetRemoteDescription(PRInt32 action, const char* sdp) {
-  MOZ_ASSERT(sdp);
+PeerConnectionImpl::SetRemoteDescription(PRInt32 action, const char* aSDP) {
+  MOZ_ASSERT(aSDP);
 
   CheckIceState();
-  mRemoteRequestedSDP = sdp;
+  mRemoteRequestedSDP = aSDP;
   mCall->setRemoteDescription((cc_jsep_action_t)action, mRemoteRequestedSDP);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::AddStream(nsIDOMMediaStream* aMediaStream)
 {
   MOZ_ASSERT(aMediaStream);
@@ -748,19 +809,19 @@ PeerConnectionImpl::RemoveStream(nsIDOMM
     }
   }
 
   PR_Unlock(mLocalSourceStreamsLock);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::AddIceCandidate(const char* candidate, const char* mid, unsigned short level) {
+PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) {
   CheckIceState();
-  mCall->addICECandidate(candidate, mid, level);
+  mCall->addICECandidate(aCandidate, aMid, aLevel);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::CloseStreams() {
   if (mReadyState != PeerConnectionImpl::kClosed)  {
     ChangeReadyState(PeerConnectionImpl::kClosing);
   }
@@ -800,66 +861,66 @@ PeerConnectionImpl::GetFingerprint(char*
   tmp[mFingerprint.size()] = '\0';
 
   *fingerprint = tmp;
   return NS_OK;
 }
 */
 
 NS_IMETHODIMP
-PeerConnectionImpl::GetLocalDescription(char** sdp)
+PeerConnectionImpl::GetLocalDescription(char** aSDP)
 {
-  MOZ_ASSERT(sdp);
+  MOZ_ASSERT(aSDP);
 
   char* tmp = new char[mLocalSDP.size() + 1];
   std::copy(mLocalSDP.begin(), mLocalSDP.end(), tmp);
   tmp[mLocalSDP.size()] = '\0';
 
-  *sdp = tmp;
+  *aSDP = tmp;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::GetRemoteDescription(char** sdp)
+PeerConnectionImpl::GetRemoteDescription(char** aSDP)
 {
-  MOZ_ASSERT(sdp);
+  MOZ_ASSERT(aSDP);
 
   char* tmp = new char[mRemoteSDP.size() + 1];
   std::copy(mRemoteSDP.begin(), mRemoteSDP.end(), tmp);
   tmp[mRemoteSDP.size()] = '\0';
 
-  *sdp = tmp;
+  *aSDP = tmp;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::GetReadyState(PRUint32* state)
+PeerConnectionImpl::GetReadyState(PRUint32* aState)
 {
-  MOZ_ASSERT(state);
+  MOZ_ASSERT(aState);
 
-  *state = mReadyState;
+  *aState = mReadyState;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::GetSipccState(PRUint32* state)
+PeerConnectionImpl::GetSipccState(PRUint32* aState)
 {
-  MOZ_ASSERT(state);
+  MOZ_ASSERT(aState);
 
   PeerConnectionCtx* pcctx = PeerConnectionCtx::GetInstance();
-  *state = pcctx ? pcctx->sipcc_state() : kIdle;
+  *aState = pcctx ? pcctx->sipcc_state() : kIdle;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PeerConnectionImpl::GetIceState(PRUint32* state)
+PeerConnectionImpl::GetIceState(PRUint32* aState)
 {
-  MOZ_ASSERT(state);
+  MOZ_ASSERT(aState);
 
-  *state = mIceState;
+  *aState = mIceState;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PeerConnectionImpl::Close()
 {
   if (mCall != NULL)
     mCall->endCall();
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -1173,17 +1173,17 @@ DataChannelConnection::HandleAssociation
     break;
   default:
     LOG(("Association change: UNKNOWN"));
     break;
   }
   LOG(("Association change: streams (in/out) = (%u/%u)",
        sac->sac_inbound_streams, sac->sac_outbound_streams));
 
-  NS_ENSURE_TRUE(sizeof(*sac) >= sac->sac_length, /* */);
+  NS_ENSURE_TRUE_VOID(sac);
   n = sac->sac_length - sizeof(*sac);
   if (((sac->sac_state == SCTP_COMM_UP) ||
         (sac->sac_state == SCTP_RESTART)) && (n > 0)) {
     for (i = 0; i < n; ++i) {
       switch (sac->sac_info[i]) {
       case SCTP_ASSOC_SUPPORTS_PR:
         LOG(("Supports: PR"));
         break;