Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1415683009: Support earliest seekable time in WMPI. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more androidfixes. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 bool WebMediaPlayerImpl::seeking() const { 482 bool WebMediaPlayerImpl::seeking() const {
483 DCHECK(main_task_runner_->BelongsToCurrentThread()); 483 DCHECK(main_task_runner_->BelongsToCurrentThread());
484 484
485 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) 485 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
486 return false; 486 return false;
487 487
488 return seeking_; 488 return seeking_;
489 } 489 }
490 490
491 double WebMediaPlayerImpl::earliestTime() const {
492 return pipeline_.GetMediaStartTime().InSecondsF();
493 }
494
491 double WebMediaPlayerImpl::duration() const { 495 double WebMediaPlayerImpl::duration() const {
492 DCHECK(main_task_runner_->BelongsToCurrentThread()); 496 DCHECK(main_task_runner_->BelongsToCurrentThread());
493 497
494 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) 498 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
495 return std::numeric_limits<double>::quiet_NaN(); 499 return std::numeric_limits<double>::quiet_NaN();
496 500
497 return GetPipelineDuration(); 501 return GetPipelineDuration();
498 } 502 }
499 503
500 double WebMediaPlayerImpl::timelineOffset() const { 504 double WebMediaPlayerImpl::timelineOffset() const {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 553 }
550 return ConvertToWebTimeRanges(buffered_time_ranges); 554 return ConvertToWebTimeRanges(buffered_time_ranges);
551 } 555 }
552 556
553 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const { 557 blink::WebTimeRanges WebMediaPlayerImpl::seekable() const {
554 DCHECK(main_task_runner_->BelongsToCurrentThread()); 558 DCHECK(main_task_runner_->BelongsToCurrentThread());
555 559
556 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata) 560 if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata)
557 return blink::WebTimeRanges(); 561 return blink::WebTimeRanges();
558 562
563 const double seekable_start = pipeline_.GetMediaStartTime().InSecondsF();
559 const double seekable_end = duration(); 564 const double seekable_end = duration();
560 565
561 // Allow a special exception for seeks to zero for streaming sources with a 566 // Allow a special exception for seeks to zero for streaming sources with a
562 // finite duration; this allows looping to work. 567 // finite duration; this allows looping to work.
563 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() && 568 const bool allow_seek_to_zero = data_source_ && data_source_->IsStreaming() &&
564 std::isfinite(seekable_end); 569 std::isfinite(seekable_end);
565 570
566 // TODO(dalecurtis): Technically this allows seeking on media which return an 571 // TODO(dalecurtis): Technically this allows seeking on media which return an
567 // infinite duration so long as DataSource::IsStreaming() is false. While not 572 // infinite duration so long as DataSource::IsStreaming() is false. While not
568 // expected, disabling this breaks semi-live players, http://crbug.com/427412. 573 // expected, disabling this breaks semi-live players, http://crbug.com/427412.
569 const blink::WebTimeRange seekable_range( 574 const blink::WebTimeRange seekable_range(
570 0.0, allow_seek_to_zero ? 0.0 : seekable_end); 575 allow_seek_to_zero ? 0.0 : seekable_start,
576 allow_seek_to_zero ? 0.0 : seekable_end);
571 return blink::WebTimeRanges(&seekable_range, 1); 577 return blink::WebTimeRanges(&seekable_range, 1);
572 } 578 }
573 579
574 bool WebMediaPlayerImpl::didLoadingProgress() { 580 bool WebMediaPlayerImpl::didLoadingProgress() {
575 DCHECK(main_task_runner_->BelongsToCurrentThread()); 581 DCHECK(main_task_runner_->BelongsToCurrentThread());
576 bool pipeline_progress = pipeline_.DidLoadingProgress(); 582 bool pipeline_progress = pipeline_.DidLoadingProgress();
577 bool data_progress = buffered_data_source_host_.DidLoadingProgress(); 583 bool data_progress = buffered_data_source_host_.DidLoadingProgress();
578 return pipeline_progress || data_progress; 584 return pipeline_progress || data_progress;
579 } 585 }
580 586
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1112 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1107 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1113 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1108 << ", Demuxer: " << (demuxer_ ? demuxer_->GetMemoryUsage() : 0); 1114 << ", Demuxer: " << (demuxer_ ? demuxer_->GetMemoryUsage() : 0);
1109 1115
1110 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1116 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1111 last_reported_memory_usage_ = current_memory_usage; 1117 last_reported_memory_usage_ = current_memory_usage;
1112 adjust_allocated_memory_cb_.Run(delta); 1118 adjust_allocated_memory_cb_.Run(delta);
1113 } 1119 }
1114 1120
1115 } // namespace media 1121 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698