Title: [165226] trunk
Revision
165226
Author
[email protected]
Date
2014-03-06 15:41:24 -0800 (Thu, 06 Mar 2014)

Log Message

[WebRTC] Updating createOffer and createAnswer methods to match WebRTC editor's draft of 01/27/2014
https://bugs.webkit.org/show_bug.cgi?id=129484

Reviewed by Eric Carlson.

According to the spec, createOffer and createAnswer will no longer have MediaConstraints as an argument,
instead they will have RTCOfferOptions and RTCOfferAnswerOptions, respectively.

Source/WebCore:

Existing tests were updated.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/mediastream/RTCOfferAnswerOptions.cpp: Added.
* Modules/mediastream/RTCOfferAnswerOptions.h: Added.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::createOffer):
(WebCore::RTCPeerConnection::createAnswer):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCPeerConnection.idl:
* platform/mediastream/RTCPeerConnectionHandler.h:
* platform/mock/RTCPeerConnectionHandlerMock.cpp:
(WebCore::RTCPeerConnectionHandlerMock::createOffer):
(WebCore::RTCPeerConnectionHandlerMock::createAnswer):
* platform/mock/RTCPeerConnectionHandlerMock.h:

LayoutTests:

* fast/mediastream/RTCPeerConnection-createAnswer-expected.txt:
* fast/mediastream/RTCPeerConnection-createAnswer.html:
* fast/mediastream/RTCPeerConnection-createOffer-expected.txt:
* fast/mediastream/RTCPeerConnection-createOffer.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (165225 => 165226)


--- trunk/LayoutTests/ChangeLog	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/LayoutTests/ChangeLog	2014-03-06 23:41:24 UTC (rev 165226)
@@ -1,3 +1,18 @@
+2014-03-06  Thiago de Barros Lacerda  <[email protected]>
+
+        [WebRTC] Updating createOffer and createAnswer methods to match WebRTC editor's draft of 01/27/2014
+        https://bugs.webkit.org/show_bug.cgi?id=129484
+
+        Reviewed by Eric Carlson.
+
+        According to the spec, createOffer and createAnswer will no longer have MediaConstraints as an argument,
+        instead they will have RTCOfferOptions and RTCOfferAnswerOptions, respectively.
+
+        * fast/mediastream/RTCPeerConnection-createAnswer-expected.txt:
+        * fast/mediastream/RTCPeerConnection-createAnswer.html:
+        * fast/mediastream/RTCPeerConnection-createOffer-expected.txt:
+        * fast/mediastream/RTCPeerConnection-createOffer.html:
+
 2014-03-05  Oliver Hunt  <[email protected]>
 
         Support caching of custom setters

Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer-expected.txt (165225 => 165226)


--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer-expected.txt	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer-expected.txt	2014-03-06 23:41:24 UTC (rev 165226)
@@ -7,15 +7,10 @@
 PASS createAnswer request succeeded.
 PASS pc.setRemoteDescription(sessionDescription, setDescriptionSucceeded, setDescriptionFailed); did not throw exception.
 PASS setRemoteDescription succeeded.
-PASS pc.createAnswer(requestSucceeded2, requestFailed2, {mandatory:{"succeed":false}}); did not throw exception.
+PASS pc.createAnswer(requestSucceeded2, requestFailed2, {}); threw exception Error: TypeMismatchError: DOM Exception 17.
 PASS createAnswer request failed.
-PASS errorReason.name is "IncompatibleConstraintsError"
-PASS pc.createAnswer(requestSucceeded3, requestFailed3); did not throw exception.
-PASS createAnswer request succeeded.
-PASS sessionDescription.type is "answer"
-PASS pc.createAnswer(requestSucceeded4, requestFailed3, {mandatory:{"succeed":true}}); did not throw exception.
-PASS createAnswer request succeeded.
-PASS sessionDescription.type is "answer"
+PASS errorReason.name is "Invalid createAnswer argument."
+PASS pc.createAnswer(requestSucceeded3, requestFailed1, {requestIdentity:"ifconfigured"}); did not throw exception.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer.html (165225 => 165226)


