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