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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "core/html/track/InbandTextTrack.h" | 57 #include "core/html/track/InbandTextTrack.h" |
58 #include "core/html/track/TextTrackContainer.h" | 58 #include "core/html/track/TextTrackContainer.h" |
59 #include "core/html/track/TextTrackList.h" | 59 #include "core/html/track/TextTrackList.h" |
60 #include "core/html/track/VideoTrack.h" | 60 #include "core/html/track/VideoTrack.h" |
61 #include "core/html/track/VideoTrackList.h" | 61 #include "core/html/track/VideoTrackList.h" |
62 #include "core/inspector/ConsoleMessage.h" | 62 #include "core/inspector/ConsoleMessage.h" |
63 #include "core/layout/LayoutVideo.h" | 63 #include "core/layout/LayoutVideo.h" |
64 #include "core/layout/LayoutView.h" | 64 #include "core/layout/LayoutView.h" |
65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
66 #include "core/loader/FrameLoader.h" | 66 #include "core/loader/FrameLoader.h" |
| 67 #include "core/loader/FrameLoaderClient.h" |
67 #include "platform/ContentType.h" | 68 #include "platform/ContentType.h" |
68 #include "platform/Logging.h" | 69 #include "platform/Logging.h" |
69 #include "platform/MIMETypeFromURL.h" | 70 #include "platform/MIMETypeFromURL.h" |
70 #include "platform/MIMETypeRegistry.h" | 71 #include "platform/MIMETypeRegistry.h" |
71 #include "platform/RuntimeEnabledFeatures.h" | 72 #include "platform/RuntimeEnabledFeatures.h" |
72 #include "platform/UserGestureIndicator.h" | 73 #include "platform/UserGestureIndicator.h" |
| 74 #include "platform/audio/AudioBus.h" |
| 75 #include "platform/audio/AudioSourceProviderClient.h" |
73 #include "platform/graphics/GraphicsLayer.h" | 76 #include "platform/graphics/GraphicsLayer.h" |
74 #include "platform/weborigin/SecurityOrigin.h" | 77 #include "platform/weborigin/SecurityOrigin.h" |
75 #include "public/platform/Platform.h" | 78 #include "public/platform/Platform.h" |
| 79 #include "public/platform/WebAudioSourceProvider.h" |
76 #include "public/platform/WebContentDecryptionModule.h" | 80 #include "public/platform/WebContentDecryptionModule.h" |
77 #include "public/platform/WebInbandTextTrack.h" | 81 #include "public/platform/WebInbandTextTrack.h" |
78 #include "wtf/CurrentTime.h" | 82 #include "wtf/CurrentTime.h" |
79 #include "wtf/MainThread.h" | 83 #include "wtf/MainThread.h" |
80 #include "wtf/MathExtras.h" | 84 #include "wtf/MathExtras.h" |
81 #include "wtf/text/CString.h" | 85 #include "wtf/text/CString.h" |
82 #include <limits> | 86 #include <limits> |
83 | 87 |
84 #if ENABLE(WEB_AUDIO) | 88 #if ENABLE(WEB_AUDIO) |
85 #include "platform/audio/AudioSourceProvider.h" | 89 #include "platform/audio/AudioSourceProvider.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 479 } |
476 #endif | 480 #endif |
477 | 481 |
478 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 482 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
479 { | 483 { |
480 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); | 484 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); |
481 | 485 |
482 if (m_shouldDelayLoadEvent) { | 486 if (m_shouldDelayLoadEvent) { |
483 document().incrementLoadEventDelayCount(); | 487 document().incrementLoadEventDelayCount(); |
484 // Note: Keeping the load event delay count increment on oldDocument tha
t was added | 488 // Note: Keeping the load event delay count increment on oldDocument tha
t was added |
485 // when m_shouldDelayLoadEvent was set so that destruction of m_player c
an not | 489 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia
Player can not |
486 // cause load event dispatching in oldDocument. | 490 // cause load event dispatching in oldDocument. |
487 } else { | 491 } else { |
488 // Incrementing the load event delay count so that destruction of m_play
er can not | 492 // Incrementing the load event delay count so that destruction of m_webM
ediaPlayer can not |
489 // cause load event dispatching in oldDocument. | 493 // cause load event dispatching in oldDocument. |
490 oldDocument.incrementLoadEventDelayCount(); | 494 oldDocument.incrementLoadEventDelayCount(); |
491 } | 495 } |
492 | 496 |
493 removeElementFromDocumentMap(this, &oldDocument); | 497 removeElementFromDocumentMap(this, &oldDocument); |
494 addElementToDocumentMap(this, &document()); | 498 addElementToDocumentMap(this, &document()); |
495 | 499 |
496 // FIXME: This is a temporary fix to prevent this object from causing the | 500 // FIXME: This is a temporary fix to prevent this object from causing the |
497 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 501 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
498 // previous document. A proper fix would provide a mechanism to allow this | 502 // previous document. A proper fix would provide a mechanism to allow this |
499 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references
on | 503 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references
on |
500 // document changes so that playback can be resumed properly. | 504 // document changes so that playback can be resumed properly. |
501 userCancelledLoad(); | 505 userCancelledLoad(); |
502 | 506 |
503 // Decrement the load event delay count on oldDocument now that m_player has
been destroyed | 507 // Decrement the load event delay count on oldDocument now that m_webMediaPl
ayer has been destroyed |
504 // and there is no risk of dispatching a load event from within the destruct
or. | 508 // and there is no risk of dispatching a load event from within the destruct
or. |
505 oldDocument.decrementLoadEventDelayCount(); | 509 oldDocument.decrementLoadEventDelayCount(); |
506 | 510 |
507 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 511 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
508 HTMLElement::didMoveToNewDocument(oldDocument); | 512 HTMLElement::didMoveToNewDocument(oldDocument); |
509 } | 513 } |
510 | 514 |
511 bool HTMLMediaElement::supportsFocus() const | 515 bool HTMLMediaElement::supportsFocus() const |
512 { | 516 { |
513 if (ownerDocument()->isMediaDocument()) | 517 if (ownerDocument()->isMediaDocument()) |
(...skipping 12 matching lines...) Expand all Loading... |
526 { | 530 { |
527 if (name == srcAttr) { | 531 if (name == srcAttr) { |
528 // Trigger a reload, as long as the 'src' attribute is present. | 532 // Trigger a reload, as long as the 'src' attribute is present. |
529 if (!value.isNull()) { | 533 if (!value.isNull()) { |
530 clearMediaPlayer(LoadMediaResource); | 534 clearMediaPlayer(LoadMediaResource); |
531 scheduleDelayedAction(LoadMediaResource); | 535 scheduleDelayedAction(LoadMediaResource); |
532 } | 536 } |
533 } else if (name == controlsAttr) { | 537 } else if (name == controlsAttr) { |
534 configureMediaControls(); | 538 configureMediaControls(); |
535 } else if (name == preloadAttr) { | 539 } else if (name == preloadAttr) { |
536 if (m_player) | 540 setPlayerPreload(); |
537 setPlayerPreload(); | |
538 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController
Enabled()) { | 541 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController
Enabled()) { |
539 setMediaGroup(value); | 542 setMediaGroup(value); |
540 } else { | 543 } else { |
541 HTMLElement::parseAttribute(name, value); | 544 HTMLElement::parseAttribute(name, value); |
542 } | 545 } |
543 } | 546 } |
544 | 547 |
545 void HTMLMediaElement::finishParsingChildren() | 548 void HTMLMediaElement::finishParsingChildren() |
546 { | 549 { |
547 HTMLElement::finishParsingChildren(); | 550 HTMLElement::finishParsingChildren(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 740 |
738 // 2 - If there are any tasks from the media element's media element event t
ask source in | 741 // 2 - If there are any tasks from the media element's media element event t
ask source in |
739 // one of the task queues, then remove those tasks. | 742 // one of the task queues, then remove those tasks. |
740 cancelPendingEventsAndCallbacks(); | 743 cancelPendingEventsAndCallbacks(); |
741 | 744 |
742 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue | 745 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue |
743 // a task to fire a simple event named abort at the media element. | 746 // a task to fire a simple event named abort at the media element. |
744 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 747 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
745 scheduleEvent(EventTypeNames::abort); | 748 scheduleEvent(EventTypeNames::abort); |
746 | 749 |
747 createMediaPlayer(); | 750 resetMediaPlayerAndMediaSource(); |
748 | 751 |
749 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then
run these substeps | 752 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then
run these substeps |
750 if (m_networkState != NETWORK_EMPTY) { | 753 if (m_networkState != NETWORK_EMPTY) { |
751 // 4.1 - Queue a task to fire a simple event named emptied at the media
element. | 754 // 4.1 - Queue a task to fire a simple event named emptied at the media
element. |
752 scheduleEvent(EventTypeNames::emptied); | 755 scheduleEvent(EventTypeNames::emptied); |
753 | 756 |
754 // 4.2 - If a fetching process is in progress for the media element, the
user agent should stop it. | 757 // 4.2 - If a fetching process is in progress for the media element, the
user agent should stop it. |
755 m_networkState = NETWORK_EMPTY; | 758 m_networkState = NETWORK_EMPTY; |
756 | 759 |
757 // 4.3 - Forget the media element's media-resource-specific tracks. | 760 // 4.3 - Forget the media element's media-resource-specific tracks. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 void HTMLMediaElement::loadNextSourceChild() | 906 void HTMLMediaElement::loadNextSourceChild() |
904 { | 907 { |
905 ContentType contentType((String())); | 908 ContentType contentType((String())); |
906 String keySystem; | 909 String keySystem; |
907 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); | 910 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); |
908 if (!mediaURL.isValid()) { | 911 if (!mediaURL.isValid()) { |
909 waitForSourceChange(); | 912 waitForSourceChange(); |
910 return; | 913 return; |
911 } | 914 } |
912 | 915 |
913 // Recreate the media player for the new url | 916 // Reset the MediaPlayer and MediaSource if any |
914 createMediaPlayer(); | 917 resetMediaPlayerAndMediaSource(); |
915 | 918 |
916 m_loadState = LoadingFromSourceElement; | 919 m_loadState = LoadingFromSourceElement; |
917 loadResource(mediaURL, contentType, keySystem); | 920 loadResource(mediaURL, contentType, keySystem); |
918 } | 921 } |
919 | 922 |
920 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
onst String& keySystem) | 923 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
onst String& keySystem) |
921 { | 924 { |
922 ASSERT(isMainThread()); | 925 ASSERT(isMainThread()); |
923 ASSERT(isSafeToLoadURL(url, Complain)); | 926 ASSERT(isSafeToLoadURL(url, Complain)); |
924 | 927 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 m_mediaSource = nullptr; | 975 m_mediaSource = nullptr; |
973 attemptLoad = false; | 976 attemptLoad = false; |
974 } | 977 } |
975 } | 978 } |
976 } | 979 } |
977 } | 980 } |
978 | 981 |
979 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { | 982 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { |
980 ASSERT(!webMediaPlayer()); | 983 ASSERT(!webMediaPlayer()); |
981 | 984 |
982 if (!m_havePreparedToPlay && !autoplay() && preloadType() == MediaPlayer
::None) { | 985 if (!m_havePreparedToPlay && !autoplay() && preloadType() == WebMediaPla
yer::PreloadNone) { |
983 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); | 986 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); |
984 deferLoad(); | 987 deferLoad(); |
985 } else { | 988 } else { |
986 startPlayerLoad(); | 989 startPlayerLoad(); |
987 } | 990 } |
988 } else { | 991 } else { |
989 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 992 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
990 } | 993 } |
991 | 994 |
992 // If there is no poster to display, allow the media engine to render video
frames as soon as | 995 // If there is no poster to display, allow the media engine to render video
frames as soon as |
993 // they are available. | 996 // they are available. |
994 updateDisplayState(); | 997 updateDisplayState(); |
995 | 998 |
996 if (layoutObject()) | 999 if (layoutObject()) |
997 layoutObject()->updateFromElement(); | 1000 layoutObject()->updateFromElement(); |
998 } | 1001 } |
999 | 1002 |
1000 void HTMLMediaElement::startPlayerLoad() | 1003 void HTMLMediaElement::startPlayerLoad() |
1001 { | 1004 { |
| 1005 ASSERT(!m_webMediaPlayer); |
1002 // Filter out user:pass as those two URL components aren't | 1006 // Filter out user:pass as those two URL components aren't |
1003 // considered for media resource fetches (including for the CORS | 1007 // considered for media resource fetches (including for the CORS |
1004 // use-credentials mode.) That behavior aligns with Gecko, with IE | 1008 // use-credentials mode.) That behavior aligns with Gecko, with IE |
1005 // being more restrictive and not allowing fetches to such URLs. | 1009 // being more restrictive and not allowing fetches to such URLs. |
1006 // | 1010 // |
1007 // Spec reference: http://whatwg.org/c/#concept-media-load-resource | 1011 // Spec reference: http://whatwg.org/c/#concept-media-load-resource |
1008 // | 1012 // |
1009 // FIXME: when the HTML spec switches to specifying resource | 1013 // FIXME: when the HTML spec switches to specifying resource |
1010 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and | 1014 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and |
1011 // along with that potentially also specifying a setting for its | 1015 // along with that potentially also specifying a setting for its |
1012 // 'authentication flag' to control how user:pass embedded in a | 1016 // 'authentication flag' to control how user:pass embedded in a |
1013 // media resource URL should be treated, then update the handling | 1017 // media resource URL should be treated, then update the handling |
1014 // here to match. | 1018 // here to match. |
1015 KURL requestURL = m_currentSrc; | 1019 KURL requestURL = m_currentSrc; |
1016 if (!requestURL.user().isEmpty()) | 1020 if (!requestURL.user().isEmpty()) |
1017 requestURL.setUser(String()); | 1021 requestURL.setUser(String()); |
1018 if (!requestURL.pass().isEmpty()) | 1022 if (!requestURL.pass().isEmpty()) |
1019 requestURL.setPass(String()); | 1023 requestURL.setPass(String()); |
1020 | 1024 |
1021 m_player->load(loadType(), requestURL, corsMode()); | 1025 LocalFrame* frame = document().frame(); |
| 1026 // TODO(srirama.m): Figure out how frame can be null when |
| 1027 // coming from executeDeferredLoad() |
| 1028 if (!frame) { |
| 1029 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1030 return; |
| 1031 } |
| 1032 |
| 1033 KURL kurl(ParsedURLString, requestURL); |
| 1034 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl
); |
| 1035 if (!m_webMediaPlayer) { |
| 1036 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1037 return; |
| 1038 } |
| 1039 |
| 1040 if (layoutObject()) |
| 1041 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 1042 #if ENABLE(WEB_AUDIO) |
| 1043 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. |
| 1044 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); |
| 1045 #endif |
| 1046 m_webMediaPlayer->setVolume(effectiveMediaVolume()); |
| 1047 |
| 1048 m_webMediaPlayer->setPoster(posterImageURL()); |
| 1049 |
| 1050 m_webMediaPlayer->setPreload(effectivePreloadType()); |
| 1051 |
| 1052 m_webMediaPlayer->load(loadType(), kurl, corsMode()); |
| 1053 |
| 1054 if (isFullscreen()) |
| 1055 m_webMediaPlayer->enterFullscreen(); |
1022 } | 1056 } |
1023 | 1057 |
1024 void HTMLMediaElement::setPlayerPreload() | 1058 void HTMLMediaElement::setPlayerPreload() |
1025 { | 1059 { |
1026 m_player->setPreload(effectivePreloadType()); | 1060 if (m_webMediaPlayer) |
| 1061 m_webMediaPlayer->setPreload(effectivePreloadType()); |
1027 | 1062 |
1028 if (loadIsDeferred() && preloadType() != MediaPlayer::None) | 1063 if (loadIsDeferred() && preloadType() != WebMediaPlayer::PreloadNone) |
1029 startDeferredLoad(); | 1064 startDeferredLoad(); |
1030 } | 1065 } |
1031 | 1066 |
1032 bool HTMLMediaElement::loadIsDeferred() const | 1067 bool HTMLMediaElement::loadIsDeferred() const |
1033 { | 1068 { |
1034 return m_deferredLoadState != NotDeferred; | 1069 return m_deferredLoadState != NotDeferred; |
1035 } | 1070 } |
1036 | 1071 |
1037 void HTMLMediaElement::deferLoad() | 1072 void HTMLMediaElement::deferLoad() |
1038 { | 1073 { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 | 1317 |
1283 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1318 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
1284 { | 1319 { |
1285 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this
); | 1320 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this
); |
1286 m_asyncEventQueue->cancelAllEvents(); | 1321 m_asyncEventQueue->cancelAllEvents(); |
1287 | 1322 |
1288 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t
his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1323 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t
his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
1289 source->cancelPendingErrorEvent(); | 1324 source->cancelPendingErrorEvent(); |
1290 } | 1325 } |
1291 | 1326 |
1292 void HTMLMediaElement::mediaPlayerNetworkStateChanged() | 1327 void HTMLMediaElement::networkStateChanged() |
1293 { | 1328 { |
1294 setNetworkState(webMediaPlayer()->networkState()); | 1329 setNetworkState(webMediaPlayer()->networkState()); |
1295 } | 1330 } |
1296 | 1331 |
1297 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) | 1332 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
1298 { | 1333 { |
1299 stopPeriodicTimers(); | 1334 stopPeriodicTimers(); |
1300 | 1335 |
1301 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more | 1336 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more |
1302 // <source> children, schedule the next one | 1337 // <source> children, schedule the next one |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 | 1408 |
1374 if (state == WebMediaPlayer::NetworkStateLoaded) { | 1409 if (state == WebMediaPlayer::NetworkStateLoaded) { |
1375 if (m_networkState != NETWORK_IDLE) | 1410 if (m_networkState != NETWORK_IDLE) |
1376 changeNetworkStateFromLoadingToIdle(); | 1411 changeNetworkStateFromLoadingToIdle(); |
1377 m_completelyLoaded = true; | 1412 m_completelyLoaded = true; |
1378 } | 1413 } |
1379 } | 1414 } |
1380 | 1415 |
1381 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() | 1416 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
1382 { | 1417 { |
1383 ASSERT(m_player); | |
1384 m_progressEventTimer.stop(); | 1418 m_progressEventTimer.stop(); |
1385 | 1419 |
1386 // Schedule one last progress event so we guarantee that at least one is fir
ed | 1420 // Schedule one last progress event so we guarantee that at least one is fir
ed |
1387 // for files that load very quickly. | 1421 // for files that load very quickly. |
1388 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) | 1422 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) |
1389 scheduleEvent(EventTypeNames::progress); | 1423 scheduleEvent(EventTypeNames::progress); |
1390 scheduleEvent(EventTypeNames::suspend); | 1424 scheduleEvent(EventTypeNames::suspend); |
1391 m_networkState = NETWORK_IDLE; | 1425 m_networkState = NETWORK_IDLE; |
1392 } | 1426 } |
1393 | 1427 |
1394 void HTMLMediaElement::mediaPlayerReadyStateChanged() | 1428 void HTMLMediaElement::readyStateChanged() |
1395 { | 1429 { |
1396 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); | 1430 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); |
1397 } | 1431 } |
1398 | 1432 |
1399 void HTMLMediaElement::setReadyState(ReadyState state) | 1433 void HTMLMediaElement::setReadyState(ReadyState state) |
1400 { | 1434 { |
1401 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is %
d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); | 1435 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is %
d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); |
1402 | 1436 |
1403 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay
ing() uses it | 1437 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay
ing() uses it |
1404 bool wasPotentiallyPlaying = potentiallyPlaying(); | 1438 bool wasPotentiallyPlaying = potentiallyPlaying(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1576 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
1543 } | 1577 } |
1544 | 1578 |
1545 updatePlayState(); | 1579 updatePlayState(); |
1546 updateMediaController(); | 1580 updateMediaController(); |
1547 cueTimeline().updateActiveCues(currentTime()); | 1581 cueTimeline().updateActiveCues(currentTime()); |
1548 } | 1582 } |
1549 | 1583 |
1550 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1584 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
1551 { | 1585 { |
1552 ASSERT(m_player); | |
1553 if (m_networkState != NETWORK_LOADING) | 1586 if (m_networkState != NETWORK_LOADING) |
1554 return; | 1587 return; |
1555 | 1588 |
1556 double time = WTF::currentTime(); | 1589 double time = WTF::currentTime(); |
1557 double timedelta = time - m_previousProgressTime; | 1590 double timedelta = time - m_previousProgressTime; |
1558 | 1591 |
1559 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { | 1592 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { |
1560 scheduleEvent(EventTypeNames::progress); | 1593 scheduleEvent(EventTypeNames::progress); |
1561 m_previousProgressTime = time; | 1594 m_previousProgressTime = time; |
1562 m_sentStalledEvent = false; | 1595 m_sentStalledEvent = false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 | 1628 |
1596 void HTMLMediaElement::seek(double time) | 1629 void HTMLMediaElement::seek(double time) |
1597 { | 1630 { |
1598 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1631 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
1599 | 1632 |
1600 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1633 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
1601 if (m_readyState == HAVE_NOTHING) | 1634 if (m_readyState == HAVE_NOTHING) |
1602 return; | 1635 return; |
1603 | 1636 |
1604 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 1637 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
1605 if (preloadType() < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1638 if (preloadType() < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTUR
E_DATA) |
1606 prepareToPlay(); | 1639 prepareToPlay(); |
1607 | 1640 |
1608 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 1641 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
1609 refreshCachedTime(); | 1642 refreshCachedTime(); |
1610 // This is needed to avoid getting default playback start position from curr
entTime(). | 1643 // This is needed to avoid getting default playback start position from curr
entTime(). |
1611 double now = m_cachedTime; | 1644 double now = m_cachedTime; |
1612 | 1645 |
1613 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1646 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1614 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1647 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1615 // it is running to complete. | 1648 // it is running to complete. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 if (m_readyState == HAVE_NOTHING) { | 1802 if (m_readyState == HAVE_NOTHING) { |
1770 m_defaultPlaybackStartPosition = time; | 1803 m_defaultPlaybackStartPosition = time; |
1771 return; | 1804 return; |
1772 } | 1805 } |
1773 | 1806 |
1774 seek(time); | 1807 seek(time); |
1775 } | 1808 } |
1776 | 1809 |
1777 double HTMLMediaElement::duration() const | 1810 double HTMLMediaElement::duration() const |
1778 { | 1811 { |
1779 // FIXME: remove m_player check once we figure out how m_player is going | 1812 // FIXME: remove m_webMediaPlayer check once we figure out how |
1780 // out of sync with readystate. m_player is cleared but readystate is not se
t | 1813 // m_webMediaPlayer is going out of sync with readystate. |
1781 // to HAVE_NOTHING | 1814 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. |
1782 if (!m_player || m_readyState < HAVE_METADATA) | 1815 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA) |
1783 return std::numeric_limits<double>::quiet_NaN(); | 1816 return std::numeric_limits<double>::quiet_NaN(); |
1784 | 1817 |
1785 // FIXME: Refactor so m_duration is kept current (in both MSE and | 1818 // FIXME: Refactor so m_duration is kept current (in both MSE and |
1786 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> | 1819 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> |
1787 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE | 1820 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE |
1788 // case because MediaSource and SourceBuffer do not notify the element | 1821 // case because MediaSource and SourceBuffer do not notify the element |
1789 // directly upon duration changes caused by endOfStream, remove, or append | 1822 // directly upon duration changes caused by endOfStream, remove, or append |
1790 // operations; rather the notification is triggered by the WebMediaPlayer | 1823 // operations; rather the notification is triggered by the WebMediaPlayer |
1791 // implementation observing that the underlying engine has updated duration | 1824 // implementation observing that the underlying engine has updated duration |
1792 // and notifying the element to consult its MediaSource for current | 1825 // and notifying the element to consult its MediaSource for current |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 } | 1874 } |
1842 | 1875 |
1843 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst | 1876 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst |
1844 { | 1877 { |
1845 return m_playbackRate >= 0 ? Forward : Backward; | 1878 return m_playbackRate >= 0 ? Forward : Backward; |
1846 } | 1879 } |
1847 | 1880 |
1848 void HTMLMediaElement::updatePlaybackRate() | 1881 void HTMLMediaElement::updatePlaybackRate() |
1849 { | 1882 { |
1850 double effectiveRate = effectivePlaybackRate(); | 1883 double effectiveRate = effectivePlaybackRate(); |
1851 if (m_player && potentiallyPlaying()) | 1884 // FIXME: remove m_webMediaPlayer check once we figure out how |
| 1885 // m_webMediaPlayer is going out of sync with readystate. |
| 1886 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. |
| 1887 if (m_webMediaPlayer && potentiallyPlaying()) |
1852 webMediaPlayer()->setRate(effectiveRate); | 1888 webMediaPlayer()->setRate(effectiveRate); |
1853 } | 1889 } |
1854 | 1890 |
1855 bool HTMLMediaElement::ended() const | 1891 bool HTMLMediaElement::ended() const |
1856 { | 1892 { |
1857 // 4.8.10.8 Playing the media resource | 1893 // 4.8.10.8 Playing the media resource |
1858 // The ended attribute must return true if the media element has ended | 1894 // The ended attribute must return true if the media element has ended |
1859 // playback and the direction of playback is forwards, and false otherwise. | 1895 // playback and the direction of playback is forwards, and false otherwise. |
1860 return endedPlayback() && directionOfPlayback() == Forward; | 1896 return endedPlayback() && directionOfPlayback() == Forward; |
1861 } | 1897 } |
1862 | 1898 |
1863 bool HTMLMediaElement::autoplay() const | 1899 bool HTMLMediaElement::autoplay() const |
1864 { | 1900 { |
1865 return fastHasAttribute(autoplayAttr); | 1901 return fastHasAttribute(autoplayAttr); |
1866 } | 1902 } |
1867 | 1903 |
1868 String HTMLMediaElement::preload() const | 1904 String HTMLMediaElement::preload() const |
1869 { | 1905 { |
1870 switch (preloadType()) { | 1906 switch (preloadType()) { |
1871 case MediaPlayer::None: | 1907 case WebMediaPlayer::PreloadNone: |
1872 return "none"; | 1908 return "none"; |
1873 case MediaPlayer::MetaData: | 1909 case WebMediaPlayer::PreloadMetaData: |
1874 return "metadata"; | 1910 return "metadata"; |
1875 case MediaPlayer::Auto: | 1911 case WebMediaPlayer::PreloadAuto: |
1876 return "auto"; | 1912 return "auto"; |
1877 } | 1913 } |
1878 | 1914 |
1879 ASSERT_NOT_REACHED(); | 1915 ASSERT_NOT_REACHED(); |
1880 return String(); | 1916 return String(); |
1881 } | 1917 } |
1882 | 1918 |
1883 void HTMLMediaElement::setPreload(const AtomicString& preload) | 1919 void HTMLMediaElement::setPreload(const AtomicString& preload) |
1884 { | 1920 { |
1885 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8().
data()); | 1921 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8().
data()); |
1886 setAttribute(preloadAttr, preload); | 1922 setAttribute(preloadAttr, preload); |
1887 } | 1923 } |
1888 | 1924 |
1889 MediaPlayer::Preload HTMLMediaElement::preloadType() const | 1925 WebMediaPlayer::Preload HTMLMediaElement::preloadType() const |
1890 { | 1926 { |
1891 // TODO(philipj): The spec requires case-sensitive string matching: | 1927 // TODO(philipj): The spec requires case-sensitive string matching: |
1892 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28951 | 1928 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28951 |
1893 const AtomicString& preload = fastGetAttribute(preloadAttr); | 1929 const AtomicString& preload = fastGetAttribute(preloadAttr); |
1894 if (equalIgnoringCase(preload, "none")) { | 1930 if (equalIgnoringCase(preload, "none")) { |
1895 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone); | 1931 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadNone); |
1896 return MediaPlayer::None; | 1932 return WebMediaPlayer::PreloadNone; |
1897 } | 1933 } |
1898 if (equalIgnoringCase(preload, "metadata")) { | 1934 if (equalIgnoringCase(preload, "metadata")) { |
1899 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadMetadat
a); | 1935 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadMetadat
a); |
1900 return MediaPlayer::MetaData; | 1936 return WebMediaPlayer::PreloadMetaData; |
1901 } | 1937 } |
1902 if (equalIgnoringCase(preload, "auto")) { | 1938 if (equalIgnoringCase(preload, "auto")) { |
1903 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadAuto); | 1939 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadAuto); |
1904 return MediaPlayer::Auto; | 1940 return WebMediaPlayer::PreloadAuto; |
1905 } | 1941 } |
1906 | 1942 |
1907 // "The attribute's missing value default is user-agent defined, though the | 1943 // "The attribute's missing value default is user-agent defined, though the |
1908 // Metadata state is suggested as a compromise between reducing server load | 1944 // Metadata state is suggested as a compromise between reducing server load |
1909 // and providing an optimal user experience." | 1945 // and providing an optimal user experience." |
1910 | 1946 |
1911 // The spec does not define an invalid value default: | 1947 // The spec does not define an invalid value default: |
1912 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 | 1948 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28950 |
1913 | 1949 |
1914 // TODO(philipj): Try to make "metadata" the default preload state: | 1950 // TODO(philipj): Try to make "metadata" the default preload state: |
1915 // https://crbug.com/310450 | 1951 // https://crbug.com/310450 |
1916 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); | 1952 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
1917 return MediaPlayer::Auto; | 1953 return WebMediaPlayer::PreloadAuto; |
1918 } | 1954 } |
1919 | 1955 |
1920 MediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const | 1956 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
1921 { | 1957 { |
1922 return autoplay() ? MediaPlayer::Auto : preloadType(); | 1958 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); |
1923 } | 1959 } |
1924 | 1960 |
1925 void HTMLMediaElement::play() | 1961 void HTMLMediaElement::play() |
1926 { | 1962 { |
1927 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 1963 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); |
1928 | 1964 |
1929 if (!UserGestureIndicator::processingUserGesture()) { | 1965 if (!UserGestureIndicator::processingUserGesture()) { |
1930 autoplayMediaEncountered(); | 1966 autoplayMediaEncountered(); |
1931 if (m_userGestureRequiredForPlay) { | 1967 if (m_userGestureRequiredForPlay) { |
1932 String message = ExceptionMessages::failedToExecute("play", "HTMLMed
iaElement", "API can only be initiated by a user gesture."); | 1968 String message = ExceptionMessages::failedToExecute("play", "HTMLMed
iaElement", "API can only be initiated by a user gesture."); |
1933 document().executionContext()->addConsoleMessage(ConsoleMessage::cre
ate(JSMessageSource, WarningMessageLevel, message)); | 1969 document().executionContext()->addConsoleMessage(ConsoleMessage::cre
ate(JSMessageSource, WarningMessageLevel, message)); |
1934 return; | 1970 return; |
1935 } | 1971 } |
1936 } else if (m_userGestureRequiredForPlay) { | 1972 } else if (m_userGestureRequiredForPlay) { |
1937 if (m_autoplayMediaCounted) | 1973 if (m_autoplayMediaCounted) |
1938 recordAutoplayMetric(AutoplayManualStart); | 1974 recordAutoplayMetric(AutoplayManualStart); |
1939 m_userGestureRequiredForPlay = false; | 1975 m_userGestureRequiredForPlay = false; |
1940 } | 1976 } |
1941 | 1977 |
1942 playInternal(); | 1978 playInternal(); |
1943 } | 1979 } |
1944 | 1980 |
1945 void HTMLMediaElement::playInternal() | 1981 void HTMLMediaElement::playInternal() |
1946 { | 1982 { |
1947 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 1983 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
1948 | 1984 |
1949 // 4.8.10.9. Playing the media resource | 1985 // 4.8.10.9. Playing the media resource |
1950 if (!m_player || m_networkState == NETWORK_EMPTY) | 1986 if (m_networkState == NETWORK_EMPTY) |
1951 scheduleDelayedAction(LoadMediaResource); | 1987 scheduleDelayedAction(LoadMediaResource); |
1952 | 1988 |
1953 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 1989 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
1954 // is ignored to seek back to start in case loop was set after playback | 1990 // is ignored to seek back to start in case loop was set after playback |
1955 // ended. See http://crbug.com/364442 | 1991 // ended. See http://crbug.com/364442 |
1956 if (endedPlayback(LoopCondition::Ignored)) | 1992 if (endedPlayback(LoopCondition::Ignored)) |
1957 seek(0); | 1993 seek(0); |
1958 | 1994 |
1959 if (m_mediaController) | 1995 if (m_mediaController) |
1960 m_mediaController->bringElementUpToSpeed(this); | 1996 m_mediaController->bringElementUpToSpeed(this); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 double progress = playedTime / duration(); | 2036 double progress = playedTime / duration(); |
2001 if (progress < 0.5) | 2037 if (progress < 0.5) |
2002 recordAutoplayMetric(AutoplayBailout); | 2038 recordAutoplayMetric(AutoplayBailout); |
2003 } | 2039 } |
2004 } | 2040 } |
2005 | 2041 |
2006 void HTMLMediaElement::pause() | 2042 void HTMLMediaElement::pause() |
2007 { | 2043 { |
2008 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); | 2044 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); |
2009 | 2045 |
2010 if (!m_player || m_networkState == NETWORK_EMPTY) | 2046 if (m_networkState == NETWORK_EMPTY) |
2011 scheduleDelayedAction(LoadMediaResource); | 2047 scheduleDelayedAction(LoadMediaResource); |
2012 | 2048 |
2013 m_autoplaying = false; | 2049 m_autoplaying = false; |
2014 | 2050 |
2015 if (!m_paused) { | 2051 if (!m_paused) { |
2016 if (m_initialPlayWithoutUserGestures) | 2052 if (m_initialPlayWithoutUserGestures) |
2017 gesturelessInitialPlayHalted(); | 2053 gesturelessInitialPlayHalted(); |
2018 | 2054 |
2019 m_paused = true; | 2055 m_paused = true; |
2020 scheduleTimeupdateEvent(false); | 2056 scheduleTimeupdateEvent(false); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 { | 2181 { |
2146 if (m_playbackProgressTimer.isActive()) | 2182 if (m_playbackProgressTimer.isActive()) |
2147 return; | 2183 return; |
2148 | 2184 |
2149 m_previousProgressTime = WTF::currentTime(); | 2185 m_previousProgressTime = WTF::currentTime(); |
2150 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER
E); | 2186 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER
E); |
2151 } | 2187 } |
2152 | 2188 |
2153 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) | 2189 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
2154 { | 2190 { |
2155 ASSERT(m_player); | |
2156 | |
2157 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime &&
directionOfPlayback() == Forward) { | 2191 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime &&
directionOfPlayback() == Forward) { |
2158 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); | 2192 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
2159 if (!m_mediaController && !m_paused) { | 2193 if (!m_mediaController && !m_paused) { |
2160 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); | 2194 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); |
2161 // changes paused to true and fires a simple event named pause at th
e media element. | 2195 // changes paused to true and fires a simple event named pause at th
e media element. |
2162 pause(); | 2196 pause(); |
2163 } | 2197 } |
2164 } | 2198 } |
2165 | 2199 |
2166 if (!m_seeking) | 2200 if (!m_seeking) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2275 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
2242 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2276 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
2243 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2277 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
2244 if (track->enabled()) | 2278 if (track->enabled()) |
2245 enabledTrackIds.append(track->trackId()); | 2279 enabledTrackIds.append(track->trackId()); |
2246 } | 2280 } |
2247 | 2281 |
2248 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2282 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
2249 } | 2283 } |
2250 | 2284 |
2251 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMed
iaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStri
ng& language, bool enabled) | 2285 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli
nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web
String& language, bool enabled) |
2252 { | 2286 { |
2253 AtomicString kindString = AudioKindToString(kind); | 2287 AtomicString kindString = AudioKindToString(kind); |
2254 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s',
%d)", | 2288 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s',
%d)", |
2255 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), enabled); | 2289 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(),
language.utf8().data(), enabled); |
2256 | 2290 |
2257 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2291 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2258 return 0; | 2292 return 0; |
2259 | 2293 |
2260 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin
g, label, language, enabled); | 2294 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin
g, label, language, enabled); |
2261 audioTracks().add(audioTrack); | 2295 audioTracks().add(audioTrack); |
2262 | 2296 |
2263 return audioTrack->trackId(); | 2297 return audioTrack->trackId(); |
2264 } | 2298 } |
2265 | 2299 |
(...skipping 19 matching lines...) Expand all Loading... |
2285 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2319 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2286 | 2320 |
2287 if (selectedTrackId) | 2321 if (selectedTrackId) |
2288 videoTracks().trackSelected(*selectedTrackId); | 2322 videoTracks().trackSelected(*selectedTrackId); |
2289 | 2323 |
2290 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. | 2324 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. |
2291 | 2325 |
2292 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2326 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
2293 } | 2327 } |
2294 | 2328 |
2295 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMed
iaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStri
ng& language, bool selected) | 2329 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli
nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web
String& language, bool selected) |
2296 { | 2330 { |
2297 AtomicString kindString = VideoKindToString(kind); | 2331 AtomicString kindString = VideoKindToString(kind); |
2298 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s',
%d)", | 2332 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s',
%d)", |
2299 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), selected); | 2333 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(),
language.utf8().data(), selected); |
2300 | 2334 |
2301 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2335 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2302 return 0; | 2336 return 0; |
2303 | 2337 |
2304 // If another track was selected (potentially by the user), leave it selecte
d. | 2338 // If another track was selected (potentially by the user), leave it selecte
d. |
2305 if (selected && videoTracks().selectedIndex() != -1) | 2339 if (selected && videoTracks().selectedIndex() != -1) |
2306 selected = false; | 2340 selected = false; |
2307 | 2341 |
2308 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin
g, label, language, selected); | 2342 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin
g, label, language, selected); |
2309 videoTracks().add(videoTrack); | 2343 videoTracks().add(videoTrack); |
2310 | 2344 |
2311 return videoTrack->trackId(); | 2345 return videoTrack->trackId(); |
2312 } | 2346 } |
2313 | 2347 |
2314 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) | 2348 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
2315 { | 2349 { |
2316 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); | 2350 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); |
2317 | 2351 |
2318 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2352 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2319 return; | 2353 return; |
2320 | 2354 |
2321 videoTracks().remove(trackId); | 2355 videoTracks().remove(trackId); |
2322 } | 2356 } |
2323 | 2357 |
2324 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2358 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
2325 { | 2359 { |
2326 // 4.8.10.12.2 Sourcing in-band text tracks | 2360 // 4.8.10.12.2 Sourcing in-band text tracks |
2327 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. | 2361 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. |
2328 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT
rack); | 2362 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT
rack); |
2329 | 2363 |
2330 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, | 2364 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, |
2331 // as defined by the relevant specification. If there is no label in that da
ta, then the label must | 2365 // as defined by the relevant specification. If there is no label in that da
ta, then the label must |
2332 // be set to the empty string. | 2366 // be set to the empty string. |
2333 // 3. Associate the text track list of cues with the rules for updating the
text track rendering appropriate | 2367 // 3. Associate the text track list of cues with the rules for updating the
text track rendering appropriate |
2334 // for the format in question. | 2368 // for the format in question. |
(...skipping 11 matching lines...) Expand all Loading... |
2346 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection
() | 2380 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection
() |
2347 scheduleDelayedAction(LoadTextTrackResource); | 2381 scheduleDelayedAction(LoadTextTrackResource); |
2348 | 2382 |
2349 // 8. Add the new text track to the media element's list of text tracks. | 2383 // 8. Add the new text track to the media element's list of text tracks. |
2350 // 9. Fire an event with the name addtrack, that does not bubble and is not
cancelable, and that uses the TrackEvent | 2384 // 9. Fire an event with the name addtrack, that does not bubble and is not
cancelable, and that uses the TrackEvent |
2351 // interface, with the track attribute initialized to the text track's TextT
rack object, at the media element's | 2385 // interface, with the track attribute initialized to the text track's TextT
rack object, at the media element's |
2352 // textTracks attribute's TextTrackList object. | 2386 // textTracks attribute's TextTrackList object. |
2353 addTextTrack(textTrack.get()); | 2387 addTextTrack(textTrack.get()); |
2354 } | 2388 } |
2355 | 2389 |
2356 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac
k) | 2390 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) |
2357 { | 2391 { |
2358 if (!m_textTracks) | 2392 if (!m_textTracks) |
2359 return; | 2393 return; |
2360 | 2394 |
2361 // This cast is safe because we created the InbandTextTrack with the WebInba
ndTextTrack | 2395 // This cast is safe because we created the InbandTextTrack with the WebInba
ndTextTrack |
2362 // passed to mediaPlayerDidAddTextTrack. | 2396 // passed to mediaPlayerDidAddTextTrack. |
2363 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*
>(webTrack->client()); | 2397 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack*
>(webTrack->client()); |
2364 if (!textTrack) | 2398 if (!textTrack) |
2365 return; | 2399 return; |
2366 | 2400 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2691 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC
onsider set to %p", this, m_nextChildNodeToConsider.get()); | 2725 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC
onsider set to %p", this, m_nextChildNodeToConsider.get()); |
2692 } else if (source == m_currentSourceNode) { | 2726 } else if (source == m_currentSourceNode) { |
2693 // Clear the current source node pointer, but don't change the movie as
the spec says: | 2727 // Clear the current source node pointer, but don't change the movie as
the spec says: |
2694 // 4.8.8 - Dynamically modifying a source element and its attribute when
the element is already | 2728 // 4.8.8 - Dynamically modifying a source element and its attribute when
the element is already |
2695 // inserted in a video or audio element will have no effect. | 2729 // inserted in a video or audio element will have no effect. |
2696 m_currentSourceNode = nullptr; | 2730 m_currentSourceNode = nullptr; |
2697 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod
e set to 0", this); | 2731 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod
e set to 0", this); |
2698 } | 2732 } |
2699 } | 2733 } |
2700 | 2734 |
2701 void HTMLMediaElement::mediaPlayerTimeChanged() | 2735 void HTMLMediaElement::timeChanged() |
2702 { | 2736 { |
2703 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); | 2737 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); |
2704 | 2738 |
2705 cueTimeline().updateActiveCues(currentTime()); | 2739 cueTimeline().updateActiveCues(currentTime()); |
2706 | 2740 |
2707 invalidateCachedTime(); | 2741 invalidateCachedTime(); |
2708 | 2742 |
2709 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. | 2743 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. |
2710 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see
king()) | 2744 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see
king()) |
2711 finishSeek(); | 2745 finishSeek(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 // for the media element's current media controller. | 2778 // for the media element's current media controller. |
2745 updateMediaController(); | 2779 updateMediaController(); |
2746 } | 2780 } |
2747 } else { | 2781 } else { |
2748 m_sentEndEvent = false; | 2782 m_sentEndEvent = false; |
2749 } | 2783 } |
2750 | 2784 |
2751 updatePlayState(); | 2785 updatePlayState(); |
2752 } | 2786 } |
2753 | 2787 |
2754 void HTMLMediaElement::mediaPlayerDurationChanged() | 2788 void HTMLMediaElement::durationChanged() |
2755 { | 2789 { |
2756 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); | 2790 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this); |
2757 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey | 2791 // FIXME: Change WebMediaPlayer to convey the currentTime |
2758 // the currentTime when the duration change occured. The current | 2792 // when the duration change occured. The current WebMediaPlayer |
2759 // WebMediaPlayer implementations always clamp currentTime() to | 2793 // implementations always clamp currentTime() to duration() |
2760 // duration() so the requestSeek condition here is always false. | 2794 // so the requestSeek condition here is always false. |
2761 durationChanged(duration(), currentTime() > duration()); | 2795 durationChanged(duration(), currentTime() > duration()); |
2762 } | 2796 } |
2763 | 2797 |
2764 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) | 2798 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
2765 { | 2799 { |
2766 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati
on, requestSeek); | 2800 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati
on, requestSeek); |
2767 | 2801 |
2768 // Abort if duration unchanged. | 2802 // Abort if duration unchanged. |
2769 if (m_duration == duration) | 2803 if (m_duration == duration) |
2770 return; | 2804 return; |
2771 | 2805 |
2772 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d
uration, duration); | 2806 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d
uration, duration); |
2773 m_duration = duration; | 2807 m_duration = duration; |
2774 scheduleEvent(EventTypeNames::durationchange); | 2808 scheduleEvent(EventTypeNames::durationchange); |
2775 | 2809 |
2776 if (mediaControls()) | 2810 if (mediaControls()) |
2777 mediaControls()->reset(); | 2811 mediaControls()->reset(); |
2778 if (layoutObject()) | 2812 if (layoutObject()) |
2779 layoutObject()->updateFromElement(); | 2813 layoutObject()->updateFromElement(); |
2780 | 2814 |
2781 if (requestSeek) | 2815 if (requestSeek) |
2782 seek(duration); | 2816 seek(duration); |
2783 } | 2817 } |
2784 | 2818 |
2785 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 2819 void HTMLMediaElement::playbackStateChanged() |
2786 { | 2820 { |
2787 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this
); | 2821 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this
); |
2788 | 2822 |
2789 if (!webMediaPlayer()) | 2823 if (!webMediaPlayer()) |
2790 return; | 2824 return; |
2791 | 2825 |
2792 if (webMediaPlayer()->paused()) | 2826 if (webMediaPlayer()->paused()) |
2793 pause(); | 2827 pause(); |
2794 else | 2828 else |
2795 playInternal(); | 2829 playInternal(); |
2796 } | 2830 } |
2797 | 2831 |
2798 void HTMLMediaElement::mediaPlayerRequestSeek(double time) | 2832 void HTMLMediaElement::requestSeek(double time) |
2799 { | 2833 { |
2800 // The player is the source of this seek request. | 2834 // The player is the source of this seek request. |
2801 if (m_mediaController) { | 2835 if (m_mediaController) { |
2802 m_mediaController->setCurrentTime(time); | 2836 m_mediaController->setCurrentTime(time); |
2803 return; | 2837 return; |
2804 } | 2838 } |
2805 setCurrentTime(time, ASSERT_NO_EXCEPTION); | 2839 setCurrentTime(time, ASSERT_NO_EXCEPTION); |
2806 } | 2840 } |
2807 | 2841 |
2808 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) | 2842 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) |
(...skipping 11 matching lines...) Expand all Loading... |
2820 } | 2854 } |
2821 | 2855 |
2822 void HTMLMediaElement::disconnectedFromRemoteDevice() | 2856 void HTMLMediaElement::disconnectedFromRemoteDevice() |
2823 { | 2857 { |
2824 m_playingRemotely = false; | 2858 m_playingRemotely = false; |
2825 if (mediaControls()) | 2859 if (mediaControls()) |
2826 mediaControls()->stoppedCasting(); | 2860 mediaControls()->stoppedCasting(); |
2827 } | 2861 } |
2828 | 2862 |
2829 // MediaPlayerPresentation methods | 2863 // MediaPlayerPresentation methods |
2830 void HTMLMediaElement::mediaPlayerRepaint() | 2864 void HTMLMediaElement::repaint() |
2831 { | 2865 { |
2832 if (m_webLayer) | 2866 if (m_webLayer) |
2833 m_webLayer->invalidate(); | 2867 m_webLayer->invalidate(); |
2834 | 2868 |
2835 updateDisplayState(); | 2869 updateDisplayState(); |
2836 if (layoutObject()) | 2870 if (layoutObject()) |
2837 layoutObject()->setShouldDoFullPaintInvalidation(); | 2871 layoutObject()->setShouldDoFullPaintInvalidation(); |
2838 } | 2872 } |
2839 | 2873 |
2840 void HTMLMediaElement::mediaPlayerSizeChanged() | 2874 void HTMLMediaElement::sizeChanged() |
2841 { | 2875 { |
2842 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); | 2876 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
2843 | 2877 |
2844 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2878 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
2845 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2879 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
2846 scheduleEvent(EventTypeNames::resize); | 2880 scheduleEvent(EventTypeNames::resize); |
2847 | 2881 |
2848 if (layoutObject()) | 2882 if (layoutObject()) |
2849 layoutObject()->updateFromElement(); | 2883 layoutObject()->updateFromElement(); |
2850 } | 2884 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 } | 2929 } |
2896 | 2930 |
2897 bool HTMLMediaElement::couldPlayIfEnoughData() const | 2931 bool HTMLMediaElement::couldPlayIfEnoughData() const |
2898 { | 2932 { |
2899 return !paused() && !endedPlayback() && !stoppedDueToErrors(); | 2933 return !paused() && !endedPlayback() && !stoppedDueToErrors(); |
2900 } | 2934 } |
2901 | 2935 |
2902 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const | 2936 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const |
2903 { | 2937 { |
2904 double dur = duration(); | 2938 double dur = duration(); |
2905 if (!m_player || std::isnan(dur)) | 2939 if (std::isnan(dur)) |
2906 return false; | 2940 return false; |
2907 | 2941 |
2908 // 4.8.10.8 Playing the media resource | 2942 // 4.8.10.8 Playing the media resource |
2909 | 2943 |
2910 // A media element is said to have ended playback when the element's | 2944 // A media element is said to have ended playback when the element's |
2911 // readyState attribute is HAVE_METADATA or greater, | 2945 // readyState attribute is HAVE_METADATA or greater, |
2912 if (m_readyState < HAVE_METADATA) | 2946 if (m_readyState < HAVE_METADATA) |
2913 return false; | 2947 return false; |
2914 | 2948 |
2915 // and the current playback position is the end of the media resource and th
e direction | 2949 // and the current playback position is the end of the media resource and th
e direction |
(...skipping 15 matching lines...) Expand all Loading... |
2931 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 2965 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
2932 if (!seekableRanges->contain(currentTime())) | 2966 if (!seekableRanges->contain(currentTime())) |
2933 return true; | 2967 return true; |
2934 } | 2968 } |
2935 | 2969 |
2936 return false; | 2970 return false; |
2937 } | 2971 } |
2938 | 2972 |
2939 void HTMLMediaElement::updatePlayState() | 2973 void HTMLMediaElement::updatePlayState() |
2940 { | 2974 { |
2941 if (!m_player) | |
2942 return; | |
2943 | |
2944 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | 2975 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
2945 bool shouldBePlaying = potentiallyPlaying(); | 2976 bool shouldBePlaying = potentiallyPlaying(); |
2946 | 2977 |
2947 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", | 2978 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", |
2948 this, boolString(shouldBePlaying), boolString(isPlaying)); | 2979 this, boolString(shouldBePlaying), boolString(isPlaying)); |
2949 | 2980 |
2950 if (shouldBePlaying) { | 2981 if (shouldBePlaying) { |
2951 setDisplayMode(Video); | 2982 setDisplayMode(Video); |
2952 invalidateCachedTime(); | 2983 invalidateCachedTime(); |
2953 | 2984 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 } else { | 3055 } else { |
3025 m_networkState = NETWORK_IDLE; | 3056 m_networkState = NETWORK_IDLE; |
3026 } | 3057 } |
3027 | 3058 |
3028 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 3059 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
3029 setShouldDelayLoadEvent(false); | 3060 setShouldDelayLoadEvent(false); |
3030 | 3061 |
3031 // 6 - Abort the overall resource selection algorithm. | 3062 // 6 - Abort the overall resource selection algorithm. |
3032 m_currentSourceNode = nullptr; | 3063 m_currentSourceNode = nullptr; |
3033 | 3064 |
3034 // Reset m_readyState since m_player is gone. | 3065 // Reset m_readyState since m_webMediaPlayer is gone. |
3035 m_readyState = HAVE_NOTHING; | 3066 m_readyState = HAVE_NOTHING; |
3036 invalidateCachedTime(); | 3067 invalidateCachedTime(); |
3037 updateMediaController(); | 3068 updateMediaController(); |
3038 cueTimeline().updateActiveCues(0); | 3069 cueTimeline().updateActiveCues(0); |
3039 } | 3070 } |
3040 | 3071 |
3041 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin
g() | 3072 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin
g() |
3042 { | 3073 { |
3043 #if ENABLE(WEB_AUDIO) | 3074 #if ENABLE(WEB_AUDIO) |
3044 if (audioSourceProvider()) | 3075 if (audioSourceProvider()) |
3045 audioSourceProvider()->setClient(0); | 3076 audioSourceProvider()->setClient(nullptr); |
3046 #endif | 3077 #endif |
3047 m_player.clear(); | 3078 if (m_webMediaPlayer) { |
| 3079 m_audioSourceProvider.wrap(nullptr); |
| 3080 m_webMediaPlayer.clear(); |
| 3081 } |
3048 } | 3082 } |
3049 | 3083 |
3050 void HTMLMediaElement::clearMediaPlayer(int flags) | 3084 void HTMLMediaElement::clearMediaPlayer(int flags) |
3051 { | 3085 { |
3052 forgetResourceSpecificTracks(); | 3086 forgetResourceSpecificTracks(); |
3053 | 3087 |
3054 closeMediaSource(); | 3088 closeMediaSource(); |
3055 | 3089 |
3056 cancelDeferredLoad(); | 3090 cancelDeferredLoad(); |
3057 | 3091 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 // the user agent should run the rules for updating the text track rendering | 3296 // the user agent should run the rules for updating the text track rendering |
3263 // of each of the text tracks in the video element's list of text tracks ... | 3297 // of each of the text tracks in the video element's list of text tracks ... |
3264 if (isHTMLVideoElement() && closedCaptionsVisible()) | 3298 if (isHTMLVideoElement() && closedCaptionsVisible()) |
3265 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); | 3299 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS
tartExposingControls); |
3266 } | 3300 } |
3267 | 3301 |
3268 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) | 3302 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) |
3269 { | 3303 { |
3270 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b
oolString(closedCaptionVisible)); | 3304 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b
oolString(closedCaptionVisible)); |
3271 | 3305 |
3272 if (!m_player || !hasClosedCaptions()) | 3306 if (!hasClosedCaptions()) |
3273 return; | 3307 return; |
3274 | 3308 |
3275 m_closedCaptionsVisible = closedCaptionVisible; | 3309 m_closedCaptionsVisible = closedCaptionVisible; |
3276 | 3310 |
3277 markCaptionAndSubtitleTracksAsUnconfigured(); | 3311 markCaptionAndSubtitleTracksAsUnconfigured(); |
3278 m_processingPreferenceChange = true; | 3312 m_processingPreferenceChange = true; |
3279 honorUserPreferencesForAutomaticTextTrackSelection(); | 3313 honorUserPreferencesForAutomaticTextTrackSelection(); |
3280 m_processingPreferenceChange = false; | 3314 m_processingPreferenceChange = false; |
3281 | 3315 |
3282 // As track visibility changed while m_processingPreferenceChange was set, | 3316 // As track visibility changed while m_processingPreferenceChange was set, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 } | 3490 } |
3457 | 3491 |
3458 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3492 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
3459 { | 3493 { |
3460 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3494 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
3461 configureMediaControls(); | 3495 configureMediaControls(); |
3462 | 3496 |
3463 return nullptr; | 3497 return nullptr; |
3464 } | 3498 } |
3465 | 3499 |
3466 void HTMLMediaElement::createMediaPlayer() | 3500 // TODO(srirama.m): Refactor this and other relevant methods and have a |
| 3501 // single method for clearing the mediaplayer and its stuff. |
| 3502 void HTMLMediaElement::resetMediaPlayerAndMediaSource() |
3467 { | 3503 { |
3468 AudioSourceProviderClientLockScope scope(*this); | 3504 AudioSourceProviderClientLockScope scope(*this); |
3469 | 3505 |
3470 closeMediaSource(); | 3506 closeMediaSource(); |
3471 | 3507 |
3472 m_player = MediaPlayer::create(this); | 3508 if (m_webMediaPlayer) { |
| 3509 m_audioSourceProvider.wrap(nullptr); |
| 3510 m_webMediaPlayer.clear(); |
| 3511 } |
3473 | 3512 |
3474 // We haven't yet found out if any remote routes are available. | 3513 // We haven't yet found out if any remote routes are available. |
3475 m_remoteRoutesAvailable = false; | 3514 m_remoteRoutesAvailable = false; |
3476 m_playingRemotely = false; | 3515 m_playingRemotely = false; |
3477 | 3516 |
3478 #if ENABLE(WEB_AUDIO) | 3517 #if ENABLE(WEB_AUDIO) |
3479 if (m_audioSourceNode && audioSourceProvider()) { | 3518 if (m_audioSourceNode) |
3480 // When creating the player, make sure its AudioSourceProvider knows abo
ut the client. | |
3481 audioSourceProvider()->setClient(m_audioSourceNode); | 3519 audioSourceProvider()->setClient(m_audioSourceNode); |
3482 } | |
3483 #endif | 3520 #endif |
3484 } | 3521 } |
3485 | 3522 |
3486 #if ENABLE(WEB_AUDIO) | 3523 #if ENABLE(WEB_AUDIO) |
3487 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3524 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
3488 { | 3525 { |
3489 ASSERT(isMainThread()); | 3526 ASSERT(isMainThread()); |
3490 m_audioSourceNode = sourceNode; | 3527 m_audioSourceNode = sourceNode; |
3491 | 3528 |
3492 AudioSourceProviderClientLockScope scope(*this); | 3529 AudioSourceProviderClientLockScope scope(*this); |
3493 if (audioSourceProvider()) | 3530 if (audioSourceProvider()) |
3494 audioSourceProvider()->setClient(m_audioSourceNode); | 3531 audioSourceProvider()->setClient(m_audioSourceNode); |
3495 } | 3532 } |
3496 | |
3497 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() | |
3498 { | |
3499 if (m_player) | |
3500 return m_player->audioSourceProvider(); | |
3501 | |
3502 return nullptr; | |
3503 } | |
3504 #endif | 3533 #endif |
3505 | 3534 |
3506 const AtomicString& HTMLMediaElement::mediaGroup() const | 3535 const AtomicString& HTMLMediaElement::mediaGroup() const |
3507 { | 3536 { |
3508 return fastGetAttribute(mediagroupAttr); | 3537 return fastGetAttribute(mediagroupAttr); |
3509 } | 3538 } |
3510 | 3539 |
3511 void HTMLMediaElement::setMediaGroup(const AtomicString& group) | 3540 void HTMLMediaElement::setMediaGroup(const AtomicString& group) |
3512 { | 3541 { |
3513 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup | 3542 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const | 3634 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
3606 { | 3635 { |
3607 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3636 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
3608 if (crossOriginMode.isNull()) | 3637 if (crossOriginMode.isNull()) |
3609 return WebMediaPlayer::CORSModeUnspecified; | 3638 return WebMediaPlayer::CORSModeUnspecified; |
3610 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3639 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
3611 return WebMediaPlayer::CORSModeUseCredentials; | 3640 return WebMediaPlayer::CORSModeUseCredentials; |
3612 return WebMediaPlayer::CORSModeAnonymous; | 3641 return WebMediaPlayer::CORSModeAnonymous; |
3613 } | 3642 } |
3614 | 3643 |
3615 void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) | 3644 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer) |
3616 { | 3645 { |
3617 if (webLayer == m_webLayer) | 3646 if (webLayer == m_webLayer) |
3618 return; | 3647 return; |
3619 | 3648 |
3620 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. | 3649 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. |
3621 if ((!m_webLayer || !webLayer) | 3650 if ((!m_webLayer || !webLayer) |
3622 #if ENABLE(OILPAN) | 3651 #if ENABLE(OILPAN) |
3623 && !m_isFinalizing | 3652 && !m_isFinalizing |
3624 #endif | 3653 #endif |
3625 ) | 3654 ) |
3626 setNeedsCompositingUpdate(); | 3655 setNeedsCompositingUpdate(); |
3627 | 3656 |
3628 if (m_webLayer) | 3657 if (m_webLayer) |
3629 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 3658 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
3630 m_webLayer = webLayer; | 3659 m_webLayer = webLayer; |
3631 if (m_webLayer) | 3660 if (m_webLayer) |
3632 GraphicsLayer::registerContentsLayer(m_webLayer); | 3661 GraphicsLayer::registerContentsLayer(m_webLayer); |
3633 } | 3662 } |
3634 | 3663 |
3635 void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSour
ce) | 3664 void HTMLMediaElement::mediaSourceOpened(WebMediaSource* webMediaSource) |
3636 { | 3665 { |
3637 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3666 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3638 } | 3667 } |
3639 | 3668 |
3640 bool HTMLMediaElement::isInteractiveContent() const | 3669 bool HTMLMediaElement::isInteractiveContent() const |
3641 { | 3670 { |
3642 return fastHasAttribute(controlsAttr); | 3671 return fastHasAttribute(controlsAttr); |
3643 } | 3672 } |
3644 | 3673 |
3645 void HTMLMediaElement::defaultEventHandler(Event* event) | 3674 void HTMLMediaElement::defaultEventHandler(Event* event) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3702 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3731 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
3703 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3732 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
3704 } | 3733 } |
3705 | 3734 |
3706 #if ENABLE(WEB_AUDIO) | 3735 #if ENABLE(WEB_AUDIO) |
3707 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3736 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3708 { | 3737 { |
3709 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) | 3738 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) |
3710 audioSourceProvider()->setClient(nullptr); | 3739 audioSourceProvider()->setClient(nullptr); |
3711 } | 3740 } |
| 3741 |
| 3742 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro
vider) |
| 3743 { |
| 3744 MutexLocker locker(provideInputLock); |
| 3745 |
| 3746 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) |
| 3747 m_webAudioSourceProvider->setClient(nullptr); |
| 3748 |
| 3749 m_webAudioSourceProvider = provider; |
| 3750 if (m_webAudioSourceProvider) |
| 3751 m_webAudioSourceProvider->setClient(m_client.get()); |
| 3752 } |
| 3753 |
| 3754 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli
ent* client) |
| 3755 { |
| 3756 MutexLocker locker(provideInputLock); |
| 3757 |
| 3758 if (client) |
| 3759 m_client = new HTMLMediaElement::AudioClientImpl(client); |
| 3760 else |
| 3761 m_client.clear(); |
| 3762 |
| 3763 if (m_webAudioSourceProvider) |
| 3764 m_webAudioSourceProvider->setClient(m_client.get()); |
| 3765 } |
| 3766 |
| 3767 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(AudioBus* bus, size
_t framesToProcess) |
| 3768 { |
| 3769 // TODO(srirama.m): Investigate whether the bus can be null or not |
| 3770 // and remove either ASSERT or null check appropriately. |
| 3771 ASSERT(bus); |
| 3772 if (!bus) |
| 3773 return; |
| 3774 |
| 3775 MutexTryLocker tryLocker(provideInputLock); |
| 3776 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { |
| 3777 bus->zero(); |
| 3778 return; |
| 3779 } |
| 3780 |
| 3781 // Wrap the AudioBus channel data using WebVector. |
| 3782 size_t n = bus->numberOfChannels(); |
| 3783 WebVector<float*> webAudioData(n); |
| 3784 for (size_t i = 0; i < n; ++i) |
| 3785 webAudioData[i] = bus->channel(i)->mutableData(); |
| 3786 |
| 3787 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); |
| 3788 } |
| 3789 |
| 3790 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float
sampleRate) |
| 3791 { |
| 3792 if (m_client) |
| 3793 m_client->setFormat(numberOfChannels, sampleRate); |
| 3794 } |
| 3795 |
| 3796 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) |
| 3797 { |
| 3798 visitor->trace(m_client); |
| 3799 } |
3712 #endif | 3800 #endif |
3713 | 3801 |
3714 } | 3802 } |
OLD | NEW |