From ab2c4d061c893e268b02ab208a1abae3a745c18b Mon Sep 17 00:00:00 2001 From: Michael Froman Date: Mon, 31 Aug 2020 22:54:29 +0000 Subject: [PATCH] Bug 1654399 - pt1 - webidl changes for RTCDtlsTransport. r=webidl,smaug Partial implementation of RTCDtlsTransport (state and onstatechange) for wfh. Stubbed out methods so everything builds. Differential Revision: https://phabricator.services.mozilla.com/D84459 --- dom/bindings/Bindings.conf | 4 ++ .../mochitest/general/test_interfaces.js | 2 + dom/webidl/RTCDtlsTransport.webidl | 23 ++++++++++ dom/webidl/RTCRtpReceiver.webidl | 1 + dom/webidl/RTCRtpSender.webidl | 1 + dom/webidl/TransceiverImpl.webidl | 2 + dom/webidl/moz.build | 1 + .../src/peerconnection/RTCDtlsTransport.h | 45 +++++++++++++++++++ .../src/peerconnection/RTCRtpReceiver.h | 2 + .../src/peerconnection/TransceiverImpl.h | 2 + 10 files changed, 83 insertions(+) create mode 100644 dom/webidl/RTCDtlsTransport.webidl create mode 100644 media/webrtc/signaling/src/peerconnection/RTCDtlsTransport.h diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 2c2b03b4bd60..642dcafc95a9 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -667,6 +667,10 @@ DOMInterfaces = { 'nativeType': 'nsDOMDataChannel', }, +'RTCDtlsTransport': { + 'headerFile': 'RTCDtlsTransport.h' +}, + 'RTCDTMFSender': { 'headerFile': 'RTCDTMFSender.h' }, diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index afa361ebd87b..a3ec59a4a112 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -979,6 +979,8 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "RTCDataChannelEvent", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "RTCDtlsTransport", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! { name: "RTCDTMFSender", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "RTCDTMFToneChangeEvent", insecureContext: true }, diff --git a/dom/webidl/RTCDtlsTransport.webidl b/dom/webidl/RTCDtlsTransport.webidl new file mode 100644 index 000000000000..0b2f095ab6f7 --- /dev/null +++ b/dom/webidl/RTCDtlsTransport.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * https://w3c.github.io/webrtc-pc/#rtcdtlstransport-interface + */ + +enum RTCDtlsTransportState { + "new", + "connecting", + "connected", + "closed", + "failed" +}; + +[Pref="media.peerconnection.enabled", + Exposed=Window] +interface RTCDtlsTransport : EventTarget { + readonly attribute RTCDtlsTransportState state; + attribute EventHandler onstatechange; +}; diff --git a/dom/webidl/RTCRtpReceiver.webidl b/dom/webidl/RTCRtpReceiver.webidl index df5cd19f24df..16b14e908a3c 100644 --- a/dom/webidl/RTCRtpReceiver.webidl +++ b/dom/webidl/RTCRtpReceiver.webidl @@ -11,6 +11,7 @@ Exposed=Window] interface RTCRtpReceiver { readonly attribute MediaStreamTrack track; + readonly attribute RTCDtlsTransport? transport; Promise getStats(); [Pref="media.peerconnection.rtpsourcesapi.enabled"] sequence getContributingSources(); diff --git a/dom/webidl/RTCRtpSender.webidl b/dom/webidl/RTCRtpSender.webidl index b7daca48facd..99df1f22609a 100644 --- a/dom/webidl/RTCRtpSender.webidl +++ b/dom/webidl/RTCRtpSender.webidl @@ -71,6 +71,7 @@ dictionary RTCRtpParameters { Exposed=Window] interface RTCRtpSender { readonly attribute MediaStreamTrack? track; + readonly attribute RTCDtlsTransport? transport; Promise setParameters (optional RTCRtpParameters parameters = {}); RTCRtpParameters getParameters(); Promise replaceTrack(MediaStreamTrack? withTrack); diff --git a/dom/webidl/TransceiverImpl.webidl b/dom/webidl/TransceiverImpl.webidl index f79524632208..cea0b23e6e80 100644 --- a/dom/webidl/TransceiverImpl.webidl +++ b/dom/webidl/TransceiverImpl.webidl @@ -23,5 +23,7 @@ interface TransceiverImpl { // TODO(bug 1616937): We won't need this once we implement RTCRtpSender in c++ [ChromeOnly] readonly attribute RTCDTMFSender? dtmf; + [ChromeOnly] + readonly attribute RTCDtlsTransport? dtlsTransport; }; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index f7d32cc20e38..13bda95c57ec 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -997,6 +997,7 @@ if CONFIG['MOZ_WEBRTC']: 'RTCCertificate.webidl', 'RTCConfiguration.webidl', 'RTCDataChannel.webidl', + 'RTCDtlsTransport.webidl', 'RTCDTMFSender.webidl', 'RTCIceCandidate.webidl', 'RTCIdentityAssertion.webidl', diff --git a/media/webrtc/signaling/src/peerconnection/RTCDtlsTransport.h b/media/webrtc/signaling/src/peerconnection/RTCDtlsTransport.h new file mode 100644 index 000000000000..1daf9ae97e4d --- /dev/null +++ b/media/webrtc/signaling/src/peerconnection/RTCDtlsTransport.h @@ -0,0 +1,45 @@ +/* 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/. */ + +#ifndef _RTCDtlsTransport_h_ +#define _RTCDtlsTransport_h_ + +#include "mozilla/DOMEventTargetHelper.h" +#include "mozilla/RefPtr.h" +#include "js/RootingAPI.h" +#include "transportlayer.h" + +class nsPIDOMWindowInner; + +namespace mozilla { +namespace dom { + +enum class RTCDtlsTransportState : uint8_t; + +class RTCDtlsTransport : public DOMEventTargetHelper { + public: + explicit RTCDtlsTransport(nsPIDOMWindowInner* aWindow); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RTCDtlsTransport, + DOMEventTargetHelper) + + // webidl + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + IMPL_EVENT_HANDLER(statechange) + RTCDtlsTransportState State() const { return mState; } + + void UpdateState(TransportLayer::State aState); + + private: + virtual ~RTCDtlsTransport() = default; + + RTCDtlsTransportState mState; +}; + +} // namespace dom +} // namespace mozilla +#endif // _RTCDtlsTransport_h_ diff --git a/media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.h b/media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.h index f6b74f1eeaac..a864c627ef92 100644 --- a/media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.h +++ b/media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.h @@ -27,6 +27,7 @@ class JsepTransceiver; namespace dom { class MediaStreamTrack; class Promise; +class RTCDtlsTransport; struct RTCRtpContributingSource; struct RTCRtpSynchronizationSource; @@ -51,6 +52,7 @@ class RTCRtpReceiver : public nsISupports, // webidl MediaStreamTrack* Track() const { return mTrack; } + RTCDtlsTransport* GetTransport() const { return nullptr; } already_AddRefed GetStats(); void GetContributingSources( nsTArray& aSources); diff --git a/media/webrtc/signaling/src/peerconnection/TransceiverImpl.h b/media/webrtc/signaling/src/peerconnection/TransceiverImpl.h index c7ef13b3cd65..a9509209ff37 100644 --- a/media/webrtc/signaling/src/peerconnection/TransceiverImpl.h +++ b/media/webrtc/signaling/src/peerconnection/TransceiverImpl.h @@ -32,6 +32,7 @@ class WebRtcCallWrapper; class JsepTrackNegotiatedDetails; namespace dom { +class RTCDtlsTransport; class RTCDTMFSender; class RTCRtpTransceiver; struct RTCRtpSourceEntry; @@ -95,6 +96,7 @@ class TransceiverImpl : public nsISupports, public nsWrapperCache { void SyncWithJS(dom::RTCRtpTransceiver& aJsTransceiver, ErrorResult& aRv); dom::RTCRtpReceiver* Receiver() const { return mReceiver; } dom::RTCDTMFSender* GetDtmf() const { return mDtmf; } + dom::RTCDtlsTransport* GetDtlsTransport() const { return nullptr; } bool CanSendDTMF() const;