| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 646 |
| 647 void Pipeline::RunEndedCallbackIfNeeded() { | 647 void Pipeline::RunEndedCallbackIfNeeded() { |
| 648 DCHECK(task_runner_->BelongsToCurrentThread()); | 648 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 649 | 649 |
| 650 if (renderer_ && !renderer_ended_) | 650 if (renderer_ && !renderer_ended_) |
| 651 return; | 651 return; |
| 652 | 652 |
| 653 if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_) | 653 if (text_renderer_ && text_renderer_->HasTracks() && !text_renderer_ended_) |
| 654 return; | 654 return; |
| 655 | 655 |
| 656 // Correct the duration against current time if it turns out that | |
| 657 // the initially reported duration is wrong | |
| 658 // TODO(sriram): There are cases where duration is correct and current time | |
| 659 // falls short of duration by a few milliseconds. This is a workaround | |
| 660 // till we find the actual fix and 250ms is chosen here as it is | |
| 661 // the max time between timeupdate events (http://crbug.com/438581). | |
| 662 TimeDelta media_time = renderer_->GetMediaTime(); | |
| 663 if ((duration_ - media_time).InMilliseconds() > 250) | |
| 664 SetDuration(media_time); | |
| 665 | |
| 666 DCHECK_EQ(status_, PIPELINE_OK); | 656 DCHECK_EQ(status_, PIPELINE_OK); |
| 667 ended_cb_.Run(); | 657 ended_cb_.Run(); |
| 668 } | 658 } |
| 669 | 659 |
| 670 scoped_ptr<TextRenderer> Pipeline::CreateTextRenderer() { | 660 scoped_ptr<TextRenderer> Pipeline::CreateTextRenderer() { |
| 671 DCHECK(task_runner_->BelongsToCurrentThread()); | 661 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 672 | 662 |
| 673 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 663 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 674 if (!cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) | 664 if (!cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) |
| 675 return scoped_ptr<media::TextRenderer>(); | 665 return scoped_ptr<media::TextRenderer>(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 metadata_cb_.Run(metadata); | 736 metadata_cb_.Run(metadata); |
| 747 } | 737 } |
| 748 | 738 |
| 749 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { | 739 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { |
| 750 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; | 740 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; |
| 751 DCHECK(task_runner_->BelongsToCurrentThread()); | 741 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 752 buffering_state_cb_.Run(new_buffering_state); | 742 buffering_state_cb_.Run(new_buffering_state); |
| 753 } | 743 } |
| 754 | 744 |
| 755 } // namespace media | 745 } // namespace media |
| OLD | NEW |