Diff
Modified: trunk/Source/WebCore/ChangeLog (276176 => 276177)
--- trunk/Source/WebCore/ChangeLog 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/ChangeLog 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1,3 +1,92 @@
+2021-04-16 Peng Liu <[email protected]>
+
+ [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=224469
+
+ Reviewed by Eric Carlson.
+
+ This patch modifies `MediaPlaybackTargetContext` to provide interfaces to serialize/deserialize
+ `AVOutputContext` and modifies `MediaPlaybackTargetCocoa` to use `MediaPlaybackTargetContext` to
+ manage its `AVOutputContext` instead of keeping a pointer to the `AVOutputContext` object.
+ With these changes, a WebContent process can forward a serialized `AVOutputContext` object
+ to other processes (e.g., the GPU process) without deserializing it. Therefore, the WebContent
+ process does not need access to the CoreMedia routing service. So we can remove the fix (r275669)
+ for bug 224328.
+
+ Covered by existing tests.
+
+ * Modules/airplay/WebMediaSessionManager.cpp:
+ (WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerState):
+ * Modules/airplay/WebMediaSessionManager.h:
+
+ * Headers.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ Modify the project file because `MediaPlaybackTargetContext` is used in Cocoa ports only.
+
+ * page/ChromeClient.h:
+ (WebCore::ChromeClient::setMockMediaPlaybackTargetPickerState):
+ * page/Page.cpp:
+ (WebCore::Page::setMockMediaPlaybackTargetPickerState):
+ * page/Page.h:
+
+ * platform/graphics/MediaPlaybackTarget.h:
+ (WebCore::MediaPlaybackTarget::hasActiveRoute const):
+ (WebCore::MediaPlaybackTarget::deviceName const):
+ (WebCore::MediaPlaybackTarget::supportsRemoteVideoPlayback):
+ (): Deleted.
+ * platform/graphics/MediaPlaybackTargetContext.h: Removed.
+ * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h:
+ (WebCore::MediaPlaybackTargetCocoa::outputContext const): Deleted.
+ * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm:
+ (WebCore::MediaPlaybackTargetCocoa::create):
+ (WebCore::MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa):
+ (WebCore::MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa):
+ (WebCore::toMediaPlaybackTargetCocoa):
+ (WebCore::MediaPlaybackTargetCocoa::supportsRemoteVideoPlayback const): Deleted.
+ (WebCore::MediaPlaybackTargetCocoa::targetContext const): Deleted.
+ (WebCore::MediaPlaybackTargetCocoa::hasActiveRoute const): Deleted.
+ (WebCore::MediaPlaybackTargetCocoa::deviceName const): Deleted.
+ Don't directly use `AVOutputContext` in this class.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless const):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget):
+
+ * platform/graphics/cocoa/MediaPlaybackTargetContext.h: Added.
+ (WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
+ (WebCore::MediaPlaybackTargetContext::type const):
+ (WebCore::MediaPlaybackTargetContext::mockState const):
+ (WebCore::MediaPlaybackTargetContext::outputContext const):
+ (WebCore::MediaPlaybackTargetContext::serializedOutputContext const):
+ (WebCore::MediaPlaybackTargetContext::encodingRequiresPlatformData const):
+ * platform/graphics/cocoa/MediaPlaybackTargetContext.mm: Added.
+ (WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
+ (WebCore::MediaPlaybackTargetContext::deviceName const):
+ (WebCore::MediaPlaybackTargetContext::hasActiveRoute const):
+ (WebCore::MediaPlaybackTargetContext::supportsRemoteVideoPlayback const):
+ (WebCore::MediaPlaybackTargetContext::serializeOutputContext):
+ (WebCore::MediaPlaybackTargetContext::deserializeOutputContext):
+
+ * platform/mock/MediaPlaybackTargetMock.cpp:
+ (WebCore::MediaPlaybackTargetMock::create):
+ (WebCore::MediaPlaybackTargetMock::MediaPlaybackTargetMock):
+ (WebCore::toMediaPlaybackTargetMock):
+ (WebCore::MediaPlaybackTargetMock::targetContext const): Deleted.
+ * platform/mock/MediaPlaybackTargetMock.h:
+ (WebCore::MediaPlaybackTargetMock::state const):
+ * platform/mock/MediaPlaybackTargetPickerMock.cpp:
+ (WebCore::MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable):
+ (WebCore::MediaPlaybackTargetPickerMock::startingMonitoringPlaybackTargets):
+ (WebCore::MediaPlaybackTargetPickerMock::invalidatePlaybackTargets):
+ (WebCore::MediaPlaybackTargetPickerMock::setState):
+ * platform/mock/MediaPlaybackTargetPickerMock.h:
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ (WebCore::Internals::setMockMediaPlaybackTargetPickerState):
+
2021-04-16 Zalan Bujtas <[email protected]>
Remove redundant renderObject in BreakingContext::handleText
Modified: trunk/Source/WebCore/Headers.cmake (276176 => 276177)
--- trunk/Source/WebCore/Headers.cmake 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/Headers.cmake 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1269,7 +1269,6 @@
platform/graphics/MIMETypeCache.h
platform/graphics/MediaPlaybackTarget.h
platform/graphics/MediaPlaybackTargetClient.h
- platform/graphics/MediaPlaybackTargetContext.h
platform/graphics/MediaPlaybackTargetPicker.h
platform/graphics/MediaPlayer.h
platform/graphics/MediaPlayerEnums.h
Modified: trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.cpp (276176 => 276177)
--- trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -161,7 +161,7 @@
m_mockPickerEnabled = enabled;
}
-void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
+void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
{
ALWAYS_LOG_MEDIASESSIONMANAGER(__func__);
mockPicker().setState(name, state);
Modified: trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.h (276176 => 276177)
--- trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -51,7 +51,7 @@
WEBCORE_EXPORT static WebMediaSessionManager& shared();
WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerEnabled(bool);
- WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State);
+ WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState);
WEBCORE_EXPORT void mockMediaPlaybackTargetPickerDismissPopup();
WEBCORE_EXPORT PlaybackTargetClientContextIdentifier addPlaybackTargetPickerClient(WebMediaSessionManagerClient&, PlaybackTargetClientContextIdentifier);
Modified: trunk/Source/WebCore/SourcesCocoa.txt (276176 => 276177)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-04-16 22:54:15 UTC (rev 276177)
@@ -369,6 +369,7 @@
platform/graphics/cocoa/IOSurfacePoolCocoa.mm
platform/graphics/cocoa/IntRectCocoa.mm
platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp
+platform/graphics/cocoa/MediaPlaybackTargetContext.mm
platform/graphics/cocoa/RemoteGraphicsContextGLProxyBaseCocoa.mm
platform/graphics/cocoa/SourceBufferParser.cpp
platform/graphics/cocoa/SourceBufferParserWebM.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (276176 => 276177)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-04-16 22:54:15 UTC (rev 276177)
@@ -6981,6 +6981,7 @@
1D0026A32374D62400CA6CDF /* JSPictureInPictureWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPictureInPictureWindow.cpp; sourceTree = "<group>"; };
1D0026A82374F9D900CA6CDF /* JSEnterPictureInPictureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEnterPictureInPictureEvent.h; sourceTree = "<group>"; };
1D0026A92374F9D900CA6CDF /* JSEnterPictureInPictureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEnterPictureInPictureEvent.cpp; sourceTree = "<group>"; };
+ 1D008AA5262108C000EE3ADE /* MediaPlaybackTargetContext.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTargetContext.mm; sourceTree = "<group>"; };
1D2C82B6236A3F6A0055D6C5 /* PictureInPictureSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureSupport.h; sourceTree = "<group>"; };
1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoderIdentifier.h; sourceTree = "<group>"; };
1DAB3113251D725C00FC9485 /* VideoLayerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VideoLayerManager.h; sourceTree = "<group>"; };
@@ -26970,7 +26971,6 @@
CDDE02E918B3DFC700CF7FF1 /* LegacyCDMSession.h */,
07E3DFD01A9E786500764CA8 /* MediaPlaybackTarget.h */,
079216531AA560AA00A3C049 /* MediaPlaybackTargetClient.h */,
- 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */,
078E43D71ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.cpp */,
078E43D81ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.h */,
E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */,
@@ -27186,6 +27186,8 @@
AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
CDC48AC82149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.cpp */,
CDC48AC72149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h */,
+ 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */,
+ 1D008AA5262108C000EE3ADE /* MediaPlaybackTargetContext.mm */,
31647FA8251616BD0010F8FB /* OpenGLSoftLinkCocoa.h */,
31647FA9251616BD0010F8FB /* OpenGLSoftLinkCocoa.mm */,
7B64C0B4254C3B160006B4AF /* RemoteGraphicsContextGLProxyBaseCocoa.mm */,
Modified: trunk/Source/WebCore/page/ChromeClient.h (276176 => 276177)
--- trunk/Source/WebCore/page/ChromeClient.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/page/ChromeClient.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -513,7 +513,7 @@
virtual void showPlaybackTargetPicker(PlaybackTargetClientContextIdentifier, const IntPoint&, bool /*isVideo*/) { }
virtual void playbackTargetPickerClientStateDidChange(PlaybackTargetClientContextIdentifier, MediaProducer::MediaStateFlags) { }
virtual void setMockMediaPlaybackTargetPickerEnabled(bool) { }
- virtual void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State) { }
+ virtual void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState) { }
virtual void mockMediaPlaybackTargetPickerDismissPopup() { }
#endif
Modified: trunk/Source/WebCore/page/Page.cpp (276176 => 276177)
--- trunk/Source/WebCore/page/Page.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/page/Page.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -2952,7 +2952,7 @@
chrome().client().setMockMediaPlaybackTargetPickerEnabled(enabled);
}
-void Page::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
+void Page::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
{
chrome().client().setMockMediaPlaybackTargetPickerState(name, state);
}
Modified: trunk/Source/WebCore/page/Page.h (276176 => 276177)
--- trunk/Source/WebCore/page/Page.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/page/Page.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -731,7 +731,7 @@
void showPlaybackTargetPicker(PlaybackTargetClientContextIdentifier, const IntPoint&, bool, RouteSharingPolicy, const String&);
void playbackTargetPickerClientStateDidChange(PlaybackTargetClientContextIdentifier, MediaProducer::MediaStateFlags);
WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerEnabled(bool);
- WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State);
+ WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState);
WEBCORE_EXPORT void mockMediaPlaybackTargetPickerDismissPopup();
WEBCORE_EXPORT void setPlaybackTarget(PlaybackTargetClientContextIdentifier, Ref<MediaPlaybackTarget>&&);
Modified: trunk/Source/WebCore/platform/graphics/MediaPlaybackTarget.h (276176 => 276177)
--- trunk/Source/WebCore/platform/graphics/MediaPlaybackTarget.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/graphics/MediaPlaybackTarget.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -27,24 +27,23 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#include "MediaPlaybackTargetContext.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
namespace WebCore {
-class MediaPlaybackTargetContext;
-
class MediaPlaybackTarget : public RefCounted<MediaPlaybackTarget> {
public:
virtual ~MediaPlaybackTarget() = default;
- enum TargetType { AVFoundation, Mock };
+ enum class TargetType : uint8_t { AVFoundation, Mock };
virtual TargetType targetType() const = 0;
+ virtual const MediaPlaybackTargetContext& targetContext() const = 0;
- virtual const MediaPlaybackTargetContext& targetContext() const = 0;
- virtual bool hasActiveRoute() const = 0;
- virtual String deviceName() const = 0;
- virtual bool supportsRemoteVideoPlayback() const = 0;
+ bool hasActiveRoute() const { return targetContext().hasActiveRoute(); }
+ String deviceName() const { return targetContext().deviceName(); }
+ bool supportsRemoteVideoPlayback() { return targetContext().supportsRemoteVideoPlayback(); }
};
}
Deleted: trunk/Source/WebCore/platform/graphics/MediaPlaybackTargetContext.h (276176 => 276177)
--- trunk/Source/WebCore/platform/graphics/MediaPlaybackTargetContext.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/graphics/MediaPlaybackTargetContext.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2015 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. ``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
- * 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.
- */
-
-#ifndef MediaPlaybackTargetContext_h
-#define MediaPlaybackTargetContext_h
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-
-#include <wtf/text/WTFString.h>
-
-OBJC_CLASS AVOutputContext;
-
-#if PLATFORM(COCOA)
-OBJC_CLASS NSKeyedArchiver;
-OBJC_CLASS NSKeyedUnarchiver;
-#endif
-
-namespace WebCore {
-
-class MediaPlaybackTargetContext {
-public:
- enum Type : int32_t {
- None,
- AVOutputContextType,
- MockType,
- };
-
- enum ContextState {
- Unknown = 0,
- OutputDeviceUnavailable = 1,
- OutputDeviceAvailable = 2,
- };
- typedef unsigned State;
-
- MediaPlaybackTargetContext()
- : m_type(None)
- {
- }
-
- MediaPlaybackTargetContext(AVOutputContext *outputContext)
- : m_type(AVOutputContextType)
- , m_outputContext(outputContext)
- {
- }
-
- MediaPlaybackTargetContext(const String& name, State state)
- : m_type(MockType)
- , m_name(name)
- , m_state(state)
- {
- }
-
- Type type() const { return m_type; }
-
- const String& mockDeviceName() const
- {
- ASSERT(m_type == MockType);
- return m_name;
- }
-
- State mockState() const
- {
- ASSERT(m_type == MockType);
- return m_state;
- }
-
- AVOutputContext *avOutputContext() const
- {
- ASSERT(m_type == AVOutputContextType);
- return m_outputContext;
- }
-
- bool encodingRequiresPlatformData() const { return m_type == AVOutputContextType; }
-
-private:
- Type m_type { None };
- AVOutputContext *m_outputContext { nullptr };
- String m_name;
- State m_state { Unknown };
-};
-
-}
-
-#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
-
-#endif // MediaPlaybackTargetContext
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h (276176 => 276177)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -28,7 +28,6 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
#include "MediaPlaybackTarget.h"
-#include "MediaPlaybackTargetContext.h"
#include <wtf/RetainPtr.h>
namespace WebCore {
@@ -36,6 +35,7 @@
class MediaPlaybackTargetCocoa : public MediaPlaybackTarget {
public:
WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(AVOutputContext *);
+ WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(MediaPlaybackTargetContext&&);
#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR) && !PLATFORM(MACCATALYST)
static Ref<MediaPlaybackTarget> create();
@@ -43,21 +43,14 @@
virtual ~MediaPlaybackTargetCocoa();
- TargetType targetType() const final { return AVFoundation; }
+ TargetType targetType() const final { return TargetType::AVFoundation; }
+ const MediaPlaybackTargetContext& targetContext() const final { return m_context; }
- const MediaPlaybackTargetContext& targetContext() const final;
- bool hasActiveRoute() const final;
- String deviceName() const final;
- bool supportsRemoteVideoPlayback() const final;
-
- AVOutputContext *outputContext() const { return m_outputContext.get(); }
-
protected:
- MediaPlaybackTargetCocoa(AVOutputContext *);
+ explicit MediaPlaybackTargetCocoa(AVOutputContext *);
+ explicit MediaPlaybackTargetCocoa(MediaPlaybackTargetContext&&);
- RetainPtr<AVOutputContext> m_outputContext;
- mutable MediaPlaybackTargetContext m_context;
- String m_deviceName;
+ MediaPlaybackTargetContext m_context;
};
MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget*);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm (276176 => 276177)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -34,17 +34,26 @@
namespace WebCore {
-Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *context)
+Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *outputContext)
{
- return adoptRef(*new MediaPlaybackTargetCocoa(context));
+ return adoptRef(*new MediaPlaybackTargetCocoa(outputContext));
}
-MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *context)
- : MediaPlaybackTarget()
- , m_outputContext(context)
+Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(MediaPlaybackTargetContext&& context)
{
+ return adoptRef(*new MediaPlaybackTargetCocoa(WTFMove(context)));
}
+MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *outputContext)
+ : m_context(outputContext)
+{
+}
+
+MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(MediaPlaybackTargetContext&& context)
+ : m_context(WTFMove(context))
+{
+}
+
#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR) && !PLATFORM(MACCATALYST)
Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create()
{
@@ -53,75 +62,10 @@
}
#endif
-bool MediaPlaybackTargetCocoa::supportsRemoteVideoPlayback() const
-{
- if (!m_outputContext)
- return false;
-
- if (![m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] || ![m_outputContext supportsMultipleOutputDevices] || ![m_outputContext respondsToSelector:@selector(outputDevices)]) {
- if (auto *outputDevice = [m_outputContext outputDevice]) {
- if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
- return true;
- }
-
- return false;
- }
-
- for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
- if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
- return true;
- }
-
- return false;
-}
-
MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa()
{
}
-const MediaPlaybackTargetContext& MediaPlaybackTargetCocoa::targetContext() const
-{
- m_context = MediaPlaybackTargetContext(m_outputContext.get());
- return m_context;
-}
-
-bool MediaPlaybackTargetCocoa::hasActiveRoute() const
-{
- if (!m_outputContext)
- return false;
-
- if ([m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] && [m_outputContext supportsMultipleOutputDevices] && [m_outputContext respondsToSelector:@selector(outputDevices)]) {
- for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
- if (outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio))
- return true;
- }
-
- return false;
- }
-
- if ([m_outputContext respondsToSelector:@selector(outputDevice)]) {
- if (auto *outputDevice = [m_outputContext outputDevice])
- return outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio);
- }
-
- return m_outputContext.get().deviceName;
-}
-
-String MediaPlaybackTargetCocoa::deviceName() const
-{
- if (!m_outputContext)
- return emptyString();
-
- if (![m_outputContext supportsMultipleOutputDevices])
- return [m_outputContext deviceName];
-
- auto outputDeviceNames = adoptNS([[NSMutableArray alloc] init]);
- for (AVOutputDevice *outputDevice in [m_outputContext outputDevices])
- [outputDeviceNames addObject:[outputDevice deviceName]];
-
- return [outputDeviceNames componentsJoinedByString:@" + "];
-}
-
MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(MediaPlaybackTarget* rep)
{
return const_cast<MediaPlaybackTargetCocoa*>(toMediaPlaybackTargetCocoa(const_cast<const MediaPlaybackTarget*>(rep)));
@@ -129,7 +73,7 @@
const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget* rep)
{
- ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::AVFoundation);
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::TargetType::AVFoundation);
return static_cast<const MediaPlaybackTargetCocoa*>(rep);
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (276176 => 276177)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -2824,7 +2824,7 @@
#if !PLATFORM(IOS_FAMILY)
if (m_playbackTarget) {
- if (m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation)
+ if (m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation)
wirelessTarget = m_avPlayer && m_avPlayer.get().externalPlaybackActive;
else
wirelessTarget = m_shouldPlayToPlaybackTarget && m_playbackTarget->hasActiveRoute();
@@ -2968,7 +2968,7 @@
{
m_playbackTarget = WTFMove(target);
- m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation ? toMediaPlaybackTargetCocoa(m_playbackTarget.get())->outputContext() : nullptr;
+ m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation ? toMediaPlaybackTargetCocoa(m_playbackTarget.get())->targetContext().outputContext() : nullptr;
INFO_LOG(LOGIDENTIFIER);
@@ -2988,7 +2988,7 @@
INFO_LOG(LOGIDENTIFIER, shouldPlay);
- if (m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation) {
+ if (m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation) {
AVOutputContext *newContext = shouldPlay ? m_outputContext.get() : nil;
if (!m_avPlayer)
@@ -3005,7 +3005,7 @@
return;
}
- ASSERT(m_playbackTarget->targetType() == MediaPlaybackTarget::Mock);
+ ASSERT(m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::Mock);
setDelayCallbacks(true);
auto weakThis = makeWeakPtr(*this);
Added: trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.h (0 => 276177)
--- trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2015-2021 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. ``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
+ * 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
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
+#include <wtf/RetainPtr.h>
+#include <wtf/text/WTFString.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS AVOutputContext;
+OBJC_CLASS NSData;
+#endif
+
+namespace WebCore {
+
+class MediaPlaybackTargetContext {
+public:
+ enum class Type : uint8_t {
+ None,
+ AVOutputContext,
+ SerializedAVOutputContext,
+ Mock,
+ };
+
+ enum class MockState : uint8_t {
+ Unknown = 0,
+ OutputDeviceUnavailable = 1,
+ OutputDeviceAvailable = 2,
+ };
+
+ MediaPlaybackTargetContext() = default;
+ WEBCORE_EXPORT explicit MediaPlaybackTargetContext(RetainPtr<AVOutputContext>&&);
+
+ MediaPlaybackTargetContext(RetainPtr<NSData>&& serializedOutputContext, bool hasActiveRoute)
+ : m_type(Type::SerializedAVOutputContext)
+ , m_serializedOutputContext(WTFMove(serializedOutputContext))
+ , m_cachedHasActiveRoute(hasActiveRoute)
+ {
+ ASSERT(m_serializedOutputContext);
+ }
+
+ MediaPlaybackTargetContext(const String& mockDeviceName, MockState state)
+ : m_type(Type::Mock)
+ , m_mockDeviceName(mockDeviceName)
+ , m_mockState(state)
+ {
+ }
+
+ Type type() const { return m_type; }
+ WEBCORE_EXPORT String deviceName() const;
+ WEBCORE_EXPORT bool hasActiveRoute() const;
+ bool supportsRemoteVideoPlayback() const;
+
+ MockState mockState() const
+ {
+ ASSERT(m_type == Type::Mock);
+ return m_mockState;
+ }
+
+ RetainPtr<AVOutputContext> outputContext() const
+ {
+ ASSERT(m_type == Type::AVOutputContext);
+ return m_outputContext;
+ }
+
+ RetainPtr<NSData> serializedOutputContext() const
+ {
+ ASSERT(m_type == Type::SerializedAVOutputContext);
+ return m_serializedOutputContext;
+ }
+
+ WEBCORE_EXPORT bool serializeOutputContext();
+ WEBCORE_EXPORT bool deserializeOutputContext();
+
+ bool encodingRequiresPlatformData() const { return m_type == Type::AVOutputContext || m_type == Type::SerializedAVOutputContext; }
+
+private:
+ Type m_type { Type::None };
+ RetainPtr<AVOutputContext> m_outputContext;
+ RetainPtr<NSData> m_serializedOutputContext;
+ bool m_cachedHasActiveRoute { false };
+
+ String m_mockDeviceName;
+ MockState m_mockState { MockState::Unknown };
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::MediaPlaybackTargetContext::Type> {
+ using values = EnumValues<
+ WebCore::MediaPlaybackTargetContext::Type,
+ WebCore::MediaPlaybackTargetContext::Type::None,
+ WebCore::MediaPlaybackTargetContext::Type::AVOutputContext,
+ WebCore::MediaPlaybackTargetContext::Type::SerializedAVOutputContext,
+ WebCore::MediaPlaybackTargetContext::Type::Mock
+ >;
+};
+
+template<> struct EnumTraits<WebCore::MediaPlaybackTargetContext::MockState> {
+ using values = EnumValues<
+ WebCore::MediaPlaybackTargetContext::MockState,
+ WebCore::MediaPlaybackTargetContext::MockState::Unknown,
+ WebCore::MediaPlaybackTargetContext::MockState::OutputDeviceUnavailable,
+ WebCore::MediaPlaybackTargetContext::MockState::OutputDeviceAvailable
+ >;
+};
+
+} // namespace WTF
+
+#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
Added: trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.mm (0 => 276177)
--- trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/MediaPlaybackTargetContext.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "MediaPlaybackTargetContext.h"
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
+#import <Foundation/Foundation.h>
+#import <objc/runtime.h>
+#import <pal/spi/cocoa/AVFoundationSPI.h>
+#import <pal/cocoa/AVFoundationSoftLink.h>
+
+namespace WebCore {
+
+MediaPlaybackTargetContext::MediaPlaybackTargetContext(RetainPtr<AVOutputContext>&& outputContext)
+ : m_outputContext(outputContext)
+{
+ ASSERT(m_outputContext);
+ m_type = MediaPlaybackTargetContext::Type::AVOutputContext;
+}
+
+String MediaPlaybackTargetContext::deviceName() const
+{
+ ASSERT(m_type == MediaPlaybackTargetContext::Type::Mock || m_type == MediaPlaybackTargetContext::Type::AVOutputContext);
+
+ if (m_type == MediaPlaybackTargetContext::Type::Mock)
+ return m_mockDeviceName;
+
+ ASSERT(m_type == MediaPlaybackTargetContext::Type::AVOutputContext);
+ String deviceName;
+ if (![m_outputContext supportsMultipleOutputDevices])
+ deviceName = [m_outputContext deviceName];
+ else {
+ auto outputDeviceNames = adoptNS([[NSMutableArray alloc] init]);
+ for (AVOutputDevice *outputDevice in [m_outputContext outputDevices])
+ [outputDeviceNames addObject:[outputDevice deviceName]];
+
+ deviceName = [outputDeviceNames componentsJoinedByString:@" + "];
+ }
+
+ return deviceName;
+}
+bool MediaPlaybackTargetContext::hasActiveRoute() const
+{
+ ASSERT(m_type != MediaPlaybackTargetContext::Type::None);
+ if (m_type == MediaPlaybackTargetContext::Type::Mock)
+ return !m_mockDeviceName.isEmpty();
+
+ // FIXME: It may not be safe to use the cached `hasActiveRoute` of a serialized AVOutputContext
+ if (m_type == MediaPlaybackTargetContext::Type::SerializedAVOutputContext)
+ return m_cachedHasActiveRoute;
+
+ ASSERT(m_type == MediaPlaybackTargetContext::Type::AVOutputContext);
+ bool hasActiveRoute = false;
+ if ([m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] && [m_outputContext supportsMultipleOutputDevices] && [m_outputContext respondsToSelector:@selector(outputDevices)]) {
+ for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
+ if (outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio))
+ hasActiveRoute = true;
+ }
+ } else if ([m_outputContext respondsToSelector:@selector(outputDevice)]) {
+ if (auto *outputDevice = [m_outputContext outputDevice])
+ hasActiveRoute = outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio);
+ } else
+ hasActiveRoute = m_outputContext.get().deviceName;
+
+ return hasActiveRoute;
+}
+bool MediaPlaybackTargetContext::supportsRemoteVideoPlayback() const
+{
+ ASSERT(m_type == MediaPlaybackTargetContext::Type::Mock || m_type == MediaPlaybackTargetContext::Type::AVOutputContext);
+ if (m_type == MediaPlaybackTargetContext::Type::Mock)
+ return !m_mockDeviceName.isEmpty();
+
+ bool supportsRemoteVideoPlayback = false;
+ if (![m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] || ![m_outputContext supportsMultipleOutputDevices] || ![m_outputContext respondsToSelector:@selector(outputDevices)]) {
+ if (auto *outputDevice = [m_outputContext outputDevice]) {
+ if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
+ supportsRemoteVideoPlayback = true;
+ }
+ } else {
+ for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
+ if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
+ supportsRemoteVideoPlayback = true;
+ }
+ }
+
+ return supportsRemoteVideoPlayback;
+}
+
+bool MediaPlaybackTargetContext::serializeOutputContext()
+{
+ ASSERT(m_type != MediaPlaybackTargetContext::Type::SerializedAVOutputContext);
+ if (m_type != MediaPlaybackTargetContext::Type::AVOutputContext)
+ return false;
+
+ auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
+ [archiver encodeObject:m_outputContext.get() forKey:NSKeyedArchiveRootObjectKey];
+ [archiver finishEncoding];
+
+ m_serializedOutputContext = [archiver encodedData];
+ m_type = MediaPlaybackTargetContext::Type::SerializedAVOutputContext;
+ m_outputContext.clear();
+
+ return true;
+}
+
+bool MediaPlaybackTargetContext::deserializeOutputContext()
+{
+ ASSERT(m_type != MediaPlaybackTargetContext::Type::AVOutputContext);
+ if (m_type != MediaPlaybackTargetContext::Type::SerializedAVOutputContext)
+ return false;
+
+ bool success = false;
+ auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:m_serializedOutputContext.get() error:nullptr]);
+ unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
+ auto allowedClassSet = adoptNS([[NSSet alloc] initWithArray:@[ PAL::getAVOutputContextClass() ]]);
+
+ @try {
+ id result = [unarchiver decodeObjectOfClasses:allowedClassSet.get() forKey:NSKeyedArchiveRootObjectKey];
+ ASSERT(result);
+ if (result) {
+ m_outputContext = result;
+ m_type = MediaPlaybackTargetContext::Type::AVOutputContext;
+ m_serializedOutputContext.clear();
+ success = true;
+ }
+ } @catch (NSException *exception) {
+ LOG_ERROR("Failed to decode object of class AVOutputContext : %@", exception);
+ } @finally {
+ [unarchiver finishDecoding];
+ unarchiver.get().delegate = nil;
+ }
+
+ return success;
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.cpp (276176 => 276177)
--- trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -30,26 +30,18 @@
namespace WebCore {
-Ref<MediaPlaybackTarget> MediaPlaybackTargetMock::create(const String& name, MediaPlaybackTargetContext::State state)
+Ref<MediaPlaybackTarget> MediaPlaybackTargetMock::create(const String& name, MediaPlaybackTargetContext::MockState state)
{
return adoptRef(*new MediaPlaybackTargetMock(name, state));
}
-MediaPlaybackTargetMock::MediaPlaybackTargetMock(const String& name, MediaPlaybackTargetContext::State state)
- : MediaPlaybackTarget()
- , m_name(name)
- , m_state(state)
+MediaPlaybackTargetMock::MediaPlaybackTargetMock(const String& name, MediaPlaybackTargetContext::MockState state)
+ : m_context(name, state)
{
}
MediaPlaybackTargetMock::~MediaPlaybackTargetMock() = default;
-const MediaPlaybackTargetContext& MediaPlaybackTargetMock::targetContext() const
-{
- m_context = MediaPlaybackTargetContext(m_name, m_state);
- return m_context;
-}
-
MediaPlaybackTargetMock* toMediaPlaybackTargetMock(MediaPlaybackTarget* rep)
{
return const_cast<MediaPlaybackTargetMock*>(toMediaPlaybackTargetMock(const_cast<const MediaPlaybackTarget*>(rep)));
@@ -57,7 +49,7 @@
const MediaPlaybackTargetMock* toMediaPlaybackTargetMock(const MediaPlaybackTarget* rep)
{
- ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::Mock);
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::TargetType::Mock);
return static_cast<const MediaPlaybackTargetMock*>(rep);
}
Modified: trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.h (276176 => 276177)
--- trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -23,13 +23,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MediaPlaybackTargetMock_h
-#define MediaPlaybackTargetMock_h
+#pragma once
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
#include "MediaPlaybackTarget.h"
-#include "MediaPlaybackTargetContext.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -36,27 +34,19 @@
class MediaPlaybackTargetMock : public MediaPlaybackTarget {
public:
- WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(const String&, MediaPlaybackTargetContext::State);
+ WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(const String&, MediaPlaybackTargetContext::MockState);
virtual ~MediaPlaybackTargetMock();
- TargetType targetType() const final { return Mock; }
+ TargetType targetType() const final { return MediaPlaybackTarget::TargetType::Mock; }
+ const MediaPlaybackTargetContext& targetContext() const final { return m_context; }
- const MediaPlaybackTargetContext& targetContext() const final;
+ MediaPlaybackTargetContext::MockState state() const { return m_context.mockState(); }
- bool hasActiveRoute() const final { return !m_name.isEmpty(); }
- bool supportsRemoteVideoPlayback() const final { return !m_name.isEmpty(); }
-
- String deviceName() const final { return m_name; }
-
- MediaPlaybackTargetContext::State state() const;
-
protected:
- MediaPlaybackTargetMock(const String&, MediaPlaybackTargetContext::State);
+ MediaPlaybackTargetMock(const String&, MediaPlaybackTargetContext::MockState);
- String m_name;
- MediaPlaybackTargetContext::State m_state { MediaPlaybackTargetContext::Unknown };
- mutable MediaPlaybackTargetContext m_context;
+ MediaPlaybackTargetContext m_context;
};
MediaPlaybackTargetMock* toMediaPlaybackTargetMock(MediaPlaybackTarget*);
@@ -65,5 +55,3 @@
}
#endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
-
-#endif
Modified: trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.cpp (276176 => 276177)
--- trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -52,7 +52,7 @@
bool MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable()
{
LOG(Media, "MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable");
- return m_state == MediaPlaybackTargetContext::OutputDeviceAvailable;
+ return m_state == MediaPlaybackTargetContext::MockState::OutputDeviceAvailable;
}
Ref<MediaPlaybackTarget> MediaPlaybackTargetPickerMock::playbackTarget()
@@ -85,10 +85,10 @@
LOG(Media, "MediaPlaybackTargetPickerMock::startingMonitoringPlaybackTargets");
m_taskQueue.enqueueTask([this] {
- if (m_state == MediaPlaybackTargetContext::OutputDeviceAvailable)
+ if (m_state == MediaPlaybackTargetContext::MockState::OutputDeviceAvailable)
availableDevicesDidChange();
- if (!m_deviceName.isEmpty() && m_state != MediaPlaybackTargetContext::Unknown)
+ if (!m_deviceName.isEmpty() && m_state != MediaPlaybackTargetContext::MockState::Unknown)
currentDeviceDidChange();
});
}
@@ -101,15 +101,15 @@
void MediaPlaybackTargetPickerMock::invalidatePlaybackTargets()
{
LOG(Media, "MediaPlaybackTargetPickerMock::invalidatePlaybackTargets");
- setState(emptyString(), MediaPlaybackTargetContext::Unknown);
+ setState(emptyString(), MediaPlaybackTargetContext::MockState::Unknown);
}
-void MediaPlaybackTargetPickerMock::setState(const String& deviceName, MediaPlaybackTargetContext::State state)
+void MediaPlaybackTargetPickerMock::setState(const String& deviceName, MediaPlaybackTargetContext::MockState state)
{
LOG(Media, "MediaPlaybackTargetPickerMock::setState - name = %s, state = 0x%x", deviceName.utf8().data(), (unsigned)state);
m_taskQueue.enqueueTask([this, state, deviceName] {
- if (deviceName != m_deviceName && state != MediaPlaybackTargetContext::Unknown) {
+ if (deviceName != m_deviceName && state != MediaPlaybackTargetContext::MockState::Unknown) {
m_deviceName = deviceName;
currentDeviceDidChange();
}
Modified: trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.h (276176 => 276177)
--- trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -48,7 +48,7 @@
void stopMonitoringPlaybackTargets() override;
void invalidatePlaybackTargets() override;
- void setState(const String&, MediaPlaybackTargetContext::State);
+ void setState(const String&, MediaPlaybackTargetContext::MockState);
void dismissPopup();
private:
@@ -57,7 +57,7 @@
String m_deviceName;
GenericTaskQueue<Timer> m_taskQueue;
- MediaPlaybackTargetContext::State m_state { MediaPlaybackTargetContext::Unknown };
+ MediaPlaybackTargetContext::MockState m_state { MediaPlaybackTargetContext::MockState::Unknown };
bool m_showingMenu { false };
};
Modified: trunk/Source/WebCore/testing/Internals.cpp (276176 => 276177)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -559,7 +559,7 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
page.setMockMediaPlaybackTargetPickerEnabled(true);
- page.setMockMediaPlaybackTargetPickerState(emptyString(), MediaPlaybackTargetContext::Unknown);
+ page.setMockMediaPlaybackTargetPickerState(emptyString(), MediaPlaybackTargetContext::MockState::Unknown);
#endif
#if ENABLE(VIDEO)
@@ -4531,14 +4531,14 @@
Page* page = contextDocument()->frame()->page();
ASSERT(page);
- MediaPlaybackTargetContext::State state = MediaPlaybackTargetContext::Unknown;
+ MediaPlaybackTargetContext::MockState state = MediaPlaybackTargetContext::MockState::Unknown;
if (equalLettersIgnoringASCIICase(deviceState, "deviceavailable"))
- state = MediaPlaybackTargetContext::OutputDeviceAvailable;
+ state = MediaPlaybackTargetContext::MockState::OutputDeviceAvailable;
else if (equalLettersIgnoringASCIICase(deviceState, "deviceunavailable"))
- state = MediaPlaybackTargetContext::OutputDeviceUnavailable;
+ state = MediaPlaybackTargetContext::MockState::OutputDeviceUnavailable;
else if (equalLettersIgnoringASCIICase(deviceState, "unknown"))
- state = MediaPlaybackTargetContext::Unknown;
+ state = MediaPlaybackTargetContext::MockState::Unknown;
else
return Exception { InvalidAccessError };
Modified: trunk/Source/WebKit/ChangeLog (276176 => 276177)
--- trunk/Source/WebKit/ChangeLog 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/ChangeLog 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1,3 +1,50 @@
+2021-04-16 Peng Liu <[email protected]>
+
+ [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=224469
+
+ Reviewed by Eric Carlson.
+
+ * Scripts/webkit/messages.py: Fix clean build failures on the WinCairo port.
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+ (WebKit::RemoteMediaPlayerProxy::setWirelessPlaybackTarget):
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+
+ * GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp:
+ (WebKit::RemoteMediaSessionHelperProxy::activeVideoRouteDidChange):
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData):
+ (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<MediaPlaybackTargetContext>::encode):
+ (IPC::ArgumentCoder<MediaPlaybackTargetContext>::decode):
+ * Shared/WebCoreArgumentCoders.h:
+ * Shared/mac/WebCoreArgumentCodersMac.mm:
+ (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData): Deleted.
+ (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData): Deleted.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::mediaRelatedIOKitClasses):
+ (WebKit::WebPageProxy::creationParameters):
+ (WebKit::WebPageProxy::setMockMediaPlaybackTargetPickerState):
+ (WebKit::WebPageProxy::setPlaybackTarget):
+ (WebKit::temporaryMachServices): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+
+ * WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp:
+ (WebKit::RemoteMediaSessionHelper::activeVideoRouteDidChange):
+
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::setMockMediaPlaybackTargetPickerState):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::playbackTargetSelected const):
+
2021-04-16 Alex Christensen <[email protected]>
Disable ApplicationCache with linkedOnOrAfter check
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (276176 => 276177)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -59,6 +59,7 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
#include <WebCore/MediaPlaybackTargetCocoa.h>
+#include <WebCore/MediaPlaybackTargetContext.h>
#include <WebCore/MediaPlaybackTargetMock.h>
#endif
@@ -697,20 +698,21 @@
m_player->setShouldPlayToPlaybackTarget(shouldPlay);
}
-void RemoteMediaPlayerProxy::setWirelessPlaybackTarget(const WebCore::MediaPlaybackTargetContext& targetContext)
+void RemoteMediaPlayerProxy::setWirelessPlaybackTarget(MediaPlaybackTargetContext&& targetContext)
{
switch (targetContext.type()) {
- case MediaPlaybackTargetContext::AVOutputContextType:
- m_player->setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
+ case MediaPlaybackTargetContext::Type::SerializedAVOutputContext: {
+ if (targetContext.deserializeOutputContext())
+ m_player->setWirelessPlaybackTarget(MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
break;
+ }
+ case MediaPlaybackTargetContext::Type::Mock:
#if PLATFORM(MAC)
- case MediaPlaybackTargetContext::MockType:
- m_player->setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetMock::create(targetContext.mockDeviceName(), targetContext.mockState()));
+ m_player->setWirelessPlaybackTarget(MediaPlaybackTargetMock::create(targetContext.deviceName(), targetContext.mockState()));
break;
-#else
- case MediaPlaybackTargetContext::MockType:
#endif
- case MediaPlaybackTargetContext::None:
+ case MediaPlaybackTargetContext::Type::AVOutputContext:
+ case MediaPlaybackTargetContext::Type::None:
ASSERT_NOT_REACHED();
break;
}
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (276176 => 276177)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -152,7 +152,7 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
void setWirelessVideoPlaybackDisabled(bool);
void setShouldPlayToPlaybackTarget(bool);
- void setWirelessPlaybackTarget(const WebCore::MediaPlaybackTargetContext&);
+ void setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetContext&&);
void mediaPlayerCurrentPlaybackTargetIsWirelessChanged(bool) final;
#endif
Modified: trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp (276176 => 276177)
--- trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -108,7 +108,11 @@
void RemoteMediaSessionHelperProxy::activeVideoRouteDidChange(SupportsAirPlayVideo supportsAirPlayVideo, Ref<WebCore::MediaPlaybackTarget>&& target)
{
- m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ActiveVideoRouteDidChange(supportsAirPlayVideo, target->targetContext()), { });
+ auto context = target->targetContext();
+ if (!context.serializeOutputContext())
+ return;
+
+ m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ActiveVideoRouteDidChange(supportsAirPlayVideo, context), { });
}
}
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (276176 => 276177)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2021-04-16 22:54:15 UTC (rev 276177)
@@ -352,6 +352,7 @@
'"InputMethodState.h"': ["PLATFORM(GTK)", "PLATFORM(WPE)"],
'"LayerHostingContext.h"': ["PLATFORM(COCOA)", ],
'"GestureTypes.h"': ["PLATFORM(IOS_FAMILY)"],
+ '<WebCore/MediaPlaybackTargetContext.h>': ["ENABLE(WIRELESS_PLAYBACK_TARGET)"],
}
if not header in conditions:
return None
Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (276176 => 276177)
--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -41,6 +41,15 @@
#import <UIKit/UIFont.h>
#endif
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#import <WebCore/MediaPlaybackTargetContext.h>
+#import <objc/runtime.h>
+#endif
+
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WebCoreArgumentCodersCocoaAdditions.mm>
+#endif
+
#if ENABLE(APPLE_PAY)
#import "DataReference.h"
#import <WebCore/PaymentAuthorizationStatus.h>
@@ -47,8 +56,8 @@
#import <pal/cocoa/PassKitSoftLink.h>
#endif
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/WebCoreArgumentCodersCocoaAdditions.mm>
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#import <pal/cocoa/AVFoundationSoftLink.h>
#endif
namespace IPC {
@@ -606,4 +615,50 @@
return true;
}
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const MediaPlaybackTargetContext& target)
+{
+ if (target.type() == MediaPlaybackTargetContext::Type::AVOutputContext) {
+ if ([PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
+ encoder << target.outputContext();
+ } else if (target.type() == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
+ encoder << target.serializedOutputContext();
+ encoder << target.hasActiveRoute();
+ } else
+ ASSERT_NOT_REACHED();
+}
+
+bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, MediaPlaybackTargetContext::Type contextType, MediaPlaybackTargetContext& target)
+{
+ ASSERT(contextType != MediaPlaybackTargetContext::Type::Mock);
+
+ if (contextType == MediaPlaybackTargetContext::Type::AVOutputContext) {
+ if (![PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
+ return false;
+
+ auto outputContext = IPC::decode<AVOutputContext>(decoder, PAL::getAVOutputContextClass());
+ if (!outputContext)
+ return false;
+
+ target = WebCore::MediaPlaybackTargetContext { WTFMove(*outputContext) };
+ return true;
+ }
+
+ if (contextType == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
+ RetainPtr<NSData> serializedOutputContext;
+ if (!IPC::decode(decoder, serializedOutputContext) || !serializedOutputContext)
+ return false;
+
+ bool hasActiveRoute;
+ if (!decoder.decode(hasActiveRoute))
+ return false;
+
+ target = WebCore::MediaPlaybackTargetContext { WTFMove(serializedOutputContext), hasActiveRoute };
+ return true;
+ }
+
+ return false;
+}
+#endif
+
} // namespace IPC
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (276176 => 276177)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -2457,8 +2457,8 @@
bool hasPlatformData = target.encodingRequiresPlatformData();
encoder << hasPlatformData;
- int32_t targetType = target.type();
- encoder << targetType;
+ MediaPlaybackTargetContext::Type contextType = target.type();
+ encoder << contextType;
if (target.encodingRequiresPlatformData()) {
encodePlatformData(encoder, target);
@@ -2465,9 +2465,9 @@
return;
}
- ASSERT(targetType == MediaPlaybackTargetContext::MockType);
- encoder << target.mockDeviceName();
- encoder << static_cast<int32_t>(target.mockState());
+ ASSERT(contextType == MediaPlaybackTargetContext::Type::Mock);
+ encoder << target.deviceName();
+ encoder << target.mockState();
}
bool ArgumentCoder<MediaPlaybackTargetContext>::decode(Decoder& decoder, MediaPlaybackTargetContext& target)
@@ -2476,24 +2476,24 @@
if (!decoder.decode(hasPlatformData))
return false;
- int32_t targetType;
- if (!decoder.decode(targetType))
+ MediaPlaybackTargetContext::Type contextType;
+ if (!decoder.decode(contextType))
return false;
if (hasPlatformData)
- return decodePlatformData(decoder, target);
+ return decodePlatformData(decoder, contextType, target);
- ASSERT(targetType == MediaPlaybackTargetContext::MockType);
-
- String mockDeviceName;
- if (!decoder.decode(mockDeviceName))
+ ASSERT(contextType == MediaPlaybackTargetContext::Type::Mock);
+ String deviceName;
+ if (!decoder.decode(deviceName))
return false;
- int32_t mockState;
+ MediaPlaybackTargetContext::MockState mockState;
if (!decoder.decode(mockState))
return false;
- target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState));
+ target = MediaPlaybackTargetContext(deviceName, mockState);
+
return true;
}
#endif
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (276176 => 276177)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -54,6 +54,10 @@
#include <WebCore/CurlProxySettings.h>
#endif
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#include <WebCore/MediaPlaybackTargetContext.h>
+#endif
+
#if ENABLE(ENCRYPTED_MEDIA)
#include <WebCore/CDMInstance.h>
#include <WebCore/CDMInstanceSession.h>
@@ -195,10 +199,6 @@
class ContentFilterUnblockHandler;
#endif
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-class MediaPlaybackTargetContext;
-#endif
-
#if ENABLE(MEDIA_STREAM)
struct MediaConstraints;
#endif
@@ -644,7 +644,7 @@
static void encode(Encoder&, const WebCore::MediaPlaybackTargetContext&);
static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::MediaPlaybackTargetContext&);
static void encodePlatformData(Encoder&, const WebCore::MediaPlaybackTargetContext&);
- static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::MediaPlaybackTargetContext&);
+ static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::MediaPlaybackTargetContext::Type, WebCore::MediaPlaybackTargetContext&);
};
#endif
Modified: trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm (276176 => 276177)
--- trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -42,12 +42,6 @@
#import <wtf/MachSendRight.h>
#import <wtf/cf/TypeCastsCF.h>
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-#import <WebCore/MediaPlaybackTargetContext.h>
-#import <objc/runtime.h>
-#import <pal/cocoa/AVFoundationSoftLink.h>
-#endif
-
namespace IPC {
void ArgumentCoder<WebCore::CertificateInfo>::encode(Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
@@ -403,29 +397,6 @@
#endif
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-
-void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const WebCore::MediaPlaybackTargetContext& target)
-{
- if ([PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
- encoder << target.avOutputContext();
-}
-
-bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, WebCore::MediaPlaybackTargetContext& target)
-{
- if (![PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
- return false;
-
- auto context = IPC::decode<AVOutputContext>(decoder, PAL::getAVOutputContextClass());
- if (!context)
- return false;
-
- target = WebCore::MediaPlaybackTargetContext { context->get() };
- return true;
-}
-
-#endif
-
#if ENABLE(VIDEO)
void ArgumentCoder<WebCore::SerializedPlatformDataCueValue>::encodePlatformData(Encoder& encoder, const WebCore::SerializedPlatformDataCueValue& value)
{
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (276176 => 276177)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -7844,14 +7844,6 @@
});
return services;
}
-
-static const Vector<ASCIILiteral>& temporaryMachServices()
-{
- static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
- "com.apple.coremedia.routingcontext.xpc"_s // Remove after <rdar://76403302> is fixed.
- });
- return services;
-}
#endif
WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea, RefPtr<API::WebsitePolicies>&& websitePolicies)
@@ -7947,9 +7939,6 @@
// FIXME(207716): The following should be removed when the GPU process is complete.
parameters.mediaExtensionHandles = SandboxExtension::createHandlesForMachLookup(mediaRelatedMachServices(), WTF::nullopt);
parameters.mediaIOKitExtensionHandles = SandboxExtension::createHandlesForIOKitClassExtensions(mediaRelatedIOKitClasses(), WTF::nullopt);
- } else {
- // FIXME(224327): Remove this else clause once <rdar://76403302> is fixed.
- parameters.mediaExtensionHandles = SandboxExtension::createHandlesForMachLookup(temporaryMachServices(), WTF::nullopt);
}
if (!preferences().useGPUProcessForMediaEnabled()
@@ -9415,7 +9404,7 @@
pageClient().mediaSessionManager().setMockMediaPlaybackTargetPickerEnabled(enabled);
}
-void WebPageProxy::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::State state)
+void WebPageProxy::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::MockState state)
{
pageClient().mediaSessionManager().setMockMediaPlaybackTargetPickerState(name, state);
}
@@ -9430,7 +9419,12 @@
if (!hasRunningProcess())
return;
- send(Messages::WebPage::PlaybackTargetSelected(contextId, target->targetContext()));
+ auto context = target->targetContext();
+ ASSERT(context.type() != MediaPlaybackTargetContext::Type::SerializedAVOutputContext);
+ if (preferences().useGPUProcessForMediaEnabled())
+ context.serializeOutputContext();
+
+ send(Messages::WebPage::PlaybackTargetSelected(contextId, context));
}
void WebPageProxy::externalOutputDeviceAvailableDidChange(PlaybackTargetClientContextIdentifier contextId, bool available)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (276176 => 276177)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -94,7 +94,6 @@
#include <WebCore/LayoutPoint.h>
#include <WebCore/LayoutSize.h>
#include <WebCore/MediaControlsContextMenuItem.h>
-#include <WebCore/MediaPlaybackTargetContext.h>
#include <WebCore/MediaProducer.h>
#include <WebCore/PageIdentifier.h>
#include <WebCore/PlatformEvent.h>
@@ -129,6 +128,10 @@
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#include <WebCore/MediaPlaybackTargetContext.h>
+#endif
+
#if PLATFORM(IOS_FAMILY)
#include "GestureTypes.h"
#include "WebAutocorrectionContext.h"
@@ -1567,7 +1570,7 @@
void showPlaybackTargetPicker(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::FloatRect&, bool hasVideo);
void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags);
void setMockMediaPlaybackTargetPickerEnabled(bool);
- void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State);
+ void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState);
void mockMediaPlaybackTargetPickerDismissPopup();
// WebMediaSessionManagerClient
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (276176 => 276177)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-04-16 22:54:15 UTC (rev 276177)
@@ -476,7 +476,7 @@
ShowPlaybackTargetPicker(WebCore::PlaybackTargetClientContextIdentifier contextId, WebCore::FloatRect pickerLocation, bool hasVideo)
PlaybackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier contextId, unsigned mediaState)
SetMockMediaPlaybackTargetPickerEnabled(bool enabled)
- SetMockMediaPlaybackTargetPickerState(String name, unsigned pickerState)
+ SetMockMediaPlaybackTargetPickerState(String name, enum:uint8_t WebCore::MediaPlaybackTargetContext::MockState pickerState)
MockMediaPlaybackTargetPickerDismissPopup()
#endif
Modified: trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp (276176 => 276177)
--- trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -81,12 +81,11 @@
void RemoteMediaSessionHelper::activeVideoRouteDidChange(SupportsAirPlayVideo supportsAirPlayVideo, MediaPlaybackTargetContext&& targetContext)
{
- if (targetContext.type() != MediaPlaybackTargetContext::AVOutputContextType) {
- ASSERT_NOT_REACHED();
+ ASSERT(targetContext.type() != MediaPlaybackTargetContext::Type::AVOutputContext);
+ if (targetContext.type() == MediaPlaybackTargetContext::Type::AVOutputContext)
return;
- }
- WebCore::MediaSessionHelper::activeVideoRouteDidChange(supportsAirPlayVideo, WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
+ WebCore::MediaSessionHelper::activeVideoRouteDidChange(supportsAirPlayVideo, WebCore::MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
}
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (276176 => 276177)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1352,7 +1352,7 @@
m_page.send(Messages::WebPageProxy::SetMockMediaPlaybackTargetPickerEnabled(enabled));
}
-void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
+void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
{
m_page.send(Messages::WebPageProxy::SetMockMediaPlaybackTargetPickerState(name, state));
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (276176 => 276177)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -378,7 +378,7 @@
void showPlaybackTargetPicker(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::IntPoint&, bool) final;
void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags) final;
void setMockMediaPlaybackTargetPickerEnabled(bool) final;
- void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
+ void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState) final;
void mockMediaPlaybackTargetPickerDismissPopup() final;
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (276176 => 276177)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1791,7 +1791,7 @@
void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
- void playbackTargetSelected(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::MediaPlaybackTargetContext& outputDevice) const;
+ void playbackTargetSelected(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaPlaybackTargetContext&&) const;
void playbackTargetAvailabilityDidChange(WebCore::PlaybackTargetClientContextIdentifier, bool);
void setShouldPlayToPlaybackTarget(WebCore::PlaybackTargetClientContextIdentifier, bool);
void playbackTargetPickerWasDismissed(WebCore::PlaybackTargetClientContextIdentifier);
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (276176 => 276177)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -35,7 +35,6 @@
#import "FontInfo.h"
#import "FrameInfoData.h"
#import "InjectedBundleHitTestResult.h"
-#import "PDFKitSoftLink.h"
#import "PDFPlugin.h"
#import "PageBanner.h"
#import "PluginView.h"
@@ -99,9 +98,12 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
#import <WebCore/MediaPlaybackTargetCocoa.h>
+#import <WebCore/MediaPlaybackTargetContext.h>
#import <WebCore/MediaPlaybackTargetMock.h>
#endif
+#import "PDFKitSoftLink.h"
+
namespace WebKit {
using namespace WebCore;
@@ -1042,16 +1044,17 @@
}
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
-void WebPage::playbackTargetSelected(PlaybackTargetClientContextIdentifier contextId, const WebCore::MediaPlaybackTargetContext& targetContext) const
+void WebPage::playbackTargetSelected(PlaybackTargetClientContextIdentifier contextId, WebCore::MediaPlaybackTargetContext&& targetContext) const
{
switch (targetContext.type()) {
- case MediaPlaybackTargetContext::AVOutputContextType:
- m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
+ case MediaPlaybackTargetContext::Type::AVOutputContext:
+ case MediaPlaybackTargetContext::Type::SerializedAVOutputContext:
+ m_page->setPlaybackTarget(contextId, MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
break;
- case MediaPlaybackTargetContext::MockType:
- m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetMock::create(targetContext.mockDeviceName(), targetContext.mockState()));
+ case MediaPlaybackTargetContext::Type::Mock:
+ m_page->setPlaybackTarget(contextId, MediaPlaybackTargetMock::create(targetContext.deviceName(), targetContext.mockState()));
break;
- case MediaPlaybackTargetContext::None:
+ case MediaPlaybackTargetContext::Type::None:
ASSERT_NOT_REACHED();
break;
}
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1,3 +1,20 @@
+2021-04-16 Peng Liu <[email protected]>
+
+ [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=224469
+
+ Reviewed by Eric Carlson.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::setMockMediaPlaybackTargetPickerState):
+ * WebView/WebMediaPlaybackTargetPicker.h:
+ * WebView/WebMediaPlaybackTargetPicker.mm:
+ (WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState):
+ * WebView/WebView.mm:
+ (-[WebView _setMockMediaPlaybackTargetPickerName:state:]):
+ * WebView/WebViewInternal.h:
+
2021-04-15 Commit Queue <[email protected]>
Unreviewed, reverting r276107.
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -243,7 +243,7 @@
void showPlaybackTargetPicker(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::IntPoint&, bool /* hasVideo */) final;
void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags) final;
void setMockMediaPlaybackTargetPickerEnabled(bool) final;
- void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
+ void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState) final;
void mockMediaPlaybackTargetPickerDismissPopup() override;
#endif
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -1129,7 +1129,7 @@
[m_webView _setMockMediaPlaybackTargetPickerEnabled:enabled];
}
-void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
+void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
{
[m_webView _setMockMediaPlaybackTargetPickerName:name state:state];
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.h (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -53,7 +53,7 @@
void showPlaybackTargetPicker(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::FloatRect&, bool hasVideo);
void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags);
void setMockMediaPlaybackTargetPickerEnabled(bool);
- void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State);
+ void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState);
void mockMediaPlaybackTargetPickerDismissPopup();
void invalidate();
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.mm (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -68,7 +68,7 @@
WebCore::WebMediaSessionManager::shared().setMockMediaPlaybackTargetPickerEnabled(enabled);
}
-void WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::State state)
+void WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::MockState state)
{
WebCore::WebMediaSessionManager::shared().setMockMediaPlaybackTargetPickerState(name, state);
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2021-04-16 22:54:15 UTC (rev 276177)
@@ -9232,7 +9232,7 @@
[self _devicePicker]->setMockMediaPlaybackTargetPickerEnabled(enabled);
}
-- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state
+- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::MockState)state
{
[self _devicePicker]->setMockMediaPlaybackTargetPickerState(name, state);
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h (276176 => 276177)
--- trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2021-04-16 22:50:31 UTC (rev 276176)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h 2021-04-16 22:54:15 UTC (rev 276177)
@@ -327,7 +327,7 @@
- (void)_showPlaybackTargetPicker:(WebCore::PlaybackTargetClientContextIdentifier)contextId location:(const WebCore::IntPoint&)location hasVideo:(BOOL)hasVideo;
- (void)_playbackTargetPickerClientStateDidChange:(WebCore::PlaybackTargetClientContextIdentifier)contextId state:(WebCore::MediaProducer::MediaStateFlags)state;
- (void)_setMockMediaPlaybackTargetPickerEnabled:(bool)enabled;
-- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state;
+- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::MockState)state;
- (void)_mockMediaPlaybackTargetPickerDismissPopup;
#endif