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

Changeset 291361 in webkit


Ignore:
Timestamp:
Mar 16, 2022, 1:29:20 PM (4 years ago)
Author:
eric.carlson@apple.com
Message:

[iOS] WebAVMediaSelectionOption should implement -mediaType
https://bugs.webkit.org/show_bug.cgi?id=237966
rdar://89934589

Reviewed by Jer Noble.

Source/WebCore:

WebKit uses AVKit to implement "video fullscreen" on iOS. AVKit can only be used
in the UI process, but WebKit's AVFoundation objects are in the GPU process, so we
create "proxy" objects in the UI process and pass state from them between the two
processes. One such object is WebAVMediaSelectionOption, which proxies for an
AVMediaSelectionOption. This proxy originally only implemented -localizedDisplayName
but AVKit now sometimes uses -mediaType, which causes an assert when it messages the
non-existent selector. Add -mediaType to fix the assert, and add log-only stubs
for every other AVMediaSelectionOption selector to catch future changes.

  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::mediaSelectionOptionForTrack const):

  • platform/MediaSelectionOption.h:

(WebCore::MediaSelectionOption::MediaSelectionOption):
(WebCore::MediaSelectionOption::isolatedCopy const):
(WebCore::MediaSelectionOption::isolatedCopy):
(WebCore::MediaSelectionOption::encode const):
(WebCore::MediaSelectionOption::decode):

  • platform/ios/PlaybackSessionInterfaceAVKit.mm:

(WebCore::toAVMediaType):
(WebCore::mediaSelectionOptions):

  • platform/ios/WebAVPlayerController.h:
  • platform/ios/WebAVPlayerController.mm:

(-[WebAVMediaSelectionOption initWithMediaType:displayName:]):
(-[WebAVMediaSelectionOption mediaSubTypes]):
(-[WebAVMediaSelectionOption hasMediaCharacteristic:]):
(-[WebAVMediaSelectionOption isPlayable]):
(-[WebAVMediaSelectionOption extendedLanguageTag]):
(-[WebAVMediaSelectionOption locale]):
(-[WebAVMediaSelectionOption commonMetadata]):
(-[WebAVMediaSelectionOption availableMetadataFormats]):
(-[WebAVMediaSelectionOption metadataForFormat:]):
(-[WebAVMediaSelectionOption associatedMediaSelectionOptionInMediaSelectionGroup:]):
(-[WebAVMediaSelectionOption propertyList]):
(-[WebAVMediaSelectionOption displayNameWithLocale:]):
(-[WebAVMediaSelectionOption mediaCharacteristics]):
(-[WebAVMediaSelectionOption outOfBandSource]):
(-[WebAVMediaSelectionOption outOfBandIdentifier]):
(-[WebAVMediaSelectionOption _isDesignatedDefault]):
(-[WebAVMediaSelectionOption languageCode]):
(-[WebAVMediaSelectionOption track]):

  • platform/mac/WebPlaybackControlsManager.mm:

(toAVTouchBarMediaSelectionOptionType):
(mediaSelectionOptions):

