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

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: Fix compile failures. 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 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)
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 = source.getAsURL();
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();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 } 1068 }
1071 1069
1072 // If there is no poster to display, allow the media engine to render video frames as soon as 1070 // If there is no poster to display, allow the media engine to render video frames as soon as
1073 // they are available. 1071 // they are available.
1074 updateDisplayState(); 1072 updateDisplayState();
1075 1073
1076 if (layoutObject()) 1074 if (layoutObject())
1077 layoutObject()->updateFromElement(); 1075 layoutObject()->updateFromElement();
1078 } 1076 }
1079 1077
1080 void HTMLMediaElement::startPlayerLoad() 1078 void HTMLMediaElement::startPlayerLoad(const KURL& playerProvidedUrl)
1081 { 1079 {
1082 DCHECK(!m_webMediaPlayer); 1080 DCHECK(!m_webMediaPlayer);
1083 1081
1084 WebMediaPlayerSource source; 1082 WebMediaPlayerSource source;
1085 if (m_srcObject) { 1083 if (m_srcObject) {
1086 source = WebMediaPlayerSource(WebMediaStream(m_srcObject)); 1084 source = WebMediaPlayerSource(WebMediaStream(m_srcObject));
1087 } else { 1085 } else {
1088 // Filter out user:pass as those two URL components aren't 1086 // Filter out user:pass as those two URL components aren't
1089 // considered for media resource fetches (including for the CORS 1087 // considered for media resource fetches (including for the CORS
1090 // use-credentials mode.) That behavior aligns with Gecko, with IE 1088 // use-credentials mode.) That behavior aligns with Gecko, with IE
1091 // being more restrictive and not allowing fetches to such URLs. 1089 // being more restrictive and not allowing fetches to such URLs.
1092 // 1090 //
1093 // Spec reference: http://whatwg.org/c/#concept-media-load-resource 1091 // Spec reference: http://whatwg.org/c/#concept-media-load-resource
1094 // 1092 //
1095 // FIXME: when the HTML spec switches to specifying resource 1093 // FIXME: when the HTML spec switches to specifying resource
1096 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and 1094 // fetches in terms of Fetch (http://fetch.spec.whatwg.org), and
1097 // along with that potentially also specifying a setting for its 1095 // along with that potentially also specifying a setting for its
1098 // 'authentication flag' to control how user:pass embedded in a 1096 // 'authentication flag' to control how user:pass embedded in a
1099 // media resource URL should be treated, then update the handling 1097 // media resource URL should be treated, then update the handling
1100 // here to match. 1098 // here to match.
1101 KURL requestURL = m_currentSrc; 1099 KURL requestURL = playerProvidedUrl.isNull() ? KURL(m_currentSrc) : play erProvidedUrl;
1102 if (!requestURL.user().isEmpty()) 1100 if (!requestURL.user().isEmpty())
1103 requestURL.setUser(String()); 1101 requestURL.setUser(String());
1104 if (!requestURL.pass().isEmpty()) 1102 if (!requestURL.pass().isEmpty())
1105 requestURL.setPass(String()); 1103 requestURL.setPass(String());
1106 1104
1107 KURL kurl(ParsedURLString, requestURL); 1105 KURL kurl(ParsedURLString, requestURL);
1108 source = WebMediaPlayerSource(WebURL(kurl)); 1106 source = WebMediaPlayerSource(WebURL(kurl));
1109 } 1107 }
1110 1108
1111 LocalFrame* frame = document().frame(); 1109 LocalFrame* frame = document().frame();
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 if (remotePlaybackClient()) 2990 if (remotePlaybackClient())
2993 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d); 2991 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnecte d);
2994 } 2992 }
2995 2993
2996 void HTMLMediaElement::cancelledRemotePlaybackRequest() 2994 void HTMLMediaElement::cancelledRemotePlaybackRequest()
2997 { 2995 {
2998 if (remotePlaybackClient()) 2996 if (remotePlaybackClient())
2999 remotePlaybackClient()->connectCancelled(); 2997 remotePlaybackClient()->connectCancelled();
3000 } 2998 }
3001 2999
3000 void HTMLMediaElement::requestReload(const WebURL& newUrl)
3001 {
3002 DCHECK(webMediaPlayer());
3003 DCHECK(!m_srcObject);
3004 DCHECK(newUrl.isValid());
3005 DCHECK(isSafeToLoadURL(newUrl, Complain));
3006 resetMediaPlayerAndMediaSource();
3007 startPlayerLoad(newUrl);
3008 }
3009
3002 // MediaPlayerPresentation methods 3010 // MediaPlayerPresentation methods
3003 void HTMLMediaElement::repaint() 3011 void HTMLMediaElement::repaint()
3004 { 3012 {
3005 if (m_webLayer) 3013 if (m_webLayer)
3006 m_webLayer->invalidate(); 3014 m_webLayer->invalidate();
3007 3015
3008 updateDisplayState(); 3016 updateDisplayState();
3009 if (layoutObject()) 3017 if (layoutObject())
3010 layoutObject()->setShouldDoFullPaintInvalidation(); 3018 layoutObject()->setShouldDoFullPaintInvalidation();
3011 } 3019 }
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 4023
4016 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4024 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4017 { 4025 {
4018 IntRect result; 4026 IntRect result;
4019 if (LayoutObject* object = m_element->layoutObject()) 4027 if (LayoutObject* object = m_element->layoutObject())
4020 result = object->absoluteBoundingBoxRect(); 4028 result = object->absoluteBoundingBoxRect();
4021 return result; 4029 return result;
4022 } 4030 }
4023 4031
4024 } // namespace blink 4032 } // 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