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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "platform/RuntimeEnabledFeatures.h" | 76 #include "platform/RuntimeEnabledFeatures.h" |
77 #include "platform/UserGestureIndicator.h" | 77 #include "platform/UserGestureIndicator.h" |
78 #include "platform/audio/AudioBus.h" | 78 #include "platform/audio/AudioBus.h" |
79 #include "platform/audio/AudioSourceProviderClient.h" | 79 #include "platform/audio/AudioSourceProviderClient.h" |
80 #include "platform/graphics/GraphicsLayer.h" | 80 #include "platform/graphics/GraphicsLayer.h" |
81 #include "platform/weborigin/SecurityOrigin.h" | 81 #include "platform/weborigin/SecurityOrigin.h" |
82 #include "public/platform/Platform.h" | 82 #include "public/platform/Platform.h" |
83 #include "public/platform/WebAudioSourceProvider.h" | 83 #include "public/platform/WebAudioSourceProvider.h" |
84 #include "public/platform/WebContentDecryptionModule.h" | 84 #include "public/platform/WebContentDecryptionModule.h" |
85 #include "public/platform/WebInbandTextTrack.h" | 85 #include "public/platform/WebInbandTextTrack.h" |
| 86 #include "public/platform/WebMediaStream.h" |
86 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 87 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
87 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" | 88 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
88 #include "wtf/CurrentTime.h" | 89 #include "wtf/CurrentTime.h" |
89 #include "wtf/MathExtras.h" | 90 #include "wtf/MathExtras.h" |
90 #include "wtf/text/CString.h" | 91 #include "wtf/text/CString.h" |
91 #include <limits> | 92 #include <limits> |
92 | 93 |
93 #ifndef LOG_MEDIA_EVENTS | 94 #ifndef LOG_MEDIA_EVENTS |
94 // Default to not logging events because so many are generated they can overwhel
m the rest of | 95 // Default to not logging events because so many are generated they can overwhel
m the rest of |
95 // the logging. | 96 // the logging. |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 return new LayoutMedia(this); | 625 return new LayoutMedia(this); |
625 } | 626 } |
626 | 627 |
627 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode*
insertionPoint) | 628 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode*
insertionPoint) |
628 { | 629 { |
629 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin
t); | 630 WTF_LOG(Media, "HTMLMediaElement::insertedInto(%p, %p)", this, insertionPoin
t); |
630 | 631 |
631 HTMLElement::insertedInto(insertionPoint); | 632 HTMLElement::insertedInto(insertionPoint); |
632 if (insertionPoint->inDocument()) { | 633 if (insertionPoint->inDocument()) { |
633 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); | 634 UseCounter::count(document(), UseCounter::HTMLMediaElementInDocument); |
634 if (!getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY)
{ | 635 if ((!getAttribute(srcAttr).isEmpty() || m_srcObject.isMediaProviderObje
ct()) && m_networkState == NETWORK_EMPTY) { |
635 m_ignorePreloadNone = false; | 636 m_ignorePreloadNone = false; |
636 invokeLoadAlgorithm(); | 637 invokeLoadAlgorithm(); |
637 } | 638 } |
638 } | 639 } |
639 | 640 |
640 return InsertionShouldCallDidNotifySubtreeInsertions; | 641 return InsertionShouldCallDidNotifySubtreeInsertions; |
641 } | 642 } |
642 | 643 |
643 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() | 644 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() |
644 { | 645 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 MediaError* HTMLMediaElement::error() const | 720 MediaError* HTMLMediaElement::error() const |
720 { | 721 { |
721 return m_error; | 722 return m_error; |
722 } | 723 } |
723 | 724 |
724 void HTMLMediaElement::setSrc(const AtomicString& url) | 725 void HTMLMediaElement::setSrc(const AtomicString& url) |
725 { | 726 { |
726 setAttribute(srcAttr, url); | 727 setAttribute(srcAttr, url); |
727 } | 728 } |
728 | 729 |
| 730 void HTMLMediaElement::setSrcObject(const WebMediaPlayerSource& srcObject) |
| 731 { |
| 732 // srcObject can be a media-provider object or null. |
| 733 ASSERT(!srcObject.isURL()); |
| 734 |
| 735 // The srcObject IDL attribute, on setting, must set the element's assigned |
| 736 // media provider object to the new value, and then invoke the element's |
| 737 // media element load algorithm. |
| 738 m_srcObject = srcObject; |
| 739 invokeLoadAlgorithm(); |
| 740 } |
| 741 |
729 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const | 742 HTMLMediaElement::NetworkState HTMLMediaElement::getNetworkState() const |
730 { | 743 { |
731 return m_networkState; | 744 return m_networkState; |
732 } | 745 } |
733 | 746 |
734 String HTMLMediaElement::canPlayType(const String& mimeType) const | 747 String HTMLMediaElement::canPlayType(const String& mimeType) const |
735 { | 748 { |
736 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType)); | 749 WebMimeRegistry::SupportsType support = supportsType(ContentType(mimeType)); |
737 String canPlay; | 750 String canPlay; |
738 | 751 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 } | 910 } |
898 } | 911 } |
899 | 912 |
900 selectMediaResource(); | 913 selectMediaResource(); |
901 } | 914 } |
902 | 915 |
903 void HTMLMediaElement::selectMediaResource() | 916 void HTMLMediaElement::selectMediaResource() |
904 { | 917 { |
905 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); | 918 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p)", this); |
906 | 919 |
907 enum Mode { attribute, children }; | 920 enum Mode { Object, Attribute, Children, Nothing }; |
| 921 Mode mode = Nothing; |
908 | 922 |
909 // 3 - If the media element has a src attribute, then let mode be attribute. | 923 // 6 - If the media element has an assigned media provider object, then let |
910 Mode mode = attribute; | 924 // mode be object. |
911 if (!fastHasAttribute(srcAttr)) { | 925 if (m_srcObject.isMediaProviderObject()) { |
912 // Otherwise, if the media element does not have a src attribute but has
a source | 926 mode = Object; |
913 // element child, then let mode be children and let candidate be the fir
st such | 927 } else if (fastHasAttribute(srcAttr)) { |
914 // source element child in tree order. | 928 // Otherwise, if the media element has no assigned media provider object |
915 if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstChil
d(*this)) { | 929 // but has a src attribute, then let mode be attribute. |
916 mode = children; | 930 mode = Attribute; |
917 m_nextChildNodeToConsider = element; | 931 } else if (HTMLSourceElement* element = Traversal<HTMLSourceElement>::firstC
hild(*this)) { |
918 m_currentSourceNode = nullptr; | 932 // Otherwise, if the media element does not have an assigned media |
919 } else { | 933 // provider object and does not have a src attribute, but does have a |
920 // Otherwise the media element has neither a src attribute nor a sou
rce element | 934 // source element child, then let mode be children and let candidate be |
921 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the | 935 // the first such source element child in tree order. |
922 // synchronous section ends. | 936 mode = Children; |
923 m_loadState = WaitingForSource; | 937 m_nextChildNodeToConsider = element; |
924 setShouldDelayLoadEvent(false); | 938 m_currentSourceNode = nullptr; |
925 setNetworkState(NETWORK_EMPTY); | 939 } else { |
926 updateDisplayState(); | 940 // Otherwise the media element has no assigned media provider object and |
| 941 // has neither a src attribute nor a source element child: set the |
| 942 // networkState to NETWORK_EMPTY, and abort these steps; the synchronous |
| 943 // section ends. |
| 944 m_loadState = WaitingForSource; |
| 945 setShouldDelayLoadEvent(false); |
| 946 setNetworkState(NETWORK_EMPTY); |
| 947 updateDisplayState(); |
927 | 948 |
928 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t
o load", this); | 949 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing to lo
ad", this); |
929 return; | |
930 } | |
931 } | |
932 | |
933 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), | |
934 // and set its networkState to NETWORK_LOADING. | |
935 setShouldDelayLoadEvent(true); | |
936 setNetworkState(NETWORK_LOADING); | |
937 | |
938 // 5 - Queue a task to fire a simple event named loadstart at the media elem
ent. | |
939 scheduleEvent(EventTypeNames::loadstart); | |
940 | |
941 // 6 - If mode is attribute, then run these substeps | |
942 if (mode == attribute) { | |
943 m_loadState = LoadingFromSrcAttr; | |
944 | |
945 const AtomicString& srcValue = fastGetAttribute(srcAttr); | |
946 // If the src attribute's value is the empty string ... jump down to the
failed step below | |
947 if (srcValue.isEmpty()) { | |
948 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
949 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'sr
c'", this); | |
950 return; | |
951 } | |
952 | |
953 KURL mediaURL = document().completeURL(srcValue); | |
954 if (!isSafeToLoadURL(mediaURL, Complain)) { | |
955 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
956 return; | |
957 } | |
958 | |
959 // No type is available when the url comes from the 'src' attribute so M
ediaPlayer | |
960 // will have to pick a media engine based on the file extension. | |
961 ContentType contentType((String())); | |
962 loadResource(mediaURL, contentType); | |
963 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' a
ttribute url", this); | |
964 return; | 950 return; |
965 } | 951 } |
966 | 952 |
967 // Otherwise, the source elements will be used | 953 // 7 - Set the media element's networkState to NETWORK_LOADING. |
968 loadNextSourceChild(); | 954 setNetworkState(NETWORK_LOADING); |
| 955 |
| 956 // 8 - Queue a task to fire a simple event named loadstart at the media elem
ent. |
| 957 scheduleEvent(EventTypeNames::loadstart); |
| 958 |
| 959 // 9 - Run the appropriate steps... |
| 960 switch (mode) { |
| 961 case Object: |
| 962 loadSourceFromObject(); |
| 963 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'srcObj
ect' attribute", this); |
| 964 break; |
| 965 case Attribute: |
| 966 loadSourceFromAttribute(); |
| 967 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using 'src' a
ttribute url", this); |
| 968 break; |
| 969 case Children: |
| 970 loadNextSourceChild(); |
| 971 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), using source
element", this); |
| 972 break; |
| 973 default: |
| 974 ASSERT_NOT_REACHED(); |
| 975 } |
| 976 } |
| 977 |
| 978 void HTMLMediaElement::loadSourceFromObject() |
| 979 { |
| 980 ASSERT(m_srcObject.isMediaProviderObject()); |
| 981 m_loadState = LoadingFromSrcObject; |
| 982 |
| 983 // No type is available when the resource comes from the 'srcObject' |
| 984 // attribute. |
| 985 ContentType contentType((String())); |
| 986 loadResource(m_srcObject, contentType); |
| 987 } |
| 988 |
| 989 void HTMLMediaElement::loadSourceFromAttribute() |
| 990 { |
| 991 m_loadState = LoadingFromSrcAttr; |
| 992 const AtomicString& srcValue = fastGetAttribute(srcAttr); |
| 993 |
| 994 // If the src attribute's value is the empty string ... jump down to the fai
led step below |
| 995 if (srcValue.isEmpty()) { |
| 996 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 997 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), empty 'src'",
this); |
| 998 return; |
| 999 } |
| 1000 |
| 1001 KURL mediaURL = document().completeURL(srcValue); |
| 1002 if (!isSafeToLoadURL(mediaURL, Complain)) { |
| 1003 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1004 return; |
| 1005 } |
| 1006 |
| 1007 // No type is available when the url comes from the 'src' attribute so |
| 1008 // MediaPlayer will have to pick a media engine based on the file extension. |
| 1009 ContentType contentType((String())); |
| 1010 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); |
969 } | 1011 } |
970 | 1012 |
971 void HTMLMediaElement::loadNextSourceChild() | 1013 void HTMLMediaElement::loadNextSourceChild() |
972 { | 1014 { |
973 ContentType contentType((String())); | 1015 ContentType contentType((String())); |
974 KURL mediaURL = selectNextSourceChild(&contentType, Complain); | 1016 KURL mediaURL = selectNextSourceChild(&contentType, Complain); |
975 if (!mediaURL.isValid()) { | 1017 if (!mediaURL.isValid()) { |
976 waitForSourceChange(); | 1018 waitForSourceChange(); |
977 return; | 1019 return; |
978 } | 1020 } |
979 | 1021 |
980 // Reset the MediaPlayer and MediaSource if any | 1022 // Reset the MediaPlayer and MediaSource if any |
981 resetMediaPlayerAndMediaSource(); | 1023 resetMediaPlayerAndMediaSource(); |
982 | 1024 |
983 m_loadState = LoadingFromSourceElement; | 1025 m_loadState = LoadingFromSourceElement; |
984 loadResource(mediaURL, contentType); | 1026 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); |
985 } | 1027 } |
986 | 1028 |
987 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) | 1029 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT
ype& contentType) |
988 { | 1030 { |
989 ASSERT(isMainThread()); | 1031 ASSERT(isMainThread()); |
990 ASSERT(isSafeToLoadURL(url, Complain)); | 1032 KURL url; |
991 | 1033 if (source.isURL()) { |
992 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlForLog
gingMedia(url).utf8().data(), contentType.raw().utf8().data()); | 1034 url = source.getAsURL(); |
| 1035 ASSERT(isSafeToLoadURL(url, Complain)); |
| 1036 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlFo
rLoggingMedia(url).utf8().data(), contentType.raw().utf8().data()); |
| 1037 } |
993 | 1038 |
994 LocalFrame* frame = document().frame(); | 1039 LocalFrame* frame = document().frame(); |
995 if (!frame) { | 1040 if (!frame) { |
996 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1041 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
997 return; | 1042 return; |
998 } | 1043 } |
999 | 1044 |
1000 // The resource fetch algorithm | 1045 // The resource fetch algorithm |
1001 setNetworkState(NETWORK_LOADING); | 1046 setNetworkState(NETWORK_LOADING); |
1002 | 1047 |
(...skipping 16 matching lines...) Expand all Loading... |
1019 setPlayerPreload(); | 1064 setPlayerPreload(); |
1020 | 1065 |
1021 if (fastHasAttribute(mutedAttr)) | 1066 if (fastHasAttribute(mutedAttr)) |
1022 m_muted = true; | 1067 m_muted = true; |
1023 updateVolume(); | 1068 updateVolume(); |
1024 | 1069 |
1025 ASSERT(!m_mediaSource); | 1070 ASSERT(!m_mediaSource); |
1026 | 1071 |
1027 bool attemptLoad = true; | 1072 bool attemptLoad = true; |
1028 | 1073 |
1029 if (url.protocolIs(mediaSourceBlobProtocol)) { | 1074 bool isObjectOrBlobURL = source.isMediaProviderObject() || url.protocolIs(me
diaSourceBlobProtocol); |
1030 if (isMediaStreamURL(url.getString())) { | 1075 if (isObjectOrBlobURL) { |
| 1076 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi
aStreamURL(url.getString())); |
| 1077 if (isMediaStream) { |
1031 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEn
abledByStream); | 1078 m_autoplayHelper->removeUserGestureRequirement(GesturelessPlaybackEn
abledByStream); |
1032 } else { | 1079 } else { |
1033 m_mediaSource = HTMLMediaSource::lookup(url.getString()); | 1080 m_mediaSource = HTMLMediaSource::lookup(url.getString()); |
1034 | 1081 |
1035 if (m_mediaSource) { | 1082 if (m_mediaSource) { |
1036 if (!m_mediaSource->attachToElement(this)) { | 1083 if (!m_mediaSource->attachToElement(this)) { |
1037 // Forget our reference to the MediaSource, so we leave it a
lone | 1084 // Forget our reference to the MediaSource, so we leave it a
lone |
1038 // while processing remainder of load failure. | 1085 // while processing remainder of load failure. |
1039 m_mediaSource = nullptr; | 1086 m_mediaSource = nullptr; |
1040 attemptLoad = false; | 1087 attemptLoad = false; |
1041 } | 1088 } |
1042 } | 1089 } |
1043 } | 1090 } |
1044 } | 1091 } |
1045 | 1092 |
1046 if (attemptLoad && canLoadURL(url, contentType)) { | 1093 bool canLoadResource = source.isMediaProviderObject() || canLoadURL(url, con
tentType); |
| 1094 if (attemptLoad && canLoadResource) { |
1047 ASSERT(!webMediaPlayer()); | 1095 ASSERT(!webMediaPlayer()); |
1048 | 1096 |
1049 if (effectivePreloadType() == WebMediaPlayer::PreloadNone) { | 1097 if (effectivePreloadType() == WebMediaPlayer::PreloadNone) { |
1050 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); | 1098 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); |
1051 deferLoad(); | 1099 deferLoad(); |
1052 } else { | 1100 } else { |
1053 startPlayerLoad(); | 1101 startPlayerLoad(); |
1054 } | 1102 } |
1055 } else { | 1103 } else { |
1056 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1104 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
1057 } | 1105 } |
1058 | 1106 |
1059 // If there is no poster to display, allow the media engine to render video
frames as soon as | 1107 // If there is no poster to display, allow the media engine to render video
frames as soon as |
1060 // they are available. | 1108 // they are available. |
1061 updateDisplayState(); | 1109 updateDisplayState(); |
1062 | 1110 |
1063 if (layoutObject()) | 1111 if (layoutObject()) |
1064 layoutObject()->updateFromElement(); | 1112 layoutObject()->updateFromElement(); |
1065 } | 1113 } |
1066 | 1114 |
1067 void HTMLMediaElement::startPlayerLoad() | 1115 void HTMLMediaElement::startPlayerLoad() |
1068 { | 1116 { |
1069 ASSERT(!m_webMediaPlayer); | 1117 ASSERT(!m_webMediaPlayer); |
1070 // Filter out user:pass as those two URL components aren't | 1118 |
1071 // considered for media resource fetches (including for the CORS | 1119 WebMediaPlayerSource source; |
1072 // use-credentials mode.) That behavior aligns with Gecko, with IE | 1120 if (m_srcObject.isMediaProviderObject()) { |
1073 // being more restrictive and not allowing fetches to such URLs. | 1121 source = m_srcObject; |
1074 // | 1122 } else { |
1075 // Spec reference: http://whatwg.org/c/#concept-media-load-resource | 1123 // Filter out user:pass as those two URL components aren't |
1076 // | 1124 // considered for media resource fetches (including for the CORS |
1077 // FIXME: when the HTML spec switches to specifying resource | 1125 // use-credentials mode.) That behavior aligns with Gecko, with IE |
1078 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and | 1126 // being more restrictive and not allowing fetches to such URLs. |
1079 // along with that potentially also specifying a setting for its | 1127 // |
1080 // 'authentication flag' to control how user:pass embedded in a | 1128 // Spec reference: http://whatwg.org/c/#concept-media-load-resource |
1081 // media resource URL should be treated, then update the handling | 1129 // |
1082 // here to match. | 1130 // FIXME: when the HTML spec switches to specifying resource |
1083 KURL requestURL = m_currentSrc; | 1131 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and |
1084 if (!requestURL.user().isEmpty()) | 1132 // along with that potentially also specifying a setting for its |
1085 requestURL.setUser(String()); | 1133 // 'authentication flag' to control how user:pass embedded in a |
1086 if (!requestURL.pass().isEmpty()) | 1134 // media resource URL should be treated, then update the handling |
1087 requestURL.setPass(String()); | 1135 // here to match. |
| 1136 KURL requestURL = m_currentSrc; |
| 1137 if (!requestURL.user().isEmpty()) |
| 1138 requestURL.setUser(String()); |
| 1139 if (!requestURL.pass().isEmpty()) |
| 1140 requestURL.setPass(String()); |
| 1141 |
| 1142 KURL kurl(ParsedURLString, requestURL); |
| 1143 source = WebMediaPlayerSource(WebURL(kurl)); |
| 1144 } |
1088 | 1145 |
1089 LocalFrame* frame = document().frame(); | 1146 LocalFrame* frame = document().frame(); |
1090 // TODO(srirama.m): Figure out how frame can be null when | 1147 // TODO(srirama.m): Figure out how frame can be null when |
1091 // coming from executeDeferredLoad() | 1148 // coming from executeDeferredLoad() |
1092 if (!frame) { | 1149 if (!frame) { |
1093 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1150 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
1094 return; | 1151 return; |
1095 } | 1152 } |
1096 | 1153 |
1097 KURL kurl(ParsedURLString, requestURL); | 1154 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(*this, sou
rce, this); |
1098 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(*this, kur
l, this); | |
1099 if (!m_webMediaPlayer) { | 1155 if (!m_webMediaPlayer) { |
1100 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1156 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
1101 return; | 1157 return; |
1102 } | 1158 } |
1103 | 1159 |
1104 if (layoutObject()) | 1160 if (layoutObject()) |
1105 layoutObject()->setShouldDoFullPaintInvalidation(); | 1161 layoutObject()->setShouldDoFullPaintInvalidation(); |
1106 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. | 1162 // Make sure if we create/re-create the WebMediaPlayer that we update our wr
apper. |
1107 m_audioSourceProvider.wrap(m_webMediaPlayer->getAudioSourceProvider()); | 1163 m_audioSourceProvider.wrap(m_webMediaPlayer->getAudioSourceProvider()); |
1108 m_webMediaPlayer->setVolume(effectiveMediaVolume()); | 1164 m_webMediaPlayer->setVolume(effectiveMediaVolume()); |
1109 | 1165 |
1110 m_webMediaPlayer->setPoster(posterImageURL()); | 1166 m_webMediaPlayer->setPoster(posterImageURL()); |
1111 | 1167 |
1112 m_webMediaPlayer->setPreload(effectivePreloadType()); | 1168 m_webMediaPlayer->setPreload(effectivePreloadType()); |
1113 | 1169 |
1114 m_webMediaPlayer->load(loadType(), kurl, corsMode()); | 1170 m_webMediaPlayer->load(loadType(), source, corsMode()); |
1115 | 1171 |
1116 if (isFullscreen()) { | 1172 if (isFullscreen()) { |
1117 // This handles any transition to or from fullscreen overlay mode. | 1173 // This handles any transition to or from fullscreen overlay mode. |
1118 frame->chromeClient().enterFullScreenForElement(this); | 1174 frame->chromeClient().enterFullScreenForElement(this); |
1119 } | 1175 } |
1120 } | 1176 } |
1121 | 1177 |
1122 void HTMLMediaElement::setPlayerPreload() | 1178 void HTMLMediaElement::setPlayerPreload() |
1123 { | 1179 { |
1124 if (m_webMediaPlayer) | 1180 if (m_webMediaPlayer) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 } | 1253 } |
1198 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); | 1254 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); |
1199 m_deferredLoadState = WaitingForTrigger; | 1255 m_deferredLoadState = WaitingForTrigger; |
1200 } | 1256 } |
1201 | 1257 |
1202 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const | 1258 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const |
1203 { | 1259 { |
1204 if (m_mediaSource) | 1260 if (m_mediaSource) |
1205 return WebMediaPlayer::LoadTypeMediaSource; | 1261 return WebMediaPlayer::LoadTypeMediaSource; |
1206 | 1262 |
1207 if (isMediaStreamURL(m_currentSrc.getString())) | 1263 if (m_srcObject.isMediaStream() || isMediaStreamURL(m_currentSrc.getString()
)) |
1208 return WebMediaPlayer::LoadTypeMediaStream; | 1264 return WebMediaPlayer::LoadTypeMediaStream; |
1209 | 1265 |
1210 return WebMediaPlayer::LoadTypeURL; | 1266 return WebMediaPlayer::LoadTypeURL; |
1211 } | 1267 } |
1212 | 1268 |
1213 bool HTMLMediaElement::textTracksAreReady() const | 1269 bool HTMLMediaElement::textTracksAreReady() const |
1214 { | 1270 { |
1215 // 4.8.10.12.1 Text track model | 1271 // 4.8.10.12.1 Text track model |
1216 // ... | 1272 // ... |
1217 // The text tracks of a media element are ready if all the text tracks whose
mode was not | 1273 // The text tracks of a media element are ready if all the text tracks whose
mode was not |
(...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3882 } | 3938 } |
3883 | 3939 |
3884 #if !ENABLE(OILPAN) | 3940 #if !ENABLE(OILPAN) |
3885 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() | 3941 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() |
3886 { | 3942 { |
3887 return m_weakPtrFactory.createWeakPtr(); | 3943 return m_weakPtrFactory.createWeakPtr(); |
3888 } | 3944 } |
3889 #endif | 3945 #endif |
3890 | 3946 |
3891 } // namespace blink | 3947 } // namespace blink |
OLD | NEW |