| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/frame/ContentSecurityPolicy.h" | 43 #include "core/frame/ContentSecurityPolicy.h" |
| 44 #include "core/frame/Frame.h" | 44 #include "core/frame/Frame.h" |
| 45 #include "core/frame/Settings.h" | 45 #include "core/frame/Settings.h" |
| 46 #include "core/frame/UseCounter.h" | 46 #include "core/frame/UseCounter.h" |
| 47 #include "core/html/HTMLMediaSource.h" | 47 #include "core/html/HTMLMediaSource.h" |
| 48 #include "core/html/HTMLSourceElement.h" | 48 #include "core/html/HTMLSourceElement.h" |
| 49 #include "core/html/HTMLTrackElement.h" | 49 #include "core/html/HTMLTrackElement.h" |
| 50 #include "core/html/MediaController.h" | 50 #include "core/html/MediaController.h" |
| 51 #include "core/html/MediaError.h" | 51 #include "core/html/MediaError.h" |
| 52 #include "core/html/MediaFragmentURIParser.h" | 52 #include "core/html/MediaFragmentURIParser.h" |
| 53 #include "core/html/MediaKeyError.h" | |
| 54 #include "core/html/MediaKeyEvent.h" | |
| 55 #include "core/html/TimeRanges.h" | 53 #include "core/html/TimeRanges.h" |
| 56 #include "core/html/shadow/MediaControls.h" | 54 #include "core/html/shadow/MediaControls.h" |
| 57 #include "core/html/track/InbandTextTrack.h" | 55 #include "core/html/track/InbandTextTrack.h" |
| 58 #include "core/html/track/TextTrackCueList.h" | 56 #include "core/html/track/TextTrackCueList.h" |
| 59 #include "core/html/track/TextTrackList.h" | 57 #include "core/html/track/TextTrackList.h" |
| 60 #include "core/loader/FrameLoader.h" | 58 #include "core/loader/FrameLoader.h" |
| 61 #include "core/rendering/RenderLayerCompositor.h" | 59 #include "core/rendering/RenderLayerCompositor.h" |
| 62 #include "core/rendering/RenderVideo.h" | 60 #include "core/rendering/RenderVideo.h" |
| 63 #include "core/rendering/RenderView.h" | 61 #include "core/rendering/RenderView.h" |
| 64 // FIXME: Remove dependency on modules/encryptedmedia (http://crbug.com/242754). | |
| 65 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" | |
| 66 #include "modules/encryptedmedia/MediaKeys.h" | |
| 67 #include "platform/ContentType.h" | 62 #include "platform/ContentType.h" |
| 68 #include "platform/Language.h" | 63 #include "platform/Language.h" |
| 69 #include "platform/Logging.h" | 64 #include "platform/Logging.h" |
| 70 #include "platform/MIMETypeFromURL.h" | 65 #include "platform/MIMETypeFromURL.h" |
| 71 #include "platform/MIMETypeRegistry.h" | 66 #include "platform/MIMETypeRegistry.h" |
| 72 #include "platform/NotImplemented.h" | 67 #include "platform/NotImplemented.h" |
| 73 #include "platform/UserGestureIndicator.h" | 68 #include "platform/UserGestureIndicator.h" |
| 74 #include "platform/graphics/GraphicsLayer.h" | 69 #include "platform/graphics/GraphicsLayer.h" |
| 75 #include "platform/weborigin/SecurityOrigin.h" | 70 #include "platform/weborigin/SecurityOrigin.h" |
| 76 #include "public/platform/Platform.h" | 71 #include "public/platform/Platform.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 139 |
| 145 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do
cument) | 140 static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* do
cument) |
| 146 { | 141 { |
| 147 DocumentElementSetMap& map = documentToElementSetMap(); | 142 DocumentElementSetMap& map = documentToElementSetMap(); |
| 148 HashSet<HTMLMediaElement*> set = map.take(document); | 143 HashSet<HTMLMediaElement*> set = map.take(document); |
| 149 set.remove(element); | 144 set.remove(element); |
| 150 if (!set.isEmpty()) | 145 if (!set.isEmpty()) |
| 151 map.add(document, set); | 146 map.add(document, set); |
| 152 } | 147 } |
| 153 | 148 |
| 154 static void throwExceptionForMediaKeyException(const String& keySystem, const St
ring& sessionId, MediaPlayer::MediaKeyException exception, ExceptionState& excep
tionState) | |
| 155 { | |
| 156 switch (exception) { | |
| 157 case MediaPlayer::NoError: | |
| 158 return; | |
| 159 case MediaPlayer::InvalidPlayerState: | |
| 160 exceptionState.throwDOMException(InvalidStateError, "The player is in an
invalid state."); | |
| 161 return; | |
| 162 case MediaPlayer::KeySystemNotSupported: | |
| 163 exceptionState.throwDOMException(NotSupportedError, "The key system prov
ided ('" + keySystem +"') is not supported."); | |
| 164 return; | |
| 165 case MediaPlayer::InvalidAccess: | |
| 166 exceptionState.throwDOMException(InvalidAccessError, "The session ID pro
vided ('" + sessionId + "') is invalid."); | |
| 167 return; | |
| 168 } | |
| 169 | |
| 170 ASSERT_NOT_REACHED(); | |
| 171 return; | |
| 172 } | |
| 173 | |
| 174 class TrackDisplayUpdateScope { | 149 class TrackDisplayUpdateScope { |
| 175 public: | 150 public: |
| 176 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) | 151 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) |
| 177 { | 152 { |
| 178 m_mediaElement = mediaElement; | 153 m_mediaElement = mediaElement; |
| 179 m_mediaElement->beginIgnoringTrackDisplayUpdateRequests(); | 154 m_mediaElement->beginIgnoringTrackDisplayUpdateRequests(); |
| 180 } | 155 } |
| 181 ~TrackDisplayUpdateScope() | 156 ~TrackDisplayUpdateScope() |
| 182 { | 157 { |
| 183 ASSERT(m_mediaElement); | 158 ASSERT(m_mediaElement); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 , m_havePreparedToPlay(false) | 275 , m_havePreparedToPlay(false) |
| 301 , m_tracksAreReady(true) | 276 , m_tracksAreReady(true) |
| 302 , m_haveVisibleTextTrack(false) | 277 , m_haveVisibleTextTrack(false) |
| 303 , m_processingPreferenceChange(false) | 278 , m_processingPreferenceChange(false) |
| 304 , m_lastTextTrackUpdateTime(-1) | 279 , m_lastTextTrackUpdateTime(-1) |
| 305 , m_textTracks(nullptr) | 280 , m_textTracks(nullptr) |
| 306 , m_ignoreTrackDisplayUpdate(0) | 281 , m_ignoreTrackDisplayUpdate(0) |
| 307 #if ENABLE(WEB_AUDIO) | 282 #if ENABLE(WEB_AUDIO) |
| 308 , m_audioSourceNode(0) | 283 , m_audioSourceNode(0) |
| 309 #endif | 284 #endif |
| 310 , m_emeMode(EmeModeNotSelected) | |
| 311 { | 285 { |
| 312 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 286 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
| 313 | 287 |
| 314 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 288 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
| 315 ScriptWrappable::init(this); | 289 ScriptWrappable::init(this); |
| 316 | 290 |
| 317 if (document.settings()) { | 291 if (document.settings()) { |
| 318 if (document.settings()->mediaPlaybackRequiresUserGesture()) | 292 if (document.settings()->mediaPlaybackRequiresUserGesture()) |
| 319 addBehaviorRestriction(RequireUserGestureForPlayRestriction); | 293 addBehaviorRestriction(RequireUserGestureForPlayRestriction); |
| 320 if (document.settings()->mediaFullscreenRequiresUserGesture()) | 294 if (document.settings()->mediaFullscreenRequiresUserGesture()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 342 m_textTracks->item(i)->clearClient(); | 316 m_textTracks->item(i)->clearClient(); |
| 343 } | 317 } |
| 344 | 318 |
| 345 if (m_mediaController) { | 319 if (m_mediaController) { |
| 346 m_mediaController->removeMediaElement(this); | 320 m_mediaController->removeMediaElement(this); |
| 347 m_mediaController = nullptr; | 321 m_mediaController = nullptr; |
| 348 } | 322 } |
| 349 | 323 |
| 350 closeMediaSource(); | 324 closeMediaSource(); |
| 351 | 325 |
| 352 setMediaKeysInternal(0); | |
| 353 | |
| 354 removeElementFromDocumentMap(this, &document()); | 326 removeElementFromDocumentMap(this, &document()); |
| 355 | 327 |
| 356 // Destroying the player may cause a resource load to be canceled, | 328 // Destroying the player may cause a resource load to be canceled, |
| 357 // which could result in userCancelledLoad() being called back. | 329 // which could result in userCancelledLoad() being called back. |
| 358 // Setting m_completelyLoaded ensures that such a call will not cause | 330 // Setting m_completelyLoaded ensures that such a call will not cause |
| 359 // us to dispatch an abort event, which would result in a crash. | 331 // us to dispatch an abort event, which would result in a crash. |
| 360 // See http://crbug.com/233654 for more details. | 332 // See http://crbug.com/233654 for more details. |
| 361 m_completelyLoaded = true; | 333 m_completelyLoaded = true; |
| 362 | 334 |
| 363 // Destroying the player may cause a resource load to be canceled, | 335 // Destroying the player may cause a resource load to be canceled, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 516 |
| 545 void HTMLMediaElement::scheduleNextSourceChild() | 517 void HTMLMediaElement::scheduleNextSourceChild() |
| 546 { | 518 { |
| 547 // Schedule the timer to try the next <source> element WITHOUT resetting sta
te ala prepareForLoad. | 519 // Schedule the timer to try the next <source> element WITHOUT resetting sta
te ala prepareForLoad. |
| 548 m_pendingActionFlags |= LoadMediaResource; | 520 m_pendingActionFlags |= LoadMediaResource; |
| 549 m_loadTimer.startOneShot(0); | 521 m_loadTimer.startOneShot(0); |
| 550 } | 522 } |
| 551 | 523 |
| 552 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 524 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
| 553 { | 525 { |
| 526 scheduleEvent(Event::createCancelable(eventName)); |
| 527 } |
| 528 |
| 529 void HTMLMediaElement::scheduleEvent(PassRefPtr<Event> event) |
| 530 { |
| 554 #if LOG_MEDIA_EVENTS | 531 #if LOG_MEDIA_EVENTS |
| 555 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", eventNam
e.ascii().data()); | 532 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", event->t
ype().ascii().data()); |
| 556 #endif | 533 #endif |
| 557 m_asyncEventQueue->enqueueEvent(Event::createCancelable(eventName)); | 534 m_asyncEventQueue->enqueueEvent(event); |
| 558 } | 535 } |
| 559 | 536 |
| 560 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 537 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) |
| 561 { | 538 { |
| 562 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. | 539 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. |
| 563 | 540 |
| 564 if (RuntimeEnabledFeatures::videoTrackEnabled() && (m_pendingActionFlags & L
oadTextTrackResource)) | 541 if (RuntimeEnabledFeatures::videoTrackEnabled() && (m_pendingActionFlags & L
oadTextTrackResource)) |
| 565 configureTextTracks(); | 542 configureTextTracks(); |
| 566 | 543 |
| 567 if (m_pendingActionFlags & LoadMediaResource) { | 544 if (m_pendingActionFlags & LoadMediaResource) { |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 if (hasMediaControls()) | 1604 if (hasMediaControls()) |
| 1628 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1605 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
| 1629 } | 1606 } |
| 1630 | 1607 |
| 1631 updatePlayState(); | 1608 updatePlayState(); |
| 1632 updateMediaController(); | 1609 updateMediaController(); |
| 1633 if (RuntimeEnabledFeatures::videoTrackEnabled()) | 1610 if (RuntimeEnabledFeatures::videoTrackEnabled()) |
| 1634 updateActiveTextTrackCues(currentTime()); | 1611 updateActiveTextTrackCues(currentTime()); |
| 1635 } | 1612 } |
| 1636 | 1613 |
| 1637 void HTMLMediaElement::mediaPlayerKeyAdded(const String& keySystem, const String
& sessionId) | |
| 1638 { | |
| 1639 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyAdded"); | |
| 1640 | |
| 1641 MediaKeyEventInit initializer; | |
| 1642 initializer.keySystem = keySystem; | |
| 1643 initializer.sessionId = sessionId; | |
| 1644 initializer.bubbles = false; | |
| 1645 initializer.cancelable = false; | |
| 1646 | |
| 1647 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyadded,
initializer); | |
| 1648 event->setTarget(this); | |
| 1649 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1650 } | |
| 1651 | |
| 1652 void HTMLMediaElement::mediaPlayerKeyError(const String& keySystem, const String
& sessionId, MediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short syst
emCode) | |
| 1653 { | |
| 1654 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyError: sessionID=%s, errorCo
de=%d, systemCode=%d", sessionId.utf8().data(), errorCode, systemCode); | |
| 1655 | |
| 1656 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 1657 switch (errorCode) { | |
| 1658 case MediaPlayerClient::UnknownError: | |
| 1659 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 1660 break; | |
| 1661 case MediaPlayerClient::ClientError: | |
| 1662 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | |
| 1663 break; | |
| 1664 case MediaPlayerClient::ServiceError: | |
| 1665 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_SERVICE; | |
| 1666 break; | |
| 1667 case MediaPlayerClient::OutputError: | |
| 1668 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_OUTPUT; | |
| 1669 break; | |
| 1670 case MediaPlayerClient::HardwareChangeError: | |
| 1671 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_HARDWARECHANGE; | |
| 1672 break; | |
| 1673 case MediaPlayerClient::DomainError: | |
| 1674 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_DOMAIN; | |
| 1675 break; | |
| 1676 } | |
| 1677 | |
| 1678 MediaKeyEventInit initializer; | |
| 1679 initializer.keySystem = keySystem; | |
| 1680 initializer.sessionId = sessionId; | |
| 1681 initializer.errorCode = MediaKeyError::create(mediaKeyErrorCode); | |
| 1682 initializer.systemCode = systemCode; | |
| 1683 initializer.bubbles = false; | |
| 1684 initializer.cancelable = false; | |
| 1685 | |
| 1686 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyerror,
initializer); | |
| 1687 event->setTarget(this); | |
| 1688 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1689 } | |
| 1690 | |
| 1691 void HTMLMediaElement::mediaPlayerKeyMessage(const String& keySystem, const Stri
ng& sessionId, const unsigned char* message, unsigned messageLength, const KURL&
defaultURL) | |
| 1692 { | |
| 1693 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyMessage: sessionID=%s", sess
ionId.utf8().data()); | |
| 1694 | |
| 1695 MediaKeyEventInit initializer; | |
| 1696 initializer.keySystem = keySystem; | |
| 1697 initializer.sessionId = sessionId; | |
| 1698 initializer.message = Uint8Array::create(message, messageLength); | |
| 1699 initializer.defaultURL = defaultURL; | |
| 1700 initializer.bubbles = false; | |
| 1701 initializer.cancelable = false; | |
| 1702 | |
| 1703 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeymessage
, initializer); | |
| 1704 event->setTarget(this); | |
| 1705 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1706 } | |
| 1707 | |
| 1708 // Create a MediaKeyNeededEvent for WD EME. | |
| 1709 static PassRefPtr<Event> createNeedKeyEvent(const String& contentType, const uns
igned char* initData, unsigned initDataLength) | |
| 1710 { | |
| 1711 MediaKeyNeededEventInit initializer; | |
| 1712 initializer.contentType = contentType; | |
| 1713 initializer.initData = Uint8Array::create(initData, initDataLength); | |
| 1714 initializer.bubbles = false; | |
| 1715 initializer.cancelable = false; | |
| 1716 | |
| 1717 return MediaKeyNeededEvent::create(EventTypeNames::needkey, initializer); | |
| 1718 } | |
| 1719 | |
| 1720 // Create a 'needkey' MediaKeyEvent for v0.1b EME. | |
| 1721 static PassRefPtr<Event> createWebkitNeedKeyEvent(const String& contentType, con
st unsigned char* initData, unsigned initDataLength) | |
| 1722 { | |
| 1723 MediaKeyEventInit webkitInitializer; | |
| 1724 webkitInitializer.keySystem = String(); | |
| 1725 webkitInitializer.sessionId = String(); | |
| 1726 webkitInitializer.initData = Uint8Array::create(initData, initDataLength); | |
| 1727 webkitInitializer.bubbles = false; | |
| 1728 webkitInitializer.cancelable = false; | |
| 1729 | |
| 1730 return MediaKeyEvent::create(EventTypeNames::webkitneedkey, webkitInitialize
r); | |
| 1731 } | |
| 1732 | |
| 1733 bool HTMLMediaElement::mediaPlayerKeyNeeded(const String& contentType, const uns
igned char* initData, unsigned initDataLength) | |
| 1734 { | |
| 1735 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyNeeded: contentType=%s", con
tentType.utf8().data()); | |
| 1736 | |
| 1737 if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { | |
| 1738 // Send event for WD EME. | |
| 1739 RefPtr<Event> event = createNeedKeyEvent(contentType, initData, initData
Length); | |
| 1740 event->setTarget(this); | |
| 1741 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1742 } | |
| 1743 | |
| 1744 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { | |
| 1745 // Send event for v0.1b EME. | |
| 1746 RefPtr<Event> event = createWebkitNeedKeyEvent(contentType, initData, in
itDataLength); | |
| 1747 event->setTarget(this); | |
| 1748 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1749 } | |
| 1750 | |
| 1751 return true; | |
| 1752 } | |
| 1753 | |
| 1754 bool HTMLMediaElement::setEmeMode(EmeMode emeMode, ExceptionState& exceptionStat
e) | |
| 1755 { | |
| 1756 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) { | |
| 1757 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr
efixed and unprefixed API not allowed."); | |
| 1758 return false; | |
| 1759 } | |
| 1760 m_emeMode = emeMode; | |
| 1761 return true; | |
| 1762 } | |
| 1763 | |
| 1764 blink::WebContentDecryptionModule* HTMLMediaElement::contentDecryptionModule() | |
| 1765 { | |
| 1766 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | |
| 1767 } | |
| 1768 | |
| 1769 void HTMLMediaElement::setMediaKeysInternal(MediaKeys* mediaKeys) | |
| 1770 { | |
| 1771 WTF_LOG(Media, "HTMLMediaElement::setMediaKeys"); | |
| 1772 if (m_mediaKeys == mediaKeys) | |
| 1773 return; | |
| 1774 | |
| 1775 ASSERT(m_emeMode = EmeModeUnprefixed); | |
| 1776 | |
| 1777 if (m_mediaKeys) | |
| 1778 m_mediaKeys->setMediaElement(0); | |
| 1779 m_mediaKeys = mediaKeys; | |
| 1780 if (m_mediaKeys) | |
| 1781 m_mediaKeys->setMediaElement(this); | |
| 1782 | |
| 1783 // If a player is connected, tell it that the CDM has changed. | |
| 1784 if (m_player) | |
| 1785 m_player->setContentDecryptionModule(contentDecryptionModule()); | |
| 1786 } | |
| 1787 | |
| 1788 void HTMLMediaElement::setMediaKeys(MediaKeys* mediaKeys, ExceptionState& except
ionState) | |
| 1789 { | |
| 1790 if (!setEmeMode(EmeModeUnprefixed, exceptionState)) | |
| 1791 return; | |
| 1792 | |
| 1793 setMediaKeysInternal(mediaKeys); | |
| 1794 } | |
| 1795 | |
| 1796 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1614 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
| 1797 { | 1615 { |
| 1798 ASSERT(m_player); | 1616 ASSERT(m_player); |
| 1799 if (m_networkState != NETWORK_LOADING) | 1617 if (m_networkState != NETWORK_LOADING) |
| 1800 return; | 1618 return; |
| 1801 | 1619 |
| 1802 double time = WTF::currentTime(); | 1620 double time = WTF::currentTime(); |
| 1803 double timedelta = time - m_previousProgressTime; | 1621 double timedelta = time - m_previousProgressTime; |
| 1804 | 1622 |
| 1805 if (m_player->didLoadingProgress()) { | 1623 if (m_player->didLoadingProgress()) { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 | 2004 |
| 2187 void HTMLMediaElement::closeMediaSource() | 2005 void HTMLMediaElement::closeMediaSource() |
| 2188 { | 2006 { |
| 2189 if (!m_mediaSource) | 2007 if (!m_mediaSource) |
| 2190 return; | 2008 return; |
| 2191 | 2009 |
| 2192 m_mediaSource->close(); | 2010 m_mediaSource->close(); |
| 2193 m_mediaSource = nullptr; | 2011 m_mediaSource = nullptr; |
| 2194 } | 2012 } |
| 2195 | 2013 |
| 2196 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionState& exceptionState) | |
| 2197 { | |
| 2198 WTF_LOG(Media, "HTMLMediaElement::webkitGenerateKeyRequest"); | |
| 2199 | |
| 2200 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2201 return; | |
| 2202 | |
| 2203 if (keySystem.isEmpty()) { | |
| 2204 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2205 return; | |
| 2206 } | |
| 2207 | |
| 2208 if (!m_player) { | |
| 2209 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2210 return; | |
| 2211 } | |
| 2212 | |
| 2213 const unsigned char* initDataPointer = 0; | |
| 2214 unsigned initDataLength = 0; | |
| 2215 if (initData) { | |
| 2216 initDataPointer = initData->data(); | |
| 2217 initDataLength = initData->length(); | |
| 2218 } | |
| 2219 | |
| 2220 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); | |
| 2221 throwExceptionForMediaKeyException(keySystem, String(), result, exceptionSta
te); | |
| 2222 } | |
| 2223 | |
| 2224 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onState& exceptionState) | |
| 2225 { | |
| 2226 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), exceptionState); | |
| 2227 } | |
| 2228 | |
| 2229 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat
e& exceptionState) | |
| 2230 { | |
| 2231 WTF_LOG(Media, "HTMLMediaElement::webkitAddKey"); | |
| 2232 | |
| 2233 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2234 return; | |
| 2235 | |
| 2236 if (keySystem.isEmpty()) { | |
| 2237 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2238 return; | |
| 2239 } | |
| 2240 | |
| 2241 if (!key) { | |
| 2242 exceptionState.throwDOMException(SyntaxError, "The key provided is inval
id."); | |
| 2243 return; | |
| 2244 } | |
| 2245 | |
| 2246 if (!key->length()) { | |
| 2247 exceptionState.throwDOMException(TypeMismatchError, "The key provided is
invalid."); | |
| 2248 return; | |
| 2249 } | |
| 2250 | |
| 2251 if (!m_player) { | |
| 2252 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2253 return; | |
| 2254 } | |
| 2255 | |
| 2256 const unsigned char* initDataPointer = 0; | |
| 2257 unsigned initDataLength = 0; | |
| 2258 if (initData) { | |
| 2259 initDataPointer = initData->data(); | |
| 2260 initDataLength = initData->length(); | |
| 2261 } | |
| 2262 | |
| 2263 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); | |
| 2264 throwExceptionForMediaKeyException(keySystem, sessionId, result, exceptionSt
ate); | |
| 2265 } | |
| 2266 | |
| 2267 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionState& exceptionState) | |
| 2268 { | |
| 2269 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), exceptionState
); | |
| 2270 } | |
| 2271 | |
| 2272 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionState& exceptionState) | |
| 2273 { | |
| 2274 WTF_LOG(Media, "HTMLMediaElement::webkitCancelKeyRequest"); | |
| 2275 | |
| 2276 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2277 return; | |
| 2278 | |
| 2279 if (keySystem.isEmpty()) { | |
| 2280 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2281 return; | |
| 2282 } | |
| 2283 | |
| 2284 if (!m_player) { | |
| 2285 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2286 return; | |
| 2287 } | |
| 2288 | |
| 2289 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); | |
| 2290 throwExceptionForMediaKeyException(keySystem, sessionId, result, exceptionSt
ate); | |
| 2291 } | |
| 2292 | |
| 2293 bool HTMLMediaElement::loop() const | 2014 bool HTMLMediaElement::loop() const |
| 2294 { | 2015 { |
| 2295 return fastHasAttribute(loopAttr); | 2016 return fastHasAttribute(loopAttr); |
| 2296 } | 2017 } |
| 2297 | 2018 |
| 2298 void HTMLMediaElement::setLoop(bool b) | 2019 void HTMLMediaElement::setLoop(bool b) |
| 2299 { | 2020 { |
| 2300 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); | 2021 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); |
| 2301 setBooleanAttribute(loopAttr, b); | 2022 setBooleanAttribute(loopAttr, b); |
| 2302 } | 2023 } |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 m_audioSourceNode->unlock(); | 3112 m_audioSourceNode->unlock(); |
| 3392 #endif | 3113 #endif |
| 3393 } | 3114 } |
| 3394 | 3115 |
| 3395 void HTMLMediaElement::clearMediaPlayer(int flags) | 3116 void HTMLMediaElement::clearMediaPlayer(int flags) |
| 3396 { | 3117 { |
| 3397 removeAllInbandTracks(); | 3118 removeAllInbandTracks(); |
| 3398 | 3119 |
| 3399 closeMediaSource(); | 3120 closeMediaSource(); |
| 3400 | 3121 |
| 3401 setMediaKeysInternal(0); | |
| 3402 | |
| 3403 clearMediaPlayerAndAudioSourceProviderClient(); | 3122 clearMediaPlayerAndAudioSourceProviderClient(); |
| 3404 | 3123 |
| 3405 stopPeriodicTimers(); | 3124 stopPeriodicTimers(); |
| 3406 m_loadTimer.stop(); | 3125 m_loadTimer.stop(); |
| 3407 | 3126 |
| 3408 m_pendingActionFlags &= ~flags; | 3127 m_pendingActionFlags &= ~flags; |
| 3409 m_loadState = WaitingForSource; | 3128 m_loadState = WaitingForSource; |
| 3410 | 3129 |
| 3411 if (m_textTracks) | 3130 if (m_textTracks) |
| 3412 configureTextTrackDisplay(AssumeNoVisibleChange); | 3131 configureTextTrackDisplay(AssumeNoVisibleChange); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3691 #if ENABLE(WEB_AUDIO) | 3410 #if ENABLE(WEB_AUDIO) |
| 3692 if (m_audioSourceNode) | 3411 if (m_audioSourceNode) |
| 3693 m_audioSourceNode->lock(); | 3412 m_audioSourceNode->lock(); |
| 3694 #endif | 3413 #endif |
| 3695 | 3414 |
| 3696 if (m_mediaSource) | 3415 if (m_mediaSource) |
| 3697 closeMediaSource(); | 3416 closeMediaSource(); |
| 3698 | 3417 |
| 3699 m_player = MediaPlayer::create(this); | 3418 m_player = MediaPlayer::create(this); |
| 3700 | 3419 |
| 3701 if (m_emeMode == EmeModeUnprefixed && m_player) | |
| 3702 m_player->setContentDecryptionModule(contentDecryptionModule()); | |
| 3703 | |
| 3704 #if ENABLE(WEB_AUDIO) | 3420 #if ENABLE(WEB_AUDIO) |
| 3705 if (m_audioSourceNode) { | 3421 if (m_audioSourceNode) { |
| 3706 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. | 3422 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. |
| 3707 if (audioSourceProvider()) | 3423 if (audioSourceProvider()) |
| 3708 audioSourceProvider()->setClient(m_audioSourceNode); | 3424 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3709 | 3425 |
| 3710 m_audioSourceNode->unlock(); | 3426 m_audioSourceNode->unlock(); |
| 3711 } | 3427 } |
| 3712 #endif | 3428 #endif |
| 3713 } | 3429 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3917 { | 3633 { |
| 3918 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3634 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3919 } | 3635 } |
| 3920 | 3636 |
| 3921 bool HTMLMediaElement::isInteractiveContent() const | 3637 bool HTMLMediaElement::isInteractiveContent() const |
| 3922 { | 3638 { |
| 3923 return fastHasAttribute(controlsAttr); | 3639 return fastHasAttribute(controlsAttr); |
| 3924 } | 3640 } |
| 3925 | 3641 |
| 3926 } | 3642 } |
| OLD | NEW |