Title: [199184] trunk/Source/WebCore
- Revision
- 199184
- Author
- [email protected]
- Date
- 2016-04-07 14:31:55 -0700 (Thu, 07 Apr 2016)
Log Message
WebPlaybackControlsManager should support mediaSelectionOptions
https://bugs.webkit.org/show_bug.cgi?id=156358
-and corresponding-
rdar://problem/25048743
Reviewed by Jer Noble.
This patch just implements
WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions and
WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions and passes that
information on to WebPlaybackControlsManager. If selection options are set via
the WebPlaybackControlsManager, then it gets the webVideoFullscreenModel() to
set the new value.
* platform/mac/WebVideoFullscreenInterfaceMac.h:
* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
(-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
(WebCore::mediaSelectionOptions):
(WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions):
(WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions):
(-[WebPlaybackControlsManager audioMediaSelectionOptions]): Deleted.
(-[WebPlaybackControlsManager legibleMediaSelectionOptions]): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (199183 => 199184)
--- trunk/Source/WebCore/ChangeLog 2016-04-07 21:26:16 UTC (rev 199183)
+++ trunk/Source/WebCore/ChangeLog 2016-04-07 21:31:55 UTC (rev 199184)
@@ -1,3 +1,31 @@
+2016-04-07 Beth Dakin <[email protected]>
+
+ WebPlaybackControlsManager should support mediaSelectionOptions
+ https://bugs.webkit.org/show_bug.cgi?id=156358
+ -and corresponding-
+ rdar://problem/25048743
+
+ Reviewed by Jer Noble.
+
+ This patch just implements
+ WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions and
+ WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions and passes that
+ information on to WebPlaybackControlsManager. If selection options are set via
+ the WebPlaybackControlsManager, then it gets the webVideoFullscreenModel() to
+ set the new value.
+
+ * platform/mac/WebVideoFullscreenInterfaceMac.h:
+ * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+ (-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
+ (-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
+ (-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
+ (-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
+ (WebCore::mediaSelectionOptions):
+ (WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions):
+ (WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions):
+ (-[WebPlaybackControlsManager audioMediaSelectionOptions]): Deleted.
+ (-[WebPlaybackControlsManager legibleMediaSelectionOptions]): Deleted.
+
2016-04-07 Brent Fulgham <[email protected]>
Wheel event callback removing the window causes crash in WebCore.
Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h (199183 => 199184)
--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h 2016-04-07 21:26:16 UTC (rev 199183)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h 2016-04-07 21:31:55 UTC (rev 199184)
@@ -69,8 +69,8 @@
WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final;
WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override;
WEBCORE_EXPORT void setCanPlayFastReverse(bool) override { }
- WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& /*options*/, uint64_t /*selectedIndex*/) override { }
- WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& /*options*/, uint64_t /*selectedIndex*/) override { }
+ WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& /*options*/, uint64_t /*selectedIndex*/) override;
+ WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector<WTF::String>& /*options*/, uint64_t /*selectedIndex*/) override;
WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override { }
Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm (199183 => 199184)
--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm 2016-04-07 21:26:16 UTC (rev 199183)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm 2016-04-07 21:31:55 UTC (rev 199184)
@@ -48,6 +48,13 @@
using namespace WebCore;
+@interface WebAVMediaSelectionOptionMac : NSObject
+@property (retain) NSString *localizedDisplayName;
+@end
+
+@implementation WebAVMediaSelectionOptionMac
+@end
+
@interface WebPlaybackControlsManager : NSObject {
NSTimeInterval _contentDuration;
AVValueTiming *_timing;
@@ -67,6 +74,10 @@
@property (nonatomic, retain, readwrite) NSArray *seekableTimeRanges;
@property (readwrite) BOOL hasEnabledAudio;
@property (readwrite) BOOL hasEnabledVideo;
+@property (nonatomic, retain, readwrite) NSArray<AVMediaSelectionOption *> *audioMediaSelectionOptions;
+@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentAudioMediaSelectionOption;
+@property (nonatomic, retain, readwrite) NSArray<AVMediaSelectionOption *> *legibleMediaSelectionOptions;
+@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentLegibleMediaSelectionOption;
@property (nonatomic) float rate;
@@ -87,6 +98,10 @@
@synthesize hasEnabledAudio=_hasEnabledAudio;
@synthesize hasEnabledVideo=_hasEnabledVideo;
@synthesize rate=_rate;
+@synthesize audioMediaSelectionOptions=_audioMediaSelectionOptions;
+@synthesize currentAudioMediaSelectionOption=_currentAudioMediaSelectionOption;
+@synthesize legibleMediaSelectionOptions=_legibleMediaSelectionOptions;
+@synthesize currentLegibleMediaSelectionOption=_currentLegibleMediaSelectionOption;
- (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac
{
@@ -110,34 +125,44 @@
_webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->seekToTime(time);
}
-- (NSArray *)audioMediaSelectionOptions
-{
- return @[];
-}
-
- (AVMediaSelectionOption *)currentAudioMediaSelectionOption
{
- return nil;
+ return _currentAudioMediaSelectionOption;
}
- (void)setCurrentAudioMediaSelectionOption:(AVMediaSelectionOption *)audioMediaSelectionOption
{
- UNUSED_PARAM(audioMediaSelectionOption);
+ if (audioMediaSelectionOption == _currentAudioMediaSelectionOption)
+ return;
+
+ _currentAudioMediaSelectionOption = audioMediaSelectionOption;
+
+ NSInteger index = NSNotFound;
+
+ if (audioMediaSelectionOption && self.audioMediaSelectionOptions)
+ index = [self.audioMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
+
+ _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
}
-- (NSArray *)legibleMediaSelectionOptions
-{
- return @[];
-}
-
- (AVMediaSelectionOption *)currentLegibleMediaSelectionOption
{
- return nil;
+ return _currentLegibleMediaSelectionOption;
}
- (void)setCurrentLegibleMediaSelectionOption:(AVMediaSelectionOption *)legibleMediaSelectionOption
{
- UNUSED_PARAM(legibleMediaSelectionOption);
+ if (legibleMediaSelectionOption == _currentLegibleMediaSelectionOption)
+ return;
+
+ _currentLegibleMediaSelectionOption = legibleMediaSelectionOption;
+
+ NSInteger index = NSNotFound;
+
+ if (legibleMediaSelectionOption && self.legibleMediaSelectionOptions)
+ index = [self.legibleMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
+
+ _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
}
- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
@@ -236,6 +261,37 @@
[controlsManager setSeekableTimeRanges:seekableRanges.get()];
}
+static RetainPtr<NSMutableArray> mediaSelectionOptions(const Vector<String>& options)
+{
+ RetainPtr<NSMutableArray> webOptions = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+ for (auto& name : options) {
+ RetainPtr<WebAVMediaSelectionOptionMac> webOption = adoptNS([[WebAVMediaSelectionOptionMac alloc] init]);
+ [webOption setLocalizedDisplayName:name];
+ [webOptions addObject:webOption.get()];
+ }
+ return webOptions;
+}
+
+void WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)
+{
+ WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+ RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
+ [controlsManager setAudioMediaSelectionOptions:webOptions.get()];
+ if (selectedIndex < [webOptions count])
+ [controlsManager setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
+}
+
+void WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions(const Vector<WTF::String>& options, uint64_t selectedIndex)
+{
+ WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+ RetainPtr<NSMutableArray> webOptions = mediaSelectionOptions(options);
+ [controlsManager setLegibleMediaSelectionOptions:webOptions.get()];
+ if (selectedIndex < [webOptions count])
+ [controlsManager setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast<NSUInteger>(selectedIndex)]];
+}
+
void WebVideoFullscreenInterfaceMac::ensureControlsManager()
{
playBackControlsManager();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes