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 <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/debug/crash_logging.h" | 16 #include "base/debug/crash_logging.h" |
17 #include "base/debug/trace_event.h" | 17 #include "base/debug/trace_event.h" |
| 18 #include "base/float_util.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 19 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
22 #include "cc/blink/web_layer_impl.h" | 23 #include "cc/blink/web_layer_impl.h" |
23 #include "cc/layers/video_layer.h" | 24 #include "cc/layers/video_layer.h" |
24 #include "gpu/GLES2/gl2extchromium.h" | 25 #include "gpu/GLES2/gl2extchromium.h" |
25 #include "gpu/command_buffer/common/mailbox_holder.h" | 26 #include "gpu/command_buffer/common/mailbox_holder.h" |
26 #include "media/audio/null_audio_sink.h" | 27 #include "media/audio/null_audio_sink.h" |
27 #include "media/base/audio_hardware_config.h" | 28 #include "media/base/audio_hardware_config.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 if (duration != kInfiniteDuration()) { | 481 if (duration != kInfiniteDuration()) { |
481 buffered_data_source_host_.AddBufferedTimeRanges( | 482 buffered_data_source_host_.AddBufferedTimeRanges( |
482 &buffered_time_ranges, duration); | 483 &buffered_time_ranges, duration); |
483 } | 484 } |
484 return ConvertToWebTimeRanges(buffered_time_ranges); | 485 return ConvertToWebTimeRanges(buffered_time_ranges); |
485 } | 486 } |
486 | 487 |
487 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const { | 488 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const { |
488 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 489 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
489 | 490 |
490 // If we haven't even gotten to ReadyStateHaveMetadata yet then there | 491 // Media without duration are considered streaming and should not be seekable. |
491 // are no seekable ranges. | 492 const double seekable_end = duration(); |
492 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 493 if (!base::IsFinite(seekable_end)) |
493 return blink::WebTimeRanges(); | 494 return blink::WebTimeRanges(); |
494 | 495 |
495 // We don't support seeking in streaming media. | 496 // If we have a finite duration then use [0, duration] as the seekable range; |
496 if (data_source_ && data_source_->IsStreaming()) | 497 // unless it's a streaming source, in which case only allow a seek to zero. |
497 return blink::WebTimeRanges(); | 498 blink::WebTimeRange seekable_range( |
498 | 499 0.0, data_source_ && data_source_->IsStreaming() ? 0.0 : seekable_end); |
499 // If we have a duration then use [0, duration] as the seekable range. | |
500 const double seekable_end = duration(); | |
501 if (!seekable_end) | |
502 return blink::WebTimeRanges(); | |
503 | |
504 blink::WebTimeRange seekable_range(0.0, seekable_end); | |
505 return blink::WebTimeRanges(&seekable_range, 1); | 500 return blink::WebTimeRanges(&seekable_range, 1); |
506 } | 501 } |
507 | 502 |
508 bool WebMediaPlayerImpl::didLoadingProgress() { | 503 bool WebMediaPlayerImpl::didLoadingProgress() { |
509 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 504 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
510 bool pipeline_progress = pipeline_.DidLoadingProgress(); | 505 bool pipeline_progress = pipeline_.DidLoadingProgress(); |
511 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); | 506 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); |
512 return pipeline_progress || data_progress; | 507 return pipeline_progress || data_progress; |
513 } | 508 } |
514 | 509 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 compositor_task_runner_->PostTask(FROM_HERE, | 1021 compositor_task_runner_->PostTask(FROM_HERE, |
1027 base::Bind(&GetCurrentFrameAndSignal, | 1022 base::Bind(&GetCurrentFrameAndSignal, |
1028 base::Unretained(compositor_), | 1023 base::Unretained(compositor_), |
1029 &video_frame, | 1024 &video_frame, |
1030 &event)); | 1025 &event)); |
1031 event.Wait(); | 1026 event.Wait(); |
1032 return video_frame; | 1027 return video_frame; |
1033 } | 1028 } |
1034 | 1029 |
1035 } // namespace media | 1030 } // namespace media |
OLD | NEW |