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

Side by Side Diff: media/filters/source_buffer_stream.cc

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Created 7 years, 5 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
OLDNEW
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/source_buffer_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 1338
1339 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) { 1339 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) {
1340 DCHECK(buffers_.empty() || 1340 DCHECK(buffers_.empty() ||
1341 buffers_.back()->GetDecodeTimestamp() <= 1341 buffers_.back()->GetDecodeTimestamp() <=
1342 new_buffers.front()->GetDecodeTimestamp()); 1342 new_buffers.front()->GetDecodeTimestamp());
1343 1343
1344 for (BufferQueue::const_iterator itr = new_buffers.begin(); 1344 for (BufferQueue::const_iterator itr = new_buffers.begin();
1345 itr != new_buffers.end(); ++itr) { 1345 itr != new_buffers.end(); ++itr) {
1346 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp()); 1346 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp());
1347 buffers_.push_back(*itr); 1347 buffers_.push_back(*itr);
1348 size_in_bytes_ += (*itr)->GetDataSize(); 1348 size_in_bytes_ += (*itr)->data_size();
1349 1349
1350 if ((*itr)->IsKeyframe()) { 1350 if ((*itr)->IsKeyframe()) {
1351 keyframe_map_.insert( 1351 keyframe_map_.insert(
1352 std::make_pair((*itr)->GetDecodeTimestamp(), 1352 std::make_pair((*itr)->GetDecodeTimestamp(),
1353 buffers_.size() - 1 + keyframe_map_index_base_)); 1353 buffers_.size() - 1 + keyframe_map_index_base_));
1354 } 1354 }
1355 } 1355 }
1356 } 1356 }
1357 1357
1358 void SourceBufferRange::Seek(base::TimeDelta timestamp) { 1358 void SourceBufferRange::Seek(base::TimeDelta timestamp) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 1495
1496 // Now we need to delete all the buffers that depend on the keyframe we've 1496 // Now we need to delete all the buffers that depend on the keyframe we've
1497 // just deleted. 1497 // just deleted.
1498 int end_index = keyframe_map_.size() > 0 ? 1498 int end_index = keyframe_map_.size() > 0 ?
1499 keyframe_map_.begin()->second - keyframe_map_index_base_ : 1499 keyframe_map_.begin()->second - keyframe_map_index_base_ :
1500 buffers_.size(); 1500 buffers_.size();
1501 1501
1502 // Delete buffers from the beginning of the buffered range up until (but not 1502 // Delete buffers from the beginning of the buffered range up until (but not
1503 // including) the next keyframe. 1503 // including) the next keyframe.
1504 for (int i = 0; i < end_index; i++) { 1504 for (int i = 0; i < end_index; i++) {
1505 int bytes_deleted = buffers_.front()->GetDataSize(); 1505 int bytes_deleted = buffers_.front()->data_size();
1506 size_in_bytes_ -= bytes_deleted; 1506 size_in_bytes_ -= bytes_deleted;
1507 total_bytes_deleted += bytes_deleted; 1507 total_bytes_deleted += bytes_deleted;
1508 deleted_buffers->push_back(buffers_.front()); 1508 deleted_buffers->push_back(buffers_.front());
1509 buffers_.pop_front(); 1509 buffers_.pop_front();
1510 ++buffers_deleted; 1510 ++buffers_deleted;
1511 } 1511 }
1512 1512
1513 // Update |keyframe_map_index_base_| to account for the deleted buffers. 1513 // Update |keyframe_map_index_base_| to account for the deleted buffers.
1514 keyframe_map_index_base_ += buffers_deleted; 1514 keyframe_map_index_base_ += buffers_deleted;
1515 1515
(...skipping 19 matching lines...) Expand all
1535 DCHECK_GT(keyframe_map_.size(), 0u); 1535 DCHECK_GT(keyframe_map_.size(), 0u);
1536 --back; 1536 --back;
1537 1537
1538 // The index of the first buffer in the last GOP is equal to the new size of 1538 // The index of the first buffer in the last GOP is equal to the new size of
1539 // |buffers_| after that GOP is deleted. 1539 // |buffers_| after that GOP is deleted.
1540 size_t goal_size = back->second - keyframe_map_index_base_; 1540 size_t goal_size = back->second - keyframe_map_index_base_;
1541 keyframe_map_.erase(back); 1541 keyframe_map_.erase(back);
1542 1542
1543 int total_bytes_deleted = 0; 1543 int total_bytes_deleted = 0;
1544 while (buffers_.size() != goal_size) { 1544 while (buffers_.size() != goal_size) {
1545 int bytes_deleted = buffers_.back()->GetDataSize(); 1545 int bytes_deleted = buffers_.back()->data_size();
1546 size_in_bytes_ -= bytes_deleted; 1546 size_in_bytes_ -= bytes_deleted;
1547 total_bytes_deleted += bytes_deleted; 1547 total_bytes_deleted += bytes_deleted;
1548 // We're removing buffers from the back, so push each removed buffer to the 1548 // We're removing buffers from the back, so push each removed buffer to the
1549 // front of |deleted_buffers| so that |deleted_buffers| are in nondecreasing 1549 // front of |deleted_buffers| so that |deleted_buffers| are in nondecreasing
1550 // order. 1550 // order.
1551 deleted_buffers->push_front(buffers_.back()); 1551 deleted_buffers->push_front(buffers_.back());
1552 buffers_.pop_back(); 1552 buffers_.pop_back();
1553 } 1553 }
1554 1554
1555 return total_bytes_deleted; 1555 return total_bytes_deleted;
(...skipping 23 matching lines...) Expand all
1579 KeyframeMap::const_iterator last_gop = keyframe_map_.end(); 1579 KeyframeMap::const_iterator last_gop = keyframe_map_.end();
1580 --last_gop; 1580 --last_gop;
1581 return last_gop->second - keyframe_map_index_base_ <= next_buffer_index_; 1581 return last_gop->second - keyframe_map_index_base_ <= next_buffer_index_;
1582 } 1582 }
1583 1583
1584 void SourceBufferRange::FreeBufferRange( 1584 void SourceBufferRange::FreeBufferRange(
1585 const BufferQueue::iterator& starting_point, 1585 const BufferQueue::iterator& starting_point,
1586 const BufferQueue::iterator& ending_point) { 1586 const BufferQueue::iterator& ending_point) {
1587 for (BufferQueue::iterator itr = starting_point; 1587 for (BufferQueue::iterator itr = starting_point;
1588 itr != ending_point; ++itr) { 1588 itr != ending_point; ++itr) {
1589 size_in_bytes_ -= (*itr)->GetDataSize(); 1589 size_in_bytes_ -= (*itr)->data_size();
1590 DCHECK_GE(size_in_bytes_, 0); 1590 DCHECK_GE(size_in_bytes_, 0);
1591 } 1591 }
1592 buffers_.erase(starting_point, ending_point); 1592 buffers_.erase(starting_point, ending_point);
1593 } 1593 }
1594 1594
1595 void SourceBufferRange::TruncateAt( 1595 void SourceBufferRange::TruncateAt(
1596 const BufferQueue::iterator& starting_point, BufferQueue* removed_buffers) { 1596 const BufferQueue::iterator& starting_point, BufferQueue* removed_buffers) {
1597 DCHECK(!removed_buffers || removed_buffers->empty()); 1597 DCHECK(!removed_buffers || removed_buffers->empty());
1598 1598
1599 // Return if we're not deleting anything. 1599 // Return if we're not deleting anything.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 return start_timestamp; 1722 return start_timestamp;
1723 } 1723 }
1724 1724
1725 base::TimeDelta SourceBufferRange::GetEndTimestamp() const { 1725 base::TimeDelta SourceBufferRange::GetEndTimestamp() const {
1726 DCHECK(!buffers_.empty()); 1726 DCHECK(!buffers_.empty());
1727 return buffers_.back()->GetDecodeTimestamp(); 1727 return buffers_.back()->GetDecodeTimestamp();
1728 } 1728 }
1729 1729
1730 base::TimeDelta SourceBufferRange::GetBufferedEndTimestamp() const { 1730 base::TimeDelta SourceBufferRange::GetBufferedEndTimestamp() const {
1731 DCHECK(!buffers_.empty()); 1731 DCHECK(!buffers_.empty());
1732 base::TimeDelta duration = buffers_.back()->GetDuration(); 1732 base::TimeDelta duration = buffers_.back()->duration();
1733 if (duration == kNoTimestamp() || duration == base::TimeDelta()) 1733 if (duration == kNoTimestamp() || duration == base::TimeDelta())
1734 duration = GetApproximateDuration(); 1734 duration = GetApproximateDuration();
1735 return GetEndTimestamp() + duration; 1735 return GetEndTimestamp() + duration;
1736 } 1736 }
1737 1737
1738 base::TimeDelta SourceBufferRange::NextKeyframeTimestamp( 1738 base::TimeDelta SourceBufferRange::NextKeyframeTimestamp(
1739 base::TimeDelta timestamp) { 1739 base::TimeDelta timestamp) {
1740 DCHECK(!keyframe_map_.empty()); 1740 DCHECK(!keyframe_map_.empty());
1741 1741
1742 if (timestamp < GetStartTimestamp() || timestamp >= GetBufferedEndTimestamp()) 1742 if (timestamp < GetStartTimestamp() || timestamp >= GetBufferedEndTimestamp())
(...skipping 26 matching lines...) Expand all
1769 return ComputeFudgeRoom(GetApproximateDuration()); 1769 return ComputeFudgeRoom(GetApproximateDuration());
1770 } 1770 }
1771 1771
1772 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { 1772 base::TimeDelta SourceBufferRange::GetApproximateDuration() const {
1773 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); 1773 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run();
1774 DCHECK(max_interbuffer_distance != kNoTimestamp()); 1774 DCHECK(max_interbuffer_distance != kNoTimestamp());
1775 return max_interbuffer_distance; 1775 return max_interbuffer_distance;
1776 } 1776 }
1777 1777
1778 } // namespace media 1778 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/pipeline_integration_test.cc ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698