Diff
Modified: trunk/Source/WebCore/ChangeLog (111875 => 111876)
--- trunk/Source/WebCore/ChangeLog 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/ChangeLog 2012-03-23 17:16:06 UTC (rev 111876)
@@ -1,3 +1,72 @@
+2012-03-23 Tommy Widenflycht <[email protected]>
+
+ MediaStream API (JSEP): Introducing PeerConnection00 and IceCallback
+ https://bugs.webkit.org/show_bug.cgi?id=81657
+
+ Reviewed by Adam Barth.
+
+ Last major WebCore patch for the JSEP PeerConnection, together with the associated
+ IceCallback (they both depend on each other and IceCallback has very few lines of real code).
+
+ My next patch after this one will do a major overhaul of the existing layout tests
+ and add a few new ones.
+
+ * GNUmakefile.list.am:
+ * Modules/mediastream/DOMWindowMediaStream.idl:
+ * Modules/mediastream/IceCallback.h: Added.
+ (WebCore):
+ (IceCallback):
+ (WebCore::IceCallback::~IceCallback):
+ * Modules/mediastream/IceCallback.idl: Added.
+ * Modules/mediastream/PeerConnection00.cpp: Added.
+ (WebCore):
+ (WebCore::PeerConnection00::create):
+ (WebCore::PeerConnection00::PeerConnection00):
+ (WebCore::PeerConnection00::~PeerConnection00):
+ (WebCore::PeerConnection00::hasLocalAudioTrack):
+ (WebCore::PeerConnection00::hasLocalVideoTrack):
+ (WebCore::PeerConnection00::parseMediaHints):
+ (WebCore::PeerConnection00::createOffer):
+ (WebCore::PeerConnection00::createAnswer):
+ (WebCore::PeerConnection00::setLocalDescription):
+ (WebCore::PeerConnection00::setRemoteDescription):
+ (WebCore::PeerConnection00::localDescription):
+ (WebCore::PeerConnection00::remoteDescription):
+ (WebCore::PeerConnection00::startIce):
+ (WebCore::PeerConnection00::processIceMessage):
+ (WebCore::PeerConnection00::readyState):
+ (WebCore::PeerConnection00::iceState):
+ (WebCore::PeerConnection00::addStream):
+ (WebCore::PeerConnection00::removeStream):
+ (WebCore::PeerConnection00::localStreams):
+ (WebCore::PeerConnection00::remoteStreams):
+ (WebCore::PeerConnection00::close):
+ (WebCore::PeerConnection00::didGenerateIceCandidate):
+ (WebCore::PeerConnection00::didChangeReadyState):
+ (WebCore::PeerConnection00::didChangeIceState):
+ (WebCore::PeerConnection00::didAddRemoteStream):
+ (WebCore::PeerConnection00::didRemoveRemoteStream):
+ (WebCore::PeerConnection00::interfaceName):
+ (WebCore::PeerConnection00::scriptExecutionContext):
+ (WebCore::PeerConnection00::stop):
+ (WebCore::PeerConnection00::eventTargetData):
+ (WebCore::PeerConnection00::ensureEventTargetData):
+ (WebCore::PeerConnection00::changeReadyState):
+ (WebCore::PeerConnection00::changeIceState):
+ * Modules/mediastream/PeerConnection00.h: Added.
+ (WebCore):
+ (PeerConnection00):
+ (WebCore::PeerConnection00::refEventTarget):
+ (WebCore::PeerConnection00::derefEventTarget):
+ * Modules/mediastream/PeerConnection00.idl: Added.
+ * WebCore.gypi:
+ * bindings/generic/RuntimeEnabledFeatures.h:
+ (WebCore::RuntimeEnabledFeatures::webkitPeerConnection00Enabled):
+ * bindings/js/JSPeerConnection00Custom.cpp: Added.
+ (WebCore):
+ (WebCore::JSPeerConnection00Constructor::constructJSPeerConnection00):
+ * dom/EventTargetFactory.in:
+
2012-03-23 Adrienne Walker <[email protected]>
[chromium] Fix scrollbarLayerLostContext flaky test crash on 10.6
Modified: trunk/Source/WebCore/GNUmakefile.list.am (111875 => 111876)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-03-23 17:16:06 UTC (rev 111876)
@@ -344,6 +344,8 @@
DerivedSources/WebCore/JSHTMLUListElement.h \
DerivedSources/WebCore/JSHTMLVideoElement.cpp \
DerivedSources/WebCore/JSHTMLVideoElement.h \
+ DerivedSources/WebCore/JSIceCallback.cpp \
+ DerivedSources/WebCore/JSIceCallback.h \
DerivedSources/WebCore/JSIceCandidate.cpp \
DerivedSources/WebCore/JSIceCandidate.h \
DerivedSources/WebCore/JSImageData.cpp \
@@ -436,6 +438,8 @@
DerivedSources/WebCore/JSOverflowEvent.h \
DerivedSources/WebCore/JSPageTransitionEvent.cpp \
DerivedSources/WebCore/JSPageTransitionEvent.h \
+ DerivedSources/WebCore/JSPeerConnection00.cpp \
+ DerivedSources/WebCore/JSPeerConnection00.h \
DerivedSources/WebCore/JSPerformance.cpp \
DerivedSources/WebCore/JSPerformance.h \
DerivedSources/WebCore/JSPerformanceNavigation.cpp \
@@ -664,6 +668,7 @@
$(WebCore)/Modules/geolocation/PositionErrorCallback.idl \
$(WebCore)/Modules/mediastream/DeprecatedPeerConnection.idl \
$(WebCore)/Modules/mediastream/DOMWindowMediaStream.idl \
+ $(WebCore)/Modules/mediastream/IceCallback.idl \
$(WebCore)/Modules/mediastream/IceCandidate.idl \
$(WebCore)/Modules/mediastream/LocalMediaStream.idl \
$(WebCore)/Modules/mediastream/MediaStream.idl \
@@ -675,6 +680,7 @@
$(WebCore)/Modules/mediastream/NavigatorUserMediaError.idl \
$(WebCore)/Modules/mediastream/NavigatorUserMediaErrorCallback.idl \
$(WebCore)/Modules/mediastream/NavigatorUserMediaSuccessCallback.idl \
+ $(WebCore)/Modules/mediastream/PeerConnection00.idl \
$(WebCore)/Modules/mediastream/SessionDescription.idl \
$(WebCore)/Modules/mediastream/SignalingCallback.idl \
$(WebCore)/Modules/webaudio/AudioContext.idl \
@@ -1097,6 +1103,7 @@
Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.h \
Source/WebCore/Modules/mediastream/DeprecatedPeerConnection.cpp \
Source/WebCore/Modules/mediastream/DeprecatedPeerConnection.h \
+ Source/WebCore/Modules/mediastream/IceCallback.h \
Source/WebCore/Modules/mediastream/IceCandidate.cpp \
Source/WebCore/Modules/mediastream/IceCandidate.h \
Source/WebCore/Modules/mediastream/LocalMediaStream.cpp \
@@ -1118,6 +1125,8 @@
Source/WebCore/Modules/mediastream/NavigatorUserMediaError.h \
Source/WebCore/Modules/mediastream/NavigatorUserMediaErrorCallback.h \
Source/WebCore/Modules/mediastream/NavigatorUserMediaSuccessCallback.h \
+ Source/WebCore/Modules/mediastream/PeerConnection00.cpp \
+ Source/WebCore/Modules/mediastream/PeerConnection00.h \
Source/WebCore/Modules/mediastream/SessionDescription.cpp \
Source/WebCore/Modules/mediastream/SessionDescription.h \
Source/WebCore/Modules/mediastream/SignalingCallback.h \
Modified: trunk/Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl (111875 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl 2012-03-23 17:16:06 UTC (rev 111876)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * 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
@@ -32,6 +32,9 @@
] DOMWindowMediaStream {
attribute [V8EnabledAtRuntime] DeprecatedPeerConnectionConstructor webkitDeprecatedPeerConnection;
attribute [V8EnabledAtRuntime] MediaStreamConstructor webkitMediaStream;
+ attribute [V8EnabledAtRuntime] PeerConnection00Constructor webkitPeerConnection00;
+ attribute SessionDescriptionConstructor SessionDescription;
+ attribute IceCandidateConstructor IceCandidate;
attribute MediaStreamEventConstructor MediaStreamEvent;
};
Copied: trunk/Source/WebCore/Modules/mediastream/IceCallback.h (from rev 111875, trunk/Source/WebCore/Modules/mediastream/SessionDescription.cpp) (0 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/IceCallback.h (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/IceCallback.h 2012-03-23 17:16:06 UTC (rev 111876)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 IceCallback_h
+#define IceCallback_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class IceCandidate;
+class PeerConnection00;
+
+class IceCallback : public RefCounted<IceCallback> {
+public:
+ virtual ~IceCallback() { }
+ virtual bool handleEvent(IceCandidate*, bool moreToFollow, PeerConnection00*) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // IceCallback_h
Added: trunk/Source/WebCore/Modules/mediastream/IceCallback.idl (0 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/IceCallback.idl (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/IceCallback.idl 2012-03-23 17:16:06 UTC (rev 111876)
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 p2p {
+
+ interface [
+ Conditional=MEDIA_STREAM,
+ Callback
+ ] IceCallback {
+ boolean handleEvent(in IceCandidate candidate, in boolean moreToFollow, in PeerConnection00 source);
+ };
+
+}
Added: trunk/Source/WebCore/Modules/mediastream/PeerConnection00.cpp (0 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnection00.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnection00.cpp 2012-03-23 17:16:06 UTC (rev 111876)
@@ -0,0 +1,465 @@
+/*
+ * 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "PeerConnection00.h"
+
+#include "ExceptionCode.h"
+#include "IceCallback.h"
+#include "IceCandidate.h"
+#include "IceCandidateDescriptor.h"
+#include "IceOptions.h"
+#include "MediaHints.h"
+#include "MediaStreamEvent.h"
+#include "MessageEvent.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include "SessionDescription.h"
+#include "SessionDescriptionDescriptor.h"
+
+namespace WebCore {
+
+PassRefPtr<PeerConnection00> PeerConnection00::create(ScriptExecutionContext* context, const String& serverConfiguration, PassRefPtr<IceCallback> iceCallback)
+{
+ RefPtr<PeerConnection00> peerConnection = adoptRef(new PeerConnection00(context, serverConfiguration, iceCallback));
+ peerConnection->suspendIfNeeded();
+ return peerConnection.release();
+}
+
+PeerConnection00::PeerConnection00(ScriptExecutionContext* context, const String& serverConfiguration, PassRefPtr<IceCallback> iceCallback)
+ : ActiveDOMObject(context, this)
+ , m_iceCallback(iceCallback)
+ , m_readyState(NEW)
+ , m_iceState(ICE_CLOSED)
+ , m_localStreams(MediaStreamList::create())
+ , m_remoteStreams(MediaStreamList::create())
+ , m_peerHandler(PeerConnection00Handler::create(this, serverConfiguration, context->securityOrigin()->toString()))
+{
+}
+
+PeerConnection00::~PeerConnection00()
+{
+}
+
+bool PeerConnection00::hasLocalAudioTrack()
+{
+ for (size_t i = 0; i < m_localStreams->length(); ++i) {
+ MediaStream* curr = m_localStreams->item(i);
+ if (curr->audioTracks()->length() > 0)
+ return true;
+ }
+ return false;
+}
+
+bool PeerConnection00::hasLocalVideoTrack()
+{
+ for (size_t i = 0; i < m_localStreams->length(); ++i) {
+ MediaStream* curr = m_localStreams->item(i);
+ if (curr->videoTracks()->length() > 0)
+ return true;
+ }
+ return false;
+}
+
+PassRefPtr<MediaHints> PeerConnection00::parseMediaHints(const String& mediaHints)
+{
+ Vector<String> hintsList;
+ mediaHints.split(",", hintsList);
+ bool audio = hasLocalAudioTrack();
+ bool video = hasLocalVideoTrack();
+ for (Vector<String>::iterator i = hintsList.begin(); i != hintsList.end(); ++i) {
+ if (*i == "audio")
+ audio = true;
+ else if (*i == "no_audio")
+ audio = false;
+ else if (*i == "video")
+ video = true;
+ else if (*i == "no_video")
+ video = false;
+ }
+
+ return MediaHints::create(audio, video);
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::createOffer()
+{
+ return createOffer("");
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::createOffer(const String& mediaHintsString)
+{
+ RefPtr<MediaHints> mediaHints = parseMediaHints(mediaHintsString);
+ RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createOffer(mediaHints.release());
+ if (!descriptor)
+ return 0;
+
+ return SessionDescription::create(descriptor);
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer)
+{
+ return createAnswer(offer, "");
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::createAnswer(const String& offer, const String& mediaHintsString)
+{
+ RefPtr<MediaHints> mediaHints = parseMediaHints(mediaHintsString);
+ RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->createAnswer(offer, mediaHints.release());
+ if (!descriptor)
+ return 0;
+
+ return SessionDescription::create(descriptor);
+}
+
+void PeerConnection00::setLocalDescription(int action, PassRefPtr<SessionDescription> sessionDescription, ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ switch (action) {
+ case SDP_OFFER:
+ case SDP_PRANSWER:
+ case SDP_ANSWER:
+ break;
+ default:
+ ec = SYNTAX_ERR;
+ return;
+ }
+
+ if (!sessionDescription) {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ bool valid = m_peerHandler->setLocalDescription(action, sessionDescription->descriptor());
+ if (!valid)
+ ec = SYNTAX_ERR;
+}
+
+void PeerConnection00::setRemoteDescription(int action, PassRefPtr<SessionDescription> sessionDescription, ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ switch (action) {
+ case SDP_OFFER:
+ case SDP_PRANSWER:
+ case SDP_ANSWER:
+ break;
+ default:
+ ec = SYNTAX_ERR;
+ return;
+ }
+
+ if (!sessionDescription) {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ bool valid = m_peerHandler->setRemoteDescription(action, sessionDescription->descriptor());
+ if (!valid)
+ ec = SYNTAX_ERR;
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::localDescription()
+{
+ RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->localDescription();
+ if (!descriptor)
+ return 0;
+
+ RefPtr<SessionDescription> desc = SessionDescription::create(descriptor.release());
+ return desc.release();
+}
+
+PassRefPtr<SessionDescription> PeerConnection00::remoteDescription()
+{
+ RefPtr<SessionDescriptionDescriptor> descriptor = m_peerHandler->remoteDescription();
+ if (!descriptor)
+ return 0;
+
+ RefPtr<SessionDescription> desc = SessionDescription::create(descriptor.release());
+ return desc.release();
+}
+
+void PeerConnection00::startIce(ExceptionCode& ec)
+{
+ startIce("", ec);
+}
+
+void PeerConnection00::startIce(const String& options, ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ IceOptions::UseCandidatesOption option;
+
+ if (options == "" || options == "all")
+ option = IceOptions::ALL;
+ else if (options == "no_relay")
+ option = IceOptions::NO_RELAY;
+ else if (options == "only_relay")
+ option = IceOptions::ONLY_RELAY;
+ else {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ bool valid = m_peerHandler->startIce(IceOptions::create(option));
+ if (!valid)
+ ec = SYNTAX_ERR;
+}
+
+void PeerConnection00::processIceMessage(PassRefPtr<IceCandidate> prpIceCandidate, ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ RefPtr<IceCandidate> iceCandidate = prpIceCandidate;
+ if (!iceCandidate) {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ bool valid = m_peerHandler->processIceMessage(iceCandidate->descriptor());
+ if (!valid)
+ ec = SYNTAX_ERR;
+}
+
+PeerConnection00::ReadyState PeerConnection00::readyState() const
+{
+ return m_readyState;
+}
+
+PeerConnection00::IceState PeerConnection00::iceState() const
+{
+ return m_iceState;
+}
+
+void PeerConnection00::addStream(PassRefPtr<MediaStream> stream, ExceptionCode& ec)
+{
+ String emptyHints;
+ return addStream(stream, emptyHints, ec);
+}
+
+void PeerConnection00::addStream(PassRefPtr<MediaStream> prpStream, const String& mediaStreamHints, ExceptionCode& ec)
+{
+ RefPtr<MediaStream> stream = prpStream;
+ if (!stream) {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ if (m_localStreams->contains(stream.get()))
+ return;
+
+ m_localStreams->append(stream);
+
+ // FIXME: When the spec says what the mediaStreamHints should look like send it down.
+ m_peerHandler->addStream(stream->descriptor());
+}
+
+void PeerConnection00::removeStream(MediaStream* stream, ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ if (!stream) {
+ ec = TYPE_MISMATCH_ERR;
+ return;
+ }
+
+ if (!m_localStreams->contains(stream))
+ return;
+
+ m_localStreams->remove(stream);
+
+ m_peerHandler->removeStream(stream->descriptor());
+}
+
+MediaStreamList* PeerConnection00::localStreams() const
+{
+ return m_localStreams.get();
+}
+
+MediaStreamList* PeerConnection00::remoteStreams() const
+{
+ return m_remoteStreams.get();
+}
+
+void PeerConnection00::close(ExceptionCode& ec)
+{
+ if (m_readyState == CLOSED) {
+ ec = INVALID_STATE_ERR;
+ return;
+ }
+
+ stop();
+}
+
+void PeerConnection00::didGenerateIceCandidate(PassRefPtr<IceCandidateDescriptor> iceCandidateDescriptor, bool moreToFollow)
+{
+ ASSERT(scriptExecutionContext()->isContextThread());
+ if (!iceCandidateDescriptor)
+ m_iceCallback->handleEvent(0, moreToFollow, this);
+ else {
+ RefPtr<IceCandidate> iceCandidate = IceCandidate::create(iceCandidateDescriptor);
+ m_iceCallback->handleEvent(iceCandidate.get(), moreToFollow, this);
+ }
+}
+
+void PeerConnection00::didChangeReadyState(uint32_t newState)
+{
+ ASSERT(scriptExecutionContext()->isContextThread());
+ changeReadyState(static_cast<ReadyState>(newState));
+}
+
+void PeerConnection00::didChangeIceState(uint32_t newState)
+{
+ ASSERT(scriptExecutionContext()->isContextThread());
+ changeIceState(static_cast<IceState>(newState));
+}
+
+void PeerConnection00::didAddRemoteStream(PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+{
+ ASSERT(scriptExecutionContext()->isContextThread());
+
+ if (m_readyState == CLOSED)
+ return;
+
+ RefPtr<MediaStream> stream = MediaStream::create(scriptExecutionContext(), streamDescriptor);
+ m_remoteStreams->append(stream);
+
+ dispatchEvent(MediaStreamEvent::create(eventNames().addstreamEvent, false, false, stream.release()));
+}
+
+void PeerConnection00::didRemoveRemoteStream(MediaStreamDescriptor* streamDescriptor)
+{
+ ASSERT(scriptExecutionContext()->isContextThread());
+ ASSERT(streamDescriptor->owner());
+
+ RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->owner());
+ stream->streamEnded();
+
+ if (m_readyState == CLOSED)
+ return;
+
+ ASSERT(m_remoteStreams->contains(stream.get()));
+ m_remoteStreams->remove(stream.get());
+
+ dispatchEvent(MediaStreamEvent::create(eventNames().removestreamEvent, false, false, stream.release()));
+}
+
+const AtomicString& PeerConnection00::interfaceName() const
+{
+ return eventNames().interfaceForPeerConnection00;
+}
+
+ScriptExecutionContext* PeerConnection00::scriptExecutionContext() const
+{
+ return ActiveDOMObject::scriptExecutionContext();
+}
+
+void PeerConnection00::stop()
+{
+ if (m_readyState == CLOSED)
+ return;
+
+ if (m_peerHandler)
+ m_peerHandler->stop();
+ m_peerHandler.clear();
+
+ changeReadyState(CLOSED);
+ changeIceState(ICE_CLOSED);
+}
+
+EventTargetData* PeerConnection00::eventTargetData()
+{
+ return &m_eventTargetData;
+}
+
+EventTargetData* PeerConnection00::ensureEventTargetData()
+{
+ return &m_eventTargetData;
+}
+
+void PeerConnection00::changeReadyState(ReadyState readyState)
+{
+ if (readyState == m_readyState)
+ return;
+
+ m_readyState = readyState;
+
+ switch (m_readyState) {
+ case NEGOTIATING:
+ dispatchEvent(Event::create(eventNames().connectingEvent, false, false));
+ break;
+ case ACTIVE:
+ dispatchEvent(Event::create(eventNames().openEvent, false, false));
+ break;
+ case CLOSED:
+ break;
+ case NEW:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
+}
+
+void PeerConnection00::changeIceState(IceState iceState)
+{
+ if (iceState == m_iceState)
+ return;
+
+ m_iceState = iceState;
+ dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
Added: trunk/Source/WebCore/Modules/mediastream/PeerConnection00.h (0 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnection00.h (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnection00.h 2012-03-23 17:16:06 UTC (rev 111876)
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 PeerConnection00_h
+#define PeerConnection00_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "ActiveDOMObject.h"
+#include "EventTarget.h"
+#include "ExceptionBase.h"
+#include "IceCallback.h"
+#include "MediaStream.h"
+#include "MediaStreamList.h"
+#include "PeerConnection00Handler.h"
+#include "PeerConnection00HandlerClient.h"
+#include "SessionDescription.h"
+#include "Timer.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MediaHints;
+
+// Note:
+// SDP stands for Session Description Protocol, which is intended for describing
+// multimedia sessions for the purposes of session announcement, session
+// invitation, and other forms of multimedia session initiation.
+//
+// More information can be found here:
+// http://tools.ietf.org/html/rfc4566
+// http://en.wikipedia.org/wiki/Session_Description_Protocol
+
+class PeerConnection00 : public RefCounted<PeerConnection00>, public PeerConnection00HandlerClient, public EventTarget, public ActiveDOMObject {
+public:
+ enum ReadyState {
+ NEW = 0,
+ NEGOTIATING = 1,
+ ACTIVE = 2,
+ CLOSED = 3
+ };
+
+ enum Action {
+ SDP_OFFER = 0x100,
+ SDP_PRANSWER = 0x200,
+ SDP_ANSWER = 0x300
+ };
+
+ enum IceState {
+ ICE_GATHERING = 0x100,
+ ICE_WAITING = 0x200,
+ ICE_CHECKING = 0x300,
+ ICE_CONNECTED = 0x400,
+ ICE_COMPLETED = 0x500,
+ ICE_FAILED = 0x600,
+ ICE_CLOSED = 0x700
+ };
+
+ static PassRefPtr<PeerConnection00> create(ScriptExecutionContext*, const String& serverConfiguration, PassRefPtr<IceCallback>);
+ ~PeerConnection00();
+
+ PassRefPtr<SessionDescription> createOffer();
+ PassRefPtr<SessionDescription> createOffer(const String& mediaHints);
+ PassRefPtr<SessionDescription> createAnswer(const String& offer);
+ PassRefPtr<SessionDescription> createAnswer(const String& offer, const String& mediaHints);
+
+ void setLocalDescription(int action, PassRefPtr<SessionDescription>, ExceptionCode&);
+ void setRemoteDescription(int action, PassRefPtr<SessionDescription>, ExceptionCode&);
+ PassRefPtr<SessionDescription> localDescription();
+ PassRefPtr<SessionDescription> remoteDescription();
+
+ void startIce(ExceptionCode&);
+ void startIce(const String& options, ExceptionCode&);
+ void processIceMessage(PassRefPtr<IceCandidate>, ExceptionCode&);
+
+ IceState iceState() const;
+ ReadyState readyState() const;
+
+ void addStream(const PassRefPtr<MediaStream>, ExceptionCode&);
+ void addStream(const PassRefPtr<MediaStream>, const String& mediaStreamHints, ExceptionCode&);
+ void removeStream(MediaStream*, ExceptionCode&);
+ MediaStreamList* localStreams() const;
+ MediaStreamList* remoteStreams() const;
+
+ void close(ExceptionCode&);
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(open);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(addstream);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(removestream);
+
+ // PeerConnection00HandlerClient
+ virtual void didGenerateIceCandidate(PassRefPtr<IceCandidateDescriptor>, bool moreToFollow) OVERRIDE;
+ virtual void didChangeReadyState(uint32_t state) OVERRIDE;
+ virtual void didChangeIceState(uint32_t state) OVERRIDE;
+ virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>) OVERRIDE;
+ virtual void didRemoveRemoteStream(MediaStreamDescriptor*) OVERRIDE;
+
+ // EventTarget
+ virtual const AtomicString& interfaceName() const OVERRIDE;
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+
+ // ActiveDOMObject
+ virtual void stop() OVERRIDE;
+
+ using RefCounted<PeerConnection00>::ref;
+ using RefCounted<PeerConnection00>::deref;
+
+private:
+ PeerConnection00(ScriptExecutionContext*, const String& serverConfiguration, PassRefPtr<IceCallback>);
+
+ // EventTarget implementation.
+ virtual EventTargetData* eventTargetData();
+ virtual EventTargetData* ensureEventTargetData();
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+ EventTargetData m_eventTargetData;
+
+ void changeReadyState(ReadyState);
+ void changeIceState(IceState);
+ bool hasLocalAudioTrack();
+ bool hasLocalVideoTrack();
+ PassRefPtr<MediaHints> parseMediaHints(const String& mediaHintsString);
+
+ RefPtr<IceCallback> m_iceCallback;
+
+ ReadyState m_readyState;
+ IceState m_iceState;
+
+ RefPtr<MediaStreamList> m_localStreams;
+ RefPtr<MediaStreamList> m_remoteStreams;
+
+ OwnPtr<PeerConnection00Handler> m_peerHandler;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // PeerConnection00_h
Added: trunk/Source/WebCore/Modules/mediastream/PeerConnection00.idl (0 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnection00.idl (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnection00.idl 2012-03-23 17:16:06 UTC (rev 111876)
@@ -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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 p2p {
+
+ interface [
+ Conditional=MEDIA_STREAM,
+ ActiveDOMObject,
+ Constructor(in DOMString serverConfiguration, in [Callback] IceCallback iceCallback),
+ CallWith=ScriptExecutionContext,
+ EventTarget
+ ] PeerConnection00 {
+ // FIXME: Make mediaHints an object
+ SessionDescription createOffer(in [Optional] DOMString mediaHints);
+
+ // FIXME: Make mediaHints an object
+ SessionDescription createAnswer(in DOMString offer, in [Optional] DOMString mediaHints);
+
+ // Actions, for setLocalDescription/setRemoteDescription.
+ const unsigned short SDP_OFFER = 0x100;
+ const unsigned short SDP_PRANSWER = 0x200;
+ const unsigned short SDP_ANSWER = 0x300;
+
+ void setLocalDescription(in unsigned short action, in SessionDescription desc)
+ raises(DOMException);
+
+ void setRemoteDescription(in unsigned short action, in SessionDescription desc)
+ raises(DOMException);
+
+ readonly attribute SessionDescription localDescription;
+
+ readonly attribute SessionDescription remoteDescription;
+
+ const unsigned short NEW = 0;
+ const unsigned short NEGOTIATING = 1;
+ const unsigned short ACTIVE = 2;
+ const unsigned short CLOSED = 3;
+ readonly attribute unsigned short readyState;
+
+ // FIXME: Make iceOptions an object
+ void startIce(in [Optional] DOMString iceOptions)
+ raises(DOMException);
+
+ void processIceMessage(in IceCandidate candidate)
+ raises(DOMException);
+
+ const unsigned short ICE_GATHERING = 0x100;
+ const unsigned short ICE_WAITING = 0x200;
+ const unsigned short ICE_CHECKING = 0x300;
+ const unsigned short ICE_CONNECTED = 0x400;
+ const unsigned short ICE_COMPLETED = 0x500;
+ const unsigned short ICE_FAILED = 0x600;
+ const unsigned short ICE_CLOSED = 0x700;
+ readonly attribute unsigned short iceState;
+
+ // FIXME: Make mediaStreamHints an object
+ [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional] DOMString mediaStreamHints)
+ raises(DOMException);
+ [StrictTypeChecking] void removeStream(in MediaStream stream)
+ raises(DOMException);
+
+ readonly attribute MediaStreamList localStreams;
+ readonly attribute MediaStreamList remoteStreams;
+
+ void close()
+ raises(DOMException);
+
+ attribute EventListener onconnecting;
+ attribute EventListener onopen;
+ attribute EventListener onstatechange;
+ attribute EventListener onaddstream;
+ attribute EventListener onremovestream;
+
+ // 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);
+ };
+
+}
Modified: trunk/Source/WebCore/Modules/mediastream/SessionDescription.cpp (111875 => 111876)
--- trunk/Source/WebCore/Modules/mediastream/SessionDescription.cpp 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/Modules/mediastream/SessionDescription.cpp 2012-03-23 17:16:06 UTC (rev 111876)
@@ -48,6 +48,7 @@
PassRefPtr<SessionDescription> SessionDescription::create(PassRefPtr<SessionDescriptionDescriptor> descriptor)
{
+ ASSERT(!!descriptor);
return adoptRef(new SessionDescription(descriptor));
}
Modified: trunk/Source/WebCore/WebCore.gypi (111875 => 111876)
--- trunk/Source/WebCore/WebCore.gypi 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/WebCore.gypi 2012-03-23 17:16:06 UTC (rev 111876)
@@ -790,6 +790,7 @@
'Modules/intents/NavigatorIntents.idl',
'Modules/mediastream/DeprecatedPeerConnection.idl',
'Modules/mediastream/DOMWindowMediaStream.idl',
+ 'Modules/mediastream/IceCallback.idl',
'Modules/mediastream/IceCandidate.idl',
'Modules/mediastream/LocalMediaStream.idl',
'Modules/mediastream/MediaStream.idl',
@@ -801,6 +802,7 @@
'Modules/mediastream/NavigatorUserMediaError.idl',
'Modules/mediastream/NavigatorUserMediaErrorCallback.idl',
'Modules/mediastream/NavigatorUserMediaSuccessCallback.idl',
+ 'Modules/mediastream/PeerConnection00.idl',
'Modules/mediastream/SessionDescription.idl',
'Modules/mediastream/SignalingCallback.idl',
'Modules/speech/DOMWindowSpeech.idl',
@@ -1459,6 +1461,7 @@
'Modules/intents/NavigatorIntents.h',
'Modules/mediastream/DeprecatedPeerConnection.cpp',
'Modules/mediastream/DeprecatedPeerConnection.h',
+ 'Modules/mediastream/IceCallback.h',
'Modules/mediastream/IceCandidate.cpp',
'Modules/mediastream/IceCandidate.h',
'Modules/mediastream/LocalMediaStream.cpp',
@@ -1480,6 +1483,8 @@
'Modules/mediastream/NavigatorUserMediaError.h',
'Modules/mediastream/NavigatorUserMediaErrorCallback.h',
'Modules/mediastream/NavigatorUserMediaSuccessCallback.h',
+ 'Modules/mediastream/PeerConnection00.cpp',
+ 'Modules/mediastream/PeerConnection00.h',
'Modules/mediastream/SessionDescription.cpp',
'Modules/mediastream/SessionDescription.h',
'Modules/mediastream/SignalingCallback.h',
Modified: trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h (111875 => 111876)
--- trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h 2012-03-23 17:16:06 UTC (rev 111876)
@@ -187,6 +187,7 @@
static bool webkitGetUserMediaEnabled() { return isMediaStreamEnabled; }
static bool webkitDeprecatedPeerConnectionEnabled() { return isMediaStreamEnabled; }
static bool webkitMediaStreamEnabled() { return isMediaStreamEnabled; }
+ static bool webkitPeerConnection00Enabled() { return isMediaStreamEnabled; }
#endif
#if ENABLE(GAMEPAD)
Modified: trunk/Source/WebCore/dom/EventTargetFactory.in (111875 => 111876)
--- trunk/Source/WebCore/dom/EventTargetFactory.in 2012-03-23 17:13:09 UTC (rev 111875)
+++ trunk/Source/WebCore/dom/EventTargetFactory.in 2012-03-23 17:16:06 UTC (rev 111876)
@@ -20,6 +20,7 @@
MessagePort
Node
Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
+PeerConnection00 conditional=MEDIA_STREAM
SharedWorker conditional=SHARED_WORKERS
SharedWorkerContext conditional=SHARED_WORKERS
SpeechRecognition conditional=SCRIPTED_SPEECH