| 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/filters/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| (...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 return source_state_map_.count(source_id) > 0u; | 1543 return source_state_map_.count(source_id) > 0u; |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 void ChunkDemuxer::UpdateDuration(TimeDelta new_duration) { | 1546 void ChunkDemuxer::UpdateDuration(TimeDelta new_duration) { |
| 1547 DCHECK(duration_ != new_duration); | 1547 DCHECK(duration_ != new_duration); |
| 1548 user_specified_duration_ = -1; | 1548 user_specified_duration_ = -1; |
| 1549 duration_ = new_duration; | 1549 duration_ = new_duration; |
| 1550 host_->SetDuration(new_duration); | 1550 host_->SetDuration(new_duration); |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 void ChunkDemuxer::IncreaseDurationIfNecessary( | 1553 void ChunkDemuxer::IncreaseDurationIfNecessary(TimeDelta new_duration) { |
| 1554 TimeDelta last_appended_buffer_timestamp, | 1554 DCHECK(new_duration != kNoTimestamp()); |
| 1555 ChunkDemuxerStream* stream) { | 1555 |
| 1556 DCHECK(last_appended_buffer_timestamp != kNoTimestamp()); | 1556 if (new_duration <= duration_) |
| 1557 if (last_appended_buffer_timestamp <= duration_) | |
| 1558 return; | 1557 return; |
| 1559 | 1558 |
| 1560 TimeDelta stream_duration = stream->GetBufferedDuration(); | 1559 DVLOG(2) << __FUNCTION__ << ": Increasing duration: " |
| 1561 DCHECK(stream_duration > TimeDelta()); | 1560 << duration_.InSecondsF() << " -> " << new_duration.InSecondsF(); |
| 1562 | 1561 |
| 1563 if (stream_duration > duration_) | 1562 UpdateDuration(new_duration); |
| 1564 UpdateDuration(stream_duration); | |
| 1565 } | 1563 } |
| 1566 | 1564 |
| 1567 void ChunkDemuxer::DecreaseDurationIfNecessary() { | 1565 void ChunkDemuxer::DecreaseDurationIfNecessary() { |
| 1568 lock_.AssertAcquired(); | 1566 lock_.AssertAcquired(); |
| 1569 | 1567 |
| 1570 TimeDelta max_duration; | 1568 TimeDelta max_duration; |
| 1571 | 1569 |
| 1572 for (SourceStateMap::const_iterator itr = source_state_map_.begin(); | 1570 for (SourceStateMap::const_iterator itr = source_state_map_.begin(); |
| 1573 itr != source_state_map_.end(); ++itr) { | 1571 itr != source_state_map_.end(); ++itr) { |
| 1574 max_duration = std::max(max_duration, | 1572 max_duration = std::max(max_duration, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 } | 1629 } |
| 1632 | 1630 |
| 1633 void ChunkDemuxer::ShutdownAllStreams() { | 1631 void ChunkDemuxer::ShutdownAllStreams() { |
| 1634 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1632 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
| 1635 itr != source_state_map_.end(); ++itr) { | 1633 itr != source_state_map_.end(); ++itr) { |
| 1636 itr->second->Shutdown(); | 1634 itr->second->Shutdown(); |
| 1637 } | 1635 } |
| 1638 } | 1636 } |
| 1639 | 1637 |
| 1640 } // namespace media | 1638 } // namespace media |
| OLD | NEW |