--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer.html	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createAnswer.html	2014-03-06 23:41:24 UTC (rev 165226)
@@ -9,7 +9,7 @@
 
             var pc = null;
 
-            function requestSucceeded4(sd)
+            function requestSucceeded5(sd)
             {
                 testPassed('createAnswer request succeeded.');
 
@@ -19,21 +19,25 @@
                 finishJSTest();
             }
 
-            function requestFailed3(reason)
+            function requestSucceeded4(sd)
             {
-                testFailed('createAnswer request failed.');
+                testPassed('createAnswer request succeeded.');
 
-                finishJSTest();
+                sessionDescription = sd;
+                shouldBe('sessionDescription.type', '"answer"');
+
+                shouldNotThrow('pc.createAnswer(requestSucceeded5, requestFailed1, {requestIdentity:"no"});');
             }
 
             function requestSucceeded3(sd)
             {
+                finishJSTest();
                 testPassed('createAnswer request succeeded.');
 
                 sessionDescription = sd;
                 shouldBe('sessionDescription.type', '"answer"');
 
-                shouldNotThrow('pc.createAnswer(requestSucceeded4, requestFailed3, {mandatory:{"succeed":true}});');
+                shouldNotThrow('pc.createAnswer(requestSucceeded4, requestFailed1, {requestIdentity:"yes"});');
             }
 
             function requestFailed2(reason)
@@ -41,9 +45,8 @@
                 testPassed('createAnswer request failed.');
 
                 errorReason = reason;
-                shouldBe('errorReason.name', '"IncompatibleConstraintsError"');
-
-                shouldNotThrow('pc.createAnswer(requestSucceeded3, requestFailed3);');
+                shouldBe('errorReason.name', '"Invalid createAnswer argument."');
+                shouldNotThrow('pc.createAnswer(requestSucceeded3, requestFailed1, {requestIdentity:"ifconfigured"});');
             }
 
             function requestSucceeded2()
@@ -78,7 +81,7 @@
             function setDescriptionSucceeded()
             {
                 testPassed('setRemoteDescription succeeded.');
-                shouldNotThrow('pc.createAnswer(requestSucceeded2, requestFailed2, {mandatory:{"succeed":false}});');
+                shouldThrow('pc.createAnswer(requestSucceeded2, requestFailed2, {});');
             }
 
             pc = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});

Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer-expected.txt (165225 => 165226)


--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer-expected.txt	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer-expected.txt	2014-03-06 23:41:24 UTC (rev 165226)
@@ -3,13 +3,28 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS pc.createOffer(requestSucceeded1, requestFailed1, {mandatory:{"succeed":true}}); did not throw exception.
+PASS pc.createOffer(requestSucceeded1, requestFailed1); did not throw exception.
 PASS createOffer request succeeded.
 PASS sessionDescription.type is "offer"
-PASS pc.createOffer(requestSucceeded2, requestFailed2, {mandatory:{"succeed":false}}); did not throw exception.
+PASS pc.createOffer(requestSucceeded2, requestFailed2, {}); threw exception Error: TypeMismatchError: DOM Exception 17.
 PASS createOffer request failed.
-PASS errorReason.name is "IncompatibleConstraintsError"
-PASS pc.createOffer(requestSucceeded3, requestFailed1); did not throw exception.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded2, requestFailed3, {requestIdentity:"yes", offerToReceiveAudio:0}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS createOffer request failed.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded2, requestFailed4, {requestIdentity:"yes", offerToReceiveVideo:0}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS createOffer request failed.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded2, requestFailed5, {offerToReceiveVideo:0, offerToReceiveAudio:0}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS createOffer request failed.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded2, requestFailed6, {requestIdentity:"yes", offerToReceiveVideo:"", offerToReceiveAudio:0}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS createOffer request failed.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded2, requestFailed7, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:""}); threw exception Error: TypeMismatchError: DOM Exception 17.
+PASS createOffer request failed.
+PASS errorReason.name is "Invalid createOffer argument."
+PASS pc.createOffer(requestSucceeded3, requestFailed1, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:0}); did not throw exception.
 PASS createOffer request succeeded.
 PASS sessionDescription.type is "offer"
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer.html (165225 => 165226)


