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

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

Issue 533543004: WebMediaPlayerImpl should notify ended event Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months 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
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 return seeking_; 430 return seeking_;
431 } 431 }
432 432
433 double WebMediaPlayerImpl::duration() const { 433 double WebMediaPlayerImpl::duration() const {
434 DCHECK(main_task_runner_->BelongsToCurrentThread()); 434 DCHECK(main_task_runner_->BelongsToCurrentThread());
435 435
436 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) 436 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
437 return std::numeric_limits<double>::quiet_NaN(); 437 return std::numeric_limits<double>::quiet_NaN();
438 438
439 if (ended_)
440 return currentTime();
441
439 return GetPipelineDuration(); 442 return GetPipelineDuration();
440 } 443 }
441 444
442 double WebMediaPlayerImpl::timelineOffset() const { 445 double WebMediaPlayerImpl::timelineOffset() const {
443 DCHECK(main_task_runner_->BelongsToCurrentThread()); 446 DCHECK(main_task_runner_->BelongsToCurrentThread());
444 447
445 if (pipeline_metadata_.timeline_offset.is_null()) 448 if (pipeline_metadata_.timeline_offset.is_null())
446 return std::numeric_limits<double>::quiet_NaN(); 449 return std::numeric_limits<double>::quiet_NaN();
447 450
448 return pipeline_metadata_.timeline_offset.ToJsTime(); 451 return pipeline_metadata_.timeline_offset.ToJsTime();
449 } 452 }
450 453
451 double WebMediaPlayerImpl::currentTime() const { 454 double WebMediaPlayerImpl::currentTime() const {
452 DCHECK(main_task_runner_->BelongsToCurrentThread()); 455 DCHECK(main_task_runner_->BelongsToCurrentThread());
453 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 456 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
454 457
455 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement,
456 // see http://crbug.com/409280
457 if (ended_)
458 return duration();
459
460 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF(); 458 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF();
461 } 459 }
462 460
463 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const { 461 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const {
464 DCHECK(main_task_runner_->BelongsToCurrentThread()); 462 DCHECK(main_task_runner_->BelongsToCurrentThread());
465 return network_state_; 463 return network_state_;
466 } 464 }
467 465
468 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const { 466 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const {
469 DCHECK(main_task_runner_->BelongsToCurrentThread()); 467 DCHECK(main_task_runner_->BelongsToCurrentThread());
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 709
712 void WebMediaPlayerImpl::OnPipelineEnded() { 710 void WebMediaPlayerImpl::OnPipelineEnded() {
713 DVLOG(1) << __FUNCTION__; 711 DVLOG(1) << __FUNCTION__;
714 DCHECK(main_task_runner_->BelongsToCurrentThread()); 712 DCHECK(main_task_runner_->BelongsToCurrentThread());
715 713
716 // Ignore state changes until we've completed all outstanding seeks. 714 // Ignore state changes until we've completed all outstanding seeks.
717 if (seeking_ || pending_seek_) 715 if (seeking_ || pending_seek_)
718 return; 716 return;
719 717
720 ended_ = true; 718 ended_ = true;
721 client_->timeChanged(); 719
720 // If the duration in the metadata is not correct, then actual duration should
721 // be updated in blink.
722 client_->durationChanged();
723 client_->mediaEnded();
722 } 724 }
723 725
724 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { 726 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) {
725 DCHECK(main_task_runner_->BelongsToCurrentThread()); 727 DCHECK(main_task_runner_->BelongsToCurrentThread());
726 DCHECK_NE(error, PIPELINE_OK); 728 DCHECK_NE(error, PIPELINE_OK);
727 729
728 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { 730 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) {
729 // Any error that occurs before reaching ReadyStateHaveMetadata should 731 // Any error that occurs before reaching ReadyStateHaveMetadata should
730 // be considered a format error. 732 // be considered a format error.
731 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); 733 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 compositor_task_runner_->PostTask(FROM_HERE, 1031 compositor_task_runner_->PostTask(FROM_HERE,
1030 base::Bind(&GetCurrentFrameAndSignal, 1032 base::Bind(&GetCurrentFrameAndSignal,
1031 base::Unretained(compositor_), 1033 base::Unretained(compositor_),
1032 &video_frame, 1034 &video_frame,
1033 &event)); 1035 &event));
1034 event.Wait(); 1036 event.Wait();
1035 return video_frame; 1037 return video_frame;
1036 } 1038 }
1037 1039
1038 } // namespace media 1040 } // namespace media
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698