WebKit Bugzilla
Attachment 348601 Details for
Bug 189182
: Move LibWebRTCMediaEndpoint data channel code to LibWebRTCDataChannelHandler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189182-20180830214519.patch (text/plain), 9.81 KB, created by
youenn fablet
on 2018-08-30 21:45:20 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2018-08-30 21:45:20 PDT
Size:
9.81 KB
patch
obsolete
>Subversion Revision: 235524 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a5427ec267eb37f0e9f0df6d4d0d657968f680a4..4d1fbc8bb7731ea39b324eb23c8458439ad6eb25 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2018-08-30 Youenn Fablet <youenn@apple.com> >+ >+ Move LibWebRTCMediaEndpoint data channel code to LibWebRTCDataChannelHandler >+ https://bugs.webkit.org/show_bug.cgi?id=189182 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Moving data channel code outside of LibWebRTCMediaEndpoint. >+ This will allow future development to support unified plan. >+ No change of behavior. >+ >+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: >+ (WebCore::LibWebRTCDataChannelHandler::fromRTCDataChannelInit): >+ (WebCore::LibWebRTCDataChannelHandler::channelEvent): >+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: >+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: >+ (WebCore::LibWebRTCMediaEndpoint::createDataChannel): >+ (WebCore::LibWebRTCMediaEndpoint::OnDataChannel): >+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: >+ > 2018-08-30 Olivia Barnett <obarnett@apple.com> > > REGRESSION(r235489): fast/dom/navigator-detached-no-crash.html crashes under Navigator::share >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp >index 6360cd8b06e732caeb80631c89a918ceeb912c68..bcfe2a45f0e894d820dbf2b69c7a5378c2aaeeea 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp >@@ -27,11 +27,64 @@ > > #if USE(LIBWEBRTC) > >+#include "EventNames.h" > #include "RTCDataChannel.h" >+#include "RTCDataChannelEvent.h" > #include <wtf/MainThread.h> > > namespace WebCore { > >+webrtc::DataChannelInit LibWebRTCDataChannelHandler::fromRTCDataChannelInit(const RTCDataChannelInit& options) >+{ >+ webrtc::DataChannelInit init; >+ if (options.ordered) >+ init.ordered = *options.ordered; >+ if (options.maxPacketLifeTime) >+ init.maxRetransmitTime = *options.maxPacketLifeTime; >+ if (options.maxRetransmits) >+ init.maxRetransmits = *options.maxRetransmits; >+ init.protocol = options.protocol.utf8().data(); >+ if (options.negotiated) >+ init.negotiated = *options.negotiated; >+ if (options.id) >+ init.id = *options.id; >+ return init; >+} >+ >+static inline String fromStdString(const std::string& value) >+{ >+ return String::fromUTF8(value.data(), value.length()); >+} >+ >+Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent(ScriptExecutionContext& context, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel) >+{ >+ auto protocol = dataChannel->protocol(); >+ auto label = dataChannel->label(); >+ >+ RTCDataChannelInit init; >+ init.ordered = dataChannel->ordered(); >+ init.maxPacketLifeTime = dataChannel->maxRetransmitTime(); >+ init.maxRetransmits = dataChannel->maxRetransmits(); >+ init.protocol = fromStdString(protocol); >+ init.negotiated = dataChannel->negotiated(); >+ init.id = dataChannel->id(); >+ >+ bool isOpened = dataChannel->state() == webrtc::DataChannelInterface::kOpen; >+ >+ auto handler = std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel)); >+ auto channel = RTCDataChannel::create(context, WTFMove(handler), fromStdString(label), WTFMove(init)); >+ >+ if (isOpened) { >+ callOnMainThread([channel = channel.copyRef()] { >+ // FIXME: We should be able to write channel->didChangeReadyState(...) >+ RTCDataChannelHandlerClient& client = channel.get(); >+ client.didChangeReadyState(RTCDataChannelState::Open); >+ }); >+ } >+ >+ return RTCDataChannelEvent::create(eventNames().datachannelEvent, Event::CanBubble::No, Event::IsCancelable::No, WTFMove(channel)); >+} >+ > LibWebRTCDataChannelHandler::~LibWebRTCDataChannelHandler() > { > if (m_client) >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h >index 55ce825c45da783d504d7d448042ec6fdb9a888f..2aa1180daefc78f066fb714f76e956640b8c1961 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h >@@ -36,15 +36,25 @@ > > #pragma GCC diagnostic pop > >+namespace webrtc { >+struct DataChannelInit; >+} >+ > namespace WebCore { > >+class RTCDataChannelEvent; > class RTCDataChannelHandlerClient; >+struct RTCDataChannelInit; >+class ScriptExecutionContext; > > class LibWebRTCDataChannelHandler final : public RTCDataChannelHandler, private webrtc::DataChannelObserver { > public: > explicit LibWebRTCDataChannelHandler(rtc::scoped_refptr<webrtc::DataChannelInterface>&& channel) : m_channel(WTFMove(channel)) { ASSERT(m_channel); } > ~LibWebRTCDataChannelHandler(); > >+ static webrtc::DataChannelInit fromRTCDataChannelInit(const RTCDataChannelInit&); >+ static Ref<RTCDataChannelEvent> channelEvent(ScriptExecutionContext&, rtc::scoped_refptr<webrtc::DataChannelInterface>&&); >+ > private: > // RTCDataChannelHandler API > void setClient(RTCDataChannelHandlerClient&) final; >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >index bf120d029b980c3528feb04095aba0e924a76ad5..7f675f39ee09089d4213e7304a4df0fc38d29e9c 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >@@ -736,65 +736,18 @@ void LibWebRTCMediaEndpoint::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverIn > > std::unique_ptr<RTCDataChannelHandler> LibWebRTCMediaEndpoint::createDataChannel(const String& label, const RTCDataChannelInit& options) > { >- ASSERT(m_backend); >- >- webrtc::DataChannelInit init; >- if (options.ordered) >- init.ordered = *options.ordered; >- if (options.maxPacketLifeTime) >- init.maxRetransmitTime = *options.maxPacketLifeTime; >- if (options.maxRetransmits) >- init.maxRetransmits = *options.maxRetransmits; >- init.protocol = options.protocol.utf8().data(); >- if (options.negotiated) >- init.negotiated = *options.negotiated; >- if (options.id) >- init.id = *options.id; >- >+ auto init = LibWebRTCDataChannelHandler::fromRTCDataChannelInit(options); > auto channel = m_backend->CreateDataChannel(label.utf8().data(), &init); >- if (!channel) >- return nullptr; >- >- return std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(channel)); >-} >- >-void LibWebRTCMediaEndpoint::addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel) >-{ >- auto protocol = dataChannel->protocol(); >- auto label = dataChannel->label(); >- >- RTCDataChannelInit init; >- init.ordered = dataChannel->ordered(); >- init.maxPacketLifeTime = dataChannel->maxRetransmitTime(); >- init.maxRetransmits = dataChannel->maxRetransmits(); >- init.protocol = fromStdString(protocol); >- init.negotiated = dataChannel->negotiated(); >- init.id = dataChannel->id(); >- >- bool isOpened = dataChannel->state() == webrtc::DataChannelInterface::kOpen; >- >- auto handler = std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel)); >- ASSERT(m_peerConnectionBackend.connection().scriptExecutionContext()); >- auto channel = RTCDataChannel::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), WTFMove(handler), fromStdString(label), WTFMove(init)); >- >- if (isOpened) { >- callOnMainThread([channel = channel.copyRef()] { >- // FIXME: We should be able to write channel->didChangeReadyState(...) >- RTCDataChannelHandlerClient& client = channel.get(); >- client.didChangeReadyState(RTCDataChannelState::Open); >- }); >- } >- >- m_peerConnectionBackend.connection().fireEvent(RTCDataChannelEvent::create(eventNames().datachannelEvent, >- Event::CanBubble::No, Event::IsCancelable::No, WTFMove(channel))); >+ return channel ? std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(channel)) : nullptr; > } > > void LibWebRTCMediaEndpoint::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel) > { >- callOnMainThread([protectedThis = makeRef(*this), dataChannel = WTFMove(dataChannel)] { >+ callOnMainThread([protectedThis = makeRef(*this), dataChannel = WTFMove(dataChannel)]() mutable { > if (protectedThis->isStopped()) > return; >- protectedThis->addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>(dataChannel)); >+ auto& connection = protectedThis->m_peerConnectionBackend.connection(); >+ connection.fireEvent(LibWebRTCDataChannelHandler::channelEvent(*connection.scriptExecutionContext(), WTFMove(dataChannel))); > }); > } > >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h >index 52331681bf78fa267b5d1db0de4e21a263cf3659..d7a263c5eb3dd70300a7051e92cb70cf80c12939 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h >@@ -124,7 +124,6 @@ private: > void addRemoteStream(webrtc::MediaStreamInterface&); > void addRemoteTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface>&&, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&); > void removeRemoteStream(webrtc::MediaStreamInterface&); >- void addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>&&); > > void OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&) final; > void gatherStatsForLogging();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189182
:
348593
| 348601