--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer.html	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-createOffer.html	2014-03-06 23:41:24 UTC (rev 165226)
@@ -18,14 +18,64 @@
                 finishJSTest();
             }
 
+            function requestFailed7(reason)
+            {
+                testPassed('createOffer request failed.');
+
+                errorReason = reason;
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
+
+                shouldNotThrow('pc.createOffer(requestSucceeded3, requestFailed1, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:0});');
+            }
+
+            function requestFailed6(reason)
+            {
+                testPassed('createOffer request failed.');
+
+                errorReason = reason;
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
+
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed7, {requestIdentity:"yes", offerToReceiveVideo:0, offerToReceiveAudio:""});');
+            }
+
+            function requestFailed5(reason)
+            {
+                testPassed('createOffer request failed.');
+
+                errorReason = reason;
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
+
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed6, {requestIdentity:"yes", offerToReceiveVideo:"", offerToReceiveAudio:0});');
+            }
+
+            function requestFailed4(reason)
+            {
+                testPassed('createOffer request failed.');
+
+                errorReason = reason;
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
+
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed5, {offerToReceiveVideo:0, offerToReceiveAudio:0});');
+            }
+
+            function requestFailed3(reason)
+            {
+                testPassed('createOffer request failed.');
+
+                errorReason = reason;
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
+
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed4, {requestIdentity:"yes", offerToReceiveVideo:0});');
+            }
+
             function requestFailed2(reason)
             {
                 testPassed('createOffer request failed.');
 
                 errorReason = reason;
-                shouldBe('errorReason.name', '"IncompatibleConstraintsError"');
+                shouldBe('errorReason.name', '"Invalid createOffer argument."');
 
-                shouldNotThrow('pc.createOffer(requestSucceeded3, requestFailed1);');
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed3, {requestIdentity:"yes", offerToReceiveAudio:0});');
             }
 
             function requestSucceeded2(sd)
@@ -47,11 +97,11 @@
                 sessionDescription = sd;
                 shouldBe('sessionDescription.type', '"offer"');
 
-                shouldNotThrow('pc.createOffer(requestSucceeded2, requestFailed2, {mandatory:{"succeed":false}});');
+                shouldThrow('pc.createOffer(requestSucceeded2, requestFailed2, {});');
             }
 
             pc = new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
-            shouldNotThrow('pc.createOffer(requestSucceeded1, requestFailed1, {mandatory:{"succeed":true}});');
+            shouldNotThrow('pc.createOffer(requestSucceeded1, requestFailed1);');
 
             window.jsTestIsAsync = true;
             window.successfullyParsed = true;

Modified: trunk/Source/WebCore/CMakeLists.txt (165225 => 165226)


--- trunk/Source/WebCore/CMakeLists.txt	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/CMakeLists.txt	2014-03-06 23:41:24 UTC (rev 165226)
@@ -860,6 +860,7 @@
     Modules/mediastream/RTCDataChannelEvent.cpp
     Modules/mediastream/RTCIceCandidate.cpp
     Modules/mediastream/RTCIceCandidateEvent.cpp
+    Modules/mediastream/RTCOfferAnswerOptions.cpp
     Modules/mediastream/RTCPeerConnection.cpp
     Modules/mediastream/RTCSessionDescription.cpp
     Modules/mediastream/RTCSessionDescriptionRequestImpl.cpp

Modified: trunk/Source/WebCore/ChangeLog (165225 => 165226)


