WebKit Bugzilla
Attachment 348948 Details for
Bug 189310
: Move ownership of outgoing source to RTCRtpSender backend
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189310-20180905112317.patch (text/plain), 10.88 KB, created by
youenn fablet
on 2018-09-05 11:23:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2018-09-05 11:23:18 PDT
Size:
10.88 KB
patch
obsolete
>Subversion Revision: 235669 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 476db707225808f0732d9ac2ecbf829f38096907..93abcc29323ab5f956f1f193ba9f47138dccdc82 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-09-05 Youenn Fablet <youenn@apple.com> >+ >+ Move ownership of outgoing source to RTCRtpSender backend >+ https://bugs.webkit.org/show_bug.cgi?id=189310 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ RTCRtpSender should own the source so that it can replace/stop it. >+ Since this is libwebrtc specific, the source is actually owned by the backend. >+ Simplified replaceTrack a bit based on that. >+ >+ No change of behavior. >+ >+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: >+ (WebCore::LibWebRTCMediaEndpoint::addTrack): >+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: >+ (WebCore::LibWebRTCPeerConnectionBackend::doStop): >+ (WebCore::updateTrackSource): >+ (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): >+ (WebCore::LibWebRTCPeerConnectionBackend::applyRotationForOutgoingVideoSources): >+ * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: >+ * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: >+ > 2018-09-05 Youenn Fablet <youenn@apple.com> > > Move replaceTrack logic to LibWebRTCPeerConnectionBackend >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >index 98cbee5c5a3450f260d6260eb7e4199e4848af63..efa19adc72f4189ebb8940482601a5e6a3f82c1d 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp >@@ -214,9 +214,9 @@ bool LibWebRTCMediaEndpoint::addTrack(LibWebRTCRtpSenderBackend& sender, MediaSt > > switch (track.privateTrack().type()) { > case RealtimeMediaSource::Type::Audio: { >- auto trackSource = RealtimeOutgoingAudioSource::create(track.privateTrack()); >- auto audioTrack = m_peerConnectionFactory.CreateAudioTrack(track.id().utf8().data(), trackSource.ptr()); >- m_peerConnectionBackend.addAudioSource(WTFMove(trackSource)); >+ auto audioSource = RealtimeOutgoingAudioSource::create(track.privateTrack()); >+ auto audioTrack = m_peerConnectionFactory.CreateAudioTrack(track.id().utf8().data(), audioSource.ptr()); >+ sender.setSource(WTFMove(audioSource)); > auto rtpSender = m_backend->AddTrack(audioTrack.get(), WTFMove(ids)); > if (!rtpSender.ok()) > return false; >@@ -226,7 +226,7 @@ bool LibWebRTCMediaEndpoint::addTrack(LibWebRTCRtpSenderBackend& sender, MediaSt > case RealtimeMediaSource::Type::Video: { > auto videoSource = RealtimeOutgoingVideoSource::create(track.privateTrack()); > auto videoTrack = m_peerConnectionFactory.CreateVideoTrack(track.id().utf8().data(), videoSource.ptr()); >- m_peerConnectionBackend.addVideoSource(WTFMove(videoSource)); >+ sender.setSource(WTFMove(videoSource)); > auto rtpSender = m_backend->AddTrack(videoTrack.get(), WTFMove(ids)); > if (!rtpSender.ok()) > return false; >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >index 6205a02c4254bdebbda9fa3b1985e2946fefda46..ebecb50d4f56f06a3b49c8e8a4c81a45a8ab01a1 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp >@@ -174,15 +174,7 @@ void LibWebRTCPeerConnectionBackend::doCreateAnswer(RTCAnswerOptions&&) > > void LibWebRTCPeerConnectionBackend::doStop() > { >- for (auto& source : m_audioSources) >- source->stop(); >- for (auto& source : m_videoSources) >- source->stop(); >- > m_endpoint->stop(); >- >- m_audioSources.clear(); >- m_videoSources.clear(); > m_pendingReceivers.clear(); > } > >@@ -208,16 +200,6 @@ void LibWebRTCPeerConnectionBackend::doAddIceCandidate(RTCIceCandidate& candidat > addIceCandidateSucceeded(); > } > >-void LibWebRTCPeerConnectionBackend::addAudioSource(Ref<RealtimeOutgoingAudioSource>&& source) >-{ >- m_audioSources.append(WTFMove(source)); >-} >- >-void LibWebRTCPeerConnectionBackend::addVideoSource(Ref<RealtimeOutgoingVideoSource>&& source) >-{ >- m_videoSources.append(WTFMove(source)); >-} >- > static inline Ref<RTCRtpReceiver> createReceiverForSource(ScriptExecutionContext& context, Ref<RealtimeMediaSource>&& source) > { > auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(source), String { source->id() }); >@@ -402,23 +384,10 @@ template<typename Source> > static inline bool updateTrackSource(Source& source, MediaStreamTrack* track) > { > if (!track) { >- source->stop(); >+ source.stop(); > return true; > } >- return source->setSource(track->privateTrack()); >-} >- >-template<typename Source> >-static inline bool tryUpdatingTrackSource(MediaStreamTrack& currentTrack, MediaStreamTrack* newTrack, const Vector<Source>& sources) >-{ >- for (auto& source : sources) { >- if (&source->source() == ¤tTrack.privateTrack()) { >- if (!updateTrackSource(source, newTrack)) >- return false; >- return true; >- } >- } >- return false; >+ return source.setSource(track->privateTrack()); > } > > void LibWebRTCPeerConnectionBackend::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& track, DOMPromiseDeferred<void>&& promise) >@@ -433,13 +402,13 @@ void LibWebRTCPeerConnectionBackend::replaceTrack(RTCRtpSender& sender, RefPtr<M > promise.reject(InvalidModificationError); > break; > case RealtimeMediaSource::Type::Audio: >- if (!tryUpdatingTrackSource(*currentTrack, track.get(), m_audioSources)) { >+ if (!updateTrackSource(*backendFromRTPSender(sender).audioSource(), track.get())) { > promise.reject(InvalidModificationError); > return; > } > break; > case RealtimeMediaSource::Type::Video: >- if (!tryUpdatingTrackSource(*currentTrack, track.get(), m_videoSources)) { >+ if (!updateTrackSource(*backendFromRTPSender(sender).videoSource(), track.get())) { > promise.reject(InvalidModificationError); > return; > } >@@ -475,8 +444,10 @@ void LibWebRTCPeerConnectionBackend::enqueueReplaceTrackTask(RTCRtpSender& sende > > void LibWebRTCPeerConnectionBackend::applyRotationForOutgoingVideoSources() > { >- for (auto& source : m_videoSources) >- source->setApplyRotation(true); >+ for (auto& transceiver : m_peerConnection.getTransceivers()) { >+ if (auto* videoSource = backendFromRTPSender(transceiver->sender()).videoSource()) >+ videoSource->setApplyRotation(true); >+ } > } > > bool LibWebRTCPeerConnectionBackend::shouldOfferAllowToReceive(const char* kind) const >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >index 64e609c260504f02f790366be0a043b8a1b02c04..5f5e02936e33d437df4450e1491eba911e93f3ee 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h >@@ -52,9 +52,6 @@ public: > LibWebRTCPeerConnectionBackend(RTCPeerConnection&, LibWebRTCProvider&); > ~LibWebRTCPeerConnectionBackend(); > >- bool hasAudioSources() const { return m_audioSources.size(); } >- bool hasVideoSources() const { return m_videoSources.size(); } >- > void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&); > > bool shouldOfferAllowToReceive(const char*) const; >@@ -85,8 +82,6 @@ private: > friend class LibWebRTCMediaEndpoint; > friend class LibWebRTCRtpSenderBackend; > RTCPeerConnection& connection() { return m_peerConnection; } >- void addAudioSource(Ref<RealtimeOutgoingAudioSource>&&); >- void addVideoSource(Ref<RealtimeOutgoingVideoSource>&&); > > void getStatsSucceeded(const DeferredPromise&, Ref<RTCStatsReport>&&); > >@@ -119,8 +114,6 @@ private: > bool m_isRemoteDescriptionSet { false }; > > Vector<std::unique_ptr<webrtc::IceCandidateInterface>> m_pendingCandidates; >- Vector<Ref<RealtimeOutgoingAudioSource>> m_audioSources; >- Vector<Ref<RealtimeOutgoingVideoSource>> m_videoSources; > Vector<Ref<RTCRtpReceiver>> m_pendingReceivers; > }; > >diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h >index 24b1b1bc7d466481d81f74665d9c77625201718f..686fa88f3ed516b0523b2319f01a6f9d85cccd68 100644 >--- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h >+++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h >@@ -28,6 +28,8 @@ > > #include "LibWebRTCMacros.h" > #include "RTCRtpSenderBackend.h" >+#include "RealtimeOutgoingAudioSource.h" >+#include "RealtimeOutgoingVideoSource.h" > #include <wtf/WeakPtr.h> > > #pragma GCC diagnostic push >@@ -53,12 +55,49 @@ public: > void setRTCSender(rtc::scoped_refptr<webrtc::RtpSenderInterface>&& rtcSender) { m_rtcSender = WTFMove(rtcSender); } > webrtc::RtpSenderInterface* rtcSender() { return m_rtcSender.get(); } > >+ RealtimeOutgoingAudioSource* audioSource() >+ { >+ return WTF::switchOn(m_source, >+ [] (Ref<RealtimeOutgoingAudioSource>& source) { return source.ptr(); }, >+ [] (const auto&) -> RealtimeOutgoingAudioSource* { return nullptr; } >+ ); >+ } >+ >+ RealtimeOutgoingVideoSource* videoSource() >+ { >+ return WTF::switchOn(m_source, >+ [] (Ref<RealtimeOutgoingVideoSource>& source) { return source.ptr(); }, >+ [] (const auto&) -> RealtimeOutgoingVideoSource* { return nullptr; } >+ ); >+ } >+ >+ bool hasNoSource() const >+ { >+ return WTF::switchOn(m_source, >+ [] (const std::nullptr_t&) { return true; }, >+ [] (const auto&) { return false; } >+ ); >+ } >+ >+ void setSource(Ref<RealtimeOutgoingAudioSource>&& source) >+ { >+ ASSERT(hasNoSource()); >+ m_source = WTFMove(source); >+ } >+ >+ void setSource(Ref<RealtimeOutgoingVideoSource>&& source) >+ { >+ ASSERT(hasNoSource()); >+ m_source = WTFMove(source); >+ } >+ > private: > void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) final; > RTCRtpParameters getParameters() const final; > > WeakPtr<LibWebRTCPeerConnectionBackend> m_peerConnectionBackend; > rtc::scoped_refptr<webrtc::RtpSenderInterface> m_rtcSender; >+ Variant<std::nullptr_t, Ref<RealtimeOutgoingAudioSource>, Ref<RealtimeOutgoingVideoSource>> m_source; > }; > > } // namespace WebCore
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 189310
:
348948
|
348956
|
348966
|
349000