Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 base::Bind( | 155 base::Bind( |
| 156 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); | 156 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 TimeDelta Pipeline::GetMediaTime() const { | 160 TimeDelta Pipeline::GetMediaTime() const { |
| 161 base::AutoLock auto_lock(lock_); | 161 base::AutoLock auto_lock(lock_); |
| 162 if (!renderer_) | 162 if (!renderer_) |
| 163 return TimeDelta(); | 163 return TimeDelta(); |
| 164 | 164 |
| 165 // FIXME: In some cases GetMediaTime() returns a value few milli seconds | |
|
DaleCurtis
2014/12/01 19:33:48
In chromium code the syntax is "TODO(<your user na
Srirama
2014/12/02 11:16:29
Done.
| |
| 166 // less than duration even though playback has ended. | |
| 165 TimeDelta media_time = renderer_->GetMediaTime(); | 167 TimeDelta media_time = renderer_->GetMediaTime(); |
| 168 if (renderer_ended_ && media_time < duration_) { | |
| 169 if ((duration_ - media_time).ToInternalValue() <= 250000) | |
|
DaleCurtis
2014/12/01 19:33:48
Note: Use InMilliseconds() not ToInternalValue().
Srirama
2014/12/02 11:16:29
Done.
| |
| 170 return duration_; | |
| 171 } | |
| 166 return std::min(media_time, duration_); | 172 return std::min(media_time, duration_); |
| 167 } | 173 } |
| 168 | 174 |
| 169 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { | 175 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { |
| 170 base::AutoLock auto_lock(lock_); | 176 base::AutoLock auto_lock(lock_); |
| 171 return buffered_time_ranges_; | 177 return buffered_time_ranges_; |
| 172 } | 178 } |
| 173 | 179 |
| 174 TimeDelta Pipeline::GetMediaDuration() const { | 180 TimeDelta Pipeline::GetMediaDuration() const { |
| 175 base::AutoLock auto_lock(lock_); | 181 base::AutoLock auto_lock(lock_); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 | 633 |
| 628 void Pipeline::RunEndedCallbackIfNeeded() { | 634 void Pipeline::RunEndedCallbackIfNeeded() { |
| 629 DCHECK(task_runner_->BelongsToCurrentThread()); | 635 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 630 | 636 |
| 631 if (renderer_ && !renderer_ended_) | 637 if (renderer_ && !renderer_ended_) |
| 632 return; | 638 return; |
| 633 | 639 |
| 634 if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_) | 640 if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_) |
| 635 return; | 641 return; |
| 636 | 642 |
| 643 // Correct the duration if current time is less | |
| 644 TimeDelta media_time = renderer_->GetMediaTime(); | |
| 645 if (media_time < duration_) { | |
| 646 if ((duration_ - media_time).ToInternalValue() > 250000) | |
| 647 SetDuration(media_time); | |
| 648 } | |
| 637 DCHECK_EQ(status_, PIPELINE_OK); | 649 DCHECK_EQ(status_, PIPELINE_OK); |
| 638 ended_cb_.Run(); | 650 ended_cb_.Run(); |
| 639 } | 651 } |
| 640 | 652 |
| 641 scoped_ptr<TextRenderer> Pipeline::CreateTextRenderer() { | 653 scoped_ptr<TextRenderer> Pipeline::CreateTextRenderer() { |
| 642 DCHECK(task_runner_->BelongsToCurrentThread()); | 654 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 643 | 655 |
| 644 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 656 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 645 if (!cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) | 657 if (!cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) |
| 646 return scoped_ptr<media::TextRenderer>(); | 658 return scoped_ptr<media::TextRenderer>(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 metadata_cb_.Run(metadata); | 725 metadata_cb_.Run(metadata); |
| 714 } | 726 } |
| 715 | 727 |
| 716 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { | 728 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { |
| 717 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; | 729 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; |
| 718 DCHECK(task_runner_->BelongsToCurrentThread()); | 730 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 719 buffering_state_cb_.Run(new_buffering_state); | 731 buffering_state_cb_.Run(new_buffering_state); |
| 720 } | 732 } |
| 721 | 733 |
| 722 } // namespace media | 734 } // namespace media |
| OLD | NEW |