--- trunk/Source/WebCore/ChangeLog	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/ChangeLog	2014-03-06 23:41:24 UTC (rev 165226)
@@ -1,3 +1,30 @@
+2014-03-06  Thiago de Barros Lacerda  <[email protected]>
+
+        [WebRTC] Updating createOffer and createAnswer methods to match WebRTC editor's draft of 01/27/2014
+        https://bugs.webkit.org/show_bug.cgi?id=129484
+
+        Reviewed by Eric Carlson.
+
+        According to the spec, createOffer and createAnswer will no longer have MediaConstraints as an argument,
+        instead they will have RTCOfferOptions and RTCOfferAnswerOptions, respectively.
+
+        Existing tests were updated.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Modules/mediastream/RTCOfferAnswerOptions.cpp: Added.
+        * Modules/mediastream/RTCOfferAnswerOptions.h: Added.
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::createOffer):
+        (WebCore::RTCPeerConnection::createAnswer):
+        * Modules/mediastream/RTCPeerConnection.h:
+        * Modules/mediastream/RTCPeerConnection.idl:
+        * platform/mediastream/RTCPeerConnectionHandler.h:
+        * platform/mock/RTCPeerConnectionHandlerMock.cpp:
+        (WebCore::RTCPeerConnectionHandlerMock::createOffer):
+        (WebCore::RTCPeerConnectionHandlerMock::createAnswer):
+        * platform/mock/RTCPeerConnectionHandlerMock.h:
+
 2014-03-06  Brian Burg  <[email protected]>
 
         Web Replay: premature release() of PassRefPtr in InspectorReplayAgent

Modified: trunk/Source/WebCore/GNUmakefile.list.am (165225 => 165226)


--- trunk/Source/WebCore/GNUmakefile.list.am	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2014-03-06 23:41:24 UTC (rev 165226)
@@ -1945,6 +1945,8 @@
 	Source/WebCore/Modules/mediastream/RTCIceCandidate.h \
 	Source/WebCore/Modules/mediastream/RTCIceCandidateEvent.cpp \
 	Source/WebCore/Modules/mediastream/RTCIceCandidateEvent.h \
+	Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.cpp \
+	Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.h \
 	Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp \
 	Source/WebCore/Modules/mediastream/RTCPeerConnection.h \
 	Source/WebCore/Modules/mediastream/RTCSessionDescription.cpp \

Added: trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.cpp (0 => 165226)


--- trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.cpp	2014-03-06 23:41:24 UTC (rev 165226)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2014 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. 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 "RTCOfferAnswerOptions.h"
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+static bool validateRequestIdentity(const String& value)
+{
+    return value == "yes" || value == "no" || value == "ifconfigured";
+}
+
+PassRefPtr<RTCOfferAnswerOptions> RTCOfferAnswerOptions::create(const Dictionary& options, ExceptionCode& ec)
+{
+    RefPtr<RTCOfferAnswerOptions> offerAnswerOptions = adoptRef(new RTCOfferAnswerOptions());
+    String requestIdentity;
+    if (!offerAnswerOptions->initialize(options)) {
+        // FIXME: https://webkit.org/b/129800
+        // According to the spec, the error is going to be defined yet, so let's use TYPE_MISMATCH_ERR for now.
+        ec = TYPE_MISMATCH_ERR;
+        return nullptr;
+    }
+
+    return offerAnswerOptions.release();
+}
+
+bool RTCOfferAnswerOptions::initialize(const Dictionary& options)
+{
+    String requestIdentity;
+    if (!options.isUndefinedOrNull() && (!options.get("requestIdentity", requestIdentity) || requestIdentity.isEmpty()))
+        return false;
+
+    if (validateRequestIdentity(requestIdentity))
+        m_requestIdentity = requestIdentity;
+
+    return true;
+}
+
+PassRefPtr<RTCOfferOptions> RTCOfferOptions::create(const Dictionary& options, ExceptionCode& ec)
+{
+    RefPtr<RTCOfferOptions> offerOptions = adoptRef(new RTCOfferOptions());
+    if (!offerOptions->initialize(options)) {
+        // FIXME: https://webkit.org/b/129800
+        // According to the spec, the error is going to be defined yet, so let's use TYPE_MISMATCH_ERR for now.
+        ec = TYPE_MISMATCH_ERR;
+        return nullptr;
+    }
+
+    return offerOptions.release();
+}
+
+bool RTCOfferOptions::initialize(const Dictionary& options)
+{
+    if (options.isUndefinedOrNull())
+        return true;
+
+    if (!RTCOfferAnswerOptions::initialize(options))
+        return false;
+
+    String offerToReceiveVideoStr;
+    bool numberConversionSuccess;
+    if (!options.get("offerToReceiveVideo", offerToReceiveVideoStr))
+        return false;
+
+    m_offerToReceiveVideo = offerToReceiveVideoStr.toInt64Strict(&numberConversionSuccess);
+    if (!numberConversionSuccess)
+        return false;
+
+    String offerToReceiveAudioStr;
+    if (!options.get("offerToReceiveAudio", offerToReceiveAudioStr))
+        return false;
+
+    m_offerToReceiveAudio = offerToReceiveAudioStr.toInt64Strict(&numberConversionSuccess);
+    if (!numberConversionSuccess)
+        return false;
+
+    bool voiceActivityDetection;
+    if (options.get("voiceActivityDetection", voiceActivityDetection))
+        m_voiceActivityDetection = voiceActivityDetection;
+
+    bool iceRestart;
+    if (options.get("iceRestart", iceRestart))
+        m_iceRestart = iceRestart;
+
+    return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)

