- Revision
- 218151
- Author
- jer.no...@apple.com
- Date
- 2017-06-12 16:01:55 -0700 (Mon, 12 Jun 2017)
Log Message
Screen sleeps while doing WebRTC video
https://bugs.webkit.org/show_bug.cgi?id=173278
Reviewed by Eric Carlson.
Source/WebCore:
HTMLMediaElement triggers changing the sleep disabler token when the media engine
says that its rate has changed; the MediaPlayerPrivateMediaStreamAVFObjC needs to
notify its client (the HTMLMediaElement) that the rate has changed when the stream
is played or paused.
Drive-by fix: Don't set a sleep disabler token (i.e., allow the system and display
to sleep) if the stream is strictly local-capture.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::shouldDisableSleep):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::pause):
Source/WTF:
Drive-by fix: add some generic methods for iterating over collections.
* WTF.xcodeproj/project.pbxproj:
* wtf/Algorithms.h: Added.
(WTF::forEach):
(WTF::anyOf):
(WTF::allOf):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (218150 => 218151)
--- trunk/Source/WTF/ChangeLog 2017-06-12 22:57:18 UTC (rev 218150)
+++ trunk/Source/WTF/ChangeLog 2017-06-12 23:01:55 UTC (rev 218151)
@@ -1,3 +1,18 @@
+2017-06-12 Jer Noble <jer.no...@apple.com>
+
+ Screen sleeps while doing WebRTC video
+ https://bugs.webkit.org/show_bug.cgi?id=173278
+
+ Reviewed by Eric Carlson.
+
+ Drive-by fix: add some generic methods for iterating over collections.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/Algorithms.h: Added.
+ (WTF::forEach):
+ (WTF::anyOf):
+ (WTF::allOf):
+
2017-06-12 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Move WebKit GType macros to WTF
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (218150 => 218151)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-06-12 22:57:18 UTC (rev 218150)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2017-06-12 23:01:55 UTC (rev 218151)
@@ -526,6 +526,7 @@
C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomDevice.cpp; sourceTree = "<group>"; };
CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
CD5497AB15857D0300B5BC30 /* MediaTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTime.h; sourceTree = "<group>"; };
+ CD6D9FCD1EEF3AD4008B0671 /* Algorithms.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Algorithms.h; sourceTree = "<group>"; };
CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMapTableSPI.h; sourceTree = "<group>"; };
CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
DCEE21FA1CEA7538000C2396 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundleSPI.h; path = cf/CFBundleSPI.h; sourceTree = "<group>"; };
@@ -714,6 +715,7 @@
A8A47339151A825B004123FF /* threads */,
A8A47348151A825B004123FF /* unicode */,
A8A4725A151A825A004123FF /* ASCIICType.h */,
+ CD6D9FCD1EEF3AD4008B0671 /* Algorithms.h */,
A8A4725B151A825A004123FF /* Assertions.cpp */,
A8A4725C151A825A004123FF /* Assertions.h */,
A8A4725D151A825A004123FF /* Atomics.h */,
Added: trunk/Source/WTF/wtf/Algorithms.h (0 => 218151)
--- trunk/Source/WTF/wtf/Algorithms.h (rev 0)
+++ trunk/Source/WTF/wtf/Algorithms.h 2017-06-12 23:01:55 UTC (rev 218151)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 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
+
+namespace WTF {
+
+template<typename ContainerType, typename ForEachFunction>
+void forEach(ContainerType container, ForEachFunction forEachFunction)
+{
+ for (auto& value : container)
+ forEachFunction(value);
+}
+
+template<typename ContainerType, typename AnyOfFunction>
+bool anyOf(ContainerType container, AnyOfFunction anyOfFunction)
+{
+ for (auto& value : container) {
+ if (anyOfFunction(value))
+ return true;
+ }
+ return false;
+}
+
+template<typename ContainerType, typename AllOfFunction>
+bool allOf(ContainerType container, AllOfFunction allOfFunction)
+{
+ for (auto& value : container) {
+ if (!allOfFunction(value))
+ return false;
+ }
+ return true;
+}
+
+}
+
Modified: trunk/Source/WebCore/ChangeLog (218150 => 218151)
--- trunk/Source/WebCore/ChangeLog 2017-06-12 22:57:18 UTC (rev 218150)
+++ trunk/Source/WebCore/ChangeLog 2017-06-12 23:01:55 UTC (rev 218151)
@@ -1,5 +1,26 @@
2017-06-12 Jer Noble <jer.no...@apple.com>
+ Screen sleeps while doing WebRTC video
+ https://bugs.webkit.org/show_bug.cgi?id=173278
+
+ Reviewed by Eric Carlson.
+
+ HTMLMediaElement triggers changing the sleep disabler token when the media engine
+ says that its rate has changed; the MediaPlayerPrivateMediaStreamAVFObjC needs to
+ notify its client (the HTMLMediaElement) that the rate has changed when the stream
+ is played or paused.
+
+ Drive-by fix: Don't set a sleep disabler token (i.e., allow the system and display
+ to sleep) if the stream is strictly local-capture.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::shouldDisableSleep):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::play):
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::pause):
+
+2017-06-12 Jer Noble <jer.no...@apple.com>
+
Seeking an MSE video will begin playing audio long before rendering video
https://bugs.webkit.org/show_bug.cgi?id=173269
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (218150 => 218151)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-06-12 22:57:18 UTC (rev 218150)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-06-12 23:01:55 UTC (rev 218151)
@@ -90,6 +90,7 @@
#include "UserGestureIndicator.h"
#include <limits>
#include <runtime/Uint8Array.h>
+#include <wtf/Algorithms.h>
#include <wtf/CurrentTime.h>
#include <wtf/MathExtras.h>
#include <wtf/MemoryPressureHandler.h>
@@ -6355,6 +6356,14 @@
return SleepType::System;
#endif
+#if ENABLE(MEDIA_STREAM)
+ if (m_mediaStreamSrcObject) {
+ // Do not block system from sleeping if element is only rendering local (capture) sources.
+ if (WTF::allOf(m_mediaStreamSrcObject->getTracks(), [] (RefPtr<MediaStreamTrack>& track) { return track && track->isCaptureTrack(); }))
+ return SleepType::None;
+ }
+#endif
+
if (!hasVideo() || !hasAudio())
return SleepType::None;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (218150 => 218151)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2017-06-12 22:57:18 UTC (rev 218150)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2017-06-12 23:01:55 UTC (rev 218151)
@@ -636,6 +636,8 @@
scheduleDeferredTask([this] {
updateReadyState();
+ if (m_player)
+ m_player->rateChanged();
});
}
@@ -654,6 +656,11 @@
updateDisplayMode();
flushRenderers();
+
+ scheduleDeferredTask([this] {
+ if (m_player)
+ m_player->rateChanged();
+ });
}
void MediaPlayerPrivateMediaStreamAVFObjC::setVolume(float volume)