Diff
Modified: trunk/LayoutTests/ChangeLog (208693 => 208694)
--- trunk/LayoutTests/ChangeLog 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/LayoutTests/ChangeLog 2016-11-14 18:52:09 UTC (rev 208694)
@@ -1,3 +1,14 @@
+2016-11-14 Youenn Fablet <you...@apple.com>
+
+ Refresh RTCDataChannel abstract infrastructure
+ https://bugs.webkit.org/show_bug.cgi?id=164680
+
+ Reviewed by Darin Adler.
+
+ * fast/mediastream/RTCPeerConnection-datachannel-expected.txt:
+ * fast/mediastream/RTCPeerConnection-datachannel.html:
+ * platform/mac/TestExpectations:
+
2016-11-14 David Kilzer <ddkil...@apple.com>
REGRESSION (r83521): Fix malformed <canvas> tag in fast/canvas/DrawImageSinglePixelStretch.html
Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel-expected.txt (208693 => 208694)
--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel-expected.txt 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel-expected.txt 2016-11-14 18:52:09 UTC (rev 208694)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS dc = pc.createDataChannel("label", {maxRetransmitTime:0, maxRetransmits:0}); threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
+FAIL dc = pc.createDataChannel("label", {maxRetransmitTime:0, maxRetransmits:0}); should throw an exception. Was [object RTCDataChannel].
PASS dc = pc.createDataChannel("label1"); did not throw exception.
PASS dc = pc.createDataChannel("label2", {}); did not throw exception.
PASS dc = pc.createDataChannel("label3", {ordered:true}); did not throw exception.
@@ -10,28 +10,7 @@
PASS dc = pc.createDataChannel("label3", {ordered:false}); did not throw exception.
PASS dc = pc.createDataChannel("label3", {maxRetransmits:0}); did not throw exception.
PASS dc = pc.createDataChannel("label3", {maxRetransmitTime:0}); did not throw exception.
-PASS pc is connected
-PASS dc = pc.createDataChannel("label"); did not throw exception.
-PASS dc.readyState is 'connecting'
-PASS pc_ondatachannel was called
-PASS dc_onopen was called
-PASS dc.readyState is 'open'
-PASS dc.label is 'label'
-PASS dc.send('xyzzy'); did not throw exception.
-PASS dc_onmessage_string was called
-PASS data is 'xyzzy'
-PASS dc.send(buffer); did not throw exception.
-PASS dc_onmessage_arraybuffer was called
-PASS data.byteLength is 2
-PASS array[0] is 17
-PASS array[1] is 19
-PASS dc.send(array); did not throw exception.
-PASS dc_onmessage_arraybufferview was called
-PASS data.byteLength is 2
-PASS array[0] is 11
-PASS array[1] is 13
-PASS dc_onclose was called
-PASS dc.readyState is 'closed'
+FAIL Test timed out
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel.html (208693 => 208694)
--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel.html 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel.html 2016-11-14 18:52:09 UTC (rev 208694)
@@ -99,6 +99,11 @@
window.jsTestIsAsync = true;
window.successfullyParsed = true;
+
+ setTimeout(function() {
+ testFailed("Test timed out");
+ finishJSTest();
+ }, 2000);
</script>
<script src=""
</body>
Modified: trunk/LayoutTests/platform/mac/TestExpectations (208693 => 208694)
--- trunk/LayoutTests/platform/mac/TestExpectations 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2016-11-14 18:52:09 UTC (rev 208694)
@@ -165,7 +165,6 @@
# WebRTC is not supported yet.
fast/events/constructors/media-stream-event-constructor.html
-fast/mediastream/RTCPeerConnection-datachannel.html [ Skip ]
fast/mediastream/RTCPeerConnection-dtmf.html [ Skip ]
fast/mediastream/RTCPeerConnection-events.html [ Skip ]
fast/mediastream/RTCPeerConnection-ice.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (208693 => 208694)
--- trunk/Source/WebCore/ChangeLog 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/ChangeLog 2016-11-14 18:52:09 UTC (rev 208694)
@@ -1,3 +1,60 @@
+2016-11-14 Youenn Fablet <you...@apple.com>
+
+ Refresh RTCDataChannel abstract infrastructure
+ https://bugs.webkit.org/show_bug.cgi?id=164680
+
+ Reviewed by Darin Adler.
+
+ No real changes, except that a mock data channel is now returned for layout test.
+ Covered by activated and rebased test.
+
+ Adding support for mock data channel.
+ Updating data channel creation by using dictionary binding infrastructure.
+ Storing of options directly in RTCDataChannel to reduce the use of the data channel handler.
+
+ * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+ (WebCore::MediaEndpointPeerConnection::createDataChannelHandler):
+ * Modules/mediastream/MediaEndpointPeerConnection.h:
+ * Modules/mediastream/PeerConnectionBackend.h:
+ * Modules/mediastream/RTCDataChannel.cpp:
+ (WebCore::RTCDataChannel::create):
+ (WebCore::RTCDataChannel::RTCDataChannel):
+ (WebCore::RTCDataChannel::bufferedAmount):
+ (WebCore::RTCDataChannel::~RTCDataChannel): Deleted.
+ (WebCore::RTCDataChannel::label): Deleted.
+ (WebCore::RTCDataChannel::ordered): Deleted.
+ (WebCore::RTCDataChannel::maxRetransmitTime): Deleted.
+ (WebCore::RTCDataChannel::maxRetransmits): Deleted.
+ (WebCore::RTCDataChannel::protocol): Deleted.
+ (WebCore::RTCDataChannel::negotiated): Deleted.
+ (WebCore::RTCDataChannel::id): Deleted.
+ * Modules/mediastream/RTCDataChannel.h:
+ * Modules/mediastream/RTCDataChannelEvent.cpp:
+ (WebCore::RTCDataChannelEvent::create):
+ (WebCore::RTCDataChannelEvent::RTCDataChannelEvent):
+ (WebCore::RTCDataChannelEvent::~RTCDataChannelEvent): Deleted.
+ * Modules/mediastream/RTCDataChannelEvent.h:
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::createDataChannel):
+ * Modules/mediastream/RTCPeerConnection.h:
+ * Modules/mediastream/RTCPeerConnection.idl:
+ * platform/mediastream/MediaEndpoint.cpp:
+ (WebCore::EmptyMediaEndpoint::EmptyMediaEndpoint): Deleted.
+ * platform/mediastream/MediaEndpoint.h:
+ * platform/mediastream/RTCDataChannelHandler.h:
+ * platform/mediastream/RTCDataChannelHandlerClient.h:
+ * platform/mediastream/RTCPeerConnectionHandler.h:
+ (WebCore::RTCDataChannelInit::RTCDataChannelInit): Deleted.
+ * platform/mediastream/openwebrtc/MediaEndpointOwr.cpp:
+ (WebCore::MediaEndpointOwr::createDataChannelHandler):
+ * platform/mediastream/openwebrtc/MediaEndpointOwr.h:
+ * platform/mock/MockMediaEndpoint.cpp:
+ (WebCore::MockMediaEndpoint::createDataChannelHandler):
+ * platform/mock/MockMediaEndpoint.h:
+ * platform/mock/RTCDataChannelHandlerMock.cpp:
+ (WebCore::RTCDataChannelHandlerMock::RTCDataChannelHandlerMock):
+ * platform/mock/RTCDataChannelHandlerMock.h:
+
2016-11-14 David Kilzer <ddkil...@apple.com>
Bug 164702: WebContent crash due to checked unsigned overflow in WebCore: WebCore::RenderLayerCompositor::requiresCompositingLayer const + 1104
Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -705,6 +705,11 @@
return RTCRtpReceiver::create(WTFMove(remoteTrack));
}
+std::unique_ptr<RTCDataChannelHandler> MediaEndpointPeerConnection::createDataChannelHandler(const String& label, const RTCDataChannelInit& options)
+{
+ return m_mediaEndpoint->createDataChannelHandler(label, options);
+}
+
void MediaEndpointPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise&& promise)
{
RTCRtpTransceiver* transceiver = matchTransceiver(m_peerConnection.getTransceivers(), [&sender] (RTCRtpTransceiver& current) {
Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -111,6 +111,8 @@
void doneGatheringCandidates(const String& mid) override;
void iceTransportStateChanged(const String& mid, MediaEndpoint::IceTransportState) override;
+ std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final;
+
std::unique_ptr<MediaEndpoint> m_mediaEndpoint;
Function<void ()> m_initialDeferredTask;
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -34,6 +34,7 @@
#include "JSDOMPromise.h"
#include "PeerConnectionStates.h"
+#include "RTCDataChannel.h"
namespace WebCore {
@@ -43,6 +44,7 @@
class MediaStreamTrack;
class PeerConnectionBackend;
class RTCConfiguration;
+class RTCDataChannelHandler;
class RTCIceCandidate;
class RTCPeerConnection;
class RTCRtpReceiver;
@@ -77,6 +79,8 @@
void setRemoteDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&);
void addIceCandidate(RTCIceCandidate&, PeerConnection::VoidPromise&&);
+ virtual std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) = 0;
+
void stop();
virtual RefPtr<RTCSessionDescription> localDescription() const = 0;
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -54,85 +54,22 @@
return arraybuffer;
}
-ExceptionOr<Ref<RTCDataChannel>> RTCDataChannel::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, const String& label, const Dictionary& options)
+Ref<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
{
- RTCDataChannelInit initData;
- String maxRetransmitsStr;
- String maxRetransmitTimeStr;
- options.get("ordered", initData.ordered);
- options.get("negotiated", initData.negotiated);
- options.get("id", initData.id);
- options.get("maxRetransmits", maxRetransmitsStr);
- options.get("maxRetransmitTime", maxRetransmitTimeStr);
- options.get("protocol", initData.protocol);
-
- bool maxRetransmitsConversion;
- bool maxRetransmitTimeConversion;
- initData.maxRetransmits = maxRetransmitsStr.toUIntStrict(&maxRetransmitsConversion);
- initData.maxRetransmitTime = maxRetransmitTimeStr.toUIntStrict(&maxRetransmitTimeConversion);
- if (maxRetransmitsConversion && maxRetransmitTimeConversion)
- return Exception { SYNTAX_ERR };
-
- auto handler = peerConnectionHandler->createDataChannel(label, initData);
- if (!handler)
- return Exception { NOT_SUPPORTED_ERR };
-
- return adoptRef(*new RTCDataChannel(*context, WTFMove(handler)));
-}
-
-Ref<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* context, std::unique_ptr<RTCDataChannelHandler>&& handler)
-{
ASSERT(handler);
- return adoptRef(*new RTCDataChannel(*context, WTFMove(handler)));
+ return adoptRef(*new RTCDataChannel(context, WTFMove(handler), WTFMove(label), WTFMove(options)));
}
-RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler)
+RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
: m_scriptExecutionContext(&context)
, m_handler(WTFMove(handler))
, m_scheduledEventTimer(*this, &RTCDataChannel::scheduledEventTimerFired)
+ , m_label(WTFMove(label))
+ , m_options(WTFMove(options))
{
m_handler->setClient(this);
}
-RTCDataChannel::~RTCDataChannel()
-{
-}
-
-String RTCDataChannel::label() const
-{
- return m_handler->label();
-}
-
-bool RTCDataChannel::ordered() const
-{
- return m_handler->ordered();
-}
-
-unsigned short RTCDataChannel::maxRetransmitTime() const
-{
- return m_handler->maxRetransmitTime();
-}
-
-unsigned short RTCDataChannel::maxRetransmits() const
-{
- return m_handler->maxRetransmits();
-}
-
-String RTCDataChannel::protocol() const
-{
- return m_handler->protocol();
-}
-
-bool RTCDataChannel::negotiated() const
-{
- return m_handler->negotiated();
-}
-
-unsigned short RTCDataChannel::id() const
-{
- return m_handler->id();
-}
-
const AtomicString& RTCDataChannel::readyState() const
{
static NeverDestroyed<AtomicString> connectingState("connecting", AtomicString::ConstructFromLiteral);
@@ -157,7 +94,7 @@
unsigned RTCDataChannel::bufferedAmount() const
{
- return m_handler->bufferedAmount();
+ return 0;
}
const AtomicString& RTCDataChannel::binaryType() const
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -26,8 +26,10 @@
#if ENABLE(WEB_RTC)
+#include "Event.h"
#include "EventTarget.h"
#include "ExceptionOr.h"
+#include "RTCDataChannelHandler.h"
#include "RTCDataChannelHandlerClient.h"
#include "ScriptWrappable.h"
#include "Timer.h"
@@ -41,22 +43,20 @@
class Blob;
class Dictionary;
-class RTCDataChannelHandler;
class RTCPeerConnectionHandler;
class RTCDataChannel final : public RefCounted<RTCDataChannel>, public EventTargetWithInlineData, public RTCDataChannelHandlerClient {
public:
- static Ref<RTCDataChannel> create(ScriptExecutionContext*, std::unique_ptr<RTCDataChannelHandler>&&);
- static ExceptionOr<Ref<RTCDataChannel>> create(ScriptExecutionContext*, RTCPeerConnectionHandler*, const String& label, const Dictionary& options);
- ~RTCDataChannel();
+ static Ref<RTCDataChannel> create(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
- String label() const;
- bool ordered() const;
- unsigned short maxRetransmitTime() const;
- unsigned short maxRetransmits() const;
- String protocol() const;
- bool negotiated() const;
- unsigned short id() const;
+ bool ordered() const { return m_options.ordered; }
+ unsigned short maxRetransmitTime() const { return m_options.maxRetransmitTime; }
+ unsigned short maxRetransmits() const { return m_options.maxRetransmits; }
+ String protocol() const { return m_options.protocol; }
+ bool negotiated() const { return m_options.negotiated; };
+ unsigned short id() const { return m_options.id; };
+
+ String label() const { return m_label; }
const AtomicString& readyState() const;
unsigned bufferedAmount() const;
@@ -76,7 +76,7 @@
using RefCounted::deref;
private:
- RTCDataChannel(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&);
+ RTCDataChannel(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
void scheduleDispatchEvent(Ref<Event>&&);
void scheduledEventTimerFired();
@@ -93,6 +93,8 @@
void didReceiveStringData(const String&) final;
void didReceiveRawData(const char*, size_t) final;
void didDetectError() final;
+ void protect() final { ref(); }
+ void unprotect() final { deref(); }
std::unique_ptr<RTCDataChannelHandler> m_handler;
@@ -105,6 +107,9 @@
Timer m_scheduledEventTimer;
Vector<Ref<Event>> m_scheduledEvents;
+
+ String m_label;
+ RTCDataChannelInit m_options;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -32,21 +32,17 @@
namespace WebCore {
-Ref<RTCDataChannelEvent> RTCDataChannelEvent::create(const AtomicString& type, bool canBubble, bool cancelable, RTCDataChannel& channel)
+Ref<RTCDataChannelEvent> RTCDataChannelEvent::create(const AtomicString& type, bool canBubble, bool cancelable, Ref<RTCDataChannel>&& channel)
{
- return adoptRef(*new RTCDataChannelEvent(type, canBubble, cancelable, channel));
+ return adoptRef(*new RTCDataChannelEvent(type, canBubble, cancelable, WTFMove(channel)));
}
-RTCDataChannelEvent::RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, RTCDataChannel& channel)
+RTCDataChannelEvent::RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, Ref<RTCDataChannel>&& channel)
: Event(type, canBubble, cancelable)
- , m_channel(channel)
+ , m_channel(WTFMove(channel))
{
}
-RTCDataChannelEvent::~RTCDataChannelEvent()
-{
-}
-
RTCDataChannel* RTCDataChannelEvent::channel()
{
return m_channel.ptr();
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -34,16 +34,14 @@
class RTCDataChannelEvent : public Event {
public:
- virtual ~RTCDataChannelEvent();
+ static Ref<RTCDataChannelEvent> create(const AtomicString& type, bool canBubble, bool cancelable, Ref<RTCDataChannel>&&);
- static Ref<RTCDataChannelEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RTCDataChannel&);
-
RTCDataChannel* channel();
virtual EventInterface eventInterface() const;
private:
- RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, RTCDataChannel&);
+ RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, Ref<RTCDataChannel>&&);
Ref<RTCDataChannel> m_channel;
};
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -374,12 +374,17 @@
m_backend->getStats(selector, WTFMove(promise));
}
-ExceptionOr<RefPtr<RTCDataChannel>> RTCPeerConnection::createDataChannel(const String&, const Dictionary&)
+ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(ScriptExecutionContext& context, String&& label, RTCDataChannelInit&& options)
{
if (m_signalingState == SignalingState::Closed)
return Exception { INVALID_STATE_ERR };
- return nullptr;
+ // FIXME: Check options
+ auto channelHandler = m_backend->createDataChannelHandler(label, options);
+ if (!channelHandler)
+ return Exception { NOT_SUPPORTED_ERR };
+
+ return RTCDataChannel::create(context, WTFMove(channelHandler), WTFMove(label), WTFMove(options));
}
void RTCPeerConnection::close()
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -38,6 +38,7 @@
#include "Dictionary.h"
#include "EventTarget.h"
#include "MediaStream.h"
+#include "RTCDataChannel.h"
#include "RTCOfferAnswerOptions.h"
#include "RTCRtpTransceiver.h"
#include "ScriptWrappable.h"
@@ -49,7 +50,6 @@
class MediaStreamTrack;
class PeerConnectionBackend;
class RTCConfiguration;
-class RTCDataChannel;
class RTCIceCandidate;
class RTCPeerConnectionErrorCallback;
class RTCSessionDescription;
@@ -60,9 +60,10 @@
static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
~RTCPeerConnection();
+ using AnswerOptions = RTCAnswerOptions;
+ using DataChannelInit = RTCDataChannelInit;
using OfferAnswerOptions = RTCOfferAnswerOptions;
using OfferOptions = RTCOfferOptions;
- using AnswerOptions = RTCAnswerOptions;
ExceptionOr<void> initializeWith(Document&, const Dictionary&);
@@ -111,7 +112,7 @@
void privateGetStats(MediaStreamTrack*, PeerConnection::StatsPromise&&);
- ExceptionOr<RefPtr<RTCDataChannel>> createDataChannel(const String& label, const Dictionary& dataChannelDict);
+ ExceptionOr<Ref<RTCDataChannel>> createDataChannel(ScriptExecutionContext&, String&&, RTCDataChannelInit&&);
void close();
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl (208693 => 208694)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl 2016-11-14 18:52:09 UTC (rev 208694)
@@ -41,6 +41,15 @@
dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
};
+dictionary RTCDataChannelInit {
+ boolean ordered = true;
+ unsigned short maxRetransmitTime;
+ unsigned short maxRetransmits;
+ USVString protocol = "";
+ boolean negotiated = false;
+ unsigned short id;
+};
+
[
ActiveDOMObject,
Conditional=WEB_RTC,
@@ -125,7 +134,7 @@
[PrivateIdentifier] Promise<void> queuedAddIceCandidate(RTCIceCandidate candidate);
[PrivateIdentifier] Promise<RTCStatsReport> privateGetStats(MediaStreamTrack? selector);
- [MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] DOMString label, optional Dictionary options);
+ [CallWith=ScriptExecutionContext, MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] DOMString label, optional RTCDataChannelInit options);
void close();
Modified: trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -34,6 +34,7 @@
#include "MediaEndpoint.h"
#include "MediaPayload.h"
+#include "RTCDataChannelHandler.h"
#include "RealtimeMediaSource.h"
namespace WebCore {
@@ -42,43 +43,40 @@
public:
static Ref<EmptyRealtimeMediaSource> create() { return adoptRef(*new EmptyRealtimeMediaSource()); }
+private:
+ EmptyRealtimeMediaSource() : RealtimeMediaSource(emptyString(), RealtimeMediaSource::None, emptyString()) { }
+
RefPtr<RealtimeMediaSourceCapabilities> capabilities() const final { return nullptr; }
const RealtimeMediaSourceSettings& settings() const final { return m_sourceSettings; }
-private:
- EmptyRealtimeMediaSource()
- : RealtimeMediaSource(emptyString(), RealtimeMediaSource::None, emptyString())
- { }
-
RealtimeMediaSourceSettings m_sourceSettings;
};
-class EmptyMediaEndpoint : public MediaEndpoint {
-public:
- EmptyMediaEndpoint(MediaEndpointClient&) { }
+class EmptyMediaEndpoint final : public MediaEndpoint {
+private:
+ void setConfiguration(MediaEndpointConfiguration&&) final { }
- void setConfiguration(MediaEndpointConfiguration&&) override { }
+ void generateDtlsInfo() final { }
+ MediaPayloadVector getDefaultAudioPayloads() final { return MediaPayloadVector(); }
+ MediaPayloadVector getDefaultVideoPayloads() final { return MediaPayloadVector(); }
+ MediaPayloadVector filterPayloads(const MediaPayloadVector&, const MediaPayloadVector&) final { return MediaPayloadVector(); }
- void generateDtlsInfo() override { }
- MediaPayloadVector getDefaultAudioPayloads() override { return MediaPayloadVector(); }
- MediaPayloadVector getDefaultVideoPayloads() override { return MediaPayloadVector(); }
- MediaPayloadVector filterPayloads(const MediaPayloadVector&, const MediaPayloadVector&) override { return MediaPayloadVector(); }
+ UpdateResult updateReceiveConfiguration(MediaEndpointSessionConfiguration*, bool) final { return UpdateResult::Failed; }
+ UpdateResult updateSendConfiguration(MediaEndpointSessionConfiguration*, const RealtimeMediaSourceMap&, bool) final { return UpdateResult::Failed; }
- UpdateResult updateReceiveConfiguration(MediaEndpointSessionConfiguration*, bool) override { return UpdateResult::Failed; }
- UpdateResult updateSendConfiguration(MediaEndpointSessionConfiguration*, const RealtimeMediaSourceMap&, bool) override { return UpdateResult::Failed; }
+ void addRemoteCandidate(const IceCandidate&, const String&, const String&, const String&) final { }
- void addRemoteCandidate(const IceCandidate&, const String&, const String&, const String&) override { }
+ Ref<RealtimeMediaSource> createMutedRemoteSource(const String&, RealtimeMediaSource::Type) final { return EmptyRealtimeMediaSource::create(); }
+ void replaceSendSource(RealtimeMediaSource&, const String&) final { }
+ void replaceMutedRemoteSourceMid(const String&, const String&) final { };
- Ref<RealtimeMediaSource> createMutedRemoteSource(const String&, RealtimeMediaSource::Type) override { return EmptyRealtimeMediaSource::create(); }
- void replaceSendSource(RealtimeMediaSource&, const String&) override { }
- void replaceMutedRemoteSourceMid(const String&, const String&) override { };
-
- void stop() override { }
+ std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final { return nullptr; }
+ void stop() final { }
};
-static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient& client)
+static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient&)
{
- return std::make_unique<EmptyMediaEndpoint>(client);
+ return std::make_unique<EmptyMediaEndpoint>();
}
CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
Modified: trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -39,13 +39,16 @@
namespace WebCore {
-struct IceCandidate;
class MediaEndpoint;
class MediaEndpointClient;
class MediaEndpointSessionConfiguration;
-struct MediaPayload;
+class RTCDataChannelHandler;
class RealtimeMediaSource;
+struct IceCandidate;
+struct MediaPayload;
+struct RTCDataChannelInit;
+
typedef std::unique_ptr<MediaEndpoint> (*CreateMediaEndpoint)(MediaEndpointClient&);
typedef Vector<MediaPayload> MediaPayloadVector;
typedef HashMap<String, RealtimeMediaSource*> RealtimeMediaSourceMap;
@@ -79,6 +82,8 @@
virtual void replaceSendSource(RealtimeMediaSource&, const String& mid) = 0;
virtual void replaceMutedRemoteSourceMid(const String& oldMid, const String& newMid) = 0;
+ virtual std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) = 0;
+
virtual void stop() = 0;
virtual void emulatePlatformEvent(const String&) { };
Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -22,8 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef RTCDataChannelHandler_h
-#define RTCDataChannelHandler_h
+#pragma once
#if ENABLE(WEB_RTC)
@@ -31,6 +30,15 @@
namespace WebCore {
+struct RTCDataChannelInit {
+ bool ordered { true };
+ int maxRetransmitTime { -1 };
+ int maxRetransmits { -1 };
+ String protocol;
+ bool negotiated { false };
+ int id { -1 };
+};
+
class RTCDataChannelHandlerClient;
class RTCDataChannelHandler {
@@ -39,15 +47,6 @@
virtual void setClient(RTCDataChannelHandlerClient*) = 0;
- virtual String label() = 0;
- virtual bool ordered() = 0;
- virtual unsigned short maxRetransmitTime() = 0;
- virtual unsigned short maxRetransmits() = 0;
- virtual String protocol() = 0;
- virtual bool negotiated() = 0;
- virtual unsigned short id() = 0;
- virtual unsigned long bufferedAmount() = 0;
-
virtual bool sendStringData(const String&) = 0;
virtual bool sendRawData(const char*, size_t) = 0;
virtual void close() = 0;
@@ -56,5 +55,3 @@
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
-
-#endif // RTCDataChannelHandler_h
Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -46,6 +46,9 @@
virtual void didReceiveStringData(const String&) = 0;
virtual void didReceiveRawData(const char*, size_t) = 0;
virtual void didDetectError() = 0;
+
+ virtual void protect() = 0;
+ virtual void unprotect() = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -53,21 +53,7 @@
class RTCStatsRequest;
class RTCVoidRequest;
-struct RTCDataChannelInit {
-public:
- RTCDataChannelInit()
- : ordered(true)
- , maxRetransmitTime(-1)
- , maxRetransmits(-1)
- , negotiated(false)
- , id(-1) { }
- bool ordered;
- int maxRetransmitTime;
- int maxRetransmits;
- String protocol;
- bool negotiated;
- int id;
-};
+struct RTCDataChannelInit;
typedef std::unique_ptr<RTCPeerConnectionHandler> (*CreatePeerConnectionHandler)(RTCPeerConnectionHandlerClient*);
Modified: trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.cpp (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -37,6 +37,7 @@
#include "MediaPayload.h"
#include "NotImplemented.h"
#include "OpenWebRTCUtilities.h"
+#include "RTCDataChannelHandler.h"
#include "RealtimeMediaSourceOwr.h"
#include <owr/owr.h>
#include <owr/owr_audio_payload.h>
@@ -94,6 +95,13 @@
m_configuration = WTFMove(configuration);
}
+std::unique_ptr<RTCDataChannelHandler> MediaEndpointOwr::createDataChannelHandler(const String&, const RTCDataChannelInit&)
+{
+ // FIXME: Implement data channel.
+ ASSERT_NOT_REACHED();
+ return nullptr;
+}
+
static void cryptoDataCallback(gchar* privateKey, gchar* certificate, gchar* fingerprint, gchar* fingerprintFunction, gpointer data)
{
MediaEndpointOwr* mediaEndpoint = (MediaEndpointOwr*) data;
Modified: trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mediastream/openwebrtc/MediaEndpointOwr.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -120,6 +120,8 @@
String mid;
};
+ std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final;
+
void prepareSession(OwrSession*, PeerMediaDescription*);
void prepareMediaSession(OwrMediaSession*, PeerMediaDescription*, bool isInitiator);
Modified: trunk/Source/WebCore/platform/mock/MockMediaEndpoint.cpp (208693 => 208694)
--- trunk/Source/WebCore/platform/mock/MockMediaEndpoint.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mock/MockMediaEndpoint.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -37,6 +37,7 @@
#include "MediaPayload.h"
#include "MockRealtimeAudioSource.h"
#include "MockRealtimeVideoSource.h"
+#include "RTCDataChannelHandlerMock.h"
#include "RealtimeMediaSource.h"
#include <wtf/MainThread.h>
@@ -63,6 +64,11 @@
stop();
}
+std::unique_ptr<RTCDataChannelHandler> MockMediaEndpoint::createDataChannelHandler(const String& label, const RTCDataChannelInit& options)
+{
+ return std::make_unique<RTCDataChannelHandlerMock>(label, options);
+}
+
void MockMediaEndpoint::generateDtlsInfo()
{
callOnMainThread([this]() {
Modified: trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -68,6 +68,8 @@
private:
void updateConfigurationMids(const MediaEndpointSessionConfiguration&);
+ std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final;
+
void dispatchFakeIceCandidates();
void iceCandidateTimerFired();
Modified: trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp (208693 => 208694)
--- trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp 2016-11-14 18:52:09 UTC (rev 208694)
@@ -37,11 +37,6 @@
RTCDataChannelHandlerMock::RTCDataChannelHandlerMock(const String& label, const RTCDataChannelInit& init)
: m_label(label)
, m_protocol(init.protocol)
- , m_maxRetransmitTime(init.maxRetransmitTime)
- , m_maxRetransmits(init.maxRetransmits)
- , m_id(init.id)
- , m_ordered(init.ordered)
- , m_negotiated(init.negotiated)
{
}
Modified: trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h (208693 => 208694)
--- trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h 2016-11-14 18:40:26 UTC (rev 208693)
+++ trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h 2016-11-14 18:52:09 UTC (rev 208694)
@@ -41,15 +41,6 @@
void setClient(RTCDataChannelHandlerClient*) override;
- String label() override { return m_label; }
- bool ordered() override { return m_ordered; }
- unsigned short maxRetransmitTime() override { return m_maxRetransmitTime; }
- unsigned short maxRetransmits() override { return m_maxRetransmits; }
- String protocol() override { return m_protocol; }
- bool negotiated() override { return m_negotiated; }
- unsigned short id() override { return m_id; }
- unsigned long bufferedAmount() override { return 0; }
-
bool sendStringData(const String&) override;
bool sendRawData(const char*, size_t) override;
void close() override;
@@ -59,11 +50,6 @@
String m_label;
String m_protocol;
- unsigned short m_maxRetransmitTime;
- unsigned short m_maxRetransmits;
- unsigned short m_id;
- bool m_ordered;
- bool m_negotiated;
};
} // namespace WebCore