Added: trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.h (0 => 165226)


--- trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCOfferAnswerOptions.h	2014-03-06 23:41:24 UTC (rev 165226)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 Apple 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 COMPUTER, INC. ``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 COMPUTER, INC. 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 RTCOfferAnswerOptions_h
+#define RTCOfferAnswerOptions_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "Dictionary.h"
+#include "ExceptionCode.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Dictionary;
+
+class RTCOfferAnswerOptions : public RefCounted<RTCOfferAnswerOptions> {
+public:
+    static PassRefPtr<RTCOfferAnswerOptions> create(const Dictionary&, ExceptionCode&);
+
+    const String& requestIdentity() const { return m_requestIdentity; }
+
+    virtual ~RTCOfferAnswerOptions() { }
+
+protected:
+    virtual bool initialize(const Dictionary&);
+    RTCOfferAnswerOptions()
+        : m_requestIdentity("ifconfigured")
+    {
+    }
+
+private:
+    String m_requestIdentity;
+};
+
+class RTCOfferOptions : public RTCOfferAnswerOptions {
+public:
+    static PassRefPtr<RTCOfferOptions> create(const Dictionary&, ExceptionCode&);
+
+    int64_t offerToReceiveVideo() const { return m_offerToReceiveVideo; }
+    int64_t offerToReceiveAudio() const { return m_offerToReceiveAudio; }
+    bool voiceActivityDetection() const { return m_voiceActivityDetection; }
+    bool iceRestart() const { return m_iceRestart; }
+
+    virtual ~RTCOfferOptions() { }
+
+private:
+    virtual bool initialize(const Dictionary&) override;
+    RTCOfferOptions()
+        : m_offerToReceiveVideo(0)
+        , m_offerToReceiveAudio(0)
+        , m_voiceActivityDetection(true)
+        , m_iceRestart(false)
+    {
+    }
+
+    int64_t m_offerToReceiveVideo;
+    int64_t m_offerToReceiveAudio;
+    bool m_voiceActivityDetection;
+    bool m_iceRestart;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // RTCOfferAnswerOptions_h

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (165225 => 165226)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2014-03-06 23:41:24 UTC (rev 165226)
@@ -42,7 +42,6 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
-#include "MediaConstraintsImpl.h"
 #include "MediaStreamEvent.h"
 #include "RTCConfiguration.h"
 #include "RTCDTMFSender.h"
@@ -52,6 +51,7 @@
 #include "RTCIceCandidate.h"
 #include "RTCIceCandidateDescriptor.h"
 #include "RTCIceCandidateEvent.h"
+#include "RTCOfferAnswerOptions.h"
 #include "RTCPeerConnectionErrorCallback.h"
 #include "RTCSessionDescription.h"
 #include "RTCSessionDescriptionCallback.h"
@@ -203,7 +203,7 @@
         (*stream)->removeObserver(this);
 }
 
