Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2046253002: When HLS redirects are encountered recreate WebMediaPlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't set m_currentSrc. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 937 }
938 } 938 }
939 939
940 void HTMLMediaElement::loadSourceFromObject() 940 void HTMLMediaElement::loadSourceFromObject()
941 { 941 {
942 DCHECK(m_srcObject); 942 DCHECK(m_srcObject);
943 m_loadState = LoadingFromSrcObject; 943 m_loadState = LoadingFromSrcObject;
944 944
945 // No type is available when the resource comes from the 'srcObject' 945 // No type is available when the resource comes from the 'srcObject'
946 // attribute. 946 // attribute.
947 ContentType contentType((String())); 947 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), ContentType( (String())));
948 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType) ;
949 } 948 }
950 949
951 void HTMLMediaElement::loadSourceFromAttribute() 950 void HTMLMediaElement::loadSourceFromAttribute()
952 { 951 {
953 m_loadState = LoadingFromSrcAttr; 952 m_loadState = LoadingFromSrcAttr;
954 const AtomicString& srcValue = fastGetAttribute(srcAttr); 953 const AtomicString& srcValue = fastGetAttribute(srcAttr);
955 954
956 // If the src attribute's value is the empty string ... jump down to the fai led step below 955 // If the src attribute's value is the empty string ... jump down to the fai led step below
957 if (srcValue.isEmpty()) { 956 if (srcValue.isEmpty()) {
958 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 957 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
959 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), empty 'src'"; 958 MEDIA_LOG << "selectMediaResource(" << (void*)this << "), empty 'src'";
960 return; 959 return;
961 } 960 }
962 961
963 KURL mediaURL = document().completeURL(srcValue); 962 KURL mediaURL = document().completeURL(srcValue);
964 if (!isSafeToLoadURL(mediaURL, Complain)) { 963 if (!isSafeToLoadURL(mediaURL, Complain)) {
965 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 964 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
966 return; 965 return;
967 } 966 }
968 967
969 // No type is available when the url comes from the 'src' attribute so 968 // No type is available when the url comes from the 'src' attribute so
970 // MediaPlayer will have to pick a media engine based on the file extension. 969 // MediaPlayer will have to pick a media engine based on the file extension.
971 ContentType contentType((String())); 970 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), ContentType((String())) );
972 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType);
973 } 971 }
974 972
975 void HTMLMediaElement::loadNextSourceChild() 973 void HTMLMediaElement::loadNextSourceChild()
976 { 974 {
977 ContentType contentType((String())); 975 ContentType contentType((String()));
978 KURL mediaURL = selectNextSourceChild(&contentType, Complain); 976 KURL mediaURL = selectNextSourceChild(&contentType, Complain);
979 if (!mediaURL.isValid()) { 977 if (!mediaURL.isValid()) {
980 waitForSourceChange(); 978 waitForSourceChange();
981 return; 979 return;
982 } 980 }
983 981
984 // Reset the MediaPlayer and MediaSource if any 982 // Reset the MediaPlayer and MediaSource if any
985 resetMediaPlayerAndMediaSource(); 983 resetMediaPlayerAndMediaSource();
986 984
987 m_loadState = LoadingFromSourceElement; 985 m_loadState = LoadingFromSourceElement;
988 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); 986 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType);
989 } 987 }
990 988
991 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT ype& contentType) 989 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co ntentType& contentType, const KURL& playerProvidedUrl)
992 { 990 {
993 DCHECK(isMainThread()); 991 DCHECK(isMainThread());
994 KURL url; 992 KURL url;
995 if (source.isURL()) { 993 if (source.isURL()) {
996 url = source.getAsURL(); 994 url = playerProvidedUrl.isNull() ? KURL(source.getAsURL()) : playerProvi dedUrl;
997 DCHECK(isSafeToLoadURL(url, Complain)); 995 DCHECK(isSafeToLoadURL(url, Complain));
998 MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggingMedi a(url) << ", " << contentType.raw() << ")"; 996 MEDIA_LOG << "loadResource(" << (void*)this << ", " << urlForLoggingMedi a(url) << ", " << contentType.raw() << ")";
999 } 997 }
1000 998
1001 LocalFrame* frame = document().frame(); 999 LocalFrame* frame = document().frame();
1002 if (!frame) { 1000 if (!frame) {
1003 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1001 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1004 return; 1002 return;
1005 } 1003 }
1006 1004
1007 // The resource fetch algorithm 1005 // The resource fetch algorithm
1008 setNetworkState(NETWORK_LOADING); 1006 setNetworkState(NETWORK_LOADING);
1009 1007
1010 m_autoplayHelper->loadingStarted(); 1008 m_autoplayHelper->loadingStarted();
1011 1009
1012 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app 1010 // Do not update the element visible source when using a player provided URL , this may reveal
1013 // cache is an internal detail not exposed through the media element API. 1011 // redirect origin information to the page.
1014 m_currentSrc = url; 1012 if (playerProvidedUrl.isNull()) {
1013 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app
1014 // cache is an internal detail not exposed through the media element API .
1015 m_currentSrc = url;
1015 1016
1016 if (m_audioSourceNode) 1017 if (m_audioSourceNode)
1017 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); 1018 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc);
1019 }
1018 1020
1019 MEDIA_LOG << "loadResource(" << (void*)this << ") - m_currentSrc -> " << url ForLoggingMedia(m_currentSrc); 1021 MEDIA_LOG << "loadResource(" << (void*)this << ") - m_currentSrc -> " << url ForLoggingMedia(m_currentSrc);
1020 1022
1021 startProgressEventTimer(); 1023 startProgressEventTimer();
1022 1024
1023 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. 1025 // Reset display mode to force a recalculation of what to show because we ar e resetting the player.
1024 setDisplayMode(Unknown); 1026 setDisplayMode(Unknown);
1025 1027
1026 setPlayerPreload(); 1028 setPlayerPreload();
1027 1029
(...skipping 28 matching lines...) Expand all
1056 if (attemptLoad && canLoadResource) { 1058 if (attemptLoad && canLoadResource) {
1057 DCHECK(!webMediaPlayer()); 1059 DCHECK(!webMediaPlayer());
1058 1060
1059 // Conditionally defer the load if effective preload is 'none'. 1061 // Conditionally defer the load if effective preload is 'none'.
1060 // Skip this optional deferral for MediaStream sources or any blob URL, 1062 // Skip this optional deferral for MediaStream sources or any blob URL,
1061 // including MediaSource blob URLs. 1063 // including MediaSource blob URLs.
1062 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel oadNone) { 1064 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel oadNone) {
1063 MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load be cause preload == 'none'"; 1065 MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load be cause preload == 'none'";
1064 deferLoad(); 1066 deferLoad();
1065 } else { 1067 } else {
1066 startPlayerLoad(); 1068 startPlayerLoad(playerProvidedUrl);
foolip 2016/06/23 11:22:36 If preload=none, then I think you'll have taken th
DaleCurtis 2016/06/23 18:55:56 This seems to work fine. Done.
1067 } 1069 }
1068 } else { 1070 } else {
1069 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1071 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1070 } 1072 }
1071 1073
1072 // If there is no poster to display, allow the media engine to render video frames as soon as 1074 // If there is no poster to display, allow the media engine to render video frames as soon as
1073 // they are available. 1075 // they are available.
1074 updateDisplayState(); 1076 updateDisplayState();
1075 1077
1076 if (layoutObject()) 1078 if (layoutObject())
1077 layoutObject()->updateFromElement(); 1079 layoutObject()->updateFromElement();
1078 } 1080 }
1079 1081
1080 void HTMLMediaElement::startPlayerLoad() 1082 void HTMLMediaElement::startPlayerLoad(const KURL& playerProvidedUrl)
1081 { 1083 {
1082 DCHECK(!m_webMediaPlayer); 1084 DCHECK(!m_webMediaPlayer);
1083 1085
1084 WebMediaPlayerSource source; 1086 WebMediaPlayerSource source;
1085 if (m_srcObject) { 1087 if (m_srcObject) {
1086 source = WebMediaPlayerSource(WebMediaStream(m_srcObject)); 1088 source = WebMediaPlayerSource(WebMediaStream(m_srcObject));
1087 } else { 1089 } else {
1088 // Filter out user:pass as those two URL components aren't 1090 // Filter out user:pass as those two URL components aren't
1089 // considered for media resource fetches (including for the CORS 1091 // considered for media resource fetches (including for the CORS
1090 // use-credentials mode.) That behavior aligns with Gecko, with IE 1092 // use-credentials mode.) That behavior aligns with Gecko, with IE
1091 // being more restrictive and not allowing fetches to such URLs. 1093 // being more restrictive and not allowing fetches to such URLs.
1092 // 1094 //
1093 // Spec reference: http://whatwg.org/c/#concept-media-load-resource 1095 // Spec reference: http://whatwg.org/c/#concept-media-load-resource
1094 // 1096 //
1095 // FIXME: when the HTML spec switches to specifying resource 1097 // FIXME: when the HTML spec switches to specifying resource
1096 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and 1098 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and
1097 // along with that potentially also specifying a setting for its 1099 // along with that potentially also specifying a setting for its
1098 // 'authentication flag' to control how user:pass embedded in a 1100 // 'authentication flag' to control how user:pass embedded in a
1099 // media resource URL should be treated, then update the handling 1101 // media resource URL should be treated, then update the handling
1100 // here to match. 1102 // here to match.
1101 KURL requestURL = m_currentSrc; 1103 KURL requestURL = playerProvidedUrl.isNull() ? KURL(m_currentSrc) : play erProvidedUrl;
1102 if (!requestURL.user().isEmpty()) 1104 if (!requestURL.user().isEmpty())
1103 requestURL.setUser(String()); 1105 requestURL.setUser(String());
1104 if (!requestURL.pass().isEmpty()) 1106 if (!requestURL.pass().isEmpty())
1105 requestURL.setPass(String()); 1107 requestURL.setPass(String());
1106 1108
1107 KURL kurl(ParsedURLString, requestURL); 1109 KURL kurl(ParsedURLString, requestURL);
1108 source = WebMediaPlayerSource(WebURL(kurl)); 1110 source = WebMediaPlayerSource(WebURL(kurl));
1109 } 1111 }
1110 1112
1111 LocalFrame* frame = document().frame(); 1113 LocalFrame* frame = document().frame();
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 if (remotePlaybackClient()) 2994 if (remotePlaybackClient())
2993 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d); 2995 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d);
2994 } 2996 }
2995 2997
2996 void HTMLMediaElement::cancelledRemotePlaybackRequest() 2998 void HTMLMediaElement::cancelledRemotePlaybackRequest()
2997 { 2999 {
2998 if (remotePlaybackClient()) 3000 if (remotePlaybackClient())
2999 remotePlaybackClient()->connectCancelled(); 3001 remotePlaybackClient()->connectCancelled();
3000 } 3002 }
3001 3003
3004 void HTMLMediaElement::requestReload(const WebURL& newUrl)
3005 {
3006 DCHECK(webMediaPlayer());
3007 DCHECK(!m_srcObject);
3008 resetMediaPlayerAndMediaSource();
3009 loadResource(WebMediaPlayerSource(newUrl), ContentType((String())));
3010 }
3011
3002 // MediaPlayerPresentation methods 3012 // MediaPlayerPresentation methods
3003 void HTMLMediaElement::repaint() 3013 void HTMLMediaElement::repaint()
3004 { 3014 {
3005 if (m_webLayer) 3015 if (m_webLayer)
3006 m_webLayer->invalidate(); 3016 m_webLayer->invalidate();
3007 3017
3008 updateDisplayState(); 3018 updateDisplayState();
3009 if (layoutObject()) 3019 if (layoutObject())
3010 layoutObject()->setShouldDoFullPaintInvalidation(); 3020 layoutObject()->setShouldDoFullPaintInvalidation();
3011 } 3021 }
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 4024
4015 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4025 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4016 { 4026 {
4017 IntRect result; 4027 IntRect result;
4018 if (LayoutObject* object = m_element->layoutObject()) 4028 if (LayoutObject* object = m_element->layoutObject())
4019 result = object->absoluteBoundingBoxRect(); 4029 result = object->absoluteBoundingBoxRect();
4020 return result; 4030 return result;
4021 } 4031 }
4022 4032
4023 } // namespace blink 4033 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/public/platform/WebMediaPlayerClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698