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

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

Issue 7867051: Introduce AudioDecoderConfig to migrate away from GetAVStream(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: samples_per_second Created 9 years, 3 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/audio_renderer_base_unittest.cc ('k') | media/filters/chunk_demuxer_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implements a Demuxer that can switch among different data sources mid-stream. 5 // Implements a Demuxer that can switch among different data sources mid-stream.
6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of 6 // Uses FFmpegDemuxer under the covers, so see the caveats at the top of
7 // ffmpeg_demuxer.h. 7 // ffmpeg_demuxer.h.
8 8
9 #include "media/filters/chunk_demuxer.h" 9 #include "media/filters/chunk_demuxer.h"
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void AddBuffers(const BufferQueue& buffers); 73 void AddBuffers(const BufferQueue& buffers);
74 void Shutdown(); 74 void Shutdown();
75 75
76 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const; 76 bool GetLastBufferTimestamp(base::TimeDelta* timestamp) const;
77 77
78 // DemuxerStream methods. 78 // DemuxerStream methods.
79 virtual void Read(const ReadCallback& read_callback); 79 virtual void Read(const ReadCallback& read_callback);
80 virtual Type type(); 80 virtual Type type();
81 virtual void EnableBitstreamConverter(); 81 virtual void EnableBitstreamConverter();
82 virtual AVStream* GetAVStream(); 82 virtual AVStream* GetAVStream();
83 virtual const AudioDecoderConfig& audio_decoder_config();
83 84
84 private: 85 private:
85 static void RunCallback(ReadCallback cb, scoped_refptr<Buffer> buffer); 86 static void RunCallback(ReadCallback cb, scoped_refptr<Buffer> buffer);
86 87
87 Type type_; 88 Type type_;
88 AVStream* av_stream_; 89 AVStream* av_stream_;
90 AudioDecoderConfig audio_config_;
89 91
90 mutable base::Lock lock_; 92 mutable base::Lock lock_;
91 ReadCBQueue read_cbs_; 93 ReadCBQueue read_cbs_;
92 BufferQueue buffers_; 94 BufferQueue buffers_;
93 bool shutdown_called_; 95 bool shutdown_called_;
94 bool received_end_of_stream_; 96 bool received_end_of_stream_;
95 97
96 // Keeps track of the timestamp of the last buffer we have 98 // Keeps track of the timestamp of the last buffer we have
97 // added to |buffers_|. This is used to enforce buffers with strictly 99 // added to |buffers_|. This is used to enforce buffers with strictly
98 // monotonically increasing timestamps. 100 // monotonically increasing timestamps.
99 base::TimeDelta last_buffer_timestamp_; 101 base::TimeDelta last_buffer_timestamp_;
100 102
101 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); 103 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream);
102 }; 104 };
103 105
104 ChunkDemuxerStream::ChunkDemuxerStream(Type type, AVStream* stream) 106 ChunkDemuxerStream::ChunkDemuxerStream(Type type, AVStream* stream)
105 : type_(type), 107 : type_(type),
106 av_stream_(stream), 108 av_stream_(stream),
107 shutdown_called_(false), 109 shutdown_called_(false),
108 received_end_of_stream_(false), 110 received_end_of_stream_(false),
109 last_buffer_timestamp_(kNoTimestamp) { 111 last_buffer_timestamp_(kNoTimestamp) {
112 if (type_ == AUDIO) {
113 AVCodecContextToAudioDecoderConfig(stream->codec, &audio_config_);
114 }
110 } 115 }
111 116
112 ChunkDemuxerStream::~ChunkDemuxerStream() {} 117 ChunkDemuxerStream::~ChunkDemuxerStream() {}
113 118
114 void ChunkDemuxerStream::Flush() { 119 void ChunkDemuxerStream::Flush() {
115 VLOG(1) << "Flush()"; 120 VLOG(1) << "Flush()";
116 base::AutoLock auto_lock(lock_); 121 base::AutoLock auto_lock(lock_);
117 buffers_.clear(); 122 buffers_.clear();
118 received_end_of_stream_ = false; 123 received_end_of_stream_ = false;
119 last_buffer_timestamp_ = kNoTimestamp; 124 last_buffer_timestamp_ = kNoTimestamp;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 DCHECK(buffer.get()); 279 DCHECK(buffer.get());
275 read_callback.Run(buffer); 280 read_callback.Run(buffer);
276 } 281 }
277 282
278 DemuxerStream::Type ChunkDemuxerStream::type() { return type_; } 283 DemuxerStream::Type ChunkDemuxerStream::type() { return type_; }
279 284
280 void ChunkDemuxerStream::EnableBitstreamConverter() {} 285 void ChunkDemuxerStream::EnableBitstreamConverter() {}
281 286
282 AVStream* ChunkDemuxerStream::GetAVStream() { return av_stream_; } 287 AVStream* ChunkDemuxerStream::GetAVStream() { return av_stream_; }
283 288
289 const AudioDecoderConfig& ChunkDemuxerStream::audio_decoder_config() {
290 CHECK_EQ(type_, AUDIO);
291 return audio_config_;
292 }
293
284 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client) 294 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client)
285 : state_(WAITING_FOR_INIT), 295 : state_(WAITING_FOR_INIT),
286 client_(client), 296 client_(client),
287 format_context_(NULL), 297 format_context_(NULL),
288 buffered_bytes_(0), 298 buffered_bytes_(0),
289 seek_waits_for_data_(true) { 299 seek_waits_for_data_(true) {
290 DCHECK(client); 300 DCHECK(client);
291 } 301 }
292 302
293 ChunkDemuxer::~ChunkDemuxer() { 303 ChunkDemuxer::~ChunkDemuxer() {
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 base::AutoUnlock auto_unlock(lock_); 724 base::AutoUnlock auto_unlock(lock_);
715 if (cb.is_null()) { 725 if (cb.is_null()) {
716 host()->SetError(error); 726 host()->SetError(error);
717 return; 727 return;
718 } 728 }
719 cb.Run(error); 729 cb.Run(error);
720 } 730 }
721 } 731 }
722 732
723 } // namespace media 733 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_renderer_base_unittest.cc ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698