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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2046253002: When HLS redirects are encountered recreate WebMediaPlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "third_party/WebKit/public/platform/WebMediaSource.h" 52 #include "third_party/WebKit/public/platform/WebMediaSource.h"
53 #include "third_party/WebKit/public/platform/WebRect.h" 53 #include "third_party/WebKit/public/platform/WebRect.h"
54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
55 #include "third_party/WebKit/public/platform/WebSize.h" 55 #include "third_party/WebKit/public/platform/WebSize.h"
56 #include "third_party/WebKit/public/platform/WebString.h" 56 #include "third_party/WebKit/public/platform/WebString.h"
57 #include "third_party/WebKit/public/platform/WebURL.h" 57 #include "third_party/WebKit/public/platform/WebURL.h"
58 #include "third_party/WebKit/public/web/WebFrame.h" 58 #include "third_party/WebKit/public/web/WebFrame.h"
59 #include "third_party/WebKit/public/web/WebLocalFrame.h" 59 #include "third_party/WebKit/public/web/WebLocalFrame.h"
60 #include "third_party/WebKit/public/web/WebView.h" 60 #include "third_party/WebKit/public/web/WebView.h"
61 61
62 #if defined(OS_ANDROID)
63 #include "media/base/android/media_codec_util.h"
64 #endif
65
62 using blink::WebCanvas; 66 using blink::WebCanvas;
63 using blink::WebMediaPlayer; 67 using blink::WebMediaPlayer;
64 using blink::WebRect; 68 using blink::WebRect;
65 using blink::WebSize; 69 using blink::WebSize;
66 using blink::WebString; 70 using blink::WebString;
67 using gpu::gles2::GLES2Interface; 71 using gpu::gles2::GLES2Interface;
68 72
69 #define STATIC_ASSERT_ENUM(a, b) \ 73 #define STATIC_ASSERT_ENUM(a, b) \
70 static_assert(static_cast<int>(a) == static_cast<int>(b), \ 74 static_assert(static_cast<int>(a) == static_cast<int>(b), \
71 "mismatching enums: " #a) 75 "mismatching enums: " #a)
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 1219
1216 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { 1220 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) {
1217 cast_impl_.setPoster(poster); 1221 cast_impl_.setPoster(poster);
1218 } 1222 }
1219 #endif // defined(OS_ANDROID) // WMPI_CAST 1223 #endif // defined(OS_ANDROID) // WMPI_CAST
1220 1224
1221 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { 1225 void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
1222 DVLOG(1) << __FUNCTION__; 1226 DVLOG(1) << __FUNCTION__;
1223 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1227 DCHECK(main_task_runner_->BelongsToCurrentThread());
1224 1228
1229 #if defined(OS_ANDROID)
1230 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are
1231 // encountered, instruct the HTML media element to create a new WebMediaPlayer
1232 // instance with the correct URL to trigger WebMediaPlayerAndroid creation.
1233 //
1234 // TODO(tguilbert): Remove this code path once we have the ability to host a
1235 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626
1236 if (data_source_) {
1237 const GURL reponse_origin_url = data_source_->GetResponseOriginURL();
1238 if (MediaCodecUtil::IsHLSPath(reponse_origin_url)) {
1239 alternative_source_url_ = reponse_origin_url;
1240 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
1241 UpdatePlayState();
1242 return;
1243 }
1244 }
1245 #endif
1246
1225 if (!success) { 1247 if (!success) {
1226 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); 1248 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
1227 1249
1228 // Not really necessary, since the pipeline was never started, but it at 1250 // Not really necessary, since the pipeline was never started, but it at
1229 // least this makes sure that the error handling code is in sync. 1251 // least this makes sure that the error handling code is in sync.
1230 UpdatePlayState(); 1252 UpdatePlayState();
1231 1253
1232 return; 1254 return;
1233 } 1255 }
1234 1256
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 // Remote players will be suspended and locally paused. 1659 // Remote players will be suspended and locally paused.
1638 if (isRemote()) 1660 if (isRemote())
1639 return; 1661 return;
1640 #endif 1662 #endif
1641 1663
1642 // Idle timeout chosen arbitrarily. 1664 // Idle timeout chosen arbitrarily.
1643 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), 1665 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5),
1644 this, &WebMediaPlayerImpl::OnPause); 1666 this, &WebMediaPlayerImpl::OnPause);
1645 } 1667 }
1646 1668
1669 blink::WebURL WebMediaPlayerImpl::alternativeSourceURL() const {
1670 return blink::WebURL(alternative_source_url_);
1671 }
1672
1647 } // namespace media 1673 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698