| 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/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 44 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
| 45 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 46 #include "core/frame/csp/ContentSecurityPolicy.h" | 46 #include "core/frame/csp/ContentSecurityPolicy.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/RenderVideo.h" | 59 #include "core/rendering/RenderVideo.h" |
| 62 #include "core/rendering/RenderView.h" | 60 #include "core/rendering/RenderView.h" |
| 63 #include "core/rendering/compositing/RenderLayerCompositor.h" | 61 #include "core/rendering/compositing/RenderLayerCompositor.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() && document.settings()->mediaPlaybackRequiresUserGes
ture()) | 291 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes
ture()) |
| 318 m_userGestureRequiredForPlay = true; | 292 m_userGestureRequiredForPlay = true; |
| 319 | 293 |
| 320 // We must always have a ShadowRoot so children like <source> will not rende
r | 294 // We must always have a ShadowRoot so children like <source> will not rende
r |
| (...skipping 14 matching lines...) Expand all Loading... |
| 335 if (m_textTracks) | 309 if (m_textTracks) |
| 336 m_textTracks->clearOwner(); | 310 m_textTracks->clearOwner(); |
| 337 | 311 |
| 338 if (m_mediaController) { | 312 if (m_mediaController) { |
| 339 m_mediaController->removeMediaElement(this); | 313 m_mediaController->removeMediaElement(this); |
| 340 m_mediaController = nullptr; | 314 m_mediaController = nullptr; |
| 341 } | 315 } |
| 342 | 316 |
| 343 closeMediaSource(); | 317 closeMediaSource(); |
| 344 | 318 |
| 345 setMediaKeysInternal(0); | |
| 346 | |
| 347 removeElementFromDocumentMap(this, &document()); | 319 removeElementFromDocumentMap(this, &document()); |
| 348 | 320 |
| 349 // Destroying the player may cause a resource load to be canceled, | 321 // Destroying the player may cause a resource load to be canceled, |
| 350 // which could result in userCancelledLoad() being called back. | 322 // which could result in userCancelledLoad() being called back. |
| 351 // Setting m_completelyLoaded ensures that such a call will not cause | 323 // Setting m_completelyLoaded ensures that such a call will not cause |
| 352 // us to dispatch an abort event, which would result in a crash. | 324 // us to dispatch an abort event, which would result in a crash. |
| 353 // See http://crbug.com/233654 for more details. | 325 // See http://crbug.com/233654 for more details. |
| 354 m_completelyLoaded = true; | 326 m_completelyLoaded = true; |
| 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, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 510 |
| 539 void HTMLMediaElement::scheduleNextSourceChild() | 511 void HTMLMediaElement::scheduleNextSourceChild() |
| 540 { | 512 { |
| 541 // Schedule the timer to try the next <source> element WITHOUT resetting sta
te ala prepareForLoad. | 513 // Schedule the timer to try the next <source> element WITHOUT resetting sta
te ala prepareForLoad. |
| 542 m_pendingActionFlags |= LoadMediaResource; | 514 m_pendingActionFlags |= LoadMediaResource; |
| 543 m_loadTimer.startOneShot(0); | 515 m_loadTimer.startOneShot(0); |
| 544 } | 516 } |
| 545 | 517 |
| 546 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 518 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
| 547 { | 519 { |
| 520 scheduleEvent(Event::createCancelable(eventName)); |
| 521 } |
| 522 |
| 523 void HTMLMediaElement::scheduleEvent(PassRefPtr<Event> event) |
| 524 { |
| 548 #if LOG_MEDIA_EVENTS | 525 #if LOG_MEDIA_EVENTS |
| 549 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", eventNam
e.ascii().data()); | 526 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent - scheduling '%s'", event->t
ype().ascii().data()); |
| 550 #endif | 527 #endif |
| 551 m_asyncEventQueue->enqueueEvent(Event::createCancelable(eventName)); | 528 m_asyncEventQueue->enqueueEvent(event); |
| 552 } | 529 } |
| 553 | 530 |
| 554 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 531 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) |
| 555 { | 532 { |
| 556 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. | 533 RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'bef
oreload', which can make arbitrary DOM mutations. |
| 557 | 534 |
| 558 if (RuntimeEnabledFeatures::videoTrackEnabled() && (m_pendingActionFlags & L
oadTextTrackResource)) | 535 if (RuntimeEnabledFeatures::videoTrackEnabled() && (m_pendingActionFlags & L
oadTextTrackResource)) |
| 559 configureTextTracks(); | 536 configureTextTracks(); |
| 560 | 537 |
| 561 if (m_pendingActionFlags & LoadMediaResource) { | 538 if (m_pendingActionFlags & LoadMediaResource) { |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 if (hasMediaControls()) | 1635 if (hasMediaControls()) |
| 1659 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1636 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
| 1660 } | 1637 } |
| 1661 | 1638 |
| 1662 updatePlayState(); | 1639 updatePlayState(); |
| 1663 updateMediaController(); | 1640 updateMediaController(); |
| 1664 if (RuntimeEnabledFeatures::videoTrackEnabled()) | 1641 if (RuntimeEnabledFeatures::videoTrackEnabled()) |
| 1665 updateActiveTextTrackCues(currentTime()); | 1642 updateActiveTextTrackCues(currentTime()); |
| 1666 } | 1643 } |
| 1667 | 1644 |
| 1668 void HTMLMediaElement::mediaPlayerKeyAdded(const String& keySystem, const String
& sessionId) | |
| 1669 { | |
| 1670 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyAdded"); | |
| 1671 | |
| 1672 MediaKeyEventInit initializer; | |
| 1673 initializer.keySystem = keySystem; | |
| 1674 initializer.sessionId = sessionId; | |
| 1675 initializer.bubbles = false; | |
| 1676 initializer.cancelable = false; | |
| 1677 | |
| 1678 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyadded,
initializer); | |
| 1679 event->setTarget(this); | |
| 1680 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1681 } | |
| 1682 | |
| 1683 void HTMLMediaElement::mediaPlayerKeyError(const String& keySystem, const String
& sessionId, MediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short syst
emCode) | |
| 1684 { | |
| 1685 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyError: sessionID=%s, errorCo
de=%d, systemCode=%d", sessionId.utf8().data(), errorCode, systemCode); | |
| 1686 | |
| 1687 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 1688 switch (errorCode) { | |
| 1689 case MediaPlayerClient::UnknownError: | |
| 1690 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; | |
| 1691 break; | |
| 1692 case MediaPlayerClient::ClientError: | |
| 1693 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; | |
| 1694 break; | |
| 1695 case MediaPlayerClient::ServiceError: | |
| 1696 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_SERVICE; | |
| 1697 break; | |
| 1698 case MediaPlayerClient::OutputError: | |
| 1699 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_OUTPUT; | |
| 1700 break; | |
| 1701 case MediaPlayerClient::HardwareChangeError: | |
| 1702 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_HARDWARECHANGE; | |
| 1703 break; | |
| 1704 case MediaPlayerClient::DomainError: | |
| 1705 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_DOMAIN; | |
| 1706 break; | |
| 1707 } | |
| 1708 | |
| 1709 MediaKeyEventInit initializer; | |
| 1710 initializer.keySystem = keySystem; | |
| 1711 initializer.sessionId = sessionId; | |
| 1712 initializer.errorCode = MediaKeyError::create(mediaKeyErrorCode); | |
| 1713 initializer.systemCode = systemCode; | |
| 1714 initializer.bubbles = false; | |
| 1715 initializer.cancelable = false; | |
| 1716 | |
| 1717 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyerror,
initializer); | |
| 1718 event->setTarget(this); | |
| 1719 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1720 } | |
| 1721 | |
| 1722 void HTMLMediaElement::mediaPlayerKeyMessage(const String& keySystem, const Stri
ng& sessionId, const unsigned char* message, unsigned messageLength, const KURL&
defaultURL) | |
| 1723 { | |
| 1724 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyMessage: sessionID=%s", sess
ionId.utf8().data()); | |
| 1725 | |
| 1726 MediaKeyEventInit initializer; | |
| 1727 initializer.keySystem = keySystem; | |
| 1728 initializer.sessionId = sessionId; | |
| 1729 initializer.message = Uint8Array::create(message, messageLength); | |
| 1730 initializer.defaultURL = defaultURL; | |
| 1731 initializer.bubbles = false; | |
| 1732 initializer.cancelable = false; | |
| 1733 | |
| 1734 RefPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeymessage
, initializer); | |
| 1735 event->setTarget(this); | |
| 1736 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1737 } | |
| 1738 | |
| 1739 // Create a MediaKeyNeededEvent for WD EME. | |
| 1740 static PassRefPtr<Event> createNeedKeyEvent(const String& contentType, const uns
igned char* initData, unsigned initDataLength) | |
| 1741 { | |
| 1742 MediaKeyNeededEventInit initializer; | |
| 1743 initializer.contentType = contentType; | |
| 1744 initializer.initData = Uint8Array::create(initData, initDataLength); | |
| 1745 initializer.bubbles = false; | |
| 1746 initializer.cancelable = false; | |
| 1747 | |
| 1748 return MediaKeyNeededEvent::create(EventTypeNames::needkey, initializer); | |
| 1749 } | |
| 1750 | |
| 1751 // Create a 'needkey' MediaKeyEvent for v0.1b EME. | |
| 1752 static PassRefPtr<Event> createWebkitNeedKeyEvent(const String& contentType, con
st unsigned char* initData, unsigned initDataLength) | |
| 1753 { | |
| 1754 MediaKeyEventInit webkitInitializer; | |
| 1755 webkitInitializer.keySystem = String(); | |
| 1756 webkitInitializer.sessionId = String(); | |
| 1757 webkitInitializer.initData = Uint8Array::create(initData, initDataLength); | |
| 1758 webkitInitializer.bubbles = false; | |
| 1759 webkitInitializer.cancelable = false; | |
| 1760 | |
| 1761 return MediaKeyEvent::create(EventTypeNames::webkitneedkey, webkitInitialize
r); | |
| 1762 } | |
| 1763 | |
| 1764 bool HTMLMediaElement::mediaPlayerKeyNeeded(const String& contentType, const uns
igned char* initData, unsigned initDataLength) | |
| 1765 { | |
| 1766 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerKeyNeeded: contentType=%s", con
tentType.utf8().data()); | |
| 1767 | |
| 1768 if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { | |
| 1769 // Send event for WD EME. | |
| 1770 RefPtr<Event> event = createNeedKeyEvent(contentType, initData, initData
Length); | |
| 1771 event->setTarget(this); | |
| 1772 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1773 } | |
| 1774 | |
| 1775 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { | |
| 1776 // Send event for v0.1b EME. | |
| 1777 RefPtr<Event> event = createWebkitNeedKeyEvent(contentType, initData, in
itDataLength); | |
| 1778 event->setTarget(this); | |
| 1779 m_asyncEventQueue->enqueueEvent(event.release()); | |
| 1780 } | |
| 1781 | |
| 1782 return true; | |
| 1783 } | |
| 1784 | |
| 1785 bool HTMLMediaElement::setEmeMode(EmeMode emeMode, ExceptionState& exceptionStat
e) | |
| 1786 { | |
| 1787 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) { | |
| 1788 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr
efixed and unprefixed API not allowed."); | |
| 1789 return false; | |
| 1790 } | |
| 1791 m_emeMode = emeMode; | |
| 1792 return true; | |
| 1793 } | |
| 1794 | |
| 1795 blink::WebContentDecryptionModule* HTMLMediaElement::contentDecryptionModule() | |
| 1796 { | |
| 1797 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | |
| 1798 } | |
| 1799 | |
| 1800 void HTMLMediaElement::setMediaKeysInternal(MediaKeys* mediaKeys) | |
| 1801 { | |
| 1802 WTF_LOG(Media, "HTMLMediaElement::setMediaKeys"); | |
| 1803 if (m_mediaKeys == mediaKeys) | |
| 1804 return; | |
| 1805 | |
| 1806 ASSERT(m_emeMode = EmeModeUnprefixed); | |
| 1807 | |
| 1808 if (m_mediaKeys) | |
| 1809 m_mediaKeys->setMediaElement(0); | |
| 1810 m_mediaKeys = mediaKeys; | |
| 1811 if (m_mediaKeys) | |
| 1812 m_mediaKeys->setMediaElement(this); | |
| 1813 | |
| 1814 // If a player is connected, tell it that the CDM has changed. | |
| 1815 if (m_player) | |
| 1816 m_player->setContentDecryptionModule(contentDecryptionModule()); | |
| 1817 } | |
| 1818 | |
| 1819 void HTMLMediaElement::setMediaKeys(MediaKeys* mediaKeys, ExceptionState& except
ionState) | |
| 1820 { | |
| 1821 if (!setEmeMode(EmeModeUnprefixed, exceptionState)) | |
| 1822 return; | |
| 1823 | |
| 1824 setMediaKeysInternal(mediaKeys); | |
| 1825 } | |
| 1826 | |
| 1827 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1645 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
| 1828 { | 1646 { |
| 1829 ASSERT(m_player); | 1647 ASSERT(m_player); |
| 1830 if (m_networkState != NETWORK_LOADING) | 1648 if (m_networkState != NETWORK_LOADING) |
| 1831 return; | 1649 return; |
| 1832 | 1650 |
| 1833 double time = WTF::currentTime(); | 1651 double time = WTF::currentTime(); |
| 1834 double timedelta = time - m_previousProgressTime; | 1652 double timedelta = time - m_previousProgressTime; |
| 1835 | 1653 |
| 1836 if (m_player->didLoadingProgress()) { | 1654 if (m_player->didLoadingProgress()) { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 | 2035 |
| 2218 void HTMLMediaElement::closeMediaSource() | 2036 void HTMLMediaElement::closeMediaSource() |
| 2219 { | 2037 { |
| 2220 if (!m_mediaSource) | 2038 if (!m_mediaSource) |
| 2221 return; | 2039 return; |
| 2222 | 2040 |
| 2223 m_mediaSource->close(); | 2041 m_mediaSource->close(); |
| 2224 m_mediaSource = nullptr; | 2042 m_mediaSource = nullptr; |
| 2225 } | 2043 } |
| 2226 | 2044 |
| 2227 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionState& exceptionState) | |
| 2228 { | |
| 2229 WTF_LOG(Media, "HTMLMediaElement::webkitGenerateKeyRequest"); | |
| 2230 | |
| 2231 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2232 return; | |
| 2233 | |
| 2234 if (keySystem.isEmpty()) { | |
| 2235 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2236 return; | |
| 2237 } | |
| 2238 | |
| 2239 if (!m_player) { | |
| 2240 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2241 return; | |
| 2242 } | |
| 2243 | |
| 2244 const unsigned char* initDataPointer = 0; | |
| 2245 unsigned initDataLength = 0; | |
| 2246 if (initData) { | |
| 2247 initDataPointer = initData->data(); | |
| 2248 initDataLength = initData->length(); | |
| 2249 } | |
| 2250 | |
| 2251 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); | |
| 2252 throwExceptionForMediaKeyException(keySystem, String(), result, exceptionSta
te); | |
| 2253 } | |
| 2254 | |
| 2255 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onState& exceptionState) | |
| 2256 { | |
| 2257 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), exceptionState); | |
| 2258 } | |
| 2259 | |
| 2260 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionStat
e& exceptionState) | |
| 2261 { | |
| 2262 WTF_LOG(Media, "HTMLMediaElement::webkitAddKey"); | |
| 2263 | |
| 2264 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2265 return; | |
| 2266 | |
| 2267 if (keySystem.isEmpty()) { | |
| 2268 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2269 return; | |
| 2270 } | |
| 2271 | |
| 2272 if (!key) { | |
| 2273 exceptionState.throwDOMException(SyntaxError, "The key provided is inval
id."); | |
| 2274 return; | |
| 2275 } | |
| 2276 | |
| 2277 if (!key->length()) { | |
| 2278 exceptionState.throwDOMException(TypeMismatchError, "The key provided is
invalid."); | |
| 2279 return; | |
| 2280 } | |
| 2281 | |
| 2282 if (!m_player) { | |
| 2283 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2284 return; | |
| 2285 } | |
| 2286 | |
| 2287 const unsigned char* initDataPointer = 0; | |
| 2288 unsigned initDataLength = 0; | |
| 2289 if (initData) { | |
| 2290 initDataPointer = initData->data(); | |
| 2291 initDataLength = initData->length(); | |
| 2292 } | |
| 2293 | |
| 2294 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); | |
| 2295 throwExceptionForMediaKeyException(keySystem, sessionId, result, exceptionSt
ate); | |
| 2296 } | |
| 2297 | |
| 2298 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionState& exceptionState) | |
| 2299 { | |
| 2300 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), exceptionState
); | |
| 2301 } | |
| 2302 | |
| 2303 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionState& exceptionState) | |
| 2304 { | |
| 2305 WTF_LOG(Media, "HTMLMediaElement::webkitCancelKeyRequest"); | |
| 2306 | |
| 2307 if (!setEmeMode(EmeModePrefixed, exceptionState)) | |
| 2308 return; | |
| 2309 | |
| 2310 if (keySystem.isEmpty()) { | |
| 2311 exceptionState.throwDOMException(SyntaxError, "The key system provided i
s empty."); | |
| 2312 return; | |
| 2313 } | |
| 2314 | |
| 2315 if (!m_player) { | |
| 2316 exceptionState.throwDOMException(InvalidStateError, "No media has been l
oaded."); | |
| 2317 return; | |
| 2318 } | |
| 2319 | |
| 2320 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); | |
| 2321 throwExceptionForMediaKeyException(keySystem, sessionId, result, exceptionSt
ate); | |
| 2322 } | |
| 2323 | |
| 2324 bool HTMLMediaElement::loop() const | 2045 bool HTMLMediaElement::loop() const |
| 2325 { | 2046 { |
| 2326 return fastHasAttribute(loopAttr); | 2047 return fastHasAttribute(loopAttr); |
| 2327 } | 2048 } |
| 2328 | 2049 |
| 2329 void HTMLMediaElement::setLoop(bool b) | 2050 void HTMLMediaElement::setLoop(bool b) |
| 2330 { | 2051 { |
| 2331 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); | 2052 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); |
| 2332 setBooleanAttribute(loopAttr, b); | 2053 setBooleanAttribute(loopAttr, b); |
| 2333 } | 2054 } |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3415 m_audioSourceNode->unlock(); | 3136 m_audioSourceNode->unlock(); |
| 3416 #endif | 3137 #endif |
| 3417 } | 3138 } |
| 3418 | 3139 |
| 3419 void HTMLMediaElement::clearMediaPlayer(int flags) | 3140 void HTMLMediaElement::clearMediaPlayer(int flags) |
| 3420 { | 3141 { |
| 3421 forgetResourceSpecificTracks(); | 3142 forgetResourceSpecificTracks(); |
| 3422 | 3143 |
| 3423 closeMediaSource(); | 3144 closeMediaSource(); |
| 3424 | 3145 |
| 3425 setMediaKeysInternal(0); | |
| 3426 | |
| 3427 clearMediaPlayerAndAudioSourceProviderClient(); | 3146 clearMediaPlayerAndAudioSourceProviderClient(); |
| 3428 | 3147 |
| 3429 stopPeriodicTimers(); | 3148 stopPeriodicTimers(); |
| 3430 m_loadTimer.stop(); | 3149 m_loadTimer.stop(); |
| 3431 | 3150 |
| 3432 m_pendingActionFlags &= ~flags; | 3151 m_pendingActionFlags &= ~flags; |
| 3433 m_loadState = WaitingForSource; | 3152 m_loadState = WaitingForSource; |
| 3434 | 3153 |
| 3435 if (m_textTracks) | 3154 if (m_textTracks) |
| 3436 configureTextTrackDisplay(AssumeNoVisibleChange); | 3155 configureTextTrackDisplay(AssumeNoVisibleChange); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3707 #if ENABLE(WEB_AUDIO) | 3426 #if ENABLE(WEB_AUDIO) |
| 3708 if (m_audioSourceNode) | 3427 if (m_audioSourceNode) |
| 3709 m_audioSourceNode->lock(); | 3428 m_audioSourceNode->lock(); |
| 3710 #endif | 3429 #endif |
| 3711 | 3430 |
| 3712 if (m_mediaSource) | 3431 if (m_mediaSource) |
| 3713 closeMediaSource(); | 3432 closeMediaSource(); |
| 3714 | 3433 |
| 3715 m_player = MediaPlayer::create(this); | 3434 m_player = MediaPlayer::create(this); |
| 3716 | 3435 |
| 3717 if (m_emeMode == EmeModeUnprefixed && m_player) | |
| 3718 m_player->setContentDecryptionModule(contentDecryptionModule()); | |
| 3719 | |
| 3720 #if ENABLE(WEB_AUDIO) | 3436 #if ENABLE(WEB_AUDIO) |
| 3721 if (m_audioSourceNode) { | 3437 if (m_audioSourceNode) { |
| 3722 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. | 3438 // When creating the player, make sure its AudioSourceProvider knows abo
ut the MediaElementAudioSourceNode. |
| 3723 if (audioSourceProvider()) | 3439 if (audioSourceProvider()) |
| 3724 audioSourceProvider()->setClient(m_audioSourceNode); | 3440 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3725 | 3441 |
| 3726 m_audioSourceNode->unlock(); | 3442 m_audioSourceNode->unlock(); |
| 3727 } | 3443 } |
| 3728 #endif | 3444 #endif |
| 3729 } | 3445 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3929 { | 3645 { |
| 3930 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3646 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3931 } | 3647 } |
| 3932 | 3648 |
| 3933 bool HTMLMediaElement::isInteractiveContent() const | 3649 bool HTMLMediaElement::isInteractiveContent() const |
| 3934 { | 3650 { |
| 3935 return fastHasAttribute(controlsAttr); | 3651 return fastHasAttribute(controlsAttr); |
| 3936 } | 3652 } |
| 3937 | 3653 |
| 3938 } | 3654 } |
| OLD | NEW |