Changeset 201119 in webkit
- Timestamp:
- May 18, 2016, 5:20:26 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r201114 r201119 1 2016-05-18 Eric Carlson <eric.carlson@apple.com> 2 3 [iOS] Fullscreen video playback broken in WK1 apps 4 https://bugs.webkit.org/show_bug.cgi?id=157847 5 <rdar://problem/25879521> 6 7 Reviewed by Jer Noble. 8 9 * platform/cocoa/WebVideoFullscreenModelVideoElement.h: 10 (WebCore::WebVideoFullscreenModelVideoElement::playbackSessionModel): New, model accessor. 11 * platform/cocoa/WebVideoFullscreenModelVideoElement.mm: 12 (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface): Set model's playback interface. 13 (WebVideoFullscreenModelVideoElement::setVideoElement): Set model's video element. 14 15 * platform/ios/WebVideoFullscreenControllerAVKit.mm: 16 (WebVideoFullscreenControllerContext::didCleanupFullscreen): Clear m_sessionModel. 17 (WebVideoFullscreenControllerContext::setVideoDimensions): This is called from both the UI and 18 Web threads, so dispatch to the UI thread when necessary. 19 (WebVideoFullscreenControllerContext::play): Call the model's playback session on the Web thread. 20 (WebVideoFullscreenControllerContext::pause): Ditto. 21 (WebVideoFullscreenControllerContext::togglePlayState): Ditto. 22 (WebVideoFullscreenControllerContext::beginScrubbing): Ditto. 23 (WebVideoFullscreenControllerContext::endScrubbing): Ditto. 24 (WebVideoFullscreenControllerContext::seekToTime): Ditto. 25 (WebVideoFullscreenControllerContext::fastSeek): Ditto. 26 (WebVideoFullscreenControllerContext::beginScanningForward): Ditto. 27 (WebVideoFullscreenControllerContext::beginScanningBackward): Ditto. 28 (WebVideoFullscreenControllerContext::endScanning): Ditto. 29 (WebVideoFullscreenControllerContext::selectAudioMediaOption): Ditto. 30 (WebVideoFullscreenControllerContext::selectLegibleMediaOption): Ditto. 31 (WebVideoFullscreenControllerContext::setUpFullscreen): Create and configure a session model. 32 (WebVideoFullscreenSessionModel::play): Pass call back to the controller. 33 (WebVideoFullscreenSessionModel::pause): Ditto. 34 (WebVideoFullscreenSessionModel::togglePlayState): Ditto. 35 (WebVideoFullscreenSessionModel::beginScrubbing): Ditto. 36 (WebVideoFullscreenSessionModel::endScrubbing): Ditto. 37 (WebVideoFullscreenSessionModel::seekToTime): Ditto. 38 (WebVideoFullscreenSessionModel::fastSeek): Ditto. 39 (WebVideoFullscreenSessionModel::beginScanningForward): Ditto. 40 (WebVideoFullscreenSessionModel::beginScanningBackward): Ditto. 41 (WebVideoFullscreenSessionModel::endScanning): Ditto. 42 (WebVideoFullscreenSessionModel::selectAudioMediaOption): Ditto. 43 (WebVideoFullscreenSessionModel::selectLegibleMediaOption): Ditto. 44 1 45 2016-05-18 Zalan Bujtas <zalan@apple.com> 2 46 -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h
r200490 r201119 57 57 WEBCORE_EXPORT HTMLVideoElement* videoElement() const { return m_videoElement.get(); } 58 58 WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*); 59 WebPlaybackSessionModelMediaElement& playbackSessionModel() { return m_playbackSessionModel; } 59 60 60 61 WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override; -
trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm
r200490 r201119 68 68 69 69 m_videoFullscreenInterface = interface; 70 m_playbackSessionModel->setWebPlaybackSessionInterface(interface); 70 71 71 72 if (m_videoFullscreenInterface && m_videoElement) … … 88 89 89 90 m_videoElement = videoElement; 91 m_playbackSessionModel->setMediaElement(videoElement); 90 92 91 93 if (!m_videoElement) -
trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
r200895 r201119 89 89 90 90 class WebVideoFullscreenControllerContext; 91 class WebVideoFullscreenSessionModel; 91 92 92 93 @interface WebVideoFullscreenController (delegate) … … 105 106 return adoptRef(*new WebVideoFullscreenControllerContext); 106 107 } 107 108 108 109 void setController(WebVideoFullscreenController* controller) { m_controller = controller; } 109 110 void setUpFullscreen(HTMLVideoElement&, UIView *, HTMLMediaElementEnums::VideoFullscreenMode); … … 111 112 void requestHideAndExitFullscreen(); 112 113 void invalidate(); 114 115 void play(); 116 void pause(); 117 void togglePlayState(); 118 void beginScrubbing(); 119 void endScrubbing(); 120 void seekToTime(double); 121 void fastSeek(double time); 122 void beginScanningForward(); 123 void beginScanningBackward(); 124 void endScanning(); 125 void selectAudioMediaOption(uint64_t); 126 void selectLegibleMediaOption(uint64_t); 113 127 114 128 private: … … 121 135 void didCleanupFullscreen() override; 122 136 void fullscreenMayReturnToInline() override; 123 137 124 138 // WebVideoFullscreenInterface 125 139 void resetMediaState() override; … … 148 162 RetainPtr<UIView> m_videoFullscreenView; 149 163 RetainPtr<WebVideoFullscreenController> m_controller; 164 RefPtr<WebVideoFullscreenSessionModel> m_sessionModel; 165 }; 166 167 168 class WebVideoFullscreenSessionModel final: public RefCounted<WebVideoFullscreenSessionModel>, public WebCore::WebPlaybackSessionModel { 169 public: 170 static Ref<WebVideoFullscreenSessionModel> create(WebVideoFullscreenControllerContext& controller) 171 { 172 return adoptRef(*new WebVideoFullscreenSessionModel(controller)); 173 } 174 virtual ~WebVideoFullscreenSessionModel() { } 175 176 void invalidate() { m_controller = nullptr; } 177 178 void setDuration(double duration) { m_duration = duration; } 179 void setCurrentTime(double currentTime) { m_currentTime = currentTime; } 180 void setBufferedTime(double bufferedTime) { m_bufferedTime = bufferedTime; } 181 void setIsPlaying(bool isPlaying) { m_isPlaying = isPlaying; } 182 void setPlaybackRate(float playbackRate) { m_playbackRate = playbackRate; } 183 void setSeekableRanges(WebCore::TimeRanges& seekableRanges) { m_seekableRanges = seekableRanges; } 184 void setCanPlayFastReverse(bool canPlayFastReverse) { m_canPlayFastReverse = canPlayFastReverse; } 185 void setAudioMediaSelectionOptions(const Vector<WTF::String>& audioMediaSelectionOptions) { m_audioMediaSelectionOptions = audioMediaSelectionOptions; } 186 void setAudioMediaSelectedIndex(uint64_t audioMediaSelectedIndex) { m_audioMediaSelectedIndex = audioMediaSelectedIndex; } 187 void setLegibleMediaSelectionOptions(const Vector<WTF::String>& legibleMediaSelectionOptions) { m_legibleMediaSelectionOptions = legibleMediaSelectionOptions; } 188 void setLegibleMediaSelectedIndex(uint64_t legibleMediaSelectedIndex) { m_legibleMediaSelectedIndex = legibleMediaSelectedIndex; } 189 void setExternalPlaybackEnabled(bool externalPlaybackEnabled) { m_externalPlaybackEnabled = externalPlaybackEnabled; } 190 void setWirelessVideoPlaybackDisabled(bool wirelessVideoPlaybackDisabled) { m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled; } 191 192 private: 193 WebVideoFullscreenSessionModel(WebVideoFullscreenControllerContext& controller) 194 : m_controller(&controller) 195 { 196 } 197 198 void play() final; 199 void pause() final; 200 void togglePlayState() final; 201 void beginScrubbing() final; 202 void endScrubbing() final; 203 void seekToTime(double) final; 204 void fastSeek(double time) final; 205 void beginScanningForward() final; 206 void beginScanningBackward() final; 207 void endScanning() final; 208 void selectAudioMediaOption(uint64_t) final; 209 void selectLegibleMediaOption(uint64_t) final; 210 211 double duration() const final { return m_duration; } 212 double currentTime() const final { return m_currentTime; } 213 double bufferedTime() const final { return m_bufferedTime; } 214 bool isPlaying() const final { return m_isPlaying; } 215 float playbackRate() const final { return m_playbackRate; } 216 Ref<WebCore::TimeRanges> seekableRanges() const final { return m_seekableRanges.copyRef(); } 217 bool canPlayFastReverse() const final { return m_canPlayFastReverse; } 218 Vector<WTF::String> audioMediaSelectionOptions() const final { return m_audioMediaSelectionOptions; } 219 uint64_t audioMediaSelectedIndex() const final { return m_audioMediaSelectedIndex; } 220 Vector<WTF::String> legibleMediaSelectionOptions() const final { return m_legibleMediaSelectionOptions; } 221 uint64_t legibleMediaSelectedIndex() const final { return m_legibleMediaSelectedIndex; } 222 bool externalPlaybackEnabled() const final { return m_externalPlaybackEnabled; } 223 bool wirelessVideoPlaybackDisabled() const final { return m_wirelessVideoPlaybackDisabled; } 224 225 WebVideoFullscreenControllerContext* m_controller; 226 double m_duration { 0 }; 227 double m_currentTime { 0 }; 228 double m_bufferedTime { 0 }; 229 bool m_isPlaying { false }; 230 float m_playbackRate { 0 }; 231 Ref<WebCore::TimeRanges> m_seekableRanges { WebCore::TimeRanges::create() }; 232 bool m_canPlayFastReverse { false }; 233 Vector<WTF::String> m_audioMediaSelectionOptions; 234 uint64_t m_audioMediaSelectedIndex { 0 }; 235 Vector<WTF::String> m_legibleMediaSelectionOptions; 236 uint64_t m_legibleMediaSelectedIndex { 0 }; 237 bool m_externalPlaybackEnabled { false }; 238 bool m_wirelessVideoPlaybackDisabled { false }; 150 239 }; 151 240 … … 185 274 m_interface = nullptr; 186 275 m_videoFullscreenView = nil; 187 276 m_sessionModel->invalidate(); 277 m_sessionModel = nullptr; 278 188 279 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 189 280 WebThreadRun([protectedThis, this] { … … 193 284 m_model = nullptr; 194 285 m_videoElement = nullptr; 195 286 196 287 [m_controller didFinishFullscreen:this]; 197 288 }); … … 264 355 void WebVideoFullscreenControllerContext::setVideoDimensions(bool hasVideo, float width, float height) 265 356 { 266 ASSERT(WebThreadIsCurrent()); 267 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 268 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, hasVideo, width, height] { 269 if (m_interface) 270 m_interface->setVideoDimensions(hasVideo, width, height); 271 }); 357 if (WebThreadIsCurrent()) { 358 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 359 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, hasVideo, width, height] { 360 if (m_interface) 361 m_interface->setVideoDimensions(hasVideo, width, height); 362 }); 363 return; 364 } 365 366 if (m_interface) 367 m_interface->setVideoDimensions(hasVideo, width, height); 272 368 } 273 369 … … 413 509 } 414 510 511 #pragma mark - WebPlaybackSessionModelContext 512 513 void WebVideoFullscreenControllerContext::play() 514 { 515 ASSERT(isUIThread()); 516 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 517 WebThreadRun([protectedThis, this] { 518 if (m_model) 519 m_model->playbackSessionModel().play(); 520 }); 521 } 522 523 void WebVideoFullscreenControllerContext::pause() 524 { 525 ASSERT(isUIThread()); 526 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 527 WebThreadRun([protectedThis, this] { 528 if (m_model) 529 m_model->playbackSessionModel().pause(); 530 }); 531 } 532 533 void WebVideoFullscreenControllerContext::togglePlayState() 534 { 535 ASSERT(isUIThread()); 536 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 537 WebThreadRun([protectedThis, this] { 538 if (m_model) 539 m_model->playbackSessionModel().togglePlayState(); 540 }); 541 } 542 543 void WebVideoFullscreenControllerContext::beginScrubbing() 544 { 545 ASSERT(isUIThread()); 546 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 547 WebThreadRun([protectedThis, this] { 548 if (m_model) 549 m_model->playbackSessionModel().beginScrubbing(); 550 }); 551 } 552 553 void WebVideoFullscreenControllerContext::endScrubbing() 554 { 555 ASSERT(isUIThread()); 556 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 557 WebThreadRun([protectedThis, this] { 558 if (m_model) 559 m_model->playbackSessionModel().endScrubbing(); 560 }); 561 } 562 563 void WebVideoFullscreenControllerContext::seekToTime(double time) 564 { 565 ASSERT(isUIThread()); 566 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 567 WebThreadRun([protectedThis, this, time] { 568 if (m_model) 569 m_model->playbackSessionModel().seekToTime(time); 570 }); 571 } 572 573 void WebVideoFullscreenControllerContext::fastSeek(double time) 574 { 575 ASSERT(isUIThread()); 576 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 577 WebThreadRun([protectedThis, this, time] { 578 if (m_model) 579 m_model->playbackSessionModel().fastSeek(time); 580 }); 581 } 582 583 void WebVideoFullscreenControllerContext::beginScanningForward() 584 { 585 ASSERT(isUIThread()); 586 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 587 WebThreadRun([protectedThis, this] { 588 if (m_model) 589 m_model->playbackSessionModel().beginScanningForward(); 590 }); 591 } 592 593 void WebVideoFullscreenControllerContext::beginScanningBackward() 594 { 595 ASSERT(isUIThread()); 596 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 597 WebThreadRun([protectedThis, this] { 598 if (m_model) 599 m_model->playbackSessionModel().beginScanningBackward(); 600 }); 601 } 602 603 void WebVideoFullscreenControllerContext::endScanning() 604 { 605 ASSERT(isUIThread()); 606 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 607 WebThreadRun([protectedThis, this] { 608 if (m_model) 609 m_model->playbackSessionModel().endScanning(); 610 }); 611 } 612 613 void WebVideoFullscreenControllerContext::selectAudioMediaOption(uint64_t index) 614 { 615 ASSERT(isUIThread()); 616 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 617 WebThreadRun([protectedThis, this, index] { 618 if (m_model) 619 m_model->playbackSessionModel().selectAudioMediaOption(index); 620 }); 621 } 622 623 void WebVideoFullscreenControllerContext::selectLegibleMediaOption(uint64_t index) 624 { 625 ASSERT(isUIThread()); 626 RefPtr<WebVideoFullscreenControllerContext> protectedThis(this); 627 WebThreadRun([protectedThis, this, index] { 628 if (m_model) 629 m_model->playbackSessionModel().selectLegibleMediaOption(index); 630 }); 631 } 632 415 633 #pragma mark Other 416 634 … … 425 643 ASSERT(isUIThread()); 426 644 427 m_interface = WebVideoFullscreenInterfaceAVKit::create(WebPlaybackSessionInterfaceAVKit::create().get()); 645 Ref<WebPlaybackSessionInterfaceAVKit> sessionInterface = WebPlaybackSessionInterfaceAVKit::create(); 646 m_interface = WebVideoFullscreenInterfaceAVKit::create(sessionInterface.get()); 647 648 m_sessionModel = WebVideoFullscreenSessionModel::create(*this); 649 sessionInterface->setWebPlaybackSessionModel(m_sessionModel.get()); 650 651 m_interface->setWebVideoFullscreenModel(this); 428 652 m_interface->setWebVideoFullscreenChangeObserver(this); 429 m_interface->setWebVideoFullscreenModel(this); 653 430 654 m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]); 431 655 … … 435 659 m_model->setWebVideoFullscreenInterface(this); 436 660 m_model->setVideoElement(m_videoElement.get()); 437 438 bool allowsPictureInPicture = m_videoElement->mediaSession().allowsPictureInPicture(*m_videoElement.get());439 661 440 662 IntRect videoElementClientRect = elementRectInWindow(m_videoElement.get()); … … 442 664 m_model->setVideoLayerFrame(videoLayerFrame); 443 665 666 bool allowsPictureInPicture = m_videoElement->mediaSession().allowsPictureInPicture(*m_videoElement.get()); 444 667 dispatch_async(dispatch_get_main_queue(), [protectedThis, this, videoElementClientRect, viewRef, mode, allowsPictureInPicture] { 445 668 m_interface->setupFullscreen(*m_videoFullscreenView.get(), videoElementClientRect, viewRef.get(), mode, allowsPictureInPicture); … … 465 688 m_interface->requestHideAndExitFullscreen(); 466 689 } 690 691 #pragma mark WebPlaybackSessionModel 692 693 void WebVideoFullscreenSessionModel::play() 694 { 695 if (m_controller) 696 m_controller->play(); 697 } 698 699 void WebVideoFullscreenSessionModel::pause() 700 { 701 if (m_controller) 702 m_controller->pause(); 703 } 704 705 void WebVideoFullscreenSessionModel::togglePlayState() 706 { 707 if (m_controller) 708 m_controller->togglePlayState(); 709 } 710 711 void WebVideoFullscreenSessionModel::beginScrubbing() 712 { 713 if (m_controller) 714 m_controller->beginScrubbing(); 715 } 716 717 void WebVideoFullscreenSessionModel::endScrubbing() 718 { 719 if (m_controller) 720 m_controller->endScrubbing(); 721 } 722 723 void WebVideoFullscreenSessionModel::seekToTime(double time) 724 { 725 if (m_controller) 726 m_controller->seekToTime(time); 727 } 728 729 void WebVideoFullscreenSessionModel::fastSeek(double time) 730 { 731 if (m_controller) 732 m_controller->fastSeek(time); 733 } 734 735 void WebVideoFullscreenSessionModel::beginScanningForward() 736 { 737 if (m_controller) 738 m_controller->beginScanningForward(); 739 } 740 741 void WebVideoFullscreenSessionModel::beginScanningBackward() 742 { 743 if (m_controller) 744 m_controller->beginScanningBackward(); 745 } 746 747 void WebVideoFullscreenSessionModel::endScanning() 748 { 749 if (m_controller) 750 m_controller->endScanning(); 751 } 752 753 void WebVideoFullscreenSessionModel::selectAudioMediaOption(uint64_t optionId) 754 { 755 if (m_controller) 756 m_controller->selectAudioMediaOption(optionId); 757 } 758 759 void WebVideoFullscreenSessionModel::selectLegibleMediaOption(uint64_t optionId) 760 { 761 if (m_controller) 762 m_controller->selectLegibleMediaOption(optionId); 763 } 764 467 765 468 766 @implementation WebVideoFullscreenController {
Note:
See TracChangeset
for help on using the changeset viewer.