Move session observers outside LibWebRTCMediaEndpoint
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2018 15:50:10 +0000 (15:50 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2018 15:50:10 +0000 (15:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189181

Reviewed by Alejandro G. Castro.

Move classes of LibWebRTCMediaEndpoint to a separate file.
No change of behavior.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
* Modules/mediastream/libwebrtc/LibWebRTCObservers.h: Added.
* WebCore.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj

index 69351f4..2823836 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-31  Youenn Fablet  <youenn@apple.com>
+
+        Move session observers outside LibWebRTCMediaEndpoint
+        https://bugs.webkit.org/show_bug.cgi?id=189181
+
+        Reviewed by Alejandro G. Castro.
+
+        Move classes of LibWebRTCMediaEndpoint to a separate file.
+        No change of behavior.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCObservers.h: Added.
+        * WebCore.xcodeproj/project.pbxproj:
+
 2018-08-31  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Remove AVMediaCaptureSource
index 5233168..9b51d36 100644 (file)
@@ -26,6 +26,7 @@
 
 #if USE(LIBWEBRTC)
 
+#include "LibWebRTCObservers.h"
 #include "LibWebRTCProvider.h"
 #include "PeerConnectionBackend.h"
 #include "RTCRtpReceiver.h"
@@ -154,48 +155,6 @@ private:
     Seconds statsLogInterval(int64_t) const;
 #endif
 
-    class CreateSessionDescriptionObserver final : public webrtc::CreateSessionDescriptionObserver {
-    public:
-        explicit CreateSessionDescriptionObserver(LibWebRTCMediaEndpoint &endpoint) : m_endpoint(endpoint) { }
-
-        void OnSuccess(webrtc::SessionDescriptionInterface* sessionDescription) final { m_endpoint.createSessionDescriptionSucceeded(std::unique_ptr<webrtc::SessionDescriptionInterface>(sessionDescription)); }
-        void OnFailure(const std::string& error) final { m_endpoint.createSessionDescriptionFailed(error); }
-
-        void AddRef() const { m_endpoint.AddRef(); }
-        rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
-
-    private:
-        LibWebRTCMediaEndpoint& m_endpoint;
-    };
-
-    class SetLocalSessionDescriptionObserver final : public webrtc::SetSessionDescriptionObserver {
-    public:
-        explicit SetLocalSessionDescriptionObserver(LibWebRTCMediaEndpoint &endpoint) : m_endpoint(endpoint) { }
-
-        void OnSuccess() final { m_endpoint.setLocalSessionDescriptionSucceeded(); }
-        void OnFailure(const std::string& error) final { m_endpoint.setLocalSessionDescriptionFailed(error); }
-
-        void AddRef() const { m_endpoint.AddRef(); }
-        rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
-
-    private:
-        LibWebRTCMediaEndpoint& m_endpoint;
-    };
-
-    class SetRemoteSessionDescriptionObserver final : public webrtc::SetSessionDescriptionObserver {
-    public:
-        explicit SetRemoteSessionDescriptionObserver(LibWebRTCMediaEndpoint &endpoint) : m_endpoint(endpoint) { }
-
-        void OnSuccess() final { m_endpoint.setRemoteSessionDescriptionSucceeded(); }
-        void OnFailure(const std::string& error) final { m_endpoint.setRemoteSessionDescriptionFailed(error); }
-
-        void AddRef() const { m_endpoint.AddRef(); }
-        rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
-
-    private:
-        LibWebRTCMediaEndpoint& m_endpoint;
-    };
-
     class StatsCollector : public webrtc::RTCStatsCollectorCallback {
     public:
         static rtc::scoped_refptr<StatsCollector> create(Ref<LibWebRTCMediaEndpoint>&& endpoint, const DeferredPromise& promise, MediaStreamTrack* track) { return new rtc::RefCountedObject<StatsCollector>(WTFMove(endpoint), promise, track); }
@@ -214,9 +173,14 @@ private:
     webrtc::PeerConnectionFactoryInterface& m_peerConnectionFactory;
     rtc::scoped_refptr<webrtc::PeerConnectionInterface> m_backend;
 
-    CreateSessionDescriptionObserver m_createSessionDescriptionObserver;
-    SetLocalSessionDescriptionObserver m_setLocalSessionDescriptionObserver;
-    SetRemoteSessionDescriptionObserver m_setRemoteSessionDescriptionObserver;
+    friend CreateSessionDescriptionObserver<LibWebRTCMediaEndpoint>;
+    friend SetLocalSessionDescriptionObserver<LibWebRTCMediaEndpoint>;
+    friend SetRemoteSessionDescriptionObserver<LibWebRTCMediaEndpoint>;
+
+    CreateSessionDescriptionObserver<LibWebRTCMediaEndpoint> m_createSessionDescriptionObserver;
+    SetLocalSessionDescriptionObserver<LibWebRTCMediaEndpoint> m_setLocalSessionDescriptionObserver;
+    SetRemoteSessionDescriptionObserver<LibWebRTCMediaEndpoint> m_setRemoteSessionDescriptionObserver;
+
     HashMap<webrtc::MediaStreamInterface*, RefPtr<MediaStream>> m_streams;
     HashMap<RTCRtpSender*, rtc::scoped_refptr<webrtc::RtpSenderInterface>> m_senders;
 
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h
new file mode 100644 (file)
index 0000000..526a118
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2018 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 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.
+ */
+
+#pragma once
+
+#if USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+#include <webrtc/api/peerconnectioninterface.h>
+
+#pragma GCC diagnostic pop
+
+namespace WebCore {
+
+template<typename Endpoint>
+class CreateSessionDescriptionObserver final : public webrtc::CreateSessionDescriptionObserver {
+public:
+    explicit CreateSessionDescriptionObserver(Endpoint &endpoint)
+        : m_endpoint(endpoint)
+    {
+    }
+
+    void OnSuccess(webrtc::SessionDescriptionInterface* sessionDescription) final { m_endpoint.createSessionDescriptionSucceeded(std::unique_ptr<webrtc::SessionDescriptionInterface>(sessionDescription)); }
+    void OnFailure(const std::string& error) final { m_endpoint.createSessionDescriptionFailed(error); }
+
+    void AddRef() const { m_endpoint.AddRef(); }
+    rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
+
+private:
+    Endpoint& m_endpoint;
+};
+
+template<typename Endpoint>
+class SetLocalSessionDescriptionObserver final : public webrtc::SetSessionDescriptionObserver {
+public:
+    explicit SetLocalSessionDescriptionObserver(Endpoint &endpoint)
+        : m_endpoint(endpoint)
+    {
+    }
+
+    void OnSuccess() final { m_endpoint.setLocalSessionDescriptionSucceeded(); }
+    void OnFailure(const std::string& error) final { m_endpoint.setLocalSessionDescriptionFailed(error); }
+
+    void AddRef() const { m_endpoint.AddRef(); }
+    rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
+
+private:
+    Endpoint& m_endpoint;
+};
+
+template<typename Endpoint>
+class SetRemoteSessionDescriptionObserver final : public webrtc::SetSessionDescriptionObserver {
+public:
+    explicit SetRemoteSessionDescriptionObserver(Endpoint &endpoint)
+        : m_endpoint(endpoint)
+    {
+    }
+
+    void OnSuccess() final { m_endpoint.setRemoteSessionDescriptionSucceeded(); }
+    void OnFailure(const std::string& error) final { m_endpoint.setRemoteSessionDescriptionFailed(error); }
+
+    void AddRef() const { m_endpoint.AddRef(); }
+    rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); }
+
+private:
+    Endpoint& m_endpoint;
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
index 8205755..3c65e97 100644 (file)
                415747441E38699E00E914D8 /* LibWebRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCProvider.h; path = libwebrtc/LibWebRTCProvider.h; sourceTree = "<group>"; };
                4157EBF81E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockLibWebRTCPeerConnection.h; sourceTree = "<group>"; };
                4157EBF91E3AB06800AC9FE9 /* MockLibWebRTCPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockLibWebRTCPeerConnection.cpp; sourceTree = "<group>"; };
+               415A3B732138E264001B4BAA /* LibWebRTCObservers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCObservers.h; path = libwebrtc/LibWebRTCObservers.h; sourceTree = "<group>"; };
                415CDAF61E6CE0D3004F11EE /* JSMediaStreamTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaStreamTrackCustom.cpp; sourceTree = "<group>"; };
                41614A761DA64236004AD06F /* HTTPHeaderValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderValues.cpp; sourceTree = "<group>"; };
                41614A771DA64236004AD06F /* HTTPHeaderValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderValues.h; sourceTree = "<group>"; };
                                5CDD83401E43253D00621E92 /* LibWebRTCDataChannelHandler.h */,
                                417612AB1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.cpp */,
                                417612AC1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.h */,
+                               415A3B732138E264001B4BAA /* LibWebRTCObservers.h */,
                                417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */,
                                417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */,
                        );