Title: [165247] trunk/Source/WebCore
Revision
165247
Author
[email protected]
Date
2014-03-06 21:41:16 -0800 (Thu, 06 Mar 2014)

Log Message

[WebRTC] Updating RTCIceServer to match spec
https://bugs.webkit.org/show_bug.cgi?id=129844

Reviewed by Eric Carlson.

Move RTCIceServer from RTCConfiguration to its own file.

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::validateIceServerURL):
(WebCore::processIceServer):
* platform/mediastream/RTCConfiguration.h:
(WebCore::RTCConfiguration::iceServers):
* platform/mediastream/RTCIceServer.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (165246 => 165247)


--- trunk/Source/WebCore/ChangeLog	2014-03-07 05:06:04 UTC (rev 165246)
+++ trunk/Source/WebCore/ChangeLog	2014-03-07 05:41:16 UTC (rev 165247)
@@ -1,3 +1,19 @@
+2014-03-06  Thiago de Barros Lacerda  <[email protected]>
+
+        [WebRTC] Updating RTCIceServer to match spec
+        https://bugs.webkit.org/show_bug.cgi?id=129844
+
+        Reviewed by Eric Carlson.
+
+        Move RTCIceServer from RTCConfiguration to its own file.
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::validateIceServerURL):
+        (WebCore::processIceServer):
+        * platform/mediastream/RTCConfiguration.h:
+        (WebCore::RTCConfiguration::iceServers):
+        * platform/mediastream/RTCIceServer.h: Added.
+
 2014-03-06  Hyowon Kim  <[email protected]>
 
         [EFL] Move EvasGL classes from WebKit to WebCore namespace.

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (165246 => 165247)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2014-03-07 05:06:04 UTC (rev 165246)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2014-03-07 05:41:16 UTC (rev 165247)
@@ -66,13 +66,12 @@
 
 namespace WebCore {
 
-static bool appendIceServer(const String& iceURL, const String& credential, const String& username, RTCConfiguration* rtcConfiguration)
+static bool validateIceServerURL(const String& iceURL)
 {
     URL url(URL(), iceURL);
     if (url.isEmpty() || !url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun")))
         return false;
 
-    rtcConfiguration->appendServer(RTCIceServer::create(url, credential, username));
     return true;
 }
 
@@ -92,19 +91,23 @@
     // So we convert to a string always, which converts a sequence to a string in the format: "foo, bar, ..",
     // then checking for a comma in the string assures that a string was a sequence and then we convert
     // it to a sequence safely.
+    if (urlString.isEmpty())
+        return INVALID_ACCESS_ERR;
+
     if (urlString.find(',') != notFound && iceServer.get("urls", urlsList) && urlsList.size()) {
         for (auto iter = urlsList.begin(); iter != urlsList.end(); ++iter) {
-            if (!appendIceServer((*iter), credential, username, rtcConfiguration))
+            if (!validateIceServerURL(*iter))
                 return INVALID_ACCESS_ERR;
         }
+    } else {
+        if (!validateIceServerURL(urlString))
+            return INVALID_ACCESS_ERR;
 
-        return 0;
+        urlsList.append(urlString);
     }
 
-    if (!urlString.isEmpty() && appendIceServer(urlString, credential, username, rtcConfiguration))
-        return 0;
-
-    return INVALID_ACCESS_ERR;
+    rtcConfiguration->appendServer(RTCIceServer::create(urlsList, credential, username));
+    return 0;
 }
 
 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionCode& ec)

Modified: trunk/Source/WebCore/platform/mediastream/RTCConfiguration.h (165246 => 165247)


--- trunk/Source/WebCore/platform/mediastream/RTCConfiguration.h	2014-03-07 05:06:04 UTC (rev 165246)
+++ trunk/Source/WebCore/platform/mediastream/RTCConfiguration.h	2014-03-07 05:41:16 UTC (rev 165247)
@@ -33,7 +33,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
-#include "URL.h"
+#include "RTCIceServer.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -41,31 +41,6 @@
 
 namespace WebCore {
 
-class RTCIceServer : public RefCounted<RTCIceServer> {
-public:
-    static PassRefPtr<RTCIceServer> create(const URL& uri, const String& credential, const String& username)
-    {
-        return adoptRef(new RTCIceServer(uri, credential, username));
-    }
-    virtual ~RTCIceServer() { }
-
-    const URL& uri() { return m_uri; }
-    const String& credential() { return m_credential; }
-    const String& username() { return m_username; }
-
-private:
-    RTCIceServer(const URL& uri, const String& credential, const String& username)
-        : m_uri(uri)
-        , m_credential(credential)
-        , m_username(username)
-    {
-    }
-
-    URL m_uri;
-    String m_credential;
-    String m_username;
-};
-
 class RTCConfiguration : public RefCounted<RTCConfiguration> {
 public:
     static PassRefPtr<RTCConfiguration> create() { return adoptRef(new RTCConfiguration()); }
@@ -74,12 +49,14 @@
     void appendServer(PassRefPtr<RTCIceServer> server) { m_servers.append(server); }
     size_t numberOfServers() { return m_servers.size(); }
     RTCIceServer* server(size_t index) { return m_servers[index].get(); }
+
     const String& iceTransports() const { return m_iceTransports; }
     void setIceTransports(const String& iceTransports)
     {
         if (iceTransports == "none" || iceTransports == "relay" || iceTransports == "all")
             m_iceTransports = iceTransports;
     }
+
     const String& requestIdentity() const { return m_requestIdentity; }
     void setRequestIdentity(const String& requestIdentity)
     {
@@ -87,6 +64,8 @@
             m_requestIdentity = requestIdentity;
     }
 
+    Vector<RefPtr<RTCIceServer>> iceServers() const { return m_servers; }
+
  private:
     RTCConfiguration()
         : m_iceTransports("all")

Added: trunk/Source/WebCore/platform/mediastream/RTCIceServer.h (0 => 165247)


--- trunk/Source/WebCore/platform/mediastream/RTCIceServer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/RTCIceServer.h	2014-03-07 05:41:16 UTC (rev 165247)
@@ -0,0 +1,67 @@
+/*
+ * 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 RTCIceServer_h
+#define RTCIceServer_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class RTCIceServer : public RefCounted<RTCIceServer> {
+public:
+    static PassRefPtr<RTCIceServer> create(const Vector<String>& urls, const String& credential, const String& username)
+    {
+        return adoptRef(new RTCIceServer(urls, credential, username));
+    }
+    virtual ~RTCIceServer() { }
+
+    const Vector<String>& urls() { return m_urls; }
+    const String& credential() { return m_credential; }
+    const String& username() { return m_username; }
+
+private:
+    RTCIceServer(const Vector<String>& urls, const String& credential, const String& username)
+        : m_urls(urls)
+        , m_credential(credential)
+        , m_username(username)
+    {
+    }
+
+    Vector<String> m_urls;
+    String m_credential;
+    String m_username;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // RTCIceServer_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to