-void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& mediaConstraints, ExceptionCode& ec)
+void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& offerOptions, ExceptionCode& ec)
 {
     if (m_signalingState == SignalingStateClosed) {
         ec = INVALID_STATE_ERR;
@@ -215,15 +215,20 @@
         return;
     }
 
-    RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaConstraints, ec);
-    if (ec)
+    RefPtr<RTCOfferOptions> options = RTCOfferOptions::create(offerOptions, ec);
+    if (ec) {
+        callOnMainThread([=] {
+            RefPtr<DOMError> error = DOMError::create("Invalid createOffer argument.");
+            errorCallback->handleEvent(error.get());
+        });
         return;
+    }
 
     RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
-    m_peerHandler->createOffer(request.release(), constraints);
+    m_peerHandler->createOffer(request.release(), options.release());
 }
 
-void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& mediaConstraints, ExceptionCode& ec)
+void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& answerOptions, ExceptionCode& ec)
 {
     if (m_signalingState == SignalingStateClosed) {
         ec = INVALID_STATE_ERR;
@@ -235,12 +240,17 @@
         return;
     }
 
-    RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaConstraints, ec);
-    if (ec)
+    RefPtr<RTCOfferAnswerOptions> options = RTCOfferAnswerOptions::create(answerOptions, ec);
+    if (ec) {
+        callOnMainThread([=] {
+            RefPtr<DOMError> error = DOMError::create("Invalid createAnswer argument.");
+            errorCallback->handleEvent(error.get());
+        });
         return;
+    }
 
     RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequestImpl::create(scriptExecutionContext(), successCallback, errorCallback);
-    m_peerHandler->createAnswer(request.release(), constraints.release());
+    m_peerHandler->createAnswer(request.release(), options.release());
 }
 
 bool RTCPeerConnection::checkStateForLocalDescription(RTCSessionDescription* localDescription)

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (165225 => 165226)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2014-03-06 23:41:24 UTC (rev 165226)
@@ -48,7 +48,6 @@
 
 namespace WebCore {
 
-class MediaConstraints;
 class MediaStreamTrack;
 class RTCConfiguration;
 class RTCDTMFSender;
@@ -64,9 +63,9 @@
     static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext&, const Dictionary& rtcConfiguration, ExceptionCode&);
     ~RTCPeerConnection();
 
-    void createOffer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, const Dictionary& mediaConstraints, ExceptionCode&);
+    void createOffer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, const Dictionary& offerOptions, ExceptionCode&);
 
-    void createAnswer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, const Dictionary& mediaConstraints, ExceptionCode&);
+    void createAnswer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, const Dictionary& answerOptions, ExceptionCode&);
 
     void setLocalDescription(PassRefPtr<RTCSessionDescription>, PassRefPtr<VoidCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, ExceptionCode&);
     PassRefPtr<RTCSessionDescription> localDescription(ExceptionCode&);

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl (165225 => 165226)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl	2014-03-06 23:41:24 UTC (rev 165226)
@@ -39,9 +39,9 @@
     EventTarget,
     InterfaceName=webkitRTCPeerConnection,
 ] interface RTCPeerConnection {
-    [RaisesException] void createOffer(RTCSessionDescriptionCallback successCallback, [Default=Undefined] optional RTCPeerConnectionErrorCallback failureCallback, optional Dictionary mediaConstraints);
+    [RaisesException] void createOffer(RTCSessionDescriptionCallback successCallback, [Default=Undefined] optional RTCPeerConnectionErrorCallback failureCallback, optional Dictionary offerOptions);
 
-    [RaisesException] void createAnswer(RTCSessionDescriptionCallback successCallback, [Default=Undefined] optional RTCPeerConnectionErrorCallback failureCallback, optional Dictionary mediaConstraints);
+    [RaisesException] void createAnswer(RTCSessionDescriptionCallback successCallback, [Default=Undefined] optional RTCPeerConnectionErrorCallback failureCallback, optional Dictionary answerOptions);
 
     [RaisesException] void setLocalDescription(RTCSessionDescription description, [Default=Undefined] optional VoidCallback successCallback, [Default=Undefined] optional RTCPeerConnectionErrorCallback failureCallback);
     [GetterRaisesException] readonly attribute RTCSessionDescription localDescription;

Modified: trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h (165225 => 165226)


--- trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h	2014-03-06 23:41:24 UTC (rev 165226)
@@ -39,12 +39,13 @@
 
 namespace WebCore {
 
-class MediaConstraints;
 class MediaStreamSource;
 class RTCConfiguration;
 class RTCDTMFSenderHandler;
 class RTCDataChannelHandler;
 class RTCIceCandidateDescriptor;
+class RTCOfferOptions;
+class RTCOfferAnswerOptions;
 class RTCPeerConnectionHandler;
 class RTCPeerConnectionHandlerClient;
 class RTCSessionDescriptionDescriptor;
@@ -82,8 +83,8 @@
 
     virtual bool initialize(PassRefPtr<RTCConfiguration>) = 0;
 
-    virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) = 0;
-    virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) = 0;
+    virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<RTCOfferOptions>) = 0;
+    virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<RTCOfferAnswerOptions>) = 0;
     virtual void setLocalDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) = 0;
     virtual void setRemoteDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) = 0;
     virtual PassRefPtr<RTCSessionDescriptionDescriptor> localDescription() = 0;