Source/WebKit:

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<MediaSelectionOption>::encode): Deleted.
(IPC::ArgumentCoder<MediaSelectionOption>::decode): Deleted.

  • Shared/WebCoreArgumentCoders.h:
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r291357 r291361  
     12022-03-16  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] WebAVMediaSelectionOption should implement -mediaType
     4        https://bugs.webkit.org/show_bug.cgi?id=237966
     5        rdar://89934589
     6
     7        Reviewed by Jer Noble.
     8
     9        WebKit uses AVKit to implement "video fullscreen" on iOS. AVKit can only be used
     10        in the UI process, but WebKit's AVFoundation objects are in the GPU process, so we
     11        create "proxy" objects in the UI process and pass state from them between the two
     12        processes. One such object is WebAVMediaSelectionOption, which proxies for an
     13        AVMediaSelectionOption. This proxy originally only implemented -localizedDisplayName
     14        but AVKit now sometimes uses -mediaType, which causes an assert when it messages the
     15        non-existent selector. Add -mediaType to fix the assert, and add log-only stubs
     16        for every other AVMediaSelectionOption selector to catch future changes.
     17
     18        * page/CaptionUserPreferences.cpp:
     19        (WebCore::CaptionUserPreferences::mediaSelectionOptionForTrack const):
     20        * platform/MediaSelectionOption.h:
     21        (WebCore::MediaSelectionOption::MediaSelectionOption):
     22        (WebCore::MediaSelectionOption::isolatedCopy const):
     23        (WebCore::MediaSelectionOption::isolatedCopy):
     24        (WebCore::MediaSelectionOption::encode const):
     25        (WebCore::MediaSelectionOption::decode):
     26        * platform/ios/PlaybackSessionInterfaceAVKit.mm:
     27        (WebCore::toAVMediaType):
     28        (WebCore::mediaSelectionOptions):
     29        * platform/ios/WebAVPlayerController.h:
     30        * platform/ios/WebAVPlayerController.mm:
     31        (-[WebAVMediaSelectionOption initWithMediaType:displayName:]):
     32        (-[WebAVMediaSelectionOption mediaSubTypes]):
     33        (-[WebAVMediaSelectionOption hasMediaCharacteristic:]):
     34        (-[WebAVMediaSelectionOption isPlayable]):
     35        (-[WebAVMediaSelectionOption extendedLanguageTag]):
     36        (-[WebAVMediaSelectionOption locale]):
     37        (-[WebAVMediaSelectionOption commonMetadata]):
     38        (-[WebAVMediaSelectionOption availableMetadataFormats]):
     39        (-[WebAVMediaSelectionOption metadataForFormat:]):
     40        (-[WebAVMediaSelectionOption associatedMediaSelectionOptionInMediaSelectionGroup:]):
     41        (-[WebAVMediaSelectionOption propertyList]):
     42        (-[WebAVMediaSelectionOption displayNameWithLocale:]):
     43        (-[WebAVMediaSelectionOption mediaCharacteristics]):
     44        (-[WebAVMediaSelectionOption outOfBandSource]):
     45        (-[WebAVMediaSelectionOption outOfBandIdentifier]):
     46        (-[WebAVMediaSelectionOption _isDesignatedDefault]):
     47        (-[WebAVMediaSelectionOption languageCode]):
     48        (-[WebAVMediaSelectionOption track]):
     49        * platform/mac/WebPlaybackControlsManager.mm:
     50        (toAVTouchBarMediaSelectionOptionType):
     51        (mediaSelectionOptions):
     52
    1532022-03-16  Philippe Normand  <pnormand@igalia.com>
    254
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r286743 r291361  
    224224MediaSelectionOption CaptionUserPreferences::mediaSelectionOptionForTrack(TextTrack* track) const
    225225{
    226     auto type = MediaSelectionOption::Type::Regular;
     226    auto legibleType = MediaSelectionOption::LegibleType::Regular;
    227227    if (track == &TextTrack::captionMenuOffItem())
    228         type = MediaSelectionOption::Type::LegibleOff;
     228        legibleType = MediaSelectionOption::LegibleType::LegibleOff;
    229229    else if (track == &TextTrack::captionMenuAutomaticItem())
    230         type = MediaSelectionOption::Type::LegibleAuto;
    231     return { displayNameForTrack(track), type };
     230        legibleType = MediaSelectionOption::LegibleType::LegibleAuto;
     231
     232    auto mediaType = MediaSelectionOption::MediaType::Unknown;
     233    switch (track->kind()) {
     234    case TextTrack::Kind::Forced:
     235    case TextTrack::Kind::Descriptions:
     236    case TextTrack::Kind::Subtitles:
     237        mediaType = MediaSelectionOption::MediaType::Subtitles;
     238        break;
     239    case TextTrack::Kind::Captions:
     240        mediaType = MediaSelectionOption::MediaType::Captions;
     241        break;
     242    case TextTrack::Kind::Metadata:
     243        mediaType = MediaSelectionOption::MediaType::Metadata;
     244        break;
     245    case TextTrack::Kind::Chapters:
     246        ASSERT_NOT_REACHED();
     247        break;
     248    }
     249
     250    return { mediaType, displayNameForTrack(track), legibleType };
    232251}
    233252   
     
    274293MediaSelectionOption CaptionUserPreferences::mediaSelectionOptionForTrack(AudioTrack* track) const
    275294{
    276     return { displayNameForTrack(track), MediaSelectionOption::Type::Regular };
     295    return { MediaSelectionOption::MediaType::Audio, displayNameForTrack(track), MediaSelectionOption::LegibleType::Regular };
    277296}
    278297
  • trunk/Source/WebCore/platform/MediaSelectionOption.h

    r290901 r291361  
    3131
    3232struct MediaSelectionOption {
    33     enum class Type {
     33    enum class MediaType {
     34        Unknown,
     35        Audio,
     36        Subtitles,
     37        Captions,
     38        Metadata,
     39    };
     40
     41    enum class LegibleType {
    3442        Regular,
    3543        LegibleOff,
     
    3846
    3947    MediaSelectionOption() = default;
    40     MediaSelectionOption(const String& displayName, Type type)
    41         : displayName { displayName }
    42         , type { type }
     48    MediaSelectionOption(MediaType mediaType, const String& displayName, LegibleType legibleType)
     49        : mediaType { mediaType }
     50        , displayName { displayName }
     51        , legibleType { legibleType }
    4352    {
    4453    }
    4554
    46     MediaSelectionOption isolatedCopy() const & { return { displayName.isolatedCopy(), type }; }
    47     MediaSelectionOption isolatedCopy() && { return { WTFMove(displayName).isolatedCopy(), type }; }
     55    MediaSelectionOption isolatedCopy() const & { return { mediaType, displayName.isolatedCopy(), legibleType }; }
     56    MediaSelectionOption isolatedCopy() && { return { mediaType, WTFMove(displayName).isolatedCopy(), legibleType }; }
    4857
     58    template<class Encoder> void encode(Encoder&) const;
     59    template<class Decoder> static bool WARN_UNUSED_RETURN decode(Decoder&, MediaSelectionOption&);
     60
     61    MediaType mediaType { MediaType::Unknown };
    4962    String displayName;
    50     Type type { Type::Regular };
     63    LegibleType legibleType { LegibleType::Regular };
    5164};
    5265
     66template<class Encoder> void MediaSelectionOption::encode(Encoder& encoder) const
     67{
     68    encoder << mediaType;
     69    encoder << displayName;
     70    encoder << legibleType;
     71}
     72
     73template<class Decoder> bool MediaSelectionOption::decode(Decoder& decoder, MediaSelectionOption& option)
     74{
     75    return decoder.decode(option.mediaType)
     76        && decoder.decode(option.displayName)
     77        && decoder.decode(option.legibleType);
     78}
     79
    5380} // namespace WebCore
     81
     82namespace WTF {
     83
     84template<> struct EnumTraits<WebCore::MediaSelectionOption::MediaType> {
     85    using values = EnumValues<
     86        WebCore::MediaSelectionOption::MediaType,
     87        WebCore::MediaSelectionOption::MediaType::Unknown,
     88        WebCore::MediaSelectionOption::MediaType::Audio,
     89        WebCore::MediaSelectionOption::MediaType::Subtitles,
     90        WebCore::MediaSelectionOption::MediaType::Captions,
     91        WebCore::MediaSelectionOption::MediaType::Metadata
     92    >;
     93};
     94
     95template<> struct EnumTraits<WebCore::MediaSelectionOption::LegibleType> {
     96    using values = EnumValues<
     97        WebCore::MediaSelectionOption::LegibleType,
     98        WebCore::MediaSelectionOption::LegibleType::Regular,
     99        WebCore::MediaSelectionOption::LegibleType::LegibleOff,
     100        WebCore::MediaSelectionOption::LegibleType::LegibleAuto
     101    >;
     102};
     103
     104} // namespace WTF
  • trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm

    r280840 r291361  
    4343
    4444#import <pal/cf/CoreMediaSoftLink.h>
     45#import <pal/cocoa/AVFoundationSoftLink.h>
    4546
    4647SOFTLINK_AVKIT_FRAMEWORK()
     
    162163}
    163164
     165static AVMediaType toAVMediaType(MediaSelectionOption::MediaType type)
     166{
     167    switch (type) {
     168    case MediaSelectionOption::MediaType::Audio:
     169        return AVMediaTypeAudio;
     170        break;
     171    case MediaSelectionOption::MediaType::Subtitles:
     172        return AVMediaTypeSubtitle;
     173        break;
     174    case MediaSelectionOption::MediaType::Captions:
     175        return AVMediaTypeClosedCaption;
     176        break;
     177    case MediaSelectionOption::MediaType::Metadata:
     178        return AVMediaTypeMetadata;
     179        break;
     180    case MediaSelectionOption::MediaType::Unknown:
     181        ASSERT_NOT_REACHED();
     182        break;
     183    }
     184
     185    return AVMediaTypeMetadata;
     186}
     187
    164188static RetainPtr<NSArray> mediaSelectionOptions(const Vector<MediaSelectionOption>& options)
    165189{
    166190    return createNSArray(options, [] (auto& option) {
    167         auto webOption = adoptNS([[WebAVMediaSelectionOption alloc] init]);
    168         [webOption setLocalizedDisplayName:option.displayName];
    169         return webOption;
     191        return [[WebAVMediaSelectionOption alloc] initWithMediaType:toAVMediaType(option.mediaType) displayName:option.displayName];
    170192    });
    171193}
  • trunk/Source/WebCore/platform/ios/WebAVPlayerController.h

    r284743 r291361  
    3434
    3535@interface WebAVMediaSelectionOption : NSObject
     36- (instancetype)initWithMediaType:(AVMediaType)type displayName:(NSString *)displayName;
     37
    3638@property (retain) NSString *localizedDisplayName;
     39@property (nonatomic, readonly) AVMediaType mediaType;
     40
    3741@end
    3842
  • trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm

    r287986 r291361  
    763763@implementation WebAVMediaSelectionOption
    764764
     765- (instancetype)initWithMediaType:(AVMediaType)mediaType displayName:(NSString *)displayName
     766{
     767    self = [super init];
     768    if (!self)
     769        return nil;
     770
     771    _mediaType = mediaType;
     772    _localizedDisplayName = displayName;
     773
     774    return self;
     775}
     776
    765777- (void)dealloc
    766778{
     
    769781}
    770782
     783- (NSArray<NSNumber *> *)mediaSubTypes
     784{
     785    ASSERT_NOT_REACHED();
     786    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption mediaSubTypes] unimplemented");
     787    return @[];
     788}
     789
     790- (BOOL)hasMediaCharacteristic:(AVMediaCharacteristic)mediaCharacteristic
     791{
     792    ASSERT_NOT_REACHED();
     793    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption hasMediaCharacteristic:] unimplemented");
     794    return NO;
     795}
     796
     797- (BOOL) isPlayable
     798{
     799    ASSERT_NOT_REACHED();
     800    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption isPlayable:] unimplemented");
     801    return YES;
     802}
     803
     804- (NSString *)extendedLanguageTag
     805{
     806    ASSERT_NOT_REACHED();
     807    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption extendedLanguageTag] unimplemented");
     808    return nil;
     809}
     810
     811- (NSLocale *)locale
     812{
     813    ASSERT_NOT_REACHED();
     814    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption locale] unimplemented");
     815    return nil;
     816}
     817
     818- (NSArray<AVMetadataItem *> *)commonMetadata
     819{
     820    ASSERT_NOT_REACHED();
     821    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption commonMetadata] unimplemented");
     822    return @[];
     823}
     824
     825- (NSArray<NSString *> *)availableMetadataFormats
     826{
     827    ASSERT_NOT_REACHED();
     828    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption availableMetadataFormats] unimplemented");
     829    return @[];
     830}
     831
     832- (NSArray<AVMetadataItem *> *)metadataForFormat:(NSString *)format
     833{
     834    ASSERT_NOT_REACHED();
     835    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption metadataForFormat:] unimplemented");
     836    return @[];
     837}
     838
     839- (AVMediaSelectionOption *)associatedMediaSelectionOptionInMediaSelectionGroup:(AVMediaSelectionGroup *)mediaSelectionGroup
     840{
     841    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption associatedMediaSelectionOptionInMediaSelectionGroup] unimplemented");
     842    ASSERT_NOT_REACHED();
     843    return nil;
     844}
     845
     846- (id)propertyList
     847{
     848    ASSERT_NOT_REACHED();
     849    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption propertyList] unimplemented");
     850    return @[];
     851}
     852
     853- (NSString *)displayNameWithLocale:(NSLocale *)locale
     854{
     855    ASSERT_NOT_REACHED();
     856    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption displayNameWithLocale:] unimplemented");
     857    return nil;
     858}
     859
     860- (NSArray<NSString *> *)mediaCharacteristics
     861{
     862    ASSERT_NOT_REACHED();
     863    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption mediaCharacteristics] unimplemented");
     864    return @[];
     865}
     866
     867- (NSString *)outOfBandSource
     868{
     869    ASSERT_NOT_REACHED();
     870    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption outOfBandSource] unimplemented");
     871    return nil;
     872}
     873
     874- (NSString *)outOfBandIdentifier
     875{
     876    ASSERT_NOT_REACHED();
     877    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption outOfBandIdentifier] unimplemented");
     878    return nil;
     879}
     880
     881- (BOOL)_isDesignatedDefault
     882{
     883    ASSERT_NOT_REACHED();
     884    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption _isDesignatedDefault] unimplemented");
     885    return NO;
     886}
     887
     888- (NSString *)languageCode
     889{
     890    ASSERT_NOT_REACHED();
     891    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption languageCode] unimplemented");
     892    return nil;
     893}
     894
     895- (AVAssetTrack *)track
     896{
     897    ASSERT_NOT_REACHED();
     898    WTFLogAlways("ERROR: -[WebAVMediaSelectionOption track:] unimplemented");
     899    return nil;
     900}
     901
    771902@end
    772903
  • trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm

    r281543 r291361  
    245245}
    246246
    247 static AVTouchBarMediaSelectionOptionType toAVTouchBarMediaSelectionOptionType(MediaSelectionOption::Type type)
     247static AVTouchBarMediaSelectionOptionType toAVTouchBarMediaSelectionOptionType(MediaSelectionOption::LegibleType type)
    248248{
    249249    switch (type) {
    250     case MediaSelectionOption::Type::Regular:
     250    case MediaSelectionOption::LegibleType::Regular:
    251251        return AVTouchBarMediaSelectionOptionTypeRegular;
    252     case MediaSelectionOption::Type::LegibleOff:
     252    case MediaSelectionOption::LegibleType::LegibleOff:
    253253        return AVTouchBarMediaSelectionOptionTypeLegibleOff;
    254     case MediaSelectionOption::Type::LegibleAuto:
     254    case MediaSelectionOption::LegibleType::LegibleAuto:
    255255        return AVTouchBarMediaSelectionOptionTypeLegibleAuto;
    256256    }
     
    263263{
    264264    return createNSArray(options, [] (auto& option) {
    265         return adoptNS([allocAVTouchBarMediaSelectionOptionInstance() initWithTitle:option.displayName type:toAVTouchBarMediaSelectionOptionType(option.type)]);
     265        return adoptNS([allocAVTouchBarMediaSelectionOptionInstance() initWithTitle:option.displayName type:toAVTouchBarMediaSelectionOptionType(option.legibleType)]);
    266266    });
    267267}
  • trunk/Source/WebKit/ChangeLog

    r291352 r291361  
     12022-03-16  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] WebAVMediaSelectionOption should implement -mediaType
     4        https://bugs.webkit.org/show_bug.cgi?id=237966
     5        rdar://89934589
     6
     7        Reviewed by Jer Noble.
     8
     9        * Shared/WebCoreArgumentCoders.cpp:
     10        (IPC::ArgumentCoder<MediaSelectionOption>::encode): Deleted.
     11        (IPC::ArgumentCoder<MediaSelectionOption>::decode): Deleted.
     12        * Shared/WebCoreArgumentCoders.h:
     13
    1142022-03-16  Per Arne Vollan  <pvollan@apple.com>
    215
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r290813 r291361  
    28812881#endif
    28822882
    2883 void ArgumentCoder<MediaSelectionOption>::encode(Encoder& encoder, const MediaSelectionOption& option)
    2884 {
    2885     encoder << option.displayName;
    2886     encoder << option.type;
    2887 }
    2888 
    2889 std::optional<MediaSelectionOption> ArgumentCoder<MediaSelectionOption>::decode(Decoder& decoder)
    2890 {
    2891     std::optional<String> displayName;
    2892     decoder >> displayName;
    2893     if (!displayName)
    2894         return std::nullopt;
    2895    
    2896     std::optional<MediaSelectionOption::Type> type;
    2897     decoder >> type;
    2898     if (!type)
    2899         return std::nullopt;
    2900    
    2901     return {{ WTFMove(*displayName), WTFMove(*type) }};
    2902 }
    2903 
    29042883void ArgumentCoder<PromisedAttachmentInfo>::encode(Encoder& encoder, const PromisedAttachmentInfo& info)
    29052884{
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r290813 r291361  
    711711#endif
    712712
    713 template<> struct ArgumentCoder<WebCore::MediaSelectionOption> {
    714     static void encode(Encoder&, const WebCore::MediaSelectionOption&);
    715     static std::optional<WebCore::MediaSelectionOption> decode(Decoder&);
    716 };
    717 
    718713template<> struct ArgumentCoder<WebCore::PromisedAttachmentInfo> {
    719714    static void encode(Encoder&, const WebCore::PromisedAttachmentInfo&);
     
    905900};
    906901#endif
    907 
    908 template<> struct EnumTraits<WebCore::MediaSelectionOption::Type> {
    909     using values = EnumValues<
    910         WebCore::MediaSelectionOption::Type,
    911         WebCore::MediaSelectionOption::Type::Regular,
    912         WebCore::MediaSelectionOption::Type::LegibleOff,
    913         WebCore::MediaSelectionOption::Type::LegibleAuto
    914     >;
    915 };
    916902
    917903template <> struct EnumTraits<WebCore::WorkerType> {
Note: See TracChangeset for help on using the changeset viewer.