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

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

Issue 1235403002: Change ChunkDemuxerStream/SourceBufferStream memory limit to size_t type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A few more DCHECKs Created 5 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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void AbortReads(); 158 void AbortReads();
159 void Seek(TimeDelta seek_time); 159 void Seek(TimeDelta seek_time);
160 void CompletePendingReadIfPossible(); 160 void CompletePendingReadIfPossible();
161 void OnSetDuration(TimeDelta duration); 161 void OnSetDuration(TimeDelta duration);
162 void MarkEndOfStream(); 162 void MarkEndOfStream();
163 void UnmarkEndOfStream(); 163 void UnmarkEndOfStream();
164 void Shutdown(); 164 void Shutdown();
165 // Sets the memory limit on each stream of a specific type. 165 // Sets the memory limit on each stream of a specific type.
166 // |memory_limit| is the maximum number of bytes each stream of type |type| 166 // |memory_limit| is the maximum number of bytes each stream of type |type|
167 // is allowed to hold in its buffer. 167 // is allowed to hold in its buffer.
168 void SetMemoryLimits(DemuxerStream::Type type, int memory_limit); 168 void SetMemoryLimits(DemuxerStream::Type type, size_t memory_limit);
169 bool IsSeekWaitingForData() const; 169 bool IsSeekWaitingForData() const;
170 170
171 private: 171 private:
172 // Called by the |stream_parser_| when a new initialization segment is 172 // Called by the |stream_parser_| when a new initialization segment is
173 // encountered. 173 // encountered.
174 // Returns true on a successful call. Returns false if an error occurred while 174 // Returns true on a successful call. Returns false if an error occurred while
175 // processing decoder configurations. 175 // processing decoder configurations.
176 bool OnNewConfigs(bool allow_audio, bool allow_video, 176 bool OnNewConfigs(bool allow_audio, bool allow_video,
177 const AudioDecoderConfig& audio_config, 177 const AudioDecoderConfig& audio_config,
178 const VideoDecoderConfig& video_config, 178 const VideoDecoderConfig& video_config,
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 if (video_) 507 if (video_)
508 video_->Shutdown(); 508 video_->Shutdown();
509 509
510 for (TextStreamMap::iterator itr = text_stream_map_.begin(); 510 for (TextStreamMap::iterator itr = text_stream_map_.begin();
511 itr != text_stream_map_.end(); ++itr) { 511 itr != text_stream_map_.end(); ++itr) {
512 itr->second->Shutdown(); 512 itr->second->Shutdown();
513 } 513 }
514 } 514 }
515 515
516 void SourceState::SetMemoryLimits(DemuxerStream::Type type, int memory_limit) { 516 void SourceState::SetMemoryLimits(DemuxerStream::Type type,
517 size_t memory_limit) {
517 switch (type) { 518 switch (type) {
518 case DemuxerStream::AUDIO: 519 case DemuxerStream::AUDIO:
519 if (audio_) 520 if (audio_)
520 audio_->set_memory_limit(memory_limit); 521 audio_->SetMemoryLimit(memory_limit);
521 break; 522 break;
522 case DemuxerStream::VIDEO: 523 case DemuxerStream::VIDEO:
523 if (video_) 524 if (video_)
524 video_->set_memory_limit(memory_limit); 525 video_->SetMemoryLimit(memory_limit);
525 break; 526 break;
526 case DemuxerStream::TEXT: 527 case DemuxerStream::TEXT:
527 for (TextStreamMap::iterator itr = text_stream_map_.begin(); 528 for (TextStreamMap::iterator itr = text_stream_map_.begin();
528 itr != text_stream_map_.end(); ++itr) { 529 itr != text_stream_map_.end(); ++itr) {
529 itr->second->set_memory_limit(memory_limit); 530 itr->second->SetMemoryLimit(memory_limit);
530 } 531 }
531 break; 532 break;
532 case DemuxerStream::UNKNOWN: 533 case DemuxerStream::UNKNOWN:
533 case DemuxerStream::NUM_TYPES: 534 case DemuxerStream::NUM_TYPES:
534 NOTREACHED(); 535 NOTREACHED();
535 break; 536 break;
536 } 537 }
537 } 538 }
538 539
539 bool SourceState::IsSeekWaitingForData() const { 540 bool SourceState::IsSeekWaitingForData() const {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 VideoRotation ChunkDemuxerStream::video_rotation() { 1019 VideoRotation ChunkDemuxerStream::video_rotation() {
1019 return VIDEO_ROTATION_0; 1020 return VIDEO_ROTATION_0;
1020 } 1021 }
1021 1022
1022 TextTrackConfig ChunkDemuxerStream::text_track_config() { 1023 TextTrackConfig ChunkDemuxerStream::text_track_config() {
1023 CHECK_EQ(type_, TEXT); 1024 CHECK_EQ(type_, TEXT);
1024 base::AutoLock auto_lock(lock_); 1025 base::AutoLock auto_lock(lock_);
1025 return stream_->GetCurrentTextTrackConfig(); 1026 return stream_->GetCurrentTextTrackConfig();
1026 } 1027 }
1027 1028
1029 void ChunkDemuxerStream::SetMemoryLimit(size_t memory_limit) {
1030 stream_->SetMemoryLimit(memory_limit);
1031 }
1032
1028 void ChunkDemuxerStream::SetLiveness(Liveness liveness) { 1033 void ChunkDemuxerStream::SetLiveness(Liveness liveness) {
1029 base::AutoLock auto_lock(lock_); 1034 base::AutoLock auto_lock(lock_);
1030 liveness_ = liveness; 1035 liveness_ = liveness;
1031 } 1036 }
1032 1037
1033 void ChunkDemuxerStream::ChangeState_Locked(State state) { 1038 void ChunkDemuxerStream::ChangeState_Locked(State state) {
1034 lock_.AssertAcquired(); 1039 lock_.AssertAcquired();
1035 DVLOG(1) << "ChunkDemuxerStream::ChangeState_Locked() : " 1040 DVLOG(1) << "ChunkDemuxerStream::ChangeState_Locked() : "
1036 << "type " << type_ 1041 << "type " << type_
1037 << " - " << state_ << " -> " << state; 1042 << " - " << state_ << " -> " << state;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 return; 1585 return;
1581 1586
1582 ShutdownAllStreams(); 1587 ShutdownAllStreams();
1583 1588
1584 ChangeState_Locked(SHUTDOWN); 1589 ChangeState_Locked(SHUTDOWN);
1585 1590
1586 if(!seek_cb_.is_null()) 1591 if(!seek_cb_.is_null())
1587 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_ERROR_ABORT); 1592 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_ERROR_ABORT);
1588 } 1593 }
1589 1594
1590 void ChunkDemuxer::SetMemoryLimits(DemuxerStream::Type type, int memory_limit) { 1595 void ChunkDemuxer::SetMemoryLimits(DemuxerStream::Type type,
1596 size_t memory_limit) {
1591 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1597 for (SourceStateMap::iterator itr = source_state_map_.begin();
1592 itr != source_state_map_.end(); ++itr) { 1598 itr != source_state_map_.end(); ++itr) {
1593 itr->second->SetMemoryLimits(type, memory_limit); 1599 itr->second->SetMemoryLimits(type, memory_limit);
1594 } 1600 }
1595 } 1601 }
1596 1602
1597 void ChunkDemuxer::ChangeState_Locked(State new_state) { 1603 void ChunkDemuxer::ChangeState_Locked(State new_state) {
1598 lock_.AssertAcquired(); 1604 lock_.AssertAcquired();
1599 DVLOG(1) << "ChunkDemuxer::ChangeState_Locked() : " 1605 DVLOG(1) << "ChunkDemuxer::ChangeState_Locked() : "
1600 << state_ << " -> " << new_state; 1606 << state_ << " -> " << new_state;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 } 1837 }
1832 1838
1833 void ChunkDemuxer::ShutdownAllStreams() { 1839 void ChunkDemuxer::ShutdownAllStreams() {
1834 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1840 for (SourceStateMap::iterator itr = source_state_map_.begin();
1835 itr != source_state_map_.end(); ++itr) { 1841 itr != source_state_map_.end(); ++itr) {
1836 itr->second->Shutdown(); 1842 itr->second->Shutdown();
1837 } 1843 }
1838 } 1844 }
1839 1845
1840 } // namespace media 1846 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698