Modified: trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp (165225 => 165226)


--- trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.cpp	2014-03-06 23:41:24 UTC (rev 165226)
@@ -58,28 +58,15 @@
     return true;
 }
 
-void RTCPeerConnectionHandlerMock::createOffer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)
+void RTCPeerConnectionHandlerMock::createOffer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<RTCOfferOptions>)
 {
-    String succeedValue;
-    RefPtr<SessionRequestNotifier> notifier;
-    if (constraints->getMandatoryConstraintValue("succeed", succeedValue) && succeedValue == "false")
-        notifier = adoptRef(new SessionRequestNotifier(request, 0, RTCPeerConnectionHandler::incompatibleConstraintsErrorName()));
-    else
-        notifier = adoptRef(new SessionRequestNotifier(request, RTCSessionDescriptionDescriptor::create("offer", "local")));
-
+    RefPtr<SessionRequestNotifier> notifier = adoptRef(new SessionRequestNotifier(request, RTCSessionDescriptionDescriptor::create("offer", "local")));
     m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
 }
 
-void RTCPeerConnectionHandlerMock::createAnswer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)
+void RTCPeerConnectionHandlerMock::createAnswer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<RTCOfferAnswerOptions>)
 {
-    RefPtr<SessionRequestNotifier> notifier;
-    // We can only create an answer if we have already had an offer and the remote session description is stored.
-    String succeedValue;
-    if (constraints->getMandatoryConstraintValue("succeed", succeedValue) && succeedValue == "false")
-        notifier = adoptRef(new SessionRequestNotifier(request, 0, RTCPeerConnectionHandler::incompatibleConstraintsErrorName()));
-    else
-        notifier = adoptRef(new SessionRequestNotifier(request, RTCSessionDescriptionDescriptor::create("answer", "local")));
-
+    RefPtr<SessionRequestNotifier> notifier = adoptRef(new SessionRequestNotifier(request, RTCSessionDescriptionDescriptor::create("answer", "local")));
     m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
 }
 

Modified: trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h (165225 => 165226)


--- trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h	2014-03-06 23:40:48 UTC (rev 165225)
+++ trunk/Source/WebCore/platform/mock/RTCPeerConnectionHandlerMock.h	2014-03-06 23:41:24 UTC (rev 165226)
@@ -43,8 +43,8 @@
 
     virtual bool initialize(PassRefPtr<RTCConfiguration>) override;
 
-    virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) override;
-    virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) override;
+    virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<RTCOfferOptions>) override;
+    virtual void createAnswer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<RTCOfferAnswerOptions>) override;
     virtual void setLocalDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) override;
     virtual void setRemoteDescription(PassRefPtr<RTCVoidRequest>, PassRefPtr<RTCSessionDescriptionDescriptor>) override;
     virtual PassRefPtr<RTCSessionDescriptionDescriptor> localDescription() override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to