⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276177 in webkit


Ignore:
Timestamp:
Apr 16, 2021, 3:54:15 PM (5 years ago)
Author:
Peng Liu
Message:

[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.

Source/WebCore:

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):

Source/WebKit:

  • 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):

Source/WebKitLegacy/mac:

  • 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:
Location:
trunk/Source
Files:
2 added
1 deleted
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276169 r276177  
     12021-04-16  Peng Liu  <peng.liu6@apple.com>
     2
     3        [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=224469
     5
     6        Reviewed by Eric Carlson.
     7
     8        This patch modifies `MediaPlaybackTargetContext` to provide interfaces to serialize/deserialize
     9        `AVOutputContext` and modifies `MediaPlaybackTargetCocoa` to use `MediaPlaybackTargetContext` to
     10        manage its `AVOutputContext` instead of keeping a pointer to the `AVOutputContext` object.
     11        With these changes, a WebContent process can forward a serialized `AVOutputContext` object
     12        to other processes (e.g., the GPU process) without deserializing it. Therefore, the WebContent
     13        process does not need access to the CoreMedia routing service. So we can remove the fix (r275669)
     14        for bug 224328.
     15
     16        Covered by existing tests.
     17
     18        * Modules/airplay/WebMediaSessionManager.cpp:
     19        (WebCore::WebMediaSessionManager::setMockMediaPlaybackTargetPickerState):
     20        * Modules/airplay/WebMediaSessionManager.h:
     21
     22        * Headers.cmake:
     23        * SourcesCocoa.txt:
     24        * WebCore.xcodeproj/project.pbxproj:
     25        Modify the project file because `MediaPlaybackTargetContext` is used in Cocoa ports only.
     26
     27        * page/ChromeClient.h:
     28        (WebCore::ChromeClient::setMockMediaPlaybackTargetPickerState):
     29        * page/Page.cpp:
     30        (WebCore::Page::setMockMediaPlaybackTargetPickerState):
     31        * page/Page.h:
     32
     33        * platform/graphics/MediaPlaybackTarget.h:
     34        (WebCore::MediaPlaybackTarget::hasActiveRoute const):
     35        (WebCore::MediaPlaybackTarget::deviceName const):
     36        (WebCore::MediaPlaybackTarget::supportsRemoteVideoPlayback):
     37        (): Deleted.
     38        * platform/graphics/MediaPlaybackTargetContext.h: Removed.
     39        * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h:
     40        (WebCore::MediaPlaybackTargetCocoa::outputContext const): Deleted.
     41        * platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm:
     42        (WebCore::MediaPlaybackTargetCocoa::create):
     43        (WebCore::MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa):
     44        (WebCore::MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa):
     45        (WebCore::toMediaPlaybackTargetCocoa):
     46        (WebCore::MediaPlaybackTargetCocoa::supportsRemoteVideoPlayback const): Deleted.
     47        (WebCore::MediaPlaybackTargetCocoa::targetContext const): Deleted.
     48        (WebCore::MediaPlaybackTargetCocoa::hasActiveRoute const): Deleted.
     49        (WebCore::MediaPlaybackTargetCocoa::deviceName const): Deleted.
     50        Don't directly use `AVOutputContext` in this class.
     51
     52        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     53        (WebCore::MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless const):
     54        (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):
     55        (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget):
     56
     57        * platform/graphics/cocoa/MediaPlaybackTargetContext.h: Added.
     58        (WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
     59        (WebCore::MediaPlaybackTargetContext::type const):
     60        (WebCore::MediaPlaybackTargetContext::mockState const):
     61        (WebCore::MediaPlaybackTargetContext::outputContext const):
     62        (WebCore::MediaPlaybackTargetContext::serializedOutputContext const):
     63        (WebCore::MediaPlaybackTargetContext::encodingRequiresPlatformData const):
     64        * platform/graphics/cocoa/MediaPlaybackTargetContext.mm: Added.
     65        (WebCore::MediaPlaybackTargetContext::MediaPlaybackTargetContext):
     66        (WebCore::MediaPlaybackTargetContext::deviceName const):
     67        (WebCore::MediaPlaybackTargetContext::hasActiveRoute const):
     68        (WebCore::MediaPlaybackTargetContext::supportsRemoteVideoPlayback const):
     69        (WebCore::MediaPlaybackTargetContext::serializeOutputContext):
     70        (WebCore::MediaPlaybackTargetContext::deserializeOutputContext):
     71
     72        * platform/mock/MediaPlaybackTargetMock.cpp:
     73        (WebCore::MediaPlaybackTargetMock::create):
     74        (WebCore::MediaPlaybackTargetMock::MediaPlaybackTargetMock):
     75        (WebCore::toMediaPlaybackTargetMock):
     76        (WebCore::MediaPlaybackTargetMock::targetContext const): Deleted.
     77        * platform/mock/MediaPlaybackTargetMock.h:
     78        (WebCore::MediaPlaybackTargetMock::state const):
     79        * platform/mock/MediaPlaybackTargetPickerMock.cpp:
     80        (WebCore::MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable):
     81        (WebCore::MediaPlaybackTargetPickerMock::startingMonitoringPlaybackTargets):
     82        (WebCore::MediaPlaybackTargetPickerMock::invalidatePlaybackTargets):
     83        (WebCore::MediaPlaybackTargetPickerMock::setState):
     84        * platform/mock/MediaPlaybackTargetPickerMock.h:
     85
     86        * testing/Internals.cpp:
     87        (WebCore::Internals::resetToConsistentState):
     88        (WebCore::Internals::setMockMediaPlaybackTargetPickerState):
     89
    1902021-04-16  Zalan Bujtas  <zalan@apple.com>
    291
  • trunk/Source/WebCore/Headers.cmake

    r276120 r276177  
    12701270    platform/graphics/MediaPlaybackTarget.h
    12711271    platform/graphics/MediaPlaybackTargetClient.h
    1272     platform/graphics/MediaPlaybackTargetContext.h
    12731272    platform/graphics/MediaPlaybackTargetPicker.h
    12741273    platform/graphics/MediaPlayer.h
  • trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.cpp

    r276120 r276177  
    162162}
    163163
    164 void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
     164void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
    165165{
    166166    ALWAYS_LOG_MEDIASESSIONMANAGER(__func__);
  • trunk/Source/WebCore/Modules/airplay/WebMediaSessionManager.h

    r276120 r276177  
    5252
    5353    WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerEnabled(bool);
    54     WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State);
     54    WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState);
    5555    WEBCORE_EXPORT void mockMediaPlaybackTargetPickerDismissPopup();
    5656
  • trunk/Source/WebCore/SourcesCocoa.txt

    r276120 r276177  
    370370platform/graphics/cocoa/IntRectCocoa.mm
    371371platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp
     372platform/graphics/cocoa/MediaPlaybackTargetContext.mm
    372373platform/graphics/cocoa/RemoteGraphicsContextGLProxyBaseCocoa.mm
    373374platform/graphics/cocoa/SourceBufferParser.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r276152 r276177  
    69826982                1D0026A82374F9D900CA6CDF /* JSEnterPictureInPictureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEnterPictureInPictureEvent.h; sourceTree = "<group>"; };
    69836983                1D0026A92374F9D900CA6CDF /* JSEnterPictureInPictureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEnterPictureInPictureEvent.cpp; sourceTree = "<group>"; };
     6984                1D008AA5262108C000EE3ADE /* MediaPlaybackTargetContext.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTargetContext.mm; sourceTree = "<group>"; };
    69846985                1D2C82B6236A3F6A0055D6C5 /* PictureInPictureSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PictureInPictureSupport.h; sourceTree = "<group>"; };
    69856986                1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoderIdentifier.h; sourceTree = "<group>"; };
     
    2697126972                                07E3DFD01A9E786500764CA8 /* MediaPlaybackTarget.h */,
    2697226973                                079216531AA560AA00A3C049 /* MediaPlaybackTargetClient.h */,
    26973                                 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */,
    2697426974                                078E43D71ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.cpp */,
    2697526975                                078E43D81ABB6C7E001C2FA6 /* MediaPlaybackTargetPicker.h */,
     
    2718727187                                CDC48AC82149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.cpp */,
    2718827188                                CDC48AC72149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h */,
     27189                                07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */,
     27190                                1D008AA5262108C000EE3ADE /* MediaPlaybackTargetContext.mm */,
    2718927191                                31647FA8251616BD0010F8FB /* OpenGLSoftLinkCocoa.h */,
    2719027192                                31647FA9251616BD0010F8FB /* OpenGLSoftLinkCocoa.mm */,
  • trunk/Source/WebCore/page/ChromeClient.h

    r276120 r276177  
    514514    virtual void playbackTargetPickerClientStateDidChange(PlaybackTargetClientContextIdentifier, MediaProducer::MediaStateFlags) { }
    515515    virtual void setMockMediaPlaybackTargetPickerEnabled(bool)  { }
    516     virtual void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State) { }
     516    virtual void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState) { }
    517517    virtual void mockMediaPlaybackTargetPickerDismissPopup() { }
    518518#endif
  • trunk/Source/WebCore/page/Page.cpp

    r276120 r276177  
    29532953}
    29542954
    2955 void Page::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
     2955void Page::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
    29562956{
    29572957    chrome().client().setMockMediaPlaybackTargetPickerState(name, state);
  • trunk/Source/WebCore/page/Page.h

    r276120 r276177  
    732732    void playbackTargetPickerClientStateDidChange(PlaybackTargetClientContextIdentifier, MediaProducer::MediaStateFlags);
    733733    WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerEnabled(bool);
    734     WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::State);
     734    WEBCORE_EXPORT void setMockMediaPlaybackTargetPickerState(const String&, MediaPlaybackTargetContext::MockState);
    735735    WEBCORE_EXPORT void mockMediaPlaybackTargetPickerDismissPopup();
    736736
  • trunk/Source/WebCore/platform/graphics/MediaPlaybackTarget.h

    r276120 r276177  
    2828#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    2929
     30#include "MediaPlaybackTargetContext.h"
    3031#include <wtf/Forward.h>
    3132#include <wtf/RefCounted.h>
     
    3334namespace WebCore {
    3435
    35 class MediaPlaybackTargetContext;
    36 
    3736class MediaPlaybackTarget : public RefCounted<MediaPlaybackTarget> {
    3837public:
    3938    virtual ~MediaPlaybackTarget() = default;
    4039
    41     enum TargetType { AVFoundation, Mock };
     40    enum class TargetType : uint8_t { AVFoundation, Mock };
    4241    virtual TargetType targetType() const = 0;
     42    virtual const MediaPlaybackTargetContext& targetContext() const = 0;
    4343
    44     virtual const MediaPlaybackTargetContext& targetContext() const = 0;
    45     virtual bool hasActiveRoute() const = 0;
    46     virtual String deviceName() const = 0;
    47     virtual bool supportsRemoteVideoPlayback() const = 0;
     44    bool hasActiveRoute() const { return targetContext().hasActiveRoute(); }
     45    String deviceName() const { return targetContext().deviceName(); }
     46    bool supportsRemoteVideoPlayback() { return targetContext().supportsRemoteVideoPlayback(); }
    4847};
    4948
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h

    r276120 r276177  
    2929
    3030#include "MediaPlaybackTarget.h"
    31 #include "MediaPlaybackTargetContext.h"
    3231#include <wtf/RetainPtr.h>
    3332
     
    3736public:
    3837    WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(AVOutputContext *);
     38    WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(MediaPlaybackTargetContext&&);
    3939
    4040#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR) && !PLATFORM(MACCATALYST)
     
    4444    virtual ~MediaPlaybackTargetCocoa();
    4545
    46     TargetType targetType() const final { return AVFoundation; }
    47 
    48     const MediaPlaybackTargetContext& targetContext() const final;
    49     bool hasActiveRoute() const final;
    50     String deviceName() const final;
    51     bool supportsRemoteVideoPlayback() const final;
    52 
    53     AVOutputContext *outputContext() const { return m_outputContext.get(); }
     46    TargetType targetType() const final { return TargetType::AVFoundation; }
     47    const MediaPlaybackTargetContext& targetContext() const final { return m_context; }
    5448
    5549protected:
    56     MediaPlaybackTargetCocoa(AVOutputContext *);
     50    explicit MediaPlaybackTargetCocoa(AVOutputContext *);
     51    explicit MediaPlaybackTargetCocoa(MediaPlaybackTargetContext&&);
    5752
    58     RetainPtr<AVOutputContext> m_outputContext;
    59     mutable MediaPlaybackTargetContext m_context;
    60     String m_deviceName;
     53    MediaPlaybackTargetContext m_context;
    6154};
    6255
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetCocoa.mm

    r276120 r276177  
    3535namespace WebCore {
    3636
    37 Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *context)
     37Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(AVOutputContext *outputContext)
    3838{
    39     return adoptRef(*new MediaPlaybackTargetCocoa(context));
     39    return adoptRef(*new MediaPlaybackTargetCocoa(outputContext));
    4040}
    4141
    42 MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *context)
    43     : MediaPlaybackTarget()
    44     , m_outputContext(context)
     42Ref<MediaPlaybackTarget> MediaPlaybackTargetCocoa::create(MediaPlaybackTargetContext&& context)
     43{
     44    return adoptRef(*new MediaPlaybackTargetCocoa(WTFMove(context)));
     45}
     46
     47MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(AVOutputContext *outputContext)
     48    : m_context(outputContext)
     49{
     50}
     51
     52MediaPlaybackTargetCocoa::MediaPlaybackTargetCocoa(MediaPlaybackTargetContext&& context)
     53    : m_context(WTFMove(context))
    4554{
    4655}
     
    5463#endif
    5564
    56 bool MediaPlaybackTargetCocoa::supportsRemoteVideoPlayback() const
    57 {
    58     if (!m_outputContext)
    59         return false;
    60 
    61     if (![m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] || ![m_outputContext supportsMultipleOutputDevices] || ![m_outputContext respondsToSelector:@selector(outputDevices)]) {
    62         if (auto *outputDevice = [m_outputContext outputDevice]) {
    63             if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
    64                 return true;
    65         }
    66 
    67         return false;
    68     }
    69 
    70     for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
    71         if (outputDevice.deviceFeatures & AVOutputDeviceFeatureVideo)
    72             return true;
    73     }
    74 
    75     return false;
    76 }
    77 
    7865MediaPlaybackTargetCocoa::~MediaPlaybackTargetCocoa()
    7966{
    80 }
    81 
    82 const MediaPlaybackTargetContext& MediaPlaybackTargetCocoa::targetContext() const
    83 {
    84     m_context = MediaPlaybackTargetContext(m_outputContext.get());
    85     return m_context;
    86 }
    87 
    88 bool MediaPlaybackTargetCocoa::hasActiveRoute() const
    89 {
    90     if (!m_outputContext)
    91         return false;
    92 
    93     if ([m_outputContext respondsToSelector:@selector(supportsMultipleOutputDevices)] && [m_outputContext supportsMultipleOutputDevices] && [m_outputContext respondsToSelector:@selector(outputDevices)]) {
    94         for (AVOutputDevice *outputDevice in [m_outputContext outputDevices]) {
    95             if (outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio))
    96                 return true;
    97         }
    98 
    99         return false;
    100     }
    101 
    102     if ([m_outputContext respondsToSelector:@selector(outputDevice)]) {
    103         if (auto *outputDevice = [m_outputContext outputDevice])
    104             return outputDevice.deviceFeatures & (AVOutputDeviceFeatureVideo | AVOutputDeviceFeatureAudio);
    105     }
    106 
    107     return m_outputContext.get().deviceName;
    108 }
    109 
    110 String MediaPlaybackTargetCocoa::deviceName() const
    111 {
    112     if (!m_outputContext)
    113         return emptyString();
    114 
    115     if (![m_outputContext supportsMultipleOutputDevices])
    116         return [m_outputContext deviceName];
    117 
    118     auto outputDeviceNames = adoptNS([[NSMutableArray alloc] init]);
    119     for (AVOutputDevice *outputDevice in [m_outputContext outputDevices])
    120         [outputDeviceNames addObject:[outputDevice deviceName]];
    121 
    122     return [outputDeviceNames componentsJoinedByString:@" + "];
    12367}
    12468
     
    13074const MediaPlaybackTargetCocoa* toMediaPlaybackTargetCocoa(const MediaPlaybackTarget* rep)
    13175{
    132     ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::AVFoundation);
     76    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::TargetType::AVFoundation);
    13377    return static_cast<const MediaPlaybackTargetCocoa*>(rep);
    13478}
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r276120 r276177  
    28252825#if !PLATFORM(IOS_FAMILY)
    28262826    if (m_playbackTarget) {
    2827         if (m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation)
     2827        if (m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation)
    28282828            wirelessTarget = m_avPlayer && m_avPlayer.get().externalPlaybackActive;
    28292829        else
     
    29692969    m_playbackTarget = WTFMove(target);
    29702970
    2971     m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation ? toMediaPlaybackTargetCocoa(m_playbackTarget.get())->outputContext() : nullptr;
     2971    m_outputContext = m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation ? toMediaPlaybackTargetCocoa(m_playbackTarget.get())->targetContext().outputContext() : nullptr;
    29722972
    29732973    INFO_LOG(LOGIDENTIFIER);
     
    29892989    INFO_LOG(LOGIDENTIFIER, shouldPlay);
    29902990
    2991     if (m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation) {
     2991    if (m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::AVFoundation) {
    29922992        AVOutputContext *newContext = shouldPlay ? m_outputContext.get() : nil;
    29932993
     
    30063006    }
    30073007
    3008     ASSERT(m_playbackTarget->targetType() == MediaPlaybackTarget::Mock);
     3008    ASSERT(m_playbackTarget->targetType() == MediaPlaybackTarget::TargetType::Mock);
    30093009
    30103010    setDelayCallbacks(true);
  • trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.cpp

    r276120 r276177  
    3131namespace WebCore {
    3232
    33 Ref<MediaPlaybackTarget> MediaPlaybackTargetMock::create(const String& name, MediaPlaybackTargetContext::State state)
     33Ref<MediaPlaybackTarget> MediaPlaybackTargetMock::create(const String& name, MediaPlaybackTargetContext::MockState state)
    3434{
    3535    return adoptRef(*new MediaPlaybackTargetMock(name, state));
    3636}
    3737
    38 MediaPlaybackTargetMock::MediaPlaybackTargetMock(const String& name, MediaPlaybackTargetContext::State state)
    39     : MediaPlaybackTarget()
    40     , m_name(name)
    41     , m_state(state)
     38MediaPlaybackTargetMock::MediaPlaybackTargetMock(const String& name, MediaPlaybackTargetContext::MockState state)
     39    : m_context(name, state)
    4240{
    4341}
    4442
    4543MediaPlaybackTargetMock::~MediaPlaybackTargetMock() = default;
    46 
    47 const MediaPlaybackTargetContext& MediaPlaybackTargetMock::targetContext() const
    48 {
    49     m_context = MediaPlaybackTargetContext(m_name, m_state);
    50     return m_context;
    51 }
    5244
    5345MediaPlaybackTargetMock* toMediaPlaybackTargetMock(MediaPlaybackTarget* rep)
     
    5850const MediaPlaybackTargetMock* toMediaPlaybackTargetMock(const MediaPlaybackTarget* rep)
    5951{
    60     ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::Mock);
     52    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(rep->targetType() == MediaPlaybackTarget::TargetType::Mock);
    6153    return static_cast<const MediaPlaybackTargetMock*>(rep);
    6254}
  • trunk/Source/WebCore/platform/mock/MediaPlaybackTargetMock.h

    r276120 r276177  
    2424 */
    2525
    26 #ifndef MediaPlaybackTargetMock_h
    27 #define MediaPlaybackTargetMock_h
     26#pragma once
    2827
    2928#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
    3029
    3130#include "MediaPlaybackTarget.h"
    32 #include "MediaPlaybackTargetContext.h"
    3331#include <wtf/text/WTFString.h>
    3432
     
    3735class MediaPlaybackTargetMock : public MediaPlaybackTarget {
    3836public:
    39     WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(const String&, MediaPlaybackTargetContext::State);
     37    WEBCORE_EXPORT static Ref<MediaPlaybackTarget> create(const String&, MediaPlaybackTargetContext::MockState);
    4038
    4139    virtual ~MediaPlaybackTargetMock();
    4240
    43     TargetType targetType() const final { return Mock; }
     41    TargetType targetType() const final { return MediaPlaybackTarget::TargetType::Mock; }
     42    const MediaPlaybackTargetContext& targetContext() const final { return m_context; }
    4443
    45     const MediaPlaybackTargetContext& targetContext() const final;
    46 
    47     bool hasActiveRoute() const final { return !m_name.isEmpty(); }
    48     bool supportsRemoteVideoPlayback() const final { return !m_name.isEmpty(); }
    49 
    50     String deviceName() const final { return m_name; }
    51 
    52     MediaPlaybackTargetContext::State state() const;
     44    MediaPlaybackTargetContext::MockState state() const { return m_context.mockState(); }
    5345
    5446protected:
    55     MediaPlaybackTargetMock(const String&, MediaPlaybackTargetContext::State);
     47    MediaPlaybackTargetMock(const String&, MediaPlaybackTargetContext::MockState);
    5648
    57     String m_name;
    58     MediaPlaybackTargetContext::State m_state { MediaPlaybackTargetContext::Unknown };
    59     mutable MediaPlaybackTargetContext m_context;
     49    MediaPlaybackTargetContext m_context;
    6050};
    6151
     
    6656
    6757#endif // ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
    68 
    69 #endif
  • trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.cpp

    r276120 r276177  
    5353{
    5454    LOG(Media, "MediaPlaybackTargetPickerMock::externalOutputDeviceAvailable");
    55     return m_state == MediaPlaybackTargetContext::OutputDeviceAvailable;
     55    return m_state == MediaPlaybackTargetContext::MockState::OutputDeviceAvailable;
    5656}
    5757
     
    8686
    8787    m_taskQueue.enqueueTask([this] {
    88         if (m_state == MediaPlaybackTargetContext::OutputDeviceAvailable)
     88        if (m_state == MediaPlaybackTargetContext::MockState::OutputDeviceAvailable)
    8989            availableDevicesDidChange();
    9090
    91         if (!m_deviceName.isEmpty() && m_state != MediaPlaybackTargetContext::Unknown)
     91        if (!m_deviceName.isEmpty() && m_state != MediaPlaybackTargetContext::MockState::Unknown)
    9292            currentDeviceDidChange();
    9393    });
     
    102102{
    103103    LOG(Media, "MediaPlaybackTargetPickerMock::invalidatePlaybackTargets");
    104     setState(emptyString(), MediaPlaybackTargetContext::Unknown);
     104    setState(emptyString(), MediaPlaybackTargetContext::MockState::Unknown);
    105105}
    106106
    107 void MediaPlaybackTargetPickerMock::setState(const String& deviceName, MediaPlaybackTargetContext::State state)
     107void MediaPlaybackTargetPickerMock::setState(const String& deviceName, MediaPlaybackTargetContext::MockState state)
    108108{
    109109    LOG(Media, "MediaPlaybackTargetPickerMock::setState - name = %s, state = 0x%x", deviceName.utf8().data(), (unsigned)state);
    110110
    111111    m_taskQueue.enqueueTask([this, state, deviceName] {
    112         if (deviceName != m_deviceName && state != MediaPlaybackTargetContext::Unknown) {
     112        if (deviceName != m_deviceName && state != MediaPlaybackTargetContext::MockState::Unknown) {
    113113            m_deviceName = deviceName;
    114114            currentDeviceDidChange();
  • trunk/Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.h

    r276120 r276177  
    4949    void invalidatePlaybackTargets() override;
    5050
    51     void setState(const String&, MediaPlaybackTargetContext::State);
     51    void setState(const String&, MediaPlaybackTargetContext::MockState);
    5252    void dismissPopup();
    5353
     
    5858    String m_deviceName;
    5959    GenericTaskQueue<Timer> m_taskQueue;
    60     MediaPlaybackTargetContext::State m_state { MediaPlaybackTargetContext::Unknown };
     60    MediaPlaybackTargetContext::MockState m_state { MediaPlaybackTargetContext::MockState::Unknown };
    6161    bool m_showingMenu { false };
    6262};
  • trunk/Source/WebCore/testing/Internals.cpp

    r276120 r276177  
    560560#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    561561    page.setMockMediaPlaybackTargetPickerEnabled(true);
    562     page.setMockMediaPlaybackTargetPickerState(emptyString(), MediaPlaybackTargetContext::Unknown);
     562    page.setMockMediaPlaybackTargetPickerState(emptyString(), MediaPlaybackTargetContext::MockState::Unknown);
    563563#endif
    564564
     
    45324532    ASSERT(page);
    45334533
    4534     MediaPlaybackTargetContext::State state = MediaPlaybackTargetContext::Unknown;
     4534    MediaPlaybackTargetContext::MockState state = MediaPlaybackTargetContext::MockState::Unknown;
    45354535
    45364536    if (equalLettersIgnoringASCIICase(deviceState, "deviceavailable"))
    4537         state = MediaPlaybackTargetContext::OutputDeviceAvailable;
     4537        state = MediaPlaybackTargetContext::MockState::OutputDeviceAvailable;
    45384538    else if (equalLettersIgnoringASCIICase(deviceState, "deviceunavailable"))
    4539         state = MediaPlaybackTargetContext::OutputDeviceUnavailable;
     4539        state = MediaPlaybackTargetContext::MockState::OutputDeviceUnavailable;
    45404540    else if (equalLettersIgnoringASCIICase(deviceState, "unknown"))
    4541         state = MediaPlaybackTargetContext::Unknown;
     4541        state = MediaPlaybackTargetContext::MockState::Unknown;
    45424542    else
    45434543        return Exception { InvalidAccessError };
  • trunk/Source/WebKit/ChangeLog

    r276164 r276177  
     12021-04-16  Peng Liu  <peng.liu6@apple.com>
     2
     3        [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=224469
     5
     6        Reviewed by Eric Carlson.
     7
     8        * Scripts/webkit/messages.py: Fix clean build failures on the WinCairo port.
     9
     10        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
     11        (WebKit::RemoteMediaPlayerProxy::setWirelessPlaybackTarget):
     12        * GPUProcess/media/RemoteMediaPlayerProxy.h:
     13
     14        * GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp:
     15        (WebKit::RemoteMediaSessionHelperProxy::activeVideoRouteDidChange):
     16
     17        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
     18        (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData):
     19        (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData):
     20        * Shared/WebCoreArgumentCoders.cpp:
     21        (IPC::ArgumentCoder<MediaPlaybackTargetContext>::encode):
     22        (IPC::ArgumentCoder<MediaPlaybackTargetContext>::decode):
     23        * Shared/WebCoreArgumentCoders.h:
     24        * Shared/mac/WebCoreArgumentCodersMac.mm:
     25        (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData): Deleted.
     26        (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData): Deleted.
     27
     28        * UIProcess/WebPageProxy.cpp:
     29        (WebKit::mediaRelatedIOKitClasses):
     30        (WebKit::WebPageProxy::creationParameters):
     31        (WebKit::WebPageProxy::setMockMediaPlaybackTargetPickerState):
     32        (WebKit::WebPageProxy::setPlaybackTarget):
     33        (WebKit::temporaryMachServices): Deleted.
     34        * UIProcess/WebPageProxy.h:
     35        * UIProcess/WebPageProxy.messages.in:
     36
     37        * WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp:
     38        (WebKit::RemoteMediaSessionHelper::activeVideoRouteDidChange):
     39
     40        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     41        (WebKit::WebChromeClient::setMockMediaPlaybackTargetPickerState):
     42        * WebProcess/WebCoreSupport/WebChromeClient.h:
     43
     44        * WebProcess/WebPage/WebPage.h:
     45        * WebProcess/WebPage/mac/WebPageMac.mm:
     46        (WebKit::WebPage::playbackTargetSelected const):
     47
    1482021-04-16  Alex Christensen  <achristensen@webkit.org>
    249
  • trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp

    r276120 r276177  
    6060#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    6161#include <WebCore/MediaPlaybackTargetCocoa.h>
     62#include <WebCore/MediaPlaybackTargetContext.h>
    6263#include <WebCore/MediaPlaybackTargetMock.h>
    6364#endif
     
    698699}
    699700
    700 void RemoteMediaPlayerProxy::setWirelessPlaybackTarget(const WebCore::MediaPlaybackTargetContext& targetContext)
     701void RemoteMediaPlayerProxy::setWirelessPlaybackTarget(MediaPlaybackTargetContext&& targetContext)
    701702{
    702703    switch (targetContext.type()) {
    703     case MediaPlaybackTargetContext::AVOutputContextType:
    704         m_player->setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
     704    case MediaPlaybackTargetContext::Type::SerializedAVOutputContext: {
     705        if (targetContext.deserializeOutputContext())
     706            m_player->setWirelessPlaybackTarget(MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
    705707        break;
     708    }
     709    case MediaPlaybackTargetContext::Type::Mock:
    706710#if PLATFORM(MAC)
    707     case MediaPlaybackTargetContext::MockType:
    708         m_player->setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetMock::create(targetContext.mockDeviceName(), targetContext.mockState()));
     711        m_player->setWirelessPlaybackTarget(MediaPlaybackTargetMock::create(targetContext.deviceName(), targetContext.mockState()));
    709712        break;
    710 #else
    711     case MediaPlaybackTargetContext::MockType:
    712 #endif
    713     case MediaPlaybackTargetContext::None:
     713#endif
     714    case MediaPlaybackTargetContext::Type::AVOutputContext:
     715    case MediaPlaybackTargetContext::Type::None:
    714716        ASSERT_NOT_REACHED();
    715717        break;
  • trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h

    r276120 r276177  
    153153    void setWirelessVideoPlaybackDisabled(bool);
    154154    void setShouldPlayToPlaybackTarget(bool);
    155     void setWirelessPlaybackTarget(const WebCore::MediaPlaybackTargetContext&);
     155    void setWirelessPlaybackTarget(WebCore::MediaPlaybackTargetContext&&);
    156156    void mediaPlayerCurrentPlaybackTargetIsWirelessChanged(bool) final;
    157157#endif
  • trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp

    r276120 r276177  
    109109void RemoteMediaSessionHelperProxy::activeVideoRouteDidChange(SupportsAirPlayVideo supportsAirPlayVideo, Ref<WebCore::MediaPlaybackTarget>&& target)
    110110{
    111     m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ActiveVideoRouteDidChange(supportsAirPlayVideo, target->targetContext()), { });
     111    auto context = target->targetContext();
     112    if (!context.serializeOutputContext())
     113        return;
     114
     115    m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ActiveVideoRouteDidChange(supportsAirPlayVideo, context), { });
    112116}
    113117
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r275835 r276177  
    353353        '"LayerHostingContext.h"': ["PLATFORM(COCOA)", ],
    354354        '"GestureTypes.h"': ["PLATFORM(IOS_FAMILY)"],
     355        '<WebCore/MediaPlaybackTargetContext.h>': ["ENABLE(WIRELESS_PLAYBACK_TARGET)"],
    355356    }
    356357    if not header in conditions:
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r276120 r276177  
    4242#endif
    4343
     44#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     45#import <WebCore/MediaPlaybackTargetContext.h>
     46#import <objc/runtime.h>
     47#endif
     48
     49#if USE(APPLE_INTERNAL_SDK)
     50#include <WebKitAdditions/WebCoreArgumentCodersCocoaAdditions.mm>
     51#endif
     52
    4453#if ENABLE(APPLE_PAY)
    4554#import "DataReference.h"
     
    4857#endif
    4958
    50 #if USE(APPLE_INTERNAL_SDK)
    51 #include <WebKitAdditions/WebCoreArgumentCodersCocoaAdditions.mm>
     59#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     60#import <pal/cocoa/AVFoundationSoftLink.h>
    5261#endif
    5362
     
    607616}
    608617
     618#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     619void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const MediaPlaybackTargetContext& target)
     620{
     621    if (target.type() == MediaPlaybackTargetContext::Type::AVOutputContext) {
     622        if ([PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
     623            encoder << target.outputContext();
     624    } else if (target.type() == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
     625        encoder << target.serializedOutputContext();
     626        encoder << target.hasActiveRoute();
     627    } else
     628        ASSERT_NOT_REACHED();
     629}
     630
     631bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, MediaPlaybackTargetContext::Type contextType, MediaPlaybackTargetContext& target)
     632{
     633    ASSERT(contextType != MediaPlaybackTargetContext::Type::Mock);
     634
     635    if (contextType == MediaPlaybackTargetContext::Type::AVOutputContext) {
     636        if (![PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
     637            return false;
     638
     639        auto outputContext = IPC::decode<AVOutputContext>(decoder, PAL::getAVOutputContextClass());
     640        if (!outputContext)
     641            return false;
     642
     643        target = WebCore::MediaPlaybackTargetContext { WTFMove(*outputContext) };
     644        return true;
     645    }
     646
     647    if (contextType == MediaPlaybackTargetContext::Type::SerializedAVOutputContext) {
     648        RetainPtr<NSData> serializedOutputContext;
     649        if (!IPC::decode(decoder, serializedOutputContext) || !serializedOutputContext)
     650            return false;
     651
     652        bool hasActiveRoute;
     653        if (!decoder.decode(hasActiveRoute))
     654            return false;
     655
     656        target = WebCore::MediaPlaybackTargetContext { WTFMove(serializedOutputContext), hasActiveRoute };
     657        return true;
     658    }
     659
     660    return false;
     661}
     662#endif
     663
    609664} // namespace IPC
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r276120 r276177  
    24582458    encoder << hasPlatformData;
    24592459
    2460     int32_t targetType = target.type();
    2461     encoder << targetType;
     2460    MediaPlaybackTargetContext::Type contextType = target.type();
     2461    encoder << contextType;
    24622462
    24632463    if (target.encodingRequiresPlatformData()) {
     
    24662466    }
    24672467
    2468     ASSERT(targetType == MediaPlaybackTargetContext::MockType);
    2469     encoder << target.mockDeviceName();
    2470     encoder << static_cast<int32_t>(target.mockState());
     2468    ASSERT(contextType == MediaPlaybackTargetContext::Type::Mock);
     2469    encoder << target.deviceName();
     2470    encoder << target.mockState();
    24712471}
    24722472
     
    24772477        return false;
    24782478
    2479     int32_t targetType;
    2480     if (!decoder.decode(targetType))
     2479    MediaPlaybackTargetContext::Type contextType;
     2480    if (!decoder.decode(contextType))
    24812481        return false;
    24822482
    24832483    if (hasPlatformData)
    2484         return decodePlatformData(decoder, target);
    2485 
    2486     ASSERT(targetType == MediaPlaybackTargetContext::MockType);
    2487 
    2488     String mockDeviceName;
    2489     if (!decoder.decode(mockDeviceName))
    2490         return false;
    2491 
    2492     int32_t mockState;
     2484        return decodePlatformData(decoder, contextType, target);
     2485
     2486    ASSERT(contextType == MediaPlaybackTargetContext::Type::Mock);
     2487    String deviceName;
     2488    if (!decoder.decode(deviceName))
     2489        return false;
     2490
     2491    MediaPlaybackTargetContext::MockState mockState;
    24932492    if (!decoder.decode(mockState))
    24942493        return false;
    24952494
    2496     target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState));
     2495    target = MediaPlaybackTargetContext(deviceName, mockState);
     2496
    24972497    return true;
    24982498}
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r276120 r276177  
    5353#if USE(CURL)
    5454#include <WebCore/CurlProxySettings.h>
     55#endif
     56
     57#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     58#include <WebCore/MediaPlaybackTargetContext.h>
    5559#endif
    5660
     
    196200#endif
    197201
    198 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
    199 class MediaPlaybackTargetContext;
    200 #endif
    201 
    202202#if ENABLE(MEDIA_STREAM)
    203203struct MediaConstraints;
     
    645645    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::MediaPlaybackTargetContext&);
    646646    static void encodePlatformData(Encoder&, const WebCore::MediaPlaybackTargetContext&);
    647     static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::MediaPlaybackTargetContext&);
     647    static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::MediaPlaybackTargetContext::Type, WebCore::MediaPlaybackTargetContext&);
    648648};
    649649#endif
  • trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm

    r276120 r276177  
    4343#import <wtf/cf/TypeCastsCF.h>
    4444
    45 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
    46 #import <WebCore/MediaPlaybackTargetContext.h>
    47 #import <objc/runtime.h>
    48 #import <pal/cocoa/AVFoundationSoftLink.h>
    49 #endif
    50 
    5145namespace IPC {
    5246
     
    404398#endif
    405399
    406 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
    407 
    408 void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const WebCore::MediaPlaybackTargetContext& target)
    409 {
    410     if ([PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
    411         encoder << target.avOutputContext();
    412 }
    413 
    414 bool ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData(Decoder& decoder, WebCore::MediaPlaybackTargetContext& target)
    415 {
    416     if (![PAL::getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
    417         return false;
    418 
    419     auto context = IPC::decode<AVOutputContext>(decoder, PAL::getAVOutputContextClass());
    420     if (!context)
    421         return false;
    422 
    423     target = WebCore::MediaPlaybackTargetContext { context->get() };
    424     return true;
    425 }
    426 
    427 #endif
    428 
    429400#if ENABLE(VIDEO)
    430401void ArgumentCoder<WebCore::SerializedPlatformDataCueValue>::encodePlatformData(Encoder& encoder, const WebCore::SerializedPlatformDataCueValue& value)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r276148 r276177  
    78457845    return services;
    78467846}
    7847 
    7848 static const Vector<ASCIILiteral>& temporaryMachServices()
    7849 {
    7850     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
    7851         "com.apple.coremedia.routingcontext.xpc"_s // Remove after <rdar://76403302> is fixed.
    7852     });
    7853     return services;
    7854 }
    78557847#endif
    78567848
     
    79487940        parameters.mediaExtensionHandles = SandboxExtension::createHandlesForMachLookup(mediaRelatedMachServices(), WTF::nullopt);
    79497941        parameters.mediaIOKitExtensionHandles = SandboxExtension::createHandlesForIOKitClassExtensions(mediaRelatedIOKitClasses(), WTF::nullopt);
    7950     } else {
    7951         // FIXME(224327): Remove this else clause once <rdar://76403302> is fixed.
    7952         parameters.mediaExtensionHandles = SandboxExtension::createHandlesForMachLookup(temporaryMachServices(), WTF::nullopt);
    79537942    }
    79547943
     
    94169405}
    94179406
    9418 void WebPageProxy::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::State state)
     9407void WebPageProxy::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::MockState state)
    94199408{
    94209409    pageClient().mediaSessionManager().setMockMediaPlaybackTargetPickerState(name, state);
     
    94319420        return;
    94329421
    9433     send(Messages::WebPage::PlaybackTargetSelected(contextId, target->targetContext()));
     9422    auto context = target->targetContext();
     9423    ASSERT(context.type() != MediaPlaybackTargetContext::Type::SerializedAVOutputContext);
     9424    if (preferences().useGPUProcessForMediaEnabled())
     9425        context.serializeOutputContext();
     9426
     9427    send(Messages::WebPage::PlaybackTargetSelected(contextId, context));
    94349428}
    94359429
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r276148 r276177  
    9595#include <WebCore/LayoutSize.h>
    9696#include <WebCore/MediaControlsContextMenuItem.h>
    97 #include <WebCore/MediaPlaybackTargetContext.h>
    9897#include <WebCore/MediaProducer.h>
    9998#include <WebCore/PageIdentifier.h>
     
    129128#include <wtf/Vector.h>
    130129#include <wtf/text/WTFString.h>
     130
     131#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     132#include <WebCore/MediaPlaybackTargetContext.h>
     133#endif
    131134
    132135#if PLATFORM(IOS_FAMILY)
     
    15681571    void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags);
    15691572    void setMockMediaPlaybackTargetPickerEnabled(bool);
    1570     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State);
     1573    void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState);
    15711574    void mockMediaPlaybackTargetPickerDismissPopup();
    15721575
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r276120 r276177  
    477477    PlaybackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier contextId, unsigned mediaState)
    478478    SetMockMediaPlaybackTargetPickerEnabled(bool enabled)
    479     SetMockMediaPlaybackTargetPickerState(String name, unsigned pickerState)
     479    SetMockMediaPlaybackTargetPickerState(String name, enum:uint8_t WebCore::MediaPlaybackTargetContext::MockState pickerState)
    480480    MockMediaPlaybackTargetPickerDismissPopup()
    481481#endif
  • trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp

    r276120 r276177  
    8282void RemoteMediaSessionHelper::activeVideoRouteDidChange(SupportsAirPlayVideo supportsAirPlayVideo, MediaPlaybackTargetContext&& targetContext)
    8383{
    84     if (targetContext.type() != MediaPlaybackTargetContext::AVOutputContextType) {
    85         ASSERT_NOT_REACHED();
     84    ASSERT(targetContext.type() != MediaPlaybackTargetContext::Type::AVOutputContext);
     85    if (targetContext.type() == MediaPlaybackTargetContext::Type::AVOutputContext)
    8686        return;
    87     }
    8887
    89     WebCore::MediaSessionHelper::activeVideoRouteDidChange(supportsAirPlayVideo, WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
     88    WebCore::MediaSessionHelper::activeVideoRouteDidChange(supportsAirPlayVideo, WebCore::MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
    9089}
    9190
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r276120 r276177  
    13531353}
    13541354
    1355 void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
     1355void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
    13561356{
    13571357    m_page.send(Messages::WebPageProxy::SetMockMediaPlaybackTargetPickerState(name, state));
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h

    r276120 r276177  
    379379    void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags) final;
    380380    void setMockMediaPlaybackTargetPickerEnabled(bool) final;
    381     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
     381    void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState) final;
    382382    void mockMediaPlaybackTargetPickerDismissPopup() final;
    383383#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r276120 r276177  
    17921792
    17931793#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
    1794     void playbackTargetSelected(WebCore::PlaybackTargetClientContextIdentifier, const WebCore::MediaPlaybackTargetContext& outputDevice) const;
     1794    void playbackTargetSelected(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaPlaybackTargetContext&&) const;
    17951795    void playbackTargetAvailabilityDidChange(WebCore::PlaybackTargetClientContextIdentifier, bool);
    17961796    void setShouldPlayToPlaybackTarget(WebCore::PlaybackTargetClientContextIdentifier, bool);
  • trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

    r276120 r276177  
    3636#import "FrameInfoData.h"
    3737#import "InjectedBundleHitTestResult.h"
    38 #import "PDFKitSoftLink.h"
    3938#import "PDFPlugin.h"
    4039#import "PageBanner.h"
     
    10099#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    101100#import <WebCore/MediaPlaybackTargetCocoa.h>
     101#import <WebCore/MediaPlaybackTargetContext.h>
    102102#import <WebCore/MediaPlaybackTargetMock.h>
    103103#endif
     104
     105#import "PDFKitSoftLink.h"
    104106
    105107namespace WebKit {
     
    10431045
    10441046#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
    1045 void WebPage::playbackTargetSelected(PlaybackTargetClientContextIdentifier contextId, const WebCore::MediaPlaybackTargetContext& targetContext) const
     1047void WebPage::playbackTargetSelected(PlaybackTargetClientContextIdentifier contextId, WebCore::MediaPlaybackTargetContext&& targetContext) const
    10461048{
    10471049    switch (targetContext.type()) {
    1048     case MediaPlaybackTargetContext::AVOutputContextType:
    1049         m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext()));
     1050    case MediaPlaybackTargetContext::Type::AVOutputContext:
     1051    case MediaPlaybackTargetContext::Type::SerializedAVOutputContext:
     1052        m_page->setPlaybackTarget(contextId, MediaPlaybackTargetCocoa::create(WTFMove(targetContext)));
    10501053        break;
    1051     case MediaPlaybackTargetContext::MockType:
    1052         m_page->setPlaybackTarget(contextId, WebCore::MediaPlaybackTargetMock::create(targetContext.mockDeviceName(), targetContext.mockState()));
     1054    case MediaPlaybackTargetContext::Type::Mock:
     1055        m_page->setPlaybackTarget(contextId, MediaPlaybackTargetMock::create(targetContext.deviceName(), targetContext.mockState()));
    10531056        break;
    1054     case MediaPlaybackTargetContext::None:
     1057    case MediaPlaybackTargetContext::Type::None:
    10551058        ASSERT_NOT_REACHED();
    10561059        break;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r276120 r276177  
     12021-04-16  Peng Liu  <peng.liu6@apple.com>
     2
     3        [GPUP] WebContent process should not create AVOutputContext instances when media in GPU Process is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=224469
     5
     6        Reviewed by Eric Carlson.
     7
     8        * WebCoreSupport/WebChromeClient.h:
     9        * WebCoreSupport/WebChromeClient.mm:
     10        (WebChromeClient::setMockMediaPlaybackTargetPickerState):
     11        * WebView/WebMediaPlaybackTargetPicker.h:
     12        * WebView/WebMediaPlaybackTargetPicker.mm:
     13        (WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState):
     14        * WebView/WebView.mm:
     15        (-[WebView _setMockMediaPlaybackTargetPickerName:state:]):
     16        * WebView/WebViewInternal.h:
     17
    1182021-04-15  Commit Queue  <commit-queue@webkit.org>
    219
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h

    r276120 r276177  
    244244    void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags) final;
    245245    void setMockMediaPlaybackTargetPickerEnabled(bool) final;
    246     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
     246    void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState) final;
    247247    void mockMediaPlaybackTargetPickerDismissPopup() override;
    248248#endif
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm

    r276120 r276177  
    11301130}
    11311131
    1132 void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
     1132void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::MockState state)
    11331133{
    11341134    [m_webView _setMockMediaPlaybackTargetPickerName:name state:state];
  • trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.h

    r276120 r276177  
    5454    void playbackTargetPickerClientStateDidChange(WebCore::PlaybackTargetClientContextIdentifier, WebCore::MediaProducer::MediaStateFlags);
    5555    void setMockMediaPlaybackTargetPickerEnabled(bool);
    56     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State);
     56    void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::MockState);
    5757    void mockMediaPlaybackTargetPickerDismissPopup();
    5858
  • trunk/Source/WebKitLegacy/mac/WebView/WebMediaPlaybackTargetPicker.mm

    r276120 r276177  
    6969}
    7070
    71 void WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::State state)
     71void WebMediaPlaybackTargetPicker::setMockMediaPlaybackTargetPickerState(const String& name, WebCore::MediaPlaybackTargetContext::MockState state)
    7272{
    7373    WebCore::WebMediaSessionManager::shared().setMockMediaPlaybackTargetPickerState(name, state);
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r276120 r276177  
    92339233}
    92349234
    9235 - (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state
     9235- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::MockState)state
    92369236{
    92379237    [self _devicePicker]->setMockMediaPlaybackTargetPickerState(name, state);
  • trunk/Source/WebKitLegacy/mac/WebView/WebViewInternal.h

    r276120 r276177  
    328328- (void)_playbackTargetPickerClientStateDidChange:(WebCore::PlaybackTargetClientContextIdentifier)contextId state:(WebCore::MediaProducer::MediaStateFlags)state;
    329329- (void)_setMockMediaPlaybackTargetPickerEnabled:(bool)enabled;
    330 - (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::State)state;
     330- (void)_setMockMediaPlaybackTargetPickerName:(NSString *)name state:(WebCore::MediaPlaybackTargetContext::MockState)state;
    331331- (void)_mockMediaPlaybackTargetPickerDismissPopup;
    332332#endif
Note: See TracChangeset for help on using the changeset viewer.