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

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

Issue 2769153005: Remove |use_fallback_path_| from WMPI (Closed)
Patch Set: Addressed comment Created 3 years, 7 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
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 #if defined(OS_ANDROID) // WMPI_CAST 228 #if defined(OS_ANDROID) // WMPI_CAST
229 cast_impl_(this, client_, params->context_3d_cb()), 229 cast_impl_(this, client_, params->context_3d_cb()),
230 #endif 230 #endif
231 volume_(1.0), 231 volume_(1.0),
232 volume_multiplier_(1.0), 232 volume_multiplier_(1.0),
233 renderer_factory_selector_(std::move(renderer_factory_selector)), 233 renderer_factory_selector_(std::move(renderer_factory_selector)),
234 surface_manager_(params->surface_manager()), 234 surface_manager_(params->surface_manager()),
235 overlay_surface_id_(SurfaceManager::kNoSurfaceID), 235 overlay_surface_id_(SurfaceManager::kNoSurfaceID),
236 suppress_destruction_errors_(false), 236 suppress_destruction_errors_(false),
237 suspend_enabled_(params->allow_suspend()), 237 suspend_enabled_(params->allow_suspend()),
238 use_fallback_path_(false),
239 is_encrypted_(false), 238 is_encrypted_(false),
240 preroll_attempt_pending_(false), 239 preroll_attempt_pending_(false),
241 observer_(params->media_observer()), 240 observer_(params->media_observer()),
242 max_keyframe_distance_to_disable_background_video_( 241 max_keyframe_distance_to_disable_background_video_(
243 params->max_keyframe_distance_to_disable_background_video()), 242 params->max_keyframe_distance_to_disable_background_video()),
244 max_keyframe_distance_to_disable_background_video_mse_( 243 max_keyframe_distance_to_disable_background_video_mse_(
245 params->max_keyframe_distance_to_disable_background_video_mse()), 244 params->max_keyframe_distance_to_disable_background_video_mse()),
246 enable_instant_source_buffer_gc_( 245 enable_instant_source_buffer_gc_(
247 params->enable_instant_source_buffer_gc()), 246 params->enable_instant_source_buffer_gc()),
248 embedded_media_experience_enabled_( 247 embedded_media_experience_enabled_(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 CORSMode cors_mode) { 397 CORSMode cors_mode) {
399 DVLOG(1) << __func__; 398 DVLOG(1) << __func__;
400 DCHECK(main_task_runner_->BelongsToCurrentThread()); 399 DCHECK(main_task_runner_->BelongsToCurrentThread());
401 400
402 GURL gurl(url); 401 GURL gurl(url);
403 ReportMetrics(load_type, gurl, frame_->GetSecurityOrigin(), media_log_.get()); 402 ReportMetrics(load_type, gurl, frame_->GetSecurityOrigin(), media_log_.get());
404 403
405 // Set subresource URL for crash reporting. 404 // Set subresource URL for crash reporting.
406 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); 405 base::debug::SetCrashKeyValue("subresource_url", gurl.spec());
407 406
408 if (use_fallback_path_) 407 // Used for HLS playback.
409 fallback_url_ = gurl; 408 loaded_url_ = gurl;
410 409
411 load_type_ = load_type; 410 load_type_ = load_type;
412 411
413 SetNetworkState(WebMediaPlayer::kNetworkStateLoading); 412 SetNetworkState(WebMediaPlayer::kNetworkStateLoading);
414 SetReadyState(WebMediaPlayer::kReadyStateHaveNothing); 413 SetReadyState(WebMediaPlayer::kReadyStateHaveNothing);
415 media_log_->AddEvent(media_log_->CreateLoadEvent(url.GetString().Utf8())); 414 media_log_->AddEvent(media_log_->CreateLoadEvent(url.GetString().Utf8()));
416 415
417 // Media source pipelines can start immediately. 416 // Media source pipelines can start immediately.
418 if (load_type == kLoadTypeMediaSource) { 417 if (load_type == kLoadTypeMediaSource) {
419 supports_save_ = false; 418 supports_save_ = false;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 if (ready_state_ < WebMediaPlayer::kReadyStateHaveMetadata) 808 if (ready_state_ < WebMediaPlayer::kReadyStateHaveMetadata)
810 return blink::WebTimeRanges(); 809 return blink::WebTimeRanges();
811 810
812 const double seekable_end = Duration(); 811 const double seekable_end = Duration();
813 812
814 // Allow a special exception for seeks to zero for streaming sources with a 813 // Allow a special exception for seeks to zero for streaming sources with a
815 // finite duration; this allows looping to work. 814 // finite duration; this allows looping to work.
816 const bool is_finite_stream = data_source_ && data_source_->IsStreaming() && 815 const bool is_finite_stream = data_source_ && data_source_->IsStreaming() &&
817 std::isfinite(seekable_end); 816 std::isfinite(seekable_end);
818 817
819 // Do not change the seekable range when using the fallback path. 818 // Do not change the seekable range when using the MediaPlayerRenderer. It
820 // The MediaPlayerRenderer will take care of dropping invalid seeks. 819 // will take care of dropping invalid seeks.
821 const bool force_seeks_to_zero = !use_fallback_path_ && is_finite_stream; 820 const bool force_seeks_to_zero =
821 !using_media_player_renderer_ && is_finite_stream;
822 822
823 // TODO(dalecurtis): Technically this allows seeking on media which return an 823 // TODO(dalecurtis): Technically this allows seeking on media which return an
824 // infinite duration so long as DataSource::IsStreaming() is false. While not 824 // infinite duration so long as DataSource::IsStreaming() is false. While not
825 // expected, disabling this breaks semi-live players, http://crbug.com/427412. 825 // expected, disabling this breaks semi-live players, http://crbug.com/427412.
826 const blink::WebTimeRange seekable_range( 826 const blink::WebTimeRange seekable_range(
827 0.0, force_seeks_to_zero ? 0.0 : seekable_end); 827 0.0, force_seeks_to_zero ? 0.0 : seekable_end);
828 return blink::WebTimeRanges(&seekable_range, 1); 828 return blink::WebTimeRanges(&seekable_range, 1);
829 } 829 }
830 830
831 bool WebMediaPlayerImpl::IsPrerollAttemptNeeded() { 831 bool WebMediaPlayerImpl::IsPrerollAttemptNeeded() {
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 if (!video_weblayer_) 1608 if (!video_weblayer_)
1609 return pipeline_metadata_.natural_size; 1609 return pipeline_metadata_.natural_size;
1610 1610
1611 return video_weblayer_->Bounds(); 1611 return video_weblayer_->Bounds();
1612 } 1612 }
1613 1613
1614 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { 1614 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) {
1615 cast_impl_.SetDeviceScaleFactor(scale_factor); 1615 cast_impl_.SetDeviceScaleFactor(scale_factor);
1616 } 1616 }
1617 1617
1618 void WebMediaPlayerImpl::SetUseFallbackPath(bool use_fallback_path) {
1619 use_fallback_path_ = use_fallback_path;
1620 }
1621
1622 void WebMediaPlayerImpl::SetPoster(const blink::WebURL& poster) { 1618 void WebMediaPlayerImpl::SetPoster(const blink::WebURL& poster) {
1623 cast_impl_.setPoster(poster); 1619 cast_impl_.setPoster(poster);
1624 } 1620 }
1625 #endif // defined(OS_ANDROID) // WMPI_CAST 1621 #endif // defined(OS_ANDROID) // WMPI_CAST
1626 1622
1627 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { 1623 void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
1628 DVLOG(1) << __func__; 1624 DVLOG(1) << __func__;
1629 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1625 DCHECK(main_task_runner_->BelongsToCurrentThread());
1630 1626
1631 #if defined(OS_ANDROID) 1627 #if defined(OS_ANDROID)
1632 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are 1628 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are
1633 // encountered, instruct the HTML media element to create a new WebMediaPlayer 1629 // encountered, instruct the HTML media element to use the MediaPlayerRenderer
1634 // instance with the correct URL to trigger the creation of WMPI with a 1630 // instead.
1635 // MediaPlayerRendererFactory instead.
1636 // 1631 //
1637 // TODO(tguilbert): Allow 'hotswapping' renderer factories to prevent reloads 1632 // TODO(tguilbert): Detect the presence of HLS based on demuxing results,
1638 // and/or rely on demuxer extracted MediaContainerNames. See crbug.com/663503. 1633 // rather than the URL string. See crbug.com/663503.
1639 if (data_source_ && !use_fallback_path_) { 1634 if (data_source_) {
1640 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects(); 1635 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects();
1641 if (MediaCodecUtil::IsHLSURL(url_after_redirects)) { 1636 if (MediaCodecUtil::IsHLSURL(url_after_redirects)) {
1642 client_->RequestReload(url_after_redirects); 1637 renderer_factory_selector_->SetUseMediaPlayer(true);
1643 // |this| may be destructed, do nothing after this.
1644 return;
1645 } 1638 }
1646 } 1639 }
1647 #endif 1640 #endif
1648 1641
1649 if (!success) { 1642 if (!success) {
1650 SetNetworkState(WebMediaPlayer::kNetworkStateFormatError); 1643 SetNetworkState(WebMediaPlayer::kNetworkStateFormatError);
1651 1644
1652 // Not really necessary, since the pipeline was never started, but it at 1645 // Not really necessary, since the pipeline was never started, but it at
1653 // least this makes sure that the error handling code is in sync. 1646 // least this makes sure that the error handling code is in sync.
1654 UpdatePlayState(); 1647 UpdatePlayState();
(...skipping 25 matching lines...) Expand all
1680 else 1673 else
1681 set_surface_cb_.Run(surface_id); 1674 set_surface_cb_.Run(surface_id);
1682 } 1675 }
1683 } 1676 }
1684 1677
1685 void WebMediaPlayerImpl::OnSurfaceRequested( 1678 void WebMediaPlayerImpl::OnSurfaceRequested(
1686 bool decoder_requires_restart_for_overlay, 1679 bool decoder_requires_restart_for_overlay,
1687 const SurfaceCreatedCB& set_surface_cb) { 1680 const SurfaceCreatedCB& set_surface_cb) {
1688 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1681 DCHECK(main_task_runner_->BelongsToCurrentThread());
1689 DCHECK(surface_manager_); 1682 DCHECK(surface_manager_);
1690 DCHECK(!use_fallback_path_);
1691 1683
1692 // A null callback indicates that the decoder is going away. 1684 // A null callback indicates that the decoder is going away.
1693 if (set_surface_cb.is_null()) { 1685 if (set_surface_cb.is_null()) {
1694 decoder_requires_restart_for_overlay_ = false; 1686 decoder_requires_restart_for_overlay_ = false;
1695 set_surface_cb_.Reset(); 1687 set_surface_cb_.Reset();
1696 return; 1688 return;
1697 } 1689 }
1698 1690
1699 // If we get a surface request it means GpuVideoDecoder is initializing, so 1691 // If we get a surface request it means GpuVideoDecoder is initializing, so
1700 // until we get a null surface request, GVD is the active decoder. 1692 // until we get a null surface request, GVD is the active decoder.
(...skipping 29 matching lines...) Expand all
1730 compositor_, request_surface_cb); 1722 compositor_, request_surface_cb);
1731 } 1723 }
1732 1724
1733 void WebMediaPlayerImpl::StartPipeline() { 1725 void WebMediaPlayerImpl::StartPipeline() {
1734 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1726 DCHECK(main_task_runner_->BelongsToCurrentThread());
1735 1727
1736 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 1728 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
1737 BindToCurrentLoop(base::Bind( 1729 BindToCurrentLoop(base::Bind(
1738 &WebMediaPlayerImpl::OnEncryptedMediaInitData, AsWeakPtr())); 1730 &WebMediaPlayerImpl::OnEncryptedMediaInitData, AsWeakPtr()));
1739 1731
1740 if (use_fallback_path_) { 1732 if (renderer_factory_selector_->GetCurrentFactory()
1733 ->GetRequiredMediaResourceType() == MediaResource::Type::URL) {
1734 if (data_source_)
1735 loaded_url_ = data_source_->GetUrlAfterRedirects();
1736
1737 // MediaPlayerRendererClient factory is the only factory that a
1738 // MediaResource::Type::URL for the moment. This might no longer be true
1739 // when we remove WebMediaPlayerCast.
1740 //
1741 // TODO(tguilbert/avayvod): Update this flag when removing |cast_impl_|.
1742 using_media_player_renderer_ = true;
1743
1741 demuxer_.reset( 1744 demuxer_.reset(
1742 new MediaUrlDemuxer(media_task_runner_, fallback_url_, 1745 new MediaUrlDemuxer(media_task_runner_, loaded_url_,
1743 frame_->GetDocument().FirstPartyForCookies())); 1746 frame_->GetDocument().FirstPartyForCookies()));
1744 pipeline_controller_.Start(demuxer_.get(), this, false, false); 1747 pipeline_controller_.Start(demuxer_.get(), this, false, false);
1745 return; 1748 return;
1746 } 1749 }
1747 1750
1748 // Figure out which demuxer to use. 1751 // Figure out which demuxer to use.
1749 if (load_type_ != kLoadTypeMediaSource) { 1752 if (load_type_ != kLoadTypeMediaSource) {
1750 DCHECK(!chunk_demuxer_); 1753 DCHECK(!chunk_demuxer_);
1751 DCHECK(data_source_); 1754 DCHECK(data_source_);
1752 1755
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 2398
2396 if (is_encrypted_) 2399 if (is_encrypted_)
2397 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); 2400 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height);
2398 2401
2399 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); 2402 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height);
2400 } 2403 }
2401 2404
2402 #undef UMA_HISTOGRAM_VIDEO_HEIGHT 2405 #undef UMA_HISTOGRAM_VIDEO_HEIGHT
2403 2406
2404 } // namespace media 2407 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698