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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 471 } |
472 | 472 |
473 blink::WebTimeRanges WebMediaPlayerImpl::buffered() const { | 473 blink::WebTimeRanges WebMediaPlayerImpl::buffered() const { |
474 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 474 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
475 | 475 |
476 Ranges<base::TimeDelta> buffered_time_ranges = | 476 Ranges<base::TimeDelta> buffered_time_ranges = |
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 // Demuxed ranges are not useful for a streaming resource, since we can't |
482 &buffered_time_ranges, duration); | 482 // actually seek to those points unless they're cached. Instead report |
| 483 // buffered() based on the lowest cached byte range. |
| 484 // |
| 485 // Technically we could do this for non-streaming resources too since we're |
| 486 // caching the same amount for them, but the returned range will be shown on |
| 487 // the controls and historically there's been outcry when gaps are shown. |
| 488 if (data_source_ && data_source_->IsStreaming()) { |
| 489 Ranges<base::TimeDelta> cached_ranges; |
| 490 buffered_data_source_host_.AddBufferedTimeRanges(&cached_ranges, |
| 491 duration); |
| 492 buffered_time_ranges = |
| 493 buffered_time_ranges.IntersectionWith(cached_ranges); |
| 494 } else { |
| 495 buffered_data_source_host_.AddBufferedTimeRanges(&buffered_time_ranges, |
| 496 duration); |
| 497 } |
483 } | 498 } |
| 499 |
484 return ConvertToWebTimeRanges(buffered_time_ranges); | 500 return ConvertToWebTimeRanges(buffered_time_ranges); |
485 } | 501 } |
486 | 502 |
487 double WebMediaPlayerImpl::maxTimeSeekable() const { | 503 double WebMediaPlayerImpl::maxTimeSeekable() const { |
488 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 504 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
489 | 505 |
490 // If we haven't even gotten to ReadyStateHaveMetadata yet then just | 506 // If we haven't even gotten to ReadyStateHaveMetadata yet then just |
491 // return 0 so that the seekable range is empty. | 507 // return 0 so that the seekable range is empty. |
492 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) | 508 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) |
493 return 0.0; | 509 return 0.0; |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 compositor_task_runner_->PostTask(FROM_HERE, | 1045 compositor_task_runner_->PostTask(FROM_HERE, |
1030 base::Bind(&GetCurrentFrameAndSignal, | 1046 base::Bind(&GetCurrentFrameAndSignal, |
1031 base::Unretained(compositor_), | 1047 base::Unretained(compositor_), |
1032 &video_frame, | 1048 &video_frame, |
1033 &event)); | 1049 &event)); |
1034 event.Wait(); | 1050 event.Wait(); |
1035 return video_frame; | 1051 return video_frame; |
1036 } | 1052 } |
1037 | 1053 |
1038 } // namespace media | 1054 } // namespace media |
OLD | NEW |