Title: [235551] trunk/Source/WebCore
Revision
235551
Author
[email protected]
Date
2018-08-31 08:50:10 -0700 (Fri, 31 Aug 2018)

Log Message

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:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235550 => 235551)


--- trunk/Source/WebCore/ChangeLog	2018-08-31 15:29:42 UTC (rev 235550)
+++ trunk/Source/WebCore/ChangeLog	2018-08-31 15:50:10 UTC (rev 235551)
@@ -1,3 +1,17 @@
+2018-08-31  Youenn Fablet  <[email protected]>
+
+        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  <[email protected]>
 
         [MediaStream] Remove AVMediaCaptureSource

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (235550 => 235551)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2018-08-31 15:29:42 UTC (rev 235550)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2018-08-31 15:50:10 UTC (rev 235551)
@@ -26,6 +26,7 @@
 
 #if USE(LIBWEBRTC)
 
+#include "LibWebRTCObservers.h"
 #include "LibWebRTCProvider.h"
 #include "PeerConnectionBackend.h"
 #include "RTCRtpReceiver.h"
@@ -154,48 +155,6 @@
     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 @@
     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;
 

Added: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h (0 => 235551)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h	2018-08-31 15:50:10 UTC (rev 235551)
@@ -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)

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (235550 => 235551)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-08-31 15:29:42 UTC (rev 235550)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-08-31 15:50:10 UTC (rev 235551)
@@ -7228,6 +7228,7 @@
 		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>"; };
@@ -16824,6 +16825,7 @@
 				5CDD83401E43253D00621E92 /* LibWebRTCDataChannelHandler.h */,
 				417612AB1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.cpp */,
 				417612AC1E3A993B00C3D81D /* LibWebRTCMediaEndpoint.h */,
+				415A3B732138E264001B4BAA /* LibWebRTCObservers.h */,
 				417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */,
 				417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */,
 			);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to