Changeset 258977 in webkit
- Timestamp:
- Mar 25, 2020 6:44:17 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r258975 r258977 1 2020-03-25 Youenn Fablet <youenn@apple.com> 2 3 Audio fails to capture stream in WebRTC if AudioSession gets interrupted 4 https://bugs.webkit.org/show_bug.cgi?id=208516 5 <rdar://problem/60020467> 6 7 Reviewed by Eric Carlson. 8 9 In case of page going to hidden, continue calling each capture factory to mute the corresponding sources if needed. 10 In case of page being visible again, reset all tracks according page muted state. This allows restarting tracks that have been 11 muted while page was hidden (video tracks or suspended audio tracks). 12 13 Since tracks can go to muted when visibility changes, we no longer return early when setting the muted state of a page to the same value. 14 Instead we apply it which ensures we comply with what UIProcess wants. 15 16 We start removing the concept of a RealtimeMediaSource be interrupted. Instead we use muting of sources. 17 This allows UIProcess or the page to override any muted state, for instance if page goes in foreground again. 18 19 We update the AudioSharedUnit to allow restarting capture even if suspended. 20 This ensures that we are able to restart capturing even if we do not receive the audio session end of interruption. 21 Also, this notification sometimes takes a long time to happen and we do not want to wait for it when user is interacting with the page. 22 A future refactoring will further remove RealtimeMediaSource interrupted-related code. 23 24 Manually tested. 25 26 * dom/Document.cpp: 27 (WebCore::Document::visibilityStateChanged): 28 * page/Page.cpp: 29 (WebCore::Page::setMuted): 30 * platform/audio/PlatformMediaSessionManager.h: 31 (WebCore::PlatformMediaSessionManager::isInterrupted const): 32 * platform/mediastream/RealtimeMediaSource.cpp: 33 (WebCore::RealtimeMediaSource::setInterrupted): 34 (WebCore::RealtimeMediaSource::setMuted): 35 * platform/mediastream/mac/BaseAudioSharedUnit.cpp: 36 (WebCore::BaseAudioSharedUnit::startProducingData): 37 (WebCore::BaseAudioSharedUnit::resume): 38 (WebCore::BaseAudioSharedUnit::suspend): 39 1 40 2020-03-25 Charlie Turner <cturner@igalia.com> 2 41 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
r257039 r258977 468 468 } 469 469 470 #if PLATFORM(IOS_FAMILY) 471 static MediaStreamTrack* findActiveCaptureTrackForDocument(Document& document, RealtimeMediaSource* activeSource, RealtimeMediaSource::Type type) 472 { 473 MediaStreamTrack* selectedTrack = nullptr; 474 for (auto* captureTrack : allCaptureTracks()) { 475 if (captureTrack->document() != &document || captureTrack->ended()) 476 continue; 477 478 if (&captureTrack->source() == activeSource) 479 return captureTrack; 480 481 // If the document has a live capture track, which is not the active one, we pick the first one. 482 // FIXME: We should probably store per page active audio/video capture tracks. 483 if (!selectedTrack && captureTrack->privateTrack().type() == type) 484 selectedTrack = captureTrack; 485 } 486 return selectedTrack; 487 } 488 #endif 489 470 490 void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document) 471 491 { 492 #if PLATFORM(IOS_FAMILY) 493 auto* activeAudioSource = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource(); 494 if (auto* audioCaptureTrack = findActiveCaptureTrackForDocument(document, activeAudioSource, RealtimeMediaSource::Type::Audio)) 495 audioCaptureTrack->setMuted(document.page()->mutedState()); 496 497 auto* activeVideoSource = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource(); 498 if (auto* videoCaptureTrack = findActiveCaptureTrackForDocument(document, activeVideoSource, RealtimeMediaSource::Type::Video)) 499 videoCaptureTrack->setMuted(document.page()->mutedState()); 500 #else 472 501 for (auto* captureTrack : allCaptureTracks()) { 473 502 if (captureTrack->document() != &document || captureTrack->ended()) … … 475 504 captureTrack->setMuted(document.page()->mutedState()); 476 505 } 506 #endif 477 507 } 478 508 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
r257039 r258977 155 155 void setIdForTesting(String&& id) { m_private->setIdForTesting(WTFMove(id)); } 156 156 157 Document* document() const; 158 157 159 #if !RELEASE_LOG_DISABLED 158 160 const Logger& logger() const final { return m_private->logger(); } … … 172 174 void configureTrackRendering(); 173 175 174 Document* document() const;175 176 176 // ActiveDOMObject API. 177 177 void stop() final { stopTrack(); } -
trunk/Source/WebCore/dom/Document.cpp
r258869 r258977 1745 1745 client->visibilityStateChanged(); 1746 1746 1747 #if ENABLE(MEDIA_STREAM) 1748 if (auto* page = this->page()) 1749 RealtimeMediaSourceCenter::singleton().setCapturePageState(hidden(), page->isMediaCaptureMuted()); 1747 #if PLATFORM(IOS_FAMILY) 1748 if (hidden()) { 1749 RealtimeMediaSourceCenter::singleton().setCapturePageState(hidden(), page()->isMediaCaptureMuted()); 1750 return; 1751 } 1752 if (!PlatformMediaSessionManager::sharedManager().isInterrupted()) 1753 MediaStreamTrack::updateCaptureAccordingToMutedState(*this); 1750 1754 #endif 1751 1755 } -
trunk/Source/WebCore/page/Page.cpp
r258882 r258977 1782 1782 void Page::setMuted(MediaProducer::MutedStateFlags muted) 1783 1783 { 1784 if (m_mutedState == muted)1785 return;1786 1787 1784 m_mutedState = muted; 1788 1785 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r258024 r258977 141 141 WEBCORE_EXPORT void processDidReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*); 142 142 143 bool isInterrupted() const { return m_interrupted; } 144 143 145 protected: 144 146 friend class PlatformMediaSession; -
trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
r252521 r258977 77 77 void RealtimeMediaSource::setInterrupted(bool interrupted, bool pageMuted) 78 78 { 79 if (interrupted == m_interrupted)80 return;81 82 79 ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, interrupted, ", page muted : ", pageMuted); 83 84 m_interrupted = interrupted;85 if (!interrupted && pageMuted)86 return;87 88 80 setMuted(interrupted); 89 81 } … … 91 83 void RealtimeMediaSource::setMuted(bool muted) 92 84 { 93 if (!muted && interrupted()) {94 ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, "ignoring unmute because of interruption");95 return;96 }97 98 85 ALWAYS_LOG_IF(m_logger, LOGIDENTIFIER, muted); 99 86 -
trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceFactory.h
r258202 r258977 46 46 void unsetActiveSource(RealtimeMediaSource&); 47 47 48 protected:49 48 RealtimeMediaSource* activeSource() { return m_activeSource; } 50 49 -
trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp
r257039 r258977 75 75 ASSERT(isMainThread()); 76 76 77 if (m_suspended) 78 resume(); 79 77 80 if (++m_producingCount != 1) 78 81 return; … … 80 83 if (isProducingData()) 81 84 return; 82 83 if (m_suspended) {84 RELEASE_LOG_INFO(WebRTC, "BaseAudioSharedUnit::startProducingData - exiting early as suspended");85 return;86 }87 85 88 86 if (hasAudioUnit()) { … … 160 158 { 161 159 ASSERT(isMainThread()); 162 ASSERT(m_suspended); 160 if (!m_suspended) 161 return 0; 162 163 163 ASSERT(!isProducingData()); 164 164 … … 181 181 182 182 forEachClient([](auto& client) { 183 client. notifyMutedChange(false);183 client.setMuted(false); 184 184 }); 185 185 … … 197 197 198 198 forEachClient([](auto& client) { 199 client. notifyMutedChange(true);199 client.setMuted(true); 200 200 }); 201 201
Note: See TracChangeset
for help on using the changeset viewer.