Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
| 42 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
| 43 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
| 44 #include "core/frame/csp/ContentSecurityPolicy.h" | 44 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 45 #include "core/html/HTMLMediaSource.h" | 45 #include "core/html/HTMLMediaSource.h" |
| 46 #include "core/html/HTMLSourceElement.h" | 46 #include "core/html/HTMLSourceElement.h" |
| 47 #include "core/html/HTMLTrackElement.h" | 47 #include "core/html/HTMLTrackElement.h" |
| 48 #include "core/html/MediaController.h" | 48 #include "core/html/MediaController.h" |
| 49 #include "core/html/MediaError.h" | 49 #include "core/html/MediaError.h" |
| 50 #include "core/html/MediaFragmentURIParser.h" | 50 #include "core/html/MediaFragmentURIParser.h" |
| 51 #include "core/html/MediaProvider.h" | |
| 51 #include "core/html/TimeRanges.h" | 52 #include "core/html/TimeRanges.h" |
| 52 #include "core/html/shadow/MediaControls.h" | 53 #include "core/html/shadow/MediaControls.h" |
| 53 #include "core/html/track/AudioTrack.h" | 54 #include "core/html/track/AudioTrack.h" |
| 54 #include "core/html/track/AudioTrackList.h" | 55 #include "core/html/track/AudioTrackList.h" |
| 55 #include "core/html/track/InbandTextTrack.h" | 56 #include "core/html/track/InbandTextTrack.h" |
| 56 #include "core/html/track/TextTrackCueList.h" | 57 #include "core/html/track/TextTrackCueList.h" |
| 57 #include "core/html/track/TextTrackList.h" | 58 #include "core/html/track/TextTrackList.h" |
| 58 #include "core/html/track/VideoTrack.h" | 59 #include "core/html/track/VideoTrack.h" |
| 59 #include "core/html/track/VideoTrackList.h" | 60 #include "core/html/track/VideoTrackList.h" |
| 60 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 , m_networkState(NETWORK_EMPTY) | 319 , m_networkState(NETWORK_EMPTY) |
| 319 , m_readyState(HAVE_NOTHING) | 320 , m_readyState(HAVE_NOTHING) |
| 320 , m_readyStateMaximum(HAVE_NOTHING) | 321 , m_readyStateMaximum(HAVE_NOTHING) |
| 321 , m_volume(1.0f) | 322 , m_volume(1.0f) |
| 322 , m_lastSeekTime(0) | 323 , m_lastSeekTime(0) |
| 323 , m_previousProgressTime(std::numeric_limits<double>::max()) | 324 , m_previousProgressTime(std::numeric_limits<double>::max()) |
| 324 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 325 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
| 325 , m_lastTimeUpdateEventWallTime(0) | 326 , m_lastTimeUpdateEventWallTime(0) |
| 326 , m_defaultPlaybackStartPosition(0) | 327 , m_defaultPlaybackStartPosition(0) |
| 327 , m_loadState(WaitingForSource) | 328 , m_loadState(WaitingForSource) |
| 329 , m_srcObject(std::nullptr_t()) | |
| 328 , m_deferredLoadState(NotDeferred) | 330 , m_deferredLoadState(NotDeferred) |
| 329 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 331 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
| 330 , m_webLayer(0) | 332 , m_webLayer(0) |
| 331 , m_preload(MediaPlayer::Auto) | 333 , m_preload(MediaPlayer::Auto) |
| 332 , m_displayMode(Unknown) | 334 , m_displayMode(Unknown) |
| 333 , m_cachedTime(MediaPlayer::invalidTime()) | 335 , m_cachedTime(MediaPlayer::invalidTime()) |
| 334 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 336 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
| 335 , m_fragmentEndTime(MediaPlayer::invalidTime()) | 337 , m_fragmentEndTime(MediaPlayer::invalidTime()) |
| 336 , m_pendingActionFlags(0) | 338 , m_pendingActionFlags(0) |
| 337 , m_userGestureRequiredForPlay(false) | 339 , m_userGestureRequiredForPlay(false) |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 } | 674 } |
| 673 | 675 |
| 674 m_pendingActionFlags = 0; | 676 m_pendingActionFlags = 0; |
| 675 } | 677 } |
| 676 | 678 |
| 677 PassRefPtrWillBeRawPtr<MediaError> HTMLMediaElement::error() const | 679 PassRefPtrWillBeRawPtr<MediaError> HTMLMediaElement::error() const |
| 678 { | 680 { |
| 679 return m_error; | 681 return m_error; |
| 680 } | 682 } |
| 681 | 683 |
| 684 void HTMLMediaElement::setSrcObject(RawPtr<MediaProvider> mediaProvider) | |
| 685 { | |
| 686 WTF_LOG(Media, "HTMLMediaElement::setSrcObject()"); | |
| 687 m_srcObject = mediaProvider; | |
| 688 clearMediaPlayer(LoadMediaResource); | |
| 689 scheduleDelayedAction(LoadMediaResource); | |
| 690 } | |
| 691 | |
| 692 MediaProvider* HTMLMediaElement::srcObject() const | |
| 693 { | |
| 694 return m_srcObject.get(); | |
| 695 } | |
| 696 | |
| 682 void HTMLMediaElement::setSrc(const AtomicString& url) | 697 void HTMLMediaElement::setSrc(const AtomicString& url) |
| 683 { | 698 { |
| 684 setAttribute(srcAttr, url); | 699 setAttribute(srcAttr, url); |
| 685 } | 700 } |
| 686 | 701 |
| 687 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const | 702 HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const |
| 688 { | 703 { |
| 689 return m_networkState; | 704 return m_networkState; |
| 690 } | 705 } |
| 691 | 706 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 } | 858 } |
| 844 } | 859 } |
| 845 | 860 |
| 846 selectMediaResource(); | 861 selectMediaResource(); |
| 847 } | 862 } |
| 848 | 863 |
| 849 void HTMLMediaElement::selectMediaResource() | 864 void HTMLMediaElement::selectMediaResource() |
| 850 { | 865 { |
| 851 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); | 866 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); |
| 852 | 867 |
| 853 enum Mode { attribute, children }; | 868 enum Mode {Object, Attribute, Children}; |
|
philipj_slow
2014/09/17 09:25:39
Please keep the whitespace after/before {/}, all t
perkj_chrome
2014/09/17 19:26:14
Done.
| |
| 854 | 869 |
| 855 // 3 - If the media element has a src attribute, then let mode be attribute. | 870 // 3 - Decide which source to load. |
| 856 Mode mode = attribute; | 871 // If the media element has a srcObject let the mode be object. |
| 857 if (!fastHasAttribute(srcAttr)) { | 872 // If it has a src attribute, let the mode be attribute. |
| 858 // Otherwise, if the media element does not have a src attribute but has a source | 873 // If it has a source element, let the mode be Children. |
| 859 // element child, then let mode be children and let candidate be the fir st such | 874 Mode mode = Object; |
| 860 // source element child in tree order. | 875 if (srcObject()) { |
| 861 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil d(*this)) { | 876 mode = Object; |
| 862 mode = children; | 877 } else if (fastHasAttribute(srcAttr)) { |
| 863 m_nextChildNodeToConsider = element; | 878 mode = Attribute; |
| 864 m_currentSourceNode = nullptr; | 879 } else if (Traversal<HTMLSourceElement>::firstChild(*this)) { |
| 865 } else { | 880 mode = Children; |
| 866 // Otherwise the media element has neither a src attribute nor a sou rce element | 881 HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChild(*t his); |
| 867 // child: set the networkState to NETWORK_EMPTY, and abort these ste ps; the | 882 m_nextChildNodeToConsider = element; |
| 868 // synchronous section ends. | 883 m_currentSourceNode = nullptr; |
| 869 m_loadState = WaitingForSource; | 884 } else { |
| 870 setShouldDelayLoadEvent(false); | 885 // Otherwise the media element has no source. |
| 871 m_networkState = NETWORK_EMPTY; | 886 // set the networkState to NETWORK_EMPTY, and abort these steps; the |
| 887 // synchronous section ends. | |
| 888 m_loadState = WaitingForSource; | |
| 889 setShouldDelayLoadEvent(false); | |
| 890 m_networkState = NETWORK_EMPTY; | |
| 872 | 891 |
| 873 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t o load", this); | 892 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to lo ad", this); |
| 874 return; | 893 return; |
| 875 } | |
| 876 } | 894 } |
| 877 | 895 |
| 878 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event), | 896 // 4 - Set the media element's delaying-the-load-event flag to true (this de lays the load event), |
| 879 // and set its networkState to NETWORK_LOADING. | 897 // and set its networkState to NETWORK_LOADING. |
| 880 setShouldDelayLoadEvent(true); | 898 setShouldDelayLoadEvent(true); |
| 881 m_networkState = NETWORK_LOADING; | 899 m_networkState = NETWORK_LOADING; |
| 882 | 900 |
| 883 // 5 - Queue a task to fire a simple event named loadstart at the media elem ent. | 901 // 5 - Queue a task to fire a simple event named loadstart at the media elem ent. |
| 884 scheduleEvent(EventTypeNames::loadstart); | 902 scheduleEvent(EventTypeNames::loadstart); |
| 885 | 903 |
| 886 // 6 - If mode is attribute, then run these substeps | 904 // 6 - Load the correct source. |
| 887 if (mode == attribute) { | 905 switch (mode) { |
| 888 m_loadState = LoadingFromSrcAttr; | 906 case Object: |
| 907 loadSourceFromObject(); | |
| 908 break; | |
| 909 case Attribute: | |
| 910 loadSourceFromAttribute(); | |
| 911 break; | |
| 912 case Children: | |
| 913 loadNextSourceChild(); | |
| 914 break; | |
| 915 } | |
| 916 } | |
| 889 | 917 |
| 890 // If the src attribute's value is the empty string ... jump down to the failed step below | 918 void HTMLMediaElement::loadSourceFromObject() |
| 891 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); | 919 { |
| 892 if (mediaURL.isEmpty()) { | 920 m_loadState = LoadingFromSrcObject; |
| 893 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 894 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'sr c'", this); | |
| 895 return; | |
| 896 } | |
| 897 | 921 |
| 898 if (!isSafeToLoadURL(mediaURL, Complain)) { | 922 KURL mediaURL = document().completeURL(m_srcObject->getObjectUrl()); |
| 899 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 900 return; | |
| 901 } | |
| 902 | 923 |
| 903 // No type or key system information is available when the url comes | 924 if (!isSafeToLoadURL(mediaURL, Complain)) { |
| 904 // from the 'src' attribute so MediaPlayer | 925 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 905 // will have to pick a media engine based on the file extension. | |
| 906 ContentType contentType((String())); | |
| 907 loadResource(mediaURL, contentType, String()); | |
| 908 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' a ttribute url", this); | |
| 909 return; | 926 return; |
| 910 } | 927 } |
| 911 | 928 |
| 912 // Otherwise, the source elements will be used | 929 // No type or key system information is available when the url comes |
| 913 loadNextSourceChild(); | 930 // from the 'srcObject' so MediaPlayer |
| 931 // will have to pick a media engine based on the file extension. | |
| 932 ContentType contentType((String())); | |
| 933 loadResource(mediaURL, contentType, String()); | |
| 934 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource, using 'srcObject' att ribute."); | |
| 935 return; | |
| 936 } | |
| 937 | |
| 938 void HTMLMediaElement::loadSourceFromAttribute() | |
| 939 { | |
| 940 m_loadState = LoadingFromSrcAttr; | |
| 941 | |
| 942 // If the src attribute's value is the empty string ... jump down to the fai led step below | |
| 943 KURL mediaURL = getNonEmptyURLAttribute(srcAttr); | |
| 944 if (mediaURL.isEmpty()) { | |
| 945 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 946 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'src'", this); | |
| 947 return; | |
| 948 } | |
| 949 | |
| 950 if (!isSafeToLoadURL(mediaURL, Complain)) { | |
| 951 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 952 return; | |
| 953 } | |
| 954 | |
| 955 // No type or key system information is available when the url comes | |
| 956 // from the 'src' attribute so MediaPlayer | |
| 957 // will have to pick a media engine based on the file extension. | |
| 958 ContentType contentType((String())); | |
| 959 loadResource(mediaURL, contentType, String()); | |
| 960 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' attri bute url", this); | |
| 961 return; | |
| 914 } | 962 } |
| 915 | 963 |
| 916 void HTMLMediaElement::loadNextSourceChild() | 964 void HTMLMediaElement::loadNextSourceChild() |
| 917 { | 965 { |
| 918 ContentType contentType((String())); | 966 ContentType contentType((String())); |
| 919 String keySystem; | 967 String keySystem; |
| 920 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); | 968 KURL mediaURL = selectNextSourceChild(&contentType, &keySystem, Complain); |
| 921 if (!mediaURL.isValid()) { | 969 if (!mediaURL.isValid()) { |
| 922 waitForSourceChange(); | 970 waitForSourceChange(); |
| 923 return; | 971 return; |
| (...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3976 | 4024 |
| 3977 #if ENABLE(WEB_AUDIO) | 4025 #if ENABLE(WEB_AUDIO) |
| 3978 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4026 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3979 { | 4027 { |
| 3980 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4028 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3981 audioSourceProvider()->setClient(0); | 4029 audioSourceProvider()->setClient(0); |
| 3982 } | 4030 } |
| 3983 #endif | 4031 #endif |
| 3984 | 4032 |
| 3985 } | 4033 } |
| OLD | NEW |