WebKit Bugzilla
Attachment 348938 Details for
Bug 189281
: Move replaceTrack logic to LibWebRTCPeerConnectionBackend
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-189281-20180905103912.patch (text/plain), 10.61 KB, created by
youenn fablet
on 2018-09-05 10:39:13 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2018-09-05 10:39:13 PDT
Size:
10.61 KB
patch
obsolete
>Subversion Revision: 235670 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 14c2e5f6db3ae028e3ccbb808cfcbc2a3147c07a..f9bda969e0dc0689da8cdeb8f9a468712eb11637 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2018-09-05 Youenn Fablet <youenn@apple.com> >+ >+ Move replaceTrack logic to LibWebRTCPeerConnectionBackend >+ https://bugs.webkit.org/show_bug.cgi?id=189281 >+ >+ Reviewed by Eric Carlson. >+ >+ Move replaceTrack handling code from RTCPeerConnection to LibWebRTCPeerConnectionBackend. >+ This makes the logic easier to understand. >+ Future refactoring will further try to put more handling in RTCRtpSenderBackend. >+ No change of behavior. >+ >+ * Modules/mediastream/RTCPeerConnection.cpp: >+ * Modules/mediastream/RTCPeerConnection.h: >+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: >+ (WebCore::tryUpdatingTrackSource): >+ (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): >+ (WebCore::LibWebRTCPeerConnectionBackend::enqueueReplaceTrackTask): >+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: >+ * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp: >+ (WebCore::LibWebRTCRtpSenderBackend::replaceTrack): >+ > 2018-09-05 Youenn Fablet <youenn@apple.com> > > ActiveDOMObjects should be GC collectable as soon as their document is being stopped >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >index 2a5a13e0a088688bdb2ecd3a4d802b6971800e51..4ad4f7cbf6a7749cebdf72e741a041152beec2ed 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp >@@ -530,26 +530,6 @@ void RTCPeerConnection::fireEvent(Event& event) > dispatchEvent(event); > } > >-void RTCPeerConnection::enqueueReplaceTrackTask(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromiseDeferred<void>&& promise) >-{ >- scriptExecutionContext()->postTask([protectedThis = makeRef(*this), protectedSender = makeRef(sender), promise = WTFMove(promise), withTrack = WTFMove(withTrack)](ScriptExecutionContext&) mutable { >- if (protectedThis->isClosed()) >- return; >- >- if (!withTrack) { >- protectedSender->setTrackToNull(); >- promise.resolve(); >- return; >- } >- >- bool hasTrack = protectedSender->track(); >- protectedSender->setTrack(withTrack.releaseNonNull()); >- if (!hasTrack) >- protectedThis->m_backend->addTrack(protectedSender.ptr(), *protectedSender->track(), { }); >- promise.resolve(); >- }); >-} >- > void RTCPeerConnection::dispatchEvent(Event& event) > { > DEBUG_LOG(LOGIDENTIFIER, "dispatching '", event.type(), "'"); >diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >index 84eb9bc9a55a5a7174c7e0fb1e7e94e7d315d2d6..35c1edf0d625009327c375eacad666eea54d10d6 100644 >--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h >@@ -150,8 +150,6 @@ public: > void disableICECandidateFiltering() { m_backend->disableICECandidateFiltering(); } > void enableICECandidateFiltering() { m_backend->enableICECandidateFiltering(); } > >- void enqueueReplaceTrackTask(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&); >- > void clearController() { m_controller = nullptr; } > > // ActiveDOMObject. >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >index 461eb5ad2b46f387c38c81d18e2404989a535f78..6205a02c4254bdebbda9fa3b1985e2946fefda46 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >@@ -408,47 +408,69 @@ static inline bool updateTrackSource(Source& source, MediaStreamTrack* track) > return source->setSource(track->privateTrack()); > } > >-void LibWebRTCPeerConnectionBackend::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& track, DOMPromiseDeferred<void>&& promise) >+template<typename Source> >+static inline bool tryUpdatingTrackSource(MediaStreamTrack& currentTrack, MediaStreamTrack* newTrack, const Vector<Source>& sources) > { >- ASSERT(sender.track()); >+ for (auto& source : sources) { >+ if (&source->source() == ¤tTrack.privateTrack()) { >+ if (!updateTrackSource(source, newTrack)) >+ return false; >+ return true; >+ } >+ } >+ return false; >+} > >+void LibWebRTCPeerConnectionBackend::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& track, DOMPromiseDeferred<void>&& promise) >+{ > auto* currentTrack = sender.track(); > >- ASSERT(!track || currentTrack->source().type() == track->source().type()); >- switch (currentTrack->source().type()) { >- case RealtimeMediaSource::Type::None: >- ASSERT_NOT_REACHED(); >- promise.reject(InvalidModificationError); >- break; >- case RealtimeMediaSource::Type::Audio: { >- for (auto& audioSource : m_audioSources) { >- if (&audioSource->source() == ¤tTrack->privateTrack()) { >- if (!updateTrackSource(audioSource, track.get())) { >- promise.reject(InvalidModificationError); >- return; >- } >- connection().enqueueReplaceTrackTask(sender, WTFMove(track), WTFMove(promise)); >+ ASSERT(!track || !currentTrack || currentTrack->source().type() == track->source().type()); >+ if (currentTrack) { >+ switch (currentTrack->source().type()) { >+ case RealtimeMediaSource::Type::None: >+ ASSERT_NOT_REACHED(); >+ promise.reject(InvalidModificationError); >+ break; >+ case RealtimeMediaSource::Type::Audio: >+ if (!tryUpdatingTrackSource(*currentTrack, track.get(), m_audioSources)) { >+ promise.reject(InvalidModificationError); > return; > } >+ break; >+ case RealtimeMediaSource::Type::Video: >+ if (!tryUpdatingTrackSource(*currentTrack, track.get(), m_videoSources)) { >+ promise.reject(InvalidModificationError); >+ return; >+ } >+ break; > } >- promise.reject(InvalidModificationError); >- break; > } >- case RealtimeMediaSource::Type::Video: { >- for (auto& videoSource : m_videoSources) { >- if (&videoSource->source() == ¤tTrack->privateTrack()) { >- if (!updateTrackSource(videoSource, track.get())) { >- promise.reject(InvalidModificationError); >- return; >- } >- connection().enqueueReplaceTrackTask(sender, WTFMove(track), WTFMove(promise)); >+ enqueueReplaceTrackTask(sender, WTFMove(track), WTFMove(promise)); >+} >+ >+void LibWebRTCPeerConnectionBackend::enqueueReplaceTrackTask(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromiseDeferred<void>&& promise) >+{ >+ m_peerConnection.scriptExecutionContext()->postTask([protectedConnection = makeRef(m_peerConnection), protectedSender = makeRef(sender), promise = WTFMove(promise), withTrack = WTFMove(withTrack), this](ScriptExecutionContext&) mutable { >+ if (protectedConnection->isClosed()) >+ return; >+ >+ if (!withTrack) { >+ protectedSender->setTrackToNull(); >+ promise.resolve(); >+ return; >+ } >+ >+ bool hasTrack = protectedSender->track(); >+ protectedSender->setTrack(withTrack.releaseNonNull()); >+ if (!hasTrack) { >+ if (!m_endpoint->addTrack(backendFromRTPSender(protectedSender), *protectedSender->track(), { })) { >+ promise.reject(Exception { TypeError, "Unable to add track"_s }); > return; > } > } >- promise.reject(InvalidModificationError); >- break; >- } >- } >+ promise.resolve(); >+ }); > } > > void LibWebRTCPeerConnectionBackend::applyRotationForOutgoingVideoSources() >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >index b55f0cf2d49b855811e87f6893d1c59cfd1505f7..64e609c260504f02f790366be0a043b8a1b02c04 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >@@ -112,6 +112,8 @@ private: > > Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind); > >+ void enqueueReplaceTrackTask(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&); >+ > Ref<LibWebRTCMediaEndpoint> m_endpoint; > bool m_isLocalDescriptionSet { false }; > bool m_isRemoteDescriptionSet { false }; >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp >index 2b2735c274b652b4b882959fe7d1a2da074ba0d1..51a78ae31dbaff5bb5f9ec5b1125b7af9d012c37 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp >@@ -41,11 +41,6 @@ void LibWebRTCRtpSenderBackend::replaceTrack(RTCRtpSender& sender, RefPtr<MediaS > return; > } > >- if (!sender.track() && track) { >- m_peerConnectionBackend->connection().enqueueReplaceTrackTask(sender, track.releaseNonNull(), WTFMove(promise)); >- return; >- } >- > m_peerConnectionBackend->replaceTrack(sender, WTFMove(track), WTFMove(promise)); > } > >diff --git a/Source/WebCore/css/FontFaceSet.h b/Source/WebCore/css/FontFaceSet.h >index 1c89172a8e71dd838d43ba6dd843838864ed6ec7..5f50163b63f782b93b6753b5ebbfe9c04ca3a4e3 100644 >--- a/Source/WebCore/css/FontFaceSet.h >+++ b/Source/WebCore/css/FontFaceSet.h >@@ -35,7 +35,7 @@ namespace WebCore { > > class DOMException; > >-class FontFaceSet final : public RefCounted<FontFaceSet>, private CSSFontFaceSetClient, public EventTargetWithInlineData, private ActiveDOMObject { >+class FontFaceSet final : public RefCounted<FontFaceSet>, private CSSFontFaceSetClient, public EventTargetWithInlineData, private ActiveDOMObject { > public: > static Ref<FontFaceSet> create(Document&, const Vector<RefPtr<FontFace>>& initialFaces); > static Ref<FontFaceSet> create(Document&, CSSFontFaceSet& backing);
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 189281
:
348866
|
348926
| 348938