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> |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 pipeline_.GetBufferedTimeRanges(); | 477 pipeline_.GetBufferedTimeRanges(); |
478 | 478 |
479 const base::TimeDelta duration = pipeline_.GetMediaDuration(); | 479 const base::TimeDelta duration = pipeline_.GetMediaDuration(); |
480 if (duration != kInfiniteDuration()) { | 480 if (duration != kInfiniteDuration()) { |
481 buffered_data_source_host_.AddBufferedTimeRanges( | 481 buffered_data_source_host_.AddBufferedTimeRanges( |
482 &buffered_time_ranges, duration); | 482 &buffered_time_ranges, duration); |
483 } | 483 } |
484 return ConvertToWebTimeRanges(buffered_time_ranges); | 484 return ConvertToWebTimeRanges(buffered_time_ranges); |
485 } | 485 } |
486 | 486 |
487 double WebMediaPlayerImpl::maxTimeSeekable() const { | 487 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const { |
488 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 488 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
489 | 489 |
490 // If we haven't even gotten to ReadyStateHaveMetadata yet then just | 490 // If we haven't even gotten to ReadyStateHaveMetadata yet then there |
491 // return 0 so that the seekable range is empty. | 491 // are no seekable ranges. |
492 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 492 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
493 return 0.0; | 493 return blink::WebTimeRanges(); |
494 | 494 |
495 // We don't support seeking in streaming media. | 495 // We don't support seeking in streaming media. |
496 if (data_source_ && data_source_->IsStreaming()) | 496 if (data_source_ && data_source_->IsStreaming()) |
497 return 0.0; | 497 return blink::WebTimeRanges(); |
498 return duration(); | 498 |
| 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); |
499 } | 506 } |
500 | 507 |
501 bool WebMediaPlayerImpl::didLoadingProgress() { | 508 bool WebMediaPlayerImpl::didLoadingProgress() { |
502 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 509 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
503 bool pipeline_progress = pipeline_.DidLoadingProgress(); | 510 bool pipeline_progress = pipeline_.DidLoadingProgress(); |
504 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); | 511 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); |
505 return pipeline_progress || data_progress; | 512 return pipeline_progress || data_progress; |
506 } | 513 } |
507 | 514 |
508 void WebMediaPlayerImpl::paint(blink::WebCanvas* canvas, | 515 void WebMediaPlayerImpl::paint(blink::WebCanvas* canvas, |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 compositor_task_runner_->PostTask(FROM_HERE, | 1029 compositor_task_runner_->PostTask(FROM_HERE, |
1023 base::Bind(&GetCurrentFrameAndSignal, | 1030 base::Bind(&GetCurrentFrameAndSignal, |
1024 base::Unretained(compositor_), | 1031 base::Unretained(compositor_), |
1025 &video_frame, | 1032 &video_frame, |
1026 &event)); | 1033 &event)); |
1027 event.Wait(); | 1034 event.Wait(); |
1028 return video_frame; | 1035 return video_frame; |
1029 } | 1036 } |
1030 | 1037 |
1031 } // namespace media | 1038 } // namespace media |
OLD | NEW |