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

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

Issue 10067035: RefCounted types should not have public destructors, media/ and gpu/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/dummy_demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 class ChunkDemuxerStream : public DemuxerStream { 118 class ChunkDemuxerStream : public DemuxerStream {
119 public: 119 public:
120 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; 120 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
121 typedef std::deque<ReadCB> ReadCBQueue; 121 typedef std::deque<ReadCB> ReadCBQueue;
122 typedef std::deque<base::Closure> ClosureQueue; 122 typedef std::deque<base::Closure> ClosureQueue;
123 123
124 explicit ChunkDemuxerStream(const AudioDecoderConfig& audio_config); 124 explicit ChunkDemuxerStream(const AudioDecoderConfig& audio_config);
125 explicit ChunkDemuxerStream(const VideoDecoderConfig& video_config); 125 explicit ChunkDemuxerStream(const VideoDecoderConfig& video_config);
126 virtual ~ChunkDemuxerStream();
127 126
128 void Flush(); 127 void Flush();
129 void Seek(base::TimeDelta time); 128 void Seek(base::TimeDelta time);
130 129
131 // Checks if it is ok to add the |buffers| to the stream. 130 // Checks if it is ok to add the |buffers| to the stream.
132 bool CanAddBuffers(const BufferQueue& buffers) const; 131 bool CanAddBuffers(const BufferQueue& buffers) const;
133 132
134 void AddBuffers(const BufferQueue& buffers); 133 void AddBuffers(const BufferQueue& buffers);
135 void Shutdown(); 134 void Shutdown();
136 135
137 // Gets the time range buffered by this object. 136 // Gets the time range buffered by this object.
138 // Returns true if there is buffered data. |start_out| & |end_out| are set to 137 // Returns true if there is buffered data. |start_out| & |end_out| are set to
139 // the start and end time of the buffered data respectively. 138 // the start and end time of the buffered data respectively.
140 // Returns false if no data is buffered. 139 // Returns false if no data is buffered.
141 bool GetBufferedRange(base::TimeDelta* start_out, 140 bool GetBufferedRange(base::TimeDelta* start_out,
142 base::TimeDelta* end_out) const; 141 base::TimeDelta* end_out) const;
143 142
144 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const; 143 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const;
145 144
146 // DemuxerStream methods. 145 // DemuxerStream methods.
147 virtual void Read(const ReadCB& read_cb) OVERRIDE; 146 virtual void Read(const ReadCB& read_cb) OVERRIDE;
148 virtual Type type() OVERRIDE; 147 virtual Type type() OVERRIDE;
149 virtual void EnableBitstreamConverter() OVERRIDE; 148 virtual void EnableBitstreamConverter() OVERRIDE;
150 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; 149 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE;
151 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; 150 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE;
152 151
152 protected:
153 virtual ~ChunkDemuxerStream();
154
153 private: 155 private:
154 enum State { 156 enum State {
155 RETURNING_DATA_FOR_READS, 157 RETURNING_DATA_FOR_READS,
156 WAITING_FOR_SEEK, 158 WAITING_FOR_SEEK,
157 RECEIVED_EOS_WHILE_WAITING_FOR_SEEK, // EOS = End of stream. 159 RECEIVED_EOS_WHILE_WAITING_FOR_SEEK, // EOS = End of stream.
158 RECEIVED_EOS, 160 RECEIVED_EOS,
159 RETURNING_EOS_FOR_READS, 161 RETURNING_EOS_FOR_READS,
160 SHUTDOWN, 162 SHUTDOWN,
161 }; 163 };
162 164
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 198 }
197 199
198 200
199 ChunkDemuxerStream::ChunkDemuxerStream(const VideoDecoderConfig& video_config) 201 ChunkDemuxerStream::ChunkDemuxerStream(const VideoDecoderConfig& video_config)
200 : type_(VIDEO), 202 : type_(VIDEO),
201 state_(RETURNING_DATA_FOR_READS), 203 state_(RETURNING_DATA_FOR_READS),
202 last_buffer_timestamp_(kNoTimestamp()) { 204 last_buffer_timestamp_(kNoTimestamp()) {
203 video_config_.CopyFrom(video_config); 205 video_config_.CopyFrom(video_config);
204 } 206 }
205 207
206 ChunkDemuxerStream::~ChunkDemuxerStream() {}
207
208 void ChunkDemuxerStream::Flush() { 208 void ChunkDemuxerStream::Flush() {
209 DVLOG(1) << "Flush()"; 209 DVLOG(1) << "Flush()";
210 ReadCBQueue read_cbs; 210 ReadCBQueue read_cbs;
211 { 211 {
212 base::AutoLock auto_lock(lock_); 212 base::AutoLock auto_lock(lock_);
213 buffers_.clear(); 213 buffers_.clear();
214 ChangeState_Locked(WAITING_FOR_SEEK); 214 ChangeState_Locked(WAITING_FOR_SEEK);
215 last_buffer_timestamp_ = kNoTimestamp(); 215 last_buffer_timestamp_ = kNoTimestamp();
216 216
217 std::swap(read_cbs_, read_cbs); 217 std::swap(read_cbs_, read_cbs);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 const VideoDecoderConfig& ChunkDemuxerStream::video_decoder_config() { 410 const VideoDecoderConfig& ChunkDemuxerStream::video_decoder_config() {
411 CHECK_EQ(type_, VIDEO); 411 CHECK_EQ(type_, VIDEO);
412 return video_config_; 412 return video_config_;
413 } 413 }
414 414
415 void ChunkDemuxerStream::ChangeState_Locked(State state) { 415 void ChunkDemuxerStream::ChangeState_Locked(State state) {
416 lock_.AssertAcquired(); 416 lock_.AssertAcquired();
417 state_ = state; 417 state_ = state;
418 } 418 }
419 419
420 ChunkDemuxerStream::~ChunkDemuxerStream() {}
421
420 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) { 422 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) {
421 lock_.AssertAcquired(); 423 lock_.AssertAcquired();
422 // Wrap & store |read_cb| so that it will 424 // Wrap & store |read_cb| so that it will
423 // get called on the current MessageLoop. 425 // get called on the current MessageLoop.
424 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb, 426 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb,
425 MessageLoop::current())); 427 MessageLoop::current()));
426 } 428 }
427 429
428 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) { 430 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) {
429 lock_.AssertAcquired(); 431 lock_.AssertAcquired();
(...skipping 23 matching lines...) Expand all
453 455
454 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client) 456 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client)
455 : state_(WAITING_FOR_INIT), 457 : state_(WAITING_FOR_INIT),
456 host_(NULL), 458 host_(NULL),
457 client_(client), 459 client_(client),
458 buffered_bytes_(0), 460 buffered_bytes_(0),
459 seek_waits_for_data_(true) { 461 seek_waits_for_data_(true) {
460 DCHECK(client); 462 DCHECK(client);
461 } 463 }
462 464
463 ChunkDemuxer::~ChunkDemuxer() {
464 DCHECK_NE(state_, INITIALIZED);
465 }
466
467 void ChunkDemuxer::Initialize(DemuxerHost* host, 465 void ChunkDemuxer::Initialize(DemuxerHost* host,
468 const PipelineStatusCB& cb) { 466 const PipelineStatusCB& cb) {
469 DVLOG(1) << "Init()"; 467 DVLOG(1) << "Init()";
470 { 468 {
471 base::AutoLock auto_lock(lock_); 469 base::AutoLock auto_lock(lock_);
472 DCHECK_EQ(state_, WAITING_FOR_INIT); 470 DCHECK_EQ(state_, WAITING_FOR_INIT);
473 host_ = host; 471 host_ = host;
474 472
475 ChangeState_Locked(INITIALIZING); 473 ChangeState_Locked(INITIALIZING);
476 init_cb_ = cb; 474 init_cb_ = cb;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 cb.Run(PIPELINE_ERROR_ABORT); 804 cb.Run(PIPELINE_ERROR_ABORT);
807 805
808 client_->DemuxerClosed(); 806 client_->DemuxerClosed();
809 } 807 }
810 808
811 void ChunkDemuxer::ChangeState_Locked(State new_state) { 809 void ChunkDemuxer::ChangeState_Locked(State new_state) {
812 lock_.AssertAcquired(); 810 lock_.AssertAcquired();
813 state_ = new_state; 811 state_ = new_state;
814 } 812 }
815 813
814 ChunkDemuxer::~ChunkDemuxer() {
815 DCHECK_NE(state_, INITIALIZED);
816 }
817
816 void ChunkDemuxer::ReportError_Locked(PipelineStatus error) { 818 void ChunkDemuxer::ReportError_Locked(PipelineStatus error) {
817 lock_.AssertAcquired(); 819 lock_.AssertAcquired();
818 DCHECK_NE(error, PIPELINE_OK); 820 DCHECK_NE(error, PIPELINE_OK);
819 821
820 ChangeState_Locked(PARSE_ERROR); 822 ChangeState_Locked(PARSE_ERROR);
821 823
822 PipelineStatusCB cb; 824 PipelineStatusCB cb;
823 825
824 if (!init_cb_.is_null()) { 826 if (!init_cb_.is_null()) {
825 std::swap(cb, init_cb_); 827 std::swap(cb, init_cb_);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 return true; 915 return true;
914 } 916 }
915 917
916 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data, 918 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data,
917 int init_data_size) { 919 int init_data_size) {
918 client_->KeyNeeded(init_data.Pass(), init_data_size); 920 client_->KeyNeeded(init_data.Pass(), init_data_size);
919 return true; 921 return true;
920 } 922 }
921 923
922 } // namespace media 924 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/dummy_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698