Skip to content

Commit

Permalink
[Cocoa] Adopt -[AVSampleBufferDisplayLayer setPreventsDisplaySleepDur…
Browse files Browse the repository at this point in the history
…ingVideoPlayback:] as API

https://bugs.webkit.org/show_bug.cgi?id=260405
rdar://112165356

Reviewed by Jer Noble.

The preventsDisplaySleepDuringVideoPlayback property on AVSampleBufferDisplayLayer has been
available as API since macOS 10.15 and iOS 13, so we can remove our SPI declaration from
AVFoundationSPI.h.

* Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
* Source/WebCore/platform/graphics/cocoa/MediaPlayerPrivateWebM.mm:
(WebCore::MediaPlayerPrivateWebM::ensureLayer):

Canonical link: https://commits.webkit.org/267056@main
  • Loading branch information
aestes committed Aug 18, 2023
1 parent f5c4eac commit fab721e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 0 additions & 6 deletions Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,6 @@ NS_ASSUME_NONNULL_END
@end
#endif

#if !USE(APPLE_INTERNAL_SDK)
@interface AVSampleBufferDisplayLayer (WebCorePrivate)
@property (assign, nonatomic) BOOL preventsDisplaySleepDuringVideoPlayback;
@end
#endif

#if !USE(APPLE_INTERNAL_SDK) && HAVE(AVAUDIOSESSION) && !PLATFORM(MACCATALYST)
#import <AVFoundation/AVAudioSession.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,10 @@ void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) const f
return;
}

if ([m_sampleBufferDisplayLayer respondsToSelector:@selector(setPreventsDisplaySleepDuringVideoPlayback:)])
m_sampleBufferDisplayLayer.get().preventsDisplaySleepDuringVideoPlayback = NO;
[m_sampleBufferDisplayLayer setPreventsDisplaySleepDuringVideoPlayback:NO];

if ([m_sampleBufferDisplayLayer respondsToSelector:@selector(setPreventsAutomaticBackgroundingDuringVideoPlayback:)])
m_sampleBufferDisplayLayer.get().preventsAutomaticBackgroundingDuringVideoPlayback = NO;
[m_sampleBufferDisplayLayer setPreventsAutomaticBackgroundingDuringVideoPlayback:NO];

@try {
[m_synchronizer addRenderer:m_sampleBufferDisplayLayer.get()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,11 @@ static bool isCopyDisplayedPixelBufferAvailable()
setNetworkState(MediaPlayer::NetworkState::DecodeError);
return;
}

if ([m_displayLayer respondsToSelector:@selector(setPreventsDisplaySleepDuringVideoPlayback:)])
m_displayLayer.get().preventsDisplaySleepDuringVideoPlayback = NO;

[m_displayLayer setPreventsDisplaySleepDuringVideoPlayback:NO];

if ([m_displayLayer respondsToSelector:@selector(setPreventsAutomaticBackgroundingDuringVideoPlayback:)])
m_displayLayer.get().preventsAutomaticBackgroundingDuringVideoPlayback = NO;
[m_displayLayer setPreventsAutomaticBackgroundingDuringVideoPlayback:NO];

@try {
[m_synchronizer addRenderer:m_displayLayer.get()];
Expand Down

0 comments on commit fab721e

Please sign in to comment.