WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-99080-20121011183409.patch (text/plain), 54.66 KB, created by
Tommy Widenflycht
on 2012-10-11 09:35:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tommy Widenflycht
Created:
2012-10-11 09:35:13 PDT
Size:
54.66 KB
patch
obsolete
>Subversion Revision: 130729 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4ac75ba092c59b811e64f4fb3837bbd25e0e6e75..e2fca8bb3c3c75eb66f3e58106e7585c6110ad18 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,110 @@ >+2012-10-11 Tommy Widenflycht <tommyw@google.com> >+ >+ MediaStream API: Implement RTCDataChannel >+ https://bugs.webkit.org/show_bug.cgi?id=99080 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch introduces RTCDataChannel which is a pipe for sending data between two RTCPeerConnections. >+ Since the data channel belongs to a peer connection object I have reused part of its infrastructure. >+ >+ Not currently testable. My next patch will add the chromium WebKit functionality, together with mocks and tests. >+ >+ * CMakeLists.txt: >+ * GNUmakefile.list.am: >+ * Modules/mediastream/RTCDataChannel.cpp: Added. >+ (WebCore): >+ (WebCore::RTCDataChannel::create): >+ (WebCore::RTCDataChannel::RTCDataChannel): >+ (WebCore::RTCDataChannel::~RTCDataChannel): >+ (WebCore::RTCDataChannel::label): >+ (WebCore::RTCDataChannel::reliable): >+ (WebCore::RTCDataChannel::readyState): >+ (WebCore::RTCDataChannel::bufferedAmount): >+ (WebCore::RTCDataChannel::binaryType): >+ (WebCore::RTCDataChannel::setBinaryType): >+ (WebCore::RTCDataChannel::send): >+ (WebCore::RTCDataChannel::close): >+ (WebCore::RTCDataChannel::readyStateChanged): >+ (WebCore::RTCDataChannel::dataArrived): >+ (WebCore::RTCDataChannel::error): >+ (WebCore::RTCDataChannel::descriptor): >+ (WebCore::RTCDataChannel::interfaceName): >+ (WebCore::RTCDataChannel::scriptExecutionContext): >+ (WebCore::RTCDataChannel::stop): >+ (WebCore::RTCDataChannel::eventTargetData): >+ (WebCore::RTCDataChannel::ensureEventTargetData): >+ * Modules/mediastream/RTCDataChannel.h: Added. >+ (WebCore): >+ (RTCDataChannel): >+ (WebCore::RTCDataChannel::refEventTarget): >+ (WebCore::RTCDataChannel::derefEventTarget): >+ * Modules/mediastream/RTCDataChannel.idl: Added. >+ * Modules/mediastream/RTCDataChannelEvent.cpp: Added. >+ (WebCore): >+ (WebCore::RTCDataChannelEvent::create): >+ (WebCore::RTCDataChannelEvent::RTCDataChannelEvent): >+ (WebCore::RTCDataChannelEvent::~RTCDataChannelEvent): >+ (WebCore::RTCDataChannelEvent::channel): >+ (WebCore::RTCDataChannelEvent::interfaceName): >+ * Modules/mediastream/RTCDataChannelEvent.h: Added. >+ (WebCore): >+ (RTCDataChannelEvent): >+ * Modules/mediastream/RTCDataChannelEvent.idl: Added. >+ * Modules/mediastream/RTCPeerConnection.cpp: >+ (WebCore::RTCPeerConnection::createDataChannel): >+ (WebCore): >+ (WebCore::RTCPeerConnection::close): >+ (WebCore::RTCPeerConnection::didAddRemoteDataChannel): >+ (WebCore::RTCPeerConnection::stop): >+ * Modules/mediastream/RTCPeerConnection.h: >+ (WebCore): >+ (RTCPeerConnection): >+ * Modules/mediastream/RTCPeerConnection.idl: >+ * WebCore.gypi: >+ * dom/EventNames.h: >+ (WebCore): >+ * dom/EventNames.in: >+ * dom/EventTargetFactory.in: >+ * platform/mediastream/RTCDataChannelDescriptor.cpp: Added. >+ (WebCore): >+ (WebCore::RTCDataChannelDescriptor::create): >+ (WebCore::RTCDataChannelDescriptor::RTCDataChannelDescriptor): >+ (WebCore::RTCDataChannelDescriptor::~RTCDataChannelDescriptor): >+ (WebCore::RTCDataChannelDescriptor::readyStateChanged): >+ (WebCore::RTCDataChannelDescriptor::dataArrived): >+ (WebCore::RTCDataChannelDescriptor::error): >+ * platform/mediastream/RTCDataChannelDescriptor.h: Added. >+ (WebCore): >+ (RTCDataChannelDescriptor): >+ (Owner): >+ (WebCore::RTCDataChannelDescriptor::Owner::~Owner): >+ (ExtraData): >+ (WebCore::RTCDataChannelDescriptor::ExtraData::~ExtraData): >+ (WebCore::RTCDataChannelDescriptor::owner): >+ (WebCore::RTCDataChannelDescriptor::setOwner): >+ (WebCore::RTCDataChannelDescriptor::label): >+ (WebCore::RTCDataChannelDescriptor::reliable): >+ (WebCore::RTCDataChannelDescriptor::readyState): >+ (WebCore::RTCDataChannelDescriptor::bufferedAmount): >+ (WebCore::RTCDataChannelDescriptor::setBufferedAmount): >+ (WebCore::RTCDataChannelDescriptor::extraData): >+ (WebCore::RTCDataChannelDescriptor::setExtraData): >+ * platform/mediastream/RTCPeerConnectionHandler.h: >+ (WebCore): >+ (RTCPeerConnectionHandler): >+ * platform/mediastream/RTCPeerConnectionHandlerClient.h: >+ (WebCore): >+ (RTCPeerConnectionHandlerClient): >+ * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp: >+ (WebCore::RTCPeerConnectionHandlerChromium::openDataChannel): >+ (WebCore): >+ (WebCore::RTCPeerConnectionHandlerChromium::sendStringData): >+ (WebCore::RTCPeerConnectionHandlerChromium::sendRawData): >+ (WebCore::RTCPeerConnectionHandlerChromium::closeDataChannel): >+ * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h: >+ (RTCPeerConnectionHandlerChromium): >+ > 2012-10-08 Simon Hausmann <simon.hausmann@digia.com> > > [Qt] Make RenderThemeQStyle/ScrollbarThemeQStyle compile without QStyle/QtWidgets >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 15d18f7ee35286e450512a8d6cb26fc83a432a9f..84ebf697eff7f4d0d6509d7139639e2910fb1ef2 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -224,6 +224,8 @@ SET(WebCore_IDL_FILES > Modules/mediastream/NavigatorUserMediaErrorCallback.idl > Modules/mediastream/NavigatorUserMediaSuccessCallback.idl > Modules/mediastream/PeerConnection00.idl >+ Modules/mediastream/RTCDataChannel.idl >+ Modules/mediastream/RTCDataChannelEvent.idl > Modules/mediastream/RTCErrorCallback.idl > Modules/mediastream/RTCIceCandidate.idl > Modules/mediastream/RTCIceCandidateEvent.idl >@@ -862,6 +864,8 @@ SET(WebCore_SOURCES > Modules/mediastream/MediaStreamTrackList.cpp > Modules/mediastream/NavigatorMediaStream.cpp > Modules/mediastream/PeerConnection00.cpp >+ Modules/mediastream/RTCDataChannel.cpp >+ Modules/mediastream/RTCDataChannelEvent.cpp > Modules/mediastream/RTCIceCandidate.cpp > Modules/mediastream/RTCIceCandidateEvent.cpp > Modules/mediastream/RTCPeerConnection.cpp >@@ -1958,6 +1962,7 @@ SET(WebCore_SOURCES > platform/mediastream/MediaStreamCenter.cpp > platform/mediastream/MediaStreamSource.cpp > platform/mediastream/PeerConnection00Handler.cpp >+ platform/mediastream/RTCDataChannelDescriptor.cpp > platform/mediastream/RTCIceCandidateDescriptor.cpp > platform/mediastream/RTCPeerConnectionHandler.cpp > platform/mediastream/RTCSessionDescriptionDescriptor.cpp >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 0b540bb413705804541847066e795a5929f374f4..da3b8fcc89f488067a6acad312d53aef8adb297c 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -627,6 +627,10 @@ webcore_built_sources += \ > DerivedSources/WebCore/JSRequestAnimationFrameCallback.h \ > DerivedSources/WebCore/JSRGBColor.cpp \ > DerivedSources/WebCore/JSRGBColor.h \ >+ DerivedSources/WebCore/JSRTCDataChannel.cpp \ >+ DerivedSources/WebCore/JSRTCDataChannel.h \ >+ DerivedSources/WebCore/JSRTCDataChannelEvent.cpp \ >+ DerivedSources/WebCore/JSRTCDataChannelEvent.h \ > DerivedSources/WebCore/JSRTCErrorCallback.cpp \ > DerivedSources/WebCore/JSRTCErrorCallback.h \ > DerivedSources/WebCore/JSRTCIceCandidate.cpp \ >@@ -1236,6 +1240,8 @@ dom_binding_idls += \ > $(WebCore)/Modules/mediastream/NavigatorUserMediaErrorCallback.idl \ > $(WebCore)/Modules/mediastream/NavigatorUserMediaSuccessCallback.idl \ > $(WebCore)/Modules/mediastream/PeerConnection00.idl \ >+ $(WebCore)/Modules/mediastream/RTCDataChannel.idl \ >+ $(WebCore)/Modules/mediastream/RTCDataChannelEvent.idl \ > $(WebCore)/Modules/mediastream/RTCErrorCallback.idl \ > $(WebCore)/Modules/mediastream/RTCIceCandidate.idl \ > $(WebCore)/Modules/mediastream/RTCIceCandidateEvent.idl \ >@@ -1934,6 +1940,10 @@ webcore_modules_sources += \ > Source/WebCore/Modules/mediastream/NavigatorUserMediaSuccessCallback.h \ > Source/WebCore/Modules/mediastream/PeerConnection00.cpp \ > Source/WebCore/Modules/mediastream/PeerConnection00.h \ >+ Source/WebCore/Modules/mediastream/RTCDataChannel.cpp \ >+ Source/WebCore/Modules/mediastream/RTCDataChannel.h \ >+ Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp \ >+ Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h \ > Source/WebCore/Modules/mediastream/RTCErrorCallback.h \ > Source/WebCore/Modules/mediastream/RTCIceCandidate.cpp \ > Source/WebCore/Modules/mediastream/RTCIceCandidate.h \ >@@ -4607,9 +4617,10 @@ webcore_sources += \ > Source/WebCore/platform/mediastream/PeerConnection00Handler.h \ > Source/WebCore/platform/mediastream/PeerConnection00HandlerClient.h \ > Source/WebCore/platform/mediastream/RTCConfiguration.h \ >+ Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.cpp \ >+ Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.h \ > Source/WebCore/platform/mediastream/RTCIceCandidateDescriptor.cpp \ > Source/WebCore/platform/mediastream/RTCIceCandidateDescriptor.h \ >- Source/WebCore/platform/mediastream/SessionDescriptionDescriptor.h \ > Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp \ > Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h \ > Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h \ >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp b/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..435a5958d6b6c202bf0f48c509b23446cb464df7 >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp >@@ -0,0 +1,267 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include "RTCDataChannel.h" >+ >+#include "Blob.h" >+#include "Event.h" >+#include "ExceptionCode.h" >+#include "MessageEvent.h" >+#include "RTCPeerConnectionHandler.h" >+#include "ScriptExecutionContext.h" >+#include <wtf/ArrayBuffer.h> >+#include <wtf/ArrayBufferView.h> >+ >+namespace WebCore { >+ >+PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* handler, String label, bool reliable, ExceptionCode& ec) >+{ >+ ASSERT(handler); >+ RefPtr<RTCDataChannel> dataChannel = create(context, handler, RTCDataChannelDescriptor::create(label, reliable)); >+ if (!handler->openDataChannel(dataChannel->descriptor())) { >+ ec = NOT_SUPPORTED_ERR; >+ return 0; >+ } >+ return dataChannel.release(); >+} >+ >+PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* handler, PassRefPtr<RTCDataChannelDescriptor> descriptor) >+{ >+ ASSERT(handler); >+ ASSERT(descriptor); >+ return adoptRef(new RTCDataChannel(context, handler, descriptor)); >+} >+ >+RTCDataChannel::RTCDataChannel(ScriptExecutionContext* context, RTCPeerConnectionHandler* handler, PassRefPtr<RTCDataChannelDescriptor> descriptor) >+ : m_scriptExecutionContext(context) >+ , m_stopped(false) >+ , m_descriptor(descriptor) >+ , m_binaryType(BinaryTypeArrayBuffer) >+ , m_handler(handler) >+{ >+ m_descriptor->setOwner(this); >+} >+ >+RTCDataChannel::~RTCDataChannel() >+{ >+ m_descriptor->setOwner(0); >+} >+ >+String RTCDataChannel::label() const >+{ >+ return m_descriptor->label(); >+} >+ >+bool RTCDataChannel::reliable() const >+{ >+ return m_descriptor->reliable(); >+} >+ >+String RTCDataChannel::readyState() const >+{ >+ switch (m_descriptor->readyState()) { >+ case RTCDataChannelDescriptor::ReadyStateConnecting: >+ return ASCIILiteral("connecting"); >+ case RTCDataChannelDescriptor::ReadyStateOpen: >+ return ASCIILiteral("open"); >+ case RTCDataChannelDescriptor::ReadyStateClosing: >+ return ASCIILiteral("closing"); >+ case RTCDataChannelDescriptor::ReadyStateClosed: >+ return ASCIILiteral("closed"); >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return ""; >+} >+ >+unsigned long RTCDataChannel::bufferedAmount() const >+{ >+ return m_descriptor->bufferedAmount(); >+} >+ >+String RTCDataChannel::binaryType() const >+{ >+ switch (m_binaryType) { >+ case BinaryTypeBlob: >+ return ASCIILiteral("blob"); >+ case BinaryTypeArrayBuffer: >+ return ASCIILiteral("arraybuffer"); >+ } >+ ASSERT_NOT_REACHED(); >+ return String(); >+} >+ >+void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionCode& ec) >+{ >+ if (binaryType == "blob") >+ ec = NOT_SUPPORTED_ERR; >+ else if (binaryType == "arraybuffer") >+ m_binaryType = BinaryTypeArrayBuffer; >+ else >+ ec = TYPE_MISMATCH_ERR; >+} >+ >+void RTCDataChannel::send(const String& data, ExceptionCode& ec) >+{ >+ if (m_descriptor->readyState() != RTCDataChannelDescriptor::ReadyStateOpen) { >+ ec = INVALID_STATE_ERR; >+ return; >+ } >+ if (!m_handler->sendStringData(descriptor(), data)) { >+ // FIXME: Decide what the right exception here is. >+ ec = SYNTAX_ERR; >+ } >+} >+ >+void RTCDataChannel::send(PassRefPtr<ArrayBuffer> prpData, ExceptionCode& ec) >+{ >+ if (m_descriptor->readyState() != RTCDataChannelDescriptor::ReadyStateOpen) { >+ ec = INVALID_STATE_ERR; >+ return; >+ } >+ >+ RefPtr<ArrayBuffer> data = prpData; >+ >+ size_t dataLength = data->byteLength(); >+ if (!dataLength) >+ return; >+ >+ const char* dataPointer = static_cast<const char*>(data->data()); >+ >+ if (!m_handler->sendRawData(descriptor(), dataPointer, dataLength)) { >+ // FIXME: Decide what the right exception here is. >+ ec = SYNTAX_ERR; >+ } >+} >+ >+void RTCDataChannel::send(PassRefPtr<ArrayBufferView> data, ExceptionCode& ec) >+{ >+ RefPtr<ArrayBuffer> arrayBuffer(data->buffer()); >+ send(arrayBuffer.release(), ec); >+} >+ >+void RTCDataChannel::send(PassRefPtr<Blob> data, ExceptionCode& ec) >+{ >+ // FIXME: implement >+ ec = NOT_SUPPORTED_ERR; >+} >+ >+void RTCDataChannel::close() >+{ >+ if (m_stopped) >+ return; >+ >+ m_handler->closeDataChannel(descriptor()); >+} >+ >+void RTCDataChannel::readyStateChanged() >+{ >+ if (m_stopped) >+ return; >+ >+ switch (m_descriptor->readyState()) { >+ case RTCDataChannelDescriptor::ReadyStateOpen: >+ dispatchEvent(Event::create(eventNames().openEvent, false, false)); >+ break; >+ case RTCDataChannelDescriptor::ReadyStateClosed: >+ dispatchEvent(Event::create(eventNames().closeEvent, false, false)); >+ break; >+ default: >+ break; >+ } >+} >+ >+void RTCDataChannel::dataArrived(const String& text) >+{ >+ if (m_stopped) >+ return; >+ >+ dispatchEvent(MessageEvent::create(text)); >+} >+ >+void RTCDataChannel::dataArrived(const char* data, size_t dataLength) >+{ >+ if (m_stopped) >+ return; >+ >+ if (m_binaryType == BinaryTypeBlob) { >+ // FIXME: Implement. >+ return; >+ } >+ if (m_binaryType == BinaryTypeArrayBuffer) { >+ RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(data, dataLength); >+ dispatchEvent(MessageEvent::create(buffer.release())); >+ return; >+ } >+ ASSERT_NOT_REACHED(); >+} >+ >+void RTCDataChannel::error() >+{ >+ if (m_stopped) >+ return; >+ >+ dispatchEvent(Event::create(eventNames().errorEvent, false, false)); >+} >+ >+RTCDataChannelDescriptor* RTCDataChannel::descriptor() >+{ >+ return m_descriptor.get(); >+} >+ >+const AtomicString& RTCDataChannel::interfaceName() const >+{ >+ return eventNames().interfaceForRTCDataChannel; >+} >+ >+ScriptExecutionContext* RTCDataChannel::scriptExecutionContext() const >+{ >+ return m_scriptExecutionContext; >+} >+ >+void RTCDataChannel::stop() >+{ >+ m_stopped = true; >+ m_handler = 0; >+ m_descriptor->setOwner(0); >+ m_scriptExecutionContext = 0; >+} >+ >+EventTargetData* RTCDataChannel::eventTargetData() >+{ >+ return &m_eventTargetData; >+} >+ >+EventTargetData* RTCDataChannel::ensureEventTargetData() >+{ >+ return &m_eventTargetData; >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannel.h b/Source/WebCore/Modules/mediastream/RTCDataChannel.h >new file mode 100644 >index 0000000000000000000000000000000000000000..510391c8e3307541fc97a03b4bb7b3a3702dce21 >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannel.h >@@ -0,0 +1,112 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef RTCDataChannel_h >+#define RTCDataChannel_h >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include "ActiveDOMObject.h" >+#include "EventTarget.h" >+#include "RTCDataChannelDescriptor.h" >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+class Blob; >+class RTCPeerConnectionHandler; >+ >+class RTCDataChannel : public RefCounted<RTCDataChannel>, public EventTarget, public RTCDataChannelDescriptor::Owner { >+public: >+ static PassRefPtr<RTCDataChannel> create(ScriptExecutionContext*, RTCPeerConnectionHandler*, String label, bool reliable, ExceptionCode&); >+ static PassRefPtr<RTCDataChannel> create(ScriptExecutionContext*, RTCPeerConnectionHandler*, PassRefPtr<RTCDataChannelDescriptor>); >+ ~RTCDataChannel(); >+ >+ String label() const; >+ >+ bool reliable() const; >+ >+ String readyState() const; >+ >+ unsigned long bufferedAmount() const; >+ >+ String binaryType() const; >+ void setBinaryType(const String&, ExceptionCode&); >+ >+ void send(const String&, ExceptionCode&); >+ void send(PassRefPtr<ArrayBuffer>, ExceptionCode&); >+ void send(PassRefPtr<ArrayBufferView>, ExceptionCode&); >+ void send(PassRefPtr<Blob>, ExceptionCode&); >+ >+ void close(); >+ >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(open); >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(error); >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(close); >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(message); >+ >+ RTCDataChannelDescriptor* descriptor(); >+ void stop(); >+ >+ // EventTarget >+ virtual const AtomicString& interfaceName() const OVERRIDE; >+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; >+ >+ using RefCounted<RTCDataChannel>::ref; >+ using RefCounted<RTCDataChannel>::deref; >+ >+private: >+ RTCDataChannel(ScriptExecutionContext*, RTCPeerConnectionHandler*, PassRefPtr<RTCDataChannelDescriptor>); >+ >+ // EventTarget >+ virtual EventTargetData* eventTargetData(); >+ virtual EventTargetData* ensureEventTargetData(); >+ virtual void refEventTarget() { ref(); } >+ virtual void derefEventTarget() { deref(); } >+ EventTargetData m_eventTargetData; >+ ScriptExecutionContext* m_scriptExecutionContext; >+ >+ // RTCDataChannelDescriptor::Owner >+ virtual void readyStateChanged() OVERRIDE; >+ virtual void dataArrived(const String&) OVERRIDE; >+ virtual void dataArrived(const char*, size_t) OVERRIDE; >+ virtual void error() OVERRIDE; >+ >+ bool m_stopped; >+ RefPtr<RTCDataChannelDescriptor> m_descriptor; >+ >+ enum BinaryType { >+ BinaryTypeBlob, >+ BinaryTypeArrayBuffer >+ }; >+ BinaryType m_binaryType; >+ >+ // Not owned by this class. >+ RTCPeerConnectionHandler* m_handler; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >+ >+#endif // RTCDataChannel_h >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannel.idl b/Source/WebCore/Modules/mediastream/RTCDataChannel.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..1fe7406392c0ed58c518e0750a5e34f729cd11ce >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannel.idl >@@ -0,0 +1,66 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+module mediastream { >+ >+ interface [ >+ Conditional=MEDIA_STREAM, >+ EventTarget >+ ] RTCDataChannel { >+ readonly attribute DOMString label; >+ readonly attribute boolean reliable; >+ readonly attribute DOMString readyState; >+ readonly attribute unsigned long bufferedAmount; >+ >+ attribute DOMString binaryType >+ setter raises(DOMException); >+ >+ void send(in ArrayBuffer data) >+ raises(DOMException); >+ void send(in ArrayBufferView data) >+ raises(DOMException); >+ void send(in Blob data) >+ raises(DOMException); >+ void send(in DOMString data) >+ raises(DOMException); >+ >+ void close(); >+ >+ attribute EventListener onopen; >+ attribute EventListener onerror; >+ attribute EventListener onclose; >+ attribute EventListener onmessage; >+ >+ // EventTarget interface >+ void addEventListener(in DOMString type, >+ in EventListener listener, >+ in [Optional] boolean useCapture); >+ void removeEventListener(in DOMString type, >+ in EventListener listener, >+ in [Optional] boolean useCapture); >+ boolean dispatchEvent(in Event event) >+ raises(EventException); >+ }; >+ >+} >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f227135b74d1b8071c628a31a1b098360a3fb9ce >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp >@@ -0,0 +1,73 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "RTCDataChannelEvent.h" >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include "EventNames.h" >+#include "RTCDataChannel.h" >+ >+namespace WebCore { >+ >+PassRefPtr<RTCDataChannelEvent> RTCDataChannelEvent::create() >+{ >+ return adoptRef(new RTCDataChannelEvent); >+} >+ >+PassRefPtr<RTCDataChannelEvent> RTCDataChannelEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<RTCDataChannel> channel) >+{ >+ return adoptRef(new RTCDataChannelEvent(type, canBubble, cancelable, channel)); >+} >+ >+ >+RTCDataChannelEvent::RTCDataChannelEvent() >+{ >+} >+ >+RTCDataChannelEvent::RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<RTCDataChannel> channel) >+ : Event(type, canBubble, cancelable) >+ , m_channel(channel) >+{ >+} >+ >+RTCDataChannelEvent::~RTCDataChannelEvent() >+{ >+} >+ >+RTCDataChannel* RTCDataChannelEvent::channel() const >+{ >+ return m_channel.get(); >+} >+ >+const AtomicString& RTCDataChannelEvent::interfaceName() const >+{ >+ return eventNames().interfaceForRTCDataChannelEvent; >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >+ >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h >new file mode 100644 >index 0000000000000000000000000000000000000000..db08cb7992ea7886d14984314124b5cea9ae174b >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h >@@ -0,0 +1,58 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef RTCDataChannelEvent_h >+#define RTCDataChannelEvent_h >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include "Event.h" >+#include "RTCDataChannel.h" >+#include <wtf/text/AtomicString.h> >+ >+namespace WebCore { >+ >+class RTCDataChannelEvent : public Event { >+public: >+ virtual ~RTCDataChannelEvent(); >+ >+ static PassRefPtr<RTCDataChannelEvent> create(); >+ static PassRefPtr<RTCDataChannelEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<RTCDataChannel>); >+ >+ RTCDataChannel* channel() const; >+ >+ virtual const AtomicString& interfaceName() const; >+ >+private: >+ RTCDataChannelEvent(); >+ RTCDataChannelEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<RTCDataChannel>); >+ >+ RefPtr<RTCDataChannel> m_channel; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >+ >+#endif // RTCDataChannelEvent_h >diff --git a/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..3a765a7269a134ef0667dfd70f10a44abea624bf >--- /dev/null >+++ b/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl >@@ -0,0 +1,33 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+module events { >+ >+ interface [ >+ Conditional=MEDIA_STREAM, >+ ] RTCDataChannelEvent : Event { >+ readonly attribute RTCDataChannel channel; >+ }; >+ >+} >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >index b9811add802342f8f932d24342022b856f670743..0e6b65099090a824559584b300075c7860ee49d2 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >@@ -43,6 +43,8 @@ > #include "MediaConstraintsImpl.h" > #include "MediaStreamEvent.h" > #include "RTCConfiguration.h" >+#include "RTCDataChannel.h" >+#include "RTCDataChannelEvent.h" > #include "RTCErrorCallback.h" > #include "RTCIceCandidate.h" > #include "RTCIceCandidateDescriptor.h" >@@ -408,6 +410,22 @@ void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P > m_peerHandler->getStats(statsRequest.release()); > } > >+PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, const Dictionary& dataChannelDict, ExceptionCode& ec) >+{ >+ if (m_readyState == ReadyStateClosed) { >+ ec = INVALID_STATE_ERR; >+ return 0; >+ } >+ >+ bool reliable = true; >+ dataChannelDict.get(ASCIILiteral("reliable"), reliable); >+ RefPtr<RTCDataChannel> channel = RTCDataChannel::create(scriptExecutionContext(), m_peerHandler.get(), label, reliable, ec); >+ if (ec) >+ return 0; >+ m_dataChannels.append(channel); >+ return channel.release(); >+} >+ > void RTCPeerConnection::close(ExceptionCode& ec) > { > if (m_readyState == ReadyStateClosing || m_readyState == ReadyStateClosed) { >@@ -415,9 +433,10 @@ void RTCPeerConnection::close(ExceptionCode& ec) > return; > } > >+ m_peerHandler->stop(); >+ > changeIceState(IceStateClosed); > changeReadyState(ReadyStateClosed); >- stop(); > } > > void RTCPeerConnection::negotiationNeeded() >@@ -478,6 +497,19 @@ void RTCPeerConnection::didRemoveRemoteStream(MediaStreamDescriptor* streamDescr > dispatchEvent(MediaStreamEvent::create(eventNames().removestreamEvent, false, false, stream.release())); > } > >+void RTCPeerConnection::didAddRemoteDataChannel(PassRefPtr<RTCDataChannelDescriptor> channelDescriptor) >+{ >+ ASSERT(scriptExecutionContext()->isContextThread()); >+ >+ if (m_readyState == ReadyStateClosed) >+ return; >+ >+ RefPtr<RTCDataChannel> channel = RTCDataChannel::create(scriptExecutionContext(), m_peerHandler.get(), channelDescriptor); >+ m_dataChannels.append(channel); >+ >+ dispatchEvent(RTCDataChannelEvent::create(eventNames().datachannelEvent, false, false, channel.release())); >+} >+ > const AtomicString& RTCPeerConnection::interfaceName() const > { > return eventNames().interfaceForRTCPeerConnection; >@@ -490,13 +522,17 @@ ScriptExecutionContext* RTCPeerConnection::scriptExecutionContext() const > > void RTCPeerConnection::stop() > { >+ if (m_readyState != ReadyStateClosed) >+ m_peerHandler->stop(); >+ >+ m_peerHandler.clear(); >+ > m_iceState = IceStateClosed; > m_readyState = ReadyStateClosed; > >- if (m_peerHandler) { >- m_peerHandler->stop(); >- m_peerHandler.clear(); >- } >+ Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); >+ for (; i != m_dataChannels.end(); ++i) >+ (*i)->stop(); > } > > EventTargetData* RTCPeerConnection::eventTargetData() >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >index a77aef26db029ce98e491d534241af963b17aebe..c7f9b910f82174bb4dcdbe8cc053cf915a1c9993 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >@@ -49,6 +49,7 @@ namespace WebCore { > class MediaConstraints; > class MediaStreamTrack; > class RTCConfiguration; >+class RTCDataChannel; > class RTCErrorCallback; > class RTCSessionDescription; > class RTCSessionDescriptionCallback; >@@ -88,6 +89,8 @@ public: > > void getStats(PassRefPtr<RTCStatsCallback> successCallback, PassRefPtr<MediaStreamTrack> selector); > >+ PassRefPtr<RTCDataChannel> createDataChannel(String label, const Dictionary& dataChannelDict, ExceptionCode&); >+ > void close(ExceptionCode&); > > DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded); >@@ -97,6 +100,7 @@ public: > DEFINE_ATTRIBUTE_EVENT_LISTENER(addstream); > DEFINE_ATTRIBUTE_EVENT_LISTENER(removestream); > DEFINE_ATTRIBUTE_EVENT_LISTENER(icechange); >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(datachannel); > > // RTCPeerConnectionHandlerClient > virtual void negotiationNeeded() OVERRIDE; >@@ -105,6 +109,7 @@ public: > virtual void didChangeIceState(IceState) OVERRIDE; > virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>) OVERRIDE; > virtual void didRemoveRemoteStream(MediaStreamDescriptor*) OVERRIDE; >+ virtual void didAddRemoteDataChannel(PassRefPtr<RTCDataChannelDescriptor>) OVERRIDE; > > // EventTarget > virtual const AtomicString& interfaceName() const OVERRIDE; >@@ -137,6 +142,8 @@ private: > RefPtr<MediaStreamList> m_localStreams; > RefPtr<MediaStreamList> m_remoteStreams; > >+ Vector<RefPtr<RTCDataChannel> > m_dataChannels; >+ > OwnPtr<RTCPeerConnectionHandler> m_peerHandler; > }; > >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl b/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl >index 56df47ac521f3da0a9979c59ada93dd26146dbdf..079807336e302dcc2c123b0868772511ac5cdb72 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl >@@ -74,6 +74,9 @@ module mediastream { > > void getStats(in [Callback] RTCStatsCallback successCallback, in [Optional=DefaultIsUndefined] MediaStreamTrack selector); > >+ RTCDataChannel createDataChannel(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString label, in [Optional=DefaultIsUndefined] Dictionary dataChannelDict) >+ raises(DOMException); >+ > void close() > raises(DOMException); > >@@ -84,6 +87,7 @@ module mediastream { > attribute EventListener onaddstream; > attribute EventListener onremovestream; > attribute EventListener onicechange; >+ attribute EventListener ondatachannel; > > // EventTarget interface > void addEventListener(in DOMString type, >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 225ad2281fc8df3e8cf73ca310c833a2decf11e5..70d13d39bfa313efed71fc02cb41cf242c12d0a2 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -456,6 +456,8 @@ > 'platform/mediastream/PeerConnection00Handler.h', > 'platform/mediastream/PeerConnection00HandlerClient.h', > 'platform/mediastream/RTCConfiguration.h', >+ 'platform/mediastream/RTCDataChannelDescriptor.cpp', >+ 'platform/mediastream/RTCDataChannelDescriptor.h', > 'platform/mediastream/RTCIceCandidateDescriptor.cpp', > 'platform/mediastream/RTCIceCandidateDescriptor.h', > 'platform/mediastream/RTCPeerConnectionHandler.h', >@@ -866,6 +868,8 @@ > 'Modules/mediastream/NavigatorUserMediaErrorCallback.idl', > 'Modules/mediastream/NavigatorUserMediaSuccessCallback.idl', > 'Modules/mediastream/PeerConnection00.idl', >+ 'Modules/mediastream/RTCDataChannel.idl', >+ 'Modules/mediastream/RTCDataChannelEvent.idl', > 'Modules/mediastream/RTCErrorCallback.idl', > 'Modules/mediastream/RTCIceCandidate.idl', > 'Modules/mediastream/RTCIceCandidateEvent.idl', >@@ -1611,6 +1615,10 @@ > 'Modules/mediastream/NavigatorUserMediaSuccessCallback.h', > 'Modules/mediastream/PeerConnection00.cpp', > 'Modules/mediastream/PeerConnection00.h', >+ 'Modules/mediastream/RTCDataChannel.h', >+ 'Modules/mediastream/RTCDataChannel.cpp', >+ 'Modules/mediastream/RTCDataChannelEvent.h', >+ 'Modules/mediastream/RTCDataChannelEvent.cpp', > 'Modules/mediastream/RTCErrorCallback.h', > 'Modules/mediastream/RTCIceCandidate.cpp', > 'Modules/mediastream/RTCIceCandidate.h', >diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h >index 669bf648c5c2187347de8eb2458084c1a318961e..7a0552a4a70da93d420117fd202e9209c3b4721a 100644 >--- a/Source/WebCore/dom/EventNames.h >+++ b/Source/WebCore/dom/EventNames.h >@@ -228,6 +228,7 @@ namespace WebCore { > macro(icechange) \ > macro(icecandidate) \ > macro(negotiationneeded) \ >+ macro(datachannel) \ > \ > macro(show) \ > \ >diff --git a/Source/WebCore/dom/EventNames.in b/Source/WebCore/dom/EventNames.in >index 9e9e0c86307ad00ec867a8ba67640e0fa0500e5e..3471c0710ab4ca552dcf524221bf7d78660ec11d 100644 >--- a/Source/WebCore/dom/EventNames.in >+++ b/Source/WebCore/dom/EventNames.in >@@ -32,6 +32,7 @@ OfflineAudioCompletionEvent conditional=WEB_AUDIO > MediaStreamEvent conditional=MEDIA_STREAM > MediaStreamTrackEvent conditional=MEDIA_STREAM > RTCIceCandidateEvent conditional=MEDIA_STREAM >+RTCDataChannelEvent conditional=MEDIA_STREAM > SpeechInputEvent conditional=INPUT_SPEECH > SpeechRecognitionError conditional=SCRIPTED_SPEECH > SpeechRecognitionEvent conditional=SCRIPTED_SPEECH >diff --git a/Source/WebCore/dom/EventTargetFactory.in b/Source/WebCore/dom/EventTargetFactory.in >index 791bd4eda5ca37af457836349779513074c2d2f4..7c39bd3f436e41ff086ccf0d5108e7e5b4edb281 100644 >--- a/Source/WebCore/dom/EventTargetFactory.in >+++ b/Source/WebCore/dom/EventTargetFactory.in >@@ -26,6 +26,7 @@ Node > Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS > PeerConnection00 conditional=MEDIA_STREAM > Performance conditional=WEB_TIMING >+RTCDataChannel conditional=MEDIA_STREAM > RTCPeerConnection conditional=MEDIA_STREAM > SharedWorker conditional=SHARED_WORKERS > SharedWorkerContext conditional=SHARED_WORKERS >diff --git a/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.cpp b/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3068100ebac8bd69dd615b505c61935d946fac03 >--- /dev/null >+++ b/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.cpp >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include "RTCDataChannelDescriptor.h" >+ >+namespace WebCore { >+ >+PassRefPtr<RTCDataChannelDescriptor> RTCDataChannelDescriptor::create(const String& label, bool reliable) >+{ >+ return adoptRef(new RTCDataChannelDescriptor(label, reliable)); >+} >+ >+RTCDataChannelDescriptor::RTCDataChannelDescriptor(const String& label, bool reliable) >+ : m_label(label) >+ , m_reliable(reliable) >+ , m_readyState(ReadyStateConnecting) >+ , m_bufferedAmount(0) >+{ >+} >+ >+RTCDataChannelDescriptor::~RTCDataChannelDescriptor() >+{ >+} >+ >+void RTCDataChannelDescriptor::readyStateChanged(ReadyState readyState) >+{ >+ ASSERT(m_readyState != ReadyStateClosed); >+ if (m_readyState != readyState && m_owner) { >+ m_readyState = readyState; >+ m_owner->readyStateChanged(); >+ } >+} >+ >+void RTCDataChannelDescriptor::dataArrived(const String& data) >+{ >+ ASSERT(m_readyState != ReadyStateClosed); >+ if (m_owner) >+ m_owner->dataArrived(data); >+} >+ >+void RTCDataChannelDescriptor::dataArrived(const char* data, size_t dataLength) >+{ >+ ASSERT(m_readyState != ReadyStateClosed); >+ if (m_owner) >+ m_owner->dataArrived(data, dataLength); >+} >+ >+void RTCDataChannelDescriptor::error() >+{ >+ ASSERT(m_readyState != ReadyStateClosed); >+ if (m_owner) >+ m_owner->error(); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.h b/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..69c2c892680dc9070a8100ee0e9a71cb38bbcbb6 >--- /dev/null >+++ b/Source/WebCore/platform/mediastream/RTCDataChannelDescriptor.h >@@ -0,0 +1,97 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef RTCDataChannelDescriptor_h >+#define RTCDataChannelDescriptor_h >+ >+#if ENABLE(MEDIA_STREAM) >+ >+#include <wtf/RefCounted.h> >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+class RTCDataChannelDescriptor : public RefCounted<RTCDataChannelDescriptor> { >+public: >+ class Owner { >+ public: >+ virtual ~Owner() { } >+ >+ virtual void readyStateChanged() = 0; >+ virtual void dataArrived(const String&) = 0; >+ virtual void dataArrived(const char*, size_t) = 0; >+ virtual void error() = 0; >+ }; >+ >+ class ExtraData : public RefCounted<ExtraData> { >+ public: >+ virtual ~ExtraData() { } >+ }; >+ >+ enum ReadyState { >+ ReadyStateConnecting = 0, >+ ReadyStateOpen = 1, >+ ReadyStateClosing = 2, >+ ReadyStateClosed = 3, >+ }; >+ >+ static PassRefPtr<RTCDataChannelDescriptor> create(const String& label, bool reliable); >+ virtual ~RTCDataChannelDescriptor(); >+ >+ RTCDataChannelDescriptor::Owner* owner() const { return m_owner; } >+ void setOwner(Owner* owner) { m_owner = owner; } >+ >+ const String& label() const { return m_label; } >+ bool reliable() const { return m_reliable; } >+ >+ ReadyState readyState() const { return m_readyState; } >+ >+ unsigned long bufferedAmount() const { return m_bufferedAmount; } >+ void setBufferedAmount(unsigned long bufferedAmount) { m_bufferedAmount = bufferedAmount; } >+ >+ void readyStateChanged(ReadyState); >+ void dataArrived(const String&); >+ void dataArrived(const char*, size_t); >+ void error(); >+ >+ PassRefPtr<ExtraData> extraData() const { return m_extraData; } >+ void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; } >+ >+private: >+ RTCDataChannelDescriptor(const String& label, bool reliable); >+ >+ Owner* m_owner; >+ String m_label; >+ bool m_reliable; >+ ReadyState m_readyState; >+ unsigned long m_bufferedAmount; >+ RefPtr<ExtraData> m_extraData; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(MEDIA_STREAM) >+ >+#endif // RTCDataChannelDescriptor_h >diff --git a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp >index 663fbc8d5699d17fdd14d3bf216b5963a317c82a..8509f2e9427568ba6279980da360c61f1a45c453 100644 >--- a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp >+++ b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.cpp >@@ -62,6 +62,12 @@ public: > virtual void getStats(PassRefPtr<RTCStatsRequest>) OVERRIDE; > virtual void stop() OVERRIDE; > >+ // RTCDataChannel. >+ virtual bool openDataChannel(PassRefPtr<RTCDataChannelDescriptor>) OVERRIDE; >+ virtual bool sendStringData(PassRefPtr<RTCDataChannelDescriptor>, const String&) OVERRIDE; >+ virtual bool sendRawData(PassRefPtr<RTCDataChannelDescriptor>, const char*, size_t) OVERRIDE; >+ virtual void closeDataChannel(PassRefPtr<RTCDataChannelDescriptor>) OVERRIDE; >+ > private: > RTCPeerConnectionHandlerClient* m_client; > }; >@@ -139,6 +145,25 @@ void RTCPeerConnectionHandlerDummy::stop() > { > } > >+bool RTCPeerConnectionHandlerDummy::openDataChannel(PassRefPtr<RTCDataChannelDescriptor>) >+{ >+ return false; >+} >+ >+bool RTCPeerConnectionHandlerDummy::sendStringData(PassRefPtr<RTCDataChannelDescriptor>, const String&) >+{ >+ return false; >+} >+ >+bool RTCPeerConnectionHandlerDummy::sendRawData(PassRefPtr<RTCDataChannelDescriptor>, const char*, size_t) >+{ >+ return false; >+} >+ >+void RTCPeerConnectionHandlerDummy::closeDataChannel(PassRefPtr<RTCDataChannelDescriptor>) >+{ >+} >+ > } // namespace WebCore > > #endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h >index e690705be7a4a2e6e59d0417d43badbda4712099..fba45887e6799656f26637e4efdea4e96566032d 100644 >--- a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h >+++ b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h >@@ -41,6 +41,7 @@ namespace WebCore { > > class MediaConstraints; > class RTCConfiguration; >+class RTCDataChannelDescriptor; > class RTCIceCandidateDescriptor; > class RTCPeerConnectionHandlerClient; > class RTCSessionDescriptionDescriptor; >@@ -68,6 +69,12 @@ public: > virtual void getStats(PassRefPtr<RTCStatsRequest>) = 0; > virtual void stop() = 0; > >+ // RTCDataChannel. >+ virtual bool openDataChannel(PassRefPtr<RTCDataChannelDescriptor>) = 0; >+ virtual bool sendStringData(PassRefPtr<RTCDataChannelDescriptor>, const String&) = 0; >+ virtual bool sendRawData(PassRefPtr<RTCDataChannelDescriptor>, const char*, size_t) = 0; >+ virtual void closeDataChannel(PassRefPtr<RTCDataChannelDescriptor>) = 0; >+ > protected: > RTCPeerConnectionHandler() { } > }; >diff --git a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h >index 33b904260b7f84649ae49e6dfd613a0b28830830..389c8671b94be7383e55d4b6c7d0423dfe1f4660 100644 >--- a/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h >+++ b/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h >@@ -38,6 +38,7 @@ > namespace WebCore { > > class MediaStreamDescriptor; >+class RTCDataChannelDescriptor; > class RTCIceCandidateDescriptor; > > class RTCPeerConnectionHandlerClient { >@@ -69,6 +70,9 @@ public: > virtual void didChangeIceState(IceState) = 0; > virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>) = 0; > virtual void didRemoveRemoteStream(MediaStreamDescriptor*) = 0; >+ >+ // RTCDataChannel. >+ virtual void didAddRemoteDataChannel(PassRefPtr<RTCDataChannelDescriptor>) = 0; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp >index 4e4e13175933141685ce1dc2b103c0ae28e87e42..07c1ccd15aac55b61dadc0e4abc0c605899eac61 100644 >--- a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp >+++ b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp >@@ -36,6 +36,7 @@ > > #include "MediaConstraints.h" > #include "RTCConfiguration.h" >+#include "RTCDataChannelDescriptor.h" > #include "RTCIceCandidateDescriptor.h" > #include "RTCPeerConnectionHandlerClient.h" > #include "RTCSessionDescriptionDescriptor.h" >@@ -212,6 +213,29 @@ void RTCPeerConnectionHandlerChromium::didRemoveRemoteStream(const WebKit::WebMe > m_client->didRemoveRemoteStream(webMediaStreamDescriptor); > } > >+bool RTCPeerConnectionHandlerChromium::openDataChannel(PassRefPtr<RTCDataChannelDescriptor> dataChannel) >+{ >+ // FIXME: Implement when WebKit changes have landed. >+ return false; >+} >+ >+bool RTCPeerConnectionHandlerChromium::sendStringData(PassRefPtr<RTCDataChannelDescriptor> dataChannel, const String& data) >+{ >+ // FIXME: Implement when WebKit changes have landed. >+ return false; >+} >+ >+bool RTCPeerConnectionHandlerChromium::sendRawData(PassRefPtr<RTCDataChannelDescriptor> dataChannel, const char* data, size_t dataLength) >+{ >+ // FIXME: Implement when WebKit changes have landed. >+ return false; >+} >+ >+void RTCPeerConnectionHandlerChromium::closeDataChannel(PassRefPtr<RTCDataChannelDescriptor> dataChannel) >+{ >+ // FIXME: Implement when WebKit changes have landed. >+} >+ > } // namespace WebCore > > #endif // ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h >index b669b256aea4010dccca58b0f186eb11a6684262..6da11957a7c5f86fb5bbe7d6ddf7ad6f8a378e0d 100644 >--- a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h >+++ b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h >@@ -67,6 +67,11 @@ public: > virtual void getStats(PassRefPtr<RTCStatsRequest>) OVERRIDE; > virtual void stop() OVERRIDE; > >+ virtual bool openDataChannel(PassRefPtr<RTCDataChannelDescriptor>) OVERRIDE; >+ virtual bool sendStringData(PassRefPtr<RTCDataChannelDescriptor>, const String&) OVERRIDE; >+ virtual bool sendRawData(PassRefPtr<RTCDataChannelDescriptor>, const char*, size_t) OVERRIDE; >+ virtual void closeDataChannel(PassRefPtr<RTCDataChannelDescriptor>) OVERRIDE; >+ > // WebKit::WebRTCPeerConnectionHandlerClient implementation. > virtual void negotiationNeeded() OVERRIDE; > virtual void didGenerateICECandidate(const WebKit::WebRTCICECandidate&) OVERRIDE;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 99080
:
168241
|
168244
|
168386
|
168639