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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 479 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
480 | 480 |
481 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 481 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
482 return blink::WebTimeRanges(); | 482 return blink::WebTimeRanges(); |
483 | 483 |
484 const double seekable_end = duration(); | 484 const double seekable_end = duration(); |
485 | 485 |
486 // Allow a special exception for seeks to zero for streaming sources with a | 486 // Allow a special exception for seeks to zero for streaming sources with a |
487 // finite duration; this allows looping to work. | 487 // finite duration; this allows looping to work. |
488 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() && | 488 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() && |
489 base::IsFinite(seekable_end); | 489 std::isfinite(seekable_end); |
490 | 490 |
491 // TODO(dalecurtis): Technically this allows seeking on media which return an | 491 // TODO(dalecurtis): Technically this allows seeking on media which return an |
492 // infinite duration so long as DataSource::IsStreaming() is false. While not | 492 // infinite duration so long as DataSource::IsStreaming() is false. While not |
493 // expected, disabling this breaks semi-live players, http://crbug.com/427412. | 493 // expected, disabling this breaks semi-live players, http://crbug.com/427412. |
494 const blink::WebTimeRange seekable_range( | 494 const blink::WebTimeRange seekable_range( |
495 0.0, allow_seek_to_zero ? 0.0 : seekable_end); | 495 0.0, allow_seek_to_zero ? 0.0 : seekable_end); |
496 return blink::WebTimeRanges(&seekable_range, 1); | 496 return blink::WebTimeRanges(&seekable_range, 1); |
497 } | 497 } |
498 | 498 |
499 bool WebMediaPlayerImpl::didLoadingProgress() { | 499 bool WebMediaPlayerImpl::didLoadingProgress() { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1013 |
1014 // pause() may be called after playback has ended and the HTMLMediaElement | 1014 // pause() may be called after playback has ended and the HTMLMediaElement |
1015 // requires that currentTime() == duration() after ending. We want to ensure | 1015 // requires that currentTime() == duration() after ending. We want to ensure |
1016 // |paused_time_| matches currentTime() in this case or a future seek() may | 1016 // |paused_time_| matches currentTime() in this case or a future seek() may |
1017 // incorrectly discard what it thinks is a seek to the existing time. | 1017 // incorrectly discard what it thinks is a seek to the existing time. |
1018 paused_time_ = | 1018 paused_time_ = |
1019 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1019 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
1020 } | 1020 } |
1021 | 1021 |
1022 } // namespace media | 1022 } // namespace media |
OLD | NEW |