OLD | NEW |
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 <limits> | 9 #include <limits> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
15 #include "base/debug/alias.h" | 16 #include "base/debug/alias.h" |
16 #include "base/debug/crash_logging.h" | 17 #include "base/debug/crash_logging.h" |
17 #include "base/float_util.h" | |
18 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
21 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
23 #include "cc/blink/web_layer_impl.h" | 23 #include "cc/blink/web_layer_impl.h" |
24 #include "cc/layers/video_layer.h" | 24 #include "cc/layers/video_layer.h" |
25 #include "gpu/blink/webgraphicscontext3d_impl.h" | 25 #include "gpu/blink/webgraphicscontext3d_impl.h" |
26 #include "media/audio/null_audio_sink.h" | 26 #include "media/audio/null_audio_sink.h" |
27 #include "media/base/bind_to_current_loop.h" | 27 #include "media/base/bind_to_current_loop.h" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 477 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
478 | 478 |
479 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 479 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
480 return blink::WebTimeRanges(); | 480 return blink::WebTimeRanges(); |
481 | 481 |
482 const double seekable_end = duration(); | 482 const double seekable_end = duration(); |
483 | 483 |
484 // Allow a special exception for seeks to zero for streaming sources with a | 484 // Allow a special exception for seeks to zero for streaming sources with a |
485 // finite duration; this allows looping to work. | 485 // finite duration; this allows looping to work. |
486 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() && | 486 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() && |
487 base::IsFinite(seekable_end); | 487 std::isfinite(seekable_end); |
488 | 488 |
489 // TODO(dalecurtis): Technically this allows seeking on media which return an | 489 // TODO(dalecurtis): Technically this allows seeking on media which return an |
490 // infinite duration so long as DataSource::IsStreaming() is false. While not | 490 // infinite duration so long as DataSource::IsStreaming() is false. While not |
491 // expected, disabling this breaks semi-live players, http://crbug.com/427412. | 491 // expected, disabling this breaks semi-live players, http://crbug.com/427412. |
492 const blink::WebTimeRange seekable_range( | 492 const blink::WebTimeRange seekable_range( |
493 0.0, allow_seek_to_zero ? 0.0 : seekable_end); | 493 0.0, allow_seek_to_zero ? 0.0 : seekable_end); |
494 return blink::WebTimeRanges(&seekable_range, 1); | 494 return blink::WebTimeRanges(&seekable_range, 1); |
495 } | 495 } |
496 | 496 |
497 bool WebMediaPlayerImpl::didLoadingProgress() { | 497 bool WebMediaPlayerImpl::didLoadingProgress() { |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 // pause() may be called after playback has ended and the HTMLMediaElement | 1022 // pause() may be called after playback has ended and the HTMLMediaElement |
1023 // requires that currentTime() == duration() after ending. We want to ensure | 1023 // requires that currentTime() == duration() after ending. We want to ensure |
1024 // |paused_time_| matches currentTime() in this case or a future seek() may | 1024 // |paused_time_| matches currentTime() in this case or a future seek() may |
1025 // incorrectly discard what it thinks is a seek to the existing time. | 1025 // incorrectly discard what it thinks is a seek to the existing time. |
1026 paused_time_ = | 1026 paused_time_ = |
1027 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1027 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
1028 } | 1028 } |
1029 | 1029 |
1030 } // namespace media | 1030 } // namespace media |
OLD | NEW |