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

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

Issue 2095053003: Merge M52: "When HLS redirects are encountered recreate WebMediaPlayer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 925 }
926 } 926 }
927 927
928 void HTMLMediaElement::loadSourceFromObject() 928 void HTMLMediaElement::loadSourceFromObject()
929 { 929 {
930 ASSERT(m_srcObject); 930 ASSERT(m_srcObject);
931 m_loadState = LoadingFromSrcObject; 931 m_loadState = LoadingFromSrcObject;
932 932
933 // No type is available when the resource comes from the 'srcObject' 933 // No type is available when the resource comes from the 'srcObject'
934 // attribute. 934 // attribute.
935 ContentType contentType((String())); 935 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), ContentType( (String())));
936 loadResource(WebMediaPlayerSource(WebMediaStream(m_srcObject)), contentType) ;
937 } 936 }
938 937
939 void HTMLMediaElement::loadSourceFromAttribute() 938 void HTMLMediaElement::loadSourceFromAttribute()
940 { 939 {
941 m_loadState = LoadingFromSrcAttr; 940 m_loadState = LoadingFromSrcAttr;
942 const AtomicString& srcValue = fastGetAttribute(srcAttr); 941 const AtomicString& srcValue = fastGetAttribute(srcAttr);
943 942
944 // If the src attribute's value is the empty string ... jump down to the fai led step below 943 // If the src attribute's value is the empty string ... jump down to the fai led step below
945 if (srcValue.isEmpty()) { 944 if (srcValue.isEmpty()) {
946 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 945 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
947 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), e mpty 'src'"; 946 DVLOG(MEDIA_LOG_LEVEL) << "selectMediaResource(" << (void*)this << "), e mpty 'src'";
948 return; 947 return;
949 } 948 }
950 949
951 KURL mediaURL = document().completeURL(srcValue); 950 KURL mediaURL = document().completeURL(srcValue);
952 if (!isSafeToLoadURL(mediaURL, Complain)) { 951 if (!isSafeToLoadURL(mediaURL, Complain)) {
953 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 952 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
954 return; 953 return;
955 } 954 }
956 955
957 // No type is available when the url comes from the 'src' attribute so 956 // No type is available when the url comes from the 'src' attribute so
958 // MediaPlayer will have to pick a media engine based on the file extension. 957 // MediaPlayer will have to pick a media engine based on the file extension.
959 ContentType contentType((String())); 958 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), ContentType((String())) );
960 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType);
961 } 959 }
962 960
963 void HTMLMediaElement::loadNextSourceChild() 961 void HTMLMediaElement::loadNextSourceChild()
964 { 962 {
965 ContentType contentType((String())); 963 ContentType contentType((String()));
966 KURL mediaURL = selectNextSourceChild(&contentType, Complain); 964 KURL mediaURL = selectNextSourceChild(&contentType, Complain);
967 if (!mediaURL.isValid()) { 965 if (!mediaURL.isValid()) {
968 waitForSourceChange(); 966 waitForSourceChange();
969 return; 967 return;
970 } 968 }
971 969
972 // Reset the MediaPlayer and MediaSource if any 970 // Reset the MediaPlayer and MediaSource if any
973 resetMediaPlayerAndMediaSource(); 971 resetMediaPlayerAndMediaSource();
974 972
975 m_loadState = LoadingFromSourceElement; 973 m_loadState = LoadingFromSourceElement;
976 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType); 974 loadResource(WebMediaPlayerSource(WebURL(mediaURL)), contentType);
977 } 975 }
978 976
979 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, ContentT ype& contentType) 977 void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co ntentType& contentType)
980 { 978 {
981 ASSERT(isMainThread()); 979 ASSERT(isMainThread());
982 KURL url; 980 KURL url;
983 if (source.isURL()) { 981 if (source.isURL()) {
984 url = source.getAsURL(); 982 url = source.getAsURL();
985 ASSERT(isSafeToLoadURL(url, Complain)); 983 ASSERT(isSafeToLoadURL(url, Complain));
986 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ", " << urlF orLoggingMedia(url) << ", " << contentType.raw() << ")"; 984 DVLOG(MEDIA_LOG_LEVEL) << "loadResource(" << (void*)this << ", " << urlF orLoggingMedia(url) << ", " << contentType.raw() << ")";
987 } 985 }
988 986
989 LocalFrame* frame = document().frame(); 987 LocalFrame* frame = document().frame();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 } 1056 }
1059 1057
1060 // If there is no poster to display, allow the media engine to render video frames as soon as 1058 // If there is no poster to display, allow the media engine to render video frames as soon as
1061 // they are available. 1059 // they are available.
1062 updateDisplayState(); 1060 updateDisplayState();
1063 1061
1064 if (layoutObject()) 1062 if (layoutObject())
1065 layoutObject()->updateFromElement(); 1063 layoutObject()->updateFromElement();
1066 } 1064 }
1067 1065
1068 void HTMLMediaElement::startPlayerLoad() 1066 void HTMLMediaElement::startPlayerLoad(const KURL& playerProvidedUrl)
1069 { 1067 {
1070 ASSERT(!m_webMediaPlayer); 1068 ASSERT(!m_webMediaPlayer);
1071 1069
1072 WebMediaPlayerSource source; 1070 WebMediaPlayerSource source;
1073 if (m_srcObject) { 1071 if (m_srcObject) {
1074 source = WebMediaPlayerSource(WebMediaStream(m_srcObject)); 1072 source = WebMediaPlayerSource(WebMediaStream(m_srcObject));
1075 } else { 1073 } else {
1076 // Filter out user:pass as those two URL components aren't 1074 // Filter out user:pass as those two URL components aren't
1077 // considered for media resource fetches (including for the CORS 1075 // considered for media resource fetches (including for the CORS
1078 // use-credentials mode.) That behavior aligns with Gecko, with IE 1076 // use-credentials mode.) That behavior aligns with Gecko, with IE
1079 // being more restrictive and not allowing fetches to such URLs. 1077 // being more restrictive and not allowing fetches to such URLs.
1080 // 1078 //
1081 // Spec reference: http://whatwg.org/c/#concept-media-load-resource 1079 // Spec reference: http://whatwg.org/c/#concept-media-load-resource
1082 // 1080 //
1083 // FIXME: when the HTML spec switches to specifying resource 1081 // FIXME: when the HTML spec switches to specifying resource
1084 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and 1082 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and
1085 // along with that potentially also specifying a setting for its 1083 // along with that potentially also specifying a setting for its
1086 // 'authentication flag' to control how user:pass embedded in a 1084 // 'authentication flag' to control how user:pass embedded in a
1087 // media resource URL should be treated, then update the handling 1085 // media resource URL should be treated, then update the handling
1088 // here to match. 1086 // here to match.
1089 KURL requestURL = m_currentSrc; 1087 KURL requestURL = playerProvidedUrl.isNull() ? KURL(m_currentSrc) : play erProvidedUrl;
1090 if (!requestURL.user().isEmpty()) 1088 if (!requestURL.user().isEmpty())
1091 requestURL.setUser(String()); 1089 requestURL.setUser(String());
1092 if (!requestURL.pass().isEmpty()) 1090 if (!requestURL.pass().isEmpty())
1093 requestURL.setPass(String()); 1091 requestURL.setPass(String());
1094 1092
1095 KURL kurl(ParsedURLString, requestURL); 1093 KURL kurl(ParsedURLString, requestURL);
1096 source = WebMediaPlayerSource(WebURL(kurl)); 1094 source = WebMediaPlayerSource(WebURL(kurl));
1097 } 1095 }
1098 1096
1099 LocalFrame* frame = document().frame(); 1097 LocalFrame* frame = document().frame();
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 if (remotePlaybackClient()) 2961 if (remotePlaybackClient())
2964 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d); 2962 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d);
2965 } 2963 }
2966 2964
2967 void HTMLMediaElement::cancelledRemotePlaybackRequest() 2965 void HTMLMediaElement::cancelledRemotePlaybackRequest()
2968 { 2966 {
2969 if (remotePlaybackClient()) 2967 if (remotePlaybackClient())
2970 remotePlaybackClient()->connectCancelled(); 2968 remotePlaybackClient()->connectCancelled();
2971 } 2969 }
2972 2970
2971 void HTMLMediaElement::requestReload(const WebURL& newUrl)
2972 {
2973 DCHECK(webMediaPlayer());
2974 DCHECK(!m_srcObject);
2975 DCHECK(newUrl.isValid());
2976 DCHECK(isSafeToLoadURL(newUrl, Complain));
2977 resetMediaPlayerAndMediaSource();
2978 startPlayerLoad(newUrl);
2979 }
2980
2973 // MediaPlayerPresentation methods 2981 // MediaPlayerPresentation methods
2974 void HTMLMediaElement::repaint() 2982 void HTMLMediaElement::repaint()
2975 { 2983 {
2976 if (m_webLayer) 2984 if (m_webLayer)
2977 m_webLayer->invalidate(); 2985 m_webLayer->invalidate();
2978 2986
2979 updateDisplayState(); 2987 updateDisplayState();
2980 if (layoutObject()) 2988 if (layoutObject())
2981 layoutObject()->setShouldDoFullPaintInvalidation(); 2989 layoutObject()->setShouldDoFullPaintInvalidation();
2982 } 2990 }
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 3951
3944 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3952 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3945 { 3953 {
3946 IntRect result; 3954 IntRect result;
3947 if (LayoutObject* object = m_element->layoutObject()) 3955 if (LayoutObject* object = m_element->layoutObject())
3948 result = object->absoluteBoundingBoxRect(); 3956 result = object->absoluteBoundingBoxRect();
3949 return result; 3957 return result;
3950 } 3958 }
3951 3959
3952 } // namespace blink 3960 } // 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